mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2024-11-30 13:44:06 +08:00
anv: optimize CLIP::MaximumVPIndex setting
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11746 Fixes:982106e676
("anv: only set 3DSTATE_CLIP::MaximumVPIndex once") Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30762> (cherry picked from commita88898a28f
)
This commit is contained in:
parent
e2bb53fd0d
commit
c71baa2255
@ -2144,7 +2144,7 @@
|
||||
"description": "anv: optimize CLIP::MaximumVPIndex setting",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "982106e6768e6f69d71710e314325c813591452d",
|
||||
"notes": null
|
||||
|
@ -1104,28 +1104,35 @@ 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;
|
||||
|
||||
const float scale = dyn->vp.depth_clip_negative_one_to_one ? 0.5f : 1.0f;
|
||||
|
||||
/* 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."
|
||||
*
|
||||
* This could mean that we might need to set the MaximumVPIndex based on
|
||||
* the pipeline's last stage, but if the last shader doesn't write the
|
||||
* viewport index and the VUE header is used, the compiler will force
|
||||
* the value to 0 (which is what the spec requires above). Otherwise it
|
||||
* seems like the HW should be pulling 0 if the VUE header is not
|
||||
* present.
|
||||
*
|
||||
* Avoiding a check on the pipeline seems to prevent additional
|
||||
* emissions of 3DSTATE_CLIP which appear to impact performance on
|
||||
* Assassin's Creed Valhalla..
|
||||
*/
|
||||
SET(CLIP, clip.MaximumVPIndex, dyn->vp.viewport_count > 0 ?
|
||||
dyn->vp.viewport_count - 1 : 0);
|
||||
|
||||
for (uint32_t i = 0; i < dyn->vp.viewport_count; i++) {
|
||||
const VkViewport *vp = &viewports[i];
|
||||
|
||||
@ -1244,16 +1251,6 @@ 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);
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
/* If the HW state is already considered dirty or the previous
|
||||
|
Loading…
Reference in New Issue
Block a user