tu: Fix the size of patch control points state

tu6_emit_patch_control_points was called with CS size calculated
at compile time, but HS params have dynamic size. Account for this.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7479

Fixes: 68f3c38c80
("tu: Implement extendedDynamicState2PatchControlPoints")

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19075>
This commit is contained in:
Danylo Piliaiev
2022-10-14 16:00:17 +02:00
committed by Marge Bot
parent ebf7f7a182
commit 3eed5931ed
3 changed files with 20 additions and 9 deletions

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);