From 6e29757a57a83e2847ccd61e43e7bf44e791df26 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 22 Jan 2021 10:24:40 -0800 Subject: [PATCH] freedreno: Move blend gmem checks to a blend dirty state check. We don't need to do this every draw call. We do now consider the blend enable field of a non-present color buffer, because it's not worth filtering that case out. Part-of: --- src/gallium/drivers/freedreno/freedreno_draw.c | 14 +++++++++----- src/gallium/drivers/freedreno/freedreno_state.h | 10 ---------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index 723eb928b3b..61cbbf98a4a 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -105,8 +105,6 @@ batch_draw_tracking(struct fd_batch *batch, const struct pipe_draw_info *info, } } - if (fd_logicop_enabled(ctx)) - batch->gmem_reason |= FD_GMEM_LOGICOP_ENABLED; for (unsigned i = 0; i < pfb->nr_cbufs; i++) { struct pipe_resource *surf; @@ -124,13 +122,19 @@ batch_draw_tracking(struct fd_batch *batch, const struct pipe_draw_info *info, buffers |= PIPE_CLEAR_COLOR0 << i; - if (fd_blend_enabled(ctx, i)) - batch->gmem_reason |= FD_GMEM_BLEND_ENABLED; - if (ctx->dirty & FD_DIRTY_FRAMEBUFFER) resource_written(batch, pfb->cbufs[i]->texture); } + if (ctx->dirty & FD_DIRTY_BLEND) { + if (ctx->blend->logicop_enable) + batch->gmem_reason |= FD_GMEM_LOGICOP_ENABLED; + for (unsigned i = 0; i < pfb->nr_cbufs; i++) { + if (ctx->blend->rt[i].blend_enable) + batch->gmem_reason |= FD_GMEM_BLEND_ENABLED; + } + } + /* Mark SSBOs */ if (ctx->dirty_shader[PIPE_SHADER_FRAGMENT] & FD_DIRTY_SHADER_SSBO) { const struct fd_shaderbuf_stateobj *so = &ctx->shaderbuf[PIPE_SHADER_FRAGMENT]; diff --git a/src/gallium/drivers/freedreno/freedreno_state.h b/src/gallium/drivers/freedreno/freedreno_state.h index 57262104d35..b45a2daac32 100644 --- a/src/gallium/drivers/freedreno/freedreno_state.h +++ b/src/gallium/drivers/freedreno/freedreno_state.h @@ -45,16 +45,6 @@ static inline bool fd_stencil_enabled(struct fd_context *ctx) return ctx->zsa && ctx->zsa->stencil[0].enabled; } -static inline bool fd_logicop_enabled(struct fd_context *ctx) -{ - return ctx->blend && ctx->blend->logicop_enable; -} - -static inline bool fd_blend_enabled(struct fd_context *ctx, unsigned n) -{ - return ctx->blend && ctx->blend->rt[n].blend_enable; -} - static inline bool fd_depth_clamp_enabled(struct fd_context *ctx) { return !(ctx->rasterizer->depth_clip_near && ctx->rasterizer->depth_clip_far);