From 028987c80362eddd39176628486a456b076f0427 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Mon, 14 Mar 2011 16:58:27 -0400 Subject: [PATCH] r600g: emit SURFACE_BASE_UPDATE packet on rv6xx This packet is required when updating the DB, CB, or STRMOUT base addresses on rv6xx for the surface sync logic to work correctly. Signed-off-by: Alex Deucher --- src/gallium/winsys/r600/drm/r600_hw_context.c | 24 +++++++++++++++++-- src/gallium/winsys/r600/drm/r600d.h | 3 +++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/gallium/winsys/r600/drm/r600_hw_context.c b/src/gallium/winsys/r600/drm/r600_hw_context.c index 6b3baa2c909..ff662a2c857 100644 --- a/src/gallium/winsys/r600/drm/r600_hw_context.c +++ b/src/gallium/winsys/r600/drm/r600_hw_context.c @@ -760,6 +760,17 @@ out_err: return r; } +static void rv6xx_context_surface_base_update(struct r600_context *ctx, + unsigned base_update_flags) +{ + /* need to emit surface base update on rv6xx */ + if ((ctx->radeon->family > CHIP_R600) || + (ctx->radeon->family < CHIP_RV770)) { + ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_SURFACE_BASE_UPDATE, 0, 0); + ctx->pm4[ctx->pm4_cdwords++] = base_update_flags; + } +} + void r600_context_bo_flush(struct r600_context *ctx, unsigned flush_flags, unsigned flush_mask, struct r600_bo *rbo) { @@ -991,6 +1002,7 @@ void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw) unsigned ndwords = 9; struct r600_block *dirty_block = NULL; struct r600_block *next_block; + unsigned rv6xx_surface_base_update = 0; if (draw->indices) { ndwords = 13; @@ -1013,10 +1025,14 @@ void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw) for (int i = 0; i < 8; i++) { if (cb[i]) { ndwords += 7; + rv6xx_surface_base_update |= SURFACE_BASE_UPDATE_COLOR(i); } } - if (db) + if (db) { ndwords += 7; + rv6xx_surface_base_update |= SURFACE_BASE_UPDATE_DEPTH; + } + /* XXX also need to update SURFACE_BASE_UPDATE_STRMOUT when we support it */ /* queries need some special values */ if (ctx->num_query_running) { @@ -1043,10 +1059,14 @@ void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw) } /* enough room to copy packet */ - LIST_FOR_EACH_ENTRY_SAFE(dirty_block, next_block, &ctx->dirty,list) { + LIST_FOR_EACH_ENTRY_SAFE(dirty_block, next_block, &ctx->dirty, list) { r600_context_block_emit_dirty(ctx, dirty_block); } + /* rv6xx surface base udpate */ + if (rv6xx_surface_base_update) + rv6xx_context_surface_base_update(ctx, rv6xx_surface_base_update); + /* draw packet */ ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_INDEX_TYPE, 0, ctx->predicate_drawing); ctx->pm4[ctx->pm4_cdwords++] = draw->vgt_index_type; diff --git a/src/gallium/winsys/r600/drm/r600d.h b/src/gallium/winsys/r600/drm/r600d.h index cb12865ff01..80424818044 100644 --- a/src/gallium/winsys/r600/drm/r600d.h +++ b/src/gallium/winsys/r600/drm/r600d.h @@ -90,6 +90,9 @@ #define PKT3_SET_SAMPLER 0x6E #define PKT3_SET_CTL_CONST 0x6F #define PKT3_SURFACE_BASE_UPDATE 0x73 +#define SURFACE_BASE_UPDATE_DEPTH (1 << 0) +#define SURFACE_BASE_UPDATE_COLOR(x) (2 << (x)) +#define SURFACE_BASE_UPDATE_STRMOUT(x) (0x200 << (x)) #define EVENT_TYPE_PS_PARTIAL_FLUSH 0x10 #define EVENT_TYPE_CACHE_FLUSH_AND_INV_TS_EVENT 0x14 -- 2.30.2