Skip to content

Commit

Permalink
Use 16 bit for p010 frames
Browse files Browse the repository at this point in the history
  • Loading branch information
nowrep authored and streetpea committed Dec 18, 2024
1 parent 51fdfe6 commit 45c63e9
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions scripts/flatpak/0002-Vulkan-use-16bit-for-p010.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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..ccb5a16c 100644
--- a/src/vulkan/gpu_tex.c
+++ b/src/vulkan/gpu_tex.c
@@ -1215,7 +1215,12 @@ 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->num_planes = fmt->num_planes;
tex_vk->usage_flags = usage;
tex_vk->aspect = params->aspect;

3 comments on commit 45c63e9

@nyanmisaka
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nowrep, any chance to upstream this patch to libplacebo?

With the arrival of Mesa 25.0 release, my FFmpeg use case also hit this bug. jellyfin/jellyfin-ffmpeg#546

[libplacebo @ 0x7fc3280072c0] Masking `sampleable` from wrapped texture because the corresponding format 'rx10' does not support PL_FMT_CAP_SAMPLEABLE
[libplacebo @ 0x7fc3280072c0] Masking `blit_src` from wrapped texture because the corresponding format 'rx10' does not support PL_FMT_CAP_BLITTABLE
[libplacebo @ 0x7fc3280072c0] Masking `blit_dst` from wrapped texture because the corresponding format 'rx10' does not support PL_FMT_CAP_BLITTABLE
[libplacebo @ 0x7fc3280072c0] Masking `sampleable` from wrapped texture because the corresponding format 'rxgx10' does not support PL_FMT_CAP_SAMPLEABLE
[libplacebo @ 0x7fc3280072c0] Masking `blit_src` from wrapped texture because the corresponding format 'rxgx10' does not support PL_FMT_CAP_BLITTABLE
[libplacebo @ 0x7fc3280072c0] Masking `blit_dst` from wrapped texture because the corresponding format 'rxgx10' does not support PL_FMT_CAP_BLITTABLE
[libplacebo @ 0x7fc3280072c0] Validation failed: (image->planes[i]).texture->params.sampleable (src/renderer.c:2704)

@nowrep
Copy link
Contributor Author

@nowrep nowrep commented on 45c63e9 Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it needs to be fixed in RADV.

@nyanmisaka
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx, will keep an eye on Mesa side.

Please sign in to comment.