Fix uninitialized variable used in vkCmdCopyBufferToImage().

This commit is contained in:
Tayfun Kayhan 2020-01-10 13:28:56 +01:00
parent 8668606a14
commit 2843f4f03b
3 changed files with 57 additions and 54 deletions

View file

@ -84,7 +84,7 @@ public:
~VulkanExample()
{
// Clean up used Vulkan resources
// Clean up used Vulkan resources
// Note : Inherited destructor cleans up resources stored in base class
// Clean up texture resources
@ -108,7 +108,7 @@ public:
uniformBuffers.skybox.destroy();
}
// Enable physical device features required for this example
// Enable physical device features required for this example
virtual void getEnabledFeatures()
{
if (deviceFeatures.samplerAnisotropy) {
@ -150,7 +150,7 @@ public:
vks::tools::exitFatal("Could not load texture from " + filename + "\n\nThe file may be part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", -1);
}
result = ktxTexture_CreateFromNamedFile(filename.c_str(), KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT, &ktxTexture);
#endif
#endif
assert(result == KTX_SUCCESS);
// Get properties required for using and upload texture data from the ktx texture object
@ -227,7 +227,8 @@ public:
{
// Calculate offset into staging buffer for the current mip level and face
ktx_size_t offset;
assert(ktxTexture_GetImageOffset(ktxTexture, level, 0, face, &offset) == KTX_SUCCESS);
KTX_error_code ret = ktxTexture_GetImageOffset(ktxTexture, level, 0, face, &offset);
assert(ret == KTX_SUCCESS);
VkBufferImageCopy bufferCopyRegion = {};
bufferCopyRegion.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
bufferCopyRegion.imageSubresource.mipLevel = level;
@ -424,7 +425,7 @@ public:
vks::initializers::descriptorPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 2)
};
VkDescriptorPoolCreateInfo descriptorPoolInfo =
VkDescriptorPoolCreateInfo descriptorPoolInfo =
vks::initializers::descriptorPoolCreateInfo(
poolSizes.size(),
poolSizes.data(),
@ -435,21 +436,21 @@ public:
void setupDescriptorSetLayout()
{
std::vector<VkDescriptorSetLayoutBinding> setLayoutBindings =
std::vector<VkDescriptorSetLayoutBinding> setLayoutBindings =
{
// Binding 0 : Vertex shader uniform buffer
vks::initializers::descriptorSetLayoutBinding(
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
VK_SHADER_STAGE_VERTEX_BIT,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
VK_SHADER_STAGE_VERTEX_BIT,
0),
// Binding 1 : Fragment shader image sampler
vks::initializers::descriptorSetLayoutBinding(
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
VK_SHADER_STAGE_FRAGMENT_BIT,
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
VK_SHADER_STAGE_FRAGMENT_BIT,
1)
};
VkDescriptorSetLayoutCreateInfo descriptorLayout =
VkDescriptorSetLayoutCreateInfo descriptorLayout =
vks::initializers::descriptorSetLayoutCreateInfo(
setLayoutBindings.data(),
setLayoutBindings.size());
@ -486,15 +487,15 @@ public:
{
// Binding 0 : Vertex shader uniform buffer
vks::initializers::writeDescriptorSet(
descriptorSets.object,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
0,
descriptorSets.object,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
0,
&uniformBuffers.object.descriptor),
// Binding 1 : Fragment shader cubemap sampler
vks::initializers::writeDescriptorSet(
descriptorSets.object,
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
1,
descriptorSets.object,
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
1,
&textureDescriptor)
};
vkUpdateDescriptorSets(device, writeDescriptorSets.size(), writeDescriptorSets.data(), 0, NULL);
@ -542,7 +543,7 @@ public:
VkPipelineColorBlendStateCreateInfo colorBlendState =
vks::initializers::pipelineColorBlendStateCreateInfo(
1,
1,
&blendAttachmentState);
VkPipelineDepthStencilStateCreateInfo depthStencilState =