From 5513d9d0d827851892ee6748a80c3f28f7040547 Mon Sep 17 00:00:00 2001 From: David Srbecky Date: Mon, 3 Jul 2017 15:48:49 +0100 Subject: [PATCH] Multiview extension: Accept layout(num_views) qualifier --- Test/300.vert | 5 +++++ Test/baseResults/300.vert.out | 26 ++++++++++++++++---------- Test/spv.OVR_multiview.vert | 2 ++ glslang/Include/Types.h | 4 ++++ glslang/MachineIndependent/ParseHelper.cpp | 7 +++++++ 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/Test/300.vert b/Test/300.vert index 91bea99..daf98b8 100644 --- a/Test/300.vert +++ b/Test/300.vert @@ -186,6 +186,8 @@ void fooDeeparray() yp = x; // ERROR, wrong size } +layout(num_views = 2) in; // ERROR, no extension + void mwErr() { gl_ViewID_OVR; // ERROR, no extension @@ -193,6 +195,9 @@ void mwErr() #extension GL_OVR_multiview : enable +layout(num_views = 2) uniform float mwUniform; // ERROR, must be global +layout(num_views = 2) in; // OK + void mwOk() { gl_ViewID_OVR; diff --git a/Test/baseResults/300.vert.out b/Test/baseResults/300.vert.out index 9cf309f..507ad73 100644 --- a/Test/baseResults/300.vert.out +++ b/Test/baseResults/300.vert.out @@ -43,10 +43,14 @@ ERROR: 0:172: 'std430' : requires the 'buffer' storage qualifier ERROR: 0:175: '' : array size required ERROR: 0:185: 'assign' : cannot convert from ' temp 4-element array of highp float' to ' temp 3-element array of highp float' ERROR: 0:186: 'assign' : cannot convert from ' temp 3-element array of highp float' to ' temp 4-element array of highp float' -ERROR: 0:191: 'gl_ViewID_OVR' : required extension not requested: Possible extensions include: +ERROR: 0:189: 'num_views' : required extension not requested: Possible extensions include: GL_OVR_multiview GL_OVR_multiview2 -ERROR: 45 compilation errors. No code generated. +ERROR: 0:193: 'gl_ViewID_OVR' : required extension not requested: Possible extensions include: +GL_OVR_multiview +GL_OVR_multiview2 +ERROR: 0:198: 'num_views' : can only apply to a standalone qualifier +ERROR: 47 compilation errors. No code generated. Shader version: 300 @@ -293,14 +297,14 @@ ERROR: node is still EOpNull! 0:184 'y' ( temp 4-element array of highp float) 0:185 'xp' ( temp 3-element array of highp float) 0:186 'yp' ( temp 4-element array of highp float) -0:189 Function Definition: mwErr( ( global void) -0:189 Function Parameters: -0:191 Sequence -0:191 'gl_ViewID_OVR' ( in highp uint ViewIndex) -0:196 Function Definition: mwOk( ( global void) -0:196 Function Parameters: -0:198 Sequence -0:198 'gl_ViewID_OVR' ( in highp uint ViewIndex) +0:191 Function Definition: mwErr( ( global void) +0:191 Function Parameters: +0:193 Sequence +0:193 'gl_ViewID_OVR' ( in highp uint ViewIndex) +0:201 Function Definition: mwOk( ( global void) +0:201 Function Parameters: +0:203 Sequence +0:203 'gl_ViewID_OVR' ( in highp uint ViewIndex) 0:? Linker Objects 0:? 'm43' ( uniform highp 4X3 matrix of float) 0:? 'm33' ( uniform highp 3X3 matrix of float) @@ -335,6 +339,7 @@ ERROR: node is still EOpNull! 0:? 'Binst' (layout( column_major shared) uniform block{layout( column_major shared) uniform highp int a}) 0:? 'Bfoo' ( global highp int) 0:? 'B430i' (layout( column_major std430) uniform block{layout( column_major std430 offset=0) uniform highp int a}) +0:? 'mwUniform' ( uniform highp float) 0:? 'gl_VertexID' ( gl_VertexId highp int VertexId) 0:? 'gl_InstanceID' ( gl_InstanceId highp int InstanceId) @@ -494,6 +499,7 @@ ERROR: node is still EOpNull! 0:? 'Binst' (layout( column_major shared) uniform block{layout( column_major shared) uniform highp int a}) 0:? 'Bfoo' ( global highp int) 0:? 'B430i' (layout( column_major std430) uniform block{layout( column_major std430 offset=0) uniform highp int a}) +0:? 'mwUniform' ( uniform highp float) 0:? 'gl_VertexID' ( gl_VertexId highp int VertexId) 0:? 'gl_InstanceID' ( gl_InstanceId highp int InstanceId) diff --git a/Test/spv.OVR_multiview.vert b/Test/spv.OVR_multiview.vert index eb20825..c81a4d9 100644 --- a/Test/spv.OVR_multiview.vert +++ b/Test/spv.OVR_multiview.vert @@ -2,6 +2,8 @@ #extension GL_OVR_multiview : enable +layout(num_views = 2) in; + void main() { gl_Position = vec4(gl_ViewID_OVR, 0, 0, 0); } diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h index 00e20b5..54dac83 100644 --- a/glslang/Include/Types.h +++ b/glslang/Include/Types.h @@ -970,6 +970,7 @@ struct TShaderQualifiers { bool earlyFragmentTests; // fragment input TLayoutDepth layoutDepth; bool blendEquation; // true if any blend equation was specified + int numViews; // multiview extenstions #ifdef NV_EXTENSIONS bool layoutOverrideCoverage; // true if layout override_coverage set @@ -994,6 +995,7 @@ struct TShaderQualifiers { earlyFragmentTests = false; layoutDepth = EldNone; blendEquation = false; + numViews = TQualifier::layoutNotSet; #ifdef NV_EXTENSIONS layoutOverrideCoverage = false; #endif @@ -1033,6 +1035,8 @@ struct TShaderQualifiers { layoutDepth = src.layoutDepth; if (src.blendEquation) blendEquation = src.blendEquation; + if (src.numViews != TQualifier::layoutNotSet) + numViews = src.numViews; #ifdef NV_EXTENSIONS if (src.layoutOverrideCoverage) layoutOverrideCoverage = src.layoutOverrideCoverage; diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 95bf1ab..116f084 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -4206,6 +4206,11 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi } return; } + if (id == "num_views") { + requireExtensions(loc, Num_OVR_multiview_EXTs, OVR_multiview_EXTs, "num_views"); + publicType.shaderQualifiers.numViews = value; + return; + } #if NV_EXTENSIONS if (language == EShLangVertex || @@ -4804,6 +4809,8 @@ void TParseContext::checkNoShaderLayouts(const TSourceLoc& loc, const TShaderQua } if (shaderQualifiers.blendEquation) error(loc, message, "blend equation", ""); + if (shaderQualifiers.numViews != TQualifier::layoutNotSet) + error(loc, message, "num_views", ""); } // Correct and/or advance an object's offset layout qualifier. -- 2.7.4