diff options
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r-- | src/gallium/winsys/i915/drm/i915_drm_winsys.h | 2 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/r600_bo.c | 2 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/r600_drm.c | 2 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/r600_hw_context.c | 122 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/r600_priv.h | 19 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/radeon_pciid.c | 5 | ||||
-rw-r--r-- | src/gallium/winsys/sw/Makefile | 4 | ||||
-rw-r--r-- | src/gallium/winsys/sw/wayland/Makefile | 13 | ||||
-rw-r--r-- | src/gallium/winsys/sw/wayland/wayland_sw_winsys.c | 285 | ||||
-rw-r--r-- | src/gallium/winsys/sw/wayland/wayland_sw_winsys.h | 41 |
10 files changed, 408 insertions, 87 deletions
diff --git a/src/gallium/winsys/i915/drm/i915_drm_winsys.h b/src/gallium/winsys/i915/drm/i915_drm_winsys.h index dae53c3e801..7f0d718bdb7 100644 --- a/src/gallium/winsys/i915/drm/i915_drm_winsys.h +++ b/src/gallium/winsys/i915/drm/i915_drm_winsys.h @@ -18,7 +18,7 @@ struct i915_drm_winsys struct i915_winsys base; boolean dump_cmd; - char *dump_raw_file; + const char *dump_raw_file; boolean send_cmd; int fd; /**< Drm file discriptor */ diff --git a/src/gallium/winsys/r600/drm/r600_bo.c b/src/gallium/winsys/r600/drm/r600_bo.c index 40d6ec4c625..100ee7cdb37 100644 --- a/src/gallium/winsys/r600/drm/r600_bo.c +++ b/src/gallium/winsys/r600/drm/r600_bo.c @@ -191,7 +191,7 @@ boolean r600_bo_get_winsys_handle(struct radeon *radeon, struct r600_bo *bo, whandle->stride = stride; switch(whandle->type) { case DRM_API_HANDLE_TYPE_KMS: - whandle->handle = r600_bo_get_handle(bo); + whandle->handle = bo->bo->handle; break; case DRM_API_HANDLE_TYPE_SHARED: if (radeon_bo_get_name(radeon, bo->bo, &whandle->handle)) diff --git a/src/gallium/winsys/r600/drm/r600_drm.c b/src/gallium/winsys/r600/drm/r600_drm.c index ddd8ee3d6dd..311324f4f71 100644 --- a/src/gallium/winsys/r600/drm/r600_drm.c +++ b/src/gallium/winsys/r600/drm/r600_drm.c @@ -199,7 +199,6 @@ static int radeon_get_clock_crystal_freq(struct radeon *radeon) uint32_t clock_crystal_freq; int r; - radeon->device = 0; info.request = RADEON_INFO_CLOCK_CRYSTAL_FREQ; info.value = (uintptr_t)&clock_crystal_freq; r = drmCommandWriteRead(radeon->fd, DRM_RADEON_INFO, &info, @@ -218,7 +217,6 @@ static int radeon_get_num_backends(struct radeon *radeon) uint32_t num_backends; int r; - radeon->device = 0; info.request = RADEON_INFO_NUM_BACKENDS; info.value = (uintptr_t)&num_backends; r = drmCommandWriteRead(radeon->fd, DRM_RADEON_INFO, &info, diff --git a/src/gallium/winsys/r600/drm/r600_hw_context.c b/src/gallium/winsys/r600/drm/r600_hw_context.c index 935ac07802e..34ea2a6bacb 100644 --- a/src/gallium/winsys/r600/drm/r600_hw_context.c +++ b/src/gallium/winsys/r600/drm/r600_hw_context.c @@ -127,10 +127,20 @@ int r600_context_add_block(struct r600_context *ctx, const struct r600_reg *reg, block->pm4_bo_index[j] = block->nbo; block->pm4[block->pm4_ndwords++] = PKT3(PKT3_NOP, 0, 0); block->pm4[block->pm4_ndwords++] = 0x00000000; - block->reloc[block->nbo].flush_flags = reg[i+j].flush_flags; - block->reloc[block->nbo].flush_mask = reg[i+j].flush_mask; + if (reg[i+j].flags & REG_FLAG_RV6XX_SBU) { + block->reloc[block->nbo].flush_flags = 0; + block->reloc[block->nbo].flush_mask = 0; + } else { + block->reloc[block->nbo].flush_flags = reg[i+j].flush_flags; + block->reloc[block->nbo].flush_mask = reg[i+j].flush_mask; + } block->reloc[block->nbo].bo_pm4_index = block->pm4_ndwords - 1; } + if ((ctx->radeon->family > CHIP_R600) && + (ctx->radeon->family < CHIP_RV770) && reg[i+j].flags & REG_FLAG_RV6XX_SBU) { + block->pm4[block->pm4_ndwords++] = PKT3(PKT3_SURFACE_BASE_UPDATE, 0, 0); + block->pm4[block->pm4_ndwords++] = reg[i+j].flush_flags; + } } for (j = 0; j < n; j++) { if (reg[i+j].flush_flags) { @@ -197,7 +207,7 @@ static const struct r600_reg r600_context_reg_list[] = { {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028028_DB_STENCIL_CLEAR, 0, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_02802C_DB_DEPTH_CLEAR, 0, 0, 0}, {0, 0, GROUP_FORCE_NEW_BLOCK, 0, 0, 0}, - {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028040_CB_COLOR0_BASE, REG_FLAG_NEED_BO, 0, 0}, + {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028040_CB_COLOR0_BASE, REG_FLAG_NEED_BO|REG_FLAG_RV6XX_SBU, SURFACE_BASE_UPDATE_COLOR(0), 0}, {0, 0, GROUP_FORCE_NEW_BLOCK, 0, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_0280A0_CB_COLOR0_INFO, REG_FLAG_NEED_BO, 0, 0xFFFFFFFF}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028060_CB_COLOR0_SIZE, 0, 0, 0}, @@ -208,7 +218,7 @@ static const struct r600_reg r600_context_reg_list[] = { {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_0280C0_CB_COLOR0_TILE, REG_FLAG_NEED_BO, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028100_CB_COLOR0_MASK, 0, 0, 0}, {0, 0, GROUP_FORCE_NEW_BLOCK, 0, 0, 0}, - {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028044_CB_COLOR1_BASE, REG_FLAG_NEED_BO, 0, 0}, + {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028044_CB_COLOR1_BASE, REG_FLAG_NEED_BO|REG_FLAG_RV6XX_SBU, SURFACE_BASE_UPDATE_COLOR(1), 0}, {0, 0, GROUP_FORCE_NEW_BLOCK, 0, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_0280A4_CB_COLOR1_INFO, REG_FLAG_NEED_BO, 0, 0xFFFFFFFF}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028064_CB_COLOR1_SIZE, 0, 0, 0}, @@ -219,7 +229,7 @@ static const struct r600_reg r600_context_reg_list[] = { {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_0280C4_CB_COLOR1_TILE, REG_FLAG_NEED_BO, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028104_CB_COLOR1_MASK, 0, 0, 0}, {0, 0, GROUP_FORCE_NEW_BLOCK, 0, 0, 0}, - {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028048_CB_COLOR2_BASE, REG_FLAG_NEED_BO, 0, 0}, + {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028048_CB_COLOR2_BASE, REG_FLAG_NEED_BO|REG_FLAG_RV6XX_SBU, SURFACE_BASE_UPDATE_COLOR(2), 0}, {0, 0, GROUP_FORCE_NEW_BLOCK, 0, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_0280A8_CB_COLOR2_INFO, REG_FLAG_NEED_BO, 0, 0xFFFFFFFF}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028068_CB_COLOR2_SIZE, 0, 0, 0}, @@ -230,7 +240,7 @@ static const struct r600_reg r600_context_reg_list[] = { {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_0280C8_CB_COLOR2_TILE, REG_FLAG_NEED_BO, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028108_CB_COLOR2_MASK, 0, 0, 0}, {0, 0, GROUP_FORCE_NEW_BLOCK, 0, 0, 0}, - {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_02804C_CB_COLOR3_BASE, REG_FLAG_NEED_BO, 0, 0}, + {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_02804C_CB_COLOR3_BASE, REG_FLAG_NEED_BO|REG_FLAG_RV6XX_SBU, SURFACE_BASE_UPDATE_COLOR(3), 0}, {0, 0, GROUP_FORCE_NEW_BLOCK, 0, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_0280AC_CB_COLOR3_INFO, REG_FLAG_NEED_BO, 0, 0xFFFFFFFF}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_02806C_CB_COLOR3_SIZE, 0, 0, 0}, @@ -241,7 +251,7 @@ static const struct r600_reg r600_context_reg_list[] = { {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_0280CC_CB_COLOR3_TILE, REG_FLAG_NEED_BO, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_02810C_CB_COLOR3_MASK, 0, 0, 0}, {0, 0, GROUP_FORCE_NEW_BLOCK, 0, 0, 0}, - {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028050_CB_COLOR4_BASE, REG_FLAG_NEED_BO, 0, 0}, + {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028050_CB_COLOR4_BASE, REG_FLAG_NEED_BO|REG_FLAG_RV6XX_SBU, SURFACE_BASE_UPDATE_COLOR(4), 0}, {0, 0, GROUP_FORCE_NEW_BLOCK, 0, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_0280B0_CB_COLOR4_INFO, REG_FLAG_NEED_BO, 0, 0xFFFFFFFF}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028070_CB_COLOR4_SIZE, 0, 0, 0}, @@ -252,7 +262,7 @@ static const struct r600_reg r600_context_reg_list[] = { {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_0280D0_CB_COLOR4_TILE, REG_FLAG_NEED_BO, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028110_CB_COLOR4_MASK, 0, 0, 0}, {0, 0, GROUP_FORCE_NEW_BLOCK, 0, 0, 0}, - {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028054_CB_COLOR5_BASE, REG_FLAG_NEED_BO, 0, 0}, + {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028054_CB_COLOR5_BASE, REG_FLAG_NEED_BO|REG_FLAG_RV6XX_SBU, SURFACE_BASE_UPDATE_COLOR(5), 0}, {0, 0, GROUP_FORCE_NEW_BLOCK, 0, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_0280B4_CB_COLOR5_INFO, REG_FLAG_NEED_BO, 0, 0xFFFFFFFF}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028074_CB_COLOR5_SIZE, 0, 0, 0}, @@ -262,7 +272,7 @@ static const struct r600_reg r600_context_reg_list[] = { {0, 0, GROUP_FORCE_NEW_BLOCK, 0, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_0280D4_CB_COLOR5_TILE, REG_FLAG_NEED_BO, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028114_CB_COLOR5_MASK, 0, 0, 0}, - {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028058_CB_COLOR6_BASE, REG_FLAG_NEED_BO, 0, 0}, + {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028058_CB_COLOR6_BASE, REG_FLAG_NEED_BO|REG_FLAG_RV6XX_SBU, SURFACE_BASE_UPDATE_COLOR(6), 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_0280B8_CB_COLOR6_INFO, REG_FLAG_NEED_BO, 0, 0xFFFFFFFF}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028078_CB_COLOR6_SIZE, 0, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028098_CB_COLOR6_VIEW, 0, 0, 0}, @@ -272,7 +282,7 @@ static const struct r600_reg r600_context_reg_list[] = { {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_0280D8_CB_COLOR6_TILE, REG_FLAG_NEED_BO, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028118_CB_COLOR6_MASK, 0, 0, 0}, {0, 0, GROUP_FORCE_NEW_BLOCK, 0, 0, 0}, - {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_02805C_CB_COLOR7_BASE, REG_FLAG_NEED_BO, 0, 0}, + {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_02805C_CB_COLOR7_BASE, REG_FLAG_NEED_BO|REG_FLAG_RV6XX_SBU, SURFACE_BASE_UPDATE_COLOR(7), 0}, {0, 0, GROUP_FORCE_NEW_BLOCK, 0, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_0280BC_CB_COLOR7_INFO, REG_FLAG_NEED_BO, 0, 0xFFFFFFFF}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_02807C_CB_COLOR7_SIZE, 0, 0, 0}, @@ -327,7 +337,7 @@ static const struct r600_reg r600_context_reg_list[] = { {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028C48_PA_SC_AA_MASK, 0, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028D2C_DB_SRESULTS_COMPARE_STATE1, 0, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028D44_DB_ALPHA_TO_MASK, 0, 0, 0}, - {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_02800C_DB_DEPTH_BASE, REG_FLAG_NEED_BO, 0, 0}, + {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_02800C_DB_DEPTH_BASE, REG_FLAG_NEED_BO|REG_FLAG_RV6XX_SBU, SURFACE_BASE_UPDATE_DEPTH, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028000_DB_DEPTH_SIZE, 0, 0, 0}, {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, R_028004_DB_DEPTH_VIEW, 0, 0, 0}, {0, 0, GROUP_FORCE_NEW_BLOCK, 0, 0, 0}, @@ -766,17 +776,6 @@ 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; - } -} - /* Flushes all surfaces */ void r600_context_flush_all(struct r600_context *ctx, unsigned flush_flags) { @@ -798,19 +797,40 @@ void r600_context_bo_flush(struct r600_context *ctx, unsigned flush_flags, unsigned flush_mask, struct r600_bo *rbo) { struct radeon_bo *bo; - bo = r600_bo_get_bo(rbo); + + bo = rbo->bo; /* if bo has already been flushed */ if (!(~bo->last_flush & flush_flags)) { bo->last_flush &= flush_mask; return; } - ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_SURFACE_SYNC, 3, ctx->predicate_drawing); - ctx->pm4[ctx->pm4_cdwords++] = flush_flags; - ctx->pm4[ctx->pm4_cdwords++] = (bo->size + 255) >> 8; - ctx->pm4[ctx->pm4_cdwords++] = 0x00000000; - ctx->pm4[ctx->pm4_cdwords++] = 0x0000000A; - ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_NOP, 0, ctx->predicate_drawing); - ctx->pm4[ctx->pm4_cdwords++] = bo->reloc_id; + + if ((ctx->radeon->family < CHIP_RV770) && + (G_0085F0_CB_ACTION_ENA(flush_flags) || + G_0085F0_DB_ACTION_ENA(flush_flags))) { + if (ctx->flags & R600_CONTEXT_CHECK_EVENT_FLUSH) { + /* the rv670 seems to fail fbo-generatemipmap unless we flush the CB1 dest base ena */ + if (ctx->radeon->family == CHIP_RV670) { + ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_SURFACE_SYNC, 3, ctx->predicate_drawing); + ctx->pm4[ctx->pm4_cdwords++] = S_0085F0_CB1_DEST_BASE_ENA(1); /* CP_COHER_CNTL */ + ctx->pm4[ctx->pm4_cdwords++] = 0xffffffff; /* CP_COHER_SIZE */ + ctx->pm4[ctx->pm4_cdwords++] = 0; /* CP_COHER_BASE */ + ctx->pm4[ctx->pm4_cdwords++] = 0x0000000A; /* POLL_INTERVAL */ + } + + ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_EVENT_WRITE, 0, ctx->predicate_drawing); + ctx->pm4[ctx->pm4_cdwords++] = EVENT_TYPE(EVENT_TYPE_CACHE_FLUSH_AND_INV_EVENT) | EVENT_INDEX(0); + ctx->flags &= ~R600_CONTEXT_CHECK_EVENT_FLUSH; + } + } else { + ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_SURFACE_SYNC, 3, ctx->predicate_drawing); + ctx->pm4[ctx->pm4_cdwords++] = flush_flags; + ctx->pm4[ctx->pm4_cdwords++] = (bo->size + 255) >> 8; + ctx->pm4[ctx->pm4_cdwords++] = 0x00000000; + ctx->pm4[ctx->pm4_cdwords++] = 0x0000000A; + ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_NOP, 0, ctx->predicate_drawing); + ctx->pm4[ctx->pm4_cdwords++] = bo->reloc_id; + } bo->last_flush = (bo->last_flush | flush_flags) & flush_mask; } @@ -818,7 +838,7 @@ void r600_context_bo_reloc(struct r600_context *ctx, u32 *pm4, struct r600_bo *r { struct radeon_bo *bo; - bo = r600_bo_get_bo(rbo); + bo = rbo->bo; assert(bo != NULL); if (bo->reloc) { *pm4 = bo->reloc_id; @@ -1120,6 +1140,7 @@ void r600_context_block_emit_dirty(struct r600_context *ctx, struct r600_block * goto out; } + ctx->flags |= R600_CONTEXT_CHECK_EVENT_FLUSH; for (int j = 0; j < block->nreg; j++) { if (block->pm4_bo_index[j]) { /* find relocation */ @@ -1135,6 +1156,7 @@ void r600_context_block_emit_dirty(struct r600_context *ctx, struct r600_block * } } } + ctx->flags &= ~R600_CONTEXT_CHECK_EVENT_FLUSH; memcpy(&ctx->pm4[ctx->pm4_cdwords], block->pm4, block->pm4_ndwords * 4); ctx->pm4_cdwords += block->pm4_ndwords; @@ -1158,6 +1180,7 @@ void r600_context_flush_dest_caches(struct r600_context *ctx) { struct r600_bo *cb[8]; struct r600_bo *db; + int i; if (!(ctx->flags & R600_CONTEXT_DST_CACHES_DIRTY)) return; @@ -1172,8 +1195,9 @@ void r600_context_flush_dest_caches(struct r600_context *ctx) cb[6] = r600_context_reg_bo(ctx, R_028058_CB_COLOR6_BASE); cb[7] = r600_context_reg_bo(ctx, R_02805C_CB_COLOR7_BASE); + ctx->flags |= R600_CONTEXT_CHECK_EVENT_FLUSH; /* flush the color buffers */ - for (int i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) { if (!cb[i]) continue; @@ -1185,7 +1209,7 @@ void r600_context_flush_dest_caches(struct r600_context *ctx) if (db) { r600_context_bo_flush(ctx, S_0085F0_DB_ACTION_ENA(1), 0, db); } - + ctx->flags &= ~R600_CONTEXT_CHECK_EVENT_FLUSH; ctx->flags &= ~R600_CONTEXT_DST_CACHES_DIRTY; } @@ -1194,7 +1218,6 @@ void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw) unsigned ndwords = 7; struct r600_block *dirty_block = NULL; struct r600_block *next_block; - unsigned rv6xx_surface_base_update = 0; if (draw->indices) { ndwords = 11; @@ -1204,33 +1227,6 @@ void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw) } } - /* rv6xx surface base update */ - if ((ctx->radeon->family > CHIP_R600) && - (ctx->radeon->family < CHIP_RV770)) { - struct r600_bo *cb[8]; - struct r600_bo *db; - - db = r600_context_reg_bo(ctx, R_02800C_DB_DEPTH_BASE); - cb[0] = r600_context_reg_bo(ctx, R_028040_CB_COLOR0_BASE); - cb[1] = r600_context_reg_bo(ctx, R_028044_CB_COLOR1_BASE); - cb[2] = r600_context_reg_bo(ctx, R_028048_CB_COLOR2_BASE); - cb[3] = r600_context_reg_bo(ctx, R_02804C_CB_COLOR3_BASE); - cb[4] = r600_context_reg_bo(ctx, R_028050_CB_COLOR4_BASE); - cb[5] = r600_context_reg_bo(ctx, R_028054_CB_COLOR5_BASE); - cb[6] = r600_context_reg_bo(ctx, R_028058_CB_COLOR6_BASE); - cb[7] = r600_context_reg_bo(ctx, R_02805C_CB_COLOR7_BASE); - for (int i = 0; i < 8; i++) { - if (cb[i]) { - rv6xx_surface_base_update |= SURFACE_BASE_UPDATE_COLOR(i); - } - } - if (db) { - 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) { if (ctx->radeon->family >= CHIP_RV770) { @@ -1263,10 +1259,6 @@ void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw) 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/r600_priv.h b/src/gallium/winsys/r600/drm/r600_priv.h index ed0f3e584d3..f8363f9272b 100644 --- a/src/gallium/winsys/r600/drm/r600_priv.h +++ b/src/gallium/winsys/r600/drm/r600_priv.h @@ -64,6 +64,7 @@ struct radeon { #define REG_FLAG_NEED_BO 1 #define REG_FLAG_DIRTY_ALWAYS 2 +#define REG_FLAG_RV6XX_SBU 4 struct r600_reg { unsigned opcode; @@ -202,24 +203,6 @@ static inline void radeon_bo_unmap(struct radeon *radeon, struct radeon_bo *bo) } /* - * r600_bo - */ -static inline struct radeon_bo *r600_bo_get_bo(struct r600_bo *bo) -{ - return bo->bo; -} - -static unsigned inline r600_bo_get_handle(struct r600_bo *bo) -{ - return bo->bo->handle; -} - -static unsigned inline r600_bo_get_size(struct r600_bo *bo) -{ - return bo->size; -} - -/* * fence */ static inline bool fence_is_after(unsigned fence, unsigned ofence) diff --git a/src/gallium/winsys/r600/drm/radeon_pciid.c b/src/gallium/winsys/r600/drm/radeon_pciid.c index 146d6bd3100..35db37aa1fd 100644 --- a/src/gallium/winsys/r600/drm/radeon_pciid.c +++ b/src/gallium/winsys/r600/drm/radeon_pciid.c @@ -177,6 +177,7 @@ static const struct pci_id radeon_pci_id[] = { {0x1002, 0x688A, CHIP_CYPRESS}, {0x1002, 0x6898, CHIP_CYPRESS}, {0x1002, 0x6899, CHIP_CYPRESS}, + {0x1002, 0x689b, CHIP_CYPRESS}, {0x1002, 0x689c, CHIP_HEMLOCK}, {0x1002, 0x689d, CHIP_HEMLOCK}, {0x1002, 0x689e, CHIP_CYPRESS}, @@ -187,7 +188,9 @@ static const struct pci_id radeon_pci_id[] = { {0x1002, 0x68b0, CHIP_JUNIPER}, {0x1002, 0x68b8, CHIP_JUNIPER}, {0x1002, 0x68b9, CHIP_JUNIPER}, + {0x1002, 0x68ba, CHIP_JUNIPER}, {0x1002, 0x68be, CHIP_JUNIPER}, + {0x1002, 0x68bf, CHIP_JUNIPER}, {0x1002, 0x68c0, CHIP_REDWOOD}, {0x1002, 0x68c1, CHIP_REDWOOD}, {0x1002, 0x68c8, CHIP_REDWOOD}, @@ -203,6 +206,7 @@ static const struct pci_id radeon_pci_id[] = { {0x1002, 0x68e8, CHIP_CEDAR}, {0x1002, 0x68e9, CHIP_CEDAR}, {0x1002, 0x68f1, CHIP_CEDAR}, + {0x1002, 0x68f2, CHIP_CEDAR}, {0x1002, 0x68f8, CHIP_CEDAR}, {0x1002, 0x68f9, CHIP_CEDAR}, {0x1002, 0x68fe, CHIP_CEDAR}, @@ -459,6 +463,7 @@ static const struct pci_id radeon_pci_id[] = { {0x1002, 0x6729, CHIP_BARTS}, {0x1002, 0x6738, CHIP_BARTS}, {0x1002, 0x6739, CHIP_BARTS}, + {0x1002, 0x673e, CHIP_BARTS}, {0x1002, 0x6740, CHIP_TURKS}, {0x1002, 0x6741, CHIP_TURKS}, {0x1002, 0x6742, CHIP_TURKS}, diff --git a/src/gallium/winsys/sw/Makefile b/src/gallium/winsys/sw/Makefile index 094e811d57d..2fad717eb16 100644 --- a/src/gallium/winsys/sw/Makefile +++ b/src/gallium/winsys/sw/Makefile @@ -14,6 +14,10 @@ ifneq ($(findstring fbdev, $(EGL_PLATFORMS)),) SUBDIRS += fbdev endif +ifneq ($(findstring wayland, $(EGL_PLATFORMS)),) +SUBDIRS += wayland +endif + default install clean: @for dir in $(SUBDIRS) ; do \ if [ -d $$dir ] ; then \ diff --git a/src/gallium/winsys/sw/wayland/Makefile b/src/gallium/winsys/sw/wayland/Makefile new file mode 100644 index 00000000000..b3f2081686e --- /dev/null +++ b/src/gallium/winsys/sw/wayland/Makefile @@ -0,0 +1,13 @@ +TOP = ../../../../.. +include $(TOP)/configs/current + +LIBNAME = ws_wayland + +LIBRARY_INCLUDES = $(WAYLAND_CFLAGS) + +LIBRARY_DEFINES = + +C_SOURCES = \ + wayland_sw_winsys.c + +include ../../../Makefile.template diff --git a/src/gallium/winsys/sw/wayland/wayland_sw_winsys.c b/src/gallium/winsys/sw/wayland/wayland_sw_winsys.c new file mode 100644 index 00000000000..1a31ada0296 --- /dev/null +++ b/src/gallium/winsys/sw/wayland/wayland_sw_winsys.c @@ -0,0 +1,285 @@ +/* + * Mesa 3-D graphics library + * Version: 7.11 + * + * Copyright (C) 2011 Benjamin Franzke <[email protected]> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include <stdlib.h> +#include <sys/types.h> +#include <sys/mman.h> +#include <unistd.h> + +#include "pipe/p_compiler.h" +#include "pipe/p_defines.h" +#include "pipe/p_state.h" +#include "util/u_format.h" +#include "util/u_math.h" +#include "util/u_memory.h" +#include "state_tracker/sw_winsys.h" + +#include <wayland-client.h> +#include "wayland_sw_winsys.h" + +struct wayland_sw_displaytarget +{ + int fd; + unsigned size; + + unsigned width; + unsigned height; + unsigned stride; + + enum pipe_format format; + + void *map; + unsigned map_count; +}; + +struct wayland_sw_winsys +{ + struct sw_winsys base; + + struct wl_display *display; +}; + +static INLINE struct wayland_sw_displaytarget * +wayland_sw_displaytarget(struct sw_displaytarget *dt) +{ + return (struct wayland_sw_displaytarget *) dt; +} + +static INLINE struct wayland_sw_winsys * +wayland_sw_winsys(struct sw_winsys *ws) +{ + return (struct wayland_sw_winsys *) ws; +} + +static void +wayland_displaytarget_display(struct sw_winsys *ws, + struct sw_displaytarget *dt, + void *context_private) +{ +} + +static void +wayland_displaytarget_unmap(struct sw_winsys *ws, + struct sw_displaytarget *dt) +{ + struct wayland_sw_displaytarget *wldt = wayland_sw_displaytarget(dt); + + wldt->map_count--; + if (wldt->map_count > 0) + return; + + munmap(wldt->map, wldt->size); + wldt->map = NULL; +} + +static void * +wayland_displaytarget_map(struct sw_winsys *ws, + struct sw_displaytarget *dt, + unsigned flags) +{ + struct wayland_sw_displaytarget *wldt = wayland_sw_displaytarget(dt); + uint mmap_flags = 0; + + if (wldt->map) { + wldt->map_count++; + return wldt->map; + } + + if (flags & PIPE_TRANSFER_READ) + mmap_flags |= PROT_READ; + if (flags & PIPE_TRANSFER_WRITE) + mmap_flags |= PROT_WRITE; + + wldt->map = mmap(NULL, wldt->size, mmap_flags, + MAP_SHARED, wldt->fd, 0); + + if (wldt->map == MAP_FAILED) + return NULL; + + wldt->map_count = 1; + + return wldt->map; +} + +static void +wayland_displaytarget_destroy(struct sw_winsys *ws, + struct sw_displaytarget *dt) +{ + struct wayland_sw_displaytarget *wldt = wayland_sw_displaytarget(dt); + + if (wldt->map) + wayland_displaytarget_unmap(ws, dt); + + FREE(wldt); +} + +static boolean +wayland_is_displaytarget_format_supported(struct sw_winsys *ws, + unsigned tex_usage, + enum pipe_format format) +{ + switch (format) { + case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: + return TRUE; + default: + return FALSE; + } +} + +static struct sw_displaytarget * +wayland_displaytarget_create(struct sw_winsys *ws, + unsigned tex_usage, + enum pipe_format format, + unsigned width, unsigned height, + unsigned alignment, + unsigned *stride) +{ + struct wayland_sw_displaytarget *wldt; + unsigned nblocksy, format_stride; + char filename[] = "/tmp/wayland-shm-XXXXXX"; + + if (!wayland_is_displaytarget_format_supported(ws, tex_usage, format)) + return NULL; + + wldt = CALLOC_STRUCT(wayland_sw_displaytarget); + if (!wldt) + return NULL; + + wldt->map = NULL; + + wldt->format = format; + wldt->width = width; + wldt->height = height; + + format_stride = util_format_get_stride(format, width); + wldt->stride = align(format_stride, alignment); + + nblocksy = util_format_get_nblocksy(format, height); + wldt->size = wldt->stride * nblocksy; + + wldt->fd = mkstemp(filename); + if (wldt->fd < 0) { + FREE(wldt); + return NULL; + } + + if (ftruncate(wldt->fd, wldt->size) < 0) { + unlink(filename); + close(wldt->fd); + FREE(wldt); + return NULL; + } + + unlink(filename); + + *stride = wldt->stride; + + return (struct sw_displaytarget *) wldt; +} + +static struct sw_displaytarget * +wayland_displaytarget_from_handle(struct sw_winsys *ws, + const struct pipe_resource *templet, + struct winsys_handle *whandle, + unsigned *stride) +{ + struct wayland_sw_displaytarget *wldt; + unsigned nblocksy; + + if (!wayland_is_displaytarget_format_supported(ws, 0, templet->format)) + return NULL; + + wldt = CALLOC_STRUCT(wayland_sw_displaytarget); + if (!wldt) + return NULL; + + wldt->fd = whandle->fd; + wldt->stride = whandle->stride; + wldt->width = templet->width0; + wldt->height = templet->height0; + wldt->format = templet->format; + + nblocksy = util_format_get_nblocksy(wldt->format, wldt->height); + + wldt->size = wldt->stride * nblocksy; + + wldt->map = NULL; + + *stride = wldt->stride; + + return (struct sw_displaytarget *) wldt; +} + + +static boolean +wayland_displaytarget_get_handle(struct sw_winsys *ws, + struct sw_displaytarget *dt, + struct winsys_handle *whandle) +{ + struct wayland_sw_displaytarget *wldt = wayland_sw_displaytarget(dt); + + whandle->fd = wldt->fd; + whandle->stride = wldt->stride; + + return TRUE; +} + +static void +wayland_destroy(struct sw_winsys *ws) +{ + struct wayland_sw_winsys *wayland = wayland_sw_winsys(ws); + + FREE(wayland); +} + +struct sw_winsys * +wayland_create_sw_winsys(struct wl_display *display) +{ + struct wayland_sw_winsys *wlws; + + wlws = CALLOC_STRUCT(wayland_sw_winsys); + if (!wlws) + return NULL; + + wlws->display = display; + + wlws->base.destroy = wayland_destroy; + wlws->base.is_displaytarget_format_supported = + wayland_is_displaytarget_format_supported; + + wlws->base.displaytarget_create = wayland_displaytarget_create; + wlws->base.displaytarget_from_handle = wayland_displaytarget_from_handle; + wlws->base.displaytarget_get_handle = wayland_displaytarget_get_handle; + wlws->base.displaytarget_destroy = wayland_displaytarget_destroy; + wlws->base.displaytarget_map = wayland_displaytarget_map; + wlws->base.displaytarget_unmap = wayland_displaytarget_unmap; + + wlws->base.displaytarget_display = wayland_displaytarget_display; + + return &wlws->base; +} + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/winsys/sw/wayland/wayland_sw_winsys.h b/src/gallium/winsys/sw/wayland/wayland_sw_winsys.h new file mode 100644 index 00000000000..5e3cfd0bf23 --- /dev/null +++ b/src/gallium/winsys/sw/wayland/wayland_sw_winsys.h @@ -0,0 +1,41 @@ +/* + * Mesa 3-D graphics library + * Version: 7.11 + * + * Copyright (C) 2011 Benjamin Franzke <[email protected]> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef WAYLAND_SW_WINSYS +#define WAYLAND_SW_WINSYS + +struct sw_winsys; + +struct winsys_handle { + int fd; + unsigned stride; +}; + +struct sw_winsys * +wayland_create_sw_winsys(struct wl_display *display); + +#endif /* WAYLAND_SW_WINSYS */ + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ |