From: Marek Olšák Date: Thu, 20 Feb 2014 14:31:59 +0000 (+0100) Subject: winsys/radeon: add interface for setting a priority number for each relocation X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=db1a7f78c2653f0cb385af363ed1c770cb1c55c9;p=mesa.git winsys/radeon: add interface for setting a priority number for each relocation The cs_add_reloc change is commented out not to break compilation. The highest priority of all cs_add_reloc calls is send to the kernel. --- diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c index ccba0c0b791..98b7a29427b 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c @@ -210,15 +210,17 @@ 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_reloc_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(struct drm_radeon_cs_reloc *reloc, + enum radeon_bo_domain rd, + enum radeon_bo_domain wd, + unsigned priority, + enum radeon_bo_domain *added_domains) { *added_domains = (rd | wd) & ~(reloc->read_domains | reloc->write_domain); reloc->read_domains |= rd; reloc->write_domain |= wd; + reloc->flags = MAX2(reloc->flags, priority); } int radeon_get_reloc(struct radeon_cs_context *csc, struct radeon_bo *bo) @@ -262,6 +264,7 @@ static unsigned radeon_add_reloc(struct radeon_drm_cs *cs, struct radeon_bo *bo, enum radeon_bo_usage usage, enum radeon_bo_domain domains, + unsigned priority, enum radeon_bo_domain *added_domains) { struct radeon_cs_context *csc = cs->csc; @@ -272,7 +275,9 @@ static unsigned radeon_add_reloc(struct radeon_drm_cs *cs, bool update_hash = TRUE; int i; + priority = MIN2(priority, 15); *added_domains = 0; + if (csc->is_handle_added[hash]) { i = csc->reloc_indices_hashlist[hash]; reloc = &csc->relocs[i]; @@ -298,7 +303,7 @@ static unsigned radeon_add_reloc(struct radeon_drm_cs *cs, * update the cmd stream with proper buffer offset). */ update_hash = FALSE; - update_reloc_domains(reloc, rd, wd, added_domains); + update_reloc(reloc, rd, wd, priority, added_domains); if (cs->base.ring_type != RING_DMA) { csc->reloc_indices_hashlist[hash] = i; return i; @@ -328,7 +333,7 @@ static unsigned radeon_add_reloc(struct radeon_drm_cs *cs, reloc->handle = bo->handle; reloc->read_domains = rd; reloc->write_domain = wd; - reloc->flags = 0; + reloc->flags = priority; csc->is_handle_added[hash] = TRUE; if (update_hash) { @@ -349,7 +354,7 @@ static unsigned radeon_drm_cs_add_reloc(struct radeon_winsys_cs *rcs, struct radeon_drm_cs *cs = radeon_drm_cs(rcs); struct radeon_bo *bo = (struct radeon_bo*)buf; enum radeon_bo_domain added_domains; - unsigned index = radeon_add_reloc(cs, bo, usage, domains, &added_domains); + unsigned index = radeon_add_reloc(cs, bo, usage, domains, 0, &added_domains); if (added_domains & RADEON_DOMAIN_GTT) cs->csc->used_gart += bo->base.size; diff --git a/src/gallium/winsys/radeon/drm/radeon_winsys.h b/src/gallium/winsys/radeon/drm/radeon_winsys.h index 37affc3896d..5b2b31aea48 100644 --- a/src/gallium/winsys/radeon/drm/radeon_winsys.h +++ b/src/gallium/winsys/radeon/drm/radeon_winsys.h @@ -160,6 +160,22 @@ enum radeon_value_id { RADEON_TIMESTAMP }; +enum radeon_bo_priority { + RADEON_PRIO_MIN, + RADEON_PRIO_SHADER_DATA, /* shader code, resource descriptors */ + RADEON_PRIO_SHADER_BUFFER_RO, /* read-only */ + RADEON_PRIO_SHADER_TEXTURE_RO, /* read-only */ + RADEON_PRIO_SHADER_RESOURCE_RW, /* buffers, textures, streamout, GS rings, RATs; read/write */ + RADEON_PRIO_COLOR_BUFFER, + RADEON_PRIO_DEPTH_BUFFER, + RADEON_PRIO_SHADER_TEXTURE_MSAA, + RADEON_PRIO_COLOR_BUFFER_MSAA, + RADEON_PRIO_DEPTH_BUFFER_MSAA, + RADEON_PRIO_COLOR_META, + RADEON_PRIO_DEPTH_META, + RADEON_PRIO_MAX /* must be <= 15 */ +}; + struct winsys_handle; struct radeon_winsys_cs_handle; @@ -411,12 +427,15 @@ struct radeon_winsys { * \param buf A winsys buffer to validate. * \param usage Whether the buffer is used for read and/or write. * \param domain Bitmask of the RADEON_DOMAIN_* flags. + * \param priority A higher number means a greater chance of being + * placed in the requested domain. 15 is the maximum. * \return Relocation index. */ unsigned (*cs_add_reloc)(struct radeon_winsys_cs *cs, struct radeon_winsys_cs_handle *buf, enum radeon_bo_usage usage, - enum radeon_bo_domain domain); + enum radeon_bo_domain domain/*, + enum radeon_bo_priority priority*/); /** * Return TRUE if there is enough memory in VRAM and GTT for the relocs