Quantcast
Channel: AMD Developer Forums: Message List - OpenGL & Vulkan
Viewing all articles
Browse latest Browse all 631

Multisample resolve shader crash

$
0
0

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.


Viewing all articles
Browse latest Browse all 631

Trending Articles