Skip to content

Commit

Permalink
CI: Backport shaderc changes from PCSX2
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Apr 14, 2024
1 parent 06a29f6 commit 59eeb89
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 162 deletions.
2 changes: 1 addition & 1 deletion scripts/build-dependencies-mac.sh
Expand Up @@ -327,7 +327,7 @@ mv "SPIRV-Headers-$SHADERC_SPIRVHEADERS" "spirv-headers"
tar xf "../../shaderc-spirv-tools-$SHADERC_SPIRVTOOLS.tar.gz"
mv "SPIRV-Tools-$SHADERC_SPIRVTOOLS" "spirv-tools"
cd ..
patch -p1 < "$SCRIPTDIR/shaderc-install.patch"
patch -p1 < "$SCRIPTDIR/shaderc-changes.patch"
cmake "${CMAKE_COMMON[@]}" "$CMAKE_ARCH_UNIVERSAL" -DSHADERC_SKIP_TESTS=ON -DSHADERC_SKIP_EXAMPLES=ON -DSHADERC_SKIP_COPYRIGHT_CHECK=ON -B build
make -C build "-j$NPROCS"
make -C build install
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-dependencies-windows-arm64.bat
Expand Up @@ -240,7 +240,7 @@ rename "SPIRV-Headers-%SHADERC_SPIRVHEADERS%" "spirv-headers" || goto error
%SEVENZIP% x "..\..\shaderc-spirv-tools-%SHADERC_SPIRVTOOLS%.zip" || goto error
rename "SPIRV-Tools-%SHADERC_SPIRVTOOLS%" "spirv-tools" || goto error
cd .. || goto error
%PATCH% -p1 < "%SCRIPTDIR%\shaderc-install.patch" || goto error
%PATCH% -p1 < "%SCRIPTDIR%\shaderc-changes.patch" || goto error
cmake %ARM64TOOLCHAIN% -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="%INSTALLDIR%" -DCMAKE_INSTALL_PREFIX="%INSTALLDIR%" -DSHADERC_SKIP_TESTS=ON -DSHADERC_SKIP_EXAMPLES=ON -DSHADERC_SKIP_COPYRIGHT_CHECK=ON -DSHADERC_ENABLE_SHARED_CRT=ON -B build -G Ninja || goto error
cmake --build build --parallel || goto error
ninja -C build install || goto error
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-dependencies-windows-x64.bat
Expand Up @@ -237,7 +237,7 @@ rename "SPIRV-Headers-%SHADERC_SPIRVHEADERS%" "spirv-headers" || goto error
%SEVENZIP% x "..\..\shaderc-spirv-tools-%SHADERC_SPIRVTOOLS%.zip" || goto error
rename "SPIRV-Tools-%SHADERC_SPIRVTOOLS%" "spirv-tools" || goto error
cd .. || goto error
%PATCH% -p1 < "%SCRIPTDIR%\shaderc-install.patch" || goto error
%PATCH% -p1 < "%SCRIPTDIR%\shaderc-changes.patch" || goto error
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="%INSTALLDIR%" -DCMAKE_INSTALL_PREFIX="%INSTALLDIR%" -DSHADERC_SKIP_TESTS=ON -DSHADERC_SKIP_EXAMPLES=ON -DSHADERC_SKIP_COPYRIGHT_CHECK=ON -DSHADERC_ENABLE_SHARED_CRT=ON -B build -G Ninja || goto error
cmake --build build --parallel || goto error
ninja -C build install || goto error
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-dependencies.sh
Expand Up @@ -291,7 +291,7 @@ mv "SPIRV-Headers-$SHADERC_SPIRVHEADERS" "spirv-headers"
tar xf "../../shaderc-spirv-tools-$SHADERC_SPIRVTOOLS.tar.gz"
mv "SPIRV-Tools-$SHADERC_SPIRVTOOLS" "spirv-tools"
cd ..
patch -p1 < "$SCRIPTDIR/shaderc-install.patch"
patch -p1 < "$SCRIPTDIR/shaderc-changes.patch"
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$INSTALLDIR" -DCMAKE_INSTALL_PREFIX="$INSTALLDIR" -DSHADERC_SKIP_TESTS=ON -DSHADERC_SKIP_EXAMPLES=ON -DSHADERC_SKIP_COPYRIGHT_CHECK=ON -B build -G Ninja
cmake --build build --parallel
ninja -C build install
Expand Down
4 changes: 2 additions & 2 deletions scripts/flatpak/modules/22-shaderc.json
Expand Up @@ -37,7 +37,7 @@
},
{
"type": "patch",
"path": "shaderc-install.patch"
"path": "../../shaderc-changes.patch"
}
],
"cleanup": [
Expand All @@ -48,4 +48,4 @@
"/lib/cmake",
"/lib/pkgconfig"
]
}
}
@@ -1,3 +1,13 @@
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,6 @@
Revision history for Shaderc

