Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
zeux opened this issue Oct 22, 2018 · 9 comments
Closed

Comments

@zeux
Copy link
Contributor

zeux commented Oct 22, 2018

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

@johnkslang
Copy link
Member

This was apparently fixed by #1507, as now the behavior is to get an error for doing this is a fragment shader.

@zeux
Copy link
Contributor Author

zeux commented Oct 25, 2018

Sorry I’m confused. This fragment shader is valid. Are you saying glslang trunk now fails to compile it?

@johnkslang
Copy link
Member

Ah, tracing through the other links, this issue was supposed to be to allow the fragment stage to do this, as requested by @sparmarNV.

@johnkslang johnkslang reopened this Oct 25, 2018
@johnkslang johnkslang assigned zeux and unassigned zeux Oct 25, 2018
@johnkslang
Copy link
Member

The description is highly confusing, as the issue is supposed to be about allowing the fragment shader to compile this, yet it starts by showing invalid SPIR-V output rather than a compilation error.

I can't assign to @sparmarNV, but with 3 recent mentions, this is a clear virtual assignment.

@sparmarNV
Copy link
Contributor

Hi John, I have a fix for this coming up.

@zeux
Copy link
Contributor Author

zeux commented Oct 26, 2018

@johnkslang I feel like we're talking about different things. This issue is not about allowing the fragment shader to compile - it already does compile. When compiling this fragment shader, the SPIRV blob is generated - but this blob doesn't contain the SPV_NV_mesh_shader extension, which causes validation layers to reject the SPIRV as being invalid. This is on glslang build from the most recent Vulkan SDK as of this writing, 1.1.85.0 (glslang version 7.10.2904).

@sparmarNV
Copy link
Contributor

@zeux the newer version of glslang incorrectly added a check to error out use of GL_NV_mesh_shader in fragment shader. The version you are using with Vulkan SDK still allows compilation but fails to emit OpExtension string. I hope this clears the confusion.
I have the fix up for review PR #1549
This will allow use of GL_NV_mesh_shader in fragment shader and emit relevant OpExtension and OpCapability declarations.

@sparmarNV
Copy link
Contributor

@zeux PR #1549 has been merged. Can you verify and close this? Thank you.

@zeux
Copy link
Contributor Author

zeux commented Oct 26, 2018

@sparmarNV Thanks! I've built the shader on latest glslang and SPIRV looks good to me - I'll close this.

@zeux zeux closed this as completed Oct 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants