radv: add debug flags to zero vram allocations.
authorDave Airlie <airlied@redhat.com>
Wed, 15 Feb 2017 01:17:02 +0000 (01:17 +0000)
committerDave Airlie <airlied@redhat.com>
Mon, 11 Sep 2017 19:37:15 +0000 (05:37 +1000)
We are seeing apps that sometimes rely on Windows behaviour, add
a flag to rule out vram zeroing.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/amd/vulkan/radv_debug.h
src/amd/vulkan/radv_device.c
src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c
src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c
src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h

index 18ef7e7e0a8e9a5b3cb04da70ce9617911138105..e45c987e6a3e6f215aa8dfa51e38c1bdcdf38c2b 100644 (file)
@@ -39,6 +39,7 @@ enum {
        RADV_DEBUG_NO_IBS            = 0x200,
        RADV_DEBUG_DUMP_SPIRV        = 0x400,
        RADV_DEBUG_VM_FAULTS         = 0x800,
+       RADV_DEBUG_ZERO_VRAM         = 0x1000,
 };
 
 enum {
index a68278ff4396c4c5a2e14ec386cd3c74a4d41df6..6b96a3da4a307b6ca4c5f71cc23ac09e441c17ce 100644 (file)
@@ -412,6 +412,7 @@ static const struct debug_control radv_debug_options[] = {
        {"noibs", RADV_DEBUG_NO_IBS},
        {"spirv", RADV_DEBUG_DUMP_SPIRV},
        {"vmfaults", RADV_DEBUG_VM_FAULTS},
+       {"zerovram", RADV_DEBUG_ZERO_VRAM},
        {NULL, 0}
 };
 
index 1c56c5590724157992629af87526adaa6d46c5f0..c8b67a095b72b6b7fc0794e360733ede76ab71e8 100644 (file)
@@ -331,6 +331,9 @@ radv_amdgpu_winsys_bo_create(struct radeon_winsys *_ws,
        if (flags & RADEON_FLAG_GTT_WC)
                request.flags |= AMDGPU_GEM_CREATE_CPU_GTT_USWC;
 
+       /* 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;
        r = amdgpu_bo_alloc(ws->dev, &request, &buf_handle);
        if (r) {
                fprintf(stderr, "amdgpu: Failed to allocate a buffer:\n");
index a6dedfa5a17fa8a685ce2166036a47498aed20ad..36606defb7757fbdf051a3a40bdc0f3431a73a40 100644 (file)
@@ -106,6 +106,7 @@ radv_amdgpu_winsys_create(int fd, uint64_t debug_flags, uint64_t perftest_flags)
        if (debug_flags & RADV_DEBUG_NO_IBS)
                ws->use_ib_bos = false;
 
+       ws->zero_all_vram_allocs = debug_flags & RADV_DEBUG_ZERO_VRAM;
        ws->batchchain = !(perftest_flags & RADV_PERFTEST_NO_BATCHCHAIN);
        LIST_INITHEAD(&ws->global_bo_list);
        pthread_mutex_init(&ws->global_bo_list_lock, NULL);
index f84f62cb2245bcf34fb151bdc20cff82b77b0999..66c93475e5ef463f5405f11b27a389ff02ead7fc 100644 (file)
@@ -45,6 +45,7 @@ struct radv_amdgpu_winsys {
        bool debug_all_bos;
        bool batchchain;
        bool use_ib_bos;
+       bool zero_all_vram_allocs;
        unsigned num_buffers;
 
        pthread_mutex_t global_bo_list_lock;