diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c index c5c915d7a4b..ce64811b178 100644 --- a/src/intel/vulkan/anv_allocator.c +++ b/src/intel/vulkan/anv_allocator.c @@ -509,7 +509,6 @@ anv_block_pool_expand_range(struct anv_block_pool *pool, pool->name, new_bo_size, bo_alloc_flags | - ANV_BO_ALLOC_LOCAL_MEM | ANV_BO_ALLOC_FIXED_ADDRESS | ANV_BO_ALLOC_MAPPED | ANV_BO_ALLOC_SNOOPED, @@ -1383,7 +1382,6 @@ anv_bo_pool_alloc(struct anv_bo_pool *pool, uint32_t size, VkResult result = anv_device_alloc_bo(pool->device, pool->name, pow2_size, - ANV_BO_ALLOC_LOCAL_MEM | ANV_BO_ALLOC_MAPPED | ANV_BO_ALLOC_SNOOPED | ANV_BO_ALLOC_CAPTURE, @@ -1490,9 +1488,8 @@ anv_scratch_pool_alloc(struct anv_device *device, struct anv_scratch_pool *pool, * * so nothing will ever touch the top page. */ - enum anv_bo_alloc_flags alloc_flags = ANV_BO_ALLOC_LOCAL_MEM; - if (devinfo->verx10 < 125) - alloc_flags |= ANV_BO_ALLOC_32BIT_ADDRESS; + const enum anv_bo_alloc_flags alloc_flags = + devinfo->verx10 < 125 ? ANV_BO_ALLOC_32BIT_ADDRESS : 0; VkResult result = anv_device_alloc_bo(device, "scratch", size, alloc_flags, 0 /* explicit_address */, @@ -1668,10 +1665,6 @@ anv_device_alloc_bo(struct anv_device *device, uint64_t explicit_address, struct anv_bo **bo_out) { - if (!(alloc_flags & ANV_BO_ALLOC_LOCAL_MEM)) - anv_perf_warn(VK_LOG_NO_OBJS(&device->physical->instance->vk.base), - "system memory used"); - if (!device->physical->has_implicit_ccs) assert(!(alloc_flags & ANV_BO_ALLOC_IMPLICIT_CCS)); @@ -1702,19 +1695,21 @@ anv_device_alloc_bo(struct anv_device *device, struct drm_i915_gem_memory_class_instance regions[2]; uint32_t nregions = 0; - if (alloc_flags & ANV_BO_ALLOC_LOCAL_MEM) { - /* vram_non_mappable & vram_mappable actually are the same region. */ - regions[nregions++] = device->physical->vram_non_mappable.region; - } else { - regions[nregions++] = device->physical->sys.region; - } + /* This always try to put the object in local memory. Here + * vram_non_mappable & vram_mappable actually are the same region. + */ + regions[nregions++] = device->physical->vram_non_mappable.region; + /* If the buffer is mapped on the host, add the system memory region. + * This ensures that if the buffer cannot live in mappable local memory, + * it can be spilled to system memory. + */ uint32_t flags = 0; - if (alloc_flags & ANV_BO_ALLOC_LOCAL_MEM_CPU_VISIBLE) { - assert(alloc_flags & ANV_BO_ALLOC_LOCAL_MEM); - /* We're required to add smem as a region when using mappable vram. */ + if ((alloc_flags & ANV_BO_ALLOC_MAPPED) || + (alloc_flags & ANV_BO_ALLOC_LOCAL_MEM_CPU_VISIBLE)) { regions[nregions++] = device->physical->sys.region; - flags |= I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS; + if (device->physical->vram_non_mappable.size > 0) + flags |= I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS; } gem_handle = anv_gem_create_regions(device, size + ccs_size, @@ -1737,8 +1732,7 @@ anv_device_alloc_bo(struct anv_device *device, .is_external = (alloc_flags & ANV_BO_ALLOC_EXTERNAL), .has_client_visible_address = (alloc_flags & ANV_BO_ALLOC_CLIENT_VISIBLE_ADDRESS) != 0, - .has_implicit_ccs = ccs_size > 0 || (device->info->verx10 >= 125 && - (alloc_flags & ANV_BO_ALLOC_LOCAL_MEM)), + .has_implicit_ccs = ccs_size > 0 || device->info->verx10 >= 125, }; if (alloc_flags & ANV_BO_ALLOC_MAPPED) { diff --git a/src/intel/vulkan/anv_cmd_buffer.c b/src/intel/vulkan/anv_cmd_buffer.c index 06c12c839a2..a7db4514797 100644 --- a/src/intel/vulkan/anv_cmd_buffer.c +++ b/src/intel/vulkan/anv_cmd_buffer.c @@ -329,7 +329,7 @@ anv_cmd_buffer_set_ray_query_buffer(struct anv_cmd_buffer *cmd_buffer, struct anv_bo *new_bo; VkResult result = anv_device_alloc_bo(device, "RT queries shadow", ray_shadow_size, - ANV_BO_ALLOC_LOCAL_MEM, /* alloc_flags */ + 0, /* alloc_flags */ 0, /* explicit_address */ &new_bo); if (result != VK_SUCCESS) { @@ -1087,7 +1087,7 @@ void anv_CmdSetRayTracingPipelineStackSizeKHR( struct anv_bo *new_bo; VkResult result = anv_device_alloc_bo(device, "RT scratch", rt->scratch.layout.total_size, - ANV_BO_ALLOC_LOCAL_MEM, + 0, /* alloc_flags */ 0, /* explicit_address */ &new_bo); if (result != VK_SUCCESS) { diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index a1eca83cdce..eda3e9bdc21 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -3407,8 +3407,7 @@ VkResult anv_CreateDevice( result = anv_device_alloc_bo(device, "workaround", 4096, ANV_BO_ALLOC_CAPTURE | - ANV_BO_ALLOC_MAPPED | - ANV_BO_ALLOC_LOCAL_MEM, + ANV_BO_ALLOC_MAPPED, 0 /* explicit_address */, &device->workaround_bo); if (result != VK_SUCCESS) @@ -3433,7 +3432,7 @@ VkResult anv_CreateDevice( result = anv_device_alloc_bo(device, "ray queries", ray_queries_size, - ANV_BO_ALLOC_LOCAL_MEM, + 0, 0 /* explicit_address */, &device->ray_query_bo); if (result != VK_SUCCESS) @@ -3997,12 +3996,6 @@ VkResult anv_AllocateMemory( goto success; } - /* Set ALLOC_LOCAL_MEM flag if heap has device local bit set and requested - * memory property flag has DEVICE_LOCAL_BIT set. - */ - if (mem_type->propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) - alloc_flags |= ANV_BO_ALLOC_LOCAL_MEM; - /* Regular allocate (not importing memory). */ result = anv_device_alloc_bo(device, "user", pAllocateInfo->allocationSize, diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 39c2b8c6c48..c868e5b4e15 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1368,11 +1368,8 @@ enum anv_bo_alloc_flags { /** This buffer has implicit CCS data attached to it */ ANV_BO_ALLOC_IMPLICIT_CCS = (1 << 9), - /** This buffer is allocated from local memory */ - ANV_BO_ALLOC_LOCAL_MEM = (1 << 10), - /** This buffer is allocated from local memory and should be cpu visible */ - ANV_BO_ALLOC_LOCAL_MEM_CPU_VISIBLE = (1 << 11), + ANV_BO_ALLOC_LOCAL_MEM_CPU_VISIBLE = (1 << 10), }; VkResult anv_device_alloc_bo(struct anv_device *device,