From 1d13f22174f690b95a14f1ef7158a655c00e24bd Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Wed, 3 May 2023 00:06:32 +0300 Subject: [PATCH] iris: rework Wa_14017076903 to only apply with occlusion queries MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Lionel Landwerlin Fixes: 415b824bc6 ("iris: implement occlusion query related Wa_14017076903") Reviewed-by: Tapani Pälli Part-of: --- src/gallium/drivers/iris/iris_context.h | 3 +++ src/gallium/drivers/iris/iris_query.c | 10 +++++++ src/gallium/drivers/iris/iris_state.c | 46 +++++++++++++++++++++++++-------- 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h index 2a2726a..9471081 100644 --- a/src/gallium/drivers/iris/iris_context.h +++ b/src/gallium/drivers/iris/iris_context.h @@ -850,6 +850,9 @@ struct iris_context { /** Is a PIPE_QUERY_PRIMITIVES_GENERATED query active? */ bool prims_generated_query_active; + /** Is a PIPE_QUERY_OCCLUSION_COUNTER query active? */ + bool occlusion_query_active; + /** 3DSTATE_STREAMOUT and 3DSTATE_SO_DECL_LIST packets */ uint32_t *streamout; diff --git a/src/gallium/drivers/iris/iris_query.c b/src/gallium/drivers/iris/iris_query.c index ac7df8f..a5c4c94 100644 --- a/src/gallium/drivers/iris/iris_query.c +++ b/src/gallium/drivers/iris/iris_query.c @@ -540,6 +540,11 @@ iris_begin_query(struct pipe_context *ctx, struct pipe_query *query) ice->state.dirty |= IRIS_DIRTY_STREAMOUT | IRIS_DIRTY_CLIP; } + if (q->type == PIPE_QUERY_OCCLUSION_COUNTER && q->index == 0) { + ice->state.occlusion_query_active = true; + ice->state.dirty |= IRIS_DIRTY_STREAMOUT; + } + if (q->type == PIPE_QUERY_SO_OVERFLOW_PREDICATE || q->type == PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE) write_overflow_values(ice, q, false); @@ -579,6 +584,11 @@ iris_end_query(struct pipe_context *ctx, struct pipe_query *query) ice->state.dirty |= IRIS_DIRTY_STREAMOUT | IRIS_DIRTY_CLIP; } + if (q->type == PIPE_QUERY_OCCLUSION_COUNTER && q->index == 0) { + ice->state.occlusion_query_active = false; + ice->state.dirty |= IRIS_DIRTY_STREAMOUT; + } + if (q->type == PIPE_QUERY_SO_OVERFLOW_PREDICATE || q->type == PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE) write_overflow_values(ice, q, true); diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index 502617e..96736c9 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -4316,17 +4316,6 @@ iris_create_so_decl_list(const struct pipe_stream_output_info *info, sol.Buffer1SurfacePitch = 4 * info->stride[1]; sol.Buffer2SurfacePitch = 4 * info->stride[2]; sol.Buffer3SurfacePitch = 4 * info->stride[3]; - -#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. - */ - sol.ForceRendering = Force_on; -#endif } iris_pack_command(GENX(3DSTATE_SO_DECL_LIST), so_decl_map, list) { @@ -6746,6 +6735,41 @@ iris_upload_dirty_render_state(struct iris_context *ice, sol.RenderingDisable = cso_rast->rasterizer_discard && !ice->state.prims_generated_query_active; sol.ReorderMode = cso_rast->flatshade_first ? LEADING : TRAILING; + + +#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. + */ + const struct iris_rasterizer_state *cso_rast = ice->state.cso_rast; + if (!cso_rast->rasterizer_discard && ice->state.occlusion_query_active) + sol.ForceRendering = Force_on; +#endif } assert(ice->state.streamout); -- 2.7.4