radeonsi: always place sparse buffers in VRAM
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 23 Nov 2017 09:29:49 +0000 (10:29 +0100)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 6 Dec 2017 10:19:00 +0000 (11:19 +0100)
Together with "radeonsi: fix the R600_RESOURCE_FLAG_UNMAPPABLE check",
this ensures that sparse buffers are placed in VRAM.

Noticed by an assertion that started triggering with commit d4fac1e1d7
("gallium/radeon: enable suballocations for VRAM with no CPU access")

Fixes KHR-GL45.sparse_buffer_tests.BufferStorageTest in debug builds.
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
src/gallium/drivers/radeon/r600_buffer_common.c
src/gallium/winsys/amdgpu/drm/amdgpu_bo.c

index f1c4780dfeabb2e43e7b649ac38e9705c721de1e..09075f3ea296fae9dc3bc2ac0959d487a12b6bce 100644 (file)
@@ -610,6 +610,9 @@ static struct pipe_resource *si_buffer_create(struct pipe_screen *screen,
        struct si_screen *sscreen = (struct si_screen*)screen;
        struct r600_resource *rbuffer = r600_alloc_buffer_struct(screen, templ);
 
+       if (templ->flags & PIPE_RESOURCE_FLAG_SPARSE)
+               rbuffer->b.b.flags |= R600_RESOURCE_FLAG_UNMAPPABLE;
+
        si_init_resource_fields(sscreen, rbuffer, templ->width0, alignment);
 
        if (templ->flags & PIPE_RESOURCE_FLAG_SPARSE)
index d3b3674f12d58e81a08efa98f973fac4e5118da5..0d824025ce868464110881cdce17b5aa990b0490 100644 (file)
@@ -1169,6 +1169,9 @@ amdgpu_bo_create(struct radeon_winsys *rws,
    /* NO_CPU_ACCESS is valid with VRAM only. */
    assert(domain == RADEON_DOMAIN_VRAM || !(flags & RADEON_FLAG_NO_CPU_ACCESS));
 
+   /* Sparse buffers must have NO_CPU_ACCESS set. */
+   assert(!(flags & RADEON_FLAG_SPARSE) || flags & RADEON_FLAG_NO_CPU_ACCESS);
+
    /* Sub-allocate small buffers from slabs. */
    if (!(flags & (RADEON_FLAG_NO_SUBALLOC | RADEON_FLAG_SPARSE)) &&
        size <= (1 << AMDGPU_SLAB_MAX_SIZE_LOG2) &&
@@ -1201,8 +1204,6 @@ no_slab:
    if (flags & RADEON_FLAG_SPARSE) {
       assert(RADEON_SPARSE_PAGE_SIZE % alignment == 0);
 
-      flags |= RADEON_FLAG_NO_CPU_ACCESS;
-
       return amdgpu_bo_sparse_create(ws, size, domain, flags);
    }