Skip to content

Commit

Permalink
vkd3d: Add config flag to skip image heap clears.
Browse files Browse the repository at this point in the history
These are typically used for resource heaps and don't need to be
cleared in most cases.
For RTV cases, they have to be initialized with a clear or discard,
and usually that will clear the memory anyway, so this flag is a softer
and safer variant of the full "skip clear" flag.

Signed-off-by: Hans-Kristian Arntzen <[email protected]>
  • Loading branch information
HansKristian-Work committed May 7, 2024
1 parent f8f32b0 commit 6130821
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/vkd3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ extern "C" {
#define VKD3D_CONFIG_FLAG_DISABLE_DEPTH_COMPRESSION (1ull << 44)
#define VKD3D_CONFIG_FLAG_DISABLE_COLOR_COMPRESSION (1ull << 45)
#define VKD3D_CONFIG_FLAG_DISABLE_NV_DGCC (1ull << 46)
#define VKD3D_CONFIG_FLAG_MEMORY_ALLOCATOR_SKIP_IMAGE_HEAP_CLEAR (1ull << 47)

struct vkd3d_instance;

Expand Down
1 change: 1 addition & 0 deletions libs/vkd3d/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,7 @@ static const struct vkd3d_debug_option vkd3d_config_options[] =
{"pipeline_library_ignore_spirv", VKD3D_CONFIG_FLAG_PIPELINE_LIBRARY_IGNORE_SPIRV},
{"mutable_single_set", VKD3D_CONFIG_FLAG_MUTABLE_SINGLE_SET},
{"memory_allocator_skip_clear", VKD3D_CONFIG_FLAG_MEMORY_ALLOCATOR_SKIP_CLEAR},
{"memory_allocator_skip_image_heap_clear", VKD3D_CONFIG_FLAG_MEMORY_ALLOCATOR_SKIP_IMAGE_HEAP_CLEAR},
{"recycle_command_pools", VKD3D_CONFIG_FLAG_RECYCLE_COMMAND_POOLS},
{"pipeline_library_ignore_mismatch_driver", VKD3D_CONFIG_FLAG_PIPELINE_LIBRARY_IGNORE_MISMATCH_DRIVER},
{"breadcrumbs", VKD3D_CONFIG_FLAG_BREADCRUMBS},
Expand Down
5 changes: 5 additions & 0 deletions libs/vkd3d/heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ static HRESULT d3d12_heap_init(struct d3d12_heap *heap, struct d3d12_device *dev
alloc_info.extra_allocation_flags = VKD3D_ALLOCATION_FLAG_ALLOW_IMAGE_SUBALLOCATION;
}

/* Buffers are far more sensitive to memory clears than images. */
if ((alloc_info.heap_desc.Flags & D3D12_HEAP_FLAG_DENY_BUFFERS) &&
(vkd3d_config_flags & VKD3D_CONFIG_FLAG_MEMORY_ALLOCATOR_SKIP_IMAGE_HEAP_CLEAR))
alloc_info.heap_desc.Flags |= D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;

if (FAILED(hr = vkd3d_private_store_init(&heap->private_store)))
return hr;

Expand Down

0 comments on commit 6130821

Please sign in to comment.