-v2024.0
+v2024.0 2024-03-09
- Update dependencies
- Utilities:
- Use Python3 explicitly in utility scripts
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -117,6 +117,9 @@ if(MSVC)
Expand Down Expand Up @@ -93,34 +103,118 @@
if(${SHADERC_ENABLE_TESTS})
add_executable(shaderc_c_smoke_test ./src/shaderc_c_smoke_test.c)
shaderc_default_c_compile_options(shaderc_c_smoke_test)
diff --git a/libshaderc_util/src/compiler.cc b/libshaderc_util/src/compiler.cc
index e5f5d10..f4f0fef 100644
--- a/libshaderc/include/shaderc/shaderc.h
+++ b/libshaderc/include/shaderc/shaderc.h
@@ -319,6 +319,10 @@ SHADERC_EXPORT void shaderc_compile_options_set_source_language(
SHADERC_EXPORT void shaderc_compile_options_set_generate_debug_info(
shaderc_compile_options_t options);

+// Sets the compiler mode to emit non-semantic debug information in the output.
+SHADERC_EXPORT void shaderc_compile_options_set_emit_non_semantic_debug_info(
+ shaderc_compile_options_t options);
+
// Sets the compiler optimization level to the given level. Only the last one
// takes effect if multiple calls of this function exist.
SHADERC_EXPORT void shaderc_compile_options_set_optimization_level(
--- a/libshaderc/include/shaderc/shaderc.hpp
+++ b/libshaderc/include/shaderc/shaderc.hpp
@@ -172,6 +172,12 @@ class CompileOptions {
shaderc_compile_options_set_generate_debug_info(options_);
}

+ // Sets the compiler mode to emit non-semantic debug information in the
+ // output.
+ void SetEmitNonSemanticDebugInfo() {
+ shaderc_compile_options_set_emit_non_semantic_debug_info(options_);
+ }
+
// Sets the compiler optimization level to the given level. Only the last one
// takes effect if multiple calls of this function exist.
void SetOptimizationLevel(shaderc_optimization_level level) {
--- a/libshaderc/src/shaderc.cc
+++ b/libshaderc/src/shaderc.cc
@@ -422,6 +422,11 @@ void shaderc_compile_options_set_generate_debug_info(
options->compiler.SetGenerateDebugInfo();
}

+void shaderc_compile_options_set_emit_non_semantic_debug_info(
+ shaderc_compile_options_t options) {
+ options->compiler.SetEmitNonSemanticDebugInfo();
+}
+
void shaderc_compile_options_set_optimization_level(
shaderc_compile_options_t options, shaderc_optimization_level level) {
auto opt_level = shaderc_util::Compiler::OptimizationLevel::Zero;
--- a/libshaderc_util/include/libshaderc_util/compiler.h
+++ b/libshaderc_util/include/libshaderc_util/compiler.h
@@ -195,6 +195,7 @@ class Compiler {
warnings_as_errors_(false),
suppress_warnings_(false),
generate_debug_info_(false),
+ emit_non_semantic_debug_info_(false),
enabled_opt_passes_(),
target_env_(TargetEnv::Vulkan),
target_env_version_(TargetEnvVersion::Default),
@@ -220,6 +221,10 @@ class Compiler {
// such as identifier names and line numbers.
void SetGenerateDebugInfo();

+ // Requests that the compiler emit non-semantic debug information.
+ // Requires VK_KHR_shader_non_semantic_info.
+ void SetEmitNonSemanticDebugInfo();
+
// Sets the optimization level to the given level. Only the last one takes
// effect if multiple calls of this method exist.
void SetOptimizationLevel(OptimizationLevel level);
@@ -486,6 +491,10 @@ class Compiler {
// output.
bool generate_debug_info_;

+ // When true and generate_debug_info_ is also set, generate non-semantic debug
+ // information.
+ bool emit_non_semantic_debug_info_;
+
// Optimization passes to be applied.
std::vector<PassId> enabled_opt_passes_;

--- a/libshaderc_util/src/compiler.cc
+++ b/libshaderc_util/src/compiler.cc
@@ -341,6 +341,10 @@ std::tuple<bool, std::vector<uint32_t>, size_t> Compiler::Compile(
@@ -341,6 +341,11 @@ std::tuple<bool, std::vector<uint32_t>, size_t> Compiler::Compile(
options.generateDebugInfo = generate_debug_info_;
options.disableOptimizer = true;
options.optimizeSize = false;
+ if (generate_debug_info_) {
+ options.emitNonSemanticShaderDebugInfo = true;
+ options.emitNonSemanticShaderDebugSource = true;
+ }
+ options.emitNonSemanticShaderDebugInfo =
+ generate_debug_info_ && emit_non_semantic_debug_info_;
+ options.emitNonSemanticShaderDebugSource =
+ generate_debug_info_ && emit_non_semantic_debug_info_;
+
// Note the call to GlslangToSpv also populates compilation_output_data.
glslang::GlslangToSpv(*program.getIntermediate(used_shader_stage), spirv,
&options);
@@ -438,6 +443,10 @@ void Compiler::SetGenerateDebugInfo() {
}
}

+void Compiler::SetEmitNonSemanticDebugInfo() {
+ emit_non_semantic_debug_info_ = true;
+}
+
void Compiler::SetOptimizationLevel(Compiler::OptimizationLevel level) {
// Clear previous settings first.
enabled_opt_passes_.clear();
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -20,9 +20,9 @@ set(SHADERC_TINT_DIR "${SHADERC_THIRD_PARTY_ROOT_DIR}/tint" CACHE STRING
set(SHADERC_ABSL_DIR "${SHADERC_THIRD_PARTY_ROOT_DIR}/abseil_cpp" CACHE STRING
"Location of re2 source")

-set( SKIP_GLSLANG_INSTALL ${SHADERC_SKIP_INSTALL} )
-set( SKIP_SPIRV_TOOLS_INSTALL ${SHADERC_SKIP_INSTALL} )
-set( SKIP_GOOGLETEST_INSTALL ${SHADERC_SKIP_INSTALL} )
+set( SKIP_GLSLANG_INSTALL ON )
+set( SKIP_SPIRV_TOOLS_INSTALL ON )
+set( SKIP_GOOGLETEST_INSTALL ON )

# Configure third party projects.
if(${SHADERC_ENABLE_TESTS})
@@ -64,7 +64,10 @@ if (NOT TARGET SPIRV-Tools)
Expand All @@ -136,7 +230,7 @@ index e5f5d10..f4f0fef 100644
if (MSVC)
if (${MSVC_VERSION} LESS 1920)
@@ -83,7 +86,7 @@ endif()

if (NOT TARGET glslang)
if (IS_DIRECTORY ${SHADERC_GLSLANG_DIR})
- add_subdirectory(${SHADERC_GLSLANG_DIR} glslang)
Expand Down
146 changes: 0 additions & 146 deletions scripts/shaderc-install.patch

This file was deleted.

0 comments on commit 59eeb89

Please sign in to comment.