mirror of
https://github.com/openbsd/ports.git
synced 2026-06-17 23:13:55 +02:00
graphics/libplacebo: backport patch to support shaders before 1.6
OK: semarie@
This commit is contained in:
@@ -3,6 +3,7 @@ COMMENT= reusable library for GPU-accelerated video/image rendering
|
||||
GH_ACCOUNT= haasn
|
||||
GH_PROJECT= libplacebo
|
||||
GH_TAGNAME= v7.351.0
|
||||
REVISION= 0
|
||||
CATEGORIES= graphics
|
||||
|
||||
SHARED_LIBS= placebo 9.0
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
glsl/spirv_shaderc: check if shaderc recognizes Vulkan 1.4
|
||||
https://code.videolan.org/videolan/libplacebo/-/commit/3662b1f5d5a721f31cbf6c0ad090ac2345834cab
|
||||
|
||||
Index: src/glsl/meson.build
|
||||
--- src/glsl/meson.build.orig
|
||||
+++ src/glsl/meson.build
|
||||
@@ -4,6 +4,14 @@ components.set('shaderc', shaderc.found())
|
||||
if shaderc.found()
|
||||
build_deps += shaderc
|
||||
sources += 'glsl/spirv_shaderc.c'
|
||||
+
|
||||
+ # Version check for shaderc is not possible because everything after v2023.8
|
||||
+ # uses this version due to a malformed version line.
|
||||
+ # See https://github.com/google/shaderc/issues/1496
|
||||
+ conf_internal.set('PL_HAVE_SHADERC_VK_1_4',
|
||||
+ cc.has_header_symbol('shaderc/shaderc.h', 'shaderc_env_version_vulkan_1_4', dependencies: shaderc))
|
||||
+ conf_internal.set('PL_HAVE_SHADERC_VK_1_3',
|
||||
+ cc.has_header_symbol('shaderc/shaderc.h', 'shaderc_env_version_vulkan_1_3', dependencies: shaderc))
|
||||
endif
|
||||
|
||||
# glslang
|
||||
@@ -0,0 +1,50 @@
|
||||
glsl/spirv_shaderc: check if shaderc recognizes Vulkan 1.4
|
||||
https://code.videolan.org/videolan/libplacebo/-/commit/3662b1f5d5a721f31cbf6c0ad090ac2345834cab
|
||||
|
||||
Index: src/glsl/spirv_shaderc.c
|
||||
--- src/glsl/spirv_shaderc.c.orig
|
||||
+++ src/glsl/spirv_shaderc.c
|
||||
@@ -22,6 +22,17 @@
|
||||
#include "spirv.h"
|
||||
#include "utils.h"
|
||||
|
||||
+#define VK_API_VERSION_MAJOR(version) (((uint32_t)(version) >> 22U) & 0x7FU)
|
||||
+#define VK_API_VERSION_MINOR(version) (((uint32_t)(version) >> 12U) & 0x3FFU)
|
||||
+
|
||||
+#if defined(PL_HAVE_SHADERC_VK_1_4)
|
||||
+# define SHADERC_VULKAN_MAX PL_VLK_VERSION(1, 4)
|
||||
+#elif defined(PL_HAVE_SHADERC_VK_1_3)
|
||||
+# define SHADERC_VULKAN_MAX PL_VLK_VERSION(1, 3)
|
||||
+#else
|
||||
+# define SHADERC_VULKAN_MAX PL_VLK_VERSION(1, 2)
|
||||
+#endif
|
||||
+
|
||||
const struct spirv_compiler pl_spirv_shaderc;
|
||||
|
||||
struct priv {
|
||||
@@ -57,8 +68,25 @@ static pl_spirv shaderc_create(pl_log log, struct pl_s
|
||||
|
||||
// Clamp to supported version by shaderc
|
||||
if (ver < spirv->version.spv_version) {
|
||||
+ PL_WARN(spirv, "SPIR-V %u.%u is not supported by the current"
|
||||
+ " version of shaderc. Falling back to %u.%u!",
|
||||
+ spirv->version.spv_version >> 16, (spirv->version.spv_version >> 8) & 0xff,
|
||||
+ ver >> 16, (ver >> 8) & 0xff);
|
||||
spirv->version.spv_version = ver;
|
||||
spirv->version.env_version = pl_spirv_version_to_vulkan(ver);
|
||||
+ }
|
||||
+
|
||||
+ if (SHADERC_VULKAN_MAX < spirv->version.env_version) {
|
||||
+ PL_WARN(spirv, "Vulkan %u.%u is not supported by the current"
|
||||
+ " version of shaderc. Falling back to %u.%u!",
|
||||
+ VK_API_VERSION_MAJOR(spirv->version.env_version),
|
||||
+ VK_API_VERSION_MINOR(spirv->version.env_version),
|
||||
+ VK_API_VERSION_MAJOR(SHADERC_VULKAN_MAX),
|
||||
+ VK_API_VERSION_MINOR(SHADERC_VULKAN_MAX));
|
||||
+ // The SPIR-V version has already been clamped above.
|
||||
+ // In practice, this only occurs for Vulkan 1.3 and 1.4,
|
||||
+ // where the SPIR-V version is the same (1.6).
|
||||
+ spirv->version.env_version = SHADERC_VULKAN_MAX;
|
||||
}
|
||||
|
||||
pl_hash_merge(&spirv->signature, (uint64_t) spirv->version.spv_version << 32 |
|
||||
Reference in New Issue
Block a user