PDA

View Full Version : Samplers in uniform buffer objects



Vexator
08-26-2010, 03:01 AM
I'd like to store samplers in a uniform buffer object. According to the wiki, this should be fine:


uniform Textures
{
sampler2D diffuseTexture;
};

However, my NVidia driver complains that:


error C7554: OpenGL requires samplers to be explicitly declared as uniform

Did I miss something? Do I have to add the keyword uniform a 2nd time?!

trinitrotoluene
08-26-2010, 06:42 AM
In this wiki (http://www.opengl.org/wiki/GLSL_Uniform) it is written that samplers cannot be part of uniform block. I have tested it with an ati card and here the info log:


Fragment shader failed to compile with the following errors:
ERROR: 0:18: error(#6) Extension error: usage incorrect Sampler can be not in uniform block
ERROR: error(#273) 0 compilation errors. No code generated

Groovounet
08-26-2010, 07:09 AM
I don't know where you found this because, no, sampler should not be place in uniform block.

Vexator
08-26-2010, 07:48 AM
Well it seems that it's neither supported by nv nor ati atm. I don't see why, though.

Alfonse Reinheart
08-26-2010, 08:10 AM
Well it seems that it's neither supported by nv nor ati atm. I don't see why, though.

Because that's what the OpenGL specification says. It was probably a mistake for GLSL to consider samplers to be "uniforms" to begin with, rather than their own special kind of thing. But because samplers are not really uniforms in the same way that vec3s or mat4s are uniforms, they cannot be in uniform blocks.

randall
10-21-2010, 05:39 AM
And what about structs? Can sampler be in a structure?