Use undefined initial image layout (fixes #187), added missing layout transition for compute texture target in ray tracing example

This commit is contained in:
saschawillems 2016-06-22 20:30:14 +02:00
parent 00560f06b5
commit dbf80b217c
7 changed files with 39 additions and 34 deletions

View file

@ -128,7 +128,7 @@ public:
imageCreateInfo.arrayLayers = 1;
imageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT;
imageCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
imageCreateInfo.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
imageCreateInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
// Image will be sampled in the fragment shader and used as storage target in the compute shader
imageCreateInfo.usage =
VK_IMAGE_USAGE_SAMPLED_BIT |
@ -145,13 +145,18 @@ public:
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &tex->deviceMemory));
VK_CHECK_RESULT(vkBindImageMemory(device, tex->image, tex->deviceMemory, 0));
tex->imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
VkCommandBuffer layoutCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
tex->imageLayout = VK_IMAGE_LAYOUT_GENERAL;
vkTools::setImageLayout(
setupCmdBuffer, tex->image,
layoutCmd,
tex->image,
VK_IMAGE_ASPECT_COLOR_BIT,
VK_IMAGE_LAYOUT_PREINITIALIZED,
VK_IMAGE_LAYOUT_UNDEFINED,
tex->imageLayout);
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
// Create sampler
VkSamplerCreateInfo sampler = vkTools::initializers::samplerCreateInfo();
sampler.magFilter = VK_FILTER_LINEAR;