[BUG REPORT] issue with texelFetch on a MSAA depth stencil texture

Discussion created by xtremer on Dec 25, 2011
Latest reply on Apr 25, 2012 by karen.zeng
texelFetch on a MSAA depth stencil texture does not work under all circumstances

Hello there,

I think I discovered a bug in AMD's implementation of GLSL's texelFetch(). I'll try to explain briefly what I am doing and will add only a few code snippets:

1. Create a MSAA FBO A with a MSAA color and depth stencil texture attached and render the scene to this FBO A:



2. Bind the depth texture from FBO A to texture unit 0 and execute a shader which uses the texture to render to another FBO B (for example a depth buffer linearization):


#version 150 core

uniform sampler2DMS u_Texture0;

void main(void)
  float Z = texelFetch(u_Texture0, ivec2(gl_FragCoord.xy), 0).x;
  float Z_Linear = 2.0 * u_ZNear / (u_ZFar + u_ZNear - Z * (u_ZFar - u_ZNear));
  f_Color = vec4(Z_Linear, Z_Linear, Z_Linear, 1.0);


3. Activate another FBO C and another shader which has a MSAA color texture bound to texture unit 0 and the same MSAA depth texture from step 1 bound to texture unit 1:


#version 150 core

uniform sampler2DMS u_Texture0;
uniform sampler2DMS u_Texture1;
void main(void)
  f_Color = texelFetch(u_Texture0, ivec2(gl_FragCoord.xy), 0);
  float Z = texelFetch(u_Texture1, ivec2(gl_FragCoord.xy), 0).x;




Now what happens is, that the texelFetch() in step 3 returns bulls**t. But if I reverse the order in step 3 and bind the depth texture to texture unit 0 and the color texture to texture unit 1 while fetching the color from u_Texture1 and the depth value from u_Texture0, then everything is cool. In this case the textelFetch returns correct values.

So I really have the feeling there is a bug in the driver? For some reason when you attach the depth stencil texture to the second unit while it was previously bound to the first unit you get this effect.

Help is really appreciated!




Driver Packaging Version    8.92-111109a-129966C-ATI
Catalyst Version    11.12
2D Driver Version
OpenGL Version
Catalyst Control Center Version    2011.1109.2212.39826


Graphics Card Manufacturer    Powered by AMD
Graphics Chipset    ATI Radeon HD 5800 Series
Device ID    6899
Vendor    1002
Subsystem ID    E140
Subsystem Vendor ID    174B
Graphics Bus Capability    PCI Express 2.0
Maximum Bus Setting    PCI Express 2.0 x16
BIOS Version
BIOS Part Number    113-C00140-00X
BIOS Date    2010/03/09
Memory Size    1024 MB
Memory Type    GDDR5
Core Clock in MHz    725 MHz
Memory Clock in MHz    1000 MHz
Total Memory Bandwidth in GByte/s    128,0 GByte/s