diff --git a/3rdparty/glslang/CMakeLists.txt b/3rdparty/glslang/CMakeLists.txt index 9bc94b01a..a0f0352b2 100644 --- a/3rdparty/glslang/CMakeLists.txt +++ b/3rdparty/glslang/CMakeLists.txt @@ -18,6 +18,8 @@ option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON) option(ENABLE_HLSL "Enables HLSL input support" ON) +option(ENABLE_OPT "Enables spirv-opt capability if present" ON) + if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND WIN32) set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "..." FORCE) endif() @@ -83,6 +85,17 @@ endfunction(glslang_set_link_args) # We depend on these for later projects, so they should come first. add_subdirectory(External) +if(NOT TARGET SPIRV-Tools-opt) + set(ENABLE_OPT OFF) +endif() + +if(ENABLE_OPT) + message(STATUS "optimizer enabled") + add_definitions(-DENABLE_OPT) +elseif(ENABLE_HLSL) + message(STATUS "spirv-tools not linked - illegal SPIRV may be generated for HLSL") +endif() + add_subdirectory(glslang) add_subdirectory(OGLCompilersDLL) if(ENABLE_GLSLANG_BINARIES) diff --git a/3rdparty/glslang/External/CMakeLists.txt b/3rdparty/glslang/External/CMakeLists.txt index 4f694ee74..d9e071e88 100644 --- a/3rdparty/glslang/External/CMakeLists.txt +++ b/3rdparty/glslang/External/CMakeLists.txt @@ -33,3 +33,10 @@ if(BUILD_TESTING) "Google Mock was not found - tests based on that will not build") endif() endif() + +if(ENABLE_OPT AND NOT TARGET SPIRV-Tools-opt) + if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools spirv-tools) + endif() +endif() + diff --git a/3rdparty/glslang/SPIRV/CMakeLists.txt b/3rdparty/glslang/SPIRV/CMakeLists.txt index 3c5ebaba7..b1c027779 100755 --- a/3rdparty/glslang/SPIRV/CMakeLists.txt +++ b/3rdparty/glslang/SPIRV/CMakeLists.txt @@ -42,12 +42,21 @@ endif(ENABLE_NV_EXTENSIONS) add_library(SPIRV STATIC ${SOURCES} ${HEADERS}) set_property(TARGET SPIRV PROPERTY FOLDER glslang) set_property(TARGET SPIRV PROPERTY POSITION_INDEPENDENT_CODE ON) -target_link_libraries(SPIRV glslang) add_library(SPVRemapper STATIC ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS}) set_property(TARGET SPVRemapper PROPERTY FOLDER glslang) set_property(TARGET SPVRemapper PROPERTY POSITION_INDEPENDENT_CODE ON) +if(ENABLE_OPT) + target_include_directories(SPIRV + PRIVATE ${spirv-tools_SOURCE_DIR}/include + PRIVATE ${spirv-tools_SOURCE_DIR}/source + ) + target_link_libraries(SPIRV glslang SPIRV-Tools-opt SPVRemapper) +else() + target_link_libraries(SPIRV glslang) +endif(ENABLE_OPT) + if(WIN32) source_group("Source" FILES ${SOURCES} ${HEADERS}) source_group("Source" FILES ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS}) diff --git a/3rdparty/glslang/SPIRV/GlslangToSpv.cpp b/3rdparty/glslang/SPIRV/GlslangToSpv.cpp index 40f7508e4..9dec286cd 100755 --- a/3rdparty/glslang/SPIRV/GlslangToSpv.cpp +++ b/3rdparty/glslang/SPIRV/GlslangToSpv.cpp @@ -1081,8 +1081,10 @@ void TGlslangToSpvTraverser::visitSymbol(glslang::TIntermSymbol* symbol) // Include all "static use" and "linkage only" interface variables on the OpEntryPoint instruction if (builder.isPointer(id)) { spv::StorageClass sc = builder.getStorageClass(id); - if (sc == spv::StorageClassInput || sc == spv::StorageClassOutput) - iOSet.insert(id); + if (sc == spv::StorageClassInput || sc == spv::StorageClassOutput) { + if (!symbol->getType().isStruct() || symbol->getType().getStruct()->size() > 0) + iOSet.insert(id); + } } // Only process non-linkage-only nodes for generating actual static uses diff --git a/3rdparty/glslang/Test/100samplerExternal.frag b/3rdparty/glslang/Test/100samplerExternal.frag new file mode 100644 index 000000000..9f6f397e0 --- /dev/null +++ b/3rdparty/glslang/Test/100samplerExternal.frag @@ -0,0 +1,41 @@ +#version 100 + +#extension GL_OES_EGL_image_external : enable + +uniform samplerExternalOES sExt; +precision mediump samplerExternalOES; +uniform samplerExternalOES mediumExt; +uniform highp samplerExternalOES highExt; + +void main() +{ + texture2D(sExt, vec2(0.2)); + texture2D(mediumExt, vec2(0.2)); + texture2D(highExt, vec2(0.2)); + texture2DProj(sExt, vec3(0.3)); + texture2DProj(sExt, vec4(0.3)); + + int lod = 0; + highp float bias = 0.01; + textureSize(sExt, lod); // ERROR + texture(sExt, vec2(0.2)); // ERROR + texture(sExt, vec2(0.2), bias); // ERROR + textureProj(sExt, vec3(0.2)); // ERROR + textureProj(sExt, vec3(0.2), bias); // ERROR + textureProj(sExt, vec4(0.2)); // ERROR + textureProj(sExt, vec4(0.2), bias); // ERROR + texelFetch(sExt, ivec2(4), lod); // ERROR + + texture3D(sExt, vec3(0.3)); // ERROR + texture2DProjLod(sExt, vec3(0.3), 0.3); // ERROR + texture(sExt, vec3(0.3)); // ERROR + textureProjLod(sExt, vec3(0.3), 0.3); // ERROR +} + +#extension GL_OES_EGL_image_external : disable + +#extension GL_OES_EGL_image_external_essl3 : enable +uniform samplerExternalOES badExt; // ERROR +#extension GL_OES_EGL_image_external_essl3 : disable + +uniform samplerExternalOES badExt; // ERROR diff --git a/3rdparty/glslang/Test/300samplerExternal.frag b/3rdparty/glslang/Test/300samplerExternal.frag new file mode 100644 index 000000000..3724f8e0a --- /dev/null +++ b/3rdparty/glslang/Test/300samplerExternal.frag @@ -0,0 +1,41 @@ +#version 300 es + +#extension GL_OES_EGL_image_external_essl3 : enable + +uniform samplerExternalOES sExt; +precision mediump samplerExternalOES; +uniform samplerExternalOES mediumExt; +uniform highp samplerExternalOES highExt; + +void main() +{ + texture2D(sExt, vec2(0.2)); // ERROR + texture2D(mediumExt, vec2(0.2)); // ERROR + texture2D(highExt, vec2(0.2)); // ERROR + texture2DProj(sExt, vec3(0.3)); // ERROR + texture2DProj(sExt, vec4(0.3)); // ERROR + + int lod = 0; + highp float bias = 0.01; + textureSize(sExt, lod); + texture(sExt, vec2(0.2)); + texture(sExt, vec2(0.2), bias); + textureProj(sExt, vec3(0.2)); + textureProj(sExt, vec3(0.2), bias); + textureProj(sExt, vec4(0.2)); + textureProj(sExt, vec4(0.2), bias); + texelFetch(sExt, ivec2(4), lod); + + texture3D(sExt, vec3(0.3)); // ERROR + texture2DProjLod(sExt, vec3(0.3), 0.3); // ERROR + texture(sExt, vec3(0.3)); // ERROR + textureProjLod(sExt, vec3(0.3), 0.3); // ERROR +} + +#extension GL_OES_EGL_image_external_essl3 : disable + +#extension GL_OES_EGL_image_external : enable +uniform samplerExternalOES badExt; // ERROR +#extension GL_OES_EGL_image_external : disable + +uniform samplerExternalOES badExt; // ERROR diff --git a/3rdparty/glslang/Test/baseResults/100samplerExternal.frag.out b/3rdparty/glslang/Test/baseResults/100samplerExternal.frag.out new file mode 100644 index 000000000..8b689c761 --- /dev/null +++ b/3rdparty/glslang/Test/baseResults/100samplerExternal.frag.out @@ -0,0 +1,172 @@ +100samplerExternal.frag +ERROR: 0:20: 'textureSize' : no matching overloaded function found +ERROR: 0:21: 'texture' : no matching overloaded function found +ERROR: 0:22: 'texture' : no matching overloaded function found +ERROR: 0:23: 'textureProj' : no matching overloaded function found +ERROR: 0:24: 'textureProj' : no matching overloaded function found +ERROR: 0:25: 'textureProj' : no matching overloaded function found +ERROR: 0:26: 'textureProj' : no matching overloaded function found +ERROR: 0:27: 'texelFetch' : no matching overloaded function found +ERROR: 0:29: 'texture3D' : no matching overloaded function found +ERROR: 0:30: 'texture2DProjLod' : no matching overloaded function found +ERROR: 0:31: 'texture' : no matching overloaded function found +ERROR: 0:32: 'textureProjLod' : no matching overloaded function found +ERROR: 0:38: 'samplerExternalOES' : required extension not requested: GL_OES_EGL_image_external +ERROR: 0:41: '' : syntax error, unexpected IDENTIFIER, expecting LEFT_BRACE or COMMA or SEMICOLON +ERROR: 14 compilation errors. No code generated. + + +Shader version: 100 +Requested GL_OES_EGL_image_external +Requested GL_OES_EGL_image_external_essl3 +ERROR: node is still EOpNull! +0:10 Function Definition: main( ( global void) +0:10 Function Parameters: +0:12 Sequence +0:12 texture ( global lowp 4-component vector of float) +0:12 'sExt' ( uniform lowp samplerExternalOES) +0:12 Constant: +0:12 0.200000 +0:12 0.200000 +0:13 texture ( global mediump 4-component vector of float) +0:13 'mediumExt' ( uniform mediump samplerExternalOES) +0:13 Constant: +0:13 0.200000 +0:13 0.200000 +0:14 texture ( global highp 4-component vector of float) +0:14 'highExt' ( uniform highp samplerExternalOES) +0:14 Constant: +0:14 0.200000 +0:14 0.200000 +0:15 textureProj ( global lowp 4-component vector of float) +0:15 'sExt' ( uniform lowp samplerExternalOES) +0:15 Constant: +0:15 0.300000 +0:15 0.300000 +0:15 0.300000 +0:16 textureProj ( global lowp 4-component vector of float) +0:16 'sExt' ( uniform lowp samplerExternalOES) +0:16 Constant: +0:16 0.300000 +0:16 0.300000 +0:16 0.300000 +0:16 0.300000 +0:18 Sequence +0:18 move second child to first child ( temp mediump int) +0:18 'lod' ( temp mediump int) +0:18 Constant: +0:18 0 (const int) +0:19 Sequence +0:19 move second child to first child ( temp highp float) +0:19 'bias' ( temp highp float) +0:19 Constant: +0:19 0.010000 +0:20 Constant: +0:20 0.000000 +0:21 Constant: +0:21 0.000000 +0:22 Constant: +0:22 0.000000 +0:23 Constant: +0:23 0.000000 +0:24 Constant: +0:24 0.000000 +0:25 Constant: +0:25 0.000000 +0:26 Constant: +0:26 0.000000 +0:27 Constant: +0:27 0.000000 +0:29 Constant: +0:29 0.000000 +0:30 Constant: +0:30 0.000000 +0:31 Constant: +0:31 0.000000 +0:32 Constant: +0:32 0.000000 +0:? Linker Objects +0:? 'sExt' ( uniform lowp samplerExternalOES) +0:? 'mediumExt' ( uniform mediump samplerExternalOES) +0:? 'highExt' ( uniform highp samplerExternalOES) +0:? 'badExt' ( uniform mediump samplerExternalOES) + + +Linked fragment stage: + + +Shader version: 100 +Requested GL_OES_EGL_image_external +Requested GL_OES_EGL_image_external_essl3 +ERROR: node is still EOpNull! +0:10 Function Definition: main( ( global void) +0:10 Function Parameters: +0:12 Sequence +0:12 texture ( global lowp 4-component vector of float) +0:12 'sExt' ( uniform lowp samplerExternalOES) +0:12 Constant: +0:12 0.200000 +0:12 0.200000 +0:13 texture ( global mediump 4-component vector of float) +0:13 'mediumExt' ( uniform mediump samplerExternalOES) +0:13 Constant: +0:13 0.200000 +0:13 0.200000 +0:14 texture ( global highp 4-component vector of float) +0:14 'highExt' ( uniform highp samplerExternalOES) +0:14 Constant: +0:14 0.200000 +0:14 0.200000 +0:15 textureProj ( global lowp 4-component vector of float) +0:15 'sExt' ( uniform lowp samplerExternalOES) +0:15 Constant: +0:15 0.300000 +0:15 0.300000 +0:15 0.300000 +0:16 textureProj ( global lowp 4-component vector of float) +0:16 'sExt' ( uniform lowp samplerExternalOES) +0:16 Constant: +0:16 0.300000 +0:16 0.300000 +0:16 0.300000 +0:16 0.300000 +0:18 Sequence +0:18 move second child to first child ( temp mediump int) +0:18 'lod' ( temp mediump int) +0:18 Constant: +0:18 0 (const int) +0:19 Sequence +0:19 move second child to first child ( temp highp float) +0:19 'bias' ( temp highp float) +0:19 Constant: +0:19 0.010000 +0:20 Constant: +0:20 0.000000 +0:21 Constant: +0:21 0.000000 +0:22 Constant: +0:22 0.000000 +0:23 Constant: +0:23 0.000000 +0:24 Constant: +0:24 0.000000 +0:25 Constant: +0:25 0.000000 +0:26 Constant: +0:26 0.000000 +0:27 Constant: +0:27 0.000000 +0:29 Constant: +0:29 0.000000 +0:30 Constant: +0:30 0.000000 +0:31 Constant: +0:31 0.000000 +0:32 Constant: +0:32 0.000000 +0:? Linker Objects +0:? 'sExt' ( uniform lowp samplerExternalOES) +0:? 'mediumExt' ( uniform mediump samplerExternalOES) +0:? 'highExt' ( uniform highp samplerExternalOES) +0:? 'badExt' ( uniform mediump samplerExternalOES) + diff --git a/3rdparty/glslang/Test/baseResults/300samplerExternal.frag.out b/3rdparty/glslang/Test/baseResults/300samplerExternal.frag.out new file mode 100644 index 000000000..9074552e8 --- /dev/null +++ b/3rdparty/glslang/Test/baseResults/300samplerExternal.frag.out @@ -0,0 +1,197 @@ +300samplerExternal.frag +ERROR: 0:12: 'texture2D' : no matching overloaded function found +ERROR: 0:13: 'texture2D' : no matching overloaded function found +ERROR: 0:14: 'texture2D' : no matching overloaded function found +ERROR: 0:15: 'texture2DProj' : no matching overloaded function found +ERROR: 0:16: 'texture2DProj' : no matching overloaded function found +ERROR: 0:29: 'texture3D' : no matching overloaded function found +ERROR: 0:30: 'texture2DProjLod' : no matching overloaded function found +ERROR: 0:31: 'texture' : no matching overloaded function found +ERROR: 0:32: 'textureProjLod' : no matching overloaded function found +ERROR: 0:38: 'samplerExternalOES' : required extension not requested: GL_OES_EGL_image_external_essl3 +ERROR: 0:41: '' : syntax error, unexpected IDENTIFIER, expecting LEFT_BRACE or COMMA or SEMICOLON +ERROR: 11 compilation errors. No code generated. + + +Shader version: 300 +Requested GL_OES_EGL_image_external +Requested GL_OES_EGL_image_external_essl3 +ERROR: node is still EOpNull! +0:10 Function Definition: main( ( global void) +0:10 Function Parameters: +0:12 Sequence +0:12 Constant: +0:12 0.000000 +0:13 Constant: +0:13 0.000000 +0:14 Constant: +0:14 0.000000 +0:15 Constant: +0:15 0.000000 +0:16 Constant: +0:16 0.000000 +0:18 Sequence +0:18 move second child to first child ( temp mediump int) +0:18 'lod' ( temp mediump int) +0:18 Constant: +0:18 0 (const int) +0:19 Sequence +0:19 move second child to first child ( temp highp float) +0:19 'bias' ( temp highp float) +0:19 Constant: +0:19 0.010000 +0:20 textureSize ( global highp 2-component vector of int, operation at mediump) +0:20 'sExt' ( uniform lowp samplerExternalOES) +0:20 'lod' ( temp mediump int) +0:21 texture ( global lowp 4-component vector of float) +0:21 'sExt' ( uniform lowp samplerExternalOES) +0:21 Constant: +0:21 0.200000 +0:21 0.200000 +0:22 texture ( global lowp 4-component vector of float, operation at highp) +0:22 'sExt' ( uniform lowp samplerExternalOES) +0:22 Constant: +0:22 0.200000 +0:22 0.200000 +0:22 'bias' ( temp highp float) +0:23 textureProj ( global lowp 4-component vector of float) +0:23 'sExt' ( uniform lowp samplerExternalOES) +0:23 Constant: +0:23 0.200000 +0:23 0.200000 +0:23 0.200000 +0:24 textureProj ( global lowp 4-component vector of float, operation at highp) +0:24 'sExt' ( uniform lowp samplerExternalOES) +0:24 Constant: +0:24 0.200000 +0:24 0.200000 +0:24 0.200000 +0:24 'bias' ( temp highp float) +0:25 textureProj ( global lowp 4-component vector of float) +0:25 'sExt' ( uniform lowp samplerExternalOES) +0:25 Constant: +0:25 0.200000 +0:25 0.200000 +0:25 0.200000 +0:25 0.200000 +0:26 textureProj ( global lowp 4-component vector of float, operation at highp) +0:26 'sExt' ( uniform lowp samplerExternalOES) +0:26 Constant: +0:26 0.200000 +0:26 0.200000 +0:26 0.200000 +0:26 0.200000 +0:26 'bias' ( temp highp float) +0:27 textureFetch ( global lowp 4-component vector of float, operation at mediump) +0:27 'sExt' ( uniform lowp samplerExternalOES) +0:27 Constant: +0:27 4 (const int) +0:27 4 (const int) +0:27 'lod' ( temp mediump int) +0:29 Constant: +0:29 0.000000 +0:30 Constant: +0:30 0.000000 +0:31 Constant: +0:31 0.000000 +0:32 Constant: +0:32 0.000000 +0:? Linker Objects +0:? 'sExt' ( uniform lowp samplerExternalOES) +0:? 'mediumExt' ( uniform mediump samplerExternalOES) +0:? 'highExt' ( uniform highp samplerExternalOES) +0:? 'badExt' ( uniform mediump samplerExternalOES) + + +Linked fragment stage: + + +Shader version: 300 +Requested GL_OES_EGL_image_external +Requested GL_OES_EGL_image_external_essl3 +ERROR: node is still EOpNull! +0:10 Function Definition: main( ( global void) +0:10 Function Parameters: +0:12 Sequence +0:12 Constant: +0:12 0.000000 +0:13 Constant: +0:13 0.000000 +0:14 Constant: +0:14 0.000000 +0:15 Constant: +0:15 0.000000 +0:16 Constant: +0:16 0.000000 +0:18 Sequence +0:18 move second child to first child ( temp mediump int) +0:18 'lod' ( temp mediump int) +0:18 Constant: +0:18 0 (const int) +0:19 Sequence +0:19 move second child to first child ( temp highp float) +0:19 'bias' ( temp highp float) +0:19 Constant: +0:19 0.010000 +0:20 textureSize ( global highp 2-component vector of int, operation at mediump) +0:20 'sExt' ( uniform lowp samplerExternalOES) +0:20 'lod' ( temp mediump int) +0:21 texture ( global lowp 4-component vector of float) +0:21 'sExt' ( uniform lowp samplerExternalOES) +0:21 Constant: +0:21 0.200000 +0:21 0.200000 +0:22 texture ( global lowp 4-component vector of float, operation at highp) +0:22 'sExt' ( uniform lowp samplerExternalOES) +0:22 Constant: +0:22 0.200000 +0:22 0.200000 +0:22 'bias' ( temp highp float) +0:23 textureProj ( global lowp 4-component vector of float) +0:23 'sExt' ( uniform lowp samplerExternalOES) +0:23 Constant: +0:23 0.200000 +0:23 0.200000 +0:23 0.200000 +0:24 textureProj ( global lowp 4-component vector of float, operation at highp) +0:24 'sExt' ( uniform lowp samplerExternalOES) +0:24 Constant: +0:24 0.200000 +0:24 0.200000 +0:24 0.200000 +0:24 'bias' ( temp highp float) +0:25 textureProj ( global lowp 4-component vector of float) +0:25 'sExt' ( uniform lowp samplerExternalOES) +0:25 Constant: +0:25 0.200000 +0:25 0.200000 +0:25 0.200000 +0:25 0.200000 +0:26 textureProj ( global lowp 4-component vector of float, operation at highp) +0:26 'sExt' ( uniform lowp samplerExternalOES) +0:26 Constant: +0:26 0.200000 +0:26 0.200000 +0:26 0.200000 +0:26 0.200000 +0:26 'bias' ( temp highp float) +0:27 textureFetch ( global lowp 4-component vector of float, operation at mediump) +0:27 'sExt' ( uniform lowp samplerExternalOES) +0:27 Constant: +0:27 4 (const int) +0:27 4 (const int) +0:27 'lod' ( temp mediump int) +0:29 Constant: +0:29 0.000000 +0:30 Constant: +0:30 0.000000 +0:31 Constant: +0:31 0.000000 +0:32 Constant: +0:32 0.000000 +0:? Linker Objects +0:? 'sExt' ( uniform lowp samplerExternalOES) +0:? 'mediumExt' ( uniform mediump samplerExternalOES) +0:? 'highExt' ( uniform highp samplerExternalOES) +0:? 'badExt' ( uniform mediump samplerExternalOES) + diff --git a/3rdparty/glslang/Test/baseResults/hlsl.emptystructreturn.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.emptystructreturn.frag.out index 5440045db..591318049 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.emptystructreturn.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.emptystructreturn.frag.out @@ -56,7 +56,7 @@ gl_FragCoord origin is upper left Capability Shader 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 - EntryPoint Fragment 4 "main" 20 23 + EntryPoint Fragment 4 "main" ExecutionMode 4 OriginUpperLeft Source HLSL 500 Name 4 "main" diff --git a/3rdparty/glslang/Test/baseResults/hlsl.emptystructreturn.vert.out b/3rdparty/glslang/Test/baseResults/hlsl.emptystructreturn.vert.out index c8cea5d1f..f93bb63d2 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.emptystructreturn.vert.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.emptystructreturn.vert.out @@ -54,7 +54,7 @@ Shader version: 500 Capability Shader 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 - EntryPoint Vertex 4 "main" 20 23 + EntryPoint Vertex 4 "main" Source HLSL 500 Name 4 "main" Name 6 "vs_in" diff --git a/3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp b/3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp index fea8a6b30..f8138ffc2 100644 --- a/3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp +++ b/3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp @@ -1324,10 +1324,25 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV if (profile == EEsProfile) { if (spvVersion.spv == 0) { + if (version < 300) { + commonBuiltins.append( + "vec4 texture2D(samplerExternalOES, vec2 coord);" // GL_OES_EGL_image_external + "vec4 texture2DProj(samplerExternalOES, vec3);" // GL_OES_EGL_image_external + "vec4 texture2DProj(samplerExternalOES, vec4);" // GL_OES_EGL_image_external + "\n"); + } else { + commonBuiltins.append( + "highp ivec2 textureSize(samplerExternalOES, int lod);" // GL_OES_EGL_image_external_essl3 + "vec4 texture(samplerExternalOES, vec2);" // GL_OES_EGL_image_external_essl3 + "vec4 texture(samplerExternalOES, vec2, float bias);" // GL_OES_EGL_image_external_essl3 + "vec4 textureProj(samplerExternalOES, vec3);" // GL_OES_EGL_image_external_essl3 + "vec4 textureProj(samplerExternalOES, vec3, float bias);" // GL_OES_EGL_image_external_essl3 + "vec4 textureProj(samplerExternalOES, vec4);" // GL_OES_EGL_image_external_essl3 + "vec4 textureProj(samplerExternalOES, vec4, float bias);" // GL_OES_EGL_image_external_essl3 + "vec4 texelFetch(samplerExternalOES, ivec2, int lod);" // GL_OES_EGL_image_external_essl3 + "\n"); + } commonBuiltins.append( - "vec4 texture2D(samplerExternalOES, vec2 coord);" // GL_OES_EGL_image_external, caught by keyword check - "vec4 texture2DProj(samplerExternalOES, vec3);" // GL_OES_EGL_image_external, caught by keyword check - "vec4 texture2DProj(samplerExternalOES, vec4);" // GL_OES_EGL_image_external, caught by keyword check "vec4 texture2DGradEXT(sampler2D, vec2, vec2, vec2);" // GL_EXT_shader_texture_lod "vec4 texture2DProjGradEXT(sampler2D, vec3, vec2, vec2);" // GL_EXT_shader_texture_lod "vec4 texture2DProjGradEXT(sampler2D, vec4, vec2, vec2);" // GL_EXT_shader_texture_lod diff --git a/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp b/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp index 8154e687a..7f721a04f 100644 --- a/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp +++ b/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp @@ -2438,6 +2438,16 @@ void TParseContext::boolCheck(const TSourceLoc& loc, const TPublicType& pType) void TParseContext::samplerCheck(const TSourceLoc& loc, const TType& type, const TString& identifier, TIntermTyped* /*initializer*/) { + // Check that the appropriate extension is enabled if external sampler is used. + // There are two extensions. The correct one must be used based on GLSL version. + if (type.getBasicType() == EbtSampler && type.getSampler().external) { + if (version < 300) { + requireExtensions(loc, 1, &E_GL_OES_EGL_image_external, "samplerExternalOES"); + } else { + requireExtensions(loc, 1, &E_GL_OES_EGL_image_external_essl3, "samplerExternalOES"); + } + } + if (type.getQualifier().storage == EvqUniform) return; diff --git a/3rdparty/glslang/glslang/MachineIndependent/Scan.cpp b/3rdparty/glslang/glslang/MachineIndependent/Scan.cpp index 25122eec1..68d1500b4 100644 --- a/3rdparty/glslang/glslang/MachineIndependent/Scan.cpp +++ b/3rdparty/glslang/glslang/MachineIndependent/Scan.cpp @@ -1152,7 +1152,9 @@ int TScanContext::tokenizeIdentifier() case SAMPLEREXTERNALOES: afterType = true; - if (parseContext.symbolTable.atBuiltInLevel() || parseContext.extensionTurnedOn(E_GL_OES_EGL_image_external)) + if (parseContext.symbolTable.atBuiltInLevel() || + parseContext.extensionTurnedOn(E_GL_OES_EGL_image_external) || + parseContext.extensionTurnedOn(E_GL_OES_EGL_image_external_essl3)) return keyword; return identifierOrType(); diff --git a/3rdparty/glslang/glslang/MachineIndependent/Versions.cpp b/3rdparty/glslang/glslang/MachineIndependent/Versions.cpp index c4329e607..807fe42b6 100644 --- a/3rdparty/glslang/glslang/MachineIndependent/Versions.cpp +++ b/3rdparty/glslang/glslang/MachineIndependent/Versions.cpp @@ -154,6 +154,7 @@ void TParseVersions::initializeExtensionBehavior() extensionBehavior[E_GL_OES_standard_derivatives] = EBhDisable; extensionBehavior[E_GL_EXT_frag_depth] = EBhDisable; extensionBehavior[E_GL_OES_EGL_image_external] = EBhDisable; + extensionBehavior[E_GL_OES_EGL_image_external_essl3] = EBhDisable; extensionBehavior[E_GL_EXT_shader_texture_lod] = EBhDisable; extensionBehavior[E_GL_EXT_shadow_samplers] = EBhDisable; extensionBehavior[E_GL_ARB_texture_rectangle] = EBhDisable; @@ -261,6 +262,7 @@ void TParseVersions::getPreamble(std::string& preamble) "#define GL_OES_standard_derivatives 1\n" "#define GL_EXT_frag_depth 1\n" "#define GL_OES_EGL_image_external 1\n" + "#define GL_OES_EGL_image_external_essl3 1\n" "#define GL_EXT_shader_texture_lod 1\n" "#define GL_EXT_shadow_samplers 1\n" diff --git a/3rdparty/glslang/glslang/MachineIndependent/Versions.h b/3rdparty/glslang/glslang/MachineIndependent/Versions.h index d5aca70ee..9399e9dd2 100644 --- a/3rdparty/glslang/glslang/MachineIndependent/Versions.h +++ b/3rdparty/glslang/glslang/MachineIndependent/Versions.h @@ -107,6 +107,7 @@ const char* const E_GL_OES_texture_3D = "GL_OES_texture_3D"; const char* const E_GL_OES_standard_derivatives = "GL_OES_standard_derivatives"; const char* const E_GL_EXT_frag_depth = "GL_EXT_frag_depth"; const char* const E_GL_OES_EGL_image_external = "GL_OES_EGL_image_external"; +const char* const E_GL_OES_EGL_image_external_essl3 = "GL_OES_EGL_image_external_essl3"; const char* const E_GL_EXT_shader_texture_lod = "GL_EXT_shader_texture_lod"; const char* const E_GL_EXT_shadow_samplers = "GL_EXT_shadow_samplers"; diff --git a/3rdparty/glslang/gtests/AST.FromFile.cpp b/3rdparty/glslang/gtests/AST.FromFile.cpp index ed6a13e85..fbbf81b51 100644 --- a/3rdparty/glslang/gtests/AST.FromFile.cpp +++ b/3rdparty/glslang/gtests/AST.FromFile.cpp @@ -62,6 +62,7 @@ INSTANTIATE_TEST_CASE_P( "versionsErrors.frag", "versionsErrors.vert", "100.frag", + "100samplerExternal.frag", "120.vert", "120.frag", "130.vert", @@ -93,6 +94,7 @@ INSTANTIATE_TEST_CASE_P( "300layout.frag", "300operations.frag", "300block.frag", + "300samplerExternal.frag", "310.comp", "310.vert", "310.geom",