1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-04-05 16:40:17 +02:00

[dxvk] Clean up buffer and buffer view creation code

This commit is contained in:
Philip Rebohle 2022-07-18 14:21:23 +02:00
parent 0b11995dea
commit d29d403c67
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99

View File

@ -58,15 +58,10 @@ namespace dxvk {
DxvkBufferHandle DxvkBuffer::allocBuffer(VkDeviceSize sliceCount, bool clear) const { DxvkBufferHandle DxvkBuffer::allocBuffer(VkDeviceSize sliceCount, bool clear) const {
auto vkd = m_device->vkd(); auto vkd = m_device->vkd();
VkBufferCreateInfo info; VkBufferCreateInfo info = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
info.pNext = nullptr;
info.flags = 0;
info.size = m_physSliceStride * sliceCount; info.size = m_physSliceStride * sliceCount;
info.usage = m_info.usage; info.usage = m_info.usage;
info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
info.queueFamilyIndexCount = 0;
info.pQueueFamilyIndices = nullptr;
DxvkBufferHandle handle; DxvkBufferHandle handle;
@ -78,26 +73,14 @@ namespace dxvk {
"\n usage: ", info.usage)); "\n usage: ", info.usage));
} }
VkMemoryDedicatedRequirements dedicatedRequirements; VkMemoryDedicatedRequirements dedicatedRequirements = { VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS };
dedicatedRequirements.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS; VkMemoryRequirements2 memReq = { VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2, &dedicatedRequirements };
dedicatedRequirements.pNext = VK_NULL_HANDLE;
dedicatedRequirements.prefersDedicatedAllocation = VK_FALSE;
dedicatedRequirements.requiresDedicatedAllocation = VK_FALSE;
VkMemoryRequirements2 memReq; VkBufferMemoryRequirementsInfo2 memReqInfo = { VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2 };
memReq.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2;
memReq.pNext = &dedicatedRequirements;
VkBufferMemoryRequirementsInfo2 memReqInfo;
memReqInfo.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2;
memReqInfo.buffer = handle.buffer; memReqInfo.buffer = handle.buffer;
memReqInfo.pNext = VK_NULL_HANDLE;
VkMemoryDedicatedAllocateInfo dedMemoryAllocInfo; VkMemoryDedicatedAllocateInfo dedMemoryAllocInfo = { VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO };
dedMemoryAllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO;
dedMemoryAllocInfo.pNext = VK_NULL_HANDLE;
dedMemoryAllocInfo.buffer = handle.buffer; dedMemoryAllocInfo.buffer = handle.buffer;
dedMemoryAllocInfo.image = VK_NULL_HANDLE;
vkd->vkGetBufferMemoryRequirements2( vkd->vkGetBufferMemoryRequirements2(
vkd->device(), &memReqInfo, &memReq); vkd->device(), &memReqInfo, &memReq);
@ -199,10 +182,7 @@ namespace dxvk {
VkBufferView DxvkBufferView::createBufferView( VkBufferView DxvkBufferView::createBufferView(
const DxvkBufferSliceHandle& slice) { const DxvkBufferSliceHandle& slice) {
VkBufferViewCreateInfo viewInfo; VkBufferViewCreateInfo viewInfo = { VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO };
viewInfo.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO;
viewInfo.pNext = nullptr;
viewInfo.flags = 0;
viewInfo.buffer = slice.handle; viewInfo.buffer = slice.handle;
viewInfo.format = m_info.format; viewInfo.format = m_info.format;
viewInfo.offset = slice.offset; viewInfo.offset = slice.offset;