ShaderC: Version update v2022.3 -> v2024.3

Bump shaderc to latest release. The latest release
contains fixes that we applied locally to improve
compilation performance and also many fixes
that improve platform compatibility.

Pull Request: https://projects.blender.org/blender/blender/pulls/129971
This commit is contained in:
Jeroen Bakker
2024-11-29 07:43:21 +01:00
parent f8217a519f
commit c8f0351b55
4 changed files with 10 additions and 200 deletions

View File

@@ -8,7 +8,8 @@ set(SHADERC_EXTRA_ARGS
-DSHADERC_SPIRV_HEADERS_DIR=${BUILD_DIR}/shaderc_spirv_headers/src/external_shaderc_spirv_headers
-DSHADERC_GLSLANG_DIR=${BUILD_DIR}/shaderc_glslang/src/external_shaderc_glslang
-DCMAKE_DEBUG_POSTFIX=_d
-DPYTHON_EXECUTABLE=${PYTHON_BINARY}
-DPython_EXECUTABLE=${PYTHON_BINARY}
-DPython3_EXECUTABLE=${PYTHON_BINARY}
)
ExternalProject_Add(external_shaderc

View File

@@ -30,11 +30,6 @@ ExternalProject_Add(external_shaderc_spirv_tools
URL_HASH ${SHADERC_SPIRV_TOOLS_HASH_TYPE}=${SHADERC_SPIRV_TOOLS_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PREFIX ${BUILD_DIR}/shaderc_spirv_tools
PATCH_COMMAND COMMAND ${PATCH_CMD} -p 1 -d
${BUILD_DIR}/shaderc_spirv_tools/src/external_shaderc_spirv_tools <
${PATCH_DIR}/shaderc_spirv_tools_5805.diff
CONFIGURE_COMMAND echo .
BUILD_COMMAND echo .
INSTALL_COMMAND echo .

View File

@@ -1296,9 +1296,9 @@ set(HARFBUZZ_FILE harfbuzz-${HARFBUZZ_VERSION}.tar.gz)
set(HARFBUZZ_DEPSBUILDTIMEONLY "UI module asked for preliminary libs so they could work on integrating it")
set(HARFBUZZ_HOMEPAGE https://github.com/harfbuzz/harfbuzz)
set(SHADERC_VERSION v2022.3)
set(SHADERC_VERSION v2024.3)
set(SHADERC_URI https://github.com/google/shaderc/archive/${SHADERC_VERSION}.tar.gz)
set(SHADERC_HASH 5cb762af57637caf997d5f46baa4e8a4)
set(SHADERC_HASH e8d45a77fe8bc954c3ca79aeba8476bd)
set(SHADERC_HASH_TYPE MD5)
set(SHADERC_FILE shaderc-${SHADERC_VERSION}.tar.gz)
set(SHADERC_NAME ShaderC)
@@ -1309,9 +1309,9 @@ set(SHADERC_COPYRIGHT "Copyright 2015 The Shaderc Authors. All rights reserved."
# The versions of shaderc's dependencies can be found in the root of shaderc's
# source in a file called DEPS.
set(SHADERC_SPIRV_TOOLS_VERSION eb0a36633d2acf4de82588504f951ad0f2cecacb)
set(SHADERC_SPIRV_TOOLS_VERSION 01c8438ee4ac52c248119b7e03e0b021f853b51a)
set(SHADERC_SPIRV_TOOLS_URI https://github.com/KhronosGroup/SPIRV-Tools/archive/${SHADERC_SPIRV_TOOLS_VERSION}.tar.gz)
set(SHADERC_SPIRV_TOOLS_HASH a4bdb8161f0e959c75d0d82d367c24f2)
set(SHADERC_SPIRV_TOOLS_HASH 8924fd30abc3ee17b77cba5a924f3666)
set(SHADERC_SPIRV_TOOLS_HASH_TYPE MD5)
set(SHADERC_SPIRV_TOOLS_FILE SPIRV-Tools-${SHADERC_SPIRV_TOOLS_VERSION}.tar.gz)
set(SHADERC_SPIRV_TOOLS_NAME SPIR-V Tools)
@@ -1319,18 +1319,18 @@ set(SHADERC_SPIRV_TOOLS_HOMEPAGE https://github.com/KhronosGroup/SPIRV-Tools/)
set(SHADERC_SPIRV_TOOLS_LICENSE SPDX:Apache-2.0)
set(SHADERC_SPIRV_TOOLS_COPYRIGHT "Copyright (c) 2015-2016 The Khronos Group Inc.")
set(SHADERC_SPIRV_HEADERS_VERSION 85a1ed200d50660786c1a88d9166e871123cce39)
set(SHADERC_SPIRV_HEADERS_VERSION 2a9b6f951c7d6b04b6c21fe1bf3f475b68b84801)
set(SHADERC_SPIRV_HEADERS_URI https://github.com/KhronosGroup/SPIRV-Headers/archive/${SHADERC_SPIRV_HEADERS_VERSION}.tar.gz)
set(SHADERC_SPIRV_HEADERS_HASH 10d5e8160f39344a641523810b075568)
set(SHADERC_SPIRV_HEADERS_HASH f5fc63cd74f5b3deae18e2a1606b8241)
set(SHADERC_SPIRV_HEADERS_HASH_TYPE MD5)
set(SHADERC_SPIRV_HEADERS_FILE SPIRV-Headers-${SHADERC_SPIRV_HEADERS_VERSION}.tar.gz)
set(SHADERC_SPIRV_HEADERS_HOMEPAGE https://github.com/KhronosGroup/SPIRV-Headers)
set(SHADERC_SPIRV_HEADERS_LICENSE SPDX:MIT-Khronos-old)
set(SHADERC_SPIRV_HEADERS_COPYRIGHT "Copyright (c) 2015-2024 The Khronos Group Inc.")
set(SHADERC_GLSLANG_VERSION 89db4e1caa273a057ea46deba709c6e50001b314)
set(SHADERC_GLSLANG_VERSION 467ce01c71e38cf01814c48987a5c0dadd914df4)
set(SHADERC_GLSLANG_URI https://github.com/KhronosGroup/glslang/archive/${SHADERC_GLSLANG_VERSION}.tar.gz)
set(SHADERC_GLSLANG_HASH 3b3c79ad8e9132ffcb8b63cc29c532e2)
set(SHADERC_GLSLANG_HASH 48baea8b66b0bfdc96a9d95a13b0b908)
set(SHADERC_GLSLANG_HASH_TYPE MD5)
set(SHADERC_GLSLANG_FILE glslang-${SHADERC_GLSLANG_VERSION}.tar.gz)
set(SHADERC_GLSLANG_HOMEPAGE https://github.com/KhronosGroup/glslang)

View File

@@ -1,186 +0,0 @@
diff --git a/Android.mk b/Android.mk
index 80c61b08..4cc2911a 100644
--- a/Android.mk
+++ b/Android.mk
@@ -27,6 +27,7 @@ SPVTOOLS_SRC_FILES := \
source/table.cpp \
source/text.cpp \
source/text_handler.cpp \
+ source/to_string.cpp \
source/util/bit_vector.cpp \
source/util/parse_number.cpp \
source/util/string_utils.cpp \
diff --git a/BUILD.gn b/BUILD.gn
index b7e20b34..e4b776b4 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -456,6 +456,8 @@ static_library("spvtools") {
"source/text.h",
"source/text_handler.cpp",
"source/text_handler.h",
+ "source/to_string.cpp",
+ "source/to_string.h",
"source/util/bit_vector.cpp",
"source/util/bit_vector.h",
"source/util/bitutils.h",
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 668579ac..ae59eaef 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -262,6 +262,7 @@ set(SPIRV_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/table.h
${CMAKE_CURRENT_SOURCE_DIR}/text.h
${CMAKE_CURRENT_SOURCE_DIR}/text_handler.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/to_string.cpp
${CMAKE_CURRENT_SOURCE_DIR}/val/validate.h
${CMAKE_CURRENT_SOURCE_DIR}/util/bit_vector.cpp
diff --git a/source/name_mapper.cpp b/source/name_mapper.cpp
index 3b31d33a..c7ca08d0 100644
--- a/source/name_mapper.cpp
+++ b/source/name_mapper.cpp
@@ -25,24 +25,14 @@
#include "source/binary.h"
#include "source/latest_version_spirv_header.h"
#include "source/parsed_operand.h"
+#include "source/to_string.h"
#include "spirv-tools/libspirv.h"
namespace spvtools {
-namespace {
-
-// Converts a uint32_t to its string decimal representation.
-std::string to_string(uint32_t id) {
- // Use stringstream, since some versions of Android compilers lack
- // std::to_string.
- std::stringstream os;
- os << id;
- return os.str();
+NameMapper GetTrivialNameMapper() {
+ return [](uint32_t i) { return spvtools::to_string(i); };
}
-} // anonymous namespace
-
-NameMapper GetTrivialNameMapper() { return to_string; }
-
FriendlyNameMapper::FriendlyNameMapper(const spv_const_context context,
const uint32_t* code,
const size_t wordCount)
diff --git a/source/opt/instrument_pass.cpp b/source/opt/instrument_pass.cpp
index d143d595..c759e0b3 100644
--- a/source/opt/instrument_pass.cpp
+++ b/source/opt/instrument_pass.cpp
@@ -18,6 +18,7 @@
#include "source/cfa.h"
#include "source/spirv_constant.h"
+#include "source/to_string.h"
namespace {
@@ -839,7 +840,7 @@ uint32_t InstrumentPass::GetStreamWriteFunctionId(uint32_t stage_idx,
context()->AddFunction(std::move(output_func));
std::string name("stream_write_");
- name += std::to_string(param_cnt);
+ name += spvtools::to_string(param_cnt);
context()->AddDebug2Inst(
NewGlobalName(param2output_func_id_[param_cnt], name));
@@ -925,7 +926,7 @@ uint32_t InstrumentPass::GetDirectReadFunctionId(uint32_t param_cnt) {
context()->AddFunction(std::move(input_func));
std::string name("direct_read_");
- name += std::to_string(param_cnt);
+ name += spvtools::to_string(param_cnt);
context()->AddDebug2Inst(NewGlobalName(func_id, name));
param2input_func_id_[param_cnt] = func_id;
diff --git a/source/to_string.cpp b/source/to_string.cpp
new file mode 100644
index 00000000..18f144b1
--- /dev/null
+++ b/source/to_string.cpp
@@ -0,0 +1,44 @@
+// Copyright (c) 2024 Google LLC
+//
+// 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.
+
+#include "source/to_string.h"
+
+#include <cassert>
+
+namespace spvtools {
+
+std::string to_string(uint32_t n) {
+ // This implementation avoids using standard library features that access
+ // the locale. Using the locale requires taking a mutex which causes
+ // annoying serialization.
+
+ constexpr int max_digits = 10; // max uint has 10 digits
+ // Contains the resulting digits, with least significant digit in the last
+ // entry.
+ char buf[max_digits];
+ int write_index = max_digits - 1;
+ if (n == 0) {
+ buf[write_index] = '0';
+ } else {
+ while (n > 0) {
+ int units = n % 10;
+ buf[write_index--] = "0123456789"[units];
+ n = (n - units) / 10;
+ }
+ write_index++;
+ }
+ assert(write_index >= 0);
+ return std::string(buf + write_index, max_digits - write_index);
+}
+} // namespace spvtools
\ No newline at end of file
diff --git a/source/to_string.h b/source/to_string.h
new file mode 100644
index 00000000..31a859e6
--- /dev/null
+++ b/source/to_string.h
@@ -0,0 +1,29 @@
+// Copyright (c) 2024 Google LLC
+//
+// 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.
+
+#ifndef SOURCE_TO_STRING_H_
+#define SOURCE_TO_STRING_H_
+
+#include <cstdint>
+#include <string>
+
+namespace spvtools {
+
+// Returns the decimal representation of a number as a string,
+// without using the locale.
+std::string to_string(uint32_t n);
+
+} // namespace spvtools
+
+#endif // SOURCE_TO_STRING_H_
\ No newline at end of file