KhronosGroup / glslang

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

SPIR-V Validation Errors when using Vulkan Relaxed Rules #3549

Open RozeFound opened 3 months ago

RozeFound commented 3 months ago

Somehow it generates this error

error: [VUID-StandaloneSpirv-Flat-04744] Fragment OpEntryPoint operand 22 with Input interfaces with integer or float type must have a Flat decoration for Entry Point id 4.
  %gl_VertexIndex = OpVariable %_ptr_Input_int Input

Fragment Shader

#version 450

precision highp float;

in vec2 fragTexCoord;

uniform sampler2D texSampler;

out vec4 diffuseColor;

void main() {
    diffuseColor = texture(texSampler, fragTexCoord);
}

Assembly generated

; SPIR-V
; Version: 1.6
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 24
; Schema: 0
               OpCapability Shader
          %1 = OpExtInstImport "GLSL.std.450"
               OpMemoryModel Logical GLSL450
               OpEntryPoint Fragment %main "main" %diffuseColor %texSampler %fragTexCoord %gl_VertexIndex %gl_InstanceIndex
               OpExecutionMode %main OriginUpperLeft
               OpSource GLSL 450
               OpName %main "main"
               OpName %diffuseColor "diffuseColor"
               OpName %texSampler "texSampler"
               OpName %fragTexCoord "fragTexCoord"
               OpName %gl_VertexIndex "gl_VertexIndex"
               OpName %gl_InstanceIndex "gl_InstanceIndex"
               OpDecorate %diffuseColor Location 0
               OpDecorate %texSampler DescriptorSet 0
               OpDecorate %texSampler Binding 1
               OpDecorate %fragTexCoord Location 0
               OpDecorate %gl_VertexIndex BuiltIn VertexIndex
               OpDecorate %gl_InstanceIndex BuiltIn InstanceIndex
       %void = OpTypeVoid
          %3 = OpTypeFunction %void
      %float = OpTypeFloat 32
    %v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%diffuseColor = OpVariable %_ptr_Output_v4float Output
         %10 = OpTypeImage %float 2D 0 0 0 1 Unknown
         %11 = OpTypeSampledImage %10
%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
 %texSampler = OpVariable %_ptr_UniformConstant_11 UniformConstant
    %v2float = OpTypeVector %float 2
%_ptr_Input_v2float = OpTypePointer Input %v2float
%fragTexCoord = OpVariable %_ptr_Input_v2float Input
        %int = OpTypeInt 32 1
%_ptr_Input_int = OpTypePointer Input %int
%gl_VertexIndex = OpVariable %_ptr_Input_int Input
%gl_InstanceIndex = OpVariable %_ptr_Input_int Input
       %main = OpFunction %void None %3
          %5 = OpLabel
         %14 = OpLoad %11 %texSampler
         %18 = OpLoad %v2float %fragTexCoord
         %19 = OpImageSampleImplicitLod %v4float %14 %18
               OpStore %diffuseColor %19
               OpReturn
               OpFunctionEnd