From: Marek Olšák <marek.ol...@amd.com>

The combined VRAM|GTT heap will be removed.
---
 src/gallium/drivers/r600/r600_buffer_common.c   | 14 --------------
 src/gallium/drivers/radeon/r600_buffer_common.c | 14 --------------
 src/gallium/winsys/amdgpu/drm/amdgpu_bo.c       | 14 +++++++++++++-
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c   |  7 +++++++
 src/gallium/winsys/radeon/drm/radeon_drm_cs.c   |  8 ++++++++
 5 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_buffer_common.c 
b/src/gallium/drivers/r600/r600_buffer_common.c
index 5ff25ae..501b96f 100644
--- a/src/gallium/drivers/r600/r600_buffer_common.c
+++ b/src/gallium/drivers/r600/r600_buffer_common.c
@@ -169,34 +169,20 @@ void r600_init_resource_fields(struct r600_common_screen 
*rscreen,
 
        /* Only displayable single-sample textures can be shared between
         * processes. */
        if (res->b.b.target == PIPE_BUFFER ||
            res->b.b.nr_samples >= 2 ||
            (rtex->surface.micro_tile_mode != RADEON_MICRO_MODE_DISPLAY &&
             /* Raven doesn't use display micro mode for 32bpp, so check this: 
*/
             !(res->b.b.bind & PIPE_BIND_SCANOUT)))
                res->flags |= RADEON_FLAG_NO_INTERPROCESS_SHARING;
 
-       /* If VRAM is just stolen system memory, allow both VRAM and
-        * GTT, whichever has free space. If a buffer is evicted from
-        * VRAM to GTT, it will stay there.
-        *
-        * DRM 3.6.0 has good BO move throttling, so we can allow VRAM-only
-        * placements even with a low amount of stolen VRAM.
-        */
-       if (!rscreen->info.has_dedicated_vram &&
-           (rscreen->info.drm_major < 3 || rscreen->info.drm_minor < 6) &&
-           res->domains == RADEON_DOMAIN_VRAM) {
-               res->domains = RADEON_DOMAIN_VRAM_GTT;
-               res->flags &= ~RADEON_FLAG_NO_CPU_ACCESS; /* disallowed with 
VRAM_GTT */
-       }
-
        if (rscreen->debug_flags & DBG_NO_WC)
                res->flags &= ~RADEON_FLAG_GTT_WC;
 
        if (res->b.b.bind & PIPE_BIND_SHARED)
                res->flags |= RADEON_FLAG_NO_SUBALLOC;
 
        /* Set expected VRAM and GART usage for the buffer. */
        res->vram_usage = 0;
        res->gart_usage = 0;
 
diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c 
b/src/gallium/drivers/radeon/r600_buffer_common.c
index d162eea..ec282d5 100644
--- a/src/gallium/drivers/radeon/r600_buffer_common.c
+++ b/src/gallium/drivers/radeon/r600_buffer_common.c
@@ -164,34 +164,20 @@ void si_init_resource_fields(struct si_screen *sscreen,
                res->flags |= RADEON_FLAG_NO_CPU_ACCESS |
                         RADEON_FLAG_GTT_WC;
        }
 
        /* Displayable and shareable surfaces are not suballocated. */
        if (res->b.b.bind & (PIPE_BIND_SHARED | PIPE_BIND_SCANOUT))
                res->flags |= RADEON_FLAG_NO_SUBALLOC; /* shareable */
        else
                res->flags |= RADEON_FLAG_NO_INTERPROCESS_SHARING;
 
-       /* If VRAM is just stolen system memory, allow both VRAM and
-        * GTT, whichever has free space. If a buffer is evicted from
-        * VRAM to GTT, it will stay there.
-        *
-        * DRM 3.6.0 has good BO move throttling, so we can allow VRAM-only
-        * placements even with a low amount of stolen VRAM.
-        */
-       if (!sscreen->info.has_dedicated_vram &&
-           (sscreen->info.drm_major < 3 || sscreen->info.drm_minor < 6) &&
-           res->domains == RADEON_DOMAIN_VRAM) {
-               res->domains = RADEON_DOMAIN_VRAM_GTT;
-               res->flags &= ~RADEON_FLAG_NO_CPU_ACCESS; /* disallowed with 
VRAM_GTT */
-       }
-
        if (sscreen->debug_flags & DBG(NO_WC))
                res->flags &= ~RADEON_FLAG_GTT_WC;
 
        /* Set expected VRAM and GART usage for the buffer. */
        res->vram_usage = 0;
        res->gart_usage = 0;
        res->max_forced_staging_uploads = 0;
        res->b.max_forced_staging_uploads = 0;
 
        if (res->domains & RADEON_DOMAIN_VRAM) {
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c 
b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index 6ec7cb7..9ab8f67 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -379,36 +379,48 @@ static struct amdgpu_winsys_bo *amdgpu_create_bo(struct 
amdgpu_winsys *ws,
                                                  unsigned pb_cache_bucket)
 {
    struct amdgpu_bo_alloc_request request = {0};
    amdgpu_bo_handle buf_handle;
    uint64_t va = 0;
    struct amdgpu_winsys_bo *bo;
    amdgpu_va_handle va_handle;
    unsigned va_gap_size;
    int r;
 
-   assert(initial_domain & RADEON_DOMAIN_VRAM_GTT);
+   /* VRAM or GTT must be specified, but not both at the same time. */
+   assert(util_bitcount(initial_domain & RADEON_DOMAIN_VRAM_GTT) == 1);
+
    bo = CALLOC_STRUCT(amdgpu_winsys_bo);
    if (!bo) {
       return NULL;
    }
 
    pb_cache_init_entry(&ws->bo_cache, &bo->u.real.cache_entry, &bo->base,
                        pb_cache_bucket);
    request.alloc_size = size;
    request.phys_alignment = alignment;
 
    if (initial_domain & RADEON_DOMAIN_VRAM)
       request.preferred_heap |= AMDGPU_GEM_DOMAIN_VRAM;
    if (initial_domain & RADEON_DOMAIN_GTT)
       request.preferred_heap |= AMDGPU_GEM_DOMAIN_GTT;
 
+   /* If VRAM is just stolen system memory, allow both VRAM and
+    * GTT, whichever has free space. If a buffer is evicted from
+    * VRAM to GTT, it will stay there.
+    *
+    * DRM 3.6.0 has good BO move throttling, so we can allow VRAM-only
+    * placements even with a low amount of stolen VRAM.
+    */
+   if (!ws->info.has_dedicated_vram && ws->info.drm_minor < 6)
+      request.preferred_heap |= AMDGPU_GEM_DOMAIN_GTT;
+
    if (flags & RADEON_FLAG_NO_CPU_ACCESS)
       request.flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
    if (flags & RADEON_FLAG_GTT_WC)
       request.flags |= AMDGPU_GEM_CREATE_CPU_GTT_USWC;
    if (flags & RADEON_FLAG_NO_INTERPROCESS_SHARING &&
        ws->info.drm_minor >= 20)
       request.flags |= AMDGPU_GEM_CREATE_VM_ALWAYS_VALID;
 
    r = amdgpu_bo_alloc(ws->dev, &request, &buf_handle);
    if (r) {
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 87c3f1e..fc95a98 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -602,20 +602,27 @@ static struct radeon_bo *radeon_create_bo(struct 
radeon_drm_winsys *rws,
 
     assert(initial_domains);
     assert((initial_domains &
             ~(RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM)) == 0);
 
     args.size = size;
     args.alignment = alignment;
     args.initial_domain = initial_domains;
     args.flags = 0;
 
+    /* If VRAM is just stolen system memory, allow both VRAM and
+     * GTT, whichever has free space. If a buffer is evicted from
+     * VRAM to GTT, it will stay there.
+     */
+    if (!rws->info.has_dedicated_vram)
+        args.initial_domain |= RADEON_DOMAIN_GTT;
+
     if (flags & RADEON_FLAG_GTT_WC)
         args.flags |= RADEON_GEM_GTT_WC;
     if (flags & RADEON_FLAG_NO_CPU_ACCESS)
         args.flags |= RADEON_GEM_NO_CPU_ACCESS;
 
     if (drmCommandWriteRead(rws->fd, DRM_RADEON_GEM_CREATE,
                             &args, sizeof(args))) {
         fprintf(stderr, "radeon: Failed to allocate a buffer:\n");
         fprintf(stderr, "radeon:    size      : %u bytes\n", size);
         fprintf(stderr, "radeon:    alignment : %u bytes\n", alignment);
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
index c3398d0..92452e4 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
@@ -331,20 +331,28 @@ static int radeon_lookup_or_add_slab_buffer(struct 
radeon_drm_cs *cs,
 
 static unsigned radeon_drm_cs_add_buffer(struct radeon_winsys_cs *rcs,
                                         struct pb_buffer *buf,
                                         enum radeon_bo_usage usage,
                                         enum radeon_bo_domain domains,
                                         enum radeon_bo_priority priority)
 {
     struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
     struct radeon_bo *bo = (struct radeon_bo*)buf;
     enum radeon_bo_domain added_domains;
+
+    /* If VRAM is just stolen system memory, allow both VRAM and
+     * GTT, whichever has free space. If a buffer is evicted from
+     * VRAM to GTT, it will stay there.
+     */
+    if (!cs->ws->info.has_dedicated_vram)
+        domains |= RADEON_DOMAIN_GTT;
+
     enum radeon_bo_domain rd = usage & RADEON_USAGE_READ ? domains : 0;
     enum radeon_bo_domain wd = usage & RADEON_USAGE_WRITE ? domains : 0;
     struct drm_radeon_cs_reloc *reloc;
     int index;
 
     if (!bo->handle) {
         index = radeon_lookup_or_add_slab_buffer(cs, bo);
         if (index < 0)
             return 0;
 
-- 
2.7.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to