Imagination PowerVR SDK Blog

Can I use the GCMP instruction on a GLSL shader?


#1

Hi,
I’m currently working on a GLSL compute shader to convert RAW camera images to sRGB color space.
I’ve read the PowerVR Instruction Set Reference and I’ve found the GCMP and GEXP instructions but I don’t know how to instruct the compiler to use them from GLSL code.

I’m looking for these instructions mostly because my naïve implementation of gamma compression (based from here ) costs about 20 cycles!

Typing pow(x, 1.0 / 2.2) on PVRShaderEditor (and other possible combinations around pow(); ) doesn’t hint the compiler to use the GCMP instruction, for example.

Is there some way to use these instructions, like a OpenGL extension?
Right now, I wouldn’t mind to have my code to only work under Series 6 GPUs.

Thank you in advance!


#2

Hi,

have you tried the sRGB extensions?
https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB_decode.txt
https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_sRGB.txt

These should instruct the compiler to sample the texture using sRGB decoding.
It might not show up in the offline compiler because I wouldn’t know that you’re sampling an sRGB texture.

bests,
Marton