KhronosGroup / glslang

Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.
Other
3.07k stars 841 forks source link

raypayloadNV usage warning #1638

Open georgeouzou opened 5 years ago

georgeouzou commented 5 years ago

Hello, I had this the following rchit shader:

#version 460
#extension GL_NV_ray_tracing : require

struct HitInfo
{
    vec4 color_dist;
};

layout(location = 0) rayPayloadNV HitInfo payload;
hitAttributeNV vec2 bary;

void main()
{
    vec3 barys = vec3(1.0f - bary.x - bary.y, bary.x, bary.y);

    const vec3 A = vec3(1.0, 0.0, 0.0);
    const vec3 B = vec3(0.0, 1.0, 0.0);
    const vec3 C = vec3(0.0, 0.0, 1.0);
    vec3 hit_color = A * barys.x + B * barys.y + C * barys.z;
    payload.color_dist = vec4(hit_color, 0.0);
}

The code compiles without warnings with glslValidator.exe but the driver crashes on vkCreateRayTracingPipelinesNV without any validation warning. The right thing to do was to use rayPayloadInNV. Can the glslValidator catch such issues?

glslValidator version: Glslang Version: 7.10.2984 ESSL Version: OpenGL ES GLSL 3.20 glslang Khronos. 10.2984 GLSL Version: 4.60 glslang Khronos. 10.2984 SPIR-V Version 0x00010300, Revision 1 GLSL.std.450 Version 100, Revision 1 Khronos Tool ID 8 SPIR-V Generator Version 7 GL_KHR_vulkan_glsl version 100 ARB_GL_gl_spirv version 100

johnkslang commented 5 years ago

@dgkoch, any input here?

ewerness-nv commented 5 years ago

The crash in the driver should be fixed now, though the fundamental problem is still there (it'll just not work correctly instead of crashing)

[below edited with a correction]

A closest hit shader with no functional rayPayloadInNV is allowed, but the trace call has to have one identified, so because of the matching rules, the closest hit shader has to have one, even if it's just an empty structure, so that's probably the best thing to warn on.