From bd97b6f9f2132fa8df90431415e32dbab5c76db8 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Fri, 20 Dec 2019 10:33:13 -0700 Subject: [PATCH 01/19] Command-line: Give better error messages. From #1829. --- StandAlone/StandAlone.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index 07479321..c869fb12 100644 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -292,9 +292,12 @@ bool SetConfigFile(const std::string& name) // // Give error and exit with failure code. // -void Error(const char* message) +void Error(const char* message, const char* detail = nullptr) { - fprintf(stderr, "%s: Error %s (use -h for usage)\n", ExecutableName, message); + fprintf(stderr, "%s: Error: ", ExecutableName); + if (detail != nullptr) + fprintf(stderr, "%s: ", detail); + fprintf(stderr, "%s (use -h for usage)\n", message); exit(EFailUsage); } @@ -482,7 +485,7 @@ void ProcessArguments(std::vector>& workItem Options |= EOptionAutoMapLocations; } else if (lowerword == "uniform-base") { if (argc <= 1) - Error("no provided for --uniform-base"); + Error("no provided", lowerword.c_str()); uniformBase = ::strtol(argv[1], NULL, 10); bumpArg(); break; @@ -493,15 +496,16 @@ void ProcessArguments(std::vector>& workItem else if (strcmp(argv[1], "opengl100") == 0) setOpenGlSpv(); else - Error("--client expects vulkan100 or opengl100"); - } + Error("expects vulkan100 or opengl100", lowerword.c_str()); + } else + Error("expects vulkan100 or opengl100", lowerword.c_str()); bumpArg(); } else if (lowerword == "dump-builtin-symbols") { DumpBuiltinSymbols = true; } else if (lowerword == "entry-point") { entryPointName = argv[1]; if (argc <= 1) - Error("no provided for --entry-point"); + Error("no provided", lowerword.c_str()); bumpArg(); } else if (lowerword == "flatten-uniform-arrays" || // synonyms lowerword == "flatten-uniform-array" || @@ -576,7 +580,7 @@ void ProcessArguments(std::vector>& workItem } else if (lowerword == "source-entrypoint" || // synonyms lowerword == "sep") { if (argc <= 1) - Error("no provided for --source-entrypoint"); + Error("no provided", lowerword.c_str()); sourceEntryPointName = argv[1]; bumpArg(); break; @@ -627,14 +631,14 @@ void ProcessArguments(std::vector>& workItem lowerword == "vn") { Options |= EOptionOutputHexadecimal; if (argc <= 1) - Error("no provided for --variable-name"); + Error("no provided", lowerword.c_str()); variableName = argv[1]; bumpArg(); break; } else if (lowerword == "version") { Options |= EOptionDumpVersions; } else { - usage(); + Error("unrecognized command-line option", argv[0]); } } break; @@ -760,7 +764,7 @@ void ProcessArguments(std::vector>& workItem Options |= EOptionOutputHexadecimal; break; default: - usage(); + Error("unrecognized command-line option", argv[0]); break; } } else { @@ -1263,7 +1267,7 @@ int singleMain() ProcessConfigFile(); if ((Options & EOptionReadHlsl) && !((Options & EOptionOutputPreprocessed) || (Options & EOptionSpv))) - Error("ERROR: HLSL requires SPIR-V code generation (or preprocessing only)"); + Error("HLSL requires SPIR-V code generation (or preprocessing only)"); // // Two modes: From 78b1180466f7bcf35ad3f82ad3abf9218988ec80 Mon Sep 17 00:00:00 2001 From: Chow Date: Tue, 26 Nov 2019 16:18:52 +0800 Subject: [PATCH 02/19] Add support for ARB_sample_shading Version : >= 130 Extension Name: ARB_sample_shading Builtin-variables: "gl_SampleID" "gl_SamplePosition" "gl_SampleMask" "gl_NumSamples" Reference: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_sample_shading.txt --- Test/130.frag | 3 + Test/baseResults/130.frag.out | 453 +++++++++++----------- glslang/MachineIndependent/Initialize.cpp | 47 ++- glslang/MachineIndependent/Versions.cpp | 2 + glslang/MachineIndependent/Versions.h | 1 + 5 files changed, 270 insertions(+), 236 deletions(-) diff --git a/Test/130.frag b/Test/130.frag index 8a5bfd52..c352df42 100644 --- a/Test/130.frag +++ b/Test/130.frag @@ -62,12 +62,14 @@ void bar2() b3 < b3; // ERROR uv3 > uv3; // ERROR uvec2(2, 3) >= uvec2(3,3); // ERROR + int samples = gl_NumSamples; // ERROR int(bl4) <= int(bl4); // true int(bl4.x) > int(bl4.y); // false } #extension GL_ARB_texture_gather : enable #extension GL_ARB_texture_rectangle : enable +#extension GL_ARB_sample_shading : enable uniform sampler2D samp2D; uniform sampler2DShadow samp2DS; @@ -83,6 +85,7 @@ void bar23() s = textureGatherOffset(samp2DA, vec3(0.3), ivec2(1)); s = textureGatherOffset(samp2DS, vec2(0.3), 1.3, ivec2(1)); // ERROR s = textureGatherOffset(samp2D, vec2(0.3), ivec2(1), 2); // ERROR + int samples = gl_NumSamples; } #extension GL_ARB_gpu_shader5 : enable diff --git a/Test/baseResults/130.frag.out b/Test/baseResults/130.frag.out index 0af9ab9f..6115f69c 100644 --- a/Test/baseResults/130.frag.out +++ b/Test/baseResults/130.frag.out @@ -7,36 +7,38 @@ WARNING: 0:45: extension GL_ARB_texture_gather is being used for textureGather(. ERROR: 0:62: '<' : wrong operand types: no operation '<' exists that takes a left-hand operand of type ' temp 3-component vector of bool' and a right operand of type ' temp 3-component vector of bool' (or there is no acceptable conversion) ERROR: 0:63: '>' : wrong operand types: no operation '>' exists that takes a left-hand operand of type ' temp 3-component vector of uint' and a right operand of type ' temp 3-component vector of uint' (or there is no acceptable conversion) ERROR: 0:64: '>=' : wrong operand types: no operation '>=' exists that takes a left-hand operand of type ' const 2-component vector of uint' and a right operand of type ' const 2-component vector of uint' (or there is no acceptable conversion) -ERROR: 0:80: 'textureGatherOffset' : no matching overloaded function found -ERROR: 0:80: 'assign' : cannot convert from ' const float' to ' temp 4-component vector of float' -ERROR: 0:81: 'textureGatherOffset(...)' : not supported for this version or the enabled extensions -ERROR: 0:84: 'textureGatherOffset(...)' : not supported for this version or the enabled extensions -ERROR: 0:85: 'textureGatherOffset(...)' : not supported for this version or the enabled extensions -WARNING: 0:88: '#extension' : extension is only partially supported: GL_ARB_gpu_shader5 -ERROR: 0:120: 'line continuation' : not supported for this version or the enabled extensions -ERROR: 0:126: 'uniform block' : not supported for this version or the enabled extensions -ERROR: 0:140: 'length' : does not operate on this type: temp bool -ERROR: 0:140: 'boolb' : can't use function syntax on variable -ERROR: 0:141: 'length' : does not operate on this type: temp float -ERROR: 0:141: '' : function call, method, or subroutine call expected -ERROR: 0:141: '' : no matching overloaded function found -ERROR: 0:142: 'length' : incomplete method syntax -ERROR: 0:143: 'length' : method does not accept any arguments -ERROR: 0:146: 'gl_FogFragCoord' : identifiers starting with "gl_" are reserved -ERROR: 0:151: 'int' : must be qualified as flat in -ERROR: 0:151: 'redeclaration' : cannot change the type of gl_FogFragCoord -ERROR: 0:153: 'early_fragment_tests' : not supported for this version or the enabled extensions -ERROR: 0:154: 'image load store' : not supported for this version or the enabled extensions -ERROR: 0:154: 'iimage2D' : Reserved word. -ERROR: 0:169: 'early_fragment_tests' : can only apply to 'in' -ERROR: 0:173: 'location qualifier on uniform or buffer' : not supported for this version or the enabled extensions -ERROR: 29 compilation errors. No code generated. +ERROR: 0:65: 'gl_NumSamples' : required extension not requested: GL_ARB_sample_shading +ERROR: 0:82: 'textureGatherOffset' : no matching overloaded function found +ERROR: 0:82: 'assign' : cannot convert from ' const float' to ' temp 4-component vector of float' +ERROR: 0:83: 'textureGatherOffset(...)' : not supported for this version or the enabled extensions +ERROR: 0:86: 'textureGatherOffset(...)' : not supported for this version or the enabled extensions +ERROR: 0:87: 'textureGatherOffset(...)' : not supported for this version or the enabled extensions +WARNING: 0:91: '#extension' : extension is only partially supported: GL_ARB_gpu_shader5 +ERROR: 0:123: 'line continuation' : not supported for this version or the enabled extensions +ERROR: 0:129: 'uniform block' : not supported for this version or the enabled extensions +ERROR: 0:143: 'length' : does not operate on this type: temp bool +ERROR: 0:143: 'boolb' : can't use function syntax on variable +ERROR: 0:144: 'length' : does not operate on this type: temp float +ERROR: 0:144: '' : function call, method, or subroutine call expected +ERROR: 0:144: '' : no matching overloaded function found +ERROR: 0:145: 'length' : incomplete method syntax +ERROR: 0:146: 'length' : method does not accept any arguments +ERROR: 0:149: 'gl_FogFragCoord' : identifiers starting with "gl_" are reserved +ERROR: 0:154: 'int' : must be qualified as flat in +ERROR: 0:154: 'redeclaration' : cannot change the type of gl_FogFragCoord +ERROR: 0:156: 'early_fragment_tests' : not supported for this version or the enabled extensions +ERROR: 0:157: 'image load store' : not supported for this version or the enabled extensions +ERROR: 0:157: 'iimage2D' : Reserved word. +ERROR: 0:172: 'early_fragment_tests' : can only apply to 'in' +ERROR: 0:176: 'location qualifier on uniform or buffer' : not supported for this version or the enabled extensions +ERROR: 30 compilation errors. No code generated. Shader version: 130 Requested GL_ARB_explicit_attrib_location Requested GL_ARB_explicit_uniform_location Requested GL_ARB_gpu_shader5 +Requested GL_ARB_sample_shading Requested GL_ARB_separate_shader_objects Requested GL_ARB_shader_image_load_store Requested GL_ARB_shading_language_420pack @@ -122,259 +124,267 @@ ERROR: node is still EOpNull! 0:63 false (const bool) 0:64 Constant: 0:64 false (const bool) -0:65 Constant: -0:65 true (const bool) +0:65 Sequence +0:65 move second child to first child ( temp int) +0:65 'samples' ( temp int) +0:65 'gl_NumSamples' ( uniform int SampleMaskIn) 0:66 Constant: -0:66 false (const bool) -0:77 Function Definition: bar23( ( global void) -0:77 Function Parameters: +0:66 true (const bool) +0:67 Constant: +0:67 false (const bool) +0:79 Function Definition: bar23( ( global void) +0:79 Function Parameters: 0:? Sequence -0:80 's' ( temp 4-component vector of float) -0:81 move second child to first child ( temp 4-component vector of float) -0:81 's' ( temp 4-component vector of float) -0:81 textureGatherOffset ( global 4-component vector of float) -0:81 'samp2DR' ( uniform sampler2DRect) -0:81 Constant: -0:81 0.300000 -0:81 0.300000 -0:81 Constant: -0:81 1 (const int) -0:81 1 (const int) -0:82 move second child to first child ( temp 4-component vector of float) -0:82 's' ( temp 4-component vector of float) -0:82 textureGatherOffset ( global 4-component vector of float) -0:82 'samp2D' ( uniform sampler2D) -0:82 Constant: -0:82 0.300000 -0:82 0.300000 -0:82 Constant: -0:82 1 (const int) -0:82 1 (const int) +0:82 's' ( temp 4-component vector of float) 0:83 move second child to first child ( temp 4-component vector of float) 0:83 's' ( temp 4-component vector of float) 0:83 textureGatherOffset ( global 4-component vector of float) -0:83 'samp2DA' ( uniform sampler2DArray) +0:83 'samp2DR' ( uniform sampler2DRect) 0:83 Constant: 0:83 0.300000 0:83 0.300000 -0:83 0.300000 0:83 Constant: 0:83 1 (const int) 0:83 1 (const int) 0:84 move second child to first child ( temp 4-component vector of float) 0:84 's' ( temp 4-component vector of float) 0:84 textureGatherOffset ( global 4-component vector of float) -0:84 'samp2DS' ( uniform sampler2DShadow) +0:84 'samp2D' ( uniform sampler2D) 0:84 Constant: 0:84 0.300000 0:84 0.300000 0:84 Constant: -0:84 1.300000 -0:84 Constant: 0:84 1 (const int) 0:84 1 (const int) 0:85 move second child to first child ( temp 4-component vector of float) 0:85 's' ( temp 4-component vector of float) 0:85 textureGatherOffset ( global 4-component vector of float) -0:85 'samp2D' ( uniform sampler2D) +0:85 'samp2DA' ( uniform sampler2DArray) 0:85 Constant: 0:85 0.300000 0:85 0.300000 +0:85 0.300000 0:85 Constant: 0:85 1 (const int) 0:85 1 (const int) -0:85 Constant: -0:85 2 (const int) -0:90 Function Definition: bar234( ( global void) -0:90 Function Parameters: +0:86 move second child to first child ( temp 4-component vector of float) +0:86 's' ( temp 4-component vector of float) +0:86 textureGatherOffset ( global 4-component vector of float) +0:86 'samp2DS' ( uniform sampler2DShadow) +0:86 Constant: +0:86 0.300000 +0:86 0.300000 +0:86 Constant: +0:86 1.300000 +0:86 Constant: +0:86 1 (const int) +0:86 1 (const int) +0:87 move second child to first child ( temp 4-component vector of float) +0:87 's' ( temp 4-component vector of float) +0:87 textureGatherOffset ( global 4-component vector of float) +0:87 'samp2D' ( uniform sampler2D) +0:87 Constant: +0:87 0.300000 +0:87 0.300000 +0:87 Constant: +0:87 1 (const int) +0:87 1 (const int) +0:87 Constant: +0:87 2 (const int) +0:88 Sequence +0:88 move second child to first child ( temp int) +0:88 'samples' ( temp int) +0:88 'gl_NumSamples' ( uniform int SampleMaskIn) +0:93 Function Definition: bar234( ( global void) +0:93 Function Parameters: 0:? Sequence -0:93 move second child to first child ( temp 4-component vector of float) -0:93 's' ( temp 4-component vector of float) -0:93 textureGatherOffset ( global 4-component vector of float) -0:93 'samp2D' ( uniform sampler2D) -0:93 Constant: -0:93 0.300000 -0:93 0.300000 -0:93 Constant: -0:93 1 (const int) -0:93 1 (const int) -0:94 move second child to first child ( temp 4-component vector of float) -0:94 's' ( temp 4-component vector of float) -0:94 textureGatherOffset ( global 4-component vector of float) -0:94 'samp2DA' ( uniform sampler2DArray) -0:94 Constant: -0:94 0.300000 -0:94 0.300000 -0:94 0.300000 -0:94 Constant: -0:94 1 (const int) -0:94 1 (const int) -0:95 move second child to first child ( temp 4-component vector of float) -0:95 's' ( temp 4-component vector of float) -0:95 textureGatherOffset ( global 4-component vector of float) -0:95 'samp2DR' ( uniform sampler2DRect) -0:95 Constant: -0:95 0.300000 -0:95 0.300000 -0:95 Constant: -0:95 1 (const int) -0:95 1 (const int) 0:96 move second child to first child ( temp 4-component vector of float) 0:96 's' ( temp 4-component vector of float) 0:96 textureGatherOffset ( global 4-component vector of float) -0:96 'samp2DS' ( uniform sampler2DShadow) +0:96 'samp2D' ( uniform sampler2D) 0:96 Constant: 0:96 0.300000 0:96 0.300000 0:96 Constant: -0:96 1.300000 -0:96 Constant: 0:96 1 (const int) 0:96 1 (const int) 0:97 move second child to first child ( temp 4-component vector of float) 0:97 's' ( temp 4-component vector of float) 0:97 textureGatherOffset ( global 4-component vector of float) -0:97 'samp2D' ( uniform sampler2D) +0:97 'samp2DA' ( uniform sampler2DArray) 0:97 Constant: 0:97 0.300000 0:97 0.300000 +0:97 0.300000 0:97 Constant: 0:97 1 (const int) 0:97 1 (const int) -0:97 Constant: -0:97 2 (const int) -0:107 Function Definition: bar235( ( global void) -0:107 Function Parameters: -0:109 Sequence -0:109 Sequence -0:109 move second child to first child ( temp 3-component vector of int) -0:109 'a' ( temp 3-component vector of int) -0:109 textureSize ( global 3-component vector of int) -0:109 'Sca' ( uniform samplerCubeArray) -0:109 Constant: -0:109 3 (const int) -0:110 Sequence -0:110 move second child to first child ( temp 4-component vector of float) -0:110 'b' ( temp 4-component vector of float) -0:110 texture ( global 4-component vector of float) -0:110 'Sca' ( uniform samplerCubeArray) -0:110 'i' ( smooth in 4-component vector of float) -0:111 Sequence -0:111 move second child to first child ( temp 4-component vector of int) -0:111 'c' ( temp 4-component vector of int) -0:111 texture ( global 4-component vector of int) -0:111 'Isca' ( uniform isamplerCubeArray) -0:111 'i' ( smooth in 4-component vector of float) -0:111 Constant: -0:111 0.700000 +0:98 move second child to first child ( temp 4-component vector of float) +0:98 's' ( temp 4-component vector of float) +0:98 textureGatherOffset ( global 4-component vector of float) +0:98 'samp2DR' ( uniform sampler2DRect) +0:98 Constant: +0:98 0.300000 +0:98 0.300000 +0:98 Constant: +0:98 1 (const int) +0:98 1 (const int) +0:99 move second child to first child ( temp 4-component vector of float) +0:99 's' ( temp 4-component vector of float) +0:99 textureGatherOffset ( global 4-component vector of float) +0:99 'samp2DS' ( uniform sampler2DShadow) +0:99 Constant: +0:99 0.300000 +0:99 0.300000 +0:99 Constant: +0:99 1.300000 +0:99 Constant: +0:99 1 (const int) +0:99 1 (const int) +0:100 move second child to first child ( temp 4-component vector of float) +0:100 's' ( temp 4-component vector of float) +0:100 textureGatherOffset ( global 4-component vector of float) +0:100 'samp2D' ( uniform sampler2D) +0:100 Constant: +0:100 0.300000 +0:100 0.300000 +0:100 Constant: +0:100 1 (const int) +0:100 1 (const int) +0:100 Constant: +0:100 2 (const int) +0:110 Function Definition: bar235( ( global void) +0:110 Function Parameters: +0:112 Sequence 0:112 Sequence -0:112 move second child to first child ( temp 4-component vector of uint) -0:112 'd' ( temp 4-component vector of uint) -0:112 texture ( global 4-component vector of uint) -0:112 'Usca' ( uniform usamplerCubeArray) -0:112 'i' ( smooth in 4-component vector of float) -0:114 move second child to first child ( temp 4-component vector of float) -0:114 'b' ( temp 4-component vector of float) -0:114 textureLod ( global 4-component vector of float) -0:114 'Sca' ( uniform samplerCubeArray) -0:114 'i' ( smooth in 4-component vector of float) -0:114 Constant: -0:114 1.700000 -0:115 move second child to first child ( temp 3-component vector of int) -0:115 'a' ( temp 3-component vector of int) -0:115 textureSize ( global 3-component vector of int) -0:115 'Scas' ( uniform samplerCubeArrayShadow) -0:115 direct index ( temp int) -0:115 'a' ( temp 3-component vector of int) -0:115 Constant: -0:115 0 (const int) -0:116 Sequence -0:116 move second child to first child ( temp float) -0:116 'f' ( temp float) -0:116 texture ( global float) -0:116 'Scas' ( uniform samplerCubeArrayShadow) -0:116 'i' ( smooth in 4-component vector of float) -0:116 direct index ( temp float) -0:116 'b' ( temp 4-component vector of float) -0:116 Constant: -0:116 1 (const int) -0:117 move second child to first child ( temp 4-component vector of int) -0:117 'c' ( temp 4-component vector of int) -0:117 textureGrad ( global 4-component vector of int) -0:117 'Isca' ( uniform isamplerCubeArray) +0:112 move second child to first child ( temp 3-component vector of int) +0:112 'a' ( temp 3-component vector of int) +0:112 textureSize ( global 3-component vector of int) +0:112 'Sca' ( uniform samplerCubeArray) +0:112 Constant: +0:112 3 (const int) +0:113 Sequence +0:113 move second child to first child ( temp 4-component vector of float) +0:113 'b' ( temp 4-component vector of float) +0:113 texture ( global 4-component vector of float) +0:113 'Sca' ( uniform samplerCubeArray) +0:113 'i' ( smooth in 4-component vector of float) +0:114 Sequence +0:114 move second child to first child ( temp 4-component vector of int) +0:114 'c' ( temp 4-component vector of int) +0:114 texture ( global 4-component vector of int) +0:114 'Isca' ( uniform isamplerCubeArray) +0:114 'i' ( smooth in 4-component vector of float) +0:114 Constant: +0:114 0.700000 +0:115 Sequence +0:115 move second child to first child ( temp 4-component vector of uint) +0:115 'd' ( temp 4-component vector of uint) +0:115 texture ( global 4-component vector of uint) +0:115 'Usca' ( uniform usamplerCubeArray) +0:115 'i' ( smooth in 4-component vector of float) +0:117 move second child to first child ( temp 4-component vector of float) +0:117 'b' ( temp 4-component vector of float) +0:117 textureLod ( global 4-component vector of float) +0:117 'Sca' ( uniform samplerCubeArray) 0:117 'i' ( smooth in 4-component vector of float) 0:117 Constant: -0:117 0.100000 -0:117 0.100000 -0:117 0.100000 -0:117 Constant: -0:117 0.200000 -0:117 0.200000 -0:117 0.200000 -0:129 Function Definition: bar23444( ( global void) -0:129 Function Parameters: +0:117 1.700000 +0:118 move second child to first child ( temp 3-component vector of int) +0:118 'a' ( temp 3-component vector of int) +0:118 textureSize ( global 3-component vector of int) +0:118 'Scas' ( uniform samplerCubeArrayShadow) +0:118 direct index ( temp int) +0:118 'a' ( temp 3-component vector of int) +0:118 Constant: +0:118 0 (const int) +0:119 Sequence +0:119 move second child to first child ( temp float) +0:119 'f' ( temp float) +0:119 texture ( global float) +0:119 'Scas' ( uniform samplerCubeArrayShadow) +0:119 'i' ( smooth in 4-component vector of float) +0:119 direct index ( temp float) +0:119 'b' ( temp 4-component vector of float) +0:119 Constant: +0:119 1 (const int) +0:120 move second child to first child ( temp 4-component vector of int) +0:120 'c' ( temp 4-component vector of int) +0:120 textureGrad ( global 4-component vector of int) +0:120 'Isca' ( uniform isamplerCubeArray) +0:120 'i' ( smooth in 4-component vector of float) +0:120 Constant: +0:120 0.100000 +0:120 0.100000 +0:120 0.100000 +0:120 Constant: +0:120 0.200000 +0:120 0.200000 +0:120 0.200000 +0:132 Function Definition: bar23444( ( global void) +0:132 Function Parameters: 0:? Sequence -0:132 Sequence -0:132 move second child to first child ( temp float) -0:132 'a1' ( temp float) -0:132 direct index ( temp float) -0:132 direct index ( temp 3-component vector of float) -0:132 'm43' ( temp 4X3 matrix of float) -0:132 Constant: -0:132 3 (const int) -0:132 Constant: -0:132 1 (const int) -0:134 Sequence -0:134 move second child to first child ( temp int) -0:134 'a2' ( temp int) -0:134 Constant: -0:134 4 (const int) -0:135 add second child into first child ( temp int) -0:135 'a2' ( temp int) -0:135 Constant: -0:135 3 (const int) -0:136 add second child into first child ( temp int) -0:136 'a2' ( temp int) -0:136 Constant: -0:136 3 (const int) +0:135 Sequence +0:135 move second child to first child ( temp float) +0:135 'a1' ( temp float) +0:135 direct index ( temp float) +0:135 direct index ( temp 3-component vector of float) +0:135 'm43' ( temp 4X3 matrix of float) +0:135 Constant: +0:135 3 (const int) +0:135 Constant: +0:135 1 (const int) 0:137 Sequence -0:137 move second child to first child ( temp float) -0:137 'b' ( const (read only) float) -0:137 component-wise multiply ( temp float) -0:137 Constant: -0:137 2.000000 -0:137 'a1' ( temp float) -0:138 move second child to first child ( temp float) -0:138 direct index ( temp float) -0:138 'a' ( global 3-component vector of float) -0:138 Constant: -0:138 0 (const int) +0:137 move second child to first child ( temp int) +0:137 'a2' ( temp int) +0:137 Constant: +0:137 4 (const int) +0:138 add second child into first child ( temp int) +0:138 'a2' ( temp int) 0:138 Constant: -0:138 -1.000000 -0:140 Constant: -0:140 0.000000 -0:141 Constant: -0:141 0.000000 +0:138 3 (const int) +0:139 add second child into first child ( temp int) +0:139 'a2' ( temp int) +0:139 Constant: +0:139 3 (const int) +0:140 Sequence +0:140 move second child to first child ( temp float) +0:140 'b' ( const (read only) float) +0:140 component-wise multiply ( temp float) +0:140 Constant: +0:140 2.000000 +0:140 'a1' ( temp float) +0:141 move second child to first child ( temp float) +0:141 direct index ( temp float) +0:141 'a' ( global 3-component vector of float) +0:141 Constant: +0:141 0 (const int) +0:141 Constant: +0:141 -1.000000 0:143 Constant: -0:143 1 (const int) -0:162 Function Definition: qux2( ( global void) -0:162 Function Parameters: +0:143 0.000000 +0:144 Constant: +0:144 0.000000 +0:146 Constant: +0:146 1 (const int) +0:165 Function Definition: qux2( ( global void) +0:165 Function Parameters: 0:? Sequence -0:165 imageAtomicCompSwap ( global int) -0:165 'iimg2D' (layout( r32i) uniform iimage2D) -0:165 Construct ivec2 ( temp 2-component vector of int) -0:165 'i' ( temp int) -0:165 'i' ( temp int) -0:165 'i' ( temp int) -0:165 'i' ( temp int) -0:166 Sequence -0:166 move second child to first child ( temp 4-component vector of int) -0:166 'pos' ( temp 4-component vector of int) -0:166 imageLoad ( global 4-component vector of int) -0:166 'iimg2D' (layout( r32i) uniform iimage2D) -0:166 Construct ivec2 ( temp 2-component vector of int) -0:166 'i' ( temp int) -0:166 'i' ( temp int) +0:168 imageAtomicCompSwap ( global int) +0:168 'iimg2D' (layout( r32i) uniform iimage2D) +0:168 Construct ivec2 ( temp 2-component vector of int) +0:168 'i' ( temp int) +0:168 'i' ( temp int) +0:168 'i' ( temp int) +0:168 'i' ( temp int) +0:169 Sequence +0:169 move second child to first child ( temp 4-component vector of int) +0:169 'pos' ( temp 4-component vector of int) +0:169 imageLoad ( global 4-component vector of int) +0:169 'iimg2D' (layout( r32i) uniform iimage2D) +0:169 Construct ivec2 ( temp 2-component vector of int) +0:169 'i' ( temp int) +0:169 'i' ( temp int) 0:? Linker Objects 0:? 'a' ( global 3-component vector of float) 0:? 'b' ( global float) @@ -416,6 +426,7 @@ Shader version: 130 Requested GL_ARB_explicit_attrib_location Requested GL_ARB_explicit_uniform_location Requested GL_ARB_gpu_shader5 +Requested GL_ARB_sample_shading Requested GL_ARB_separate_shader_objects Requested GL_ARB_shader_image_load_store Requested GL_ARB_shading_language_420pack diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index c14a039b..90106d92 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -5178,19 +5178,25 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV "flat in int gl_PrimitiveID;" ); - if (version >= 400) { + if (version >= 130) { // ARB_sample_shading stageBuiltins[EShLangFragment].append( "flat in int gl_SampleID;" " in vec2 gl_SamplePosition;" - "flat in int gl_SampleMaskIn[];" " out int gl_SampleMask[];" ); - if (spvVersion.spv == 0) + + if (spvVersion.spv == 0) { stageBuiltins[EShLangFragment].append( "uniform int gl_NumSamples;" - ); + ); + } } + if (version >= 400) + stageBuiltins[EShLangFragment].append( + "flat in int gl_SampleMaskIn[];" + ); + if (version >= 430) stageBuiltins[EShLangFragment].append( "flat in int gl_Layer;" @@ -7422,18 +7428,29 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion BuiltInVariable("gl_FragStencilRefARB", EbvFragStencilRef, symbolTable); } - if ((profile != EEsProfile && version >= 400) || + if ((profile != EEsProfile && version >= 130) || (profile == EEsProfile && version >= 310)) { - BuiltInVariable("gl_SampleID", EbvSampleId, symbolTable); - BuiltInVariable("gl_SamplePosition", EbvSamplePosition, symbolTable); - BuiltInVariable("gl_SampleMaskIn", EbvSampleMask, symbolTable); - BuiltInVariable("gl_SampleMask", EbvSampleMask, symbolTable); - if (profile == EEsProfile && version < 320) { - symbolTable.setVariableExtensions("gl_SampleID", 1, &E_GL_OES_sample_variables); - symbolTable.setVariableExtensions("gl_SamplePosition", 1, &E_GL_OES_sample_variables); - symbolTable.setVariableExtensions("gl_SampleMaskIn", 1, &E_GL_OES_sample_variables); - symbolTable.setVariableExtensions("gl_SampleMask", 1, &E_GL_OES_sample_variables); - symbolTable.setVariableExtensions("gl_NumSamples", 1, &E_GL_OES_sample_variables); + BuiltInVariable("gl_SampleID", EbvSampleId, symbolTable); + BuiltInVariable("gl_SamplePosition", EbvSamplePosition, symbolTable); + BuiltInVariable("gl_SampleMask", EbvSampleMask, symbolTable); + + if (profile != EEsProfile && version < 400) { + BuiltInVariable("gl_NumSamples", EbvSampleMask, symbolTable); + + symbolTable.setVariableExtensions("gl_SampleMask", 1, &E_GL_ARB_sample_shading); + symbolTable.setVariableExtensions("gl_SampleID", 1, &E_GL_ARB_sample_shading); + symbolTable.setVariableExtensions("gl_SamplePosition", 1, &E_GL_ARB_sample_shading); + symbolTable.setVariableExtensions("gl_NumSamples", 1, &E_GL_ARB_sample_shading); + } else { + BuiltInVariable("gl_SampleMaskIn", EbvSampleMask, symbolTable); + + if (profile == EEsProfile && version < 320) { + symbolTable.setVariableExtensions("gl_SampleID", 1, &E_GL_OES_sample_variables); + symbolTable.setVariableExtensions("gl_SamplePosition", 1, &E_GL_OES_sample_variables); + symbolTable.setVariableExtensions("gl_SampleMaskIn", 1, &E_GL_OES_sample_variables); + symbolTable.setVariableExtensions("gl_SampleMask", 1, &E_GL_OES_sample_variables); + symbolTable.setVariableExtensions("gl_NumSamples", 1, &E_GL_OES_sample_variables); + } } } diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp index 23cc5302..e0e01a1d 100644 --- a/glslang/MachineIndependent/Versions.cpp +++ b/glslang/MachineIndependent/Versions.cpp @@ -192,6 +192,7 @@ void TParseVersions::initializeExtensionBehavior() extensionBehavior[E_GL_ARB_shader_viewport_layer_array] = EBhDisable; extensionBehavior[E_GL_ARB_fragment_shader_interlock] = EBhDisable; extensionBehavior[E_GL_ARB_shader_clock] = EBhDisable; + extensionBehavior[E_GL_ARB_sample_shading] = EBhDisable; extensionBehavior[E_GL_KHR_shader_subgroup_basic] = EBhDisable; extensionBehavior[E_GL_KHR_shader_subgroup_vote] = EBhDisable; @@ -394,6 +395,7 @@ void TParseVersions::getPreamble(std::string& preamble) "#define GL_ARB_sparse_texture2 1\n" "#define GL_ARB_sparse_texture_clamp 1\n" "#define GL_ARB_shader_stencil_export 1\n" + "#define GL_ARB_sample_shading 1\n" // "#define GL_ARB_cull_distance 1\n" // present for 4.5, but need extension control over block members "#define GL_ARB_post_depth_coverage 1\n" "#define GL_ARB_fragment_shader_interlock 1\n" diff --git a/glslang/MachineIndependent/Versions.h b/glslang/MachineIndependent/Versions.h index 5048ad7d..dac01ba6 100644 --- a/glslang/MachineIndependent/Versions.h +++ b/glslang/MachineIndependent/Versions.h @@ -144,6 +144,7 @@ const char* const E_GL_ARB_post_depth_coverage = "GL_ARB_post_depth_cov const char* const E_GL_ARB_shader_viewport_layer_array = "GL_ARB_shader_viewport_layer_array"; const char* const E_GL_ARB_fragment_shader_interlock = "GL_ARB_fragment_shader_interlock"; const char* const E_GL_ARB_shader_clock = "GL_ARB_shader_clock"; +const char* const E_GL_ARB_sample_shading = "GL_ARB_sample_shading"; const char* const E_GL_KHR_shader_subgroup_basic = "GL_KHR_shader_subgroup_basic"; const char* const E_GL_KHR_shader_subgroup_vote = "GL_KHR_shader_subgroup_vote"; From a8f9886cc6e608dd4a55d34a28972412894edfe4 Mon Sep 17 00:00:00 2001 From: Chow Date: Tue, 26 Nov 2019 16:28:52 +0800 Subject: [PATCH 03/19] Add support for ARB_texture_multisample GLSL Version : >= 140 Purpose: Allow users to use features by enabling this extension, even in low versions. Extension Name: ARB_texture_multisample Builtin-variables: Nah Builtin-functions: Nah Keywords: sampler2DMS, isampler2DMS, usampler2DMS, sampler2DMSArray, isampler2DMSArray, usampler2DMSArray Reference: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_texture_multisample.txt --- Test/140.frag | 7 + Test/baseResults/140.frag.out | 171 ++++++++++++------------ glslang/MachineIndependent/Scan.cpp | 6 + glslang/MachineIndependent/Versions.cpp | 2 + glslang/MachineIndependent/Versions.h | 1 + 5 files changed, 102 insertions(+), 85 deletions(-) diff --git a/Test/140.frag b/Test/140.frag index 2bc2f59f..5efdbed7 100644 --- a/Test/140.frag +++ b/Test/140.frag @@ -17,6 +17,7 @@ void main() #error GL_ES is not set #endif + in struct S { float f; } s; // ERROR float patch = 3.1; @@ -51,3 +52,9 @@ float fooi() { return i1 + i2; } + +uniform sampler2DMS aaa1; // ERROR + +#extension GL_ARB_texture_multisample : enable + +uniform sampler2DMS aaa2; diff --git a/Test/baseResults/140.frag.out b/Test/baseResults/140.frag.out index 7ce21703..702718a2 100644 --- a/Test/baseResults/140.frag.out +++ b/Test/baseResults/140.frag.out @@ -1,14 +1,15 @@ 140.frag WARNING: 0:3: varying deprecated in version 130; may be removed in future release 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: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 -ERROR: 0:40: 'assign' : l-value required "v" (can't modify shader input) -ERROR: 0:40: 'out' : Non-L-value cannot be passed for 'out' or 'inout' parameters. -ERROR: 8 compilation errors. No code generated. +ERROR: 0:21: 'fragment-shader struct input' : not supported for this version or the enabled extensions +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 +ERROR: 0:27: 'location' : not supported for this version or the enabled extensions +ERROR: 0:27: 'location qualifier on output' : not supported for this version or the enabled extensions +ERROR: 0:41: 'assign' : l-value required "v" (can't modify shader input) +ERROR: 0:41: 'out' : Non-L-value cannot be passed for 'out' or 'inout' parameters. +ERROR: 0:56: '' : syntax error, unexpected IDENTIFIER, expecting LEFT_BRACE or COMMA or SEMICOLON +ERROR: 9 compilation errors. No code generated. Shader version: 140 @@ -25,80 +26,80 @@ ERROR: node is still EOpNull! 0:12 'gl_ClipDistance' ( smooth in 5-element array of float ClipDistance) 0:12 Constant: 0:12 2 (const int) -0:22 Sequence -0:22 move second child to first child ( temp float) -0:22 'patch' ( global float) -0:22 Constant: -0:22 3.100000 -0:38 Function Definition: foo( ( global void) -0:38 Function Parameters: -0:40 Sequence -0:40 Sequence -0:40 move second child to first child ( temp 2-component vector of float) -0:40 'r1' ( temp 2-component vector of float) -0:40 modf ( global 2-component vector of float) -0:40 vector swizzle ( temp 2-component vector of float) -0:40 'v' ( smooth in 4-component vector of float) -0:40 Sequence -0:40 Constant: -0:40 0 (const int) -0:40 Constant: -0:40 1 (const int) -0:40 vector swizzle ( temp 2-component vector of float) -0:40 'v' ( smooth in 4-component vector of float) -0:40 Sequence -0:40 Constant: -0:40 2 (const int) -0:40 Constant: -0:40 3 (const int) +0:23 Sequence +0:23 move second child to first child ( temp float) +0:23 'patch' ( global float) +0:23 Constant: +0:23 3.100000 +0:39 Function Definition: foo( ( global void) +0:39 Function Parameters: +0:41 Sequence 0:41 Sequence 0:41 move second child to first child ( temp 2-component vector of float) -0:41 'r2' ( temp 2-component vector of float) +0:41 'r1' ( temp 2-component vector of float) 0:41 modf ( global 2-component vector of float) 0:41 vector swizzle ( temp 2-component vector of float) -0:41 'o' ( out 4-component vector of float) +0:41 'v' ( smooth in 4-component vector of float) 0:41 Sequence 0:41 Constant: 0:41 0 (const int) 0:41 Constant: 0:41 1 (const int) 0:41 vector swizzle ( temp 2-component vector of float) -0:41 'o' ( out 4-component vector of float) +0:41 'v' ( smooth in 4-component vector of float) 0:41 Sequence 0:41 Constant: 0:41 2 (const int) 0:41 Constant: 0:41 3 (const int) -0:42 move second child to first child ( temp float) -0:42 direct index ( temp float) -0:42 'o' ( out 4-component vector of float) -0:42 Constant: -0:42 2 (const int) -0:42 Function Call: fooi( ( global float) -0:47 Sequence -0:47 move second child to first child ( temp float) -0:47 'i1' ( global float) -0:47 Test condition and select ( temp float) -0:47 Condition -0:47 'gl_FrontFacing' ( gl_FrontFacing bool Face) -0:47 true case -0:47 Constant: -0:47 -2.000000 -0:47 false case -0:47 Constant: -0:47 2.000000 +0:42 Sequence +0:42 move second child to first child ( temp 2-component vector of float) +0:42 'r2' ( temp 2-component vector of float) +0:42 modf ( global 2-component vector of float) +0:42 vector swizzle ( temp 2-component vector of float) +0:42 'o' ( out 4-component vector of float) +0:42 Sequence +0:42 Constant: +0:42 0 (const int) +0:42 Constant: +0:42 1 (const int) +0:42 vector swizzle ( temp 2-component vector of float) +0:42 'o' ( out 4-component vector of float) +0:42 Sequence +0:42 Constant: +0:42 2 (const int) +0:42 Constant: +0:42 3 (const int) +0:43 move second child to first child ( temp float) +0:43 direct index ( temp float) +0:43 'o' ( out 4-component vector of float) +0:43 Constant: +0:43 2 (const int) +0:43 Function Call: fooi( ( global float) 0:48 Sequence 0:48 move second child to first child ( temp float) -0:48 'i2' ( global float) -0:48 Constant: -0:48 102.000000 -0:50 Function Definition: fooi( ( global float) -0:50 Function Parameters: -0:52 Sequence -0:52 Branch: Return with expression -0:52 add ( temp float) -0:52 'i1' ( global float) -0:52 'i2' ( global float) +0:48 'i1' ( global float) +0:48 Test condition and select ( temp float) +0:48 Condition +0:48 'gl_FrontFacing' ( gl_FrontFacing bool Face) +0:48 true case +0:48 Constant: +0:48 -2.000000 +0:48 false case +0:48 Constant: +0:48 2.000000 +0:49 Sequence +0:49 move second child to first child ( temp float) +0:49 'i2' ( global float) +0:49 Constant: +0:49 102.000000 +0:51 Function Definition: fooi( ( global float) +0:51 Function Parameters: +0:53 Sequence +0:53 Branch: Return with expression +0:53 add ( temp float) +0:53 'i1' ( global float) +0:53 'i2' ( global float) 0:? Linker Objects 0:? 'v' ( smooth in 4-component vector of float) 0:? 'i' ( smooth in 4-component vector of float) @@ -131,28 +132,28 @@ ERROR: node is still EOpNull! 0:12 'gl_ClipDistance' ( smooth in 5-element array of float ClipDistance) 0:12 Constant: 0:12 2 (const int) -0:22 Sequence -0:22 move second child to first child ( temp float) -0:22 'patch' ( global float) -0:22 Constant: -0:22 3.100000 -0:47 Sequence -0:47 move second child to first child ( temp float) -0:47 'i1' ( global float) -0:47 Test condition and select ( temp float) -0:47 Condition -0:47 'gl_FrontFacing' ( gl_FrontFacing bool Face) -0:47 true case -0:47 Constant: -0:47 -2.000000 -0:47 false case -0:47 Constant: -0:47 2.000000 +0:23 Sequence +0:23 move second child to first child ( temp float) +0:23 'patch' ( global float) +0:23 Constant: +0:23 3.100000 0:48 Sequence 0:48 move second child to first child ( temp float) -0:48 'i2' ( global float) -0:48 Constant: -0:48 102.000000 +0:48 'i1' ( global float) +0:48 Test condition and select ( temp float) +0:48 Condition +0:48 'gl_FrontFacing' ( gl_FrontFacing bool Face) +0:48 true case +0:48 Constant: +0:48 -2.000000 +0:48 false case +0:48 Constant: +0:48 2.000000 +0:49 Sequence +0:49 move second child to first child ( temp float) +0:49 'i2' ( global float) +0:49 Constant: +0:49 102.000000 0:? Linker Objects 0:? 'v' ( smooth in 4-component vector of float) 0:? 'i' ( smooth in 4-component vector of float) diff --git a/glslang/MachineIndependent/Scan.cpp b/glslang/MachineIndependent/Scan.cpp index 75cc475e..710af4ab 100644 --- a/glslang/MachineIndependent/Scan.cpp +++ b/glslang/MachineIndependent/Scan.cpp @@ -1421,6 +1421,9 @@ int TScanContext::tokenizeIdentifier() afterType = true; if (parseContext.isEsProfile() && parseContext.version >= 310) return keyword; + if (!parseContext.isEsProfile() && (parseContext.version > 140 || + (parseContext.version == 140 && parseContext.extensionsTurnedOn(1, &E_GL_ARB_texture_multisample)))) + return keyword; return es30ReservedFromGLSL(150); case SAMPLER2DMSARRAY: @@ -1430,6 +1433,9 @@ int TScanContext::tokenizeIdentifier() if ((parseContext.isEsProfile() && parseContext.version >= 320) || parseContext.extensionsTurnedOn(1, &E_GL_OES_texture_storage_multisample_2d_array)) return keyword; + if (!parseContext.isEsProfile() && (parseContext.version > 140 || + (parseContext.version == 140 && parseContext.extensionsTurnedOn(1, &E_GL_ARB_texture_multisample)))) + return keyword; return es30ReservedFromGLSL(150); case SAMPLER1D: diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp index 23cc5302..05c0c693 100644 --- a/glslang/MachineIndependent/Versions.cpp +++ b/glslang/MachineIndependent/Versions.cpp @@ -172,6 +172,7 @@ void TParseVersions::initializeExtensionBehavior() extensionBehavior[E_GL_ARB_tessellation_shader] = EBhDisable; extensionBehavior[E_GL_ARB_enhanced_layouts] = EBhDisable; extensionBehavior[E_GL_ARB_texture_cube_map_array] = EBhDisable; + extensionBehavior[E_GL_ARB_texture_multisample] = EBhDisable; extensionBehavior[E_GL_ARB_shader_texture_lod] = EBhDisable; extensionBehavior[E_GL_ARB_explicit_attrib_location] = EBhDisable; extensionBehavior[E_GL_ARB_explicit_uniform_location] = EBhDisable; @@ -379,6 +380,7 @@ void TParseVersions::getPreamble(std::string& preamble) "#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_texture_multisample 1\n" "#define GL_ARB_shader_texture_lod 1\n" "#define GL_ARB_explicit_attrib_location 1\n" "#define GL_ARB_explicit_uniform_location 1\n" diff --git a/glslang/MachineIndependent/Versions.h b/glslang/MachineIndependent/Versions.h index 5048ad7d..b980852c 100644 --- a/glslang/MachineIndependent/Versions.h +++ b/glslang/MachineIndependent/Versions.h @@ -124,6 +124,7 @@ const char* const E_GL_ARB_compute_shader = "GL_ARB_compute_shader const char* const E_GL_ARB_tessellation_shader = "GL_ARB_tessellation_shader"; const char* const E_GL_ARB_enhanced_layouts = "GL_ARB_enhanced_layouts"; const char* const E_GL_ARB_texture_cube_map_array = "GL_ARB_texture_cube_map_array"; +const char* const E_GL_ARB_texture_multisample = "GL_ARB_texture_multisample"; const char* const E_GL_ARB_shader_texture_lod = "GL_ARB_shader_texture_lod"; const char* const E_GL_ARB_explicit_attrib_location = "GL_ARB_explicit_attrib_location"; const char* const E_GL_ARB_explicit_uniform_location = "GL_ARB_explicit_uniform_location"; From 97c4c0936f15377787a1109a33c87379049f5814 Mon Sep 17 00:00:00 2001 From: Chow Date: Tue, 26 Nov 2019 17:02:46 +0800 Subject: [PATCH 04/19] Add support for ARB_uniform_buffer_object GLSL Version : >= 120 Purpose: Allow users to use features by enabling this extension, even in low versions. Extension Name: ARB_uniform_buffer_object Builtin-variables: Uniform Builtin-functions: Nah Keywords: Nah Features: uniform block Reference: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_uniform_buffer_object.txt --- Test/120.vert | 12 ++++++++++++ Test/baseResults/120.vert.out | 3 ++- glslang/MachineIndependent/ParseHelper.cpp | 2 +- glslang/MachineIndependent/Versions.cpp | 2 ++ glslang/MachineIndependent/Versions.h | 1 + 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Test/120.vert b/Test/120.vert index d2765571..7b98492b 100644 --- a/Test/120.vert +++ b/Test/120.vert @@ -201,3 +201,15 @@ int mac; #define macr(A,B) A ## B int macr(qrs,tuv); + +layout(std140) uniform BlockName // ERROR +{ + int test; +}; + +#extension GL_ARB_uniform_buffer_object : enable + +layout(std140) uniform BlockName +{ + int test; +}; \ No newline at end of file diff --git a/Test/baseResults/120.vert.out b/Test/baseResults/120.vert.out index 5a91ed66..6c42b75e 100644 --- a/Test/baseResults/120.vert.out +++ b/Test/baseResults/120.vert.out @@ -79,7 +79,8 @@ ERROR: 0:192: 'assign' : l-value required (can't modify a const) ERROR: 0:195: 'gl_ModelViewMatrix' : identifiers starting with "gl_" are reserved ERROR: 0:200: 'token pasting (##)' : not supported for this version or the enabled extensions ERROR: 0:203: 'token pasting (##)' : not supported for this version or the enabled extensions -ERROR: 80 compilation errors. No code generated. +ERROR: 0:205: '' : syntax error, unexpected IDENTIFIER +ERROR: 81 compilation errors. No code generated. Shader version: 120 diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 9c46d57c..acdb9f78 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -7609,7 +7609,7 @@ void TParseContext::blockStageIoCheck(const TSourceLoc& loc, const TQualifier& q switch (qualifier.storage) { case EvqUniform: profileRequires(loc, EEsProfile, 300, nullptr, "uniform block"); - profileRequires(loc, ENoProfile, 140, nullptr, "uniform block"); + profileRequires(loc, ENoProfile, 140, E_GL_ARB_uniform_buffer_object, "uniform block"); if (currentBlockQualifier.layoutPacking == ElpStd430 && ! currentBlockQualifier.isPushConstant()) requireExtensions(loc, 1, &E_GL_EXT_scalar_block_layout, "std430 requires the buffer storage qualifier"); break; diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp index 23cc5302..e3be9377 100644 --- a/glslang/MachineIndependent/Versions.cpp +++ b/glslang/MachineIndependent/Versions.cpp @@ -192,6 +192,7 @@ void TParseVersions::initializeExtensionBehavior() extensionBehavior[E_GL_ARB_shader_viewport_layer_array] = EBhDisable; extensionBehavior[E_GL_ARB_fragment_shader_interlock] = EBhDisable; extensionBehavior[E_GL_ARB_shader_clock] = EBhDisable; + extensionBehavior[E_GL_ARB_uniform_buffer_object] = EBhDisable; extensionBehavior[E_GL_KHR_shader_subgroup_basic] = EBhDisable; extensionBehavior[E_GL_KHR_shader_subgroup_vote] = EBhDisable; @@ -397,6 +398,7 @@ void TParseVersions::getPreamble(std::string& preamble) // "#define GL_ARB_cull_distance 1\n" // present for 4.5, but need extension control over block members "#define GL_ARB_post_depth_coverage 1\n" "#define GL_ARB_fragment_shader_interlock 1\n" + "#define GL_ARB_uniform_buffer_object 1\n" "#define GL_EXT_shader_non_constant_global_initializers 1\n" "#define GL_EXT_shader_image_load_formatted 1\n" "#define GL_EXT_post_depth_coverage 1\n" diff --git a/glslang/MachineIndependent/Versions.h b/glslang/MachineIndependent/Versions.h index 5048ad7d..4e189c1c 100644 --- a/glslang/MachineIndependent/Versions.h +++ b/glslang/MachineIndependent/Versions.h @@ -144,6 +144,7 @@ const char* const E_GL_ARB_post_depth_coverage = "GL_ARB_post_depth_cov const char* const E_GL_ARB_shader_viewport_layer_array = "GL_ARB_shader_viewport_layer_array"; const char* const E_GL_ARB_fragment_shader_interlock = "GL_ARB_fragment_shader_interlock"; const char* const E_GL_ARB_shader_clock = "GL_ARB_shader_clock"; +const char* const E_GL_ARB_uniform_buffer_object = "GL_ARB_uniform_buffer_object"; const char* const E_GL_KHR_shader_subgroup_basic = "GL_KHR_shader_subgroup_basic"; const char* const E_GL_KHR_shader_subgroup_vote = "GL_KHR_shader_subgroup_vote"; From 891ec09c62bb570c5c4d125221dd437d13940f9d Mon Sep 17 00:00:00 2001 From: Chow Date: Wed, 25 Dec 2019 17:08:48 +0800 Subject: [PATCH 05/19] Modify atomic_uint binding check Modify atomic_uint binding check. Currently, when not declared with offset, default atomic_unint won't check whether its binding is valid or not more than its limit value. --- Test/450.comp | 3 +++ Test/baseResults/450.comp.out | 13 +++++++------ glslang/MachineIndependent/ParseHelper.cpp | 8 +++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Test/450.comp b/Test/450.comp index fb2b56a7..316674dd 100644 --- a/Test/450.comp +++ b/Test/450.comp @@ -1,5 +1,8 @@ #version 450 core layout(local_size_x = 0) in; // ERROR, 0 not allowed + +layout(binding=10000) uniform atomic_uint; // ERROR + void main() { shared float f; // ERROR shared must be global diff --git a/Test/baseResults/450.comp.out b/Test/baseResults/450.comp.out index 4ae77cca..ce95f8db 100644 --- a/Test/baseResults/450.comp.out +++ b/Test/baseResults/450.comp.out @@ -1,14 +1,15 @@ 450.comp ERROR: 0:2: 'local_size_x' : must be at least 1 -ERROR: 0:5: 'shared' : not allowed in nested scope -ERROR: 2 compilation errors. No code generated. +ERROR: 0:4: 'binding' : atomic_uint binding is too large +ERROR: 0:8: 'shared' : not allowed in nested scope +ERROR: 3 compilation errors. No code generated. Shader version: 450 local_size = (1, 1, 1) ERROR: node is still EOpNull! -0:3 Function Definition: main( ( global void) -0:3 Function Parameters: +0:6 Function Definition: main( ( global void) +0:6 Function Parameters: 0:? Linker Objects @@ -18,7 +19,7 @@ Linked compute stage: Shader version: 450 local_size = (1, 1, 1) ERROR: node is still EOpNull! -0:3 Function Definition: main( ( global void) -0:3 Function Parameters: +0:6 Function Definition: main( ( global void) +0:6 Function Parameters: 0:? Linker Objects diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 9c46d57c..d7a85100 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -6380,13 +6380,15 @@ const TFunction* TParseContext::findFunctionExplicitTypes(const TSourceLoc& loc, void TParseContext::declareTypeDefaults(const TSourceLoc& loc, const TPublicType& publicType) { #ifndef GLSLANG_WEB - if (publicType.basicType == EbtAtomicUint && publicType.qualifier.hasBinding() && - publicType.qualifier.hasOffset()) { + if (publicType.basicType == EbtAtomicUint && publicType.qualifier.hasBinding()) { if (publicType.qualifier.layoutBinding >= (unsigned int)resources.maxAtomicCounterBindings) { error(loc, "atomic_uint binding is too large", "binding", ""); return; } - atomicUintOffsets[publicType.qualifier.layoutBinding] = publicType.qualifier.layoutOffset; + + if(publicType.qualifier.hasOffset()) { + atomicUintOffsets[publicType.qualifier.layoutBinding] = publicType.qualifier.layoutOffset; + } return; } From 5db058c020655417286d51946d0e93ccacb45860 Mon Sep 17 00:00:00 2001 From: Chow Date: Wed, 25 Dec 2019 17:27:45 +0800 Subject: [PATCH 06/19] atomic counter offset should align to 4 atomic counter offset should align to 4 Ref: glspec46.core - 6.8 BufferObjectState offset restriction multiple of 4 --- Test/atomic_uint.frag | 3 +- Test/baseResults/atomic_uint.frag.out | 131 +++++++++++---------- glslang/MachineIndependent/ParseHelper.cpp | 4 + 3 files changed, 72 insertions(+), 66 deletions(-) diff --git a/Test/atomic_uint.frag b/Test/atomic_uint.frag index 9a95a48a..41552144 100644 --- a/Test/atomic_uint.frag +++ b/Test/atomic_uint.frag @@ -1,6 +1,7 @@ #version 420 core layout(binding = 0) uniform atomic_uint counter; +layout(binding = 0, offset = 9) uniform atomic_uint counter; uint func(atomic_uint c) { @@ -41,7 +42,7 @@ uniform atomic_uint aNoBind; // ERROR, no binding layout(binding=0, offset=32) uniform atomic_uint aOffset; layout(binding=0, offset=4) uniform atomic_uint; layout(binding=0) uniform atomic_uint bar3; // offset is 4 -layout(binding=0) uniform atomic_uint ac[3]; // offset = 8 +layout(binding=0) uniform atomic_uint ac[2]; // offset = 8 layout(binding=0) uniform atomic_uint ad; // offset = 20 layout(offset=8) uniform atomic_uint bar4; // ERROR, no binding layout(binding = 0, offset = 12) uniform atomic_uint overlap; // ERROR, overlapping offsets diff --git a/Test/baseResults/atomic_uint.frag.out b/Test/baseResults/atomic_uint.frag.out index c705a063..a0c6773b 100644 --- a/Test/baseResults/atomic_uint.frag.out +++ b/Test/baseResults/atomic_uint.frag.out @@ -1,64 +1,65 @@ atomic_uint.frag -ERROR: 0:10: 'atomic_uint' : samplers and atomic_uints cannot be output parameters -ERROR: 0:12: 'return' : type does not match, or is not convertible to, the function's return type -ERROR: 0:18: 'atomic_uint' : atomic_uints can only be used in uniform variables or function parameters: non_uniform_counter -ERROR: 0:23: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCounterBindings -ERROR: 0:28: '+' : wrong operand types: no operation '+' exists that takes a left-hand operand of type 'layout( binding=0 offset=0) uniform atomic_uint' and a right operand of type 'layout( binding=0 offset=0) uniform atomic_uint' (or there is no acceptable conversion) -ERROR: 0:29: '-' : wrong operand type no operation '-' exists that takes an operand of type layout( binding=0 offset=0) uniform atomic_uint (or there is no acceptable conversion) -ERROR: 0:31: '[]' : scalar integer expression required -ERROR: 0:34: 'assign' : l-value required "counter" (can't modify a uniform) -ERROR: 0:34: 'assign' : cannot convert from ' const int' to 'layout( binding=0 offset=0) uniform atomic_uint' -ERROR: 0:37: 'atomic_uint' : atomic_uints can only be used in uniform variables or function parameters: acin -ERROR: 0:38: 'atomic_uint' : atomic_uints can only be used in uniform variables or function parameters: acg -ERROR: 0:47: 'offset' : atomic counters sharing the same offset: 12 -ERROR: 0:48: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCounterBindings -ERROR: 13 compilation errors. No code generated. +ERROR: 0:4: 'counter' : redefinition +ERROR: 0:11: 'atomic_uint' : samplers and atomic_uints cannot be output parameters +ERROR: 0:13: 'return' : type does not match, or is not convertible to, the function's return type +ERROR: 0:19: 'atomic_uint' : atomic_uints can only be used in uniform variables or function parameters: non_uniform_counter +ERROR: 0:24: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCounterBindings +ERROR: 0:29: '+' : wrong operand types: no operation '+' exists that takes a left-hand operand of type 'layout( binding=0 offset=0) uniform atomic_uint' and a right operand of type 'layout( binding=0 offset=0) uniform atomic_uint' (or there is no acceptable conversion) +ERROR: 0:30: '-' : wrong operand type no operation '-' exists that takes an operand of type layout( binding=0 offset=0) uniform atomic_uint (or there is no acceptable conversion) +ERROR: 0:32: '[]' : scalar integer expression required +ERROR: 0:35: 'assign' : l-value required "counter" (can't modify a uniform) +ERROR: 0:35: 'assign' : cannot convert from ' const int' to 'layout( binding=0 offset=0) uniform atomic_uint' +ERROR: 0:38: 'atomic_uint' : atomic_uints can only be used in uniform variables or function parameters: acin +ERROR: 0:39: 'atomic_uint' : atomic_uints can only be used in uniform variables or function parameters: acg +ERROR: 0:48: 'offset' : atomic counters sharing the same offset: 12 +ERROR: 0:49: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCounterBindings +ERROR: 14 compilation errors. No code generated. Shader version: 420 ERROR: node is still EOpNull! -0:5 Function Definition: func(au1; ( global uint) -0:5 Function Parameters: -0:5 'c' ( in atomic_uint) -0:7 Sequence -0:7 Branch: Return with expression -0:7 AtomicCounterIncrement ( global uint) -0:7 'c' ( in atomic_uint) -0:10 Function Definition: func2(au1; ( global uint) -0:10 Function Parameters: -0:10 'c' ( out atomic_uint) -0:12 Sequence -0:12 Branch: Return with expression -0:12 'counter' (layout( binding=0 offset=0) uniform atomic_uint) +0:6 Function Definition: func(au1; ( global uint) +0:6 Function Parameters: +0:6 'c' ( in atomic_uint) +0:8 Sequence +0:8 Branch: Return with expression +0:8 AtomicCounterIncrement ( global uint) +0:8 'c' ( in atomic_uint) +0:11 Function Definition: func2(au1; ( global uint) +0:11 Function Parameters: +0:11 'c' ( out atomic_uint) +0:13 Sequence 0:13 Branch: Return with expression -0:13 AtomicCounter ( global uint) -0:13 'counter' (layout( binding=0 offset=0) uniform atomic_uint) -0:16 Function Definition: main( ( global void) -0:16 Function Parameters: +0:13 'counter' (layout( binding=0 offset=0) uniform atomic_uint) +0:14 Branch: Return with expression +0:14 AtomicCounter ( global uint) +0:14 'counter' (layout( binding=0 offset=0) uniform atomic_uint) +0:17 Function Definition: main( ( global void) +0:17 Function Parameters: 0:? Sequence -0:19 Sequence -0:19 move second child to first child ( temp uint) -0:19 'val' ( temp uint) -0:19 AtomicCounter ( global uint) -0:19 'counter' (layout( binding=0 offset=0) uniform atomic_uint) -0:20 AtomicCounterDecrement ( global uint) -0:20 'counter' (layout( binding=0 offset=0) uniform atomic_uint) -0:26 Function Definition: opac( ( global void) -0:26 Function Parameters: -0:28 Sequence -0:28 'counter' (layout( binding=0 offset=0) uniform atomic_uint) +0:20 Sequence +0:20 move second child to first child ( temp uint) +0:20 'val' ( temp uint) +0:20 AtomicCounter ( global uint) +0:20 'counter' (layout( binding=0 offset=0) uniform atomic_uint) +0:21 AtomicCounterDecrement ( global uint) +0:21 'counter' (layout( binding=0 offset=0) uniform atomic_uint) +0:27 Function Definition: opac( ( global void) +0:27 Function Parameters: +0:29 Sequence 0:29 'counter' (layout( binding=0 offset=0) uniform atomic_uint) -0:31 indirect index ( temp int) -0:31 'a' ( temp 3-element array of int) -0:31 'counter' (layout( binding=0 offset=0) uniform atomic_uint) -0:32 direct index (layout( binding=1 offset=3) temp atomic_uint) -0:32 'countArr' (layout( binding=1 offset=3) uniform 4-element array of atomic_uint) -0:32 Constant: -0:32 2 (const int) -0:33 indirect index (layout( binding=1 offset=3) temp atomic_uint) +0:30 'counter' (layout( binding=0 offset=0) uniform atomic_uint) +0:32 indirect index ( temp int) +0:32 'a' ( temp 3-element array of int) +0:32 'counter' (layout( binding=0 offset=0) uniform atomic_uint) +0:33 direct index (layout( binding=1 offset=3) temp atomic_uint) 0:33 'countArr' (layout( binding=1 offset=3) uniform 4-element array of atomic_uint) -0:33 'i' ( uniform int) -0:34 'counter' (layout( binding=0 offset=0) uniform atomic_uint) +0:33 Constant: +0:33 2 (const int) +0:34 indirect index (layout( binding=1 offset=3) temp atomic_uint) +0:34 'countArr' (layout( binding=1 offset=3) uniform 4-element array of atomic_uint) +0:34 'i' ( uniform int) +0:35 'counter' (layout( binding=0 offset=0) uniform atomic_uint) 0:? Linker Objects 0:? 'counter' (layout( binding=0 offset=0) uniform atomic_uint) 0:? 'countArr' (layout( binding=1 offset=3) uniform 4-element array of atomic_uint) @@ -68,8 +69,8 @@ ERROR: node is still EOpNull! 0:? 'aNoBind' ( uniform atomic_uint) 0:? 'aOffset' (layout( binding=0 offset=32) uniform atomic_uint) 0:? 'bar3' (layout( binding=0 offset=4) uniform atomic_uint) -0:? 'ac' (layout( binding=0 offset=8) uniform 3-element array of atomic_uint) -0:? 'ad' (layout( binding=0 offset=20) uniform atomic_uint) +0:? 'ac' (layout( binding=0 offset=8) uniform 2-element array of atomic_uint) +0:? 'ad' (layout( binding=0 offset=16) uniform atomic_uint) 0:? 'bar4' (layout( offset=8) uniform atomic_uint) 0:? 'overlap' (layout( binding=0 offset=12) uniform atomic_uint) 0:? 'bigBind' (layout( binding=20) uniform atomic_uint) @@ -80,16 +81,16 @@ Linked fragment stage: Shader version: 420 ERROR: node is still EOpNull! -0:16 Function Definition: main( ( global void) -0:16 Function Parameters: +0:17 Function Definition: main( ( global void) +0:17 Function Parameters: 0:? Sequence -0:19 Sequence -0:19 move second child to first child ( temp uint) -0:19 'val' ( temp uint) -0:19 AtomicCounter ( global uint) -0:19 'counter' (layout( binding=0 offset=0) uniform atomic_uint) -0:20 AtomicCounterDecrement ( global uint) -0:20 'counter' (layout( binding=0 offset=0) uniform atomic_uint) +0:20 Sequence +0:20 move second child to first child ( temp uint) +0:20 'val' ( temp uint) +0:20 AtomicCounter ( global uint) +0:20 'counter' (layout( binding=0 offset=0) uniform atomic_uint) +0:21 AtomicCounterDecrement ( global uint) +0:21 'counter' (layout( binding=0 offset=0) uniform atomic_uint) 0:? Linker Objects 0:? 'counter' (layout( binding=0 offset=0) uniform atomic_uint) 0:? 'countArr' (layout( binding=1 offset=3) uniform 4-element array of atomic_uint) @@ -99,8 +100,8 @@ ERROR: node is still EOpNull! 0:? 'aNoBind' ( uniform atomic_uint) 0:? 'aOffset' (layout( binding=0 offset=32) uniform atomic_uint) 0:? 'bar3' (layout( binding=0 offset=4) uniform atomic_uint) -0:? 'ac' (layout( binding=0 offset=8) uniform 3-element array of atomic_uint) -0:? 'ad' (layout( binding=0 offset=20) uniform atomic_uint) +0:? 'ac' (layout( binding=0 offset=8) uniform 2-element array of atomic_uint) +0:? 'ad' (layout( binding=0 offset=16) uniform atomic_uint) 0:? 'bar4' (layout( offset=8) uniform atomic_uint) 0:? 'overlap' (layout( binding=0 offset=12) uniform atomic_uint) 0:? 'bigBind' (layout( binding=20) uniform atomic_uint) diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 9c46d57c..2688af71 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -6035,6 +6035,10 @@ void TParseContext::fixOffset(const TSourceLoc& loc, TSymbol& symbol) offset = qualifier.layoutOffset; else offset = atomicUintOffsets[qualifier.layoutBinding]; + + if (offset % 4 != 0) + error(loc, "atomic counters offset should align based on 4:", "offset", "%d", offset); + symbol.getWritableType().getQualifier().layoutOffset = offset; // Check for overlap From 5de15a256eb092ad4de283491777464bf3a86e5c Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Thu, 26 Dec 2019 10:56:54 -0700 Subject: [PATCH 07/19] HLSL: Fix #2037: Integer dot used incorrect input for adds. --- SPIRV/GlslangToSpv.cpp | 2 +- Test/baseResults/hlsl.int.dot.frag.out | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 745dd7f2..07556366 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -7482,7 +7482,7 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv:: id = builder.createCompositeExtract(mulOp, typeId, 0); for (int i = 1; i < componentCount; ++i) { builder.setPrecision(id, precision); - id = builder.createBinOp(spv::OpIAdd, typeId, id, builder.createCompositeExtract(operands[0], typeId, i)); + id = builder.createBinOp(spv::OpIAdd, typeId, id, builder.createCompositeExtract(mulOp, typeId, i)); } } else { switch (consumedOperands) { diff --git a/Test/baseResults/hlsl.int.dot.frag.out b/Test/baseResults/hlsl.int.dot.frag.out index a691836f..7ea22a14 100644 --- a/Test/baseResults/hlsl.int.dot.frag.out +++ b/Test/baseResults/hlsl.int.dot.frag.out @@ -295,7 +295,7 @@ gl_FragCoord origin is upper left 39: 17(ivec2) Load 19(i3) 40: 17(ivec2) IMul 38 39 41: 11(int) CompositeExtract 40 0 - 42: 11(int) CompositeExtract 38 1 + 42: 11(int) CompositeExtract 40 1 43: 11(int) IAdd 41 42 44: 17(ivec2) CompositeConstruct 43 43 Store 19(i3) 44 @@ -303,9 +303,9 @@ gl_FragCoord origin is upper left 46: 22(ivec3) Load 24(i4) 47: 22(ivec3) IMul 45 46 48: 11(int) CompositeExtract 47 0 - 49: 11(int) CompositeExtract 45 1 + 49: 11(int) CompositeExtract 47 1 50: 11(int) IAdd 48 49 - 51: 11(int) CompositeExtract 45 2 + 51: 11(int) CompositeExtract 47 2 52: 11(int) IAdd 50 51 53: 22(ivec3) CompositeConstruct 52 52 52 Store 24(i4) 53 @@ -313,11 +313,11 @@ gl_FragCoord origin is upper left 55: 27(ivec4) Load 29(i5) 56: 27(ivec4) IMul 54 55 57: 11(int) CompositeExtract 56 0 - 58: 11(int) CompositeExtract 54 1 + 58: 11(int) CompositeExtract 56 1 59: 11(int) IAdd 57 58 - 60: 11(int) CompositeExtract 54 2 + 60: 11(int) CompositeExtract 56 2 61: 11(int) IAdd 59 60 - 62: 11(int) CompositeExtract 54 3 + 62: 11(int) CompositeExtract 56 3 63: 11(int) IAdd 61 62 64: 27(ivec4) CompositeConstruct 63 63 63 63 Store 29(i5) 64 From 05a5b53208e1eee47fd8fe6a8871e147833d1a96 Mon Sep 17 00:00:00 2001 From: Roy Date: Fri, 3 Jan 2020 16:21:34 +0800 Subject: [PATCH 08/19] Fix glslang can't link multiple AST in a single stage Root cause: GlslangToSpv use symbol structure's ptr as a map key, but multiple shader object can build a new AST. In the AST the the same symbol has different ptr point to their structure, so indext map faild. solution: Add a new map glslangTypeToIdMap to map ptr to symbol id, and use symbol id to index memberRemapper. --- SPIRV/GlslangToSpv.cpp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 07556366..0c8a87e3 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -245,7 +245,9 @@ protected: std::unordered_map functionMap; std::unordered_map structMap[glslang::ElpCount][glslang::ElmCount]; // for mapping glslang block indices to spv indices (e.g., due to hidden members): - std::unordered_map > memberRemapper; + std::unordered_map> memberRemapper; + // for mapping glslang symbol struct to symbol Id + std::unordered_map glslangTypeToIdMap; std::stack breakForLoop; // false means break for switch std::unordered_map counterOriginator; // Map pointee types for EbtReference to their forward pointers @@ -1661,6 +1663,9 @@ void TGlslangToSpvTraverser::dumpSpv(std::vector& out) void TGlslangToSpvTraverser::visitSymbol(glslang::TIntermSymbol* symbol) { SpecConstantOpModeGuard spec_constant_op_mode_setter(&builder); + if (symbol->getType().isStruct()) + glslangTypeToIdMap[symbol->getType().getStruct()] = symbol->getId(); + if (symbol->getType().getQualifier().isSpecConstant()) spec_constant_op_mode_setter.turnOnSpecConstantOpMode(); @@ -1753,6 +1758,12 @@ void TGlslangToSpvTraverser::visitSymbol(glslang::TIntermSymbol* symbol) bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::TIntermBinary* node) { builder.setLine(node->getLoc().line, node->getLoc().getFilename()); + if (node->getLeft()->getAsSymbolNode() != nullptr && node->getLeft()->getType().isStruct()) { + glslangTypeToIdMap[node->getLeft()->getType().getStruct()] = node->getLeft()->getAsSymbolNode()->getId(); + } + if (node->getRight()->getAsSymbolNode() != nullptr && node->getRight()->getType().isStruct()) { + glslangTypeToIdMap[node->getRight()->getType().getStruct()] = node->getRight()->getAsSymbolNode()->getId(); + } SpecConstantOpModeGuard spec_constant_op_mode_setter(&builder); if (node->getType().getQualifier().isSpecConstant()) @@ -1857,9 +1868,12 @@ bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::T { // This may be, e.g., an anonymous block-member selection, which generally need // index remapping due to hidden members in anonymous blocks. - std::vector& remapper = memberRemapper[node->getLeft()->getType().getStruct()]; - assert(remapper.size() > 0); - spvIndex = remapper[glslangIndex]; + int glslangId = glslangTypeToIdMap[node->getLeft()->getType().getStruct()]; + if (memberRemapper.find(glslangId) != memberRemapper.end()) { + std::vector& remapper = memberRemapper[glslangId]; + assert(remapper.size() > 0); + spvIndex = remapper[glslangIndex]; + } } // normal case for indexing array or structure or block @@ -3483,7 +3497,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty // else, we haven't seen it... if (type.getBasicType() == glslang::EbtBlock) - memberRemapper[glslangMembers].resize(glslangMembers->size()); + memberRemapper[glslangTypeToIdMap[glslangMembers]].resize(glslangMembers->size()); spvType = convertGlslangStructToSpvType(type, glslangMembers, explicitLayout, qualifier); } break; @@ -3619,15 +3633,15 @@ spv::Id TGlslangToSpvTraverser::convertGlslangStructToSpvType(const glslang::TTy if (glslangMember.hiddenMember()) { ++memberDelta; if (type.getBasicType() == glslang::EbtBlock) - memberRemapper[glslangMembers][i] = -1; + memberRemapper[glslangTypeToIdMap[glslangMembers]][i] = -1; } else { if (type.getBasicType() == glslang::EbtBlock) { if (filterMember(glslangMember)) { memberDelta++; - memberRemapper[glslangMembers][i] = -1; + memberRemapper[glslangTypeToIdMap[glslangMembers]][i] = -1; continue; } - memberRemapper[glslangMembers][i] = i - memberDelta; + memberRemapper[glslangTypeToIdMap[glslangMembers]][i] = i - memberDelta; } // modify just this child's view of the qualifier glslang::TQualifier memberQualifier = glslangMember.getQualifier(); @@ -3685,7 +3699,7 @@ void TGlslangToSpvTraverser::decorateStructType(const glslang::TType& type, glslang::TType& glslangMember = *(*glslangMembers)[i].type; int member = i; if (type.getBasicType() == glslang::EbtBlock) { - member = memberRemapper[glslangMembers][i]; + member = memberRemapper[glslangTypeToIdMap[glslangMembers]][i]; if (filterMember(glslangMember)) continue; } From a3c7a25e104d7c7132848b2c042af627472e6a42 Mon Sep 17 00:00:00 2001 From: Chow Date: Tue, 26 Nov 2019 17:27:33 +0800 Subject: [PATCH 09/19] Add support for ARB_gpu_shader_fp64 GLSL Version : >= 150 Purpose: Allow users to use features by enabling this extension, even in low versions. Extension Name: ARB_gpu_shader_fp64 Builtin-variables: Nah Builtin-functions: functions overloaded for this extension, please check registry in reference. Keywords: Double Features: add support for type "double" Reference: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_gpu_shader_fp64.txt Add support for implicit conversion 1. Remove builtin double vertex (this is introduced by vertex_attrib_64bit 2. Add extension check and implicit conversion as double has been introduced 3. Add test results. --- Test/150.frag | 9 ++++ Test/baseResults/150.frag.out | 62 +++++++++++++++++++++- glslang/MachineIndependent/Initialize.cpp | 8 +-- glslang/MachineIndependent/ParseHelper.cpp | 2 +- glslang/MachineIndependent/Scan.cpp | 9 +++- glslang/MachineIndependent/Versions.cpp | 7 ++- glslang/MachineIndependent/Versions.h | 1 + glslang/MachineIndependent/glslang.m4 | 32 +++++------ glslang/MachineIndependent/glslang.y | 32 +++++------ glslang/MachineIndependent/glslang_tab.cpp | 32 +++++------ glslang/MachineIndependent/parseVersions.h | 4 +- 11 files changed, 138 insertions(+), 60 deletions(-) diff --git a/Test/150.frag b/Test/150.frag index e87d6336..1985d6ef 100644 --- a/Test/150.frag +++ b/Test/150.frag @@ -49,3 +49,12 @@ int primitiveID() return gl_PrimitiveID; gl_PerFragment; // ERROR, block name can't get reused } + +in double type1; // ERROR +#extension GL_ARB_gpu_shader_fp64 : enable +double type2; +double type3 = 2.0; +int absTest = sqrt(type3); +double absTest2 = sqrt(type3); +double absTest3 = sqrt(2); +float dk = sqrt(11); \ No newline at end of file diff --git a/Test/baseResults/150.frag.out b/Test/baseResults/150.frag.out index e51b13d1..18c19538 100644 --- a/Test/baseResults/150.frag.out +++ b/Test/baseResults/150.frag.out @@ -5,10 +5,15 @@ ERROR: 0:6: 'layout qualifier' : can only apply origin_upper_left and pixel_cent ERROR: 0:14: 'gl_FragCoord' : cannot redeclare after use ERROR: 0:50: 'gl_PerFragment' : cannot be used (maybe an instance name is needed) ERROR: 0:50: 'gl_PerFragment' : undeclared identifier -ERROR: 6 compilation errors. No code generated. +ERROR: 0:53: 'double' : Reserved word. +ERROR: 0:53: 'double' : not supported for this version or the enabled extensions +ERROR: 0:53: 'double' : must be qualified as flat in +ERROR: 0:57: '=' : cannot convert from ' global double' to ' global int' +ERROR: 10 compilation errors. No code generated. Shader version: 150 +Requested GL_ARB_gpu_shader_fp64 gl_FragCoord pixel center is integer gl_FragCoord origin is upper left ERROR: node is still EOpNull! @@ -109,6 +114,26 @@ ERROR: node is still EOpNull! 0:49 Branch: Return with expression 0:49 'gl_PrimitiveID' ( flat in int PrimitiveID) 0:50 'gl_PerFragment' ( temp float) +0:56 Sequence +0:56 move second child to first child ( temp double) +0:56 'type3' ( global double) +0:56 Constant: +0:56 2.000000 +0:58 Sequence +0:58 move second child to first child ( temp double) +0:58 'absTest2' ( global double) +0:58 sqrt ( global double) +0:58 'type3' ( global double) +0:59 Sequence +0:59 move second child to first child ( temp double) +0:59 'absTest3' ( global double) +0:59 Constant: +0:59 1.414214 +0:60 Sequence +0:60 move second child to first child ( temp float) +0:60 'dk' ( global float) +0:60 Constant: +0:60 3.316625 0:? Linker Objects 0:? 'gl_FragCoord' ( gl_FragCoord 4-component vector of float FragCoord) 0:? 'foo' ( smooth in 4-component vector of float) @@ -123,12 +148,20 @@ ERROR: node is still EOpNull! 0:? 'p2' ( flat in 2-component vector of int) 0:? 'p3' ( flat in 3-component vector of int) 0:? 'samp' ( flat in int) +0:? 'type1' ( smooth in double) +0:? 'type2' ( global double) +0:? 'type3' ( global double) +0:? 'absTest' ( global int) +0:? 'absTest2' ( global double) +0:? 'absTest3' ( global double) +0:? 'dk' ( global float) Linked fragment stage: Shader version: 150 +Requested GL_ARB_gpu_shader_fp64 gl_FragCoord pixel center is integer gl_FragCoord origin is upper left ERROR: node is still EOpNull! @@ -144,6 +177,26 @@ ERROR: node is still EOpNull! 0:18 'patch' ( global float) 0:18 Constant: 0:18 3.100000 +0:56 Sequence +0:56 move second child to first child ( temp double) +0:56 'type3' ( global double) +0:56 Constant: +0:56 2.000000 +0:58 Sequence +0:58 move second child to first child ( temp double) +0:58 'absTest2' ( global double) +0:58 sqrt ( global double) +0:58 'type3' ( global double) +0:59 Sequence +0:59 move second child to first child ( temp double) +0:59 'absTest3' ( global double) +0:59 Constant: +0:59 1.414214 +0:60 Sequence +0:60 move second child to first child ( temp float) +0:60 'dk' ( global float) +0:60 Constant: +0:60 3.316625 0:? Linker Objects 0:? 'gl_FragCoord' ( gl_FragCoord 4-component vector of float FragCoord) 0:? 'foo' ( smooth in 4-component vector of float) @@ -158,4 +211,11 @@ ERROR: node is still EOpNull! 0:? 'p2' ( flat in 2-component vector of int) 0:? 'p3' ( flat in 3-component vector of int) 0:? 'samp' ( flat in int) +0:? 'type1' ( smooth in double) +0:? 'type2' ( global double) +0:? 'type3' ( global double) +0:? 'absTest' ( global int) +0:? 'absTest2' ( global double) +0:? 'absTest3' ( global double) +0:? 'dk' ( global float) diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 90106d92..2a5025b7 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -690,7 +690,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV // // double functions added to desktop 4.00, but not fma, frexp, ldexp, or pack/unpack // - if (profile != EEsProfile && version >= 400) { + if (profile != EEsProfile && version >= 150) { // ARB_gpu_shader_fp64 commonBuiltins.append( "double sqrt(double);" @@ -1298,15 +1298,15 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV "vec3 fma(vec3, vec3, vec3 );" "vec4 fma(vec4, vec4, vec4 );" "\n"); + } - if (profile != EEsProfile) { + if (profile != EEsProfile && version >= 150) { // ARB_gpu_shader_fp64 commonBuiltins.append( "double fma(double, double, double);" "dvec2 fma(dvec2, dvec2, dvec2 );" "dvec3 fma(dvec3, dvec3, dvec3 );" "dvec4 fma(dvec4, dvec4, dvec4 );" "\n"); - } } if ((profile == EEsProfile && version >= 310) || @@ -1325,7 +1325,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV "\n"); } - if (profile != EEsProfile && version >= 400) { + if (profile != EEsProfile && version >= 150) { // ARB_gpu_shader_fp64 commonBuiltins.append( "double frexp(double, out int);" "dvec2 frexp( dvec2, out ivec2);" diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index b9ab5c82..11db9651 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -6091,7 +6091,7 @@ const TFunction* TParseContext::findFunction(const TSourceLoc& loc, const TFunct if (isEsProfile() || version < 120) function = findFunctionExact(loc, call, builtIn); else if (version < 400) - function = findFunction120(loc, call, builtIn); + function = extensionTurnedOn(E_GL_ARB_gpu_shader_fp64) ? findFunction400(loc, call, builtIn) : findFunction120(loc, call, builtIn); else if (explicitTypesEnabled) function = findFunctionExplicitTypes(loc, call, builtIn); else diff --git a/glslang/MachineIndependent/Scan.cpp b/glslang/MachineIndependent/Scan.cpp index 710af4ab..fd18fd4d 100644 --- a/glslang/MachineIndependent/Scan.cpp +++ b/glslang/MachineIndependent/Scan.cpp @@ -1166,7 +1166,10 @@ int TScanContext::tokenizeIdentifier() case DVEC3: case DVEC4: afterType = true; - if (parseContext.isEsProfile() || parseContext.version < 400) + if (parseContext.isEsProfile() || parseContext.version < 150 || + (!parseContext.symbolTable.atBuiltInLevel() && + parseContext.version < 400 && + !parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_fp64))) reservedWord(); return keyword; @@ -1741,7 +1744,9 @@ int TScanContext::dMat() return keyword; } - if (!parseContext.isEsProfile() && parseContext.version >= 400) + if (!parseContext.isEsProfile() && (parseContext.version >= 400 || + parseContext.symbolTable.atBuiltInLevel() || + (parseContext.version >= 150 && parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_fp64)))) return keyword; if (parseContext.isForwardCompatible()) diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp index 23f74232..409e3ce4 100644 --- a/glslang/MachineIndependent/Versions.cpp +++ b/glslang/MachineIndependent/Versions.cpp @@ -184,6 +184,7 @@ void TParseVersions::initializeExtensionBehavior() extensionBehavior[E_GL_ARB_shader_texture_image_samples] = EBhDisable; extensionBehavior[E_GL_ARB_viewport_array] = EBhDisable; extensionBehavior[E_GL_ARB_gpu_shader_int64] = EBhDisable; + extensionBehavior[E_GL_ARB_gpu_shader_fp64] = EBhDisable; extensionBehavior[E_GL_ARB_shader_ballot] = EBhDisable; extensionBehavior[E_GL_ARB_sparse_texture2] = EBhDisable; extensionBehavior[E_GL_ARB_sparse_texture_clamp] = EBhDisable; @@ -394,6 +395,7 @@ void TParseVersions::getPreamble(std::string& preamble) "#define GL_ARB_shader_texture_image_samples 1\n" "#define GL_ARB_viewport_array 1\n" "#define GL_ARB_gpu_shader_int64 1\n" + "#define GL_ARB_gpu_shader_fp64 1\n" "#define GL_ARB_shader_ballot 1\n" "#define GL_ARB_sparse_texture2 1\n" "#define GL_ARB_sparse_texture_clamp 1\n" @@ -923,10 +925,11 @@ void TParseVersions::fullIntegerCheck(const TSourceLoc& loc, const char* op) } // Call for any operation needing GLSL double data-type support. -void TParseVersions::doubleCheck(const TSourceLoc& loc, const char* op) +void TParseVersions::doubleCheck(const TSourceLoc& loc, const char* op, bool builtIn) { requireProfile(loc, ECoreProfile | ECompatibilityProfile, op); - profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, nullptr, op); + if (!builtIn) + profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, E_GL_ARB_gpu_shader_fp64, op); } // Call for any operation needing GLSL float16 data-type support. diff --git a/glslang/MachineIndependent/Versions.h b/glslang/MachineIndependent/Versions.h index d319a2d5..58558e59 100644 --- a/glslang/MachineIndependent/Versions.h +++ b/glslang/MachineIndependent/Versions.h @@ -136,6 +136,7 @@ const char* const E_GL_ARB_derivative_control = "GL_ARB_derivative_con const char* const E_GL_ARB_shader_texture_image_samples = "GL_ARB_shader_texture_image_samples"; const char* const E_GL_ARB_viewport_array = "GL_ARB_viewport_array"; const char* const E_GL_ARB_gpu_shader_int64 = "GL_ARB_gpu_shader_int64"; +const char* const E_GL_ARB_gpu_shader_fp64 = "GL_ARB_gpu_shader_fp64"; const char* const E_GL_ARB_shader_ballot = "GL_ARB_shader_ballot"; const char* const E_GL_ARB_sparse_texture2 = "GL_ARB_sparse_texture2"; const char* const E_GL_ARB_sparse_texture_clamp = "GL_ARB_sparse_texture_clamp"; diff --git a/glslang/MachineIndependent/glslang.m4 b/glslang/MachineIndependent/glslang.m4 index 20f2ba40..410db17f 100644 --- a/glslang/MachineIndependent/glslang.m4 +++ b/glslang/MachineIndependent/glslang.m4 @@ -1751,7 +1751,7 @@ type_specifier_nonarray } GLSLANG_WEB_EXCLUDE_ON | DOUBLE { - parseContext.doubleCheck($1.loc, "double"); + parseContext.doubleCheck($1.loc, "double", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; } @@ -1811,19 +1811,19 @@ GLSLANG_WEB_EXCLUDE_ON $$.basicType = EbtUint64; } | DVEC2 { - parseContext.doubleCheck($1.loc, "double vector"); + parseContext.doubleCheck($1.loc, "double vector", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setVector(2); } | DVEC3 { - parseContext.doubleCheck($1.loc, "double vector"); + parseContext.doubleCheck($1.loc, "double vector", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setVector(3); } | DVEC4 { - parseContext.doubleCheck($1.loc, "double vector"); + parseContext.doubleCheck($1.loc, "double vector", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setVector(4); @@ -2027,73 +2027,73 @@ GLSLANG_WEB_EXCLUDE_ON $$.setVector(4); } | DMAT2 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(2, 2); } | DMAT3 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(3, 3); } | DMAT4 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(4, 4); } | DMAT2X2 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(2, 2); } | DMAT2X3 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(2, 3); } | DMAT2X4 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(2, 4); } | DMAT3X2 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(3, 2); } | DMAT3X3 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(3, 3); } | DMAT3X4 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(3, 4); } | DMAT4X2 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(4, 2); } | DMAT4X3 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(4, 3); } | DMAT4X4 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(4, 4); diff --git a/glslang/MachineIndependent/glslang.y b/glslang/MachineIndependent/glslang.y index e263f3d7..2d744052 100644 --- a/glslang/MachineIndependent/glslang.y +++ b/glslang/MachineIndependent/glslang.y @@ -1751,7 +1751,7 @@ type_specifier_nonarray } | DOUBLE { - parseContext.doubleCheck($1.loc, "double"); + parseContext.doubleCheck($1.loc, "double", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; } @@ -1811,19 +1811,19 @@ type_specifier_nonarray $$.basicType = EbtUint64; } | DVEC2 { - parseContext.doubleCheck($1.loc, "double vector"); + parseContext.doubleCheck($1.loc, "double vector", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setVector(2); } | DVEC3 { - parseContext.doubleCheck($1.loc, "double vector"); + parseContext.doubleCheck($1.loc, "double vector", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setVector(3); } | DVEC4 { - parseContext.doubleCheck($1.loc, "double vector"); + parseContext.doubleCheck($1.loc, "double vector", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setVector(4); @@ -2027,73 +2027,73 @@ type_specifier_nonarray $$.setVector(4); } | DMAT2 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(2, 2); } | DMAT3 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(3, 3); } | DMAT4 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(4, 4); } | DMAT2X2 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(2, 2); } | DMAT2X3 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(2, 3); } | DMAT2X4 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(2, 4); } | DMAT3X2 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(3, 2); } | DMAT3X3 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(3, 3); } | DMAT3X4 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(3, 4); } | DMAT4X2 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(4, 2); } | DMAT4X3 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(4, 3); } | DMAT4X4 { - parseContext.doubleCheck($1.loc, "double matrix"); + parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(4, 4); diff --git a/glslang/MachineIndependent/glslang_tab.cpp b/glslang/MachineIndependent/glslang_tab.cpp index d2967973..bc1e3212 100644 --- a/glslang/MachineIndependent/glslang_tab.cpp +++ b/glslang/MachineIndependent/glslang_tab.cpp @@ -6498,7 +6498,7 @@ yyreduce: case 228: #line 1753 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double"); + parseContext.doubleCheck((yyvsp[0].lex).loc, "double", parseContext.symbolTable.atBuiltInLevel()); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; } @@ -6618,7 +6618,7 @@ yyreduce: case 240: #line 1813 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double vector"); + parseContext.doubleCheck((yyvsp[0].lex).loc, "double vector", parseContext.symbolTable.atBuiltInLevel()); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setVector(2); @@ -6629,7 +6629,7 @@ yyreduce: case 241: #line 1819 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double vector"); + parseContext.doubleCheck((yyvsp[0].lex).loc, "double vector", parseContext.symbolTable.atBuiltInLevel()); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setVector(3); @@ -6640,7 +6640,7 @@ yyreduce: case 242: #line 1825 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double vector"); + parseContext.doubleCheck((yyvsp[0].lex).loc, "double vector", parseContext.symbolTable.atBuiltInLevel()); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setVector(4); @@ -7014,7 +7014,7 @@ yyreduce: case 276: #line 2029 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(2, 2); @@ -7025,7 +7025,7 @@ yyreduce: case 277: #line 2035 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(3, 3); @@ -7036,7 +7036,7 @@ yyreduce: case 278: #line 2041 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(4, 4); @@ -7047,7 +7047,7 @@ yyreduce: case 279: #line 2047 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(2, 2); @@ -7058,7 +7058,7 @@ yyreduce: case 280: #line 2053 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(2, 3); @@ -7069,7 +7069,7 @@ yyreduce: case 281: #line 2059 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(2, 4); @@ -7080,7 +7080,7 @@ yyreduce: case 282: #line 2065 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(3, 2); @@ -7091,7 +7091,7 @@ yyreduce: case 283: #line 2071 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(3, 3); @@ -7102,7 +7102,7 @@ yyreduce: case 284: #line 2077 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(3, 4); @@ -7113,7 +7113,7 @@ yyreduce: case 285: #line 2083 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(4, 2); @@ -7124,7 +7124,7 @@ yyreduce: case 286: #line 2089 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(4, 3); @@ -7135,7 +7135,7 @@ yyreduce: case 287: #line 2095 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(4, 4); diff --git a/glslang/MachineIndependent/parseVersions.h b/glslang/MachineIndependent/parseVersions.h index aa1964fc..daa190dc 100644 --- a/glslang/MachineIndependent/parseVersions.h +++ b/glslang/MachineIndependent/parseVersions.h @@ -102,7 +102,7 @@ public: void updateExtensionBehavior(const char* const extension, TExtensionBehavior) { } void checkExtensionStage(const TSourceLoc&, const char* const extension) { } void fullIntegerCheck(const TSourceLoc&, const char* op) { } - void doubleCheck(const TSourceLoc&, const char* op) { } + void doubleCheck(const TSourceLoc&, const char* op, bool builtIn = false) { } bool float16Arithmetic() { return false; } void requireFloat16Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc) { } bool int16Arithmetic() { return false; } @@ -142,7 +142,7 @@ public: virtual void fullIntegerCheck(const TSourceLoc&, const char* op); virtual void unimplemented(const TSourceLoc&, const char* featureDesc); - virtual void doubleCheck(const TSourceLoc&, const char* op); + virtual void doubleCheck(const TSourceLoc&, const char* op, bool builtIn = false); virtual void float16Check(const TSourceLoc&, const char* op, bool builtIn = false); virtual void float16ScalarVectorCheck(const TSourceLoc&, const char* op, bool builtIn = false); virtual bool float16Arithmetic(); From ac6b7cf58180c74d04e612d2cf12e2027edd65db Mon Sep 17 00:00:00 2001 From: Chow Date: Mon, 6 Jan 2020 15:53:20 +0800 Subject: [PATCH 10/19] Add builtin constants Add builtin constants: gl_MaxFragmentUniformVectors and gl_MaxVertexUniformVectors. They should both be available since version 410 for core. --- Test/410.vert | 1 + Test/baseResults/410.vert.out | 12 ++++++++++++ glslang/MachineIndependent/Initialize.cpp | 8 ++++++++ 3 files changed, 21 insertions(+) diff --git a/Test/410.vert b/Test/410.vert index 0ecf4768..1891a670 100644 --- a/Test/410.vert +++ b/Test/410.vert @@ -6,4 +6,5 @@ in dmat4 dm4; void main() { + int test = gl_MaxFragmentUniformVectors; } diff --git a/Test/baseResults/410.vert.out b/Test/baseResults/410.vert.out index aacdf36c..79268bc9 100644 --- a/Test/baseResults/410.vert.out +++ b/Test/baseResults/410.vert.out @@ -3,6 +3,12 @@ Shader version: 410 0:? Sequence 0:7 Function Definition: main( ( global void) 0:7 Function Parameters: +0:9 Sequence +0:9 Sequence +0:9 move second child to first child ( temp int) +0:9 'test' ( temp int) +0:9 Constant: +0:9 16 (const int) 0:? Linker Objects 0:? 'd' ( in double) 0:? 'd3' ( in 3-component vector of double) @@ -18,6 +24,12 @@ Shader version: 410 0:? Sequence 0:7 Function Definition: main( ( global void) 0:7 Function Parameters: +0:9 Sequence +0:9 Sequence +0:9 move second child to first child ( temp int) +0:9 'test' ( temp int) +0:9 Constant: +0:9 16 (const int) 0:? Linker Objects 0:? 'd' ( in double) 0:? 'd3' ( in 3-component vector of double) diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 90106d92..1e810bcc 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -6627,6 +6627,14 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf } else { // non-ES profile + if (version > 400) { + snprintf(builtInConstant, maxSize, "const int gl_MaxVertexUniformVectors = %d;", resources.maxVertexUniformVectors); + s.append(builtInConstant); + + snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentUniformVectors = %d;", resources.maxFragmentUniformVectors); + s.append(builtInConstant); + } + snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs); s.append(builtInConstant); From 8db9eccc0baf30c9d22c496ab28db0fe1e4e97c5 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Mon, 6 Jan 2020 07:50:40 -0700 Subject: [PATCH 11/19] Bump revision --- glslang/Include/revision.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index 5933bce5..a0e4b206 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -1,3 +1,3 @@ // This header is generated by the make-revision script. -#define GLSLANG_PATCH_LEVEL 3500 +#define GLSLANG_PATCH_LEVEL 3559 From 3eb540fbe7b98d2e1059a13d4eacea294c12b609 Mon Sep 17 00:00:00 2001 From: Roy Date: Mon, 6 Jan 2020 15:02:14 +0800 Subject: [PATCH 12/19] Add missing extension defination This micro should been defined 1, if opengl 2.0 is required. --- glslang/MachineIndependent/Versions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp index 23f74232..dce8681e 100644 --- a/glslang/MachineIndependent/Versions.cpp +++ b/glslang/MachineIndependent/Versions.cpp @@ -338,7 +338,6 @@ void TParseVersions::getPreamble(std::string& preamble) // AEP "#define GL_ANDROID_extension_pack_es31a 1\n" - "#define GL_KHR_blend_equation_advanced 1\n" "#define GL_OES_sample_variables 1\n" "#define GL_OES_shader_image_atomic 1\n" "#define GL_OES_shader_multisample_interpolation 1\n" @@ -505,6 +504,7 @@ void TParseVersions::getPreamble(std::string& preamble) preamble += "#define GL_GOOGLE_cpp_style_line_directive 1\n" "#define GL_GOOGLE_include_directive 1\n" + "#define GL_KHR_blend_equation_advanced 1\n" ; #endif From ab6a58801f524a85decba86438a35c14d362aaf0 Mon Sep 17 00:00:00 2001 From: Chow Date: Wed, 8 Jan 2020 14:07:50 +0800 Subject: [PATCH 13/19] Move symbol builtin check to grammar stage FYI, move builtin check to type symbol check. Avoid modifying interface doubleCheck(). --- glslang/MachineIndependent/Versions.cpp | 7 +-- glslang/MachineIndependent/glslang.m4 | 68 ++++++++++++++++------ glslang/MachineIndependent/glslang.y | 68 ++++++++++++++++------ glslang/MachineIndependent/glslang_tab.cpp | 68 ++++++++++++++++------ glslang/MachineIndependent/parseVersions.h | 4 +- 5 files changed, 158 insertions(+), 57 deletions(-) diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp index 409e3ce4..8f3618c5 100644 --- a/glslang/MachineIndependent/Versions.cpp +++ b/glslang/MachineIndependent/Versions.cpp @@ -925,11 +925,10 @@ void TParseVersions::fullIntegerCheck(const TSourceLoc& loc, const char* op) } // Call for any operation needing GLSL double data-type support. -void TParseVersions::doubleCheck(const TSourceLoc& loc, const char* op, bool builtIn) +void TParseVersions::doubleCheck(const TSourceLoc& loc, const char* op) { - requireProfile(loc, ECoreProfile | ECompatibilityProfile, op); - if (!builtIn) - profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, E_GL_ARB_gpu_shader_fp64, op); + //requireProfile(loc, ECoreProfile | ECompatibilityProfile, op); + profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, E_GL_ARB_gpu_shader_fp64, op); } // Call for any operation needing GLSL float16 data-type support. diff --git a/glslang/MachineIndependent/glslang.m4 b/glslang/MachineIndependent/glslang.m4 index 410db17f..cd949c2d 100644 --- a/glslang/MachineIndependent/glslang.m4 +++ b/glslang/MachineIndependent/glslang.m4 @@ -402,7 +402,9 @@ GLSLANG_WEB_EXCLUDE_ON $$ = parseContext.intermediate.addConstantUnion((unsigned short)$1.u, $1.loc, true); } | DOUBLECONSTANT { - parseContext.doubleCheck($1.loc, "double literal"); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double literal"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double literal"); $$ = parseContext.intermediate.addConstantUnion($1.d, EbtDouble, $1.loc, true); } | FLOAT16CONSTANT { @@ -1751,7 +1753,9 @@ type_specifier_nonarray } GLSLANG_WEB_EXCLUDE_ON | DOUBLE { - parseContext.doubleCheck($1.loc, "double", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; } @@ -1811,19 +1815,25 @@ GLSLANG_WEB_EXCLUDE_ON $$.basicType = EbtUint64; } | DVEC2 { - parseContext.doubleCheck($1.loc, "double vector", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double vector"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double vector"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setVector(2); } | DVEC3 { - parseContext.doubleCheck($1.loc, "double vector", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double vector"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double vector"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setVector(3); } | DVEC4 { - parseContext.doubleCheck($1.loc, "double vector", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double vector"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double vector"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setVector(4); @@ -2027,73 +2037,97 @@ GLSLANG_WEB_EXCLUDE_ON $$.setVector(4); } | DMAT2 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(2, 2); } | DMAT3 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(3, 3); } | DMAT4 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(4, 4); } | DMAT2X2 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(2, 2); } | DMAT2X3 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(2, 3); } | DMAT2X4 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(2, 4); } | DMAT3X2 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(3, 2); } | DMAT3X3 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(3, 3); } | DMAT3X4 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(3, 4); } | DMAT4X2 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(4, 2); } | DMAT4X3 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(4, 3); } | DMAT4X4 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(4, 4); diff --git a/glslang/MachineIndependent/glslang.y b/glslang/MachineIndependent/glslang.y index 2d744052..9f30fdb2 100644 --- a/glslang/MachineIndependent/glslang.y +++ b/glslang/MachineIndependent/glslang.y @@ -402,7 +402,9 @@ primary_expression $$ = parseContext.intermediate.addConstantUnion((unsigned short)$1.u, $1.loc, true); } | DOUBLECONSTANT { - parseContext.doubleCheck($1.loc, "double literal"); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double literal"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double literal"); $$ = parseContext.intermediate.addConstantUnion($1.d, EbtDouble, $1.loc, true); } | FLOAT16CONSTANT { @@ -1751,7 +1753,9 @@ type_specifier_nonarray } | DOUBLE { - parseContext.doubleCheck($1.loc, "double", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; } @@ -1811,19 +1815,25 @@ type_specifier_nonarray $$.basicType = EbtUint64; } | DVEC2 { - parseContext.doubleCheck($1.loc, "double vector", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double vector"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double vector"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setVector(2); } | DVEC3 { - parseContext.doubleCheck($1.loc, "double vector", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double vector"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double vector"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setVector(3); } | DVEC4 { - parseContext.doubleCheck($1.loc, "double vector", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double vector"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double vector"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setVector(4); @@ -2027,73 +2037,97 @@ type_specifier_nonarray $$.setVector(4); } | DMAT2 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(2, 2); } | DMAT3 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(3, 3); } | DMAT4 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(4, 4); } | DMAT2X2 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(2, 2); } | DMAT2X3 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(2, 3); } | DMAT2X4 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(2, 4); } | DMAT3X2 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(3, 2); } | DMAT3X3 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(3, 3); } | DMAT3X4 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(3, 4); } | DMAT4X2 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(4, 2); } | DMAT4X3 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(4, 3); } | DMAT4X4 { - parseContext.doubleCheck($1.loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck($1.loc, "double matrix"); $$.init($1.loc, parseContext.symbolTable.atGlobalLevel()); $$.basicType = EbtDouble; $$.setMatrix(4, 4); diff --git a/glslang/MachineIndependent/glslang_tab.cpp b/glslang/MachineIndependent/glslang_tab.cpp index bc1e3212..2a47faad 100644 --- a/glslang/MachineIndependent/glslang_tab.cpp +++ b/glslang/MachineIndependent/glslang_tab.cpp @@ -4279,7 +4279,9 @@ yyreduce: case 15: #line 404 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double literal"); + parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double literal"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck((yyvsp[0].lex).loc, "double literal"); (yyval.interm.intermTypedNode) = parseContext.intermediate.addConstantUnion((yyvsp[0].lex).d, EbtDouble, (yyvsp[0].lex).loc, true); } #line 4286 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */ @@ -6498,7 +6500,9 @@ yyreduce: case 228: #line 1753 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck((yyvsp[0].lex).loc, "double"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; } @@ -6618,7 +6622,9 @@ yyreduce: case 240: #line 1813 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double vector", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double vector"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck((yyvsp[0].lex).loc, "double vector"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setVector(2); @@ -6629,7 +6635,9 @@ yyreduce: case 241: #line 1819 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double vector", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double vector"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck((yyvsp[0].lex).loc, "double vector"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setVector(3); @@ -6640,7 +6648,9 @@ yyreduce: case 242: #line 1825 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double vector", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double vector"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck((yyvsp[0].lex).loc, "double vector"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setVector(4); @@ -7014,7 +7024,9 @@ yyreduce: case 276: #line 2029 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(2, 2); @@ -7025,7 +7037,9 @@ yyreduce: case 277: #line 2035 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(3, 3); @@ -7036,7 +7050,9 @@ yyreduce: case 278: #line 2041 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(4, 4); @@ -7047,7 +7063,9 @@ yyreduce: case 279: #line 2047 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(2, 2); @@ -7058,7 +7076,9 @@ yyreduce: case 280: #line 2053 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(2, 3); @@ -7069,7 +7089,9 @@ yyreduce: case 281: #line 2059 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(2, 4); @@ -7080,7 +7102,9 @@ yyreduce: case 282: #line 2065 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(3, 2); @@ -7091,7 +7115,9 @@ yyreduce: case 283: #line 2071 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(3, 3); @@ -7102,7 +7128,9 @@ yyreduce: case 284: #line 2077 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(3, 4); @@ -7113,7 +7141,9 @@ yyreduce: case 285: #line 2083 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(4, 2); @@ -7124,7 +7154,9 @@ yyreduce: case 286: #line 2089 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(4, 3); @@ -7135,7 +7167,9 @@ yyreduce: case 287: #line 2095 "MachineIndependent/glslang.y" /* yacc.c:1646 */ { - parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix", parseContext.symbolTable.atBuiltInLevel()); + parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix"); + if (! parseContext.symbolTable.atBuiltInLevel()) + parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix"); (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel()); (yyval.interm.type).basicType = EbtDouble; (yyval.interm.type).setMatrix(4, 4); diff --git a/glslang/MachineIndependent/parseVersions.h b/glslang/MachineIndependent/parseVersions.h index daa190dc..aa1964fc 100644 --- a/glslang/MachineIndependent/parseVersions.h +++ b/glslang/MachineIndependent/parseVersions.h @@ -102,7 +102,7 @@ public: void updateExtensionBehavior(const char* const extension, TExtensionBehavior) { } void checkExtensionStage(const TSourceLoc&, const char* const extension) { } void fullIntegerCheck(const TSourceLoc&, const char* op) { } - void doubleCheck(const TSourceLoc&, const char* op, bool builtIn = false) { } + void doubleCheck(const TSourceLoc&, const char* op) { } bool float16Arithmetic() { return false; } void requireFloat16Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc) { } bool int16Arithmetic() { return false; } @@ -142,7 +142,7 @@ public: virtual void fullIntegerCheck(const TSourceLoc&, const char* op); virtual void unimplemented(const TSourceLoc&, const char* featureDesc); - virtual void doubleCheck(const TSourceLoc&, const char* op, bool builtIn = false); + virtual void doubleCheck(const TSourceLoc&, const char* op); virtual void float16Check(const TSourceLoc&, const char* op, bool builtIn = false); virtual void float16ScalarVectorCheck(const TSourceLoc&, const char* op, bool builtIn = false); virtual bool float16Arithmetic(); From 6f98892dd19f34f77ccc60ca313166ea60b85cb6 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Tue, 7 Jan 2020 07:03:11 -0700 Subject: [PATCH 14/19] Fix #1829: Add "--" command-line options for macro def/undef. This allows OpModuleProcessed logging to be consistent with everything taking "--" options. --- StandAlone/StandAlone.cpp | 29 ++++++++++++++++++++++------- Test/runtests | 4 ++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index c869fb12..28c5e150 100644 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -204,7 +204,7 @@ public: text.append("#define "); fixLine(def); - Processes.push_back("D"); + Processes.push_back("define-macro "); Processes.back().append(def); // The first "=" needs to turn into a space @@ -222,7 +222,7 @@ public: text.append("#undef "); fixLine(undef); - Processes.push_back("U"); + Processes.push_back("undef-macro "); Processes.back().append(undef); text.append(undef); @@ -500,6 +500,13 @@ void ProcessArguments(std::vector>& workItem } else Error("expects vulkan100 or opengl100", lowerword.c_str()); bumpArg(); + } else if (lowerword == "define-macro" || + lowerword == "d") { + if (argc > 1) + UserPreamble.addDef(argv[1]); + else + Error("expects ", argv[0]); + bumpArg(); } else if (lowerword == "dump-builtin-symbols") { DumpBuiltinSymbols = true; } else if (lowerword == "entry-point") { @@ -627,6 +634,13 @@ void ProcessArguments(std::vector>& workItem "spirv1.0, spirv1.1, spirv1.2, spirv1.3, spirv1.4, or spirv1.5"); } bumpArg(); + } else if (lowerword == "undef-macro" || + lowerword == "u") { + if (argc > 1) + UserPreamble.addUndef(argv[1]); + else + Error("expects ", argv[0]); + bumpArg(); } else if (lowerword == "variable-name" || // synonyms lowerword == "vn") { Options |= EOptionOutputHexadecimal; @@ -649,7 +663,7 @@ void ProcessArguments(std::vector>& workItem if (argv[0][2] == 0) Options |= EOptionReadHlsl; else - UserPreamble.addDef(getStringOperand("-D macro name")); + UserPreamble.addDef(getStringOperand("-D")); break; case 'u': uniformLocationOverrides.push_back(getUniformOverride()); @@ -692,7 +706,7 @@ void ProcessArguments(std::vector>& workItem bumpArg(); break; case 'U': - UserPreamble.addUndef(getStringOperand("-U: macro name")); + UserPreamble.addUndef(getStringOperand("-U")); break; case 'V': setVulkanSpv(); @@ -1502,8 +1516,8 @@ void usage() "Options:\n" " -C cascading errors; risk crash from accumulation of error recoveries\n" " -D input is HLSL (this is the default when any suffix is .hlsl)\n" - " -D\n" - " -D define a pre-processor macro\n" + " -D | --define-macro | --D \n" + " define a pre-processor macro\n" " -E print pre-processed GLSL; cannot be used with -l;\n" " errors will appear on stderr\n" " -G[ver] create SPIR-V binary, under OpenGL semantics; turns on -l;\n" @@ -1519,7 +1533,8 @@ void usage() " -Os optimizes SPIR-V to minimize size\n" " -S uses specified stage rather than parsing the file extension\n" " choices for are vert, tesc, tese, geom, frag, or comp\n" - " -U undefine a pre-processor macro\n" + " -U | --undef-macro | --U \n" + " undefine a pre-processor macro\n" " -V[ver] create SPIR-V binary, under Vulkan semantics; turns on -l;\n" " default file name is .spv (-o overrides this)\n" " 'ver', when present, is the version of the input semantics,\n" diff --git a/Test/runtests b/Test/runtests index 23406dc3..d1ca221f 100755 --- a/Test/runtests +++ b/Test/runtests @@ -176,9 +176,9 @@ diff -b $BASEDIR/hlsl.pp.line3.frag.out $TARGETDIR/hlsl.pp.line3.frag.out || HAS # Testing -D and -U # echo "Testing -D and -U" -$EXE -DUNDEFED -UIN_SHADER -DFOO=200 -i -l -UUNDEFED -DMUL=FOO*2 glsl.-D-U.frag > $TARGETDIR/glsl.-D-U.frag.out +$EXE -DUNDEFED -UIN_SHADER -DFOO=200 -i -l --U UNDEFED --define-macro MUL=FOO*2 glsl.-D-U.frag > $TARGETDIR/glsl.-D-U.frag.out diff -b $BASEDIR/glsl.-D-U.frag.out $TARGETDIR/glsl.-D-U.frag.out || HASERROR=1 -$EXE -D -Od -e main -V -i -DUNDEFED -UIN_SHADER -DFOO=200 -UUNDEFED -Od hlsl.-D-U.frag > $TARGETDIR/hlsl.-D-U.frag.out +$EXE -D -Od -e main -V -i -DUNDEFED -UIN_SHADER --D FOO=200 --undef-macro UNDEFED -Od hlsl.-D-U.frag > $TARGETDIR/hlsl.-D-U.frag.out diff -b $BASEDIR/hlsl.-D-U.frag.out $TARGETDIR/hlsl.-D-U.frag.out || HASERROR=1 # From 273d3a50931951b52c5b1f46ea583c786f1be6c8 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Wed, 15 Jan 2020 00:10:41 -0700 Subject: [PATCH 15/19] SPV/Vulkan: Add support for Vulkan 1.2, which defaults to SPIR-V 1.5. --- SPIRV/SpvTools.cpp | 2 ++ StandAlone/StandAlone.cpp | 28 ++++++++++++------- Test/runtests | 1 + .../MachineIndependent/localintermediate.h | 3 ++ glslang/Public/ShaderLang.h | 1 + 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/SPIRV/SpvTools.cpp b/SPIRV/SpvTools.cpp index 7c3b0391..8db58c5f 100644 --- a/SPIRV/SpvTools.cpp +++ b/SPIRV/SpvTools.cpp @@ -67,6 +67,8 @@ spv_target_env MapToSpirvToolsEnv(const SpvVersion& spvVersion, spv::SpvBuildLog logger->missingFunctionality("Target version for SPIRV-Tools validator"); return spv_target_env::SPV_ENV_VULKAN_1_1; } + case glslang::EShTargetVulkan_1_2: + return spv_target_env::SPV_ENV_UNIVERSAL_1_5; //?? should change to SPV_ENV_VULKAN_1_2, when available default: break; } diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index 28c5e150..6e4c8d30 100644 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -608,6 +608,9 @@ void ProcessArguments(std::vector>& workItem } else if (strcmp(argv[1], "vulkan1.1") == 0) { setVulkanSpv(); ClientVersion = glslang::EShTargetVulkan_1_1; + } else if (strcmp(argv[1], "vulkan1.2") == 0) { + setVulkanSpv(); + ClientVersion = glslang::EShTargetVulkan_1_2; } else if (strcmp(argv[1], "opengl") == 0) { setOpenGlSpv(); ClientVersion = glslang::EShTargetOpenGL_450; @@ -630,7 +633,7 @@ void ProcessArguments(std::vector>& workItem TargetLanguage = glslang::EShTargetSpv; TargetVersion = glslang::EShTargetSpv_1_5; } else - Error("--target-env expected one of: vulkan1.0, vulkan1.1, opengl,\n" + Error("--target-env expected one of: vulkan1.0, vulkan1.1, vulkan1.2, opengl,\n" "spirv1.0, spirv1.1, spirv1.2, spirv1.3, spirv1.4, or spirv1.5"); } bumpArg(); @@ -825,6 +828,10 @@ void ProcessArguments(std::vector>& workItem TargetLanguage = glslang::EShTargetSpv; TargetVersion = glslang::EShTargetSpv_1_3; break; + case glslang::EShTargetVulkan_1_2: + TargetLanguage = glslang::EShTargetSpv; + TargetVersion = glslang::EShTargetSpv_1_5; + break; case glslang::EShTargetOpenGL_450: TargetLanguage = glslang::EShTargetSpv; TargetVersion = glslang::EShTargetSpv_1_0; @@ -1640,16 +1647,17 @@ void usage() " --sep synonym for --source-entrypoint\n" " --stdin read from stdin instead of from a file;\n" " requires providing the shader stage using -S\n" - " --target-env {vulkan1.0 | vulkan1.1 | opengl | \n" + " --target-env {vulkan1.0 | vulkan1.1 | vulkan1.2 | opengl | \n" " spirv1.0 | spirv1.1 | spirv1.2 | spirv1.3 | spirv1.4 | spirv1.5}\n" - " set execution environment that emitted code\n" - " will execute in (versus source language\n" - " semantics selected by --client) defaults:\n" - " * 'vulkan1.0' under '--client vulkan'\n" - " * 'opengl' under '--client opengl'\n" - " * 'spirv1.0' under --target-env vulkan1.0\n" - " * 'spirv1.3' under --target-env vulkan1.1\n" - " multiple --targen-env can be specified.\n" + " Set the execution environment that the\n" + " generated code will be executed in.\n" + " Defaults to:\n" + " * vulkan1.0 under --client vulkan\n" + " * opengl under --client opengl\n" + " * spirv1.0 under --target-env vulkan1.0\n" + " * spirv1.3 under --target-env vulkan1.1\n" + " * spirv1.5 under --target-env vulkan1.2\n" + " Multiple --target-env can be specified.\n" " --variable-name \n" " --vn creates a C header file that contains a\n" " uint32_t array named \n" diff --git a/Test/runtests b/Test/runtests index d1ca221f..1a7c7c94 100755 --- a/Test/runtests +++ b/Test/runtests @@ -189,6 +189,7 @@ $EXE --client vulkan100 spv.targetVulkan.vert || HASERROR=1 $EXE --client opengl100 spv.targetOpenGL.vert || HASERROR=1 $EXE --target-env vulkan1.0 spv.targetVulkan.vert || HASERROR=1 $EXE --target-env vulkan1.1 spv.targetVulkan.vert || HASERROR=1 +$EXE --target-env vulkan1.2 spv.targetVulkan.vert || HASERROR=1 $EXE --target-env opengl spv.targetOpenGL.vert || HASERROR=1 $EXE -V100 spv.targetVulkan.vert || HASERROR=1 $EXE -G100 spv.targetOpenGL.vert || HASERROR=1 diff --git a/glslang/MachineIndependent/localintermediate.h b/glslang/MachineIndependent/localintermediate.h index cb172e5e..683290af 100644 --- a/glslang/MachineIndependent/localintermediate.h +++ b/glslang/MachineIndependent/localintermediate.h @@ -332,6 +332,9 @@ public: case EShTargetVulkan_1_1: processes.addProcess("target-env vulkan1.1"); break; + case EShTargetVulkan_1_2: + processes.addProcess("target-env vulkan1.2"); + break; default: processes.addProcess("target-env vulkanUnknown"); break; diff --git a/glslang/Public/ShaderLang.h b/glslang/Public/ShaderLang.h index 4cc6c2f4..4fe5c7df 100755 --- a/glslang/Public/ShaderLang.h +++ b/glslang/Public/ShaderLang.h @@ -145,6 +145,7 @@ typedef enum { typedef enum { EShTargetVulkan_1_0 = (1 << 22), // Vulkan 1.0 EShTargetVulkan_1_1 = (1 << 22) | (1 << 12), // Vulkan 1.1 + EShTargetVulkan_1_2 = (1 << 22) | (2 << 12), // Vulkan 1.2 EShTargetOpenGL_450 = 450, // OpenGL } EShTargetClientVersion; From c3bb5d6914c2ee8ef70ec3237186754c33014d3d Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Wed, 15 Jan 2020 09:35:48 -0700 Subject: [PATCH 16/19] Update to latest SPIRV-Tools, supporting Vulkan 1.2. --- SPIRV/SpvTools.cpp | 2 +- known_good.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SPIRV/SpvTools.cpp b/SPIRV/SpvTools.cpp index 8db58c5f..97bd4e74 100644 --- a/SPIRV/SpvTools.cpp +++ b/SPIRV/SpvTools.cpp @@ -68,7 +68,7 @@ spv_target_env MapToSpirvToolsEnv(const SpvVersion& spvVersion, spv::SpvBuildLog return spv_target_env::SPV_ENV_VULKAN_1_1; } case glslang::EShTargetVulkan_1_2: - return spv_target_env::SPV_ENV_UNIVERSAL_1_5; //?? should change to SPV_ENV_VULKAN_1_2, when available + return spv_target_env::SPV_ENV_VULKAN_1_2; default: break; } diff --git a/known_good.json b/known_good.json index ada57d78..60e2c2d2 100644 --- a/known_good.json +++ b/known_good.json @@ -5,7 +5,7 @@ "site" : "github", "subrepo" : "KhronosGroup/SPIRV-Tools", "subdir" : "External/spirv-tools", - "commit" : "5c019b5923c1f6bf00a3ac28114ec4a7b1faa0e2" + "commit" : "323a81fc5e30e43a04e5e22af4cba98ca2a161e6" }, { "name" : "spirv-tools/external/spirv-headers", From 8a914f4293fd64ea4842e553828fb37f589703be Mon Sep 17 00:00:00 2001 From: Chow Date: Tue, 24 Dec 2019 11:49:02 +0800 Subject: [PATCH 17/19] Add Error check flag in io mapper GLSL could detect contradictory uniform binding, but missing error reporting, even if we could now observe error inside infosink. Add error check when first time validate uniform binding. When doing traversal, it should be zero error. This error check flag will be used during linking time. To quickly report errors like contradictory uniform bindings. Add error check flags for TDefaultGlslIoResolver when catching EPrefixInternalError --- glslang/MachineIndependent/iomapper.cpp | 3 +++ glslang/MachineIndependent/iomapper.h | 1 + 2 files changed, 4 insertions(+) diff --git a/glslang/MachineIndependent/iomapper.cpp b/glslang/MachineIndependent/iomapper.cpp index 3262c0a2..48564227 100644 --- a/glslang/MachineIndependent/iomapper.cpp +++ b/glslang/MachineIndependent/iomapper.cpp @@ -831,6 +831,7 @@ void TDefaultGlslIoResolver::reserverStorageSlot(TVarEntryInfo& ent, TInfoSink& if (iter->second != location) { TString errorMsg = "Invalid location: " + name; infoSink.info.message(EPrefixInternalError, errorMsg.c_str()); + hasError = true; } } } @@ -856,6 +857,7 @@ void TDefaultGlslIoResolver::reserverStorageSlot(TVarEntryInfo& ent, TInfoSink& if (iter->second != location) { TString errorMsg = "Invalid location: " + name; infoSink.info.message(EPrefixInternalError, errorMsg.c_str()); + hasError = true; } } } @@ -884,6 +886,7 @@ void TDefaultGlslIoResolver::reserverResourceSlot(TVarEntryInfo& ent, TInfoSink& if (iter->second != binding) { TString errorMsg = "Invalid binding: " + name; infoSink.info.message(EPrefixInternalError, errorMsg.c_str()); + hasError = true; } } } diff --git a/glslang/MachineIndependent/iomapper.h b/glslang/MachineIndependent/iomapper.h index 684e88d5..933e259f 100644 --- a/glslang/MachineIndependent/iomapper.h +++ b/glslang/MachineIndependent/iomapper.h @@ -129,6 +129,7 @@ public: uint32_t computeTypeLocationSize(const TType& type, EShLanguage stage); TSlotSetMap slots; + bool hasError = false; protected: TDefaultIoResolverBase(TDefaultIoResolverBase&); From 3ed344dd784ecbbc5855e613786f3a1238823e56 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Thu, 16 Jan 2020 00:52:28 -0700 Subject: [PATCH 18/19] Fix #2059, and also attempt to skip test bots [skip ci] --- .appveyor.yml | 14 ++++++++++++++ README.md | 10 +++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 32e8f2bd..44d5f046 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -17,6 +17,20 @@ branches: only: - master +# changes to these files don't need to trigger testing +skip_commits: + files: + - README.md + - README-spirv-remap.txt + - LICENSE.txt + - CODE_OF_CONDUCT.md + - BUILD.* + - WORKSPACE + - kokoro/* + - make-revision + - Android.mk + - _config.yml + # Travis advances the master-tot tag to current top of the tree after # each push into the master branch, because it relies on that tag to # upload build artifacts to the master-tot release. This will cause diff --git a/README.md b/README.md index 67801e47..7c3bdcf3 100755 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Deprecations `${CMAKE_INSTALL_INCLUDEDIR}`. This `SPIRV` folder is being moved to `glslang/SPIRV`. During the transition the `SPIRV` folder will be installed into both locations. The old install of `SPIRV/` will be removed as a CMake install -target no sooner then May 1, 2020. See issue #1964. +target no sooner than May 1, 2020. See issue #1964. Execution of Standalone Wrapper ------------------------------- @@ -185,7 +185,7 @@ Use the steps in [Build Steps](#build-steps), with the following notes/exception + turn on `-DENABLE_GLSLANG_WEB=ON` + optionally, for GLSL compilation error messages, turn on `-DENABLE_GLSLANG_WEB_DEVEL=ON` * `emsdk` needs to be present in your executable search path, *PATH* for - Bash-like enivironments + Bash-like environments + [Instructions located here](https://emscripten.org/docs/getting_started/downloads.html#sdk-download-and-install) * Wrap cmake call: `emcmake cmake` @@ -309,7 +309,7 @@ class TProgram Reflection queries ``` -For just validating (not generating code), subsitute these calls: +For just validating (not generating code), substitute these calls: ```cxx setEnvInput(EShSourceHlsl or EShSourceGlsl, stage, EShClientNone, 0); @@ -327,7 +327,7 @@ This interface is in roughly the first 2/3 of `ShaderLang.h`, and referred to as the `Sh*()` interface, as all the entry points start `Sh`. The `Sh*()` interface takes a "compiler" call-back object, which it calls after -building call back that is passed the AST and can then execute a backend on it. +building call back that is passed the AST and can then execute a back end on it. The following is a simplified resulting run-time call stack: @@ -354,7 +354,7 @@ Basic Internal Operation * The intermediate representation is very high-level, and represented as an in-memory tree. This serves to lose no information from the original program, and to have efficient transfer of the result from - parsing to the back-end. In the AST, constants are propogated and + parsing to the back-end. In the AST, constants are propagated and folded, and a very small amount of dead code is eliminated. To aid linking and reflection, the last top-level branch in the AST From b0ada80356ca7b560c600b93a596af1331442542 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Fri, 17 Jan 2020 00:11:12 -0700 Subject: [PATCH 19/19] HLSL: Fix #1974: ignore input primitives on non-entry-point functions. --- Test/baseResults/hlsl.gs-hs-mix.tesc.out | 2 - Test/baseResults/hlsl.semantic.geom.out | 292 +++++++++++++++++------ Test/hlsl.semantic.geom | 8 + hlsl/hlslGrammar.cpp | 2 + hlsl/hlslParseHelper.cpp | 13 +- hlsl/hlslParseHelper.h | 7 + 6 files changed, 244 insertions(+), 80 deletions(-) diff --git a/Test/baseResults/hlsl.gs-hs-mix.tesc.out b/Test/baseResults/hlsl.gs-hs-mix.tesc.out index fabc1109..ffa96b1b 100644 --- a/Test/baseResults/hlsl.gs-hs-mix.tesc.out +++ b/Test/baseResults/hlsl.gs-hs-mix.tesc.out @@ -1,7 +1,6 @@ hlsl.gs-hs-mix.tesc Shader version: 500 vertices = 3 -input primitive = triangles vertex spacing = fractional_odd_spacing triangle order = ccw 0:? Sequence @@ -402,7 +401,6 @@ Linked tessellation control stage: Shader version: 500 vertices = 3 -input primitive = triangles vertex spacing = fractional_odd_spacing triangle order = ccw 0:? Sequence diff --git a/Test/baseResults/hlsl.semantic.geom.out b/Test/baseResults/hlsl.semantic.geom.out index daf4eed2..29ec2351 100644 --- a/Test/baseResults/hlsl.semantic.geom.out +++ b/Test/baseResults/hlsl.semantic.geom.out @@ -66,6 +66,58 @@ output primitive = line_strip 0:13 Function Call: @main(u1[3];struct-S-f1-f1-f1-u1-u1-i11; ( temp void) 0:? 'VertexID' ( temp 3-element array of uint) 0:? 'OutputStream' ( temp structure{ temp float clip0, temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii}) +0:21 Function Definition: notmain(u1[2];struct-S-f1-f1-f1-u1-u1-i11; ( temp void) +0:21 Function Parameters: +0:21 'VertexID' ( in 2-element array of uint) +0:21 'OutputStream' ( out structure{ temp float clip0, temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii}) +0:? Sequence +0:23 Sequence +0:23 Sequence +0:23 move second child to first child ( temp float) +0:? 'OutputStream.clip0' ( out float Position) +0:23 clip0: direct index for structure ( temp float) +0:23 's' ( temp structure{ temp float clip0, temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii}) +0:23 Constant: +0:23 0 (const int) +0:? Sequence +0:23 move second child to first child ( temp float) +0:23 direct index ( out float ClipDistance) +0:? 'OutputStream.clip0' ( out 1-element array of float ClipDistance) +0:23 Constant: +0:23 0 (const int) +0:23 clip0: direct index for structure ( temp float) +0:23 's' ( temp structure{ temp float clip0, temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii}) +0:23 Constant: +0:23 1 (const int) +0:? Sequence +0:23 move second child to first child ( temp float) +0:23 direct index ( out float CullDistance) +0:? 'OutputStream.cull0' ( out 1-element array of float CullDistance) +0:23 Constant: +0:23 0 (const int) +0:23 cull0: direct index for structure ( temp float) +0:23 's' ( temp structure{ temp float clip0, temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii}) +0:23 Constant: +0:23 2 (const int) +0:23 move second child to first child ( temp uint) +0:? 'OutputStream.vpai' ( out uint ViewportIndex) +0:23 vpai: direct index for structure ( temp uint) +0:23 's' ( temp structure{ temp float clip0, temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii}) +0:23 Constant: +0:23 3 (const int) +0:23 move second child to first child ( temp uint) +0:? 'OutputStream.rtai' ( out uint Layer) +0:23 rtai: direct index for structure ( temp uint) +0:23 's' ( temp structure{ temp float clip0, temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii}) +0:23 Constant: +0:23 4 (const int) +0:23 move second child to first child ( temp int) +0:? 'OutputStream.ii' (layout( location=0) out int) +0:23 ii: direct index for structure ( temp int) +0:23 's' ( temp structure{ temp float clip0, temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii}) +0:23 Constant: +0:23 5 (const int) +0:23 EmitVertex ( temp void) 0:? Linker Objects 0:? 'VertexID' (layout( location=0) in 3-element array of uint) 0:? 'OutputStream.clip0' ( out float Position) @@ -146,6 +198,58 @@ output primitive = line_strip 0:13 Function Call: @main(u1[3];struct-S-f1-f1-f1-u1-u1-i11; ( temp void) 0:? 'VertexID' ( temp 3-element array of uint) 0:? 'OutputStream' ( temp structure{ temp float clip0, temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii}) +0:21 Function Definition: notmain(u1[2];struct-S-f1-f1-f1-u1-u1-i11; ( temp void) +0:21 Function Parameters: +0:21 'VertexID' ( in 2-element array of uint) +0:21 'OutputStream' ( out structure{ temp float clip0, temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii}) +0:? Sequence +0:23 Sequence +0:23 Sequence +0:23 move second child to first child ( temp float) +0:? 'OutputStream.clip0' ( out float Position) +0:23 clip0: direct index for structure ( temp float) +0:23 's' ( temp structure{ temp float clip0, temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii}) +0:23 Constant: +0:23 0 (const int) +0:? Sequence +0:23 move second child to first child ( temp float) +0:23 direct index ( out float ClipDistance) +0:? 'OutputStream.clip0' ( out 1-element array of float ClipDistance) +0:23 Constant: +0:23 0 (const int) +0:23 clip0: direct index for structure ( temp float) +0:23 's' ( temp structure{ temp float clip0, temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii}) +0:23 Constant: +0:23 1 (const int) +0:? Sequence +0:23 move second child to first child ( temp float) +0:23 direct index ( out float CullDistance) +0:? 'OutputStream.cull0' ( out 1-element array of float CullDistance) +0:23 Constant: +0:23 0 (const int) +0:23 cull0: direct index for structure ( temp float) +0:23 's' ( temp structure{ temp float clip0, temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii}) +0:23 Constant: +0:23 2 (const int) +0:23 move second child to first child ( temp uint) +0:? 'OutputStream.vpai' ( out uint ViewportIndex) +0:23 vpai: direct index for structure ( temp uint) +0:23 's' ( temp structure{ temp float clip0, temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii}) +0:23 Constant: +0:23 3 (const int) +0:23 move second child to first child ( temp uint) +0:? 'OutputStream.rtai' ( out uint Layer) +0:23 rtai: direct index for structure ( temp uint) +0:23 's' ( temp structure{ temp float clip0, temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii}) +0:23 Constant: +0:23 4 (const int) +0:23 move second child to first child ( temp int) +0:? 'OutputStream.ii' (layout( location=0) out int) +0:23 ii: direct index for structure ( temp int) +0:23 's' ( temp structure{ temp float clip0, temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii}) +0:23 Constant: +0:23 5 (const int) +0:23 EmitVertex ( temp void) 0:? Linker Objects 0:? 'VertexID' (layout( location=0) in 3-element array of uint) 0:? 'OutputStream.clip0' ( out float Position) @@ -158,7 +262,7 @@ output primitive = line_strip Validation failed // Module Version 10000 // Generated by (magic number): 80008 -// Id's are bound by 65 +// Id's are bound by 88 Capability Geometry Capability ClipDistance @@ -166,7 +270,7 @@ Validation failed Capability MultiViewport 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 - EntryPoint Geometry 4 "main" 20 29 34 40 45 50 57 + EntryPoint Geometry 4 "main" 28 37 42 48 53 58 65 ExecutionMode 4 Triangles ExecutionMode 4 Invocations 1 ExecutionMode 4 OutputLineStrip @@ -183,25 +287,29 @@ Validation failed Name 17 "@main(u1[3];struct-S-f1-f1-f1-u1-u1-i11;" Name 15 "VertexID" Name 16 "OutputStream" - Name 20 "OutputStream.clip0" - Name 21 "s" - Name 29 "OutputStream.clip0" - Name 34 "OutputStream.cull0" - Name 40 "OutputStream.vpai" - Name 45 "OutputStream.rtai" - Name 50 "OutputStream.ii" - Name 55 "VertexID" - Name 57 "VertexID" - Name 59 "OutputStream" - Name 60 "param" - Name 62 "param" - Decorate 20(OutputStream.clip0) BuiltIn Position - Decorate 29(OutputStream.clip0) BuiltIn ClipDistance - Decorate 34(OutputStream.cull0) BuiltIn CullDistance - Decorate 40(OutputStream.vpai) BuiltIn ViewportIndex - Decorate 45(OutputStream.rtai) BuiltIn Layer - Decorate 50(OutputStream.ii) Location 0 - Decorate 57(VertexID) Location 0 + Name 25 "notmain(u1[2];struct-S-f1-f1-f1-u1-u1-i11;" + Name 23 "VertexID" + Name 24 "OutputStream" + Name 28 "OutputStream.clip0" + Name 29 "s" + Name 37 "OutputStream.clip0" + Name 42 "OutputStream.cull0" + Name 48 "OutputStream.vpai" + Name 53 "OutputStream.rtai" + Name 58 "OutputStream.ii" + Name 63 "VertexID" + Name 65 "VertexID" + Name 67 "OutputStream" + Name 68 "param" + Name 70 "param" + Name 73 "s" + Decorate 28(OutputStream.clip0) BuiltIn Position + Decorate 37(OutputStream.clip0) BuiltIn ClipDistance + Decorate 42(OutputStream.cull0) BuiltIn CullDistance + Decorate 48(OutputStream.vpai) BuiltIn ViewportIndex + Decorate 53(OutputStream.rtai) BuiltIn Layer + Decorate 58(OutputStream.ii) Location 0 + Decorate 65(VertexID) Location 0 2: TypeVoid 3: TypeFunction 2 6: TypeInt 32 0 @@ -213,69 +321,101 @@ Validation failed 12(S): TypeStruct 10(float) 10(float) 10(float) 6(int) 6(int) 11(int) 13: TypePointer Function 12(S) 14: TypeFunction 2 9(ptr) 13(ptr) - 19: TypePointer Output 10(float) -20(OutputStream.clip0): 19(ptr) Variable Output - 22: 11(int) Constant 0 - 23: TypePointer Function 10(float) - 26: 6(int) Constant 1 - 27: TypeArray 10(float) 26 - 28: TypePointer Output 27 -29(OutputStream.clip0): 28(ptr) Variable Output - 30: 11(int) Constant 1 -34(OutputStream.cull0): 28(ptr) Variable Output - 35: 11(int) Constant 2 - 39: TypePointer Output 6(int) -40(OutputStream.vpai): 39(ptr) Variable Output - 41: 11(int) Constant 3 - 42: TypePointer Function 6(int) -45(OutputStream.rtai): 39(ptr) Variable Output - 46: 11(int) Constant 4 - 49: TypePointer Output 11(int) -50(OutputStream.ii): 49(ptr) Variable Output - 51: 11(int) Constant 5 - 52: TypePointer Function 11(int) - 56: TypePointer Input 8 - 57(VertexID): 56(ptr) Variable Input + 19: 6(int) Constant 2 + 20: TypeArray 6(int) 19 + 21: TypePointer Function 20 + 22: TypeFunction 2 21(ptr) 13(ptr) + 27: TypePointer Output 10(float) +28(OutputStream.clip0): 27(ptr) Variable Output + 30: 11(int) Constant 0 + 31: TypePointer Function 10(float) + 34: 6(int) Constant 1 + 35: TypeArray 10(float) 34 + 36: TypePointer Output 35 +37(OutputStream.clip0): 36(ptr) Variable Output + 38: 11(int) Constant 1 +42(OutputStream.cull0): 36(ptr) Variable Output + 43: 11(int) Constant 2 + 47: TypePointer Output 6(int) +48(OutputStream.vpai): 47(ptr) Variable Output + 49: 11(int) Constant 3 + 50: TypePointer Function 6(int) +53(OutputStream.rtai): 47(ptr) Variable Output + 54: 11(int) Constant 4 + 57: TypePointer Output 11(int) +58(OutputStream.ii): 57(ptr) Variable Output + 59: 11(int) Constant 5 + 60: TypePointer Function 11(int) + 64: TypePointer Input 8 + 65(VertexID): 64(ptr) Variable Input 4(main): 2 Function None 3 5: Label - 55(VertexID): 9(ptr) Variable Function -59(OutputStream): 13(ptr) Variable Function - 60(param): 9(ptr) Variable Function - 62(param): 13(ptr) Variable Function - 58: 8 Load 57(VertexID) - Store 55(VertexID) 58 - 61: 8 Load 55(VertexID) - Store 60(param) 61 - 63: 2 FunctionCall 17(@main(u1[3];struct-S-f1-f1-f1-u1-u1-i11;) 60(param) 62(param) - 64: 12(S) Load 62(param) - Store 59(OutputStream) 64 + 63(VertexID): 9(ptr) Variable Function +67(OutputStream): 13(ptr) Variable Function + 68(param): 9(ptr) Variable Function + 70(param): 13(ptr) Variable Function + 66: 8 Load 65(VertexID) + Store 63(VertexID) 66 + 69: 8 Load 63(VertexID) + Store 68(param) 69 + 71: 2 FunctionCall 17(@main(u1[3];struct-S-f1-f1-f1-u1-u1-i11;) 68(param) 70(param) + 72: 12(S) Load 70(param) + Store 67(OutputStream) 72 Return FunctionEnd 17(@main(u1[3];struct-S-f1-f1-f1-u1-u1-i11;): 2 Function None 14 15(VertexID): 9(ptr) FunctionParameter 16(OutputStream): 13(ptr) FunctionParameter 18: Label - 21(s): 13(ptr) Variable Function - 24: 23(ptr) AccessChain 21(s) 22 - 25: 10(float) Load 24 - Store 20(OutputStream.clip0) 25 - 31: 23(ptr) AccessChain 21(s) 30 - 32: 10(float) Load 31 - 33: 19(ptr) AccessChain 29(OutputStream.clip0) 22 - Store 33 32 - 36: 23(ptr) AccessChain 21(s) 35 - 37: 10(float) Load 36 - 38: 19(ptr) AccessChain 34(OutputStream.cull0) 22 - Store 38 37 - 43: 42(ptr) AccessChain 21(s) 41 - 44: 6(int) Load 43 - Store 40(OutputStream.vpai) 44 - 47: 42(ptr) AccessChain 21(s) 46 - 48: 6(int) Load 47 - Store 45(OutputStream.rtai) 48 - 53: 52(ptr) AccessChain 21(s) 51 - 54: 11(int) Load 53 - Store 50(OutputStream.ii) 54 + 29(s): 13(ptr) Variable Function + 32: 31(ptr) AccessChain 29(s) 30 + 33: 10(float) Load 32 + Store 28(OutputStream.clip0) 33 + 39: 31(ptr) AccessChain 29(s) 38 + 40: 10(float) Load 39 + 41: 27(ptr) AccessChain 37(OutputStream.clip0) 30 + Store 41 40 + 44: 31(ptr) AccessChain 29(s) 43 + 45: 10(float) Load 44 + 46: 27(ptr) AccessChain 42(OutputStream.cull0) 30 + Store 46 45 + 51: 50(ptr) AccessChain 29(s) 49 + 52: 6(int) Load 51 + Store 48(OutputStream.vpai) 52 + 55: 50(ptr) AccessChain 29(s) 54 + 56: 6(int) Load 55 + Store 53(OutputStream.rtai) 56 + 61: 60(ptr) AccessChain 29(s) 59 + 62: 11(int) Load 61 + Store 58(OutputStream.ii) 62 + EmitVertex + Return + FunctionEnd +25(notmain(u1[2];struct-S-f1-f1-f1-u1-u1-i11;): 2 Function None 22 + 23(VertexID): 21(ptr) FunctionParameter +24(OutputStream): 13(ptr) FunctionParameter + 26: Label + 73(s): 13(ptr) Variable Function + 74: 31(ptr) AccessChain 73(s) 30 + 75: 10(float) Load 74 + Store 28(OutputStream.clip0) 75 + 76: 31(ptr) AccessChain 73(s) 38 + 77: 10(float) Load 76 + 78: 27(ptr) AccessChain 37(OutputStream.clip0) 30 + Store 78 77 + 79: 31(ptr) AccessChain 73(s) 43 + 80: 10(float) Load 79 + 81: 27(ptr) AccessChain 42(OutputStream.cull0) 30 + Store 81 80 + 82: 50(ptr) AccessChain 73(s) 49 + 83: 6(int) Load 82 + Store 48(OutputStream.vpai) 83 + 84: 50(ptr) AccessChain 73(s) 54 + 85: 6(int) Load 84 + Store 53(OutputStream.rtai) 85 + 86: 60(ptr) AccessChain 73(s) 59 + 87: 11(int) Load 86 + Store 58(OutputStream.ii) 87 EmitVertex Return FunctionEnd diff --git a/Test/hlsl.semantic.geom b/Test/hlsl.semantic.geom index fc6a53ab..9e0ed4ce 100644 --- a/Test/hlsl.semantic.geom +++ b/Test/hlsl.semantic.geom @@ -14,3 +14,11 @@ void main(triangle in uint VertexID[3] : VertexID, S s; OutputStream.Append(s); } + +[maxvertexcount(4)] +void notmain(line in uint VertexID[2] : VertexID, + inout LineStream OutputStream) +{ + S s; + OutputStream.Append(s); +} diff --git a/hlsl/hlslGrammar.cpp b/hlsl/hlslGrammar.cpp index 8ab1a900..47ced29c 100644 --- a/hlsl/hlslGrammar.cpp +++ b/hlsl/hlslGrammar.cpp @@ -2516,6 +2516,8 @@ bool HlslGrammar::acceptMemberFunctionDefinition(TIntermNode*& nodeList, const T // bool HlslGrammar::acceptFunctionParameters(TFunction& function) { + parseContext.beginParameterParsing(function); + // LEFT_PAREN if (! acceptTokenClass(EHTokLeftParen)) return false; diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index be665ac0..d801b4a4 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -69,7 +69,8 @@ HlslParseContext::HlslParseContext(TSymbolTable& symbolTable, TIntermediate& int clipDistanceOutput(nullptr), cullDistanceOutput(nullptr), clipDistanceInput(nullptr), - cullDistanceInput(nullptr) + cullDistanceInput(nullptr), + parsingEntrypointParameters(false) { globalUniformDefaults.clear(); globalUniformDefaults.layoutMatrix = ElmRowMajor; @@ -2049,7 +2050,7 @@ TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunct }; // if we aren't in the entry point, fix the IO as such and exit - if (userFunction.getName().compare(intermediate.getEntryPointName().c_str()) != 0) { + if (! isEntrypointName(userFunction.getName())) { remapNonEntryPointIO(userFunction); return nullptr; } @@ -8884,6 +8885,10 @@ void HlslParseContext::addQualifierToExisting(const TSourceLoc& loc, TQualifier // bool HlslParseContext::handleInputGeometry(const TSourceLoc& loc, const TLayoutGeometry& geometry) { + // these can be declared on non-entry-points, in which case they lose their meaning + if (! parsingEntrypointParameters) + return true; + switch (geometry) { case ElgPoints: // fall through case ElgLines: // ... @@ -8914,6 +8919,10 @@ bool HlslParseContext::handleOutputGeometry(const TSourceLoc& loc, const TLayout if (language != EShLangGeometry) return true; + // these can be declared on non-entry-points, in which case they lose their meaning + if (! parsingEntrypointParameters) + return true; + switch (geometry) { case ElgPoints: case ElgLineStrip: diff --git a/hlsl/hlslParseHelper.h b/hlsl/hlslParseHelper.h index 822de896..6f416610 100644 --- a/hlsl/hlslParseHelper.h +++ b/hlsl/hlslParseHelper.h @@ -183,6 +183,11 @@ public: void getFullNamespaceName(TString*&) const; void addScopeMangler(TString&); + void beginParameterParsing(TFunction& function) + { + parsingEntrypointParameters = isEntrypointName(function.getName()); + } + void pushSwitchSequence(TIntermSequence* sequence) { switchSequenceStack.push_back(sequence); } void popSwitchSequence() { switchSequenceStack.pop_back(); } @@ -241,6 +246,7 @@ protected: TIntermTyped* convertInitializerList(const TSourceLoc&, const TType&, TIntermTyped* initializer, TIntermTyped* scalarInit); bool isScalarConstructor(const TIntermNode*); TOperator mapAtomicOp(const TSourceLoc& loc, TOperator op, bool isImage); + bool isEntrypointName(const TString& name) { return name.compare(intermediate.getEntryPointName().c_str()) == 0; } // Return true if this node requires L-value conversion (e.g, to an imageStore). bool shouldConvertLValue(const TIntermNode*) const; @@ -494,6 +500,7 @@ protected: }; TMap textureShadowVariant; + bool parsingEntrypointParameters; }; // This is the prefix we use for built-in methods to avoid namespace collisions with