diff --git a/Test/150.frag b/Test/150.frag index 1985d6ef..e24dba05 100644 --- a/Test/150.frag +++ b/Test/150.frag @@ -57,4 +57,25 @@ 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 +float dk = sqrt(11); + +#extension GL_ARB_shader_bit_encoding: enable + +float f; +vec4 v4; +ivec4 iv4a; +uvec2 uv2c; +void bitEncodingPass() +{ + int i = floatBitsToInt(f); + uvec4 uv11 = floatBitsToUint(v4); + vec4 v14 = intBitsToFloat(iv4a); + vec2 v15 = uintBitsToFloat(uv2c); +} + +#extension GL_ARB_shader_bit_encoding: disable + +void bitEncodingFail() +{ + int i = floatBitsToInt(f); // Error, extention GL_ARB_bit_encoding is diabled +} diff --git a/Test/baseResults/150.frag.out b/Test/baseResults/150.frag.out index 18c19538..4a55ea40 100644 --- a/Test/baseResults/150.frag.out +++ b/Test/baseResults/150.frag.out @@ -9,11 +9,13 @@ 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. +ERROR: 0:80: 'floatBitsToInt' : required extension not requested: GL_ARB_shader_bit_encoding +ERROR: 11 compilation errors. No code generated. Shader version: 150 Requested GL_ARB_gpu_shader_fp64 +Requested GL_ARB_shader_bit_encoding gl_FragCoord pixel center is integer gl_FragCoord origin is upper left ERROR: node is still EOpNull! @@ -134,6 +136,37 @@ ERROR: node is still EOpNull! 0:60 'dk' ( global float) 0:60 Constant: 0:60 3.316625 +0:68 Function Definition: bitEncodingPass( ( global void) +0:68 Function Parameters: +0:70 Sequence +0:70 Sequence +0:70 move second child to first child ( temp int) +0:70 'i' ( temp int) +0:70 floatBitsToInt ( global int) +0:70 'f' ( global float) +0:71 Sequence +0:71 move second child to first child ( temp 4-component vector of uint) +0:71 'uv11' ( temp 4-component vector of uint) +0:71 floatBitsToUint ( global 4-component vector of uint) +0:71 'v4' ( global 4-component vector of float) +0:72 Sequence +0:72 move second child to first child ( temp 4-component vector of float) +0:72 'v14' ( temp 4-component vector of float) +0:72 intBitsToFloat ( global 4-component vector of float) +0:72 'iv4a' ( global 4-component vector of int) +0:73 Sequence +0:73 move second child to first child ( temp 2-component vector of float) +0:73 'v15' ( temp 2-component vector of float) +0:73 uintBitsToFloat ( global 2-component vector of float) +0:73 'uv2c' ( global 2-component vector of uint) +0:78 Function Definition: bitEncodingFail( ( global void) +0:78 Function Parameters: +0:80 Sequence +0:80 Sequence +0:80 move second child to first child ( temp int) +0:80 'i' ( temp int) +0:80 floatBitsToInt ( global int) +0:80 'f' ( global float) 0:? Linker Objects 0:? 'gl_FragCoord' ( gl_FragCoord 4-component vector of float FragCoord) 0:? 'foo' ( smooth in 4-component vector of float) @@ -155,6 +188,10 @@ ERROR: node is still EOpNull! 0:? 'absTest2' ( global double) 0:? 'absTest3' ( global double) 0:? 'dk' ( global float) +0:? 'f' ( global float) +0:? 'v4' ( global 4-component vector of float) +0:? 'iv4a' ( global 4-component vector of int) +0:? 'uv2c' ( global 2-component vector of uint) Linked fragment stage: @@ -162,6 +199,7 @@ Linked fragment stage: Shader version: 150 Requested GL_ARB_gpu_shader_fp64 +Requested GL_ARB_shader_bit_encoding gl_FragCoord pixel center is integer gl_FragCoord origin is upper left ERROR: node is still EOpNull! @@ -218,4 +256,8 @@ ERROR: node is still EOpNull! 0:? 'absTest2' ( global double) 0:? 'absTest3' ( global double) 0:? 'dk' ( global float) +0:? 'f' ( global float) +0:? 'v4' ( global 4-component vector of float) +0:? 'iv4a' ( global 4-component vector of int) +0:? 'uv2c' ( global 2-component vector of uint) diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 344594af..32106c7d 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -1262,7 +1262,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV #endif if ((profile == EEsProfile && version >= 300) || - (profile != EEsProfile && version >= 330)) { + (profile != EEsProfile && version >= 150)) { // GL_ARB_shader_bit_encoding commonBuiltins.append( "int floatBitsToInt(highp float value);" "ivec2 floatBitsToInt(highp vec2 value);" @@ -7816,6 +7816,13 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion symbolTable.setFunctionExtensions("imageAtomicCompSwap", 1, &E_GL_OES_shader_image_atomic); } + 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); + } + symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group); BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable); symbolTable.setVariableExtensions("gl_ViewIndex", 1, &E_GL_EXT_multiview); diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp index d6b961d5..2da1dbc6 100644 --- a/glslang/MachineIndependent/Versions.cpp +++ b/glslang/MachineIndependent/Versions.cpp @@ -197,6 +197,7 @@ void TParseVersions::initializeExtensionBehavior() extensionBehavior[E_GL_ARB_shader_clock] = EBhDisable; extensionBehavior[E_GL_ARB_uniform_buffer_object] = EBhDisable; extensionBehavior[E_GL_ARB_sample_shading] = EBhDisable; + extensionBehavior[E_GL_ARB_shader_bit_encoding] = EBhDisable; extensionBehavior[E_GL_KHR_shader_subgroup_basic] = EBhDisable; extensionBehavior[E_GL_KHR_shader_subgroup_vote] = EBhDisable; @@ -409,6 +410,7 @@ void TParseVersions::getPreamble(std::string& preamble) "#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_ARB_shader_bit_encoding 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 170efb00..f9ab2e2f 100644 --- a/glslang/MachineIndependent/Versions.h +++ b/glslang/MachineIndependent/Versions.h @@ -152,6 +152,7 @@ const char* const E_GL_ARB_fragment_shader_interlock = "GL_ARB_fragment_shade 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_ARB_sample_shading = "GL_ARB_sample_shading"; +const char* const E_GL_ARB_shader_bit_encoding = "GL_ARB_shader_bit_encoding"; 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";