tu: Implement VK_EXT_legacy_dithering

Signed-off-by: Karmjit Mahil <karmjit.mahil@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30536>
This commit is contained in:
Karmjit Mahil
2024-08-06 13:29:47 +02:00
committed by Marge Bot
parent 110201cfd8
commit 3c4fb8f7fa
6 changed files with 33 additions and 4 deletions

View File

@@ -671,7 +671,7 @@ Khronos extensions that are not part of any Vulkan version:
VK_KHR_map_memory2 DONE (anv, nvk, radv, tu)
VK_EXT_map_memory_placed DONE (anv, nvk, radv, tu)
VK_MESA_image_alignment_control DONE (radv)
VK_EXT_legacy_dithering DONE (anv)
VK_EXT_legacy_dithering DONE (anv, tu)
Clover OpenCL 1.0 -- all DONE:

View File

@@ -1579,6 +1579,11 @@ r3d_setup(struct tu_cmd_buffer *cmd,
/* Disable sample counting in order to not affect occlusion query. */
tu_cs_emit_regs(cs, A6XX_RB_SAMPLE_COUNT_CONTROL(.disable = true));
tu_cs_emit_regs(cs, A6XX_RB_DITHER_CNTL());
if (CHIP >= A7XX) {
tu_cs_emit_regs(cs, A7XX_SP_DITHER_CNTL());
}
if (cmd->state.prim_generated_query_running_before_rp) {
tu_emit_event_write<CHIP>(cmd, cs, FD_STOP_PRIMITIVE_CTRS);
}

View File

@@ -501,6 +501,23 @@ tu6_emit_mrt(struct tu_cmd_buffer *cmd,
tu_cs_emit_regs(cs, A6XX_GRAS_LRZ_MRT_BUF_INFO_0(.color_format = mrt0_format));
const bool dither = subpass->legacy_dithering_enabled;
const uint32_t dither_cntl =
A6XX_RB_DITHER_CNTL(
.dither_mode_mrt0 = dither ? DITHER_ALWAYS : DITHER_DISABLE,
.dither_mode_mrt1 = dither ? DITHER_ALWAYS : DITHER_DISABLE,
.dither_mode_mrt2 = dither ? DITHER_ALWAYS : DITHER_DISABLE,
.dither_mode_mrt3 = dither ? DITHER_ALWAYS : DITHER_DISABLE,
.dither_mode_mrt4 = dither ? DITHER_ALWAYS : DITHER_DISABLE,
.dither_mode_mrt5 = dither ? DITHER_ALWAYS : DITHER_DISABLE,
.dither_mode_mrt6 = dither ? DITHER_ALWAYS : DITHER_DISABLE,
.dither_mode_mrt7 = dither ? DITHER_ALWAYS : DITHER_DISABLE, )
.value;
tu_cs_emit_regs(cs, A6XX_RB_DITHER_CNTL(.dword = dither_cntl));
if (CHIP >= A7XX) {
tu_cs_emit_regs(cs, A7XX_SP_DITHER_CNTL(.dword = dither_cntl));
}
tu_cs_emit_regs(cs,
A6XX_RB_SRGB_CNTL(.dword = subpass->srgb_cntl));
tu_cs_emit_regs(cs,
@@ -1287,8 +1304,6 @@ tu6_init_hw(struct tu_cmd_buffer *cmd, struct tu_cs *cs)
emit_rb_ccu_cntl<CHIP>(cs, cmd->device, false);
cmd->state.ccu_state = TU_CMD_CCU_SYSMEM;
tu_cs_emit_write_reg(cs, REG_A7XX_SP_DITHER_CNTL, 0);
for (size_t i = 0; i < ARRAY_SIZE(phys_dev->info->a6xx.magic_raw); i++) {
auto magic_reg = phys_dev->info->a6xx.magic_raw[i];
if (!magic_reg.reg)
@@ -1393,7 +1408,6 @@ tu6_init_hw(struct tu_cmd_buffer *cmd, struct tu_cs *cs)
tu_cs_emit_write_reg(cs, REG_A6XX_PC_MODE_CNTL, phys_dev->info->a6xx.magic.PC_MODE_CNTL);
tu_cs_emit_regs(cs, A6XX_RB_ALPHA_CONTROL()); /* always disable alpha test */
tu_cs_emit_regs(cs, A6XX_RB_DITHER_CNTL()); /* always disable dithering */
tu_disable_draw_states(cmd, cs);

View File

@@ -256,6 +256,7 @@ get_device_extensions(const struct tu_physical_device *device,
.EXT_image_view_min_lod = true,
.EXT_index_type_uint8 = true,
.EXT_inline_uniform_block = true,
.EXT_legacy_dithering = true,
.EXT_legacy_vertex_attributes = true,
.EXT_line_rasterization = true,
.EXT_load_store_op_none = true,
@@ -597,6 +598,9 @@ tu_get_features(struct tu_physical_device *pdevice,
/* VK_EXT_legacy_vertex_attributes */
features->legacyVertexAttributes = true;
/* VK_EXT_legacy_dithering */
features->legacyDithering = true;
/* VK_EXT_map_memory_placed */
features->memoryMapPlaced = true;
features->memoryMapRangePlaced = false;

View File

@@ -911,6 +911,8 @@ tu_CreateRenderPass2(VkDevice _device,
subpass->resolve_depth_stencil = is_depth_stencil_resolve_enabled(ds_resolve);
subpass->samples = (VkSampleCountFlagBits) 0;
subpass->srgb_cntl = 0;
subpass->legacy_dithering_enabled = desc->flags &
VK_SUBPASS_DESCRIPTION_ENABLE_LEGACY_DITHERING_BIT_EXT;
const BITMASK_ENUM(VkSubpassDescriptionFlagBits) raster_order_access_bits =
VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_EXT |
@@ -1076,6 +1078,8 @@ tu_setup_dynamic_render_pass(struct tu_cmd_buffer *cmd_buffer,
subpass->color_attachments = cmd_buffer->dynamic_color_attachments;
subpass->resolve_attachments = cmd_buffer->dynamic_resolve_attachments;
subpass->multiview_mask = info->viewMask;
subpass->legacy_dithering_enabled = info->flags &
VK_RENDERING_ENABLE_LEGACY_DITHERING_BIT_EXT;
uint32_t a = 0;
for (uint32_t i = 0; i < info->colorAttachmentCount; i++) {

View File

@@ -48,6 +48,8 @@ struct tu_subpass
uint32_t resolve_count;
bool resolve_depth_stencil;
bool legacy_dithering_enabled;
bool feedback_loop_color;
bool feedback_loop_ds;