Fragment shader for unsigned integer textures

I am using following shader for unsigned integer textures to read a data:
Fragment shader:


out uvec4 fragColor;
uniform uint factor;
void main()
{
uint temp=factor;
temp=temp/2;
fragColor = uvec4(temp,temp,temp,temp);
}

But i am getting error on driver A:
“Compile failed.
ERROR: 0:7: ‘/’ : Wrong operand types. No operation ‘/’ exists that takes a left-hand operand of type ‘uint’ and a right operand of type ‘const int’ (and there is no acceptable conversion)
ERROR: 1 compilation errors. No code generated.”

on AMD it runs perfectly… Is driver A is buggy?

Instead

temp=temp/2;

use

temp=temp/2u;

and always keep your eye on signed/unsigned operands: paragraph 4.1.10 “Implicit conversions” of GLSL spec says:

There are no implicit conversions between signed and unsigned integers.

and always keep your eye on signed/unsigned operands: paragraph 4.1.10 “Implicit conversions” of GLSL spec says: “There are no implicit conversions between signed and unsigned integers”

This is true of the GLSL specs earlier than 4.0. GLSL 4.0 added an implicit conversion from signed to unsigned. AMD seems to use the same compiler for all shader versions when it comes to syntax and conversions, so you get these more advanced features whether you want them or not (another example is a swizzle on a float). Nvidia’s GLSL compiler is more strict in this regard, so unless you specify #version 400, implicit int->uint conversions are not supported.

Thanks, it got worked… :slight_smile:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.