Unexpected crashes in Vulkan geometry shader

465 views Asked by At

I am experiencing odd crashes when doing float comparisons in a Vulkan geometry shader. The shader code is as follows:

#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable

layout (triangles) in;
layout (triangle_strip,  max_vertices=3) out;

layout(binding = 0) uniform UniformBufferObject {
    mat4 modelView;
    mat4 staticModelView;
} ubo;

in vec2 texCoordGeom[];

layout(location = 0) out vec2 texCoord;

void main() {
    float dist0 = length(gl_in[0].gl_Position.xyz - gl_in[1].gl_Position.xyz);
    float dist1 = length(gl_in[1].gl_Position.xyz - gl_in[2].gl_Position.xyz);
    float dist2 = length(gl_in[0].gl_Position.xyz - gl_in[2].gl_Position.xyz);

    float maxDist = max(dist0, max(dist1, dist2));

    if(maxDist < 0.01) {
        gl_Position = ubo.modelView * gl_in[0].gl_Position;
        texCoord = texCoordGeom[0];
        EmitVertex();

        gl_Position = ubo.modelView * gl_in[1].gl_Position;
        texCoord = texCoordGeom[1];
        EmitVertex();

        gl_Position = ubo.modelView * gl_in[2].gl_Position;
        texCoord = texCoordGeom[2];
        EmitVertex();
        EndPrimitive();
    }
}

It appears to crash at the conditional:

if(maxDist < 0.01)

When I remove this conditional the code runs without issues. If I change the value of the threshold from 0.01 to something larger, such as 0.1 or 1, again the code runs without issues.

Note that I am using the glslangValidator.exe from the VulkanSDK to compile the shader code. No validation errors are thrown except for the warning:

Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.

Also note that no helpful errors are thrown when the program does crash as the entire GPU freezes (screen goes black momentarily) and the program exits.

1

There are 1 answers

0
grouma On BEST ANSWER

For future readers this appeared to be a driver issue. Since updating to the latest driver (Radeon Driver Packaging Version 16.50.2011-161219a-309792E) along with the latest LunarG Vulkan SDK (1.0.37.0) the problem has resolved itself. Note I was running on an AMD Radeon R9 380 Series.