radv: make shader BOs read-only for the GPU
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 4 Jan 2018 14:19:47 +0000 (15:19 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 8 Jan 2018 20:24:51 +0000 (21:24 +0100)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_private.h
src/amd/vulkan/radv_shader.c

index 5f78af624b5da5d733eac002e1b611cafa2a6587..528d3539c91136532f2fd6e1dd60973b69f40295 100644 (file)
@@ -263,6 +263,8 @@ radv_physical_device_init(struct radv_physical_device *device,
         */
        device->has_clear_state = device->rad_info.chip_class >= CIK;
 
+       device->cpdma_prefetch_writes_memory = device->rad_info.chip_class <= VI;
+
        radv_physical_device_init_mem_types(device);
 
        result = radv_init_wsi(device);
index 30ccbea176aaef7536c000ab6d81ddd562edb4ba..f691c832bc25b357785c67b4f1d0b7ee8c97e8e4 100644 (file)
@@ -272,6 +272,7 @@ struct radv_physical_device {
        bool has_rbplus; /* if RB+ register exist */
        bool rbplus_allowed; /* if RB+ is allowed */
        bool has_clear_state;
+       bool cpdma_prefetch_writes_memory;
 
        /* This is the drivers on-disk cache used as a fallback as opposed to
         * the pipeline cache defined by apps.
index 31879805ae08d8dfb3b3dbb2c3086722d67f2e4d..971d3abac913fa356efa56bf842f8e0ca1c6f7b0 100644 (file)
@@ -330,7 +330,10 @@ radv_alloc_shader_memory(struct radv_device *device,
 
        slab->size = 256 * 1024;
        slab->bo = device->ws->buffer_create(device->ws, slab->size, 256,
-                                            RADEON_DOMAIN_VRAM, RADEON_FLAG_NO_INTERPROCESS_SHARING);
+                                            RADEON_DOMAIN_VRAM,
+                                            RADEON_FLAG_NO_INTERPROCESS_SHARING |
+                                            device->physical_device->cpdma_prefetch_writes_memory ?
+                                                    0 : RADEON_FLAG_READ_ONLY);
        slab->ptr = (char*)device->ws->buffer_map(slab->bo);
        list_inithead(&slab->shaders);