From 4255bd63a449449b4c44f1105ce0d0627987fa88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timur=20Krist=C3=B3f?= Date: Thu, 12 Jan 2023 01:17:08 +0100 Subject: [PATCH] radv: Compute tess info when emitting patch control points. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some tess info needs to be calculated in the command buffer when dynamic patch control points are enabled. Move this calculation from radv_emit_all_graphics states to where it actually matters. Signed-off-by: Timur Kristóf Reviewed-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/radv_cmd_buffer.c | 46 +++++++++++++------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index 8561cbf1bb1..58da56c18fc 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -2534,6 +2534,24 @@ radv_emit_patch_control_points(struct radv_cmd_buffer *cmd_buffer) const struct radv_dynamic_state *d = &cmd_buffer->state.dynamic; unsigned ls_hs_config, base_reg; + /* Compute tessellation info that depends on the number of patch control points + * when the bound pipeline declared this state as dynamic. + */ + if (cmd_buffer->state.graphics_pipeline->dynamic_states & RADV_DYNAMIC_PATCH_CONTROL_POINTS) { + /* Compute the number of patches. */ + cmd_buffer->state.tess_num_patches = get_tcs_num_patches( + d->vk.ts.patch_control_points, tcs->info.tcs.tcs_vertices_out, + tcs->info.tcs.num_linked_inputs, tcs->info.tcs.num_linked_outputs, + tcs->info.tcs.num_linked_patch_outputs, pdevice->hs.tess_offchip_block_dw_size, + pdevice->rad_info.gfx_level, pdevice->rad_info.family); + + /* Compute the LDS size. */ + cmd_buffer->state.tess_lds_size = calculate_tess_lds_size( + pdevice->rad_info.gfx_level, d->vk.ts.patch_control_points, tcs->info.tcs.tcs_vertices_out, + tcs->info.tcs.num_linked_inputs, cmd_buffer->state.tess_num_patches, + tcs->info.tcs.num_linked_outputs, tcs->info.tcs.num_linked_patch_outputs); + } + ls_hs_config = S_028B58_NUM_PATCHES(cmd_buffer->state.tess_num_patches) | S_028B58_HS_NUM_INPUT_CP(d->vk.ts.patch_control_points) | S_028B58_HS_NUM_OUTPUT_CP(tcs->info.tcs.tcs_vertices_out); @@ -9148,34 +9166,6 @@ radv_emit_all_graphics_states(struct radv_cmd_buffer *cmd_buffer, const struct r } } - /* Pre-compute some tessellation info that depend on the number of patch control points when the - * bound pipeline declared this state as dynamic. - */ - if (cmd_buffer->state.graphics_pipeline->dynamic_states & RADV_DYNAMIC_PATCH_CONTROL_POINTS) { - uint64_t dynamic_states = - cmd_buffer->state.dirty & cmd_buffer->state.emitted_graphics_pipeline->needed_dynamic_state; - - if (dynamic_states & RADV_CMD_DIRTY_DYNAMIC_PATCH_CONTROL_POINTS) { - const struct radv_physical_device *pdevice = device->physical_device; - const struct radv_shader *tcs = cmd_buffer->state.shaders[MESA_SHADER_TESS_CTRL]; - const struct radv_dynamic_state *d = &cmd_buffer->state.dynamic; - - /* Compute the number of patches and emit the context register. */ - cmd_buffer->state.tess_num_patches = get_tcs_num_patches( - d->vk.ts.patch_control_points, tcs->info.tcs.tcs_vertices_out, - tcs->info.tcs.num_linked_inputs, tcs->info.tcs.num_linked_outputs, - tcs->info.tcs.num_linked_patch_outputs, pdevice->hs.tess_offchip_block_dw_size, - pdevice->rad_info.gfx_level, pdevice->rad_info.family); - - /* Compute the LDS size and emit the shader register. */ - cmd_buffer->state.tess_lds_size = calculate_tess_lds_size( - pdevice->rad_info.gfx_level, d->vk.ts.patch_control_points, - tcs->info.tcs.tcs_vertices_out, tcs->info.tcs.num_linked_inputs, - cmd_buffer->state.tess_num_patches, tcs->info.tcs.num_linked_outputs, - tcs->info.tcs.num_linked_patch_outputs); - } - } - radv_cmd_buffer_flush_dynamic_state(cmd_buffer); radv_emit_draw_registers(cmd_buffer, info);