radv/winsys: add a new flag that requests zerovram allocations
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 20 Feb 2020 06:19:27 +0000 (07:19 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 20 Feb 2020 17:47:29 +0000 (18:47 +0100)
This introduces RADON_FLAG_ZERO_VRAM.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3888>

src/amd/vulkan/radv_radeon_winsys.h
src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c

index 5c7b1ab5118cae26c5f71d6047f202bb9de98c44..59c628b730fceb7e3a7b2e6d5501591eca25f990 100644 (file)
@@ -61,6 +61,7 @@ enum radeon_bo_flag { /* bitfield */
        RADEON_FLAG_READ_ONLY =     (1 << 7),
        RADEON_FLAG_32BIT =         (1 << 8),
        RADEON_FLAG_PREFER_LOCAL_BO = (1 << 9),
+       RADEON_FLAG_ZERO_VRAM = (1 << 10),
 };
 
 enum radeon_bo_usage { /* bitfield */
index 9e19b7b1f89bd28f1fd8b328455d97a5b0552fc7..c07641d6ab859cf72cd009f9256716894dbc2d61 100644 (file)
@@ -382,8 +382,11 @@ radv_amdgpu_winsys_bo_create(struct radeon_winsys *_ws,
        }
 
        /* this won't do anything on pre 4.9 kernels */
-       if (ws->zero_all_vram_allocs && (initial_domain & RADEON_DOMAIN_VRAM))
-               request.flags |= AMDGPU_GEM_CREATE_VRAM_CLEARED;
+       if (initial_domain & RADEON_DOMAIN_VRAM) {
+               if (ws->zero_all_vram_allocs || (flags & RADEON_FLAG_ZERO_VRAM))
+                       request.flags |= AMDGPU_GEM_CREATE_VRAM_CLEARED;
+       }
+
        r = amdgpu_bo_alloc(ws->dev, &request, &buf_handle);
        if (r) {
                fprintf(stderr, "amdgpu: Failed to allocate a buffer:\n");