[Mesa-dev] [PATCH 5/7] winsys/radeon: add interface for setting a priority number for each relocation
Marek Olšák
maraeo at gmail.com
Mon Feb 24 15:48:32 PST 2014
From: Marek Olšák <marek.olsak at amd.com>
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.
---
src/gallium/winsys/radeon/drm/radeon_drm_cs.c | 20 +++++++++++++-------
src/gallium/winsys/radeon/drm/radeon_winsys.h | 21 ++++++++++++++++++++-
2 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
index 2e07fa5..a25a7d7 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
@@ -210,10 +210,11 @@ 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_usage usage,
- enum radeon_bo_domain new_domain,
- enum radeon_bo_domain *added_domains)
+static INLINE void update_reloc(struct drm_radeon_cs_reloc *reloc,
+ enum radeon_bo_usage usage,
+ enum radeon_bo_domain new_domain,
+ unsigned priority,
+ enum radeon_bo_domain *added_domains)
{
enum radeon_bo_domain current = reloc->read_domains | reloc->write_domain;
enum radeon_bo_domain final;
@@ -235,6 +236,8 @@ static INLINE void update_reloc_domains(struct drm_radeon_cs_reloc *reloc,
/* write_domain is zero */
reloc->read_domains = final;
}
+
+ reloc->flags = MAX2(reloc->flags, priority);
}
int radeon_get_reloc(struct radeon_cs_context *csc, struct radeon_bo *bo)
@@ -278,6 +281,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;
@@ -286,7 +290,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];
@@ -312,7 +318,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, usage, domains, added_domains);
+ update_reloc(reloc, usage, domains, priority, added_domains);
if (cs->base.ring_type != RING_DMA) {
csc->reloc_indices_hashlist[hash] = i;
return i;
@@ -344,7 +350,7 @@ static unsigned radeon_add_reloc(struct radeon_drm_cs *cs,
reloc->write_domain = domains;
else
reloc->read_domains = domains;
- reloc->flags = 0;
+ reloc->flags = priority;
csc->is_handle_added[hash] = TRUE;
if (update_hash) {
@@ -365,7 +371,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 a692408..650df4e 100644
--- a/src/gallium/winsys/radeon/drm/radeon_winsys.h
+++ b/src/gallium/winsys/radeon/drm/radeon_winsys.h
@@ -165,6 +165,22 @@ enum radeon_value_id {
RADEON_GTT_USAGE
};
+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;
@@ -426,12 +442,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
--
1.8.3.2
More information about the mesa-dev
mailing list