diff --git a/src/gallium/drivers/d3d12/d3d12_blit.cpp b/src/gallium/drivers/d3d12/d3d12_blit.cpp index e87ef87e750..6a5c962f995 100644 --- a/src/gallium/drivers/d3d12/d3d12_blit.cpp +++ b/src/gallium/drivers/d3d12/d3d12_blit.cpp @@ -25,6 +25,7 @@ #include "d3d12_compiler.h" #include "d3d12_debug.h" #include "d3d12_format.h" +#include "d3d12_query.h" #include "d3d12_resource.h" #include "d3d12_screen.h" @@ -956,8 +957,7 @@ d3d12_blit(struct pipe_context *pctx, util_format_short_name(info->dst.resource->format)); if (!info->render_condition_enable && ctx->current_predication) { - ctx->cmdlist->SetPredication( - d3d12_resource_resource(ctx->current_predication), 0, D3D12_PREDICATION_OP_EQUAL_ZERO); + d3d12_enable_predication(ctx); if (D3D12_DEBUG_BLIT & d3d12_debug) debug_printf("D3D12 BLIT: Re-enable predication\n"); } diff --git a/src/gallium/drivers/d3d12/d3d12_context.cpp b/src/gallium/drivers/d3d12/d3d12_context.cpp index 08fefc9d5a2..c2689168462 100644 --- a/src/gallium/drivers/d3d12/d3d12_context.cpp +++ b/src/gallium/drivers/d3d12/d3d12_context.cpp @@ -1908,9 +1908,7 @@ d3d12_clear_render_target(struct pipe_context *pctx, d3d12_batch_reference_surface_texture(d3d12_current_batch(ctx), surf); if (!render_condition_enabled && ctx->current_predication) { - ctx->cmdlist->SetPredication( - d3d12_resource_resource(ctx->current_predication), 0, - D3D12_PREDICATION_OP_EQUAL_ZERO); + d3d12_enable_predication(ctx); } } @@ -1951,9 +1949,7 @@ d3d12_clear_depth_stencil(struct pipe_context *pctx, d3d12_batch_reference_surface_texture(d3d12_current_batch(ctx), surf); if (!render_condition_enabled && ctx->current_predication) { - ctx->cmdlist->SetPredication( - d3d12_resource_resource(ctx->current_predication), 0, - D3D12_PREDICATION_OP_EQUAL_ZERO); + d3d12_enable_predication(ctx); } } diff --git a/src/gallium/drivers/d3d12/d3d12_context.h b/src/gallium/drivers/d3d12/d3d12_context.h index b37a74238ed..10e826f88fb 100644 --- a/src/gallium/drivers/d3d12/d3d12_context.h +++ b/src/gallium/drivers/d3d12/d3d12_context.h @@ -246,6 +246,7 @@ struct d3d12_context { struct d3d12_validation_tools *validation_tools; struct d3d12_resource *current_predication; + bool predication_condition; #ifdef __cplusplus ResourceStateManager *resource_state_manager; diff --git a/src/gallium/drivers/d3d12/d3d12_query.cpp b/src/gallium/drivers/d3d12/d3d12_query.cpp index 5b279d8a36f..32141016ae2 100644 --- a/src/gallium/drivers/d3d12/d3d12_query.cpp +++ b/src/gallium/drivers/d3d12/d3d12_query.cpp @@ -503,13 +503,20 @@ d3d12_render_condition(struct pipe_context *pctx, d3d12_apply_resource_states(ctx); ctx->current_predication = query->predicate; + ctx->predication_condition = condition; + d3d12_enable_predication(ctx); +} + +void +d3d12_enable_predication(struct d3d12_context *ctx) +{ /* documentation of ID3D12GraphicsCommandList::SetPredication method: - * "resource manipulation commands are _not_ actually performed - * if the resulting predicate data of the predicate is equal to - * the operation specified." - */ - ctx->cmdlist->SetPredication(d3d12_resource_resource(query->predicate), 0, - condition ? D3D12_PREDICATION_OP_NOT_EQUAL_ZERO : + * "resource manipulation commands are _not_ actually performed + * if the resulting predicate data of the predicate is equal to + * the operation specified." + */ + ctx->cmdlist->SetPredication(d3d12_resource_resource(ctx->current_predication), 0, + ctx->predication_condition ? D3D12_PREDICATION_OP_NOT_EQUAL_ZERO : D3D12_PREDICATION_OP_EQUAL_ZERO); } diff --git a/src/gallium/drivers/d3d12/d3d12_query.h b/src/gallium/drivers/d3d12/d3d12_query.h index 61ce2250a4f..869bc49cc3e 100644 --- a/src/gallium/drivers/d3d12/d3d12_query.h +++ b/src/gallium/drivers/d3d12/d3d12_query.h @@ -35,4 +35,7 @@ d3d12_resume_queries(struct d3d12_context *ctx); void d3d12_validate_queries(struct d3d12_context *ctx); +void +d3d12_enable_predication(struct d3d12_context *ctx); + #endif