From 56840e4c895bcad6c498230c7a633760208122d9 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Wed, 19 Apr 2023 22:58:16 +0300 Subject: [PATCH] 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 Fixes: c34916f841d3 ("anv: implement occlusion query related Wa_14017076903") Reviewed-by: Kenneth Graunke Part-of: --- src/intel/vulkan/anv_private.h | 2 ++ src/intel/vulkan/genX_cmd_buffer.c | 36 ++++++++++++++++++++++++++++++++++++ src/intel/vulkan/genX_pipeline.c | 11 ----------- src/intel/vulkan/genX_query.c | 2 ++ 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index ac36d0d..04db528 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -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 { diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index 89b7545..62db883 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -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; diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c index cb94487..5f4a56f 100644 --- a/src/intel/vulkan/genX_pipeline.c +++ b/src/intel/vulkan/genX_pipeline.c @@ -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); diff --git a/src/intel/vulkan/genX_query.c b/src/intel/vulkan/genX_query.c index 9635332..4942099 100644 --- a/src/intel/vulkan/genX_query.c +++ b/src/intel/vulkan/genX_query.c @@ -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: -- 2.7.4