vk_buffer_cache: Make use of designated initializers where applicable

Note: An array within CopyFrom() cannot be converted over yet, as it
ICEs MSVC when converted over.
This commit is contained in:
Lioncash 2020-07-16 16:59:35 -04:00
parent 104c523d3d
commit a66a0a6a53

View file

@ -39,16 +39,17 @@ std::unique_ptr<VKStreamBuffer> CreateStreamBuffer(const VKDevice& device, VKSch
Buffer::Buffer(const VKDevice& device, VKMemoryManager& memory_manager, VKScheduler& scheduler_, Buffer::Buffer(const VKDevice& device, VKMemoryManager& memory_manager, VKScheduler& scheduler_,
VKStagingBufferPool& staging_pool_, VAddr cpu_addr, std::size_t size) VKStagingBufferPool& staging_pool_, VAddr cpu_addr, std::size_t size)
: VideoCommon::BufferBlock{cpu_addr, size}, scheduler{scheduler_}, staging_pool{staging_pool_} { : BufferBlock{cpu_addr, size}, scheduler{scheduler_}, staging_pool{staging_pool_} {
VkBufferCreateInfo ci; const VkBufferCreateInfo ci{
ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
ci.pNext = nullptr; .pNext = nullptr,
ci.flags = 0; .flags = 0,
ci.size = static_cast<VkDeviceSize>(size); .size = static_cast<VkDeviceSize>(size),
ci.usage = BUFFER_USAGE | VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; .usage = BUFFER_USAGE | VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; .sharingMode = VK_SHARING_MODE_EXCLUSIVE,
ci.queueFamilyIndexCount = 0; .queueFamilyIndexCount = 0,
ci.pQueueFamilyIndices = nullptr; .pQueueFamilyIndices = nullptr,
};
buffer.handle = device.GetLogical().CreateBuffer(ci); buffer.handle = device.GetLogical().CreateBuffer(ci);
buffer.commit = memory_manager.Commit(buffer.handle, false); buffer.commit = memory_manager.Commit(buffer.handle, false);
@ -66,16 +67,17 @@ void Buffer::Upload(std::size_t offset, std::size_t size, const u8* data) {
scheduler.Record([staging = *staging.handle, handle, offset, size](vk::CommandBuffer cmdbuf) { scheduler.Record([staging = *staging.handle, handle, offset, size](vk::CommandBuffer cmdbuf) {
cmdbuf.CopyBuffer(staging, handle, VkBufferCopy{0, offset, size}); cmdbuf.CopyBuffer(staging, handle, VkBufferCopy{0, offset, size});
VkBufferMemoryBarrier barrier; const VkBufferMemoryBarrier barrier{
barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
barrier.pNext = nullptr; .pNext = nullptr,
barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
barrier.dstAccessMask = UPLOAD_ACCESS_BARRIERS; .dstAccessMask = UPLOAD_ACCESS_BARRIERS,
barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
barrier.buffer = handle; .buffer = handle,
barrier.offset = offset; .offset = offset,
barrier.size = size; .size = size,
};
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, UPLOAD_PIPELINE_STAGE, 0, {}, cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, UPLOAD_PIPELINE_STAGE, 0, {},
barrier, {}); barrier, {});
}); });
@ -87,16 +89,17 @@ void Buffer::Download(std::size_t offset, std::size_t size, u8* data) {
const VkBuffer handle = Handle(); const VkBuffer handle = Handle();
scheduler.Record([staging = *staging.handle, handle, offset, size](vk::CommandBuffer cmdbuf) { scheduler.Record([staging = *staging.handle, handle, offset, size](vk::CommandBuffer cmdbuf) {
VkBufferMemoryBarrier barrier; const VkBufferMemoryBarrier barrier{
barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
barrier.pNext = nullptr; .pNext = nullptr,
barrier.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT; .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
barrier.buffer = handle; .buffer = handle,
barrier.offset = offset; .offset = offset,
barrier.size = size; .size = size,
};
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_VERTEX_SHADER_BIT |
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT |