I have this shader and whenever it's used it crashes the driver in the next draw call :
precision highp float;
uniform highp sampler2DMS Texture0;
uniform highp sampler2DMS Texture1;
in highp vec2 OutTexcoord;
uniform vec2 Texture0Size;
uniform float NumSamples;
layout(location = 0) out vec4 FragColor;
void main()
{
vec4 FinalColor = vec4(0, 1, 0, 0.5);
//texelFetch acts like D3D Texture::Load
vec2 TextureSpaceCoords = vec2( OutTexcoord.x * Texture0Size.x, OutTexcoord.y * Texture0Size.y );
vec4 ColorSum = vec4( 0, 0, 0, 0 );
for(int i=0; i<NumSamples; i++)
ColorSum += texelFetch( Texture0, ivec2( TextureSpaceCoords.x, TextureSpaceCoords.y), i );
ColorSum = ColorSum / NumSamples;
vec4 Depth = texelFetch( Texture1, ivec2( TextureSpaceCoords.x, TextureSpaceCoords.y), 0 );//.x;
//FragColor = vec4( Depth, Depth, Depth, 1.0 );
FragColor = FinalColor;//vec4(Depth,Depth,Depth,Depth);//FinalColor;
gl_FragDepth = Depth.x;
}
Ofcourse the shader isn't exactly correct though crashes should never happen. After correction I get a black screen with this :
precision highp float;
uniform highp sampler2DMS Texture0;
uniform highp sampler2DMS Texture1;
in highp vec2 OutTexcoord;
uniform vec2 Texture0Size;
uniform float NumSamples;
layout(location = 0) out vec4 FragColor;
void main()
{
vec4 FinalColor = vec4(0, 1, 0, 0.5);
//texelFetch acts like D3D Texture::Load
vec2 TextureSpaceCoords = vec2( OutTexcoord.x * Texture0Size.x, OutTexcoord.y * Texture0Size.y );
vec4 ColorSum = vec4( 0, 0, 0, 0 );
for(int i=0; i<NumSamples; i++)
ColorSum += texelFetch( Texture0, ivec2( TextureSpaceCoords.x, TextureSpaceCoords.y), i );
FinalColor = ColorSum / NumSamples;
vec4 Depth = texelFetch( Texture1, ivec2( TextureSpaceCoords.x, TextureSpaceCoords.y), 0 );//.x;
//FragColor = vec4( Depth, Depth, Depth, 1.0 );
FragColor = FinalColor;//vec4(Depth,Depth,Depth,Depth);//FinalColor;
gl_FragDepth = Depth.x;
}
EDIT : I solved my own issue : I ran it under an Android device and it reported that the for loop compared ints with floats, changing
uniform float NumSamples;
to
uniform int NumSamples;
solves the black screen issue.
Can i try this code?
I haven't saved a copy of the app code + shaders for this, I'm sorry, but I do have repro cases for other unanswered issues around here.
hi cippyboy,
can you tell us your graphics card info?
and your system is linux or windows?
i compiled your above 2 shaders on my PC as fragment shader,
no error or crash generated.
regards
davy
The crash is when you try to draw with it, not when compiling the shaders. I have a R9 280X and 14.12 drivers
hi cippyboy,
can you share the project with me?
so that i can solve your issue more quickly.
regards
davy
hi cippyboy,
i tried following shader, can't reproduce your issue (use the shader to draw).
with R9 285 & HD7950 (tahiti)
// GLSL
#version 440 compatibility
out vec4 s_frag_color;
layout(rgba32f) uniform sampler2DMS image01;
uniform float numSamp;
void main()
{
vec4 v1 = vec4(0.0);
for (int i = 0; i < numSamp; i++)
{
v1 += texelFetch(image01, ivec2(0,0), i);
}
s_frag_color = v1;
}
// end of GLSL
thank you anyway.
regards
davy