Skip to content

Fragment shader with perprimitiveNV doesn't have OpExtension SPV_NV_mesh_shader #1541

@zeux

Description

@zeux

Compiling the following fragment shader:

#version 450

#extension GL_NV_mesh_shader: require

layout(location = 0) out vec4 outputColor;

layout(location = 0) in vec4 color;
layout(location = 1) in perprimitiveNV vec3 triangleNormal;

void main()
{
	outputColor = color;
}

Produces the following SPIRV:

; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 7
; Bound: 16
; Schema: 0
               OpCapability Shader
          %1 = OpExtInstImport "GLSL.std.450"
               OpMemoryModel Logical GLSL450
               OpEntryPoint Fragment %main "main" %outputColor %color %triangleNormal
               OpExecutionMode %main OriginUpperLeft
               OpSource GLSL 450
               OpSourceExtension "GL_NV_mesh_shader"
               OpName %main "main"
               OpName %outputColor "outputColor"
               OpName %color "color"
               OpName %triangleNormal "triangleNormal"
               OpDecorate %outputColor Location 0
               OpDecorate %color Location 0
               OpDecorate %triangleNormal PerPrimitiveNV
               OpDecorate %triangleNormal Location 1
       %void = OpTypeVoid
          %3 = OpTypeFunction %void
      %float = OpTypeFloat 32
    %v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%outputColor = OpVariable %_ptr_Output_v4float Output
%_ptr_Input_v4float = OpTypePointer Input %v4float
      %color = OpVariable %_ptr_Input_v4float Input
    %v3float = OpTypeVector %float 3
%_ptr_Input_v3float = OpTypePointer Input %v3float
%triangleNormal = OpVariable %_ptr_Input_v3float Input
       %main = OpFunction %void None %3
          %5 = OpLabel
         %12 = OpLoad %v4float %color
               OpStore %outputColor %12
               OpReturn
               OpFunctionEnd

The SPIRV uses PerPrimitiveNV decoration that is declared in SPV_NV_mesh_shader extension, but SPIRV doesn't require it - it only mentions source extension and doesn't have OpExtension SPV_NV_mesh_shader. This produces a validation error, initially filed here KhronosGroup/Vulkan-ValidationLayers#414

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions