diff --git a/LICENSE.txt b/LICENSE.txt index 5f58565d..f93d62f4 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -337,7 +337,7 @@ GPL 3 with special bison exception ================================================================================ -------------------------------------------------------------------------------- -The preprocessor has the core licenses stated above, plus an additional licence: +The preprocessor has the core licenses stated above, plus additional licences: /****************************************************************************\ Copyright (c) 2002, NVIDIA Corporation. @@ -382,3 +382,29 @@ NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \****************************************************************************/ + +/* +** Copyright (c) 2014-2016 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a copy +** of this software and/or associated documentation files (the "Materials"), +** to deal in the Materials without restriction, including without limitation +** the rights to use, copy, modify, merge, publish, distribute, sublicense, +** and/or sell copies of the Materials, and to permit persons to whom the +** Materials are furnished to do so, subject to the following conditions: +** +** The above copyright notice and this permission notice shall be included in +** all copies or substantial portions of the Materials. +** +** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS +** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND +** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS +** IN THE MATERIALS. +*/ diff --git a/SPIRV/SpvBuilder.cpp b/SPIRV/SpvBuilder.cpp index 838f916a..0b0e48ab 100644 --- a/SPIRV/SpvBuilder.cpp +++ b/SPIRV/SpvBuilder.cpp @@ -433,11 +433,11 @@ Id Builder::makeGenericType(spv::Op opcode, std::vector& opera Instruction* type; for (int t = 0; t < (int)groupedTypes[opcode].size(); ++t) { type = groupedTypes[opcode][t]; - if (type->getNumOperands() != operands.size()) + if (static_cast(type->getNumOperands()) != operands.size()) continue; // Number mismatch, find next bool match = true; - for (int op = 0; match && op < operands.size(); ++op) { + for (size_t op = 0; match && op < operands.size(); ++op) { match = (operands[op].isId ? type->getIdOperand(op) : type->getImmediateOperand(op)) == operands[op].word; } if (match) @@ -446,7 +446,7 @@ Id Builder::makeGenericType(spv::Op opcode, std::vector& opera // not found, make it type = new Instruction(getUniqueId(), NoType, opcode); - for (int op = 0; op < operands.size(); ++op) { + for (size_t op = 0; op < operands.size(); ++op) { if (operands[op].isId) type->addIdOperand(operands[op].word); else diff --git a/Test/baseResults/150.frag.out b/Test/baseResults/150.frag.out index 3e666586..066b8bb4 100644 --- a/Test/baseResults/150.frag.out +++ b/Test/baseResults/150.frag.out @@ -8,7 +8,9 @@ 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: 0:80: 'floatBitsToInt' : required extension not requested: GL_ARB_shader_bit_encoding +ERROR: 0:80: 'floatBitsToInt' : required extension not requested: Possible extensions include: +GL_ARB_shader_bit_encoding +GL_ARB_gpu_shader5 ERROR: 0:100: 'packSnorm2x16' : required extension not requested: GL_ARB_shading_language_packing ERROR: 0:114: 'textureQueryLOD' : required extension not requested: GL_ARB_texture_query_lod ERROR: 0:115: 'textureQueryLOD' : required extension not requested: GL_ARB_texture_query_lod diff --git a/Test/baseResults/floatBitsToInt.vert.out b/Test/baseResults/floatBitsToInt.vert.out new file mode 100644 index 00000000..6d5185c8 --- /dev/null +++ b/Test/baseResults/floatBitsToInt.vert.out @@ -0,0 +1,217 @@ +floatBitsToInt.vert +WARNING: 0:2: '#extension' : extension is only partially supported: GL_ARB_gpu_shader5 + +Shader version: 150 +Requested GL_ARB_gpu_shader5 +0:? Sequence +0:6 Function Definition: main( ( global void) +0:6 Function Parameters: +0:8 Sequence +0:8 move second child to first child ( temp 4-component vector of float) +0:8 'result' ( smooth out 4-component vector of float) +0:8 Constant: +0:8 1.000000 +0:8 1.000000 +0:8 1.000000 +0:8 1.000000 +0:9 Sequence +0:9 move second child to first child ( temp int) +0:9 'ret_val' ( temp int) +0:9 floatBitsToInt ( global int) +0:9 'value' ( uniform float) +0:10 Test condition and select ( temp void) +0:10 Condition +0:10 Compare Not Equal ( temp bool) +0:10 'expected_value' ( uniform int) +0:10 'ret_val' ( temp int) +0:10 true case +0:10 Sequence +0:10 move second child to first child ( temp 4-component vector of float) +0:10 'result' ( smooth out 4-component vector of float) +0:10 Constant: +0:10 0.000000 +0:10 0.000000 +0:10 0.000000 +0:10 0.000000 +0:12 switch +0:12 condition +0:12 'gl_VertexID' ( gl_VertexId int VertexId) +0:12 body +0:12 Sequence +0:13 case: with expression +0:13 Constant: +0:13 0 (const int) +0:? Sequence +0:13 move second child to first child ( temp 4-component vector of float) +0:13 gl_Position: direct index for structure ( gl_Position 4-component vector of float Position) +0:13 'anon@0' ( out block{ gl_Position 4-component vector of float Position gl_Position, gl_PointSize float PointSize gl_PointSize, out unsized 1-element array of float ClipDistance gl_ClipDistance}) +0:13 Constant: +0:13 0 (const uint) +0:13 Constant: +0:13 -1.000000 +0:13 1.000000 +0:13 0.000000 +0:13 1.000000 +0:13 Branch: Break +0:14 case: with expression +0:14 Constant: +0:14 1 (const int) +0:? Sequence +0:14 move second child to first child ( temp 4-component vector of float) +0:14 gl_Position: direct index for structure ( gl_Position 4-component vector of float Position) +0:14 'anon@0' ( out block{ gl_Position 4-component vector of float Position gl_Position, gl_PointSize float PointSize gl_PointSize, out unsized 1-element array of float ClipDistance gl_ClipDistance}) +0:14 Constant: +0:14 0 (const uint) +0:14 Constant: +0:14 1.000000 +0:14 1.000000 +0:14 0.000000 +0:14 1.000000 +0:14 Branch: Break +0:15 case: with expression +0:15 Constant: +0:15 2 (const int) +0:? Sequence +0:15 move second child to first child ( temp 4-component vector of float) +0:15 gl_Position: direct index for structure ( gl_Position 4-component vector of float Position) +0:15 'anon@0' ( out block{ gl_Position 4-component vector of float Position gl_Position, gl_PointSize float PointSize gl_PointSize, out unsized 1-element array of float ClipDistance gl_ClipDistance}) +0:15 Constant: +0:15 0 (const uint) +0:15 Constant: +0:15 -1.000000 +0:15 -1.000000 +0:15 0.000000 +0:15 1.000000 +0:15 Branch: Break +0:16 case: with expression +0:16 Constant: +0:16 3 (const int) +0:? Sequence +0:16 move second child to first child ( temp 4-component vector of float) +0:16 gl_Position: direct index for structure ( gl_Position 4-component vector of float Position) +0:16 'anon@0' ( out block{ gl_Position 4-component vector of float Position gl_Position, gl_PointSize float PointSize gl_PointSize, out unsized 1-element array of float ClipDistance gl_ClipDistance}) +0:16 Constant: +0:16 0 (const uint) +0:16 Constant: +0:16 1.000000 +0:16 -1.000000 +0:16 0.000000 +0:16 1.000000 +0:16 Branch: Break +0:? Linker Objects +0:? 'expected_value' ( uniform int) +0:? 'value' ( uniform float) +0:? 'result' ( smooth out 4-component vector of float) +0:? 'anon@0' ( out block{ gl_Position 4-component vector of float Position gl_Position, gl_PointSize float PointSize gl_PointSize, out unsized 1-element array of float ClipDistance gl_ClipDistance}) +0:? 'gl_VertexID' ( gl_VertexId int VertexId) +0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId) + + +Linked vertex stage: + + +Shader version: 150 +Requested GL_ARB_gpu_shader5 +0:? Sequence +0:6 Function Definition: main( ( global void) +0:6 Function Parameters: +0:8 Sequence +0:8 move second child to first child ( temp 4-component vector of float) +0:8 'result' ( smooth out 4-component vector of float) +0:8 Constant: +0:8 1.000000 +0:8 1.000000 +0:8 1.000000 +0:8 1.000000 +0:9 Sequence +0:9 move second child to first child ( temp int) +0:9 'ret_val' ( temp int) +0:9 floatBitsToInt ( global int) +0:9 'value' ( uniform float) +0:10 Test condition and select ( temp void) +0:10 Condition +0:10 Compare Not Equal ( temp bool) +0:10 'expected_value' ( uniform int) +0:10 'ret_val' ( temp int) +0:10 true case +0:10 Sequence +0:10 move second child to first child ( temp 4-component vector of float) +0:10 'result' ( smooth out 4-component vector of float) +0:10 Constant: +0:10 0.000000 +0:10 0.000000 +0:10 0.000000 +0:10 0.000000 +0:12 switch +0:12 condition +0:12 'gl_VertexID' ( gl_VertexId int VertexId) +0:12 body +0:12 Sequence +0:13 case: with expression +0:13 Constant: +0:13 0 (const int) +0:? Sequence +0:13 move second child to first child ( temp 4-component vector of float) +0:13 gl_Position: direct index for structure ( gl_Position 4-component vector of float Position) +0:13 'anon@0' ( out block{ gl_Position 4-component vector of float Position gl_Position, gl_PointSize float PointSize gl_PointSize, out 1-element array of float ClipDistance gl_ClipDistance}) +0:13 Constant: +0:13 0 (const uint) +0:13 Constant: +0:13 -1.000000 +0:13 1.000000 +0:13 0.000000 +0:13 1.000000 +0:13 Branch: Break +0:14 case: with expression +0:14 Constant: +0:14 1 (const int) +0:? Sequence +0:14 move second child to first child ( temp 4-component vector of float) +0:14 gl_Position: direct index for structure ( gl_Position 4-component vector of float Position) +0:14 'anon@0' ( out block{ gl_Position 4-component vector of float Position gl_Position, gl_PointSize float PointSize gl_PointSize, out 1-element array of float ClipDistance gl_ClipDistance}) +0:14 Constant: +0:14 0 (const uint) +0:14 Constant: +0:14 1.000000 +0:14 1.000000 +0:14 0.000000 +0:14 1.000000 +0:14 Branch: Break +0:15 case: with expression +0:15 Constant: +0:15 2 (const int) +0:? Sequence +0:15 move second child to first child ( temp 4-component vector of float) +0:15 gl_Position: direct index for structure ( gl_Position 4-component vector of float Position) +0:15 'anon@0' ( out block{ gl_Position 4-component vector of float Position gl_Position, gl_PointSize float PointSize gl_PointSize, out 1-element array of float ClipDistance gl_ClipDistance}) +0:15 Constant: +0:15 0 (const uint) +0:15 Constant: +0:15 -1.000000 +0:15 -1.000000 +0:15 0.000000 +0:15 1.000000 +0:15 Branch: Break +0:16 case: with expression +0:16 Constant: +0:16 3 (const int) +0:? Sequence +0:16 move second child to first child ( temp 4-component vector of float) +0:16 gl_Position: direct index for structure ( gl_Position 4-component vector of float Position) +0:16 'anon@0' ( out block{ gl_Position 4-component vector of float Position gl_Position, gl_PointSize float PointSize gl_PointSize, out 1-element array of float ClipDistance gl_ClipDistance}) +0:16 Constant: +0:16 0 (const uint) +0:16 Constant: +0:16 1.000000 +0:16 -1.000000 +0:16 0.000000 +0:16 1.000000 +0:16 Branch: Break +0:? Linker Objects +0:? 'expected_value' ( uniform int) +0:? 'value' ( uniform float) +0:? 'result' ( smooth out 4-component vector of float) +0:? 'anon@0' ( out block{ gl_Position 4-component vector of float Position gl_Position, gl_PointSize float PointSize gl_PointSize, out 1-element array of float ClipDistance gl_ClipDistance}) +0:? 'gl_VertexID' ( gl_VertexId int VertexId) +0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId) + diff --git a/Test/baseResults/xfbUnsizedArray.error.tese.out b/Test/baseResults/xfbUnsizedArray.error.tese.out new file mode 100644 index 00000000..df3495f1 --- /dev/null +++ b/Test/baseResults/xfbUnsizedArray.error.tese.out @@ -0,0 +1,35 @@ +xfbUnsizedArray.error.tese +ERROR: 0:4: 'xfb_offset' : unsized array in buffer 0 +ERROR: 1 compilation errors. No code generated. + + +Shader version: 430 +Requested GL_ARB_enhanced_layouts +in xfb mode +input primitive = isolines +vertex spacing = none +triangle order = none +using point mode +ERROR: node is still EOpNull! +0:6 Function Definition: main( ( global void) +0:6 Function Parameters: +0:? Linker Objects +0:? 'unsized' (layout( xfb_buffer=0 xfb_offset=0) out unsized 1-element array of 4-component vector of float) + + +Linked tessellation evaluation stage: + + +Shader version: 430 +Requested GL_ARB_enhanced_layouts +in xfb mode +input primitive = isolines +vertex spacing = equal_spacing +triangle order = ccw +using point mode +ERROR: node is still EOpNull! +0:6 Function Definition: main( ( global void) +0:6 Function Parameters: +0:? Linker Objects +0:? 'unsized' (layout( xfb_buffer=0 xfb_offset=0) out 1-element array of 4-component vector of float) + diff --git a/Test/floatBitsToInt.vert b/Test/floatBitsToInt.vert new file mode 100644 index 00000000..a6bb18a6 --- /dev/null +++ b/Test/floatBitsToInt.vert @@ -0,0 +1,18 @@ +#version 150 +#extension GL_ARB_gpu_shader5 : require +uniform int expected_value; +uniform float value; +out vec4 result; +void main() +{ + result = vec4(1.0, 1.0, 1.0, 1.0); + int ret_val = floatBitsToInt(value); + if (expected_value != ret_val){ result = vec4(0.0, 0.0, 0.0, 0.0); } + + switch (gl_VertexID) { + case 0: gl_Position = vec4(-1.0, 1.0, 0.0, 1.0); break; + case 1: gl_Position = vec4( 1.0, 1.0, 0.0, 1.0); break; + case 2: gl_Position = vec4(-1.0,-1.0, 0.0, 1.0); break; + case 3: gl_Position = vec4( 1.0,-1.0, 0.0, 1.0); break; + } +} \ No newline at end of file diff --git a/Test/xfbUnsizedArray.error.tese b/Test/xfbUnsizedArray.error.tese new file mode 100644 index 00000000..a59069bb --- /dev/null +++ b/Test/xfbUnsizedArray.error.tese @@ -0,0 +1,8 @@ +#version 430 core +#extension GL_ARB_enhanced_layouts : require +layout(isolines, point_mode) in; +layout (xfb_offset = 0) out vec4 unsized[]; // error: unsized array + +void main() +{ +} diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index c770242e..03fdce9f 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -8353,10 +8353,11 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion } if (profile != EEsProfile && version < 330 ) { - symbolTable.setFunctionExtensions("floatBitsToInt", 1, &E_GL_ARB_shader_bit_encoding); - symbolTable.setFunctionExtensions("floatBitsToUint", 1, &E_GL_ARB_shader_bit_encoding); - symbolTable.setFunctionExtensions("intBitsToFloat", 1, &E_GL_ARB_shader_bit_encoding); - symbolTable.setFunctionExtensions("uintBitsToFloat", 1, &E_GL_ARB_shader_bit_encoding); + const char* bitsConvertExt[2] = {E_GL_ARB_shader_bit_encoding, E_GL_ARB_gpu_shader5}; + symbolTable.setFunctionExtensions("floatBitsToInt", 2, bitsConvertExt); + symbolTable.setFunctionExtensions("floatBitsToUint", 2, bitsConvertExt); + symbolTable.setFunctionExtensions("intBitsToFloat", 2, bitsConvertExt); + symbolTable.setFunctionExtensions("uintBitsToFloat", 2, bitsConvertExt); } if (profile != EEsProfile && version < 430 ) { diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 1985286c..fa291160 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -6212,11 +6212,13 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type) #ifndef GLSLANG_WEB if (qualifier.hasXfbOffset() && qualifier.hasXfbBuffer()) { - int repeated = intermediate.addXfbBufferOffset(type); - if (repeated >= 0) - error(loc, "overlapping offsets at", "xfb_offset", "offset %d in buffer %d", repeated, qualifier.layoutXfbBuffer); - if (type.isUnsizedArray()) + if (type.isUnsizedArray()) { error(loc, "unsized array", "xfb_offset", "in buffer %d", qualifier.layoutXfbBuffer); + } else { + int repeated = intermediate.addXfbBufferOffset(type); + if (repeated >= 0) + error(loc, "overlapping offsets at", "xfb_offset", "offset %d in buffer %d", repeated, qualifier.layoutXfbBuffer); + } // "The offset must be a multiple of the size of the first component of the first // qualified variable or block member, or a compile-time error results. Further, if applied to an aggregate diff --git a/glslang/MachineIndependent/linkValidate.cpp b/glslang/MachineIndependent/linkValidate.cpp index 1fc7d1f1..620be97c 100644 --- a/glslang/MachineIndependent/linkValidate.cpp +++ b/glslang/MachineIndependent/linkValidate.cpp @@ -1802,7 +1802,7 @@ unsigned int TIntermediate::computeTypeXfbSize(const TType& type, bool& contains return size; } - int numComponents; + int numComponents {0}; if (type.isScalar()) numComponents = 1; else if (type.isVector()) diff --git a/gtests/AST.FromFile.cpp b/gtests/AST.FromFile.cpp index 3f8ff0e3..c0ced5e4 100644 --- a/gtests/AST.FromFile.cpp +++ b/gtests/AST.FromFile.cpp @@ -236,6 +236,7 @@ INSTANTIATE_TEST_SUITE_P( "noMatchingFunction.frag", "constantUnaryConversion.comp", "xfbUnsizedArray.error.vert", + "xfbUnsizedArray.error.tese", "glsl.140.layoutOffset.error.vert", "glsl.430.layoutOffset.error.vert", "glsl.450.subgroup.frag", @@ -291,7 +292,8 @@ INSTANTIATE_TEST_SUITE_P( "GL_ARB_draw_instanced.vert", "GL_ARB_fragment_coord_conventions.vert", "BestMatchFunction.vert", - "EndStreamPrimitive.geom" + "EndStreamPrimitive.geom", + "floatBitsToInt.vert", })), FileNameAsCustomTestSuffix ); diff --git a/gtests/GlslMapIO.FromFile.cpp b/gtests/GlslMapIO.FromFile.cpp index 73fdec4e..aabb4ae2 100644 --- a/gtests/GlslMapIO.FromFile.cpp +++ b/gtests/GlslMapIO.FromFile.cpp @@ -113,11 +113,13 @@ bool verifyIOMapping(std::string& linkingError, glslang::TProgram& program) { bool found = false; for (auto outIt : pipeOut) { if (outIt.second->getType()->isStruct()) { - unsigned int baseLoc = outIt.second->getType()->getQualifier().hasLocation() ? outIt.second->getType()->getQualifier().layoutLocation : -1; - for (int j = 0; j < outIt.second->getType()->getStruct()->size(); j++) { + unsigned int baseLoc = outIt.second->getType()->getQualifier().hasLocation() ? + outIt.second->getType()->getQualifier().layoutLocation : + std::numeric_limits::max(); + for (size_t j = 0; j < outIt.second->getType()->getStruct()->size(); j++) { baseLoc = (*outIt.second->getType()->getStruct())[j].type->getQualifier().hasLocation() ? (*outIt.second->getType()->getStruct())[j].type->getQualifier().layoutLocation : baseLoc; - if (baseLoc != -1) { + if (baseLoc != std::numeric_limits::max()) { if (baseLoc == in.getType()->getQualifier().layoutLocation) { found = true; break; @@ -134,10 +136,10 @@ bool verifyIOMapping(std::string& linkingError, glslang::TProgram& program) { } else { unsigned int baseLoc = in.getType()->getQualifier().hasLocation() ? in.getType()->getQualifier().layoutLocation : -1; - for (int j = 0; j < in.getType()->getStruct()->size(); j++) { + for (size_t j = 0; j < in.getType()->getStruct()->size(); j++) { baseLoc = (*in.getType()->getStruct())[j].type->getQualifier().hasLocation() ? (*in.getType()->getStruct())[j].type->getQualifier().layoutLocation : baseLoc; - if (baseLoc != -1) { + if (baseLoc != std::numeric_limits::max()) { bool isMemberFound = false; for (auto outIt : pipeOut) { if (baseLoc == outIt.second->getType()->getQualifier().layoutLocation) { @@ -350,4 +352,4 @@ INSTANTIATE_TEST_SUITE_P( } // anonymous namespace } // namespace glslangtest -#endif \ No newline at end of file +#endif