anv: only set 3DSTATE_CLIP::MaximumVPIndex once

Currently we can end up merging 2 prepacked 3DSTATE_CLIP instructions
where 2 different places in the driver fill the MaximumVPIndex.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 50f6903bd9 ("anv: add new low level emission & dirty state tracking")
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30684>
(cherry picked from commit 982106e676)
This commit is contained in:
Lionel Landwerlin 2024-08-07 10:17:00 +03:00 committed by Eric Engestrom
parent 98f760e17b
commit 9817d44c27
3 changed files with 22 additions and 21 deletions

View file

@ -1094,7 +1094,7 @@
"description": "anv: only set 3DSTATE_CLIP::MaximumVPIndex once",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "50f6903bd9c472eef2af2cbf62027df3bbe0ca8a",
"notes": null

View file

@ -1235,10 +1235,23 @@ genX(cmd_buffer_flush_gfx_runtime_state)(struct anv_cmd_buffer *cmd_buffer)
}
if ((gfx->dirty & ANV_CMD_DIRTY_RENDER_AREA) ||
(gfx->dirty & ANV_CMD_DIRTY_PIPELINE) ||
BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_VP_VIEWPORTS) ||
BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_VP_SCISSORS) ||
BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_RS_DEPTH_CLAMP_ENABLE) ||
BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_VP_DEPTH_CLIP_NEGATIVE_ONE_TO_ONE)) {
bool last_raster_stage_write_viewport;
if (anv_pipeline_is_primitive(pipeline)) {
const struct brw_vue_prog_data *last =
anv_pipeline_get_last_vue_prog_data(pipeline);
last_raster_stage_write_viewport =
(last->vue_map.slots_valid & VARYING_BIT_VIEWPORT) != 0;
} else {
const struct brw_mesh_prog_data *mesh_prog_data = get_mesh_prog_data(pipeline);
last_raster_stage_write_viewport =
mesh_prog_data->map.start_dw[VARYING_SLOT_VIEWPORT] >= 0;
}
struct anv_instance *instance = cmd_buffer->device->physical->instance;
const VkViewport *viewports = dyn->vp.viewports;
@ -1363,7 +1376,14 @@ genX(cmd_buffer_flush_gfx_runtime_state)(struct anv_cmd_buffer *cmd_buffer)
SET(VIEWPORT_CC, vp_cc.elem[i].MinimumDepth, min_depth);
SET(VIEWPORT_CC, vp_cc.elem[i].MaximumDepth, max_depth);
SET(CLIP, clip.MaximumVPIndex, dyn->vp.viewport_count > 0 ?
/* From the Vulkan 1.0.45 spec:
*
* "If the last active vertex processing stage shader entry
* point's interface does not include a variable decorated with
* ViewportIndex, then the first viewport is used."
*/
SET(CLIP, clip.MaximumVPIndex, (last_raster_stage_write_viewport &&
dyn->vp.viewport_count > 0) ?
dyn->vp.viewport_count - 1 : 0);
}

View file

@ -972,19 +972,6 @@ emit_3dstate_clip(struct anv_graphics_pipeline *pipeline,
const struct brw_vue_prog_data *last =
anv_pipeline_get_last_vue_prog_data(pipeline);
/* From the Vulkan 1.0.45 spec:
*
* "If the last active vertex processing stage shader entry
* point's interface does not include a variable decorated with
* ViewportIndex, then the first viewport is used."
*/
if (vp && (last->vue_map.slots_valid & VARYING_BIT_VIEWPORT)) {
clip.MaximumVPIndex = vp->viewport_count > 0 ?
vp->viewport_count - 1 : 0;
} else {
clip.MaximumVPIndex = 0;
}
/* From the Vulkan 1.0.45 spec:
*
* "If the last active vertex processing stage shader entry point's
@ -996,12 +983,6 @@ emit_3dstate_clip(struct anv_graphics_pipeline *pipeline,
} else if (anv_pipeline_is_mesh(pipeline)) {
const struct brw_mesh_prog_data *mesh_prog_data = get_mesh_prog_data(pipeline);
if (vp && vp->viewport_count > 0 &&
mesh_prog_data->map.start_dw[VARYING_SLOT_VIEWPORT] >= 0) {
clip.MaximumVPIndex = vp->viewport_count - 1;
} else {
clip.MaximumVPIndex = 0;
}
clip.ForceZeroRTAIndexEnable =
mesh_prog_data->map.start_dw[VARYING_SLOT_LAYER] < 0;