commit:     de916e3ad11a728544603942e2093c2c4888fb44
Author:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
AuthorDate: Tue May 21 17:10:24 2024 +0000
Commit:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
CommitDate: Tue May 21 17:19:18 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=de916e3a

games-emulation/pcsx2: update live for upstream's shaderc changes

Hardly tested beside running a game + a valid shader using vulkan,
please report bugs to Gentoo if there is anything up with this that
cannot be reproduced with upstream's AppImage.

Signed-off-by: Ionen Wolkens <ionen <AT> gentoo.org>

 .../files/pcsx2-1.7.5835-vanilla-shaderc.patch     | 49 ++++++++++++++++++++++
 games-emulation/pcsx2/pcsx2-9999.ebuild            |  4 +-
 2 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/games-emulation/pcsx2/files/pcsx2-1.7.5835-vanilla-shaderc.patch 
b/games-emulation/pcsx2/files/pcsx2-1.7.5835-vanilla-shaderc.patch
new file mode 100644
index 000000000000..e9c06fb07a5c
--- /dev/null
+++ b/games-emulation/pcsx2/files/pcsx2-1.7.5835-vanilla-shaderc.patch
@@ -0,0 +1,49 @@
+PCSX2 upstream modifies shaderc[1][2][3] rendering its code incompatible
+with vanilla. We'd rather not package this modified shaderc if it can
+reasonably be avoided, so this does minimal code changes to allow vanilla
+usage.
+
+Disclaimer: as the author of this patch, be warned that I can hardly claim
+to know neither C++ nor shaderc, so it could very well be wrong. If run into
+vulkan/shaderc-related issues, try to reproduce with upstream's AppImage
+before reporting bugs to them as they offer no support for distros' builds.
+
+[1] https://github.com/PCSX2/pcsx2/commit/1cd4ba269854646
+[2] https://github.com/PCSX2/pcsx2/commit/fbfdf1200d27260
+[3] https://github.com/PCSX2/pcsx2/commit/ff7995f0d6caaac
+
+Signed-off-by: Ionen Wolkens <[email protected]>
+--- a/pcsx2/GS/Renderers/Vulkan/VKShaderCache.cpp
++++ b/pcsx2/GS/Renderers/Vulkan/VKShaderCache.cpp
+@@ -109,5 +109,5 @@
+       X(shaderc_compile_options_set_optimization_level) \
+       X(shaderc_compile_options_set_target_env) \
+-      X(shaderc_compilation_status_to_string) \
++      X(shaderc_result_get_compilation_status) \
+       X(shaderc_compile_into_spv) \
+       X(shaderc_result_release) \
+@@ -217,19 +217,16 @@
+       dyn_shaderc::shaderc_compile_options_set_source_language(options, 
shaderc_source_language_glsl);
+       dyn_shaderc::shaderc_compile_options_set_target_env(options, 
shaderc_target_env_vulkan, 0);
+-      dyn_shaderc::shaderc_compile_options_set_generate_debug_info(options, 
debug,
+-              debug && 
GSDeviceVK::GetInstance()->GetOptionalExtensions().vk_khr_shader_non_semantic_info);
++      dyn_shaderc::shaderc_compile_options_set_generate_debug_info(options);
+       dyn_shaderc::shaderc_compile_options_set_optimization_level(
+               options, debug ? shaderc_optimization_level_zero : 
shaderc_optimization_level_performance);
+ 
+-      shaderc_compilation_result_t result;
+-      const shaderc_compilation_status status = 
dyn_shaderc::shaderc_compile_into_spv(
++      shaderc_compilation_result_t result = 
dyn_shaderc::shaderc_compile_into_spv(
+               dyn_shaderc::s_compiler, source.data(), source.length(), 
static_cast<shaderc_shader_kind>(stage), "source",
+-              "main", options, &result);
+-      if (status != shaderc_compilation_status_success)
++              "main", options);
++      if (dyn_shaderc::shaderc_result_get_compilation_status(result) != 
shaderc_compilation_status_success)
+       {
+               const std::string_view errors(result ? 
dyn_shaderc::shaderc_result_get_error_message(result) :
+                                                                               
           "null result object");
+-              ERROR_LOG("Failed to compile shader to SPIR-V: {}\n{}",
+-                      
dyn_shaderc::shaderc_compilation_status_to_string(status), errors);
++              ERROR_LOG("Failed to compile shader to SPIR-V: {}", errors);
+               DumpBadShader(source, errors);
+       }

diff --git a/games-emulation/pcsx2/pcsx2-9999.ebuild 
b/games-emulation/pcsx2/pcsx2-9999.ebuild
index 643fe6a2b122..295c925c4305 100644
--- a/games-emulation/pcsx2/pcsx2-9999.ebuild
+++ b/games-emulation/pcsx2/pcsx2-9999.ebuild
@@ -27,7 +27,7 @@ IUSE="alsa cpu_flags_x86_sse4_1 +clang jack pulseaudio sndio 
test vulkan wayland
 REQUIRED_USE="cpu_flags_x86_sse4_1" # dies at runtime if no support
 RESTRICT="!test? ( test )"
 
-# dlopen: libglvnd, qtsvg, vulkan-loader, wayland
+# dlopen: libglvnd, qtsvg, shaderc, vulkan-loader, wayland
 COMMON_DEPEND="
        app-arch/lz4:=
        app-arch/zstd:=
@@ -78,8 +78,8 @@ BDEPEND="
 PATCHES=(
        "${FILESDIR}"/${PN}-1.7.4667-flags.patch
        "${FILESDIR}"/${PN}-1.7.5232-cubeb-automagic.patch
-       "${FILESDIR}"/${PN}-1.7.5700-vanilla-shaderc.patch
        "${FILESDIR}"/${PN}-1.7.5817-missing-headers.patch
+       "${FILESDIR}"/${PN}-1.7.5835-vanilla-shaderc.patch
 )
 
 src_prepare() {

Reply via email to