vkd3d: Clear suballocated memory to zero.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
This commit is contained in:
Philip Rebohle 2021-02-16 03:41:41 +01:00 committed by Hans-Kristian Arntzen
parent 668a4e1f2c
commit a39bab95a1
2 changed files with 30 additions and 2 deletions

View File

@ -8733,6 +8733,7 @@ static void STDMETHODCALLTYPE d3d12_command_queue_ExecuteCommandLists(ID3D12Comm
VkCommandBuffer *buffers;
LONG **outstanding;
unsigned int i, j;
HRESULT hr;
TRACE("iface %p, command_list_count %u, command_lists %p.\n",
iface, command_list_count, command_lists);
@ -8740,6 +8741,14 @@ static void STDMETHODCALLTYPE d3d12_command_queue_ExecuteCommandLists(ID3D12Comm
if (!command_list_count)
return;
if (FAILED(hr = vkd3d_memory_allocator_flush_clears(
&command_queue->device->memory_allocator, command_queue->device)))
{
d3d12_device_mark_as_removed(command_queue->device, hr,
"Failed to execute pending memory clears.\n");
return;
}
num_command_buffers = command_list_count + 1;
for (i = 0; i < command_list_count; ++i)

View File

@ -24,6 +24,9 @@
#include "vkd3d_descriptor_debug.h"
#endif
static void vkd3d_memory_allocator_wait_allocation(struct vkd3d_memory_allocator *allocator,
struct d3d12_device *device, const struct vkd3d_memory_allocation *allocation);
static inline bool is_cpu_accessible_heap(const D3D12_HEAP_PROPERTIES *properties)
{
if (properties->Type == D3D12_HEAP_TYPE_DEFAULT)
@ -616,6 +619,9 @@ static void vkd3d_memory_chunk_destroy(struct vkd3d_memory_chunk *chunk, struct
{
TRACE("chunk %p, device %p, allocator %p.\n", chunk, device, allocator);
if (chunk->allocation.clear_semaphore_value)
vkd3d_memory_allocator_wait_allocation(allocator, device, &chunk->allocation);
vkd3d_memory_allocation_free(&chunk->allocation, device, allocator);
vkd3d_free(chunk->free_ranges);
vkd3d_free(chunk);
@ -1104,6 +1110,9 @@ static HRESULT vkd3d_memory_allocator_try_suballocate_memory(struct vkd3d_memory
void vkd3d_free_memory_2(struct d3d12_device *device, struct vkd3d_memory_allocator *allocator,
const struct vkd3d_memory_allocation *allocation)
{
if (allocation->clear_semaphore_value)
vkd3d_memory_allocator_wait_allocation(allocator, device, allocation);
if (allocation->chunk)
{
pthread_mutex_lock(&allocator->mutex);
@ -1153,11 +1162,21 @@ static HRESULT vkd3d_suballocate_memory(struct d3d12_device *device, struct vkd3
static HRESULT vkd3d_allocate_memory_2(struct d3d12_device *device, struct vkd3d_memory_allocator *allocator,
const struct vkd3d_allocate_memory_info *info, struct vkd3d_memory_allocation *allocation)
{
HRESULT hr;
if (!info->pNext && !info->host_ptr && info->memory_requirements.size < VKD3D_VA_BLOCK_SIZE &&
!(info->heap_flags & D3D12_HEAP_FLAG_DENY_BUFFERS))
return vkd3d_suballocate_memory(device, allocator, info, allocation);
hr = vkd3d_suballocate_memory(device, allocator, info, allocation);
else
return vkd3d_memory_allocation_init(allocation, device, allocator, info);
hr = vkd3d_memory_allocation_init(allocation, device, allocator, info);
if (FAILED(hr))
return hr;
if (!(info->heap_flags & D3D12_HEAP_FLAG_CREATE_NOT_ZEROED))
vkd3d_memory_allocator_clear_allocation(allocator, device, allocation);
return hr;
}
HRESULT vkd3d_allocate_heap_memory_2(struct d3d12_device *device, struct vkd3d_memory_allocator *allocator,