Merge commit 'caa54d9779d5605aca4e1a0c0c962a3d8f4aeb31' into HEAD
This merges the Vulkan 1.4.304.1 SDK known-good version of shaderc
specified in https://github.com/google/shaderc/commit/3f164a03cd21f7d59be753a07c7626cffc74512d
Bug: 379153784
Change-Id: I5fa19896890e02a4a0e883f977cafcce076e130d
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/shaderc/+/1205827
Reviewed-by: Craig Stout <cstout@google.com>
diff --git a/.gitignore b/.gitignore
index 06673ec..1cd253f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,3 +18,4 @@
android_test/libs
android_test/include
.DS_Store
+.vscode/
diff --git a/Android.mk b/Android.mk
index ed4a782..b2a949e 100644
--- a/Android.mk
+++ b/Android.mk
@@ -19,12 +19,9 @@
include $(ROOT_SHADERC_PATH)/libshaderc/Android.mk
ALL_LIBS:=libglslang.a \
- libOGLCompiler.a \
- libOSDependent.a \
libshaderc.a \
libshaderc_util.a \
libSPIRV.a \
- libHLSL.a \
libSPIRV-Tools.a \
libSPIRV-Tools-opt.a
diff --git a/CHANGES b/CHANGES
index 7de30b5..22caae4 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,47 @@
Revision history for Shaderc
+v2024.4
+ - Support Vulkan 1.4
+
+v2024.3
+ - Update dependencies: Glslang, SPRIV-Tools, SPIRV-Headers
+ - SPIRV-Tools is at v2024.4.rc1
+ - This incorporates a SPIRV-Tools fix which was limiting parallelism.
+ Validator friendly name generation was serializing on a mutex
+ protecting the locale object.
+ - During HLSL compilation or any optimizing compile, don't tell the
+ validator to use "friendly names". This should save time spent in the
+ initial validation step of the optimization recipe.
+ - Adapt test golden results to Glslang changes which reorder
+ decorations by object enum value.
+ - Fix ndk-build library dependencies: libshaderc_util depends on glslang
+ - Use Python 3.12 on Linux CI bots
+ - Fix Python 3.12 warnings for string escapes
+
+v2024.2
+ - Update dependencies:
+ Glslang: top of tree 2024-06-21
+ SPIRV-Header: top of tree 2024-06-21
+ SPIRV-Tools: v2024.3.rc1
+ - Build:
+ - Remove support for VS2017
+
+v2024.1
+ - Update dependencies
+ - Propagate test/install options to Glslang
+
+v2024.0
+ - Update dependencies
+ - Utilities:
+ - Use Python3 explicitly in utility scripts
+
+v2023.8 2024-01-03
+ - API: Expose rlaxed Vulkan rules from glslang
+ - Update to Glslang 14.0.0
+ - CMake:
+ - Comply with CMP0148: Use PythonInterp
+ - Use TARGET_OBJECTS to simplify creating the shaderc_shared library.
+
v2023.7 2023-10-12
- Update dependencies
- Finish converting build instructions and flags to always use C++17
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 075641e..ffcb54b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -91,18 +91,18 @@
add_compile_options("-Wextra-semi")
endif()
-find_host_package(PythonInterp 3 REQUIRED)
+find_package(Python COMPONENTS Interpreter REQUIRED)
if (SHADERC_ENABLE_COPYRIGHT_CHECK)
add_custom_target(check-copyright ALL
- ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/utils/add_copyright.py
+ ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/utils/add_copyright.py
--check
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Check copyright")
endif()
add_custom_target(add-copyright
- ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/utils/add_copyright.py
+ ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/utils/add_copyright.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Add copyright")
@@ -130,7 +130,7 @@
endif()
add_custom_target(build-version
- ${PYTHON_EXECUTABLE}
+ ${Python_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/utils/update_build_version.py
${shaderc_SOURCE_DIR} ${spirv-tools_SOURCE_DIR} ${glslang_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/build-version.inc
COMMENT "Update build-version.inc in the Shaderc build directory (if necessary).")
diff --git a/DEPS b/DEPS
index a7dc1d3..d8f506b 100644
--- a/DEPS
+++ b/DEPS
@@ -5,13 +5,13 @@
'google_git': 'https://github.com/google',
'khronos_git': 'https://github.com/KhronosGroup',
- 'abseil_revision': '5be22f98733c674d532598454ae729253bc53e82',
- 'effcee_revision' : '19b4aa87af25cb4ee779a071409732f34bfc305c',
- 'glslang_revision': '48f9ed8b08be974f4e463ef38136c8f23513b2cf',
- 'googletest_revision': 'e47544ad31cb3ceecd04cc13e8fe556f8df9fe0b',
- 're2_revision': 'c9cba76063cf4235c1a15dd14a24a4ef8d623761',
- 'spirv_headers_revision': '4183b260f4cccae52a89efdfcdd43c4897989f42',
- 'spirv_tools_revision': '360d469b9eac54d6c6e20f609f9ec35e3a5380ad',
+ 'abseil_revision': '1315c900e1ddbb08a23e06eeb9a06450052ccb5e',
+ 'effcee_revision': 'd74d33d93043952a99ae7cd7458baf6bc8df1da0',
+ 'glslang_revision': 'a0995c49ebcaca2c6d3b03efbabf74f3843decdb',
+ 'googletest_revision': '1d17ea141d2c11b8917d2c7d029f1c4e2b9769b2',
+ 're2_revision': '4a8cee3dd3c3d81b6fe8b867811e193d5819df07',
+ 'spirv_headers_revision': '3f17b2af6784bfa2c5aa5dbb8e0e74a607dd8b3b',
+ 'spirv_tools_revision': '4d2f0b40bfe290dea6c6904dafdf7fd8328ba346',
}
deps = {
diff --git a/README.md b/README.md
index 3f54ded..0ebacfa 100644
--- a/README.md
+++ b/README.md
@@ -28,7 +28,7 @@
<img alt="Linux" src="kokoro/img/linux.png" width="20px" height="20px" hspace="2px"/>[](https://storage.googleapis.com/shaderc/badges/build_link_linux_clang_release.html)
<img alt="MacOS" src="kokoro/img/macos.png" width="20px" height="20px" hspace="2px"/>[](https://storage.googleapis.com/shaderc/badges/build_link_macos_clang_release.html)
-<img alt="Windows" src="kokoro/img/windows.png" width="20px" height="20px" hspace="2px"/>[](https://storage.googleapis.com/shaderc/badges/build_link_windows_vs2017_release.html)
+<img alt="Windows" src="kokoro/img/windows.png" width="20px" height="20px" hspace="2px"/>[](https://storage.googleapis.com/shaderc/badges/build_link_windows_vs2019_release.html)
[More downloads](downloads.md)
@@ -176,7 +176,7 @@
On Windows, the following tools should be installed and available on your path:
-- Visual Studio 2017 or later. Previous versions of Visual Studio may work but
+- Visual Studio 2019 or later. Previous versions of Visual Studio may work but
are untested and unsupported.
- Git - including the associated tools, Bash, `diff`.
diff --git a/cmake/setup_build.cmake b/cmake/setup_build.cmake
index 994de9f..936796d 100644
--- a/cmake/setup_build.cmake
+++ b/cmake/setup_build.cmake
@@ -49,7 +49,7 @@
find_host_package(PythonInterp 3 REQUIRED)
find_host_package(BISON)
else()
-find_package(PythonInterp 3 REQUIRED)
+ find_package(Python COMPONENTS Interpreter REQUIRED)
endif()
option(DISABLE_RTTI "Disable RTTI in builds")
diff --git a/cmake/utils.cmake b/cmake/utils.cmake
index e9475b9..b2489d9 100644
--- a/cmake/utils.cmake
+++ b/cmake/utils.cmake
@@ -173,50 +173,10 @@
# Combines the static library "target" with all of its transitive static
# library dependencies into a single static library "new_target".
function(shaderc_combine_static_lib new_target target)
-
set(all_libs "")
shaderc_get_transitive_libs(${target} all_libs)
-
- set(libname
- ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${new_target}${CMAKE_STATIC_LIBRARY_SUFFIX})
-
- if (MSVC)
- string(REPLACE ";" ">;$<TARGET_FILE:" temp_string "${all_libs}")
- set(lib_target_list "$<TARGET_FILE:${temp_string}>")
-
- add_custom_command(OUTPUT ${libname}
- DEPENDS ${all_libs}
- COMMAND lib.exe ${lib_target_list} /OUT:${libname} /NOLOGO)
- elseif(APPLE)
- string(REPLACE ";" ">;$<TARGET_FILE:" temp_string "${all_libs}")
- set(lib_target_list "$<TARGET_FILE:${temp_string}>")
-
- add_custom_command(OUTPUT ${libname}
- DEPENDS ${all_libs}
- COMMAND libtool -static -o ${libname} ${lib_target_list})
- else()
- string(REPLACE ";" "> \naddlib $<TARGET_FILE:" temp_string "${all_libs}")
- set(start_of_file
- "create ${libname}\naddlib $<TARGET_FILE:${temp_string}>")
- set(build_script_file "${start_of_file}\nsave\nend\n")
-
- file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${new_target}.ar"
- CONTENT ${build_script_file}
- CONDITION 1)
-
- add_custom_command(OUTPUT ${libname}
- DEPENDS ${all_libs}
- COMMAND ${CMAKE_AR} -M < ${new_target}.ar)
- endif()
-
- add_custom_target(${new_target}_genfile ALL
- DEPENDS ${libname})
-
- # CMake needs to be able to see this as another normal library,
- # so import the newly created library as an imported library,
- # and set up the dependencies on the custom target.
- add_library(${new_target} STATIC IMPORTED)
- set_target_properties(${new_target}
- PROPERTIES IMPORTED_LOCATION ${libname})
- add_dependencies(${new_target} ${new_target}_genfile)
+ add_library(${new_target} STATIC)
+ foreach(lib IN LISTS all_libs)
+ target_sources(${new_target} PRIVATE $<TARGET_OBJECTS:${lib}>)
+ endforeach()
endfunction()
diff --git a/downloads.md b/downloads.md
index b610422..c69ed95 100644
--- a/downloads.md
+++ b/downloads.md
@@ -8,10 +8,10 @@
| Windows | Linux | MacOS |
| --- | --- | --- |
| [MSVC 2019](https://storage.googleapis.com/shaderc/badges/build_link_windows_vs2019_release.html) | [clang](https://storage.googleapis.com/shaderc/badges/build_link_linux_clang_release.html) | [clang](https://storage.googleapis.com/shaderc/badges/build_link_macos_clang_release.html) |
-| [MSVC 2017](https://storage.googleapis.com/shaderc/badges/build_link_windows_vs2017_release.html) | [gcc](https://storage.googleapis.com/shaderc/badges/build_link_linux_gcc_release.html) | |
+| | [gcc](https://storage.googleapis.com/shaderc/badges/build_link_linux_gcc_release.html) | |
## Debug
| Windows | Linux | MacOS |
| --- | --- | --- |
| [MSVC 2019](https://storage.googleapis.com/shaderc/badges/build_link_windows_vs2019_debug.html) | [clang](https://storage.googleapis.com/shaderc/badges/build_link_linux_clang_debug.html) | [clang](https://storage.googleapis.com/shaderc/badges/build_link_macos_clang_debug.html) |
-| [MSVC 2017](https://storage.googleapis.com/shaderc/badges/build_link_windows_vs2017_debug.html) | [gcc](https://storage.googleapis.com/shaderc/badges/build_link_linux_gcc_debug.html) | |
+| | [gcc](https://storage.googleapis.com/shaderc/badges/build_link_linux_gcc_debug.html) | |
diff --git a/glslc/CMakeLists.txt b/glslc/CMakeLists.txt
index c8fa6d5..1277d87 100644
--- a/glslc/CMakeLists.txt
+++ b/glslc/CMakeLists.txt
@@ -43,7 +43,7 @@
endif(SHADERC_ENABLE_WGSL_OUTPUT)
target_link_libraries(glslc PRIVATE
- glslang OSDependent OGLCompiler HLSL glslang SPIRV # Glslang libraries
+ glslang SPIRV # Glslang libraries
$<$<BOOL:${SHADERC_ENABLE_WGSL_OUTPUT}>:libtint> # Tint libraries, optional
shaderc_util shaderc # internal Shaderc libraries
${CMAKE_THREAD_LIBS_INIT})
diff --git a/glslc/README.asciidoc b/glslc/README.asciidoc
index c9ffbdc..c185433 100644
--- a/glslc/README.asciidoc
+++ b/glslc/README.asciidoc
@@ -234,6 +234,8 @@
* `vulkan1.0`: create SPIR-V under Vulkan 1.0 semantics.
* `vulkan1.1`: create SPIR-V under Vulkan 1.1 semantics.
* `vulkan1.2`: create SPIR-V under Vulkan 1.2 semantics.
+* `vulkan1.3`: create SPIR-V under Vulkan 1.3 semantics.
+* `vulkan1.4`: create SPIR-V under Vulkan 1.4 semantics.
* `opengl`: create SPIR-V under OpenGL 4.5 semantics.
* `opengl4.5`: create SPIR-V under OpenGL 4.5 semantics.
diff --git a/glslc/src/main.cc b/glslc/src/main.cc
index 5cc3f43..5e7c68d 100644
--- a/glslc/src/main.cc
+++ b/glslc/src/main.cc
@@ -165,6 +165,7 @@
vulkan1.1
vulkan1.2
vulkan1.3
+ vulkan1.4
vulkan # Same as vulkan1.0
opengl4.5
opengl # Same as opengl4.5
@@ -174,8 +175,9 @@
required to be supported for the target environment.
For example, default for vulkan1.0 is spv1.0, and
the default for vulkan1.1 is spv1.3,
- the default for vulkan1.2 is spv1.5.
- the default for vulkan1.3 is spv1.6.
+ the default for vulkan1.2 is spv1.5,
+ the default for vulkan1.3 is spv1.6,
+ the default for vulkan1.4 is spv1.6.
Values are:
spv1.0, spv1.1, spv1.2, spv1.3, spv1.4, spv1.5, spv1.6
--version Display compiler version information.
@@ -265,8 +267,9 @@
// Sets binding base for the given uniform kind. If stage is
// shader_glsl_infer_from_source then set it for all shader stages.
- auto set_binding_base = [&compiler](
- shaderc_shader_kind stage, shaderc_uniform_kind kind, uint32_t base) {
+ auto set_binding_base = [&compiler](shaderc_shader_kind stage,
+ shaderc_uniform_kind kind,
+ uint32_t base) {
if (stage == shaderc_glsl_infer_from_source)
compiler.options().SetBindingBase(kind, base);
else
@@ -452,6 +455,9 @@
} else if (target_env_str == "vulkan1.3") {
target_env = shaderc_target_env_vulkan;
version = shaderc_env_version_vulkan_1_3;
+ } else if (target_env_str == "vulkan1.4") {
+ target_env = shaderc_target_env_vulkan;
+ version = shaderc_env_version_vulkan_1_4;
} else if (target_env_str == "opengl") {
target_env = shaderc_target_env_opengl;
} else if (target_env_str == "opengl4.5") {
@@ -675,9 +681,10 @@
// from the file name. If current_fshader_stage is specifed to one of
// the forced shader kinds, use that for the following compilation.
input_files.emplace_back(glslc::InputFileSpec{
- arg.str(), (current_fshader_stage == shaderc_glsl_infer_from_source
- ? glslc::DeduceDefaultShaderKindFromFileName(arg)
- : current_fshader_stage),
+ arg.str(),
+ (current_fshader_stage == shaderc_glsl_infer_from_source
+ ? glslc::DeduceDefaultShaderKindFromFileName(arg)
+ : current_fshader_stage),
language, current_entry_point_name});
}
}
diff --git a/glslc/test/CMakeLists.txt b/glslc/test/CMakeLists.txt
index ac001bd..372f21a 100644
--- a/glslc/test/CMakeLists.txt
+++ b/glslc/test/CMakeLists.txt
@@ -13,15 +13,15 @@
# limitations under the License.
add_test(NAME shaderc_expect_unittests
- COMMAND ${PYTHON_EXECUTABLE} -m unittest expect_unittest.py
+ COMMAND ${Python_EXECUTABLE} -m unittest expect_unittest.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_test(NAME shaderc_glslc_test_framework_unittests
- COMMAND ${PYTHON_EXECUTABLE} -m unittest glslc_test_framework_unittest.py
+ COMMAND ${Python_EXECUTABLE} -m unittest glslc_test_framework_unittest.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
if(${SHADERC_ENABLE_TESTS})
add_test(NAME glslc_tests
- COMMAND ${PYTHON_EXECUTABLE}
+ COMMAND ${Python_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/glslc_test_framework.py
$<TARGET_FILE:glslc_exe> $<TARGET_FILE:spirv-dis>
--test-dir ${CMAKE_CURRENT_SOURCE_DIR})
diff --git a/glslc/test/option_dash_cap_O.py b/glslc/test/option_dash_cap_O.py
index fa474f9..cf301c5 100644
--- a/glslc/test/option_dash_cap_O.py
+++ b/glslc/test/option_dash_cap_O.py
@@ -21,71 +21,94 @@
EMPTY_SHADER_IN_CWD = Directory('.', [File('shader.vert', MINIMAL_SHADER)])
ASSEMBLY_WITH_DEBUG_SOURCE = [
- '; SPIR-V\n',
- '; Version: 1.0\n',
- '; Generator: Google Shaderc over Glslang; 11\n',
- '; Bound: 7\n',
- '; Schema: 0\n',
- ' OpCapability Shader\n',
- ' %2 = OpExtInstImport "GLSL.std.450"\n',
- ' OpMemoryModel Logical GLSL450\n',
- ' OpEntryPoint Vertex %main "main"\n',
- ' %1 = OpString "shader.vert"\n',
- ' OpSource ESSL 310 %1 "// OpModuleProcessed entry-point main\n',
- '// OpModuleProcessed client vulkan100\n',
- '// OpModuleProcessed target-env vulkan1.0\n',
- '// OpModuleProcessed entry-point main\n',
- '#line 1\n',
- '#version 310 es\n',
- 'void main() {}"\n',
- ' OpSourceExtension "GL_GOOGLE_cpp_style_line_directive"\n',
- ' OpSourceExtension "GL_GOOGLE_include_directive"\n',
- ' OpName %main "main"\n',
- ' %void = OpTypeVoid\n',
- ' %4 = OpTypeFunction %void\n',
- ' OpLine %1 2 11\n',
- ' %main = OpFunction %void None %4\n',
- ' %6 = OpLabel\n',
- ' OpReturn\n',
- ' OpFunctionEnd\n']
+ """; SPIR-V
+; Version: 1.0
+; Generator: Google Shaderc over Glslang; 11
+; Bound: 7
+; Schema: 0
+ OpCapability Shader
+ %2 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %main "main"
+ %1 = OpString "shader.vert"
+ OpSource ESSL 310 %1 "// OpModuleProcessed entry-point main
+// OpModuleProcessed client vulkan100
+// OpModuleProcessed target-env vulkan1.0
+// OpModuleProcessed entry-point main
+#line 1
+#version 310 es
+void main() {}"
+ OpSourceExtension "GL_GOOGLE_cpp_style_line_directive"
+ OpSourceExtension "GL_GOOGLE_include_directive"
+ OpName %main "main"
+ %void = OpTypeVoid
+ %4 = OpTypeFunction %void
+ OpLine %1 2 11
+ %main = OpFunction %void None %4
+ %6 = OpLabel
+ OpLine %1 2 0
+ OpReturn
+ OpFunctionEnd
+"""
+]
-ASSEMBLY_WITH_DEBUG = [
- '; SPIR-V\n',
- '; Version: 1.0\n',
- '; Generator: Google Shaderc over Glslang; 11\n',
- '; Bound: 6\n',
- '; Schema: 0\n',
- ' OpCapability Shader\n',
- ' %1 = OpExtInstImport "GLSL.std.450"\n',
- ' OpMemoryModel Logical GLSL450\n',
- ' OpEntryPoint Vertex %main "main"\n',
- ' OpSource ESSL 310\n',
- ' OpSourceExtension "GL_GOOGLE_cpp_style_line_directive"\n',
- ' OpSourceExtension "GL_GOOGLE_include_directive"\n',
- ' OpName %main "main"\n',
- ' %void = OpTypeVoid\n',
- ' %3 = OpTypeFunction %void\n',
- ' %main = OpFunction %void None %3\n',
- ' %5 = OpLabel\n',
- ' OpReturn\n',
- ' OpFunctionEnd\n']
+ASSEMBLY_O0 = [
+ """; SPIR-V
+; Version: 1.0
+; Generator: Google Shaderc over Glslang; 11
+; Bound: 6
+; Schema: 0
+ OpCapability Shader
+ %1 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %main "main"
+ OpSource ESSL 310
+ OpSourceExtension "GL_GOOGLE_cpp_style_line_directive"
+ OpSourceExtension "GL_GOOGLE_include_directive"
+ OpName %main "main"
+ %void = OpTypeVoid
+ %3 = OpTypeFunction %void
+ %main = OpFunction %void None %3
+ %5 = OpLabel
+ OpReturn
+ OpFunctionEnd
+"""]
-ASSEMBLY_WITHOUT_DEBUG = [
- '; SPIR-V\n',
- '; Version: 1.0\n',
- '; Generator: Google Shaderc over Glslang; 11\n',
- '; Bound: 6\n',
- '; Schema: 0\n',
- ' OpCapability Shader\n',
- ' %1 = OpExtInstImport "GLSL.std.450"\n',
- ' OpMemoryModel Logical GLSL450\n',
- ' OpEntryPoint Vertex %4 "main"\n',
- ' %void = OpTypeVoid\n',
- ' %3 = OpTypeFunction %void\n',
- ' %4 = OpFunction %void None %3\n', # %4 vs. %main
- ' %5 = OpLabel\n',
- ' OpReturn\n',
- ' OpFunctionEnd\n']
+ASSEMBLY_O = [
+ """; SPIR-V
+; Version: 1.0
+; Generator: Google Shaderc over Glslang; 11
+; Bound: 6
+; Schema: 0
+ OpCapability Shader
+ %1 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %4 "main"
+ %void = OpTypeVoid
+ %3 = OpTypeFunction %void
+ %4 = OpFunction %void None %3
+ %5 = OpLabel
+ OpReturn
+ OpFunctionEnd
+"""]
+
+ASSEMBLY_Os = [
+ """; SPIR-V
+; Version: 1.0
+; Generator: Google Shaderc over Glslang; 11
+; Bound: 6
+; Schema: 0
+ OpCapability Shader
+ %1 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %4 "main"
+ %void = OpTypeVoid
+ %3 = OpTypeFunction %void
+ %4 = OpFunction %void None %3
+ %5 = OpLabel
+ OpReturn
+ OpFunctionEnd
+"""]
@inside_glslc_testsuite('OptionDashCapO')
@@ -95,7 +118,8 @@
environment = EMPTY_SHADER_IN_CWD
glslc_args = ['-S', '-O0', 'shader.vert']
target_filename = 'shader.vert.spvasm'
- expected_file_contents = ASSEMBLY_WITH_DEBUG
+ expected_file_contents = ASSEMBLY_O0
+
@inside_glslc_testsuite('OptionDashCapO')
class TestDashCapOPerformance(expect.ValidFileContents):
@@ -104,7 +128,8 @@
environment = EMPTY_SHADER_IN_CWD
glslc_args = ['-S', '-O', 'shader.vert']
target_filename = 'shader.vert.spvasm'
- expected_file_contents = ASSEMBLY_WITHOUT_DEBUG
+ expected_file_contents = ASSEMBLY_O
+
@inside_glslc_testsuite('OptionDashCapO')
class TestDashCapOs(expect.ValidFileContents):
@@ -113,7 +138,7 @@
environment = EMPTY_SHADER_IN_CWD
glslc_args = ['-S', '-Os', 'shader.vert']
target_filename = 'shader.vert.spvasm'
- expected_file_contents = ASSEMBLY_WITHOUT_DEBUG
+ expected_file_contents = ASSEMBLY_Os
@inside_glslc_testsuite('OptionDashCapO')
@@ -123,7 +148,7 @@
environment = EMPTY_SHADER_IN_CWD
glslc_args = ['-S', '-Os', '-O0', '-Os', '-O0', 'shader.vert']
target_filename = 'shader.vert.spvasm'
- expected_file_contents = ASSEMBLY_WITH_DEBUG
+ expected_file_contents = ASSEMBLY_O0
@inside_glslc_testsuite('OptionDashCapO')
diff --git a/glslc/test/option_fauto_bind_uniforms.py b/glslc/test/option_fauto_bind_uniforms.py
index 3f90a12..d6f86d0 100644
--- a/glslc/test/option_fauto_bind_uniforms.py
+++ b/glslc/test/option_fauto_bind_uniforms.py
@@ -80,8 +80,10 @@
u6[2];
u7;
u8;
- return float4(u8.Consume() + t2.SampleCmp(s2, 1.0, 2.0)) + t1.Sample(s1, 1.0)
- + t6.Load(1);
+ // SampleCmp disabled due to https://github.com/KhronosGroup/glslang/issues/2444.
+ //return float4(u8.Consume() + t2.SampleCmp(s2, 1.0, 2.0)) + t1.Sample(s1, 1.0)
+ // + t6.Load(1);
+ return float4(u8.Consume()) + t1.Sample(s1, 1.0) + t6.Load(1);
}
"""
@@ -340,7 +342,7 @@
shader = FileShader(HLSL_SHADER_WITHOUT_BINDINGS, '.frag')
glslc_args = ['-S', '-x', 'hlsl', '-fhlsl-iomap', shader,
'-fauto-bind-uniforms', '-fsampler-binding-base', '100']
- expected_assembly_substr = "OpDecorate %s2 Binding 102"
+ expected_assembly_substr = "OpDecorate %s1 Binding 101"
@inside_glslc_testsuite('OptionFAutoBindUniforms')
@@ -351,7 +353,7 @@
shader = FileShader(HLSL_SHADER_WITHOUT_BINDINGS, '.frag')
glslc_args = ['-S', '-x', 'hlsl', '-fhlsl-iomap', shader,
'-fauto-bind-uniforms', '-fsampler-binding-base', 'frag', '100']
- expected_assembly_substr = "OpDecorate %s2 Binding 102"
+ expected_assembly_substr = "OpDecorate %s1 Binding 101"
@inside_glslc_testsuite('OptionFAutoBindUniforms')
@@ -362,7 +364,7 @@
shader = FileShader(HLSL_SHADER_WITHOUT_BINDINGS, '.frag')
glslc_args = ['-S', '-x', 'hlsl', '-fhlsl-iomap', shader,
'-fauto-bind-uniforms', '-fsampler-binding-base', 'compute', '100']
- expected_assembly_substr = "OpDecorate %s2 Binding 2"
+ expected_assembly_substr = "OpDecorate %s1 Binding 1"
@inside_glslc_testsuite('OptionFAutoBindUniforms')
diff --git a/glslc/test/option_fresource_set_binding.py b/glslc/test/option_fresource_set_binding.py
index 254004e..03edda7 100644
--- a/glslc/test/option_fresource_set_binding.py
+++ b/glslc/test/option_fresource_set_binding.py
@@ -38,10 +38,10 @@
'-fresource-set-binding', 'frag',
't4', '9', '16',
't5', '17', '18']
- expected_assembly_substr = """OpDecorate %t4 DescriptorSet 9
- OpDecorate %t4 Binding 16
- OpDecorate %t5 DescriptorSet 17
- OpDecorate %t5 Binding 18"""
+ expected_assembly_substr = """OpDecorate %t4 Binding 16
+ OpDecorate %t4 DescriptorSet 9
+ OpDecorate %t5 Binding 18
+ OpDecorate %t5 DescriptorSet 17"""
@inside_glslc_testsuite('OptionFRegisterSetBinding')
@@ -52,10 +52,10 @@
glslc_args = ['-S', '-x', 'hlsl', shader,
'-fresource-set-binding', 'frag',
't4', '9', '16']
- expected_assembly_substr = """OpDecorate %t4 DescriptorSet 9
- OpDecorate %t4 Binding 16
- OpDecorate %t5 DescriptorSet 0
- OpDecorate %t5 Binding 5"""
+ expected_assembly_substr = """OpDecorate %t4 Binding 16
+ OpDecorate %t4 DescriptorSet 9
+ OpDecorate %t5 Binding 5
+ OpDecorate %t5 DescriptorSet 0"""
@inside_glslc_testsuite('OptionFRegisterSetBinding')
@@ -67,10 +67,10 @@
'-fresource-set-binding', 'vert',
't4', '9', '16',
't5', '17', '18']
- expected_assembly_substr = """OpDecorate %t4 DescriptorSet 0
- OpDecorate %t4 Binding 4
- OpDecorate %t5 DescriptorSet 0
- OpDecorate %t5 Binding 5"""
+ expected_assembly_substr = """OpDecorate %t4 Binding 4
+ OpDecorate %t4 DescriptorSet 0
+ OpDecorate %t5 Binding 5
+ OpDecorate %t5 DescriptorSet 0"""
@inside_glslc_testsuite('OptionFRegisterSetBinding')
@@ -82,10 +82,10 @@
'-fresource-set-binding',
't4', '9', '16',
't5', '17', '18']
- expected_assembly_substr = """OpDecorate %t4 DescriptorSet 9
- OpDecorate %t4 Binding 16
- OpDecorate %t5 DescriptorSet 17
- OpDecorate %t5 Binding 18"""
+ expected_assembly_substr = """OpDecorate %t4 Binding 16
+ OpDecorate %t4 DescriptorSet 9
+ OpDecorate %t5 Binding 18
+ OpDecorate %t5 DescriptorSet 17"""
@inside_glslc_testsuite('OptionFRegisterSetBinding')
diff --git a/glslc/test/option_mfmt.py b/glslc/test/option_mfmt.py
index bd58478..f87102f 100644
--- a/glslc/test/option_mfmt.py
+++ b/glslc/test/option_mfmt.py
@@ -22,7 +22,7 @@
# match exactly, and there should not be a trailing comma at the end of the
# list. When -mfmt=c is specified, curly brackets should be presented.
MINIMAL_SHADER_NUM_FORMAT_PATTERN = "^0x07230203.*[0-9a-f]$"
-MINIMAL_SHADER_C_FORMAT_PATTERN = "^\{0x07230203.*[0-9a-f]\}"
+MINIMAL_SHADER_C_FORMAT_PATTERN = "^\\{0x07230203.*[0-9a-f]\\}"
ERROR_SHADER = '#version 140\n#error\nvoid main() {}'
diff --git a/glslc/test/option_target_env.py b/glslc/test/option_target_env.py
index 91e6022..9555a77 100644
--- a/glslc/test/option_target_env.py
+++ b/glslc/test/option_target_env.py
@@ -131,16 +131,27 @@
glslc_args = ['--target-env=vulkan1.2', '-c', shader]
@inside_glslc_testsuite('OptionTargetEnv')
-class TestTargetEnvEqVulkan1_2WithVulkan1_0ShaderSucceeds(expect.ValidObjectFile1_6):
+class TestTargetEnvEqVulkan1_3WithVulkan1_0ShaderSucceeds(expect.ValidObjectFile1_6):
shader = FileShader(vulkan_vertex_shader(), '.vert')
glslc_args = ['--target-env=vulkan1.3', '-c', shader]
@inside_glslc_testsuite('OptionTargetEnv')
-class TestTargetEnvEqVulkan1_2WithVulkan1_1ShaderSucceeds(expect.ValidObjectFile1_6):
+class TestTargetEnvEqVulkan1_3WithVulkan1_1ShaderSucceeds(expect.ValidObjectFile1_6):
shader = FileShader(vulkan_compute_subgroup_shader(), '.comp')
glslc_args = ['--target-env=vulkan1.3', '-c', shader]
@inside_glslc_testsuite('OptionTargetEnv')
+class TestTargetEnvEqVulkan1_4WithVulkan1_0ShaderSucceeds(expect.ValidObjectFile1_6):
+ shader = FileShader(vulkan_vertex_shader(), '.vert')
+ glslc_args = ['--target-env=vulkan1.4', '-c', shader]
+
+@inside_glslc_testsuite('OptionTargetEnv')
+class TestTargetEnvEqVulkan1_4WithVulkan1_1ShaderSucceeds(expect.ValidObjectFile1_6):
+ shader = FileShader(vulkan_compute_subgroup_shader(), '.comp')
+ glslc_args = ['--target-env=vulkan1.4', '-c', shader]
+
+
+@inside_glslc_testsuite('OptionTargetEnv')
class TestTargetEnvEqOpenGL4_5WithOpenGLShaderSucceeds(expect.ValidObjectFile):
shader = FileShader(opengl_vertex_shader(), '.vert')
glslc_args = ['--target-env=opengl4.5', '-c', shader]
diff --git a/glslc/test/parameter_tests.py b/glslc/test/parameter_tests.py
index 6e3e1cd..d496210 100644
--- a/glslc/test/parameter_tests.py
+++ b/glslc/test/parameter_tests.py
@@ -169,6 +169,7 @@
vulkan1.1
vulkan1.2
vulkan1.3
+ vulkan1.4
vulkan # Same as vulkan1.0
opengl4.5
opengl # Same as opengl4.5
@@ -178,8 +179,9 @@
required to be supported for the target environment.
For example, default for vulkan1.0 is spv1.0, and
the default for vulkan1.1 is spv1.3,
- the default for vulkan1.2 is spv1.5.
- the default for vulkan1.3 is spv1.6.
+ the default for vulkan1.2 is spv1.5,
+ the default for vulkan1.3 is spv1.6,
+ the default for vulkan1.4 is spv1.6.
Values are:
spv1.0, spv1.1, spv1.2, spv1.3, spv1.4, spv1.5, spv1.6
--version Display compiler version information.
diff --git a/kokoro/android-release/build-docker.sh b/kokoro/android-release/build-docker.sh
index 8bd5215..a818325 100755
--- a/kokoro/android-release/build-docker.sh
+++ b/kokoro/android-release/build-docker.sh
@@ -48,8 +48,8 @@
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
-DANDROID_NDK=$ANDROID_NDK_HOME ..
-echo $(date): Build glslang...
-ninja glslang-standalone
+echo $(date): Build glslang library...
+ninja glslang
echo $(date): Build everything...
ninja
diff --git a/kokoro/linux/build-docker.sh b/kokoro/linux/build-docker.sh
index 7d71b61..bdc4573 100755
--- a/kokoro/linux/build-docker.sh
+++ b/kokoro/linux/build-docker.sh
@@ -27,6 +27,7 @@
using cmake-3.17.2
using ninja-1.10.0
+using python-3.12
if [ ! -z "$COMPILER" ]; then
using "$COMPILER"
diff --git a/kokoro/windows/build.bat b/kokoro/windows/build.bat
index a87cfea..27da106 100644
--- a/kokoro/windows/build.bat
+++ b/kokoro/windows/build.bat
@@ -38,9 +38,6 @@
if %VS_VERSION% == 2019 (
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
echo "Using VS 2019..."
-) else if %VS_VERSION% == 2017 (
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
- echo "Using VS 2017..."
)
:: #########################################
diff --git a/kokoro/windows/build_debug_2017.bat b/kokoro/windows/build_debug_2017.bat
deleted file mode 100644
index c1ecf87..0000000
--- a/kokoro/windows/build_debug_2017.bat
+++ /dev/null
@@ -1,23 +0,0 @@
-:: Copyright (C) 2017 Google Inc.
-::
-:: Licensed under the Apache License, Version 2.0 (the "License");
-:: you may not use this file except in compliance with the License.
-:: You may obtain a copy of the License at
-::
-:: http://www.apache.org/licenses/LICENSE-2.0
-::
-:: Unless required by applicable law or agreed to in writing, software
-:: distributed under the License is distributed on an "AS IS" BASIS,
-:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-:: See the License for the specific language governing permissions and
-:: limitations under the License.
-::
-:: Windows Build Script.
-
-@echo on
-
-:: Find out the directory of the common build script.
-set SCRIPT_DIR=%~dp0
-
-:: Call with correct parameter
-call %SCRIPT_DIR%\build.bat Debug 2017
diff --git a/kokoro/windows/build_release_2017.bat b/kokoro/windows/build_release_2017.bat
deleted file mode 100644
index 4102eaa..0000000
--- a/kokoro/windows/build_release_2017.bat
+++ /dev/null
@@ -1,24 +0,0 @@
-:: Copyright (C) 2017 Google Inc.
-::
-:: Licensed under the Apache License, Version 2.0 (the "License");
-:: you may not use this file except in compliance with the License.
-:: You may obtain a copy of the License at
-::
-:: http://www.apache.org/licenses/LICENSE-2.0
-::
-:: Unless required by applicable law or agreed to in writing, software
-:: distributed under the License is distributed on an "AS IS" BASIS,
-:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-:: See the License for the specific language governing permissions and
-:: limitations under the License.
-::
-:: Windows Build Script.
-
-@echo on
-
-:: Find out the directory of the common build script.
-set SCRIPT_DIR=%~dp0
-
-:: Call with correct parameter
-call %SCRIPT_DIR%\build.bat RelWithDebInfo 2017
-
diff --git a/kokoro/windows/continuous_debug_2017.cfg b/kokoro/windows/continuous_debug_2017.cfg
deleted file mode 100644
index 34c3b06..0000000
--- a/kokoro/windows/continuous_debug_2017.cfg
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright (C) 2017 Google Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Continuous build configuration.
-build_file: "shaderc/kokoro/windows/build_debug_2017.bat"
-
-action {
- define_artifacts {
- regex: "install.zip"
- }
-}
diff --git a/kokoro/windows/continuous_release_2017.cfg b/kokoro/windows/continuous_release_2017.cfg
deleted file mode 100644
index b3249d4..0000000
--- a/kokoro/windows/continuous_release_2017.cfg
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright (C) 2017 Google Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Continuous build configuration.
-build_file: "shaderc/kokoro/windows/build_release_2017.bat"
-
-action {
- define_artifacts {
- regex: "install.zip"
- }
-}
diff --git a/kokoro/windows/presubmit_debug_2017.cfg b/kokoro/windows/presubmit_debug_2017.cfg
deleted file mode 100644
index 57168d3..0000000
--- a/kokoro/windows/presubmit_debug_2017.cfg
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (C) 2017 Google Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Presubmit build configuration.
-build_file: "shaderc/kokoro/windows/build_debug_2017.bat"
diff --git a/kokoro/windows/presubmit_release_2017.cfg b/kokoro/windows/presubmit_release_2017.cfg
deleted file mode 100644
index 16499fc..0000000
--- a/kokoro/windows/presubmit_release_2017.cfg
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (C) 2017 Google Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Presubmit build configuration.
-build_file: "shaderc/kokoro/windows/build_release_2017.bat"
diff --git a/libshaderc/CMakeLists.txt b/libshaderc/CMakeLists.txt
index 2cced9e..df9a88d 100644
--- a/libshaderc/CMakeLists.txt
+++ b/libshaderc/CMakeLists.txt
@@ -63,7 +63,7 @@
find_package(Threads)
set(SHADERC_LIBS
- glslang OSDependent OGLCompiler glslang ${CMAKE_THREAD_LIBS_INIT}
+ glslang ${CMAKE_THREAD_LIBS_INIT}
shaderc_util
SPIRV # from glslang
SPIRV-Tools
@@ -97,20 +97,7 @@
shaderc_combine_static_lib(shaderc_combined shaderc)
if(SHADERC_ENABLE_INSTALL)
- # Since shaderc_combined is defined as an imported library, we cannot use the
- # install() directive to install it. Install it like a normal file.
- get_target_property(generated_location shaderc_combined LOCATION)
- string(REGEX MATCH "Visual Studio .*" vs_generator "${CMAKE_GENERATOR}")
- if (NOT "${vs_generator}" STREQUAL "")
- # With Visual Studio generators, the LOCATION property is not properly
- # expanded according to the current build configuration. We need to work
- # around this problem by manually substitution.
- string(REPLACE "$(Configuration)" "\${CMAKE_INSTALL_CONFIG_NAME}"
- install_location "${generated_location}")
- install(FILES ${install_location} DESTINATION ${CMAKE_INSTALL_LIBDIR})
- else()
- install(FILES ${generated_location} DESTINATION ${CMAKE_INSTALL_LIBDIR})
- endif()
+ install(TARGETS shaderc_combined DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif(SHADERC_ENABLE_INSTALL)
shaderc_add_tests(
diff --git a/libshaderc/README.md b/libshaderc/README.md
index bf9d317..45636e8 100644
--- a/libshaderc/README.md
+++ b/libshaderc/README.md
@@ -7,8 +7,8 @@
There are two main shaderc libraries that are created during a CMake
compilation. The first is `libshaderc`, which is a static library
containing just the functionality exposed by libshaderc. It depends
-on other compilation targets `glslang`, `OSDependent`, `OGLCompiler`,
-`shaderc_util`, `SPIRV`, `HLSL`, `SPIRV-Tools`, and `SPIRV-Tools-opt`.
+on other compilation targets `glslang`, `shaderc_util`, `SPIRV`,
+`SPIRV-Tools`, and `SPIRV-Tools-opt`.
The other is `libshaderc_combined`, which is a static library containing
libshaderc and all of its dependencies.
@@ -38,12 +38,9 @@
counterparts should be linked in the order specified.
* `build/libshaderc/libshaderc.a`
* `build/third_party/glslang/glslang/glslang.a`
- * `build/third_party/glslang/glslang/OSDependent/{Platform}/libOSDependent.a`
- * `build/third_party/glslang/OGLCompilersDLL/libOGLCompiler.a`
* `build/third_party/glslang/libglslang.a`
* `build/shaderc_util/libshaderc_util.a`
* `build/third_party/glslang/SPIRV/libSPIRV.a`
- * `build/third_party/glslang/hlsl/libHLSL.a`
* `build/third_party/spirv-tools/libSPIRV-Tools-opt.a`
* `build/third_party/spirv-tools/libSPIRV-Tools.a`
diff --git a/libshaderc/include/shaderc/env.h b/libshaderc/include/shaderc/env.h
index 14b418d..3d32b2a 100644
--- a/libshaderc/include/shaderc/env.h
+++ b/libshaderc/include/shaderc/env.h
@@ -41,6 +41,7 @@
shaderc_env_version_vulkan_1_1 = ((1u << 22) | (1 << 12)),
shaderc_env_version_vulkan_1_2 = ((1u << 22) | (2 << 12)),
shaderc_env_version_vulkan_1_3 = ((1u << 22) | (3 << 12)),
+ shaderc_env_version_vulkan_1_4 = ((1u << 22) | (4 << 12)),
// For OpenGL, use the number from #version in shaders.
// TODO(dneto): Currently no difference between OpenGL 4.5 and 4.6.
// See glslang/Standalone/Standalone.cpp
diff --git a/libshaderc/include/shaderc/shaderc.h b/libshaderc/include/shaderc/shaderc.h
index 235f607..3a3e97d 100644
--- a/libshaderc/include/shaderc/shaderc.h
+++ b/libshaderc/include/shaderc/shaderc.h
@@ -489,6 +489,12 @@
SHADERC_EXPORT void shaderc_compile_options_set_hlsl_16bit_types(
shaderc_compile_options_t options, bool enable);
+// Enables or disables relaxed Vulkan rules.
+//
+// This allows most OpenGL shaders to compile under Vulkan semantics.
+SHADERC_EXPORT void shaderc_compile_options_set_vulkan_rules_relaxed(
+ shaderc_compile_options_t options, bool enable);
+
// Sets whether the compiler should invert position.Y output in vertex shader.
SHADERC_EXPORT void shaderc_compile_options_set_invert_y(
shaderc_compile_options_t options, bool enable);
diff --git a/libshaderc/include/shaderc/shaderc.hpp b/libshaderc/include/shaderc/shaderc.hpp
index bc057c1..a4e93ff 100644
--- a/libshaderc/include/shaderc/shaderc.hpp
+++ b/libshaderc/include/shaderc/shaderc.hpp
@@ -353,12 +353,19 @@
shaderc_compile_options_set_hlsl_16bit_types(options_, enable);
}
+ // Enables or disables relaxed Vulkan rules.
+ //
+ // This allows most OpenGL shaders to compile under Vulkan semantics.
+ void SetVulkanRulesRelaxed(bool enable) {
+ shaderc_compile_options_set_vulkan_rules_relaxed(options_, enable);
+ }
+
// Sets whether the compiler should invert position.Y output in vertex shader.
void SetInvertY(bool enable) {
shaderc_compile_options_set_invert_y(options_, enable);
}
- // Sets whether the compiler should generates code for max an min which,
+ // Sets whether the compiler should generate code for max and min which,
// if given a NaN operand, will return the other operand. Similarly, the
// clamp builtin will favour the non-NaN operands, as if clamp were
// implemented as a composition of max and min.
diff --git a/libshaderc/src/shaderc.cc b/libshaderc/src/shaderc.cc
index 3223820..821f31f 100644
--- a/libshaderc/src/shaderc.cc
+++ b/libshaderc/src/shaderc.cc
@@ -110,7 +110,7 @@
public:
explicit StageDeducer(
shaderc_shader_kind kind = shaderc_glsl_infer_from_source)
- : kind_(kind), error_(false){}
+ : kind_(kind), error_(false) {}
// The method that underlying glslang will call to determine the shader stage
// to be used in current compilation. It is called only when there is neither
// forced shader kind (or say stage, in the view of glslang), nor #pragma
@@ -203,9 +203,9 @@
void* user_data)
: resolver_(resolver),
result_releaser_(result_releaser),
- user_data_(user_data){}
+ user_data_(user_data) {}
InternalFileIncluder()
- : resolver_(nullptr), result_releaser_(nullptr), user_data_(nullptr){}
+ : resolver_(nullptr), result_releaser_(nullptr), user_data_(nullptr) {}
private:
// Check the validity of the callbacks.
@@ -311,6 +311,10 @@
version_number) {
return Compiler::TargetEnvVersion::Vulkan_1_3;
}
+ if (static_cast<uint32_t>(Compiler::TargetEnvVersion::Vulkan_1_4) ==
+ version_number) {
+ return Compiler::TargetEnvVersion::Vulkan_1_4;
+ }
if (static_cast<uint32_t>(Compiler::TargetEnvVersion::OpenGL_4_5) ==
version_number) {
return Compiler::TargetEnvVersion::OpenGL_4_5;
@@ -564,8 +568,13 @@
options->compiler.EnableHlsl16BitTypes(enable);
}
-void shaderc_compile_options_set_invert_y(
+void shaderc_compile_options_set_vulkan_rules_relaxed(
shaderc_compile_options_t options, bool enable) {
+ options->compiler.SetVulkanRulesRelaxed(enable);
+}
+
+void shaderc_compile_options_set_invert_y(shaderc_compile_options_t options,
+ bool enable) {
options->compiler.EnableInvertY(enable);
}
@@ -582,9 +591,7 @@
return compiler;
}
-void shaderc_compiler_release(shaderc_compiler_t compiler) {
- delete compiler;
-}
+void shaderc_compiler_release(shaderc_compiler_t compiler) { delete compiler; }
namespace {
shaderc_compilation_result_t CompileToSpecifiedOutputType(
@@ -624,7 +631,8 @@
std::tie(compilation_succeeded, compilation_output_data,
compilation_output_data_size_in_bytes) =
additional_options->compiler.Compile(
- source_string, forced_stage, input_file_name_str, entry_point_name,
+ source_string, forced_stage, input_file_name_str,
+ entry_point_name,
// stage_deducer has a flag: error_, which we need to check later.
// We need to make this a reference wrapper, so that std::function
// won't make a copy for this callable object.
@@ -636,9 +644,9 @@
std::tie(compilation_succeeded, compilation_output_data,
compilation_output_data_size_in_bytes) =
shaderc_util::Compiler().Compile(
- source_string, forced_stage, input_file_name_str, entry_point_name,
- std::ref(stage_deducer), includer, output_type, &errors,
- &total_warnings, &total_errors);
+ source_string, forced_stage, input_file_name_str,
+ entry_point_name, std::ref(stage_deducer), includer, output_type,
+ &errors, &total_warnings, &total_errors);
}
result->messages = errors.str();
diff --git a/libshaderc/src/shaderc_cpp_test.cc b/libshaderc/src/shaderc_cpp_test.cc
index 0f1f37f..401d5b9 100644
--- a/libshaderc/src/shaderc_cpp_test.cc
+++ b/libshaderc/src/shaderc_cpp_test.cc
@@ -103,12 +103,12 @@
// Compiles a shader, asserts compilation success, and returns the warning
// messages.
// The input file name is set to "shader" by default.
- std::string CompilationWarnings(
- const std::string& shader, shaderc_shader_kind kind,
- // This could default to options_, but that can
- // be easily confused with a no-options-provided
- // case:
- const CompileOptions& options) {
+ std::string CompilationWarnings(const std::string& shader,
+ shaderc_shader_kind kind,
+ // This could default to options_, but that
+ // can be easily confused with a
+ // no-options-provided case:
+ const CompileOptions& options) {
const auto compilation_result =
compiler_.CompileGlslToSpv(shader, kind, "shader", options);
EXPECT_TRUE(CompilationResultIsSuccess(compilation_result)) << kind << '\n'
@@ -458,9 +458,8 @@
TEST_F(CppInterface, GenerateDebugInfoBinary) {
options_.SetGenerateDebugInfo();
- const std::string binary_output =
- CompilationOutput(kMinimalDebugInfoShader,
- shaderc_glsl_vertex_shader, options_);
+ const std::string binary_output = CompilationOutput(
+ kMinimalDebugInfoShader, shaderc_glsl_vertex_shader, options_);
// The binary output should contain the name of the vector (debug_info_sample)
// null-terminated, as well as the whole original source.
std::string vector_name("debug_info_sample");
@@ -472,9 +471,8 @@
TEST_F(CppInterface, GenerateDebugInfoBinaryClonedOptions) {
options_.SetGenerateDebugInfo();
CompileOptions cloned_options(options_);
- const std::string binary_output =
- CompilationOutput(kMinimalDebugInfoShader,
- shaderc_glsl_vertex_shader, cloned_options);
+ const std::string binary_output = CompilationOutput(
+ kMinimalDebugInfoShader, shaderc_glsl_vertex_shader, cloned_options);
// The binary output should contain the name of the vector (debug_info_sample)
// null-terminated, as well as the whole original source.
std::string vector_name("debug_info_sample");
@@ -846,39 +844,39 @@
}
INSTANTIATE_TEST_SUITE_P(CppInterface, IncluderTests,
- testing::ValuesIn(std::vector<IncluderTestCase>{
- IncluderTestCase(
- // Fake file system.
- {
- {"root",
- "#version 150\n"
- "void foo() {}\n"
- "#include \"path/to/file_1\"\n"},
- {"path/to/file_1", "content of file_1\n"},
- },
- // Expected output.
- "#line 0 \"path/to/file_1\"\n"
- " content of file_1\n"
- "#line 3"),
- IncluderTestCase(
- // Fake file system.
- {{"root",
- "#version 150\n"
- "void foo() {}\n"
- "#include \"path/to/file_1\"\n"},
- {"path/to/file_1",
- "#include \"path/to/file_2\"\n"
- "content of file_1\n"},
- {"path/to/file_2", "content of file_2\n"}},
- // Expected output.
- "#line 0 \"path/to/file_1\"\n"
- "#line 0 \"path/to/file_2\"\n"
- " content of file_2\n"
- "#line 1 \"path/to/file_1\"\n"
- " content of file_1\n"
- "#line 3"),
+ testing::ValuesIn(std::vector<IncluderTestCase>{
+ IncluderTestCase(
+ // Fake file system.
+ {
+ {"root",
+ "#version 150\n"
+ "void foo() {}\n"
+ "#include \"path/to/file_1\"\n"},
+ {"path/to/file_1", "content of file_1\n"},
+ },
+ // Expected output.
+ "#line 0 \"path/to/file_1\"\n"
+ " content of file_1\n"
+ "#line 3"),
+ IncluderTestCase(
+ // Fake file system.
+ {{"root",
+ "#version 150\n"
+ "void foo() {}\n"
+ "#include \"path/to/file_1\"\n"},
+ {"path/to/file_1",
+ "#include \"path/to/file_2\"\n"
+ "content of file_1\n"},
+ {"path/to/file_2", "content of file_2\n"}},
+ // Expected output.
+ "#line 0 \"path/to/file_1\"\n"
+ "#line 0 \"path/to/file_2\"\n"
+ " content of file_2\n"
+ "#line 1 \"path/to/file_1\"\n"
+ " content of file_1\n"
+ "#line 3"),
- }));
+ }));
TEST_F(CppInterface, WarningsOnLine) {
// By default the compiler will emit a warning on line 2 complaining
@@ -1077,6 +1075,7 @@
shaderc_glsl_compute_shader, options_));
}
+// Simple Vulkan 1.1 tests
TEST_F(CppInterface,
TargetEnvCompileOptionsVulkan1_1EnvVulkan1_0ShaderSucceeds) {
options_.SetTargetEnvironment(shaderc_target_env_vulkan,
@@ -1093,6 +1092,59 @@
shaderc_glsl_compute_shader, options_));
}
+// Simple Vulkan 1.2 tests
+TEST_F(CppInterface,
+ TargetEnvCompileOptionsVulkan1_2EnvVulkan1_0ShaderSucceeds) {
+ options_.SetTargetEnvironment(shaderc_target_env_vulkan,
+ shaderc_env_version_vulkan_1_2);
+ EXPECT_TRUE(CompilationSuccess(BarrierComputeShader(),
+ shaderc_glsl_compute_shader, options_));
+}
+
+TEST_F(CppInterface,
+ TargetEnvCompileOptionsVulkan1_2EnvVulkan1_1ShaderSucceeds) {
+ options_.SetTargetEnvironment(shaderc_target_env_vulkan,
+ shaderc_env_version_vulkan_1_2);
+ EXPECT_TRUE(CompilationSuccess(SubgroupBarrierComputeShader(),
+ shaderc_glsl_compute_shader, options_));
+}
+
+// Simple Vulkan 1.3 tests
+TEST_F(CppInterface,
+ TargetEnvCompileOptionsVulkan1_3EnvVulkan1_0ShaderSucceeds) {
+ options_.SetTargetEnvironment(shaderc_target_env_vulkan,
+ shaderc_env_version_vulkan_1_3);
+ EXPECT_TRUE(CompilationSuccess(BarrierComputeShader(),
+ shaderc_glsl_compute_shader, options_));
+}
+
+TEST_F(CppInterface,
+ TargetEnvCompileOptionsVulkan1_3EnvVulkan1_1ShaderSucceeds) {
+ options_.SetTargetEnvironment(shaderc_target_env_vulkan,
+ shaderc_env_version_vulkan_1_3);
+ EXPECT_TRUE(CompilationSuccess(SubgroupBarrierComputeShader(),
+ shaderc_glsl_compute_shader, options_));
+}
+
+// Simple Vulkan 1.4 tests
+TEST_F(CppInterface,
+ TargetEnvCompileOptionsVulkan1_4EnvVulkan1_0ShaderSucceeds) {
+ options_.SetTargetEnvironment(shaderc_target_env_vulkan,
+ shaderc_env_version_vulkan_1_4);
+ EXPECT_TRUE(CompilationSuccess(BarrierComputeShader(),
+ shaderc_glsl_compute_shader, options_));
+}
+
+TEST_F(CppInterface,
+ TargetEnvCompileOptionsVulkan1_4EnvVulkan1_1ShaderSucceeds) {
+ options_.SetTargetEnvironment(shaderc_target_env_vulkan,
+ shaderc_env_version_vulkan_1_4);
+ EXPECT_TRUE(CompilationSuccess(SubgroupBarrierComputeShader(),
+ shaderc_glsl_compute_shader, options_));
+}
+
+// Other tests
+
TEST_F(CppInterface, BeginAndEndOnSpvCompilationResult) {
const SpvCompilationResult compilation_result = compiler_.CompileGlslToSpv(
kMinimalShader, shaderc_glsl_vertex_shader, "shader");
@@ -1432,8 +1484,9 @@
// source. https://github.com/KhronosGroup/glslang/issues/1616
options.SetAutoBindUniforms(true);
CompileOptions cloned_options(options);
- const std::string disassembly_text = AssemblyOutput(
- kHlslShaderWithCounterBuffer, shaderc_glsl_fragment_shader, cloned_options);
+ const std::string disassembly_text =
+ AssemblyOutput(kHlslShaderWithCounterBuffer, shaderc_glsl_fragment_shader,
+ cloned_options);
EXPECT_THAT(disassembly_text, HasSubstr("OpDecorateString"));
}
diff --git a/libshaderc/src/shaderc_test.cc b/libshaderc/src/shaderc_test.cc
index 5610b0b..43cc372 100644
--- a/libshaderc/src/shaderc_test.cc
+++ b/libshaderc/src/shaderc_test.cc
@@ -609,9 +609,8 @@
TEST_F(CompileStringWithOptionsTest, GenerateDebugInfoBinary) {
shaderc_compile_options_set_generate_debug_info(options_.get());
ASSERT_NE(nullptr, compiler_.get_compiler_handle());
- const std::string binary_output =
- CompilationOutput(kMinimalDebugInfoShader,
- shaderc_glsl_vertex_shader, options_.get());
+ const std::string binary_output = CompilationOutput(
+ kMinimalDebugInfoShader, shaderc_glsl_vertex_shader, options_.get());
// The binary output should contain the name of the vector (debug_info_sample)
// null-terminated, as well as the whole original source.
std::string vector_name("debug_info_sample");
@@ -626,8 +625,8 @@
shaderc_compile_options_clone(options_.get()));
ASSERT_NE(nullptr, compiler_.get_compiler_handle());
const std::string binary_output =
- CompilationOutput(kMinimalDebugInfoShader,
- shaderc_glsl_vertex_shader, cloned_options.get());
+ CompilationOutput(kMinimalDebugInfoShader, shaderc_glsl_vertex_shader,
+ cloned_options.get());
// The binary output should contain the name of the vector (debug_info_sample)
// null-terminated, as well as the whole original source.
std::string vector_name("debug_info_sample");
@@ -984,39 +983,39 @@
}
INSTANTIATE_TEST_SUITE_P(CompileStringTest, IncluderTests,
- testing::ValuesIn(std::vector<IncluderTestCase>{
- IncluderTestCase(
- // Fake file system.
- {
- {"root",
- "#version 150\n"
- "void foo() {}\n"
- "#include \"path/to/file_1\"\n"},
- {"path/to/file_1", "content of file_1\n"},
- },
- // Expected output.
- "#line 0 \"path/to/file_1\"\n"
- " content of file_1\n"
- "#line 3"),
- IncluderTestCase(
- // Fake file system.
- {{"root",
- "#version 150\n"
- "void foo() {}\n"
- "#include \"path/to/file_1\"\n"},
- {"path/to/file_1",
- "#include \"path/to/file_2\"\n"
- "content of file_1\n"},
- {"path/to/file_2", "content of file_2\n"}},
- // Expected output.
- "#line 0 \"path/to/file_1\"\n"
- "#line 0 \"path/to/file_2\"\n"
- " content of file_2\n"
- "#line 1 \"path/to/file_1\"\n"
- " content of file_1\n"
- "#line 3"),
+ testing::ValuesIn(std::vector<IncluderTestCase>{
+ IncluderTestCase(
+ // Fake file system.
+ {
+ {"root",
+ "#version 150\n"
+ "void foo() {}\n"
+ "#include \"path/to/file_1\"\n"},
+ {"path/to/file_1", "content of file_1\n"},
+ },
+ // Expected output.
+ "#line 0 \"path/to/file_1\"\n"
+ " content of file_1\n"
+ "#line 3"),
+ IncluderTestCase(
+ // Fake file system.
+ {{"root",
+ "#version 150\n"
+ "void foo() {}\n"
+ "#include \"path/to/file_1\"\n"},
+ {"path/to/file_1",
+ "#include \"path/to/file_2\"\n"
+ "content of file_1\n"},
+ {"path/to/file_2", "content of file_2\n"}},
+ // Expected output.
+ "#line 0 \"path/to/file_1\"\n"
+ "#line 0 \"path/to/file_2\"\n"
+ " content of file_2\n"
+ "#line 1 \"path/to/file_1\"\n"
+ " content of file_1\n"
+ "#line 3"),
- }));
+ }));
TEST_F(CompileStringWithOptionsTest, WarningsOnLine) {
// Some versions of Glslang will return an error, some will return just
@@ -1225,6 +1224,63 @@
shaderc_glsl_compute_shader, options_.get()));
}
+// Simple Vulkan 1.2 tests
+TEST_F(CompileStringWithOptionsTest,
+ TargetEnvRespectedWhenCompilingVulkan1_0ShaderToVulkan1_2Succeeds) {
+ shaderc_compile_options_set_target_env(options_.get(),
+ shaderc_target_env_vulkan,
+ shaderc_env_version_vulkan_1_2);
+ EXPECT_TRUE(CompilesToValidSpv(compiler_, kGlslShaderComputeBarrier,
+ shaderc_glsl_compute_shader, options_.get()));
+}
+
+TEST_F(CompileStringWithOptionsTest,
+ TargetEnvRespectedWhenCompilingVulkan1_1ShaderToVulkan1_2Succeeds) {
+ shaderc_compile_options_set_target_env(options_.get(),
+ shaderc_target_env_vulkan,
+ shaderc_env_version_vulkan_1_2);
+ EXPECT_TRUE(CompilesToValidSpv(compiler_, kGlslShaderComputeSubgroupBarrier,
+ shaderc_glsl_compute_shader, options_.get()));
+}
+
+// Simple Vulkan 1.3 tests
+TEST_F(CompileStringWithOptionsTest,
+ TargetEnvRespectedWhenCompilingVulkan1_0ShaderToVulkan1_3Succeeds) {
+ shaderc_compile_options_set_target_env(options_.get(),
+ shaderc_target_env_vulkan,
+ shaderc_env_version_vulkan_1_3);
+ EXPECT_TRUE(CompilesToValidSpv(compiler_, kGlslShaderComputeBarrier,
+ shaderc_glsl_compute_shader, options_.get()));
+}
+
+TEST_F(CompileStringWithOptionsTest,
+ TargetEnvRespectedWhenCompilingVulkan1_1ShaderToVulkan1_3Succeeds) {
+ shaderc_compile_options_set_target_env(options_.get(),
+ shaderc_target_env_vulkan,
+ shaderc_env_version_vulkan_1_3);
+ EXPECT_TRUE(CompilesToValidSpv(compiler_, kGlslShaderComputeSubgroupBarrier,
+ shaderc_glsl_compute_shader, options_.get()));
+}
+
+// Simple Vulkan 1.4 tests
+TEST_F(CompileStringWithOptionsTest,
+ TargetEnvRespectedWhenCompilingVulkan1_0ShaderToVulkan1_4Succeeds) {
+ shaderc_compile_options_set_target_env(options_.get(),
+ shaderc_target_env_vulkan,
+ shaderc_env_version_vulkan_1_4);
+ EXPECT_TRUE(CompilesToValidSpv(compiler_, kGlslShaderComputeBarrier,
+ shaderc_glsl_compute_shader, options_.get()));
+}
+
+TEST_F(CompileStringWithOptionsTest,
+ TargetEnvRespectedWhenCompilingVulkan1_1ShaderToVulkan1_4Succeeds) {
+ shaderc_compile_options_set_target_env(options_.get(),
+ shaderc_target_env_vulkan,
+ shaderc_env_version_vulkan_1_4);
+ EXPECT_TRUE(CompilesToValidSpv(compiler_, kGlslShaderComputeSubgroupBarrier,
+ shaderc_glsl_compute_shader, options_.get()));
+}
+
// task shader
TEST_F(CompileStringWithOptionsTest,
TargetEnvRespectedWhenCompilingVulkan1_0TaskShaderToVulkan1_0Succeeds) {
diff --git a/libshaderc_util/Android.mk b/libshaderc_util/Android.mk
index 9642e25..78a2efe 100644
--- a/libshaderc_util/Android.mk
+++ b/libshaderc_util/Android.mk
@@ -27,6 +27,6 @@
src/shader_stage.cc \
src/spirv_tools_wrapper.cc \
src/version_profile.cc
-LOCAL_STATIC_LIBRARIES:=SPIRV SPIRV-Tools-opt
+LOCAL_STATIC_LIBRARIES:=SPIRV SPIRV-Tools-opt glslang
LOCAL_C_INCLUDES:=$(LOCAL_PATH)/include
include $(BUILD_STATIC_LIBRARY)
diff --git a/libshaderc_util/CMakeLists.txt b/libshaderc_util/CMakeLists.txt
index 99ce3c4..69ba519 100644
--- a/libshaderc_util/CMakeLists.txt
+++ b/libshaderc_util/CMakeLists.txt
@@ -46,7 +46,7 @@
find_package(Threads)
target_link_libraries(shaderc_util PRIVATE
- glslang OSDependent OGLCompiler HLSL glslang SPIRV
+ glslang SPIRV
SPIRV-Tools-opt ${CMAKE_THREAD_LIBS_INIT})
shaderc_add_tests(
diff --git a/libshaderc_util/include/libshaderc_util/compiler.h b/libshaderc_util/include/libshaderc_util/compiler.h
index ffd7c24..09dd31e 100644
--- a/libshaderc_util/include/libshaderc_util/compiler.h
+++ b/libshaderc_util/include/libshaderc_util/compiler.h
@@ -24,10 +24,9 @@
#include <unordered_map>
#include <utility>
-#include "glslang/Public/ShaderLang.h"
-
#include "counting_includer.h"
#include "file_finder.h"
+#include "glslang/Public/ShaderLang.h"
#include "mutex.h"
#include "resources.h"
#include "string_piece.h"
@@ -85,7 +84,8 @@
Vulkan_1_0 = ((1 << 22)), // Vulkan 1.0
Vulkan_1_1 = ((1 << 22) | (1 << 12)), // Vulkan 1.1
Vulkan_1_2 = ((1 << 22) | (2 << 12)), // Vulkan 1.2
- Vulkan_1_3 = ((1 << 22) | (3 << 12)), // Vulkan 1.2
+ Vulkan_1_3 = ((1 << 22) | (3 << 12)), // Vulkan 1.3
+ Vulkan_1_4 = ((1 << 22) | (4 << 12)), // Vulkan 1.4
// For OpenGL, use the numbering from #version in shaders.
OpenGL_4_5 = 450,
};
@@ -233,6 +233,11 @@
// Enables or disables HLSL 16-bit types.
void EnableHlsl16BitTypes(bool enable);
+ // Enables or disables relaxed Vulkan rules.
+ //
+ // This allows most OpenGL shaders to compile under Vulkan semantics.
+ void SetVulkanRulesRelaxed(bool enable);
+
// Enables or disables invert position.Y output in vertex shader.
void EnableInvertY(bool enable);
@@ -292,8 +297,8 @@
}
// Sets the lowest binding number used when automatically assigning bindings
- // for uniform resources of the given type, for all shader stages. The default
- // base is zero.
+ // for uniform resources of the given type, for all shader stages. The
+ // default base is zero.
void SetAutoBindingBase(UniformKind kind, uint32_t base) {
for (auto stage : stages()) {
SetAutoBindingBaseForStage(stage, kind, base);
@@ -338,8 +343,8 @@
// shader stage. For example,
// SetHlslRegisterSetAndBinding(Stage::Fragment, "t1", "4", "5")
// means register "t1" in a fragment shader should map to binding 5 in set 4.
- // (Glslang wants this data as strings, not ints or enums.) The string data is
- // copied.
+ // (Glslang wants this data as strings, not ints or enums.) The string data
+ // is copied.
void SetHlslRegisterSetAndBindingForStage(Stage stage, const std::string& reg,
const std::string& set,
const std::string& binding) {
@@ -388,7 +393,8 @@
const string_piece& error_tag)>&
stage_callback,
CountingIncluder& includer, OutputType output_type,
- std::ostream* error_stream, size_t* total_warnings, size_t* total_errors) const;
+ std::ostream* error_stream, size_t* total_warnings,
+ size_t* total_errors) const;
static EShMessages GetDefaultRules() {
return static_cast<EShMessages>(EShMsgSpvRules | EShMsgVulkanRules |
@@ -516,9 +522,9 @@
// and convert image variables to combined image-sampler variables.
bool auto_combined_image_sampler_;
- // The base binding number per uniform type, per stage, used when automatically
- // binding uniforms that don't hzve explicit bindings in the shader source.
- // The default is zero.
+ // The base binding number per uniform type, per stage, used when
+ // automatically binding uniforms that don't hzve explicit bindings in the
+ // shader source. The default is zero.
uint32_t auto_binding_base_[kNumStages][kNumUniformKinds];
// True if the compiler should automatically map uniforms that don't
@@ -539,12 +545,17 @@
// source language is HLSL.
bool hlsl_legalization_enabled_;
- // True if the compiler should support extension SPV_GOOGLE_hlsl_functionality1.
+ // True if the compiler should support extension
+ // SPV_GOOGLE_hlsl_functionality1.
bool hlsl_functionality1_enabled_;
// True if the compiler should support 16-bit HLSL types.
bool hlsl_16bit_types_enabled_;
+ // True if the compiler should relax Vulkan rules to allow OGL shaders to
+ // compile.
+ bool vulkan_rules_relaxed_ = false;
+
// True if the compiler should invert position.Y output in vertex shader.
bool invert_y_enabled_;
diff --git a/libshaderc_util/src/compiler.cc b/libshaderc_util/src/compiler.cc
index 525cbc5..9bf9a43 100644
--- a/libshaderc_util/src/compiler.cc
+++ b/libshaderc_util/src/compiler.cc
@@ -178,7 +178,8 @@
const string_piece& error_tag)>&
stage_callback,
CountingIncluder& includer, OutputType output_type,
- std::ostream* error_stream, size_t* total_warnings, size_t* total_errors) const {
+ std::ostream* error_stream, size_t* total_warnings,
+ size_t* total_errors) const {
// Compilation results to be returned:
// Initialize the result tuple as a failed compilation. In error cases, we
// should return result_tuple directly without setting its members.
@@ -192,8 +193,8 @@
// Check target environment.
const auto target_client_info = GetGlslangClientInfo(
- error_tag, target_env_, target_env_version_,
- target_spirv_version_, target_spirv_version_is_forced_);
+ error_tag, target_env_, target_env_version_, target_spirv_version_,
+ target_spirv_version_is_forced_);
if (!target_client_info.error.empty()) {
*error_stream << target_client_info.error;
*total_warnings = 0;
@@ -272,7 +273,8 @@
shader.setEntryPoint(entry_point_name);
shader.setAutoMapBindings(auto_bind_uniforms_);
if (auto_combined_image_sampler_) {
- shader.setTextureSamplerTransformMode(EShTexSampTransUpgradeTextureRemoveSampler);
+ shader.setTextureSamplerTransformMode(
+ EShTexSampTransUpgradeTextureRemoveSampler);
}
shader.setAutoMapLocations(auto_map_locations_);
const auto& bases = auto_binding_base_[static_cast<int>(used_shader_stage)];
@@ -294,6 +296,23 @@
if (hlsl_functionality1_enabled_) {
shader.setEnvTargetHlslFunctionality1();
}
+ if (vulkan_rules_relaxed_) {
+ glslang::EShSource language = glslang::EShSourceNone;
+ switch (source_language_) {
+ case SourceLanguage::GLSL:
+ language = glslang::EShSourceGlsl;
+ break;
+ case SourceLanguage::HLSL:
+ language = glslang::EShSourceHlsl;
+ break;
+ }
+ // This option will only be used if the Vulkan client is used.
+ // If new versions of GL_KHR_vulkan_glsl come out, it would make sense to
+ // let callers specify which version to use. For now, just use 100.
+ shader.setEnvInput(language, used_shader_stage, glslang::EShClientVulkan,
+ 100);
+ shader.setEnvInputVulkanRulesRelaxed();
+ }
shader.setInvertY(invert_y_enabled_);
shader.setNanMinMaxClamp(nan_clamp_);
@@ -452,6 +471,10 @@
hlsl_functionality1_enabled_ = enable;
}
+void Compiler::SetVulkanRulesRelaxed(bool enable) {
+ vulkan_rules_relaxed_ = enable;
+}
+
void Compiler::EnableHlsl16BitTypes(bool enable) {
hlsl_16bit_types_enabled_ = enable;
}
@@ -474,8 +497,8 @@
&string_names, 1);
shader.setPreamble(shader_preamble.data());
auto target_client_info = GetGlslangClientInfo(
- error_tag, target_env_, target_env_version_,
- target_spirv_version_, target_spirv_version_is_forced_);
+ error_tag, target_env_, target_env_version_, target_spirv_version_,
+ target_spirv_version_is_forced_);
if (!target_client_info.error.empty()) {
return std::make_tuple(false, "", target_client_info.error);
}
@@ -735,6 +758,9 @@
} else if (env_version == Compiler::TargetEnvVersion::Vulkan_1_3) {
result.client_version = glslang::EShTargetVulkan_1_3;
result.target_language_version = glslang::EShTargetSpv_1_6;
+ } else if (env_version == Compiler::TargetEnvVersion::Vulkan_1_4) {
+ result.client_version = glslang::EShTargetVulkan_1_4;
+ result.target_language_version = glslang::EShTargetSpv_1_6;
} else {
errs << "error:" << error_tag << ": Invalid target client version "
<< static_cast<uint32_t>(env_version) << " for Vulkan environment "
diff --git a/libshaderc_util/src/compiler_test.cc b/libshaderc_util/src/compiler_test.cc
index a0a964d..b580d0e 100644
--- a/libshaderc_util/src/compiler_test.cc
+++ b/libshaderc_util/src/compiler_test.cc
@@ -14,10 +14,10 @@
#include "libshaderc_util/compiler.h"
-#include <sstream>
-
#include <gmock/gmock.h>
+#include <sstream>
+
#include "death_test.h"
#include "libshaderc_util/counting_includer.h"
#include "libshaderc_util/spirv_tools_wrapper.h"
@@ -106,6 +106,18 @@
gl_Position = my_mat * my_vec;
})";
+// A GLSL fragment shader with the location defined for its non-opaque uniform
+// variable.
+const char kGlslFragShaderOpaqueUniforms[] =
+ R"(#version 320 es
+ precision lowp float;
+
+ layout(location = 0) out vec4 oColor;
+ layout(location = 0) uniform float a;
+ void main(void) {
+ oColor = vec4(1.0, 0.0, 0.0, a);
+ })";
+
// A GLSL vertex shader without the location defined for its non-opaque uniform
// variable.
const char kGlslVertShaderNoExplicitLocation[] =
@@ -341,16 +353,18 @@
compiler_.SetTargetEnv(Compiler::TargetEnv::Vulkan,
static_cast<Compiler::TargetEnvVersion>(123));
EXPECT_FALSE(SimpleCompilationSucceeds(kVulkanVertexShader, EShLangVertex));
- EXPECT_THAT(errors_,
- HasSubstr("Invalid target client version 123 for Vulkan environment 0"));
+ EXPECT_THAT(
+ errors_,
+ HasSubstr("Invalid target client version 123 for Vulkan environment 0"));
}
TEST_F(CompilerTest, BadTargetEnvOpenGLVersionFails) {
compiler_.SetTargetEnv(Compiler::TargetEnv::OpenGL,
static_cast<Compiler::TargetEnvVersion>(123));
EXPECT_FALSE(SimpleCompilationSucceeds(kVulkanVertexShader, EShLangVertex));
- EXPECT_THAT(errors_,
- HasSubstr("Invalid target client version 123 for OpenGL environment 1"));
+ EXPECT_THAT(
+ errors_,
+ HasSubstr("Invalid target client version 123 for OpenGL environment 1"));
}
TEST_F(CompilerTest, SpirvTargetVersion1_0Succeeds) {
@@ -523,18 +537,17 @@
#define CASE(LIMIT, DEFAULT, NEW) \
{ Compiler::Limit::LIMIT, DEFAULT, NEW }
-INSTANTIATE_TEST_SUITE_P(
- CompilerTest, LimitTest,
- // See resources.cc for the defaults.
- testing::ValuesIn(std::vector<SetLimitCase>{
- // clang-format off
+INSTANTIATE_TEST_SUITE_P(CompilerTest, LimitTest,
+ // See resources.cc for the defaults.
+ testing::ValuesIn(std::vector<SetLimitCase>{
+ // clang-format off
// This is just a sampling of the possible values.
CASE(MaxLights, 8, 99),
CASE(MaxClipPlanes, 6, 10929),
CASE(MaxTessControlAtomicCounters, 0, 72),
CASE(MaxSamples, 4, 8),
- // clang-format on
- }));
+ // clang-format on
+ }));
#undef CASE
// Returns a fragment shader accessing a texture with the given
@@ -807,9 +820,20 @@
EXPECT_THAT(disassembly,
HasSubstr("OpExtension \"SPV_GOOGLE_hlsl_functionality1\""))
<< disassembly;
+ EXPECT_THAT(disassembly, HasSubstr("OpDecorateString %_entryPointOutput "
+ "UserSemantic \"SV_TARGET0\""))
+ << disassembly;
+}
+
+TEST_F(CompilerTest, RelaxedVulkanRulesEnabled) {
+ compiler_.SetSourceLanguage(Compiler::SourceLanguage::GLSL);
+ compiler_.SetAutoBindUniforms(true); // Uniform variable needs a binding
+ compiler_.SetVulkanRulesRelaxed(true);
+ const auto words =
+ SimpleCompilationBinary(kGlslFragShaderOpaqueUniforms, EShLangFragment);
+ const auto disassembly = Disassemble(words);
EXPECT_THAT(disassembly,
- HasSubstr("OpDecorateString %_entryPointOutput "
- "UserSemantic \"SV_TARGET0\""))
+ HasSubstr("OpMemberName %gl_DefaultUniformBlock 0 \"a\""))
<< disassembly;
}
@@ -902,6 +926,8 @@
// Unforced SPIR-V version. Success cases.
{CASE_VK(1_0, 1_4), false, GCASE_VK("", 1_0, 1_0)},
{CASE_VK(1_1, 1_4), false, GCASE_VK("", 1_1, 1_3)},
+ {CASE_VK(1_3, 1_6), false, GCASE_VK("", 1_3, 1_6)},
+ {CASE_VK(1_4, 1_6), false, GCASE_VK("", 1_4, 1_6)},
{CASE_GL(4_5, 1_4), false, GCASE_GL("", 450, 1_0)},
}));
@@ -917,6 +943,12 @@
{CASE_VK(1_1, 1_1), true, GCASE_VK("", 1_1, 1_1)},
{CASE_VK(1_1, 1_2), true, GCASE_VK("", 1_1, 1_2)},
{CASE_VK(1_1, 1_3), true, GCASE_VK("", 1_1, 1_3)},
+ {CASE_VK(1_3, 1_4), true, GCASE_VK("", 1_3, 1_4)},
+ {CASE_VK(1_3, 1_5), true, GCASE_VK("", 1_3, 1_5)},
+ {CASE_VK(1_3, 1_6), true, GCASE_VK("", 1_3, 1_6)},
+ {CASE_VK(1_4, 1_4), true, GCASE_VK("", 1_4, 1_4)},
+ {CASE_VK(1_4, 1_5), true, GCASE_VK("", 1_4, 1_5)},
+ {CASE_VK(1_4, 1_6), true, GCASE_VK("", 1_4, 1_6)},
{CASE_GL(4_5, 1_0), true, GCASE_GL("", 450, 1_0)},
{CASE_GL(4_5, 1_1), true, GCASE_GL("", 450, 1_1)},
{CASE_GL(4_5, 1_2), true, GCASE_GL("", 450, 1_2)},
diff --git a/libshaderc_util/src/spirv_tools_wrapper.cc b/libshaderc_util/src/spirv_tools_wrapper.cc
index b4f57f8..49426d0 100644
--- a/libshaderc_util/src/spirv_tools_wrapper.cc
+++ b/libshaderc_util/src/spirv_tools_wrapper.cc
@@ -40,6 +40,8 @@
return SPV_ENV_VULKAN_1_2;
case Compiler::TargetEnvVersion::Vulkan_1_3:
return SPV_ENV_VULKAN_1_3;
+ case Compiler::TargetEnvVersion::Vulkan_1_4:
+ return SPV_ENV_VULKAN_1_4;
default:
break;
}
@@ -126,6 +128,11 @@
val_opts.SetRelaxLogicalPointer(true);
// This uses relaxed rules for pre-legalized HLSL.
val_opts.SetBeforeHlslLegalization(true);
+ // Don't use friendly names when printing validation errors.
+ // It incurs a high startup cost whether or not there is an
+ // error. Validation failures are compiler bugs, and so they
+ // should be rare anyway.
+ val_opts.SetFriendlyNames(false);
// Set additional optimizer options.
optimizer_options.set_validator_options(val_opts);
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index a01f31e..d44f62a 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -83,6 +83,11 @@
if (NOT TARGET glslang)
if (IS_DIRECTORY ${SHADERC_GLSLANG_DIR})
+ if (SHADERC_ENABLE_TESTS)
+ # Glslang tests are off by default. Turn them on if testing Shaderc.
+ set(GLSLANG_TESTS ON)
+ endif()
+ set(GLSLANG_ENABLE_INSTALL $<NOT:${SKIP_GLSLANG_INSTALL}>)
add_subdirectory(${SHADERC_GLSLANG_DIR} glslang)
endif()
if (NOT TARGET glslang)
diff --git a/utils/add_copyright.py b/utils/add_copyright.py
index ab3c5f1..7ea0897 100755
--- a/utils/add_copyright.py
+++ b/utils/add_copyright.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright 2015 The Shaderc Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/utils/remove-file-by-suffix.py b/utils/remove-file-by-suffix.py
index 39af161..ce7c658 100755
--- a/utils/remove-file-by-suffix.py
+++ b/utils/remove-file-by-suffix.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright 2015 The Shaderc Authors. All rights reserved.
#
diff --git a/utils/update_build_version.py b/utils/update_build_version.py
index 11ee53e..b7ce5b8 100755
--- a/utils/update_build_version.py
+++ b/utils/update_build_version.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright 2016 The Shaderc Authors. All rights reserved.
#