diff options
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r-- | src/gallium/winsys/r600/drm/r600_priv.h | 8 | ||||
-rw-r--r-- | src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 34 | ||||
-rw-r--r-- | src/gallium/winsys/radeon/drm/radeon_drm_bo.h | 3 | ||||
-rw-r--r-- | src/gallium/winsys/radeon/drm/radeon_drm_cs.c | 43 | ||||
-rw-r--r-- | src/gallium/winsys/radeon/drm/radeon_winsys.h | 18 |
5 files changed, 60 insertions, 46 deletions
diff --git a/src/gallium/winsys/r600/drm/r600_priv.h b/src/gallium/winsys/r600/drm/r600_priv.h index f1bbe38f0f7..1f18e0ee405 100644 --- a/src/gallium/winsys/r600/drm/r600_priv.h +++ b/src/gallium/winsys/r600/drm/r600_priv.h @@ -74,15 +74,11 @@ int r600_resource_init(struct r600_context *ctx, struct r600_range *range, unsig static INLINE unsigned r600_context_bo_reloc(struct r600_context *ctx, struct r600_resource *rbo, enum radeon_bo_usage usage) { - enum radeon_bo_domain rd = usage & RADEON_USAGE_READ ? rbo->domains : 0; - enum radeon_bo_domain wd = usage & RADEON_USAGE_WRITE ? rbo->domains : 0; + unsigned reloc_index; assert(usage); - unsigned reloc_index = - ctx->screen->ws->cs_add_reloc(ctx->cs, rbo->cs_buf, - rd, wd); - + reloc_index = ctx->screen->ws->cs_add_reloc(ctx->cs, rbo->cs_buf, usage); if (reloc_index >= ctx->creloc) ctx->creloc = reloc_index+1; diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c index 20139b42c68..2dca3b9d958 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c @@ -336,6 +336,12 @@ static struct pb_buffer *radeon_bomgr_create_bo(struct pb_manager *_mgr, struct drm_radeon_gem_create args = {}; struct radeon_bo_desc *rdesc = (struct radeon_bo_desc*)desc; + assert(rdesc->initial_domains && rdesc->reloc_domains); + assert((rdesc->initial_domains & + ~(RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM)) == 0); + assert((rdesc->reloc_domains & + ~(RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM)) == 0); + args.size = size; args.alignment = desc->alignment; args.initial_domain = rdesc->initial_domains; @@ -361,6 +367,7 @@ static struct pb_buffer *radeon_bomgr_create_bo(struct pb_manager *_mgr, bo->mgr = mgr; bo->rws = mgr->rws; bo->handle = args.handle; + bo->reloc_domains = rdesc->reloc_domains; pipe_mutex_init(bo->map_mutex); return &bo->base; @@ -505,8 +512,7 @@ static struct pb_buffer * radeon_winsys_bo_create(struct radeon_winsys *rws, unsigned size, unsigned alignment, - unsigned bind, - enum radeon_bo_domain domain) + unsigned bind, unsigned usage) { struct radeon_drm_winsys *ws = radeon_drm_winsys(rws); struct radeon_bo_desc desc; @@ -515,8 +521,27 @@ radeon_winsys_bo_create(struct radeon_winsys *rws, memset(&desc, 0, sizeof(desc)); desc.base.alignment = alignment; - desc.base.usage = domain; - desc.initial_domains = domain; + + /* Determine the memory domains. */ + switch (usage) { + case PIPE_USAGE_STAGING: + case PIPE_USAGE_STREAM: + case PIPE_USAGE_DYNAMIC: + desc.initial_domains = RADEON_GEM_DOMAIN_GTT; + desc.reloc_domains = RADEON_GEM_DOMAIN_GTT; + break; + default: + if (bind & (PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER | + PIPE_BIND_CONSTANT_BUFFER)) { + desc.initial_domains = RADEON_GEM_DOMAIN_GTT; + } else { + desc.initial_domains = RADEON_GEM_DOMAIN_VRAM; + } + desc.reloc_domains = RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM; + } + + /* Additional criteria for the cache manager. */ + desc.base.usage = desc.initial_domains; /* Assign a buffer manager. */ if (bind & (PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER | @@ -572,6 +597,7 @@ static struct pb_buffer *radeon_winsys_bo_from_handle(struct radeon_winsys *rws, } bo->handle = open_arg.handle; bo->name = whandle->handle; + bo->reloc_domains = RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM; /* Initialize it. */ pipe_reference_init(&bo->base.reference, 1); diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.h b/src/gallium/winsys/radeon/drm/radeon_drm_bo.h index a3dbde76dcd..ba71cfb3440 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.h +++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.h @@ -42,11 +42,13 @@ struct radeon_bo_desc { struct pb_desc base; unsigned initial_domains; + unsigned reloc_domains; }; struct radeon_bo { struct pb_buffer base; + /* Don't move these! */ unsigned last_flush; unsigned binding; @@ -56,6 +58,7 @@ struct radeon_bo { void *ptr; pipe_mutex map_mutex; + uint32_t reloc_domains; uint32_t handle; uint32_t name; diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c index a3d0be5c1f3..8d5a6b33a7e 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c @@ -170,15 +170,14 @@ static struct radeon_winsys_cs *radeon_drm_cs_create(struct radeon_winsys *rws) #define OUT_CS(cs, value) (cs)->buf[(cs)->cdw++] = (value) -static INLINE void update_domains(struct drm_radeon_cs_reloc *reloc, - enum radeon_bo_domain rd, - enum radeon_bo_domain wd, - enum radeon_bo_domain *added_domains) +static INLINE void update_reloc_domains(struct drm_radeon_cs_reloc *reloc, + enum radeon_bo_usage usage, + unsigned domains) { - *added_domains = (rd | wd) & ~(reloc->read_domains | reloc->write_domain); - - reloc->read_domains |= rd; - reloc->write_domain |= wd; + if (usage & RADEON_USAGE_READ) + reloc->read_domains |= domains; + if (usage & RADEON_USAGE_WRITE) + reloc->write_domain |= domains; } int radeon_get_reloc(struct radeon_cs_context *csc, struct radeon_bo *bo) @@ -220,9 +219,8 @@ int radeon_get_reloc(struct radeon_cs_context *csc, struct radeon_bo *bo) static unsigned radeon_add_reloc(struct radeon_cs_context *csc, struct radeon_bo *bo, - enum radeon_bo_domain rd, - enum radeon_bo_domain wd, - enum radeon_bo_domain *added_domains) + enum radeon_bo_usage usage, + unsigned *added_domains) { struct drm_radeon_cs_reloc *reloc; unsigned i; @@ -231,7 +229,7 @@ static unsigned radeon_add_reloc(struct radeon_cs_context *csc, if (csc->is_handle_added[hash]) { reloc = csc->relocs_hashlist[hash]; if (reloc->handle == bo->handle) { - update_domains(reloc, rd, wd, added_domains); + update_reloc_domains(reloc, usage, bo->reloc_domains); return csc->reloc_indices_hashlist[hash]; } @@ -240,7 +238,7 @@ static unsigned radeon_add_reloc(struct radeon_cs_context *csc, --i; reloc = &csc->relocs[i]; if (reloc->handle == bo->handle) { - update_domains(reloc, rd, wd, added_domains); + update_reloc_domains(reloc, usage, bo->reloc_domains); csc->relocs_hashlist[hash] = reloc; csc->reloc_indices_hashlist[hash] = i; @@ -270,8 +268,10 @@ static unsigned radeon_add_reloc(struct radeon_cs_context *csc, p_atomic_inc(&bo->num_cs_references); reloc = &csc->relocs[csc->crelocs]; reloc->handle = bo->handle; - reloc->read_domains = rd; - reloc->write_domain = wd; + if (usage & RADEON_USAGE_READ) + reloc->read_domains = bo->reloc_domains; + if (usage & RADEON_USAGE_WRITE) + reloc->write_domain = bo->reloc_domains; reloc->flags = 0; csc->is_handle_added[hash] = TRUE; @@ -280,24 +280,23 @@ static unsigned radeon_add_reloc(struct radeon_cs_context *csc, csc->chunks[1].length_dw += RELOC_DWORDS; - *added_domains = rd | wd; + *added_domains = bo->reloc_domains; return csc->crelocs++; } static unsigned radeon_drm_cs_add_reloc(struct radeon_winsys_cs *rcs, struct radeon_winsys_cs_handle *buf, - enum radeon_bo_domain rd, - enum radeon_bo_domain wd) + enum radeon_bo_usage usage) { struct radeon_drm_cs *cs = radeon_drm_cs(rcs); struct radeon_bo *bo = (struct radeon_bo*)buf; - enum radeon_bo_domain added_domains; + unsigned added_domains = 0; - unsigned index = radeon_add_reloc(cs->csc, bo, rd, wd, &added_domains); + unsigned index = radeon_add_reloc(cs->csc, bo, usage, &added_domains); - if (added_domains & RADEON_DOMAIN_GTT) + if (added_domains & RADEON_GEM_DOMAIN_GTT) cs->csc->used_gart += bo->base.size; - if (added_domains & RADEON_DOMAIN_VRAM) + if (added_domains & RADEON_GEM_DOMAIN_VRAM) cs->csc->used_vram += bo->base.size; return index; diff --git a/src/gallium/winsys/radeon/drm/radeon_winsys.h b/src/gallium/winsys/radeon/drm/radeon_winsys.h index 31d39e9bdcb..8bfbc6cd2ef 100644 --- a/src/gallium/winsys/radeon/drm/radeon_winsys.h +++ b/src/gallium/winsys/radeon/drm/radeon_winsys.h @@ -56,11 +56,6 @@ enum radeon_bo_layout { RADEON_LAYOUT_UNKNOWN }; -enum radeon_bo_domain { /* bitfield */ - RADEON_DOMAIN_GTT = 2, - RADEON_DOMAIN_VRAM = 4 -}; - enum radeon_bo_usage { /* bitfield */ RADEON_USAGE_READ = 2, RADEON_USAGE_WRITE = 4, @@ -140,14 +135,13 @@ struct radeon_winsys { * \param size The size to allocate. * \param alignment An alignment of the buffer in memory. * \param bind A bitmask of the PIPE_BIND_* flags. - * \param domain A bitmask of the RADEON_DOMAIN_* flags. + * \param usage A bitmask of the PIPE_USAGE_* flags. * \return The created buffer object. */ struct pb_buffer *(*buffer_create)(struct radeon_winsys *ws, unsigned size, unsigned alignment, - unsigned bind, - enum radeon_bo_domain domain); + unsigned bind, unsigned usage); struct radeon_winsys_cs_handle *(*buffer_get_cs_handle)( struct pb_buffer *buf); @@ -275,14 +269,12 @@ struct radeon_winsys { * * \param cs A command stream to add buffer for validation against. * \param buf A winsys buffer to validate. - * \param rd A read domain containing a bitmask of the RADEON_DOMAIN_* flags. - * \param wd A write domain containing a bitmask of the RADEON_DOMAIN_* flags. + * \param usage Whether the buffer is used for read and/or write. * \return Relocation index. */ unsigned (*cs_add_reloc)(struct radeon_winsys_cs *cs, struct radeon_winsys_cs_handle *buf, - enum radeon_bo_domain rd, - enum radeon_bo_domain wd); + enum radeon_bo_usage usage); /** * Return TRUE if there is enough memory in VRAM and GTT for the relocs @@ -299,8 +291,6 @@ struct radeon_winsys { * * \param cs A command stream the relocation is written to. * \param buf A winsys buffer to write the relocation for. - * \param rd A read domain containing a bitmask of the RADEON_DOMAIN_* flags. - * \param wd A write domain containing a bitmask of the RADEON_DOMAIN_* flags. */ void (*cs_write_reloc)(struct radeon_winsys_cs *cs, struct radeon_winsys_cs_handle *buf); |