Unexpected failures in the neck of the volcano geometry

I am having unexpected crashes when doing float mappings in the Volcano 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 seems to fall with the condition:

if(maxDist < 0.01)

When I remove this condition, the code runs without problems. If I change the threshold value from 0.01 to a larger one, for example 0.1 or 1, the code will work again without problems.

Note that I am using glslangValidator.exe from VulkanSDK to compile shader code. Verification errors are not issued with the exception of the warning:

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

, , GPU ( ), .

+4
1

. ( Radeon Driver Packaging Version 16.50.2011-161219a-309792E) LunarG Vulkan SDK (1.0.37.0) . . AMD Radeon R9 380 Series.

+1

Source: https://habr.com/ru/post/1665296/


All Articles