Merge remote-tracking branch 'origin/upstream/main' into main
Change-Id: I31d1d40472a29d98aa3ce8de00676ca0992d7ec3
diff --git a/Android.mk b/Android.mk
index e1ad18a..147d959 100644
--- a/Android.mk
+++ b/Android.mk
@@ -52,8 +52,8 @@
$(1)/libshaderc_combined.a: $(addprefix $(1)/, $(ALL_LIBS)) $(1)/combine.ar
@echo "[$(TARGET_ARCH_ABI)] Combine: libshaderc_combined.a <= $(ALL_LIBS)"
- @cd $(1) && $(2)ar -M < combine.ar && cd $(ROOT_SHADERC_PATH)
- @$(2)objcopy --strip-debug $(1)/libshaderc_combined.a
+ @cd $(1) && $(TARGET_AR) -M < combine.ar && cd $(ROOT_SHADERC_PATH)
+ @$(TARGET_STRIP) --strip-debug $(1)/libshaderc_combined.a
$(NDK_APP_LIBS_OUT)/$(APP_STL)/$(TARGET_ARCH_ABI)/libshaderc.a: \
$(1)/libshaderc_combined.a
@@ -73,4 +73,4 @@
libshaderc_combined: $(SHADERC_HEADERS_IN_OUT_DIR)
-$(eval $(call gen_libshaderc,$(TARGET_OUT),$(TOOLCHAIN_PREFIX)))
+$(eval $(call gen_libshaderc,$(TARGET_OUT)))
diff --git a/CHANGES b/CHANGES
index d68c626..0110c41 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,36 @@
Revision history for Shaderc
+v2022.4-dev 2022-10-12
+ - Start v2202.4 development
+
+v2022.3 2022-10-12
+ - #1264: Implement defaults for SPV_EXT_mesh_shader builtins
+ - Update SPIRV-Tools to v2022.4
+
+v2022.2 2022-08-11
+ - Require CMake 3.14 or later
+ - Support 16bit types in HLSL, via glslc option -fhlsl-16bit-types
+ and associated library API methods. PR #1251
+ - Update glslc tests for newer Glslang debug output
+ - Update SPIRV-Tools v2022.3 plus one patch
+ - Update SPIRV-Headers
+
+v2022.1 2022-02-03
+ - Update DEPS to include two fixes on top of SPIRV-Tools v2022.1:
+ - Validator handles Nontemporal image operand
+ - Optimizer handles RayQueryKHR type
+
+v2022.0 2022-01-27
+ - Update to Glslang 11.8.0
+
+v2021.4 2022-01-27
+ - Support Vulkan 1.3
+ - Support targeting SPIR-V 1.6, which is the default for Vulkan 1.3
+ - Updated copyright check: Excludes Glslang generated files when
+ building in source tree
+ - Fix Android.mk rules for building libshaderc_combined, to adapt to more
+ recent NDKs that have removed the GNU binutils.
+
v2021.3 2021-11-11
- Add build switch to disable copyright check
- Update DEPS:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b55e1f0..3bf9d16 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,6 +13,12 @@
# limitations under the License.
cmake_minimum_required(VERSION 2.8.12)
+
+if (POLICY CMP00091)
+ # Enable MSVC Runtime Library Property
+ cmake_policy(SET CMP0091 NEW)
+endif()
+
project(shaderc)
enable_testing()
diff --git a/DEPS b/DEPS
index 710a86e..61e1b72 100644
--- a/DEPS
+++ b/DEPS
@@ -4,12 +4,12 @@
'google_git': 'https://github.com/google',
'khronos_git': 'https://github.com/KhronosGroup',
- 'effcee_revision' : '2ec8f8738118cc483b67c04a759fee53496c5659',
- 'glslang_revision': '600c5037baac82a80851d1fb95f3f09d34bb43e8',
- 'googletest_revision': '389cb68b87193358358ae87cc56d257fd0d80189',
- 're2_revision': '7107ebc4fbf7205151d8d2a57b2fc6e7853125d4',
- 'spirv_headers_revision': '814e728b30ddd0f4509233099a3ad96fd4318c07',
- 'spirv_tools_revision': 'ab8eb607750208066e2d57eff6a34dbaf05f5ada',
+ 'effcee_revision' : '35912e1b7778ec2ddcff7e7188177761539e59',
+ 'glslang_revision': '89db4e1caa273a057ea46deba709c6e50001b314',
+ 'googletest_revision': 'd9bb8412d60b993365abb53f00b6dad9b2c01b62',
+ 're2_revision': 'd2836d1b1c34c4e330a85a1006201db474bf2c8a',
+ 'spirv_headers_revision': '85a1ed200d50660786c1a88d9166e871123cce39',
+ 'spirv_tools_revision': 'eb0a36633d2acf4de82588504f951ad0f2cecacb',
}
deps = {
diff --git a/README.md b/README.md
index 3048618..0e3075b 100644
--- a/README.md
+++ b/README.md
@@ -96,7 +96,6 @@
git clone https://github.com/google/shaderc $SOURCE_DIR
cd $SOURCE_DIR
./utils/git-sync-deps
-cd $SOURCE_DIR/
```
**Note:** The [known-good](https://github.com/google/shaderc/tree/known-good)
@@ -163,7 +162,8 @@
For building, testing, and profiling Shaderc, the following tools should be
installed regardless of your OS:
-- [CMake](http://www.cmake.org/): for generating compilation targets.
+- [CMake](http://www.cmake.org/) 3.14 or later: for generating compilation targets.
+ - Shaderc is tested with cmake 3.17.2
- [Python 3](http://www.python.org/): for utility scripts and running the test suite.
On Linux, the following tools should be installed:
diff --git a/glslc/README.asciidoc b/glslc/README.asciidoc
index 2d64820..9b754b8 100644
--- a/glslc/README.asciidoc
+++ b/glslc/README.asciidoc
@@ -20,6 +20,7 @@
glslc [-c|-S|-E]
[-x ...] [-std=standard]
[ ... options for resource bindings ... ]
+ [-fhlsl-16bit-types]
[-fhlsl-offsets]
[-fhlsl-functionality1]
[-fentry-point=<name>]
@@ -237,7 +238,7 @@
* `opengl4.5`: create SPIR-V under OpenGL 4.5 semantics.
Generated code uses SPIR-V 1.0, except for code compiled for Vulkan 1.1, which uses
-SPIR-V 1.3, and code compiled for Vulkan 1.5, which uses SPIR-V 1.5.
+SPIR-V 1.3, and code compiled for Vulkan 1.2, which uses SPIR-V 1.5.
If this option is not specified, a default of `vulkan1.0` is used.
@@ -259,6 +260,7 @@
* `spv1.3`
* `spv1.4`
* `spv1.5`
+* `spv1.6`
==== `-x`
@@ -376,6 +378,11 @@
{0x07230203, 0x00010000, 0x00080001, 0x00000006...}
|===
+[[option-fhlsl-16bit-types]]
+==== `-fhlsl-16bit-types`
+
+Enables 16bit types for HLSL compilation.
+
[[option-fhlsl-offsets]]
==== `-fhlsl-offsets`
diff --git a/glslc/src/main.cc b/glslc/src/main.cc
index 5ca5d61..d989455 100644
--- a/glslc/src/main.cc
+++ b/glslc/src/main.cc
@@ -67,13 +67,15 @@
-fentry-point=<name>
Specify the entry point name for HLSL compilation, for
all subsequent source files. Default is "main".
+ -fhlsl-16bit-types
+ Enable 16-bit type support for HLSL.
-fhlsl_functionality1, -fhlsl-functionality1
Enable extension SPV_GOOGLE_hlsl_functionality1 for HLSL
compilation.
- -finvert-y Invert position.Y output in vertex shader.
-fhlsl-iomap Use HLSL IO mappings for bindings.
-fhlsl-offsets Use HLSL offset rules for packing members of blocks.
Affects only GLSL. HLSL rules are always used for HLSL.
+ -finvert-y Invert position.Y output in vertex shader.
-flimit=<settings>
Specify resource limits. Each limit is specified by a limit
name followed by an integer value. Tokens should be
@@ -159,6 +161,7 @@
vulkan1.0 # The default
vulkan1.1
vulkan1.2
+ vulkan1.3
vulkan # Same as vulkan1.0
opengl4.5
opengl # Same as opengl4.5
@@ -169,8 +172,9 @@
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.
Values are:
- spv1.0, spv1.1, spv1.2, spv1.3, spv1.4, spv1.5
+ spv1.0, spv1.1, spv1.2, spv1.3, spv1.4, spv1.5, spv1.6
--version Display compiler version information.
-w Suppresses all warning messages.
-Werror Treat all warnings as errors.
@@ -320,6 +324,8 @@
} else if (arg == "-fhlsl_functionality1" ||
arg == "-fhlsl-functionality1") {
compiler.options().SetHlslFunctionality1(true);
+ } else if (arg == "-fhlsl-16bit-types") {
+ compiler.options().SetHlsl16BitTypes(true);
} else if (arg == "-finvert-y") {
compiler.options().SetInvertY(true);
} else if (arg == "-fnan-clamp") {
@@ -438,6 +444,9 @@
} else if (target_env_str == "vulkan1.2") {
target_env = shaderc_target_env_vulkan;
version = shaderc_env_version_vulkan_1_2;
+ } 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 == "opengl") {
target_env = shaderc_target_env_opengl;
} else if (target_env_str == "opengl4.5") {
@@ -470,6 +479,8 @@
ver = shaderc_spirv_version_1_4;
} else if (ver_str == "spv1.5") {
ver = shaderc_spirv_version_1_5;
+ } else if (ver_str == "spv1.6") {
+ ver = shaderc_spirv_version_1_6;
} else {
std::cerr << "glslc: error: invalid value '" << ver_str
<< "' in '--target-spv=" << ver_str << "'" << std::endl;
diff --git a/glslc/test/expect.py b/glslc/test/expect.py
index 7410f73..9ac54b2 100644
--- a/glslc/test/expect.py
+++ b/glslc/test/expect.py
@@ -312,6 +312,22 @@
return True, ''
+class ValidObjectFile1_6(SuccessfulReturn, CorrectObjectFilePreamble):
+ """Mixin class for checking that every input file generates a valid SPIR-V 1.6
+ object file following the object file naming rule, and there is no output on
+ stdout/stderr."""
+
+ def check_object_file_preamble(self, status):
+ for input_filename in status.input_filenames:
+ object_filename = get_object_filename(input_filename)
+ success, message = self.verify_object_file_preamble(
+ os.path.join(status.directory, object_filename),
+ 0x10600)
+ if not success:
+ return False, message
+ return True, ''
+
+
class ValidObjectFileWithAssemblySubstr(SuccessfulReturn, CorrectObjectFilePreamble):
"""Mixin class for checking that every input file generates a valid object
file following the object file naming rule, there is no output on
diff --git a/glslc/test/option_dash_cap_O.py b/glslc/test/option_dash_cap_O.py
index 9655a39..337610a 100644
--- a/glslc/test/option_dash_cap_O.py
+++ b/glslc/test/option_dash_cap_O.py
@@ -43,6 +43,7 @@
' 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',
diff --git a/glslc/test/option_fhlsl_16bit_types.py b/glslc/test/option_fhlsl_16bit_types.py
new file mode 100644
index 0000000..ce26ebc
--- /dev/null
+++ b/glslc/test/option_fhlsl_16bit_types.py
@@ -0,0 +1,46 @@
+# Copyright 2018 The Shaderc Authors. All rights reserved.
+#
+# 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.
+
+import expect
+from glslc_test_framework import inside_glslc_testsuite
+from placeholder import FileShader
+
+HLSL_SHADER_WITH_HALF_TYPE = """
+float4 main() : SV_Target0 {
+ half h0 = (half)0.0;
+ half h1 = (half)1.0;
+ half h2 = (half)2.0;
+ half h3 = (half)3.0;
+ half4 v = (half4)(h0,h1,h2,h3) * (half)2.0;
+ return (float4)(v);
+}
+"""
+
+
+@inside_glslc_testsuite('OptionFHlsl16BitTypes')
+class TestHlsl16BitTypes_EnablesCapability(expect.ValidAssemblyFileWithSubstr):
+ """Tests that -fhlsl_16bit_types enables the 16bit floating point capability."""
+
+ shader = FileShader(HLSL_SHADER_WITH_HALF_TYPE, '.frag')
+ glslc_args = ['-S', '-x', 'hlsl', '-fhlsl-16bit-types', '-fauto-bind-uniforms', shader]
+ expected_assembly_substr = 'OpCapability Float16';
+
+
+@inside_glslc_testsuite('OptionFHlsl16BitTypes')
+class TestHlsl16BitTypes_CreatesType(expect.ValidAssemblyFileWithSubstr):
+ """Tests that -fhlsl_16bit_types creates the 16bit floating point capability."""
+
+ shader = FileShader(HLSL_SHADER_WITH_HALF_TYPE, '.frag')
+ glslc_args = ['-S', '-x', 'hlsl', '-fhlsl-16bit-types', '-fauto-bind-uniforms', shader]
+ expected_assembly_substr = '= OpTypeFloat 16';
diff --git a/glslc/test/option_target_env.py b/glslc/test/option_target_env.py
index 4805581..91e6022 100644
--- a/glslc/test/option_target_env.py
+++ b/glslc/test/option_target_env.py
@@ -131,6 +131,16 @@
glslc_args = ['--target-env=vulkan1.2', '-c', shader]
@inside_glslc_testsuite('OptionTargetEnv')
+class TestTargetEnvEqVulkan1_2WithVulkan1_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):
+ shader = FileShader(vulkan_compute_subgroup_shader(), '.comp')
+ glslc_args = ['--target-env=vulkan1.3', '-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/option_target_spv.py b/glslc/test/option_target_spv.py
index 870025b..86ad6f1 100644
--- a/glslc/test/option_target_spv.py
+++ b/glslc/test/option_target_spv.py
@@ -78,6 +78,13 @@
glslc_args = ['--target-spv=spv1.5', '-c', shader]
+@inside_glslc_testsuite('OptionTargetSpv')
+class TestTargetSpv1p5(expect.ValidObjectFile1_6):
+ """Tests that compiling to spv1.6 succeeds and generates SPIR-V 1.6 binary."""
+ shader = FileShader(vulkan_vertex_shader(), '.vert')
+ glslc_args = ['--target-spv=spv1.6', '-c', shader]
+
+
### Option parsing error cases
@inside_glslc_testsuite('OptionTargetSpv')
diff --git a/glslc/test/parameter_tests.py b/glslc/test/parameter_tests.py
index be011a1..c8cfa0c 100644
--- a/glslc/test/parameter_tests.py
+++ b/glslc/test/parameter_tests.py
@@ -71,13 +71,15 @@
-fentry-point=<name>
Specify the entry point name for HLSL compilation, for
all subsequent source files. Default is "main".
+ -fhlsl-16bit-types
+ Enable 16-bit type support for HLSL.
-fhlsl_functionality1, -fhlsl-functionality1
Enable extension SPV_GOOGLE_hlsl_functionality1 for HLSL
compilation.
- -finvert-y Invert position.Y output in vertex shader.
-fhlsl-iomap Use HLSL IO mappings for bindings.
-fhlsl-offsets Use HLSL offset rules for packing members of blocks.
Affects only GLSL. HLSL rules are always used for HLSL.
+ -finvert-y Invert position.Y output in vertex shader.
-flimit=<settings>
Specify resource limits. Each limit is specified by a limit
name followed by an integer value. Tokens should be
@@ -163,6 +165,7 @@
vulkan1.0 # The default
vulkan1.1
vulkan1.2
+ vulkan1.3
vulkan # Same as vulkan1.0
opengl4.5
opengl # Same as opengl4.5
@@ -173,8 +176,9 @@
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.
Values are:
- spv1.0, spv1.1, spv1.2, spv1.3, spv1.4, spv1.5
+ spv1.0, spv1.1, spv1.2, spv1.3, spv1.4, spv1.5, spv1.6
--version Display compiler version information.
-w Suppresses all warning messages.
-Werror Treat all warnings as errors.
diff --git a/kokoro/android-release/build-docker.sh b/kokoro/android-release/build-docker.sh
new file mode 100755
index 0000000..b05e6e7
--- /dev/null
+++ b/kokoro/android-release/build-docker.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+# Copyright (C) 2017-2022 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.
+#
+# Android Build Script.
+
+
+# Fail on any error.
+set -e
+
+. /bin/using.sh # Declare the bash `using` function for configuring toolchains.
+
+# Display commands being run.
+set -x
+
+using cmake-3.17.2
+using ninja-1.10.0
+using ndk-r21d # Sets ANDROID_NDK_HOME, pointing at the NDK's root dir
+
+cd $ROOT_DIR
+./utils/git-sync-deps
+
+mkdir build
+cd $ROOT_DIR/build
+
+# Invoke the build.
+BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT}
+echo $(date): Starting build...
+cmake \
+ -GNinja \
+ -DCMAKE_MAKE_PROGRAM=ninja \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DANDROID_ABI="$TARGET_ARCH" \
+ -DSHADERC_SKIP_TESTS=ON \
+ -DSPIRV_SKIP_TESTS=ON \
+ -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
+ -DANDROID_NDK=$ANDROID_NDK_HOME ..
+
+echo $(date): Build glslang...
+ninja glslangValidator
+
+echo $(date): Build everything...
+ninja
+
+echo $(date): Check Shaderc for copyright notices...
+ninja check-copyright
+
+echo $(date): Build completed.
diff --git a/kokoro/android-release/build.sh b/kokoro/android-release/build.sh
old mode 100644
new mode 100755
index 0443c8a..3b5f11c
--- a/kokoro/android-release/build.sh
+++ b/kokoro/android-release/build.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-# Copyright (C) 2017 Google Inc.
+# Copyright (C) 2020-2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -14,46 +14,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# Android Build Script.
+# Linux Build Script.
+set -e # Fail on any error.
-# Fail on any error.
-set -e
-# Display commands being run.
-set -x
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )"
+ROOT_DIR="$( cd "${SCRIPT_DIR}/../.." >/dev/null 2>&1 && pwd )"
-BUILD_ROOT=$PWD
-SRC=$PWD/github/shaderc
-TARGET_ARCH=$1
+TARGET_ARCH="$1"
-# Get NINJA.
-wget -q https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-linux.zip
-unzip -q ninja-linux.zip
-NINJA=$PWD/ninja
-
-# Get Android NDK.
-wget -q https://dl.google.com/android/repository/android-ndk-r18b-linux-x86_64.zip
-unzip -q android-ndk-r18b-linux-x86_64.zip
-NDK=$PWD/android-ndk-r18b
-
-cd $SRC
-./utils/git-sync-deps
-
-mkdir build
-cd $SRC/build
-
-# Invoke the build.
-BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT}
-echo $(date): Starting build...
-cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=$NINJA -DANDROID_ABI=$TARGET_ARCH -DSHADERC_SKIP_TESTS=ON -DSPIRV_SKIP_TESTS=ON -DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake -DANDROID_NDK=$NDK ..
-
-echo $(date): Build glslang...
-$NINJA glslangValidator
-
-echo $(date): Build everything...
-$NINJA
-
-echo $(date): Check Shaderc for copyright notices...
-$NINJA check-copyright
-
-echo $(date): Build completed.
+# --privileged is required for some sanitizer builds, as they seem to require
+# PTRACE privileges
+docker run --rm -i \
+ --privileged \
+ --volume "${ROOT_DIR}:${ROOT_DIR}" \
+ --volume "${KOKORO_ARTIFACTS_DIR}:${KOKORO_ARTIFACTS_DIR}" \
+ --workdir "${ROOT_DIR}" \
+ --env ROOT_DIR="${ROOT_DIR}" \
+ --env SCRIPT_DIR="${SCRIPT_DIR}" \
+ --env TARGET_ARCH="${TARGET_ARCH}" \
+ --env KOKORO_ARTIFACTS_DIR="${KOKORO_ARTIFACTS_DIR}" \
+ --entrypoint "${SCRIPT_DIR}/build-docker.sh" \
+ "gcr.io/shaderc-build/radial-build:latest"
diff --git a/kokoro/android-release/build_arm.sh b/kokoro/android-release/build_arm.sh
old mode 100644
new mode 100755
diff --git a/kokoro/android-release/build_x86.sh b/kokoro/android-release/build_x86.sh
old mode 100644
new mode 100755
diff --git a/kokoro/linux/build-docker.sh b/kokoro/linux/build-docker.sh
index fb65f81..9687d0a 100755
--- a/kokoro/linux/build-docker.sh
+++ b/kokoro/linux/build-docker.sh
@@ -92,6 +92,9 @@
fi
echo $(date): ctest completed.
+# libshaderc_util/core is generated by the death test in shaderc_util_file_finder_test
+rm -f libshaderc_util/core
+
# Package the build.
ninja install
cd $KOKORO_ARTIFACTS_DIR
diff --git a/kokoro/linux/build.sh b/kokoro/linux/build.sh
index 765a387..3e6375c 100755
--- a/kokoro/linux/build.sh
+++ b/kokoro/linux/build.sh
@@ -24,7 +24,10 @@
CONFIG=$1
COMPILER=$2
+# --privileged is required for some sanitizer builds, as they seem to require
+# PTRACE privileges
docker run --rm -i \
+ --privileged \
--volume "${ROOT_DIR}:${ROOT_DIR}" \
--volume "${KOKORO_ARTIFACTS_DIR}:${KOKORO_ARTIFACTS_DIR}" \
--workdir "${ROOT_DIR}" \
diff --git a/kokoro/ndk-build/build.sh b/kokoro/ndk-build/build.sh
index edf361c..0b9e124 100644
--- a/kokoro/ndk-build/build.sh
+++ b/kokoro/ndk-build/build.sh
@@ -44,13 +44,21 @@
# Invoke the build.
BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT}
-echo $(date): Starting ndk-build ...
-$ANDROID_NDK/ndk-build \
- -C $SRC/android_test \
- NDK_APP_OUT=`pwd` \
- V=1 \
- SPVTOOLS_LOCAL_PATH=$SRC/third_party/spirv-tools \
- SPVHEADERS_LOCAL_PATH=$SRC/third_party/spirv-headers \
- -j 8
+
+function do_ndk_build () {
+ echo $(date): Starting ndk-build $@...
+ $ANDROID_NDK/ndk-build \
+ -C $SRC/android_test \
+ NDK_APP_OUT=`pwd` \
+ V=1 \
+ SPVTOOLS_LOCAL_PATH=$SRC/third_party/spirv-tools \
+ SPVHEADERS_LOCAL_PATH=$SRC/third_party/spirv-headers \
+ -j 8 $@
+}
+
+do_ndk_build
+
+# Check that libshaderc_combined builds
+do_ndk_build libshaderc_combined
echo $(date): ndk-build completed.
diff --git a/libshaderc/include/shaderc/env.h b/libshaderc/include/shaderc/env.h
index 5285b9e..14b418d 100644
--- a/libshaderc/include/shaderc/env.h
+++ b/libshaderc/include/shaderc/env.h
@@ -40,6 +40,7 @@
shaderc_env_version_vulkan_1_0 = ((1u << 22)),
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)),
// 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
@@ -60,7 +61,8 @@
shaderc_spirv_version_1_2 = 0x010200u,
shaderc_spirv_version_1_3 = 0x010300u,
shaderc_spirv_version_1_4 = 0x010400u,
- shaderc_spirv_version_1_5 = 0x010500u
+ shaderc_spirv_version_1_5 = 0x010500u,
+ shaderc_spirv_version_1_6 = 0x010600u
} shaderc_spirv_version;
#ifdef __cplusplus
diff --git a/libshaderc/include/shaderc/shaderc.h b/libshaderc/include/shaderc/shaderc.h
index 1bc354d..84e068b 100644
--- a/libshaderc/include/shaderc/shaderc.h
+++ b/libshaderc/include/shaderc/shaderc.h
@@ -461,6 +461,10 @@
SHADERC_EXPORT void shaderc_compile_options_set_hlsl_functionality1(
shaderc_compile_options_t options, bool enable);
+// Sets whether 16-bit types are supported in HLSL or not.
+SHADERC_EXPORT void shaderc_compile_options_set_hlsl_16bit_types(
+ 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 13d04b1..599a2eb 100644
--- a/libshaderc/include/shaderc/shaderc.hpp
+++ b/libshaderc/include/shaderc/shaderc.hpp
@@ -342,6 +342,11 @@
shaderc_compile_options_set_hlsl_functionality1(options_, enable);
}
+ // Sets whether 16-bit types are supported in HLSL or not.
+ void SetHlsl16BitTypes(bool enable) {
+ shaderc_compile_options_set_hlsl_16bit_types(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);
diff --git a/libshaderc/src/shaderc.cc b/libshaderc/src/shaderc.cc
index 7fdd516..a2822b5 100644
--- a/libshaderc/src/shaderc.cc
+++ b/libshaderc/src/shaderc.cc
@@ -305,6 +305,10 @@
version_number) {
return Compiler::TargetEnvVersion::Vulkan_1_2;
}
+ if (static_cast<uint32_t>(Compiler::TargetEnvVersion::Vulkan_1_3) ==
+ version_number) {
+ return Compiler::TargetEnvVersion::Vulkan_1_3;
+ }
if (static_cast<uint32_t>(Compiler::TargetEnvVersion::OpenGL_4_5) ==
version_number) {
return Compiler::TargetEnvVersion::OpenGL_4_5;
@@ -548,6 +552,11 @@
options->compiler.EnableHlslFunctionality1(enable);
}
+void shaderc_compile_options_set_hlsl_16bit_types(
+ shaderc_compile_options_t options, bool enable) {
+ options->compiler.EnableHlsl16BitTypes(enable);
+}
+
void shaderc_compile_options_set_invert_y(
shaderc_compile_options_t options, bool enable) {
options->compiler.EnableInvertY(enable);
diff --git a/libshaderc_util/include/libshaderc_util/compiler.h b/libshaderc_util/include/libshaderc_util/compiler.h
index bad5b6a..420f285 100644
--- a/libshaderc_util/include/libshaderc_util/compiler.h
+++ b/libshaderc_util/include/libshaderc_util/compiler.h
@@ -85,6 +85,7 @@
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
// For OpenGL, use the numbering from #version in shaders.
OpenGL_4_5 = 450,
};
@@ -97,6 +98,7 @@
v1_3 = 0x010300u,
v1_4 = 0x010400u,
v1_5 = 0x010500u,
+ v1_6 = 0x010600u,
};
enum class OutputType {
@@ -208,6 +210,7 @@
hlsl_offsets_(false),
hlsl_legalization_enabled_(true),
hlsl_functionality1_enabled_(false),
+ hlsl_16bit_types_enabled_(false),
invert_y_enabled_(false),
nan_clamp_(false),
hlsl_explicit_bindings_() {}
@@ -226,6 +229,9 @@
// Enables or disables extension SPV_GOOGLE_hlsl_functionality1
void EnableHlslFunctionality1(bool enable);
+ // Enables or disables HLSL 16-bit types.
+ void EnableHlsl16BitTypes(bool enable);
+
// Enables or disables invert position.Y output in vertex shader.
void EnableInvertY(bool enable);
@@ -526,6 +532,9 @@
// 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 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 8a8d12b..e1345d2 100644
--- a/libshaderc_util/src/compiler.cc
+++ b/libshaderc_util/src/compiler.cc
@@ -72,7 +72,8 @@
// only valid combinations are used.
EShMessages GetMessageRules(shaderc_util::Compiler::TargetEnv env,
shaderc_util::Compiler::SourceLanguage lang,
- bool hlsl_offsets, bool debug_info) {
+ bool hlsl_offsets, bool hlsl_16bit_types,
+ bool debug_info) {
using shaderc_util::Compiler;
EShMessages result = EShMsgCascadingErrors;
if (lang == Compiler::SourceLanguage::HLSL) {
@@ -94,6 +95,9 @@
if (hlsl_offsets) {
result = static_cast<EShMessages>(result | EShMsgHlslOffsets);
}
+ if (hlsl_16bit_types) {
+ result = static_cast<EShMessages>(result | EShMsgHlslEnable16BitTypes);
+ }
if (debug_info) {
result = static_cast<EShMessages>(result | EShMsgDebugInfo);
}
@@ -294,7 +298,7 @@
const EShMessages rules =
GetMessageRules(target_env_, source_language_, hlsl_offsets_,
- generate_debug_info_);
+ hlsl_16bit_types_enabled_, generate_debug_info_);
bool success = shader.parse(&limits_, default_version_, default_profile_,
force_version_profile_, kNotForwardCompatible,
@@ -444,6 +448,10 @@
hlsl_functionality1_enabled_ = enable;
}
+void Compiler::EnableHlsl16BitTypes(bool enable) {
+ hlsl_16bit_types_enabled_ = enable;
+}
+
void Compiler::EnableInvertY(bool enable) { invert_y_enabled_ = enable; }
void Compiler::SetNanClamp(bool enable) { nan_clamp_ = enable; }
@@ -481,7 +489,7 @@
const auto rules = static_cast<EShMessages>(
EShMsgOnlyPreprocessor |
GetMessageRules(target_env_, source_language_, hlsl_offsets_,
- false));
+ hlsl_16bit_types_enabled_, false));
std::string preprocessed_shader;
const bool success = shader.preprocess(
@@ -720,6 +728,9 @@
} else if (env_version == Compiler::TargetEnvVersion::Vulkan_1_2) {
result.client_version = glslang::EShTargetVulkan_1_2;
result.target_language_version = glslang::EShTargetSpv_1_5;
+ } 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 {
errs << "error:" << error_tag << ": Invalid target client version "
<< static_cast<uint32_t>(env_version) << " for Vulkan environment "
@@ -766,6 +777,9 @@
case Compiler::SpirvVersion::v1_5:
result.target_language_version = glslang::EShTargetSpv_1_5;
break;
+ case Compiler::SpirvVersion::v1_6:
+ result.target_language_version = glslang::EShTargetSpv_1_6;
+ break;
default:
errs << "error:" << error_tag << ": Unknown SPIR-V version " << std::hex
<< uint32_t(spv_version);
diff --git a/libshaderc_util/src/compiler_test.cc b/libshaderc_util/src/compiler_test.cc
index 1dfbb6d..a0a964d 100644
--- a/libshaderc_util/src/compiler_test.cc
+++ b/libshaderc_util/src/compiler_test.cc
@@ -165,7 +165,7 @@
std::string Disassemble(const std::vector<uint32_t> binary) {
std::string result;
shaderc_util::SpirvToolsDisassemble(Compiler::TargetEnv::Vulkan,
- Compiler::TargetEnvVersion::Vulkan_1_2,
+ Compiler::TargetEnvVersion::Vulkan_1_3,
binary, &result);
return result;
}
@@ -389,6 +389,12 @@
EXPECT_THAT(errors_, Eq(""));
}
+TEST_F(CompilerTest, SpirvTargetVersion1_6Succeeds) {
+ compiler_.SetTargetSpirv(Compiler::SpirvVersion::v1_6);
+ EXPECT_TRUE(SimpleCompilationSucceeds(kVulkanVertexShader, EShLangVertex));
+ EXPECT_THAT(errors_, Eq(""));
+}
+
TEST_F(CompilerTest, SpirvTargetBadVersionFails) {
compiler_.SetTargetSpirv(static_cast<Compiler::SpirvVersion>(0x090900));
EXPECT_FALSE(SimpleCompilationSucceeds(kVulkanVertexShader, EShLangVertex));
diff --git a/libshaderc_util/src/resources.cc b/libshaderc_util/src/resources.cc
index d64e47f..6c662d3 100644
--- a/libshaderc_util/src/resources.cc
+++ b/libshaderc_util/src/resources.cc
@@ -125,6 +125,15 @@
/* .maxTaskWorkGroupSizeY_NV = */ 1,
/* .maxTaskWorkGroupSizeZ_NV = */ 1,
/* .maxMeshViewCountNV = */ 4,
+ /* .maxMeshOutputVerticesEXT = */ 256,
+ /* .maxMeshOutputPrimitivesEXT = */ 256,
+ /* .maxMeshWorkGroupSizeX_EXT = */ 128,
+ /* .maxMeshWorkGroupSizeY_EXT = */ 128,
+ /* .maxMeshWorkGroupSizeZ_EXT = */ 128,
+ /* .maxTaskWorkGroupSizeX_EXT = */ 128,
+ /* .maxTaskWorkGroupSizeY_EXT = */ 128,
+ /* .maxTaskWorkGroupSizeZ_EXT = */ 128,
+ /* .maxMeshViewCountEXT = */ 4,
/* .maxDualSourceDrawBuffersEXT = */ 1,
// This is the glslang TLimits structure.
// It defines whether or not the following features are enabled.
diff --git a/libshaderc_util/src/spirv_tools_wrapper.cc b/libshaderc_util/src/spirv_tools_wrapper.cc
index 8ce5253..63bff6a 100644
--- a/libshaderc_util/src/spirv_tools_wrapper.cc
+++ b/libshaderc_util/src/spirv_tools_wrapper.cc
@@ -37,6 +37,8 @@
return SPV_ENV_VULKAN_1_1;
case Compiler::TargetEnvVersion::Vulkan_1_2:
return SPV_ENV_VULKAN_1_2;
+ case Compiler::TargetEnvVersion::Vulkan_1_3:
+ return SPV_ENV_VULKAN_1_3;
default:
break;
}
diff --git a/utils/add_copyright.py b/utils/add_copyright.py
index 37505bc..ab3c5f1 100755
--- a/utils/add_copyright.py
+++ b/utils/add_copyright.py
@@ -62,7 +62,7 @@
"""Returns glob-matching filenames under the current directory, but skips
some irrelevant paths."""
return find('.', glob, ['third_party', 'external', 'build*', 'out*',
- 'CompilerIdCXX', '.venv'])
+ 'CompilerIdCXX', '.venv', 'glslang'])
def skip(line):