Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/HansKristian-Work/vkd3d-proton.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Kristian Arntzen <post@arntzen-software.no>2022-09-22 18:30:50 +0300
committerHans-Kristian Arntzen <post@arntzen-software.no>2022-11-10 16:28:46 +0300
commit1700b792199a23abd4ee750fd919c891960d440c (patch)
tree51ca86b85691a6f32b66edb5bac30eb2a7fecf1c
parent43a461a9a77515ab95b383ceb3a3f03ee2fcfc52 (diff)
vkd3d: Add scratch pool for upload data.
To be used for inline UBO replacement. Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
-rw-r--r--libs/vkd3d/command.c6
-rw-r--r--libs/vkd3d/device.c18
-rw-r--r--libs/vkd3d/vkd3d_private.h1
3 files changed, 25 insertions, 0 deletions
diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c
index 4b7b1356..548ee121 100644
--- a/libs/vkd3d/command.c
+++ b/libs/vkd3d/command.c
@@ -2433,6 +2433,7 @@ struct vkd3d_scratch_allocation
VkBuffer buffer;
VkDeviceSize offset;
VkDeviceAddress va;
+ void *host_ptr;
};
static bool d3d12_command_allocator_allocate_scratch_memory(struct d3d12_command_allocator *allocator,
@@ -2465,6 +2466,10 @@ static bool d3d12_command_allocator_allocate_scratch_memory(struct d3d12_command
allocation->buffer = scratch->allocation.resource.vk_buffer;
allocation->offset = scratch->allocation.offset + aligned_offset;
allocation->va = scratch->allocation.resource.va + aligned_offset;
+ if (scratch->allocation.cpu_address)
+ allocation->host_ptr = void_ptr_offset(scratch->allocation.cpu_address, aligned_offset);
+ else
+ allocation->host_ptr = NULL;
return true;
}
}
@@ -2489,6 +2494,7 @@ static bool d3d12_command_allocator_allocate_scratch_memory(struct d3d12_command
allocation->buffer = scratch->allocation.resource.vk_buffer;
allocation->offset = scratch->allocation.offset;
allocation->va = scratch->allocation.resource.va;
+ allocation->host_ptr = scratch->allocation.cpu_address;
return true;
}
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index b5baaebf..e12699f5 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -2696,6 +2696,24 @@ static HRESULT d3d12_device_create_scratch_buffer(struct d3d12_device *device, e
&alloc_info, &scratch->allocation)))
return hr;
}
+ else if (kind == VKD3D_SCRATCH_POOL_KIND_UNIFORM_UPLOAD)
+ {
+ struct vkd3d_allocate_heap_memory_info alloc_info;
+
+ /* We only care about memory types for INDIRECT_PREPROCESS. */
+ assert(memory_types == ~0u);
+
+ memset(&alloc_info, 0, sizeof(alloc_info));
+ alloc_info.heap_desc.Properties.Type = D3D12_HEAP_TYPE_UPLOAD;
+ alloc_info.heap_desc.SizeInBytes = size;
+ alloc_info.heap_desc.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
+ alloc_info.heap_desc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS | D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
+ alloc_info.extra_allocation_flags = VKD3D_ALLOCATION_FLAG_INTERNAL_SCRATCH;
+
+ if (FAILED(hr = vkd3d_allocate_heap_memory(device, &device->memory_allocator,
+ &alloc_info, &scratch->allocation)))
+ return hr;
+ }
else
{
return E_INVALIDARG;
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index 797ca0a3..3fac5f43 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -1989,6 +1989,7 @@ enum vkd3d_scratch_pool_kind
{
VKD3D_SCRATCH_POOL_KIND_DEVICE_STORAGE = 0,
VKD3D_SCRATCH_POOL_KIND_INDIRECT_PREPROCESS,
+ VKD3D_SCRATCH_POOL_KIND_UNIFORM_UPLOAD,
VKD3D_SCRATCH_POOL_KIND_COUNT
};