Mesa (main): dzn: Lower alignment requirements when allocating buffers or single-sample images
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jun 14 23:17:14 UTC 2022
Module: Mesa
Branch: main
Commit: fb52be93762b34d49c547058478c36a449a28383
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fb52be93762b34d49c547058478c36a449a28383
Author: Boris Brezillon <boris.brezillon at collabora.com>
Date: Tue Apr 19 11:12:53 2022 +0200
dzn: Lower alignment requirements when allocating buffers or single-sample images
VkMemoryDedicatedAllocateInfo, when present, provides us with extra
information about the memory usage, which allow us to lower the alignment
requirements.
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16926>
---
src/microsoft/vulkan/dzn_device.c | 32 +++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/src/microsoft/vulkan/dzn_device.c b/src/microsoft/vulkan/dzn_device.c
index 65a113c1f1c..d156f9c8864 100644
--- a/src/microsoft/vulkan/dzn_device.c
+++ b/src/microsoft/vulkan/dzn_device.c
@@ -2142,6 +2142,9 @@ dzn_device_memory_create(struct dzn_device *device,
mem->size = pAllocateInfo->allocationSize;
+ const struct dzn_buffer *buffer = NULL;
+ const struct dzn_image *image = NULL;
+
vk_foreach_struct_const(ext, pAllocateInfo->pNext) {
switch (ext->sType) {
case VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO: {
@@ -2152,6 +2155,15 @@ dzn_device_memory_create(struct dzn_device *device,
assert(exp->handleTypes == 0);
break;
}
+ case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO: {
+ const VkMemoryDedicatedAllocateInfo *dedicated =
+ (const VkMemoryDedicatedAllocateInfo *)ext;
+
+ buffer = dzn_buffer_from_handle(dedicated->buffer);
+ image = dzn_image_from_handle(dedicated->image);
+ assert(!buffer || !image);
+ break;
+ }
default:
dzn_debug_ignored_stype(ext->sType);
break;
@@ -2162,12 +2174,22 @@ dzn_device_memory_create(struct dzn_device *device,
&pdevice->memory.memoryTypes[pAllocateInfo->memoryTypeIndex];
D3D12_HEAP_DESC heap_desc = { 0 };
- // TODO: fix all of these:
+
heap_desc.SizeInBytes = pAllocateInfo->allocationSize;
- heap_desc.Alignment =
- heap_desc.SizeInBytes >= D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT ?
- D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT :
- D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
+ if (buffer) {
+ heap_desc.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
+ } else if (image) {
+ heap_desc.Alignment =
+ image->vk.samples > 1 ?
+ D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT :
+ D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
+ } else {
+ heap_desc.Alignment =
+ heap_desc.SizeInBytes >= D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT ?
+ D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT :
+ D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
+ }
+
heap_desc.Flags =
dzn_physical_device_get_heap_flags_for_mem_type(pdevice,
pAllocateInfo->memoryTypeIndex);
More information about the mesa-commit
mailing list