Hi everyone,
I'm currently testing shader storage buffer object on my HD 7950 (catalyst 14.4 / Windows 7 x64) and I'm having a strange issue :
I currently need to access some data stored in a SSBO from my fragment shader and, if the code works well on a GTX690, i can't get it to work on my AMD card :
To test if the data are correct in my buffer, i created a simple rendering of a quad that displays the data grid on screen using a vertex and a fragment shader :
-> a simple texture coordinate (which is in fact the fragment coord) is passed from the vertex to the fragment and is used to draw a 10x10 grid.
Thing is, if i don't use the SSBO, everything is fine and the grid is correctly displayed, but if i try to access the SSBO data inside the fragment, the openGL compiler throws me this error when I call glUseProgramStages with the fragment shader:
textureCoordinates' s data type or qualifier doesn't match between vertex shader and fragment shader
Vertex Shader :
#version 430 /** * Basic vertex shader for FBO rendering */ out gl_PerVertex { vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[]; }; layout (location = 0) in vec3 Position; out vec3 textureCoordinates; void main() { gl_Position = vec4(Position,1.0); textureCoordinates = 0.5*(Position.xyz+1.0); }
Fragment shader
#version 430 in vec3 textureCoordinates; out vec4 Color; struct SSBOStructure { vec4 data; }; layout (binding=0) buffer SSBO { int nbData; SSBOStructure datas[]; }; void main() { Color = vec4(0.0); vec2 cellPos = textureCoordinates.xy * 10; vec2 delta = fract(cellPos); cellPos = floor(cellPos); if(delta.x < 0.01 || delta.x > 0.99 || delta.y < 0.01 || delta.y > 0.99) { Color = vec4(1.0); } if(cellPos.x == 0 && cellPos.y == 0) { Color = vec4(datas[0].data); // if this line is commented, everythings ok } }
I've seen other discussion that report issues with SSBO on AMD cards so i know that this kind of buffer is kinda still "experimental" on AMD devices, but did anyone had this issue before, or does anyone have an idea of what is wrong with my fragment shader that makes it unsuitable for AMD cards ?
Edit : I just have tested multiple SSBOs binding and access in fragment shader using a grid computed with gl_FragCoord instead of interpolated texture coords, and deleting the in and out vec3 textureCoordinates. It works well in that case, so my guess is the use of SSBO somehow breaks the interpolated variable between stages for the compiler (maybe the memory layout of the interpolated data).