diff --git a/SPIRV/GLSL.ext.NV.h b/SPIRV/GLSL.ext.NV.h index 89f0a5c03..e93c9f7e1 100644 --- a/SPIRV/GLSL.ext.NV.h +++ b/SPIRV/GLSL.ext.NV.h @@ -1,5 +1,5 @@ /* -** Copyright (c) 2014-2016 The Khronos Group Inc. +** Copyright (c) 2014-2017 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a copy ** of this software and/or associated documentation files (the "Materials"), @@ -33,7 +33,7 @@ enum Op; enum Capability; static const int GLSLextNVVersion = 100; -static const int GLSLextNVRevision = 4; +static const int GLSLextNVRevision = 5; //SPV_NV_sample_mask_override_coverage const char* const E_SPV_NV_sample_mask_override_coverage = "SPV_NV_sample_mask_override_coverage"; @@ -71,4 +71,13 @@ static const BuiltIn BuiltInSecondaryViewportMaskNV = static_cast(5258) static const Capability CapabilityShaderStereoViewNV = static_cast(5259); + +//SPV_NVX_multiview_per_view_attributes +const char* const E_SPV_NVX_multiview_per_view_attributes = "SPV_NVX_multiview_per_view_attributes"; + +static const BuiltIn BuiltInPositionPerViewNV = static_cast(5260); +static const BuiltIn BuiltInViewportMaskPerViewNV = static_cast(5261); + +static const Capability CapabilityPerViewAttributesNV = static_cast(5262); + #endif // #ifndef GLSLextNV_H \ No newline at end of file diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 02609d01e..1a300b525 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -642,6 +642,14 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI builder.addExtension(spv::E_SPV_NV_stereo_view_rendering); builder.addCapability(spv::CapabilityShaderStereoViewNV); return spv::BuiltInSecondaryViewportMaskNV; + case glslang::EbvPositionPerViewNV: + builder.addExtension(spv::E_SPV_NVX_multiview_per_view_attributes); + builder.addCapability(spv::CapabilityPerViewAttributesNV); + return spv::BuiltInPositionPerViewNV; + case glslang::EbvViewportMaskPerViewNV: + builder.addExtension(spv::E_SPV_NVX_multiview_per_view_attributes); + builder.addCapability(spv::CapabilityPerViewAttributesNV); + return spv::BuiltInViewportMaskPerViewNV; #endif default: return spv::BuiltInMax; } @@ -2384,6 +2392,11 @@ void TGlslangToSpvTraverser::decorateStructType(const glslang::TType& type, builder.addExtension(spv::E_SPV_NV_stereo_view_rendering); } } + if (glslangMember.getQualifier().layoutPassthrough) { + addMemberDecoration(spvType, member, (spv::Decoration)spv::DecorationPassthroughNV); + builder.addCapability(spv::CapabilityGeometryShaderPassthroughNV); + builder.addExtension(spv::E_SPV_NV_geometry_shader_passthrough); + } #endif } } @@ -2661,6 +2674,8 @@ void TGlslangToSpvTraverser::declareUseOfStructMember(const glslang::TTypeList& case glslang::EbvViewportMaskNV: case glslang::EbvSecondaryPositionNV: case glslang::EbvSecondaryViewportMaskNV: + case glslang::EbvPositionPerViewNV: + case glslang::EbvViewportMaskPerViewNV: #endif // Generate the associated capability. Delegate to TranslateBuiltInDecoration. // Alternately, we could just call this for any glslang built-in, since the diff --git a/SPIRV/disassemble.cpp b/SPIRV/disassemble.cpp index 74ae40767..c950a66a0 100644 --- a/SPIRV/disassemble.cpp +++ b/SPIRV/disassemble.cpp @@ -483,7 +483,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode, #ifdef NV_EXTENSIONS }else if (strcmp(spv::E_SPV_NV_sample_mask_override_coverage, name) == 0 || strcmp(spv::E_SPV_NV_geometry_shader_passthrough, name) == 0 || - strcmp(spv::E_SPV_NV_viewport_array2, name) == 0) { + strcmp(spv::E_SPV_NV_viewport_array2, name) == 0 || + strcmp(spv::E_SPV_NVX_multiview_per_view_attributes, name) == 0) { extInstSet = GLSLextNVInst; #endif } @@ -659,7 +660,8 @@ static const char* GLSLextNVGetDebugNames(const char* name, unsigned entrypoint) if (strcmp(name, spv::E_SPV_NV_sample_mask_override_coverage) == 0 || strcmp(name, spv::E_SPV_NV_geometry_shader_passthrough) == 0 || strcmp(name, spv::E_ARB_shader_viewport_layer_array) == 0 || - strcmp(name, spv::E_SPV_NV_viewport_array2) == 0){ + strcmp(name, spv::E_SPV_NV_viewport_array2) == 0 || + strcmp(spv::E_SPV_NVX_multiview_per_view_attributes, name) == 0) { switch (entrypoint) { case DecorationOverrideCoverageNV: return "OverrideCoverageNV"; case DecorationPassthroughNV: return "PassthroughNV"; @@ -671,6 +673,9 @@ static const char* GLSLextNVGetDebugNames(const char* name, unsigned entrypoint) case BuiltInSecondaryPositionNV: return "SecondaryPositionNV"; case BuiltInSecondaryViewportMaskNV: return "SecondaryViewportMaskNV"; case CapabilityShaderStereoViewNV: return "ShaderStereoViewNV"; + case BuiltInPositionPerViewNV: return "PositionPerViewNV"; + case BuiltInViewportMaskPerViewNV: return "ViewportMaskPerViewNV"; + case CapabilityPerViewAttributesNV: return "PerViewAttributesNV"; default: return "Bad"; } } diff --git a/SPIRV/doc.cpp b/SPIRV/doc.cpp index 871809978..b0351e495 100755 --- a/SPIRV/doc.cpp +++ b/SPIRV/doc.cpp @@ -344,6 +344,8 @@ const char* BuiltInString(int builtIn) case 5253: return "ViewportMaskNV"; case 5257: return "SecondaryPositionNV"; case 5258: return "SecondaryViewportMaskNV"; + case 5260: return "PositionPerViewNV"; + case 5261: return "ViewportMaskPerViewNV"; #endif } } diff --git a/Test/baseResults/310.tesc.out b/Test/baseResults/310.tesc.out index d004fa166..89be51e6a 100644 --- a/Test/baseResults/310.tesc.out +++ b/Test/baseResults/310.tesc.out @@ -71,8 +71,8 @@ ERROR: node is still EOpNull! 0:25 move second child to first child (temp highp 4-component vector of float) 0:25 'p' (temp highp 4-component vector of float) 0:25 gl_Position: direct index for structure (in highp 4-component vector of float Position) -0:25 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV}) -0:25 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV}) +0:25 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV, in implicitly-sized array of highp 4-component vector of float gl_PositionPerViewNV}) +0:25 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV, in implicitly-sized array of highp 4-component vector of float gl_PositionPerViewNV}) 0:25 Constant: 0:25 1 (const int) 0:25 Constant: @@ -81,8 +81,8 @@ ERROR: node is still EOpNull! 0:26 move second child to first child (temp highp float) 0:26 'ps' (temp highp float) 0:26 gl_PointSize: direct index for structure (in highp float PointSize) -0:26 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV}) -0:26 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV}) +0:26 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV, in implicitly-sized array of highp 4-component vector of float gl_PositionPerViewNV}) +0:26 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV, in implicitly-sized array of highp 4-component vector of float gl_PositionPerViewNV}) 0:26 Constant: 0:26 1 (const int) 0:26 Constant: @@ -210,8 +210,8 @@ ERROR: node is still EOpNull! 0:114 move second child to first child (temp highp float) 0:114 'ps' (temp highp float) 0:114 gl_PointSize: direct index for structure (in highp float PointSize) -0:114 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV}) -0:114 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV}) +0:114 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV, in implicitly-sized array of highp 4-component vector of float gl_PositionPerViewNV}) +0:114 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV, in implicitly-sized array of highp 4-component vector of float gl_PositionPerViewNV}) 0:114 Constant: 0:114 1 (const int) 0:114 Constant: @@ -402,8 +402,8 @@ ERROR: node is still EOpNull! 0:25 move second child to first child (temp highp 4-component vector of float) 0:25 'p' (temp highp 4-component vector of float) 0:25 gl_Position: direct index for structure (in highp 4-component vector of float Position) -0:25 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV}) -0:25 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV}) +0:25 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV, in 1-element array of highp 4-component vector of float gl_PositionPerViewNV}) +0:25 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV, in 1-element array of highp 4-component vector of float gl_PositionPerViewNV}) 0:25 Constant: 0:25 1 (const int) 0:25 Constant: @@ -412,8 +412,8 @@ ERROR: node is still EOpNull! 0:26 move second child to first child (temp highp float) 0:26 'ps' (temp highp float) 0:26 gl_PointSize: direct index for structure (in highp float PointSize) -0:26 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV}) -0:26 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV}) +0:26 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV, in 1-element array of highp 4-component vector of float gl_PositionPerViewNV}) +0:26 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV, in 1-element array of highp 4-component vector of float gl_PositionPerViewNV}) 0:26 Constant: 0:26 1 (const int) 0:26 Constant: diff --git a/Test/baseResults/310.tese.out b/Test/baseResults/310.tese.out index c6ce6650b..aa0d8b126 100644 --- a/Test/baseResults/310.tese.out +++ b/Test/baseResults/310.tese.out @@ -78,8 +78,8 @@ ERROR: node is still EOpNull! 0:36 move second child to first child (temp highp 4-component vector of float) 0:36 'p' (temp highp 4-component vector of float) 0:36 gl_Position: direct index for structure (in highp 4-component vector of float Position) -0:36 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV}) -0:36 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV}) +0:36 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV, in implicitly-sized array of highp 4-component vector of float gl_PositionPerViewNV}) +0:36 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV, in implicitly-sized array of highp 4-component vector of float gl_PositionPerViewNV}) 0:36 Constant: 0:36 1 (const int) 0:36 Constant: @@ -88,8 +88,8 @@ ERROR: node is still EOpNull! 0:37 move second child to first child (temp highp float) 0:37 'ps' (temp highp float) 0:37 gl_PointSize: direct index for structure (in highp float PointSize) -0:37 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV}) -0:37 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV}) +0:37 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV, in implicitly-sized array of highp 4-component vector of float gl_PositionPerViewNV}) +0:37 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV, in implicitly-sized array of highp 4-component vector of float gl_PositionPerViewNV}) 0:37 Constant: 0:37 1 (const int) 0:37 Constant: @@ -211,8 +211,8 @@ ERROR: node is still EOpNull! 0:36 move second child to first child (temp highp 4-component vector of float) 0:36 'p' (temp highp 4-component vector of float) 0:36 gl_Position: direct index for structure (in highp 4-component vector of float Position) -0:36 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV}) -0:36 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV}) +0:36 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV, in 1-element array of highp 4-component vector of float gl_PositionPerViewNV}) +0:36 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV, in 1-element array of highp 4-component vector of float gl_PositionPerViewNV}) 0:36 Constant: 0:36 1 (const int) 0:36 Constant: @@ -221,8 +221,8 @@ ERROR: node is still EOpNull! 0:37 move second child to first child (temp highp float) 0:37 'ps' (temp highp float) 0:37 gl_PointSize: direct index for structure (in highp float PointSize) -0:37 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV}) -0:37 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV}) +0:37 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV, in 1-element array of highp 4-component vector of float gl_PositionPerViewNV}) +0:37 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV, in 1-element array of highp 4-component vector of float gl_PositionPerViewNV}) 0:37 Constant: 0:37 1 (const int) 0:37 Constant: diff --git a/Test/baseResults/spv.multiviewPerViewAttributes.tesc.out b/Test/baseResults/spv.multiviewPerViewAttributes.tesc.out new file mode 100644 index 000000000..61b38c8bc --- /dev/null +++ b/Test/baseResults/spv.multiviewPerViewAttributes.tesc.out @@ -0,0 +1,78 @@ +spv.multiviewPerViewAttributes.tesc +Warning, version 450 is not yet complete; most version-specific features are present, but some are missing. + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 37 + + Capability Tessellation + Capability Bad + Extension "SPV_NVX_multiview_per_view_attributes" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint TessellationControl 4 "main" 17 19 31 + ExecutionMode 4 OutputVertices 4 + Source GLSL 450 + SourceExtension "GL_NVX_multiview_per_view_attributes" + Name 4 "main" + Name 13 "gl_PerVertex" + MemberName 13(gl_PerVertex) 0 "gl_PositionPerViewNV" + MemberName 13(gl_PerVertex) 1 "gl_ViewportMaskPerViewNV" + Name 17 "gl_out" + Name 19 "gl_InvocationID" + Name 27 "gl_PerVertex" + MemberName 27(gl_PerVertex) 0 "gl_Position" + MemberName 27(gl_PerVertex) 1 "gl_PointSize" + MemberName 27(gl_PerVertex) 2 "gl_ClipDistance" + MemberName 27(gl_PerVertex) 3 "gl_CullDistance" + MemberName 27(gl_PerVertex) 4 "gl_SecondaryPositionNV" + MemberName 27(gl_PerVertex) 5 "gl_PositionPerViewNV" + Name 31 "gl_in" + MemberDecorate 13(gl_PerVertex) 0 BuiltIn PositionPerViewNV + MemberDecorate 13(gl_PerVertex) 1 BuiltIn ViewportMaskPerViewNV + Decorate 13(gl_PerVertex) Block + Decorate 19(gl_InvocationID) BuiltIn InvocationId + MemberDecorate 27(gl_PerVertex) 0 BuiltIn Position + MemberDecorate 27(gl_PerVertex) 1 BuiltIn PointSize + MemberDecorate 27(gl_PerVertex) 2 BuiltIn ClipDistance + MemberDecorate 27(gl_PerVertex) 3 BuiltIn CullDistance + Decorate 27(gl_PerVertex) Block + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypeInt 32 0 + 9: 8(int) Constant 1 + 10: TypeArray 7(fvec4) 9 + 11: TypeInt 32 1 + 12: TypeArray 11(int) 9 +13(gl_PerVertex): TypeStruct 10 12 + 14: 8(int) Constant 4 + 15: TypeArray 13(gl_PerVertex) 14 + 16: TypePointer Output 15 + 17(gl_out): 16(ptr) Variable Output + 18: TypePointer Input 11(int) +19(gl_InvocationID): 18(ptr) Variable Input + 21: 11(int) Constant 1 + 22: 11(int) Constant 0 + 23: TypePointer Output 11(int) + 26: TypeArray 6(float) 9 +27(gl_PerVertex): TypeStruct 7(fvec4) 6(float) 26 26 7(fvec4) 10 + 28: 8(int) Constant 32 + 29: TypeArray 27(gl_PerVertex) 28 + 30: TypePointer Input 29 + 31(gl_in): 30(ptr) Variable Input + 32: TypePointer Input 7(fvec4) + 35: TypePointer Output 7(fvec4) + 4(main): 2 Function None 3 + 5: Label + 20: 11(int) Load 19(gl_InvocationID) + 24: 23(ptr) AccessChain 17(gl_out) 20 21 22 + Store 24 21 + 25: 11(int) Load 19(gl_InvocationID) + 33: 32(ptr) AccessChain 31(gl_in) 21 22 + 34: 7(fvec4) Load 33 + 36: 35(ptr) AccessChain 17(gl_out) 25 22 22 + Store 36 34 + Return + FunctionEnd diff --git a/Test/baseResults/spv.multiviewPerViewAttributes.vert.out b/Test/baseResults/spv.multiviewPerViewAttributes.vert.out new file mode 100644 index 000000000..2f3df9b54 --- /dev/null +++ b/Test/baseResults/spv.multiviewPerViewAttributes.vert.out @@ -0,0 +1,62 @@ +spv.multiviewPerViewAttributes.vert +Warning, version 450 is not yet complete; most version-specific features are present, but some are missing. + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 29 + + Capability Shader + Capability Bad + Extension "SPV_NVX_multiview_per_view_attributes" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Vertex 4 "main" 11 20 24 + Source GLSL 450 + SourceExtension "GL_NVX_multiview_per_view_attributes" + Name 4 "main" + Name 11 "gl_ViewportMaskPerViewNV" + Name 20 "gl_PositionPerViewNV" + Name 22 "gl_PerVertex" + MemberName 22(gl_PerVertex) 0 "gl_Position" + MemberName 22(gl_PerVertex) 1 "gl_PointSize" + MemberName 22(gl_PerVertex) 2 "gl_ClipDistance" + MemberName 22(gl_PerVertex) 3 "gl_CullDistance" + Name 24 "" + Decorate 11(gl_ViewportMaskPerViewNV) BuiltIn ViewportMaskPerViewNV + Decorate 20(gl_PositionPerViewNV) BuiltIn PositionPerViewNV + MemberDecorate 22(gl_PerVertex) 0 BuiltIn Position + MemberDecorate 22(gl_PerVertex) 1 BuiltIn PointSize + MemberDecorate 22(gl_PerVertex) 2 BuiltIn ClipDistance + MemberDecorate 22(gl_PerVertex) 3 BuiltIn CullDistance + Decorate 22(gl_PerVertex) Block + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 1 + 7: TypeInt 32 0 + 8: 7(int) Constant 1 + 9: TypeArray 6(int) 8 + 10: TypePointer Output 9 +11(gl_ViewportMaskPerViewNV): 10(ptr) Variable Output + 12: 6(int) Constant 0 + 13: 6(int) Constant 1 + 14: TypePointer Output 6(int) + 16: TypeFloat 32 + 17: TypeVector 16(float) 4 + 18: TypeArray 17(fvec4) 8 + 19: TypePointer Output 18 +20(gl_PositionPerViewNV): 19(ptr) Variable Output + 21: TypeArray 16(float) 8 +22(gl_PerVertex): TypeStruct 17(fvec4) 16(float) 21 21 + 23: TypePointer Output 22(gl_PerVertex) + 24: 23(ptr) Variable Output + 25: TypePointer Output 17(fvec4) + 4(main): 2 Function None 3 + 5: Label + 15: 14(ptr) AccessChain 11(gl_ViewportMaskPerViewNV) 12 + Store 15 13 + 26: 25(ptr) AccessChain 24 12 + 27: 17(fvec4) Load 26 + 28: 25(ptr) AccessChain 20(gl_PositionPerViewNV) 12 + Store 28 27 + Return + FunctionEnd diff --git a/Test/baseResults/spv.stereoViewRendering.tesc.out b/Test/baseResults/spv.stereoViewRendering.tesc.out index c8f9642c1..5d5a3d0ba 100644 --- a/Test/baseResults/spv.stereoViewRendering.tesc.out +++ b/Test/baseResults/spv.stereoViewRendering.tesc.out @@ -3,7 +3,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre // Module Version 10000 // Generated by (magic number): 80001 -// Id's are bound by 38 +// Id's are bound by 39 Capability Geometry Capability Tessellation @@ -13,7 +13,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre Extension "SPV_NV_viewport_array2" 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 - EntryPoint TessellationControl 4 "main" 16 18 32 + EntryPoint TessellationControl 4 "main" 16 18 33 ExecutionMode 4 OutputVertices 4 Source GLSL 450 SourceExtension "GL_NV_stereo_view_rendering" @@ -25,13 +25,14 @@ Warning, version 450 is not yet complete; most version-specific features are pre MemberName 12(gl_PerVertex) 2 "gl_SecondaryViewportMaskNV" Name 16 "gl_out" Name 18 "gl_InvocationID" - Name 28 "gl_PerVertex" - MemberName 28(gl_PerVertex) 0 "gl_Position" - MemberName 28(gl_PerVertex) 1 "gl_PointSize" - MemberName 28(gl_PerVertex) 2 "gl_ClipDistance" - MemberName 28(gl_PerVertex) 3 "gl_CullDistance" - MemberName 28(gl_PerVertex) 4 "gl_SecondaryPositionNV" - Name 32 "gl_in" + Name 29 "gl_PerVertex" + MemberName 29(gl_PerVertex) 0 "gl_Position" + MemberName 29(gl_PerVertex) 1 "gl_PointSize" + MemberName 29(gl_PerVertex) 2 "gl_ClipDistance" + MemberName 29(gl_PerVertex) 3 "gl_CullDistance" + MemberName 29(gl_PerVertex) 4 "gl_SecondaryPositionNV" + MemberName 29(gl_PerVertex) 5 "gl_PositionPerViewNV" + Name 33 "gl_in" MemberDecorate 12(gl_PerVertex) 0 BuiltIn Layer MemberDecorate 12(gl_PerVertex) 0 ViewportRelativeNV MemberDecorate 12(gl_PerVertex) 0 SecondaryViewportRelativeNV 1 @@ -39,11 +40,11 @@ Warning, version 450 is not yet complete; most version-specific features are pre MemberDecorate 12(gl_PerVertex) 2 BuiltIn SecondaryViewportMaskNV Decorate 12(gl_PerVertex) Block Decorate 18(gl_InvocationID) BuiltIn InvocationId - MemberDecorate 28(gl_PerVertex) 0 BuiltIn Position - MemberDecorate 28(gl_PerVertex) 1 BuiltIn PointSize - MemberDecorate 28(gl_PerVertex) 2 BuiltIn ClipDistance - MemberDecorate 28(gl_PerVertex) 3 BuiltIn CullDistance - Decorate 28(gl_PerVertex) Block + MemberDecorate 29(gl_PerVertex) 0 BuiltIn Position + MemberDecorate 29(gl_PerVertex) 1 BuiltIn PointSize + MemberDecorate 29(gl_PerVertex) 2 BuiltIn ClipDistance + MemberDecorate 29(gl_PerVertex) 3 BuiltIn CullDistance + Decorate 29(gl_PerVertex) Block 2: TypeVoid 3: TypeFunction 2 6: TypeInt 32 1 @@ -65,22 +66,23 @@ Warning, version 450 is not yet complete; most version-specific features are pre 23: TypePointer Output 6(int) 26: 9(int) Constant 1 27: TypeArray 7(float) 26 -28(gl_PerVertex): TypeStruct 8(fvec4) 7(float) 27 27 8(fvec4) - 29: 9(int) Constant 32 - 30: TypeArray 28(gl_PerVertex) 29 - 31: TypePointer Input 30 - 32(gl_in): 31(ptr) Variable Input - 33: TypePointer Input 8(fvec4) - 36: TypePointer Output 8(fvec4) + 28: TypeArray 8(fvec4) 26 +29(gl_PerVertex): TypeStruct 8(fvec4) 7(float) 27 27 8(fvec4) 28 + 30: 9(int) Constant 32 + 31: TypeArray 29(gl_PerVertex) 30 + 32: TypePointer Input 31 + 33(gl_in): 32(ptr) Variable Input + 34: TypePointer Input 8(fvec4) + 37: TypePointer Output 8(fvec4) 4(main): 2 Function None 3 5: Label 19: 6(int) Load 18(gl_InvocationID) 24: 23(ptr) AccessChain 16(gl_out) 19 20 21 Store 24 22 25: 6(int) Load 18(gl_InvocationID) - 34: 33(ptr) AccessChain 32(gl_in) 22 21 - 35: 8(fvec4) Load 34 - 37: 36(ptr) AccessChain 16(gl_out) 25 22 - Store 37 35 + 35: 34(ptr) AccessChain 33(gl_in) 22 21 + 36: 8(fvec4) Load 35 + 38: 37(ptr) AccessChain 16(gl_out) 25 22 + Store 38 36 Return FunctionEnd diff --git a/Test/spv.multiviewPerViewAttributes.tesc b/Test/spv.multiviewPerViewAttributes.tesc new file mode 100644 index 000000000..a0dd64dfb --- /dev/null +++ b/Test/spv.multiviewPerViewAttributes.tesc @@ -0,0 +1,14 @@ +#version 450 + +#extension GL_NVX_multiview_per_view_attributes :require + +layout(vertices = 4) out; +out gl_PerVertex { + int gl_ViewportMaskPerViewNV[]; + vec4 gl_PositionPerViewNV[]; + } gl_out[]; +void main() +{ + gl_out[gl_InvocationID].gl_ViewportMaskPerViewNV[0] = 1; + gl_out[gl_InvocationID].gl_PositionPerViewNV[0] = gl_in[1].gl_Position; +} diff --git a/Test/spv.multiviewPerViewAttributes.vert b/Test/spv.multiviewPerViewAttributes.vert new file mode 100644 index 000000000..dd64a16c3 --- /dev/null +++ b/Test/spv.multiviewPerViewAttributes.vert @@ -0,0 +1,10 @@ +#version 450 + +#extension GL_NVX_multiview_per_view_attributes :require + +void main() +{ + gl_ViewportMaskPerViewNV[0] = 1; + gl_PositionPerViewNV[0] = gl_Position; +} + diff --git a/glslang/Include/BaseTypes.h b/glslang/Include/BaseTypes.h index 449e3aeac..f0e3c3781 100644 --- a/glslang/Include/BaseTypes.h +++ b/glslang/Include/BaseTypes.h @@ -207,6 +207,8 @@ enum TBuiltInVariable { EbvViewportMaskNV, EbvSecondaryPositionNV, EbvSecondaryViewportMaskNV, + EbvPositionPerViewNV, + EbvViewportMaskPerViewNV, #endif // HLSL built-ins that live only temporarily, until they get remapped // to one of the above. @@ -325,6 +327,8 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v) case EbvViewportMaskNV: return "ViewportMaskNV"; case EbvSecondaryPositionNV: return "SecondaryPositionNV"; case EbvSecondaryViewportMaskNV: return "SecondaryViewportMaskNV"; + case EbvPositionPerViewNV: return "PositionPerViewNV"; + case EbvViewportMaskPerViewNV: return "ViewportMaskPerViewNV"; #endif default: return "unknown built-in variable"; } diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h index 605f5f163..4a14843dc 100644 --- a/glslang/Include/Types.h +++ b/glslang/Include/Types.h @@ -1360,6 +1360,8 @@ public: case EbvViewportMaskNV: case EbvSecondaryPositionNV: case EbvSecondaryViewportMaskNV: + case EbvPositionPerViewNV: + case EbvViewportMaskPerViewNV: #endif return true; default: diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 287d6d69a..b9fa08255 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -3249,6 +3249,8 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV "out int gl_ViewportMask[];" "out int gl_SecondaryViewportMaskNV[];" "out vec4 gl_SecondaryPositionNV;" + "out vec4 gl_PositionPerViewNV[];" + "out int gl_ViewportMaskPerViewNV[];" ); #endif @@ -3313,6 +3315,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV "float gl_CullDistance[];" #ifdef NV_EXTENSIONS "vec4 gl_SecondaryPositionNV;" + "vec4 gl_PositionPerViewNV[];" #endif ); stageBuiltins[EShLangGeometry].append( @@ -3362,9 +3365,11 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV #ifdef NV_EXTENSIONS if (version >= 450) stageBuiltins[EShLangGeometry].append( - "out int gl_ViewportMask[];" - "out int gl_SecondaryViewportMaskNV[];" - "out vec4 gl_SecondaryPositionNV;" + "out int gl_ViewportMask[];" + "out int gl_SecondaryViewportMaskNV[];" + "out vec4 gl_SecondaryPositionNV;" + "out vec4 gl_PositionPerViewNV[];" + "out int gl_ViewportMaskPerViewNV[];" ); #endif @@ -3424,11 +3429,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV stageBuiltins[EShLangTessControl].append( "float gl_CullDistance[];" #ifdef NV_EXTENSIONS - "int gl_ViewportIndex;" - "int gl_Layer;" - "int gl_ViewportMask[];" + "int gl_ViewportIndex;" + "int gl_Layer;" + "int gl_ViewportMask[];" "vec4 gl_SecondaryPositionNV;" - "int gl_SecondaryViewportMaskNV[];" + "int gl_SecondaryViewportMaskNV[];" + "vec4 gl_PositionPerViewNV[];" + "int gl_ViewportMaskPerViewNV[];" #endif ); stageBuiltins[EShLangTessControl].append( @@ -3503,11 +3510,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV #ifdef NV_EXTENSIONS if (version >= 450) stageBuiltins[EShLangTessEvaluation].append( - "out int gl_ViewportIndex;" - "out int gl_Layer;" - "out int gl_ViewportMask[];" + "out int gl_ViewportIndex;" + "out int gl_Layer;" + "out int gl_ViewportMask[];" "out vec4 gl_SecondaryPositionNV;" - "out int gl_SecondaryViewportMaskNV[];" + "out int gl_SecondaryViewportMaskNV[];" + "out vec4 gl_PositionPerViewNV[];" + "out int gl_ViewportMaskPerViewNV[];" ); #endif @@ -4446,6 +4455,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf "highp float gl_PointSize;" #ifdef NV_EXTENSIONS "highp vec4 gl_SecondaryPositionNV;" + "highp vec4 gl_PositionPerViewNV[];" #endif "} gl_in[gl_MaxPatchVertices];" "\n"); @@ -4635,6 +4645,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf "float gl_CullDistance[];" #ifdef NV_EXTENSIONS "vec4 gl_SecondaryPositionNV;" + "vec4 gl_PositionPerViewNV[];" #endif ); s.append( @@ -5033,19 +5044,26 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion symbolTable.setVariableExtensions("gl_ViewportMask", 1, &E_GL_NV_viewport_array2); symbolTable.setVariableExtensions("gl_SecondaryPositionNV", 1, &E_GL_NV_stereo_view_rendering); symbolTable.setVariableExtensions("gl_SecondaryViewportMaskNV", 1, &E_GL_NV_stereo_view_rendering); + symbolTable.setVariableExtensions("gl_PositionPerViewNV", 1, &E_GL_NVX_multiview_per_view_attributes); + symbolTable.setVariableExtensions("gl_ViewportMaskPerViewNV", 1, &E_GL_NVX_multiview_per_view_attributes); BuiltInVariable("gl_ViewportMask", EbvViewportMaskNV, symbolTable); BuiltInVariable("gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable); BuiltInVariable("gl_SecondaryViewportMaskNV", EbvSecondaryViewportMaskNV, symbolTable); + BuiltInVariable("gl_PositionPerViewNV", EbvPositionPerViewNV, symbolTable); + BuiltInVariable("gl_ViewportMaskPerViewNV", EbvViewportMaskPerViewNV, symbolTable); - if (language != EShLangVertex) + if (language != EShLangVertex) { BuiltInVariable("gl_in", "gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable); - + BuiltInVariable("gl_in", "gl_PositionPerViewNV", EbvPositionPerViewNV, symbolTable); + } BuiltInVariable("gl_out", "gl_Layer", EbvLayer, symbolTable); BuiltInVariable("gl_out", "gl_ViewportIndex", EbvViewportIndex, symbolTable); BuiltInVariable("gl_out", "gl_ViewportMask", EbvViewportMaskNV, symbolTable); BuiltInVariable("gl_out", "gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable); BuiltInVariable("gl_out", "gl_SecondaryViewportMaskNV", EbvSecondaryViewportMaskNV, symbolTable); + BuiltInVariable("gl_out", "gl_PositionPerViewNV", EbvPositionPerViewNV, symbolTable); + BuiltInVariable("gl_out", "gl_ViewportMaskPerViewNV", EbvViewportMaskPerViewNV, symbolTable); #endif BuiltInVariable("gl_PatchVerticesIn", EbvPatchVertices, symbolTable); diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp index 9025e7612..6387538c4 100644 --- a/glslang/MachineIndependent/Versions.cpp +++ b/glslang/MachineIndependent/Versions.cpp @@ -201,6 +201,7 @@ void TParseVersions::initializeExtensionBehavior() extensionBehavior[E_GL_ARB_shader_viewport_layer_array] = EBhDisable; extensionBehavior[E_GL_NV_viewport_array2] = EBhDisable; extensionBehavior[E_GL_NV_stereo_view_rendering] = EBhDisable; + extensionBehavior[E_GL_NVX_multiview_per_view_attributes] = EBhDisable; #endif // AEP diff --git a/glslang/MachineIndependent/Versions.h b/glslang/MachineIndependent/Versions.h index cf8f5e23d..474e4106a 100644 --- a/glslang/MachineIndependent/Versions.h +++ b/glslang/MachineIndependent/Versions.h @@ -149,6 +149,7 @@ const char* const E_SPV_NV_geometry_shader_passthrough = "GL_NV_geometr const char* const E_GL_ARB_shader_viewport_layer_array = "GL_ARB_shader_viewport_layer_array"; const char* const E_GL_NV_viewport_array2 = "GL_NV_viewport_array2"; const char* const E_GL_NV_stereo_view_rendering = "GL_NV_stereo_view_rendering"; +const char* const E_GL_NVX_multiview_per_view_attributes = "GL_NVX_multiview_per_view_attributes"; // Arrays of extensions for the above viewportEXTs duplications diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index fc0ba06a6..dabd02180 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -386,6 +386,8 @@ INSTANTIATE_TEST_CASE_P( "spv.viewportArray2.tesc", "spv.stereoViewRendering.vert", "spv.stereoViewRendering.tesc", + "spv.multiviewPerViewAttributes.vert", + "spv.multiviewPerViewAttributes.tesc", })), FileNameAsCustomTestSuffix );