Commit d6be6da0 by John Kessenich

SPV: Fix #1016: Don't allow non-GLSL-extension protected Layer and ViewportIndex members.

parent 03e63fa8
......@@ -2465,6 +2465,10 @@ bool TGlslangToSpvTraverser::filterMember(const glslang::TType& member)
if (member.getFieldName() == "gl_ViewportMaskPerViewNV" &&
extensions.find("GL_NVX_multiview_per_view_attributes") == extensions.end())
return true;
if ((member.getFieldName() == "gl_ViewportIndex" || member.getFieldName() == "gl_Layer") &&
extensions.find(glslang::E_GL_ARB_shader_viewport_layer_array) == extensions.end() &&
extensions.find(glslang::E_GL_NV_viewport_array2) == extensions.end())
return true;
return false;
};
......
spv.450.geom
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 26
// Id's are bound by 31
Capability Geometry
Capability GeometryPointSize
Capability MultiViewport
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Geometry 4 "main" 13 20
EntryPoint Geometry 4 "main" 13 20 27 29
ExecutionMode 4 Triangles
ExecutionMode 4 Invocations 4
ExecutionMode 4 OutputLineStrip
......@@ -26,6 +27,8 @@ spv.450.geom
MemberName 16(gl_PerVertex) 2 "gl_ClipDistance"
MemberName 16(gl_PerVertex) 3 "gl_CullDistance"
Name 20 "gl_in"
Name 27 "gl_Layer"
Name 29 "gl_ViewportIndex"
MemberDecorate 11(gl_PerVertex) 0 BuiltIn Position
MemberDecorate 11(gl_PerVertex) 1 BuiltIn PointSize
MemberDecorate 11(gl_PerVertex) 2 BuiltIn ClipDistance
......@@ -36,6 +39,8 @@ spv.450.geom
MemberDecorate 16(gl_PerVertex) 2 BuiltIn ClipDistance
MemberDecorate 16(gl_PerVertex) 3 BuiltIn CullDistance
Decorate 16(gl_PerVertex) Block
Decorate 27(gl_Layer) BuiltIn Layer
Decorate 29(gl_ViewportIndex) BuiltIn ViewportIndex
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
......@@ -55,11 +60,18 @@ spv.450.geom
20(gl_in): 19(ptr) Variable Input
21: TypePointer Input 6(float)
24: TypePointer Output 6(float)
26: TypePointer Output 14(int)
27(gl_Layer): 26(ptr) Variable Output
28: 14(int) Constant 2
29(gl_ViewportIndex): 26(ptr) Variable Output
30: 14(int) Constant 3
4(main): 2 Function None 3
5: Label
22: 21(ptr) AccessChain 20(gl_in) 15 15
23: 6(float) Load 22
25: 24(ptr) AccessChain 13 15
Store 25 23
Store 27(gl_Layer) 28
Store 29(gl_ViewportIndex) 30
Return
FunctionEnd
......@@ -9,4 +9,6 @@ layout(invocations = 4) in;
void main()
{
gl_PointSize = gl_in[1].gl_PointSize;
gl_Layer = 2;
gl_ViewportIndex = 3;
}
......@@ -2,7 +2,7 @@
layout(vertices = 4) out;
patch out vec4 patchOut;
layout(location=1) patch out vec4 patchOut;
struct S {
float sMem1; // should not see a patch decoration
......@@ -17,6 +17,7 @@ layout(location = 12) patch out TheBlock {
void main()
{
gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
}
layout(location = 2) patch out SingleBlock {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment