GLSL pack/unpack


Is it possible to use some kind of pk2h/pk4ub/etc… like instructions under GLSL on NVidia cards? I’m working on a deferred shading algorithm and I’ve used the NV_fragment_program extension until now. I found a short description of the EXT_Cg_shader extension, but it only says that we can use the Cg standard library functions in a GLSL program.

Any help would be appreciated…

from Cg_Toolkit.pdf (1.2):

float pack_2half(float2 a);
float pack_2half(half2 a);
half2 unpack_2half(float a);

float pack_2ushort(float2 a);
float pack_2ushort(half2 a);
float2 unpack_2ushort(float a);

float pack_4byte(float4 a);
float pack_4byte(half4 a);
half4 unpack_4byte(float a);

float pack_4ubyte(float4 a);
float pack_4ubyte(half4 a);
half4 unpack_4ubyte(float a);

Thanks, I’ve already knew this, so the question really is that is there any way to use them, or some similar functions under GLSL.

Yes, all of the Cg stdlib functions are exposed in the NVIDIA GLSL implementation. Just call the unpack functions the same way you would in a Cg shader.

It seems that NVIDIA GLSL compiler does not recognize pack/unpack functions anymore. As a result, my programs fail to start on GF8800 with 97.xx drivers. Is it a bug or intended behaviour?

have a bang on this:-;f=11;t=000944#000000

Thanks! I wonder how fast this code is in comparison with native PK4UB/UP4UB.