From f8565996019c6d3ebf7e4fe54e6d43eba9b5adb9 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Tue, 29 Jul 2014 19:31:13 +0000 Subject: [PATCH] Implement most of GL_ARB_explicit_attrib_location (all but index on fragment output). git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@27545 e7fa87d3-cd2b-0410-9028-fcbf551c1848 --- Test/140.frag | 6 + Test/140.vert | 6 + Test/baseResults/140.frag.out | 171 +++++++++++++++-------------- Test/baseResults/140.vert.out | 21 +++- glslang/MachineIndependent/ParseHelper.cpp | 17 +-- glslang/MachineIndependent/Versions.cpp | 6 +- glslang/MachineIndependent/Versions.h | 1 + 7 files changed, 132 insertions(+), 96 deletions(-) diff --git a/Test/140.frag b/Test/140.frag index 50fe391..0abc574 100644 --- a/Test/140.frag +++ b/Test/140.frag @@ -23,6 +23,12 @@ float patch = 3.1; layout(location=3) in vec4 vl; // ERROR +layout(location = 3) out vec4 factorBad; // ERROR + +#extension GL_ARB_explicit_attrib_location : enable + +layout(location = 5) out vec4 factor; + #extension GL_ARB_separate_shader_objects : enable layout(location=4) in vec4 vl2; diff --git a/Test/140.vert b/Test/140.vert index 6e162be..5dfa71e 100644 --- a/Test/140.vert +++ b/Test/140.vert @@ -22,6 +22,12 @@ void main() out vec4 gl_Position; // ERROR +layout(location = 9) in vec4 locBad; // ERROR + +#extension GL_ARB_explicit_attrib_location : enable + +layout(location = 9) in vec4 loc; + #extension GL_ARB_separate_shader_objects : enable out vec4 gl_Position; diff --git a/Test/baseResults/140.frag.out b/Test/baseResults/140.frag.out index 9ce7cac..8600e92 100644 --- a/Test/baseResults/140.frag.out +++ b/Test/baseResults/140.frag.out @@ -4,12 +4,16 @@ ERROR: 0:17: '#error' : GL_ES is not set ERROR: 0:20: 'fragment-shader struct input' : not supported for this version or the enabled extensions ERROR: 0:24: 'location' : not supported for this version or the enabled extensions ERROR: 0:24: 'location qualifier on input' : not supported for this version or the enabled extensions -ERROR: 0:32: 'assign' : l-value required "v" (can't modify shader input) -ERROR: 0:32: 'out' : Non-L-value cannot be passed for 'out' or 'inout' parameters. -ERROR: 6 compilation errors. No code generated. +ERROR: 0:26: 'location' : not supported for this version or the enabled extensions +ERROR: 0:26: 'location qualifier on output' : not supported for this version or the enabled extensions +WARNING: 0:28: '#extension' : extension is only partially supported: GL_ARB_explicit_attrib_location +ERROR: 0:38: 'assign' : l-value required "v" (can't modify shader input) +ERROR: 0:38: 'out' : Non-L-value cannot be passed for 'out' or 'inout' parameters. +ERROR: 8 compilation errors. No code generated. Shader version: 140 +Requested GL_ARB_explicit_attrib_location Requested GL_ARB_separate_shader_objects ERROR: node is still EOpNull! 0:10 Function Definition: main( (void) @@ -27,45 +31,45 @@ ERROR: node is still EOpNull! 0:22 'patch' (float) 0:22 Constant: 0:22 3.100000 -0:30 Function Definition: foo( (void) -0:30 Function Parameters: -0:32 Sequence -0:32 Sequence -0:32 move second child to first child (2-component vector of float) -0:32 'r1' (2-component vector of float) -0:32 modf (2-component vector of float) -0:32 vector swizzle (2-component vector of float) -0:32 'v' (smooth in 4-component vector of float) -0:32 Sequence -0:32 Constant: -0:32 0 (const int) -0:32 Constant: -0:32 1 (const int) -0:32 vector swizzle (2-component vector of float) -0:32 'v' (smooth in 4-component vector of float) -0:32 Sequence -0:32 Constant: -0:32 2 (const int) -0:32 Constant: -0:32 3 (const int) -0:33 Sequence -0:33 move second child to first child (2-component vector of float) -0:33 'r2' (2-component vector of float) -0:33 modf (2-component vector of float) -0:33 vector swizzle (2-component vector of float) -0:33 'o' (out 4-component vector of float) -0:33 Sequence -0:33 Constant: -0:33 0 (const int) -0:33 Constant: -0:33 1 (const int) -0:33 vector swizzle (2-component vector of float) -0:33 'o' (out 4-component vector of float) -0:33 Sequence -0:33 Constant: -0:33 2 (const int) -0:33 Constant: -0:33 3 (const int) +0:36 Function Definition: foo( (void) +0:36 Function Parameters: +0:38 Sequence +0:38 Sequence +0:38 move second child to first child (2-component vector of float) +0:38 'r1' (2-component vector of float) +0:38 modf (2-component vector of float) +0:38 vector swizzle (2-component vector of float) +0:38 'v' (smooth in 4-component vector of float) +0:38 Sequence +0:38 Constant: +0:38 0 (const int) +0:38 Constant: +0:38 1 (const int) +0:38 vector swizzle (2-component vector of float) +0:38 'v' (smooth in 4-component vector of float) +0:38 Sequence +0:38 Constant: +0:38 2 (const int) +0:38 Constant: +0:38 3 (const int) +0:39 Sequence +0:39 move second child to first child (2-component vector of float) +0:39 'r2' (2-component vector of float) +0:39 modf (2-component vector of float) +0:39 vector swizzle (2-component vector of float) +0:39 'o' (out 4-component vector of float) +0:39 Sequence +0:39 Constant: +0:39 0 (const int) +0:39 Constant: +0:39 1 (const int) +0:39 vector swizzle (2-component vector of float) +0:39 'o' (out 4-component vector of float) +0:39 Sequence +0:39 Constant: +0:39 2 (const int) +0:39 Constant: +0:39 3 (const int) 0:? Linker Objects 0:? 'v' (smooth in 4-component vector of float) 0:? 'i' (smooth in 4-component vector of float) @@ -75,6 +79,8 @@ ERROR: node is still EOpNull! 0:? 's' (smooth in structure{float f}) 0:? 'patch' (float) 0:? 'vl' (layout(location=3 ) smooth in 4-component vector of float) +0:? 'factorBad' (layout(location=3 ) out 4-component vector of float) +0:? 'factor' (layout(location=5 ) out 4-component vector of float) 0:? 'vl2' (layout(location=4 ) smooth in 4-component vector of float) @@ -82,6 +88,7 @@ Linked fragment stage: Shader version: 140 +Requested GL_ARB_explicit_attrib_location Requested GL_ARB_separate_shader_objects ERROR: node is still EOpNull! 0:10 Function Definition: main( (void) @@ -99,45 +106,45 @@ ERROR: node is still EOpNull! 0:22 'patch' (float) 0:22 Constant: 0:22 3.100000 -0:30 Function Definition: foo( (void) -0:30 Function Parameters: -0:32 Sequence -0:32 Sequence -0:32 move second child to first child (2-component vector of float) -0:32 'r1' (2-component vector of float) -0:32 modf (2-component vector of float) -0:32 vector swizzle (2-component vector of float) -0:32 'v' (smooth in 4-component vector of float) -0:32 Sequence -0:32 Constant: -0:32 0 (const int) -0:32 Constant: -0:32 1 (const int) -0:32 vector swizzle (2-component vector of float) -0:32 'v' (smooth in 4-component vector of float) -0:32 Sequence -0:32 Constant: -0:32 2 (const int) -0:32 Constant: -0:32 3 (const int) -0:33 Sequence -0:33 move second child to first child (2-component vector of float) -0:33 'r2' (2-component vector of float) -0:33 modf (2-component vector of float) -0:33 vector swizzle (2-component vector of float) -0:33 'o' (out 4-component vector of float) -0:33 Sequence -0:33 Constant: -0:33 0 (const int) -0:33 Constant: -0:33 1 (const int) -0:33 vector swizzle (2-component vector of float) -0:33 'o' (out 4-component vector of float) -0:33 Sequence -0:33 Constant: -0:33 2 (const int) -0:33 Constant: -0:33 3 (const int) +0:36 Function Definition: foo( (void) +0:36 Function Parameters: +0:38 Sequence +0:38 Sequence +0:38 move second child to first child (2-component vector of float) +0:38 'r1' (2-component vector of float) +0:38 modf (2-component vector of float) +0:38 vector swizzle (2-component vector of float) +0:38 'v' (smooth in 4-component vector of float) +0:38 Sequence +0:38 Constant: +0:38 0 (const int) +0:38 Constant: +0:38 1 (const int) +0:38 vector swizzle (2-component vector of float) +0:38 'v' (smooth in 4-component vector of float) +0:38 Sequence +0:38 Constant: +0:38 2 (const int) +0:38 Constant: +0:38 3 (const int) +0:39 Sequence +0:39 move second child to first child (2-component vector of float) +0:39 'r2' (2-component vector of float) +0:39 modf (2-component vector of float) +0:39 vector swizzle (2-component vector of float) +0:39 'o' (out 4-component vector of float) +0:39 Sequence +0:39 Constant: +0:39 0 (const int) +0:39 Constant: +0:39 1 (const int) +0:39 vector swizzle (2-component vector of float) +0:39 'o' (out 4-component vector of float) +0:39 Sequence +0:39 Constant: +0:39 2 (const int) +0:39 Constant: +0:39 3 (const int) 0:? Linker Objects 0:? 'v' (smooth in 4-component vector of float) 0:? 'i' (smooth in 4-component vector of float) @@ -147,5 +154,7 @@ ERROR: node is still EOpNull! 0:? 's' (smooth in structure{float f}) 0:? 'patch' (float) 0:? 'vl' (layout(location=3 ) smooth in 4-component vector of float) +0:? 'factorBad' (layout(location=3 ) out 4-component vector of float) +0:? 'factor' (layout(location=5 ) out 4-component vector of float) 0:? 'vl2' (layout(location=4 ) smooth in 4-component vector of float) diff --git a/Test/baseResults/140.vert.out b/Test/baseResults/140.vert.out index 61f6af8..2fa9191 100644 --- a/Test/baseResults/140.vert.out +++ b/Test/baseResults/140.vert.out @@ -1,14 +1,18 @@ 140.vert ERROR: 0:23: 'gl_Position' : identifiers starting with "gl_" are reserved -ERROR: 0:28: 'redeclaration' : cannot change storage, memory, or auxiliary qualification of gl_Position -ERROR: 0:28: 'redeclaration' : cannot change interpolation qualification of gl_Position -ERROR: 0:29: 'redeclaration' : cannot change the type of gl_Position -ERROR: 0:32: 'gl_ClipVertex' : cannot redeclare after use -ERROR: 0:33: 'gl_FogFragCoord' : cannot redeclare after use -ERROR: 6 compilation errors. No code generated. +ERROR: 0:25: 'location' : not supported for this version or the enabled extensions +ERROR: 0:25: 'location qualifier on input' : not supported for this version or the enabled extensions +WARNING: 0:27: '#extension' : extension is only partially supported: GL_ARB_explicit_attrib_location +ERROR: 0:34: 'redeclaration' : cannot change storage, memory, or auxiliary qualification of gl_Position +ERROR: 0:34: 'redeclaration' : cannot change interpolation qualification of gl_Position +ERROR: 0:35: 'redeclaration' : cannot change the type of gl_Position +ERROR: 0:38: 'gl_ClipVertex' : cannot redeclare after use +ERROR: 0:39: 'gl_FogFragCoord' : cannot redeclare after use +ERROR: 8 compilation errors. No code generated. Shader version: 140 +Requested GL_ARB_explicit_attrib_location Requested GL_ARB_separate_shader_objects ERROR: node is still EOpNull! 0:9 Function Definition: main( (void) @@ -51,6 +55,8 @@ ERROR: node is still EOpNull! 0:? 'anon@0' (layout(column_major std140 ) uniform block{layout(column_major std140 offset=0 ) uniform int anonMem}) 0:? 'gl_TexCoord' (smooth out implicitly-sized array of 4-component vector of float) 0:? 'gl_Position' (smooth out 4-component vector of float) +0:? 'locBad' (layout(location=9 ) in 4-component vector of float) +0:? 'loc' (layout(location=9 ) in 4-component vector of float) 0:? 'gl_PointSize' (gl_PointSize float) 0:? 'gl_PointSize' (gl_PointSize float) 0:? 'gl_ClipVertex' (gl_ClipVertex 4-component vector of float) @@ -65,6 +71,7 @@ Linked vertex stage: Shader version: 140 +Requested GL_ARB_explicit_attrib_location Requested GL_ARB_separate_shader_objects ERROR: node is still EOpNull! 0:9 Function Definition: main( (void) @@ -107,6 +114,8 @@ ERROR: node is still EOpNull! 0:? 'anon@0' (layout(column_major std140 ) uniform block{layout(column_major std140 offset=0 ) uniform int anonMem}) 0:? 'gl_TexCoord' (smooth out 1-element array of 4-component vector of float) 0:? 'gl_Position' (smooth out 4-component vector of float) +0:? 'locBad' (layout(location=9 ) in 4-component vector of float) +0:? 'loc' (layout(location=9 ) in 4-component vector of float) 0:? 'gl_PointSize' (gl_PointSize float) 0:? 'gl_PointSize' (gl_PointSize float) 0:? 'gl_ClipVertex' (gl_ClipVertex 4-component vector of float) diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index addd8f6..e950eff 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -3037,7 +3037,8 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType, return; } else if (id == "location") { profileRequires(loc, EEsProfile, 300, 0, "location"); - profileRequires(loc, ~EEsProfile, 330, GL_ARB_separate_shader_objects, "location"); + const char* exts[2] = { GL_ARB_separate_shader_objects, GL_ARB_explicit_attrib_location }; + profileRequires(loc, ~EEsProfile, 330, 2, exts, "location"); if ((unsigned int)value >= TQualifier::layoutLocationEnd) error(loc, "location is too large", id.c_str(), ""); else @@ -3354,9 +3355,10 @@ void TParseContext::layoutQualifierCheck(TSourceLoc loc, const TQualifier& quali if (profile == EEsProfile) requireStage(loc, EShLangVertex, feature); requireStage(loc, (EShLanguageMask)~EShLangComputeMask, feature); - if (language == EShLangVertex) - profileRequires(loc, ~EEsProfile, 330, GL_ARB_separate_shader_objects, feature); - else + if (language == EShLangVertex) { + const char* exts[2] = { GL_ARB_separate_shader_objects, GL_ARB_explicit_attrib_location }; + profileRequires(loc, ~EEsProfile, 330, 2, exts, feature); + } else profileRequires(loc, ~EEsProfile, 410, GL_ARB_separate_shader_objects, feature); break; } @@ -3366,9 +3368,10 @@ void TParseContext::layoutQualifierCheck(TSourceLoc loc, const TQualifier& quali if (profile == EEsProfile) requireStage(loc, EShLangFragment, feature); requireStage(loc, (EShLanguageMask)~EShLangComputeMask, feature); - if (language == EShLangFragment) - profileRequires(loc, ~EEsProfile, 330, GL_ARB_separate_shader_objects, feature); - else + if (language == EShLangFragment) { + const char* exts[2] = { GL_ARB_separate_shader_objects, GL_ARB_explicit_attrib_location }; + profileRequires(loc, ~EEsProfile, 330, 2, exts, feature); + } else profileRequires(loc, ~EEsProfile, 410, GL_ARB_separate_shader_objects, feature); break; } diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp index eaff500..eee23f1 100644 --- a/glslang/MachineIndependent/Versions.cpp +++ b/glslang/MachineIndependent/Versions.cpp @@ -154,7 +154,6 @@ void TParseContext::initializeExtensionBehavior() extensionBehavior[GL_EXT_frag_depth] = EBhDisable; extensionBehavior[GL_OES_EGL_image_external] = EBhDisable; extensionBehavior[GL_EXT_shader_texture_lod] = EBhDisable; - extensionBehavior[GL_ARB_shader_texture_lod] = EBhDisable; extensionBehavior[GL_ARB_texture_rectangle] = EBhDisable; extensionBehavior[GL_3DL_array_objects] = EBhDisable; @@ -165,6 +164,8 @@ void TParseContext::initializeExtensionBehavior() extensionBehavior[GL_ARB_tessellation_shader] = EBhDisable; extensionBehavior[GL_ARB_enhanced_layouts] = EBhDisable; extensionBehavior[GL_ARB_texture_cube_map_array] = EBhDisable; + extensionBehavior[GL_ARB_shader_texture_lod] = EBhDisable; + extensionBehavior[GL_ARB_explicit_attrib_location] = EBhDisablePartial; // "index" for fragment outputs is missing } // Get code that is not part of a shared symbol table, is specific to this shader, @@ -201,7 +202,8 @@ const char* TParseContext::getPreamble() "#define GL_ARB_tessellation_shader 1\n" "#define GL_ARB_enhanced_layouts 1\n" "#define GL_ARB_texture_cube_map_array 1\n" - "#define GL_ARB_shader_texture_lod 1\n"; + "#define GL_ARB_shader_texture_lod 1\n" + "#define GL_ARB_explicit_attrib_location 1\n"; } } diff --git a/glslang/MachineIndependent/Versions.h b/glslang/MachineIndependent/Versions.h index e9d85df..fce980a 100644 --- a/glslang/MachineIndependent/Versions.h +++ b/glslang/MachineIndependent/Versions.h @@ -89,6 +89,7 @@ const char* const GL_ARB_tessellation_shader = "GL_ARB_tessellation_shader" const char* const GL_ARB_enhanced_layouts = "GL_ARB_enhanced_layouts"; const char* const GL_ARB_texture_cube_map_array = "GL_ARB_texture_cube_map_array"; const char* const GL_ARB_shader_texture_lod = "GL_ARB_shader_texture_lod"; +const char* const GL_ARB_explicit_attrib_location = "GL_ARB_explicit_attrib_location"; } // end namespace glslang -- 2.7.4