AnsweredAssumed Answered

Black screen when sampling texture in AMD cards (not Nvdia)

Question asked by khanhhh89 on Nov 17, 2016
Latest reply on Nov 22, 2016 by dwitczak

My program use QtOpenGL to draw a sphere and color it by sampling a texture in a single draw call. It works on Nvdia cards, but when I switch to AMD cards (my laptop and other laptops), it show a black screen. (Note: it only failed with AMD Catalyst Software Suite driver, but works with the AMD Radeon Software Crimson Edition Beta driver at this link).

Here is the normal picture on Nvdia cards, and the black bug picture on AMD cards.






It seems to be a texture sampling bug (not framebuffer bug) because OpenGL draws normally when I use a simple shading method (color = dot(vertexPixelNormal, lightDirection)) as the following picture.


I use CodeXL from AMD for debugging, and when I click on the texture ID from the CodeXL explorer view, it show exactly my image (Does it mean that my image is updated to GPU successfully?). Here is the OpenGL calls log.

Note: You can't see the function glTextureStorage2DEXT before glTextureSubImage2D in the log because CodeXL doesn't log glTextureStorage2DEXT, which is used by QtOpenGL. I debug step by step and ensure that this function is called.


Here is the texture property from CodeXL property view



Here is the fragment shader

#version 150 core

uniform sampler2D matcapTexture

vec3 matcapColor
(vec3 eye, vec3 normal)
  vec3 reflected
= reflect(eye, normal);

float m = 2.0 * sqrt(
(reflected.x, 2.0) +
(reflected.y, 2.0) +
(reflected.z + 1.0, 2.0)
  vec2 uv
=  reflected.xy / m + 0.5;
.y = 1.0 - uv.y;
return texture(matcapTexture, uv).xyz;

in vec4 fragInput
;  //vec4(eyePosition, depth)

void main()
  vec3 n 
= normalize(cross(dFdx(, dFdy(;   //calculate vertex pixel normal by dfdx,dfdy
const vec3 LightDirection = vec3(0.0f, 0.0f, -1.0f);
  vec3 fragColor
= matcapColor(LightDirection, n);
[0]   = vec4(fragColor.x, fragColor.y, fragColor.z, 1.0f);

I spent several days for this bug but can't find any clues. Hope you guys could help me show what's incorrect here. Did I do something that AMD didn't expect?