From 8dc8a2eec4e3debf4291a292e6b46118973c1967 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Mon, 9 Feb 2026 12:55:22 +0100 Subject: [PATCH] panvk: Support VK_EXT_legacy_dithering Wire up the existing Panfrost dithering infrastructure to the Vulkan extension. The library already supports dithered formats via pan_dithered_format_from_pipe_format(), so this plumbs the VK_RENDERING_ENABLE_LEGACY_DITHERING_BIT_EXT flag through to the blend descriptor emission and color attachment internal conversion paths. Dithering is only applied to color attachments, not depth or framebuffer preloads. Signed-off-by: Christian Gmeiner Reviewed-by: Erik Faye-Lund Part-of: --- docs/features.txt | 2 +- docs/relnotes/new_features.txt | 1 + src/panfrost/vulkan/panvk_vX_blend.c | 10 +++++++--- src/panfrost/vulkan/panvk_vX_cmd_draw.c | 5 ++++- src/panfrost/vulkan/panvk_vX_physical_device.c | 4 ++++ 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/features.txt b/docs/features.txt index ae3d8967a28..1e52f809e2f 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -727,7 +727,7 @@ Khronos extensions that are not part of any Vulkan version: VK_INTEL_shader_integer_functions2 DONE (anv, hasvk, radv) VK_EXT_map_memory_placed DONE (anv, hk, nvk, pvr, radv, tu, vn) VK_MESA_image_alignment_control DONE (anv, nvk, radv) - VK_EXT_legacy_dithering DONE (anv, tu, vn) + VK_EXT_legacy_dithering DONE (anv, panvk, tu, vn) VK_QCOM_fragment_density_map_offset DONE (tu) VK_QCOM_image_processing DONE (tu) VK_QCOM_multiview_per_view_render_areas DONE (tu) diff --git a/docs/relnotes/new_features.txt b/docs/relnotes/new_features.txt index c5db62dde79..d5bbdb9b021 100644 --- a/docs/relnotes/new_features.txt +++ b/docs/relnotes/new_features.txt @@ -19,3 +19,4 @@ VK_EXT_color_write_enable on panvk VK_EXT_image_view_min_lod on panvk VK_EXT_depth_clamp_control on panvk VK_VALVE_shader_mixed_float_dot_product on RADV (Vega20, Navi14, RDNA2+) +VK_EXT_legacy_dithering on panvk diff --git a/src/panfrost/vulkan/panvk_vX_blend.c b/src/panfrost/vulkan/panvk_vX_blend.c index 2174acaa8a5..a5acfb06306 100644 --- a/src/panfrost/vulkan/panvk_vX_blend.c +++ b/src/panfrost/vulkan/panvk_vX_blend.c @@ -117,7 +117,7 @@ static void emit_blend_desc(const struct pan_blend_state *state, uint8_t rt_idx, const struct pan_shader_info *fs_info, uint8_t loc, uint64_t fs_code, uint64_t blend_shader, uint16_t constant, - struct mali_blend_packed *bd) + bool dithered, struct mali_blend_packed *bd) { const struct pan_blend_rt_state *rt = &state->rts[rt_idx]; @@ -168,7 +168,7 @@ emit_blend_desc(const struct pan_blend_state *state, uint8_t rt_idx, */ cfg.internal.fixed_function.num_comps = 4; cfg.internal.fixed_function.conversion.memory_format = - GENX(pan_dithered_format_from_pipe_format)(rt->format, false); + GENX(pan_dithered_format_from_pipe_format)(rt->format, dithered); #if PAN_ARCH >= 7 if (cfg.internal.mode == MALI_BLEND_MODE_FIXED_FUNCTION && @@ -380,8 +380,12 @@ panvk_per_arch(blend_emit_descs)(struct panvk_cmd_buffer *cmdbuf, struct mali_blend_packed packed[MAX_RTS]; for (uint8_t rt = 0; rt < bs.rt_count; rt++) { + bool dithered = render->flags & + VK_RENDERING_ENABLE_LEGACY_DITHERING_BIT_EXT; + emit_blend_desc(&bs, rt, fs_info, rt_loc[rt], fs_code, - blend_shaders[rt], ff_blend_constant, &packed[rt]); + blend_shaders[rt], ff_blend_constant, dithered, + &packed[rt]); } /* Copy into the GPU descriptor array */ diff --git a/src/panfrost/vulkan/panvk_vX_cmd_draw.c b/src/panfrost/vulkan/panvk_vX_cmd_draw.c index 3e6550b3916..c6cbc9d301d 100644 --- a/src/panfrost/vulkan/panvk_vX_cmd_draw.c +++ b/src/panfrost/vulkan/panvk_vX_cmd_draw.c @@ -718,9 +718,12 @@ prepare_iam_sysvals(struct panvk_cmd_buffer *cmdbuf, BITSET_WORD *dirty_sysvals) iam[ia_idx].target = PANVK_COLOR_ATTACHMENT(i); + bool dithered = cmdbuf->state.gfx.render.flags & + VK_RENDERING_ENABLE_LEGACY_DITHERING_BIT_EXT; + pan_pack(&conv, INTERNAL_CONVERSION, cfg) { cfg.memory_format = - GENX(pan_dithered_format_from_pipe_format)(pfmt, false); + GENX(pan_dithered_format_from_pipe_format)(pfmt, dithered); #if PAN_ARCH < 9 cfg.register_format = vk_format_is_uint(fmt) ? MALI_REGISTER_FILE_FORMAT_U32 diff --git a/src/panfrost/vulkan/panvk_vX_physical_device.c b/src/panfrost/vulkan/panvk_vX_physical_device.c index 4655a662fe9..f6ed02a830a 100644 --- a/src/panfrost/vulkan/panvk_vX_physical_device.c +++ b/src/panfrost/vulkan/panvk_vX_physical_device.c @@ -161,6 +161,7 @@ panvk_per_arch(get_physical_device_extensions)( .EXT_image_robustness = true, .EXT_image_view_min_lod = true, .EXT_index_type_uint8 = true, + .EXT_legacy_dithering = true, .EXT_line_rasterization = true, .EXT_load_store_op_none = true, .EXT_non_seamless_cube_map = true, @@ -553,6 +554,9 @@ panvk_per_arch(get_physical_device_features)( /* VK_EXT_ycbcr_image_arrays */ .ycbcrImageArrays = PAN_ARCH >= 10, + /* VK_EXT_legacy_dithering */ + .legacyDithering = true, + /* VK_EXT_non_seamless_cube_map */ .nonSeamlessCubeMap = true,