anv: rework Wa_14017076903 to only apply with occlusion queries

Fixes KHR-GL46.transform_feedback.* tests with zink+anv on DG2

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: c34916f841 ("anv: implement occlusion query related Wa_14017076903")
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22586>
This commit is contained in:
Lionel Landwerlin 2023-04-19 22:58:16 +03:00 committed by Marge Bot
parent 8f23a5dd96
commit 56840e4c89
4 changed files with 40 additions and 11 deletions

View file

@ -2637,6 +2637,8 @@ struct anv_cmd_graphics_state {
bool object_preemption;
bool has_uint_rt;
uint32_t n_occlusion_queries;
};
enum anv_depth_reg_mode {

View file

@ -3260,6 +3260,39 @@ cmd_buffer_emit_streamout(struct anv_cmd_buffer *cmd_buffer)
.RenderStreamSelect = dyn->rs.rasterization_stream,
};
#if INTEL_NEEDS_WA_14017076903
/* Wa_14017076903 :
*
* SKL PRMs, Volume 7: 3D-Media-GPGPU, Stream Output Logic (SOL) Stage:
*
* SOL_INT::Render_Enable =
* (3DSTATE_STREAMOUT::Force_Rending == Force_On) ||
* (
* (3DSTATE_STREAMOUT::Force_Rending != Force_Off) &&
* !(3DSTATE_GS::Enable && 3DSTATE_GS::Output Vertex Size == 0) &&
* !3DSTATE_STREAMOUT::API_Render_Disable &&
* (
* 3DSTATE_DEPTH_STENCIL_STATE::Stencil_TestEnable ||
* 3DSTATE_DEPTH_STENCIL_STATE::Depth_TestEnable ||
* 3DSTATE_DEPTH_STENCIL_STATE::Depth_WriteEnable ||
* 3DSTATE_PS_EXTRA::PS_Valid ||
* 3DSTATE_WM::Legacy Depth_Buffer_Clear ||
* 3DSTATE_WM::Legacy Depth_Buffer_Resolve_Enable ||
* 3DSTATE_WM::Legacy Hierarchical_Depth_Buffer_Resolve_Enable
* )
* )
*
* If SOL_INT::Render_Enable is false, the SO stage will not forward any
* topologies down the pipeline. Which is not what we want for occlusion
* queries.
*
* Here we force rendering to get SOL_INT::Render_Enable when occlusion
* queries are active.
*/
if (!so.RenderingDisable && cmd_buffer->state.gfx.n_occlusion_queries > 0)
so.ForceRendering = Force_on;
#endif
switch (dyn->rs.provoking_vertex) {
case VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT:
so.ReorderMode = LEADING;
@ -3722,6 +3755,9 @@ genX(BeginCommandBuffer)(
*/
cmd_buffer->state.conditional_render_enabled =
conditional_rendering_info && conditional_rendering_info->conditionalRenderingEnable;
if (pBeginInfo->pInheritanceInfo->occlusionQueryEnable)
cmd_buffer->state.gfx.n_occlusion_queries = 1;
}
return VK_SUCCESS;

View file

@ -1112,17 +1112,6 @@ emit_3dstate_streamout(struct anv_graphics_pipeline *pipeline,
so.Stream2VertexReadLength = urb_entry_read_length - 1;
so.Stream3VertexReadOffset = urb_entry_read_offset;
so.Stream3VertexReadLength = urb_entry_read_length - 1;
#if INTEL_NEEDS_WA_14017076903
/* Wa_14017076903 : SOL should be programmed to force the
* rendering to be enabled.
*
* This fixes a rare case where SOL must render to get correct
* occlusion query results even when no PS and depth buffers are
* bound.
*/
so.ForceRendering = Force_on;
#endif
}
GENX(3DSTATE_STREAMOUT_pack)(NULL, pipeline->gfx8.streamout_state, &so);

View file

@ -1019,6 +1019,7 @@ void genX(CmdBeginQueryIndexedEXT)(
switch (pool->type) {
case VK_QUERY_TYPE_OCCLUSION:
cmd_buffer->state.gfx.n_occlusion_queries++;
emit_ps_depth_count(cmd_buffer, anv_address_add(query_addr, 8));
break;
@ -1210,6 +1211,7 @@ void genX(CmdEndQueryIndexedEXT)(
case VK_QUERY_TYPE_OCCLUSION:
emit_ps_depth_count(cmd_buffer, anv_address_add(query_addr, 16));
emit_query_pc_availability(cmd_buffer, query_addr, true);
cmd_buffer->state.gfx.n_occlusion_queries--;
break;
case VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT: