From 8df8e1283f91ba4df3dbdf650e78e8754400deaf Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 21 Oct 2023 21:09:40 +0200 Subject: [PATCH] gpu: Work around Ycbcr not working with dynamically uniform indices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's a well hidden line in the spec that says in https://registry.khronos.org/vulkan/specs/1.3/html/chap15.html#interfaces-resources-descset If the combined image sampler enables sampler Y′CBCR conversion, it **must** be indexed only by constant integral expressions when aggregated into arrays in shader code, irrespective of the shaderSampledImageArrayDynamicIndexing feature. So we'll use the same trick that we use for old GL here and do an if dance that gives us dynamically uniform expressions. --- gsk/gpu/shaders/common-vulkan.glsl | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/gsk/gpu/shaders/common-vulkan.glsl b/gsk/gpu/shaders/common-vulkan.glsl index a841c6d4d6..c97701d5ae 100644 --- a/gsk/gpu/shaders/common-vulkan.glsl +++ b/gsk/gpu/shaders/common-vulkan.glsl @@ -9,7 +9,7 @@ layout(push_constant) uniform PushConstants { } push; layout(constant_id=0) const uint GSK_SHADER_CLIP = GSK_GPU_SHADER_CLIP_NONE; -layout(constant_id=1) const uint GSK_IMMUTABLE_SAMPLERS = 1; +layout(constant_id=1) const uint GSK_IMMUTABLE_SAMPLERS = 8; #define GSK_GLOBAL_MVP push.mvp #define GSK_GLOBAL_CLIP push.clip @@ -42,7 +42,27 @@ gsk_texture (uint id, vec2 pos) { if ((id & 1) != 0) - return texture (immutable_textures[nonuniformEXT (id >> 1)], pos); + { + id >>= 1; + if (id == 0) + return texture (immutable_textures[0], pos); + else if (GSK_IMMUTABLE_SAMPLERS > 1 && id == 1) + return texture (immutable_textures[1], pos); + else if (GSK_IMMUTABLE_SAMPLERS > 2 && id == 2) + return texture (immutable_textures[2], pos); + else if (GSK_IMMUTABLE_SAMPLERS > 3 && id == 3) + return texture (immutable_textures[3], pos); + else if (GSK_IMMUTABLE_SAMPLERS > 4 && id == 4) + return texture (immutable_textures[4], pos); + else if (GSK_IMMUTABLE_SAMPLERS > 5 && id == 5) + return texture (immutable_textures[5], pos); + else if (GSK_IMMUTABLE_SAMPLERS > 6 && id == 6) + return texture (immutable_textures[6], pos); + else if (GSK_IMMUTABLE_SAMPLERS > 7 && id == 7) + return texture (immutable_textures[7], pos); + else + return vec4 (1.0, 0.0, 0.8, 1.0); + } return texture (textures[nonuniformEXT (id >> 1)], pos); }