aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys/radeon
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/winsys/radeon')
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm_cs.c40
1 files changed, 12 insertions, 28 deletions
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
index f6b9d6283f2..ccba0c0b791 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
@@ -211,30 +211,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_reloc_domains(struct drm_radeon_cs_reloc *reloc,
- enum radeon_bo_usage usage,
- enum radeon_bo_domain new_domain,
+ enum radeon_bo_domain rd,
+ enum radeon_bo_domain wd,
enum radeon_bo_domain *added_domains)
{
- enum radeon_bo_domain current = reloc->read_domains | reloc->write_domain;
- enum radeon_bo_domain final;
-
- /* If there is at least one command which wants the buffer to be in VRAM
- * only, keep it in VRAM. */
- if ((current & new_domain) == RADEON_DOMAIN_VRAM)
- final = RADEON_DOMAIN_VRAM;
- else
- final = current | new_domain;
-
- *added_domains = final & ~current;
-
- /* If we have at least one write usage... */
- if (usage & RADEON_USAGE_WRITE || reloc->write_domain) {
- reloc->write_domain = final;
- reloc->read_domains = 0;
- } else {
- /* write_domain is zero */
- reloc->read_domains = final;
- }
+ *added_domains = (rd | wd) & ~(reloc->read_domains | reloc->write_domain);
+
+ reloc->read_domains |= rd;
+ reloc->write_domain |= wd;
}
int radeon_get_reloc(struct radeon_cs_context *csc, struct radeon_bo *bo)
@@ -283,6 +267,8 @@ static unsigned radeon_add_reloc(struct radeon_drm_cs *cs,
struct radeon_cs_context *csc = cs->csc;
struct drm_radeon_cs_reloc *reloc;
unsigned hash = bo->handle & (sizeof(csc->is_handle_added)-1);
+ enum radeon_bo_domain rd = usage & RADEON_USAGE_READ ? domains : 0;
+ enum radeon_bo_domain wd = usage & RADEON_USAGE_WRITE ? domains : 0;
bool update_hash = TRUE;
int i;
@@ -312,7 +298,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_domains(reloc, rd, wd, added_domains);
if (cs->base.ring_type != RING_DMA) {
csc->reloc_indices_hashlist[hash] = i;
return i;
@@ -340,10 +326,8 @@ static unsigned radeon_add_reloc(struct radeon_drm_cs *cs,
p_atomic_inc(&bo->num_cs_references);
reloc = &csc->relocs[csc->crelocs];
reloc->handle = bo->handle;
- if (usage & RADEON_USAGE_WRITE)
- reloc->write_domain = domains;
- else
- reloc->read_domains = domains;
+ reloc->read_domains = rd;
+ reloc->write_domain = wd;
reloc->flags = 0;
csc->is_handle_added[hash] = TRUE;
@@ -353,7 +337,7 @@ static unsigned radeon_add_reloc(struct radeon_drm_cs *cs,
csc->chunks[1].length_dw += RELOC_DWORDS;
- *added_domains = domains;
+ *added_domains = rd | wd;
return csc->crelocs++;
}