Small fixes and code refactoring for Tutorial07.

This commit is contained in:
Pawel Lapinski
2018-02-22 14:11:20 +01:00
parent 7b4dca8586
commit 4bf7361221

View File

@@ -471,7 +471,7 @@ namespace ApiWithoutSecrets {
return false; return false;
} }
memcpy( staging_buffer_memory_pointer, &uniform_data[0], Vulkan.UniformBuffer.Size ); memcpy( staging_buffer_memory_pointer, uniform_data.data(), Vulkan.UniformBuffer.Size );
VkMappedMemoryRange flush_range = { VkMappedMemoryRange flush_range = {
VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // VkStructureType sType VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // VkStructureType sType
@@ -485,6 +485,8 @@ namespace ApiWithoutSecrets {
vkUnmapMemory( GetDevice(), Vulkan.StagingBuffer.Memory ); vkUnmapMemory( GetDevice(), Vulkan.StagingBuffer.Memory );
// Prepare command buffer to copy data from staging buffer to a uniform buffer // Prepare command buffer to copy data from staging buffer to a uniform buffer
VkCommandBuffer command_buffer = Vulkan.RenderingResources[0].CommandBuffer;
VkCommandBufferBeginInfo command_buffer_begin_info = { VkCommandBufferBeginInfo command_buffer_begin_info = {
VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType
nullptr, // const void *pNext nullptr, // const void *pNext
@@ -492,8 +494,6 @@ namespace ApiWithoutSecrets {
nullptr // const VkCommandBufferInheritanceInfo *pInheritanceInfo nullptr // const VkCommandBufferInheritanceInfo *pInheritanceInfo
}; };
VkCommandBuffer command_buffer = Vulkan.RenderingResources[0].CommandBuffer;
vkBeginCommandBuffer( command_buffer, &command_buffer_begin_info); vkBeginCommandBuffer( command_buffer, &command_buffer_begin_info);
VkBufferCopy buffer_copy_info = { VkBufferCopy buffer_copy_info = {
@@ -506,7 +506,7 @@ namespace ApiWithoutSecrets {
VkBufferMemoryBarrier buffer_memory_barrier = { VkBufferMemoryBarrier buffer_memory_barrier = {
VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType; VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
nullptr, // const void *pNext nullptr, // const void *pNext
VK_ACCESS_MEMORY_WRITE_BIT, // VkAccessFlags srcAccessMask VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask
VK_ACCESS_UNIFORM_READ_BIT, // VkAccessFlags dstAccessMask VK_ACCESS_UNIFORM_READ_BIT, // VkAccessFlags dstAccessMask
VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex
VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex
@@ -536,7 +536,6 @@ namespace ApiWithoutSecrets {
} }
vkDeviceWaitIdle( GetDevice() ); vkDeviceWaitIdle( GetDevice() );
return true; return true;
} }
@@ -563,7 +562,7 @@ namespace ApiWithoutSecrets {
nullptr, // const void *pNext nullptr, // const void *pNext
0, // VkDescriptorSetLayoutCreateFlags flags 0, // VkDescriptorSetLayoutCreateFlags flags
static_cast<uint32_t>(layout_bindings.size()), // uint32_t bindingCount static_cast<uint32_t>(layout_bindings.size()), // uint32_t bindingCount
&layout_bindings[0] // const VkDescriptorSetLayoutBinding *pBindings layout_bindings.data() // const VkDescriptorSetLayoutBinding *pBindings
}; };
if( vkCreateDescriptorSetLayout( GetDevice(), &descriptor_set_layout_create_info, nullptr, &Vulkan.DescriptorSet.Layout ) != VK_SUCCESS ) { if( vkCreateDescriptorSetLayout( GetDevice(), &descriptor_set_layout_create_info, nullptr, &Vulkan.DescriptorSet.Layout ) != VK_SUCCESS ) {
@@ -592,7 +591,7 @@ namespace ApiWithoutSecrets {
0, // VkDescriptorPoolCreateFlags flags 0, // VkDescriptorPoolCreateFlags flags
1, // uint32_t maxSets 1, // uint32_t maxSets
static_cast<uint32_t>(pool_sizes.size()), // uint32_t poolSizeCount static_cast<uint32_t>(pool_sizes.size()), // uint32_t poolSizeCount
&pool_sizes[0] // const VkDescriptorPoolSize *pPoolSizes pool_sizes.data() // const VkDescriptorPoolSize *pPoolSizes
}; };
if( vkCreateDescriptorPool( GetDevice(), &descriptor_pool_create_info, nullptr, &Vulkan.DescriptorSet.Pool ) != VK_SUCCESS ) { if( vkCreateDescriptorPool( GetDevice(), &descriptor_pool_create_info, nullptr, &Vulkan.DescriptorSet.Pool ) != VK_SUCCESS ) {
@@ -736,7 +735,6 @@ namespace ApiWithoutSecrets {
std::cout << "Could not create pipeline layout!" << std::endl; std::cout << "Could not create pipeline layout!" << std::endl;
return false; return false;
} }
return true; return true;
} }