forked from suyu/suyu
vk_stream_buffer: Make use of designated initializers where applicable
This commit is contained in:
parent
70147e913f
commit
3c060503bc
1 changed files with 16 additions and 19 deletions
|
@ -122,30 +122,27 @@ void VKStreamBuffer::CreateBuffers(VkBufferUsageFlags usage) {
|
||||||
// Substract from the preferred heap size some bytes to avoid getting out of memory.
|
// Substract from the preferred heap size some bytes to avoid getting out of memory.
|
||||||
const VkDeviceSize heap_size = memory_properties.memoryHeaps[preferred_heap].size;
|
const VkDeviceSize heap_size = memory_properties.memoryHeaps[preferred_heap].size;
|
||||||
const VkDeviceSize allocable_size = heap_size - 9 * 1024 * 1024;
|
const VkDeviceSize allocable_size = heap_size - 9 * 1024 * 1024;
|
||||||
|
buffer = device.GetLogical().CreateBuffer({
|
||||||
VkBufferCreateInfo buffer_ci;
|
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
||||||
buffer_ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
|
.pNext = nullptr,
|
||||||
buffer_ci.pNext = nullptr;
|
.flags = 0,
|
||||||
buffer_ci.flags = 0;
|
.size = std::min(PREFERRED_STREAM_BUFFER_SIZE, allocable_size),
|
||||||
buffer_ci.size = std::min(PREFERRED_STREAM_BUFFER_SIZE, allocable_size);
|
.usage = usage,
|
||||||
buffer_ci.usage = usage;
|
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
||||||
buffer_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
.queueFamilyIndexCount = 0,
|
||||||
buffer_ci.queueFamilyIndexCount = 0;
|
.pQueueFamilyIndices = nullptr,
|
||||||
buffer_ci.pQueueFamilyIndices = nullptr;
|
});
|
||||||
|
|
||||||
buffer = device.GetLogical().CreateBuffer(buffer_ci);
|
|
||||||
|
|
||||||
const auto requirements = device.GetLogical().GetBufferMemoryRequirements(*buffer);
|
const auto requirements = device.GetLogical().GetBufferMemoryRequirements(*buffer);
|
||||||
const u32 required_flags = requirements.memoryTypeBits;
|
const u32 required_flags = requirements.memoryTypeBits;
|
||||||
stream_buffer_size = static_cast<u64>(requirements.size);
|
stream_buffer_size = static_cast<u64>(requirements.size);
|
||||||
|
|
||||||
VkMemoryAllocateInfo memory_ai;
|
memory = device.GetLogical().AllocateMemory({
|
||||||
memory_ai.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
|
||||||
memory_ai.pNext = nullptr;
|
.pNext = nullptr,
|
||||||
memory_ai.allocationSize = requirements.size;
|
.allocationSize = requirements.size,
|
||||||
memory_ai.memoryTypeIndex = GetMemoryType(memory_properties, required_flags);
|
.memoryTypeIndex = GetMemoryType(memory_properties, required_flags),
|
||||||
|
});
|
||||||
memory = device.GetLogical().AllocateMemory(memory_ai);
|
|
||||||
buffer.BindMemory(*memory, 0);
|
buffer.BindMemory(*memory, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue