From 77c8023e8918785ce15c5b2087d5b30e3bd54a73 Mon Sep 17 00:00:00 2001 From: Street Pea Date: Thu, 16 Jan 2025 18:19:02 -0800 Subject: [PATCH] adjust 16 bit for p010 patch --- .../0002-Vulkan-use-16bit-for-p010.patch | 67 ++++++++----------- 1 file changed, 29 insertions(+), 38 deletions(-) diff --git a/scripts/flatpak/0002-Vulkan-use-16bit-for-p010.patch b/scripts/flatpak/0002-Vulkan-use-16bit-for-p010.patch index 1add78e6..a0ffbb36 100644 --- a/scripts/flatpak/0002-Vulkan-use-16bit-for-p010.patch +++ b/scripts/flatpak/0002-Vulkan-use-16bit-for-p010.patch @@ -1,48 +1,39 @@ -diff --git a/src/vulkan/formats.c b/src/vulkan/formats.c -index f0eb0fb7..7d1c6478 100644 ---- a/src/vulkan/formats.c -+++ b/src/vulkan/formats.c -@@ -415,7 +415,12 @@ void vk_setup_formats(struct pl_gpu_t *gpu) - .pNext = has_drm_mods ? &drm_props : NULL, - }; - -- vk->GetPhysicalDeviceFormatProperties2KHR(vk->physd, vk_fmt->tfmt, &prop2); -+ VkFormat tfmt = vk_fmt->tfmt; -+ if (tfmt == VK_FORMAT_R10X6_UNORM_PACK16) -+ tfmt = VK_FORMAT_R16_UNORM; -+ else if (tfmt == VK_FORMAT_R10X6G10X6_UNORM_2PACK16) -+ tfmt = VK_FORMAT_R16G16_UNORM; -+ vk->GetPhysicalDeviceFormatProperties2KHR(vk->physd, tfmt, &prop2); - - // If wholly unsupported, try falling back to the emulation formats - // for texture operations diff --git a/src/vulkan/gpu_tex.c b/src/vulkan/gpu_tex.c -index a419ffdc..ec32c546 100644 +index a419ffdc..19249e19 100644 --- a/src/vulkan/gpu_tex.c +++ b/src/vulkan/gpu_tex.c -@@ -371,6 +371,11 @@ pl_tex vk_tex_create(pl_gpu gpu, const struct pl_tex_params *params) - .pQueueFamilyIndices = qfs, - }; - -+ if (tex_vk->img_fmt == VK_FORMAT_R10X6_UNORM_PACK16) -+ iinfo.format = VK_FORMAT_R16_UNORM; -+ else if (tex_vk->img_fmt == VK_FORMAT_R10X6G10X6_UNORM_2PACK16) -+ iinfo.format = VK_FORMAT_R16G16_UNORM; -+ - struct vk_malloc_params mparams = { - .optimal = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, - .export_handle = params->export_handle, -@@ -1215,7 +1220,12 @@ pl_tex pl_vulkan_wrap(pl_gpu gpu, const struct pl_vulkan_wrap_params *params) +@@ -1144,10 +1144,15 @@ skip_blocking: + + pl_tex pl_vulkan_wrap(pl_gpu gpu, const struct pl_vulkan_wrap_params *params) + { ++ VkFormat desired_fmt = params->format; ++ if (desired_fmt == VK_FORMAT_R10X6_UNORM_PACK16) ++ desired_fmt = VK_FORMAT_R16_UNORM; ++ else if (desired_fmt == VK_FORMAT_R10X6G10X6_UNORM_2PACK16) ++ desired_fmt = VK_FORMAT_R16G16_UNORM; + pl_fmt fmt = NULL; + for (int i = 0; i < gpu->num_formats; i++) { + const struct vk_format **vkfmt = PL_PRIV(gpu->formats[i]); +- if ((*vkfmt)->tfmt == params->format) { ++ if ((*vkfmt)->tfmt == desired_fmt) { + fmt = gpu->formats[i]; + break; + } +@@ -1155,7 +1160,7 @@ pl_tex pl_vulkan_wrap(pl_gpu gpu, const struct pl_vulkan_wrap_params *params) + + if (!fmt) { + PL_ERR(gpu, "Could not find pl_fmt suitable for wrapped image " +- "with format %s", vk_fmt_name(params->format)); ++ "with format %s", vk_fmt_name(desired_fmt)); + return NULL; + } + +@@ -1215,7 +1220,7 @@ pl_tex pl_vulkan_wrap(pl_gpu gpu, const struct pl_vulkan_wrap_params *params) tex_vk->external_img = true; tex_vk->held = !fmt->num_planes; tex_vk->img = params->image; - tex_vk->img_fmt = params->format; -+ if (params->format == VK_FORMAT_R10X6_UNORM_PACK16) -+ tex_vk->img_fmt = VK_FORMAT_R16_UNORM; -+ else if (params->format == VK_FORMAT_R10X6G10X6_UNORM_2PACK16) -+ tex_vk->img_fmt = VK_FORMAT_R16G16_UNORM; -+ else -+ tex_vk->img_fmt = params->format; ++ tex_vk->img_fmt = desired_fmt; tex_vk->num_planes = fmt->num_planes; tex_vk->usage_flags = usage; tex_vk->aspect = params->aspect;