diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c index 82d22d7e767..c62a9b58fd2 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.c +++ b/src/freedreno/vulkan/tu_cmd_buffer.c @@ -4494,8 +4494,10 @@ tu6_draw_common(struct tu_cmd_buffer *cmd, if (cmd->state.dirty & TU_CMD_DIRTY_PATCH_CONTROL_POINTS) { bool tess = cmd->state.pipeline->active_stages & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; - struct tu_cs cs = tu_cmd_dynamic_state(cmd, TU_DYNAMIC_STATE_PATCH_CONTROL_POINTS, - tess ? TU6_EMIT_PATCH_CONTROL_POINTS_DWORDS : 0); + uint32_t state_size = TU6_EMIT_PATCH_CONTROL_POINTS_DWORDS( + pipeline->program.hs_param_dwords); + struct tu_cs cs = tu_cmd_dynamic_state( + cmd, TU_DYNAMIC_STATE_PATCH_CONTROL_POINTS, tess ? state_size : 0); tu6_emit_patch_control_points(&cs, cmd->state.pipeline, cmd->state.patch_control_points); } diff --git a/src/freedreno/vulkan/tu_pipeline.c b/src/freedreno/vulkan/tu_pipeline.c index ee777de06ad..bc5d61ee95d 100644 --- a/src/freedreno/vulkan/tu_pipeline.c +++ b/src/freedreno/vulkan/tu_pipeline.c @@ -1755,12 +1755,9 @@ tu6_emit_patch_control_points(struct tu_cs *cs, const struct ir3_const_state *hs_const = &pipeline->program.link[MESA_SHADER_TESS_CTRL].const_state; - unsigned hs_constlen = - pipeline->program.link[MESA_SHADER_TESS_CTRL].constlen; uint32_t hs_base = hs_const->offsets.primitive_param; - uint32_t hs_param_dwords = MIN2((hs_constlen - hs_base) * 4, ARRAY_SIZE(hs_params)); tu6_emit_const(cs, CP_LOAD_STATE6_GEOM, hs_base, SB6_HS_SHADER, 0, - hs_param_dwords, hs_params); + pipeline->program.hs_param_dwords, hs_params); uint32_t patch_local_mem_size_16b = patch_control_points * pipeline->program.vs_param_stride / 4; @@ -3942,10 +3939,21 @@ tu_pipeline_builder_parse_shader_stages(struct tu_pipeline_builder *builder, pipeline->program.hs_param_stride = hs->output_size; pipeline->program.hs_vertices_out = hs->tess.tcs_vertices_out; + const struct ir3_const_state *hs_const = + &pipeline->program.link[MESA_SHADER_TESS_CTRL].const_state; + unsigned hs_constlen = + pipeline->program.link[MESA_SHADER_TESS_CTRL].constlen; + uint32_t hs_base = hs_const->offsets.primitive_param; + pipeline->program.hs_param_dwords = + MIN2((hs_constlen - hs_base) * 4, 8); + + uint32_t state_size = TU6_EMIT_PATCH_CONTROL_POINTS_DWORDS( + pipeline->program.hs_param_dwords); + struct tu_cs cs; if (tu_pipeline_static_state(pipeline, &cs, TU_DYNAMIC_STATE_PATCH_CONTROL_POINTS, - TU6_EMIT_PATCH_CONTROL_POINTS_DWORDS)) { + state_size)) { tu6_emit_patch_control_points(&cs, pipeline, pipeline->tess.patch_control_points); } diff --git a/src/freedreno/vulkan/tu_pipeline.h b/src/freedreno/vulkan/tu_pipeline.h index 906802d7556..dee0a93856a 100644 --- a/src/freedreno/vulkan/tu_pipeline.h +++ b/src/freedreno/vulkan/tu_pipeline.h @@ -209,6 +209,7 @@ struct tu_pipeline uint32_t vs_param_stride; uint32_t hs_param_stride; + uint32_t hs_param_dwords; uint32_t hs_vertices_out; uint32_t cs_instrlen; } program; @@ -295,8 +296,8 @@ void tu6_emit_vertex_input(struct tu_cs *cs, const VkVertexInputAttributeDescription2EXT *attrs); #define EMIT_CONST_DWORDS(const_dwords) (4 + const_dwords) -#define TU6_EMIT_PATCH_CONTROL_POINTS_DWORDS \ - (EMIT_CONST_DWORDS(4) + EMIT_CONST_DWORDS(8) + 2 + 2 + 2) +#define TU6_EMIT_PATCH_CONTROL_POINTS_DWORDS(hs_param_dwords) \ + (EMIT_CONST_DWORDS(4) + EMIT_CONST_DWORDS(hs_param_dwords) + 2 + 2 + 2) void tu6_emit_patch_control_points(struct tu_cs *cs, const struct tu_pipeline *pipeline, unsigned patch_control_points);