Corrected image usage bits and descriptor types for compute storage images (#76)
This commit is contained in:
parent
598da3670e
commit
76d41fcd6d
1 changed files with 18 additions and 14 deletions
|
|
@ -102,10 +102,10 @@ public:
|
||||||
vkFreeCommandBuffers(device, cmdPool, 1, &computeCmdBuffer);
|
vkFreeCommandBuffers(device, cmdPool, 1, &computeCmdBuffer);
|
||||||
|
|
||||||
textureLoader->destroyTexture(textureColorMap);
|
textureLoader->destroyTexture(textureColorMap);
|
||||||
|
textureLoader->destroyTexture(textureComputeTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare an empty texture as the blit target from
|
// Prepare a texture target that is used to store compute shader calculations
|
||||||
// the offscreen framebuffer
|
|
||||||
void prepareTextureTarget(vkTools::VulkanTexture *tex, uint32_t width, uint32_t height, VkFormat format)
|
void prepareTextureTarget(vkTools::VulkanTexture *tex, uint32_t width, uint32_t height, VkFormat format)
|
||||||
{
|
{
|
||||||
VkFormatProperties formatProperties;
|
VkFormatProperties formatProperties;
|
||||||
|
|
@ -113,9 +113,8 @@ public:
|
||||||
|
|
||||||
// Get device properties for the requested texture format
|
// Get device properties for the requested texture format
|
||||||
vkGetPhysicalDeviceFormatProperties(physicalDevice, format, &formatProperties);
|
vkGetPhysicalDeviceFormatProperties(physicalDevice, format, &formatProperties);
|
||||||
// Check if blit destination is supported for the requested format
|
// Check if requested image format supports image storage operations
|
||||||
// Only try for optimal tiling, linear tiling usually won't support blit as destination anyway
|
assert(formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT);
|
||||||
assert(formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_DST_BIT);
|
|
||||||
|
|
||||||
// Prepare blit target texture
|
// Prepare blit target texture
|
||||||
tex->width = width;
|
tex->width = width;
|
||||||
|
|
@ -129,8 +128,10 @@ public:
|
||||||
imageCreateInfo.arrayLayers = 1;
|
imageCreateInfo.arrayLayers = 1;
|
||||||
imageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT;
|
imageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
imageCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
|
imageCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||||
// Texture will be sampled in a shader and is also the blit destination
|
// Image will be sampled in the fragment shader and used as storage target in the compute shader
|
||||||
imageCreateInfo.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
imageCreateInfo.usage =
|
||||||
|
VK_IMAGE_USAGE_SAMPLED_BIT |
|
||||||
|
VK_IMAGE_USAGE_STORAGE_BIT;
|
||||||
imageCreateInfo.flags = 0;
|
imageCreateInfo.flags = 0;
|
||||||
|
|
||||||
VkMemoryAllocateInfo memAllocInfo = vkTools::initializers::memoryAllocateInfo();
|
VkMemoryAllocateInfo memAllocInfo = vkTools::initializers::memoryAllocateInfo();
|
||||||
|
|
@ -411,7 +412,10 @@ public:
|
||||||
std::vector<VkDescriptorPoolSize> poolSizes =
|
std::vector<VkDescriptorPoolSize> poolSizes =
|
||||||
{
|
{
|
||||||
vkTools::initializers::descriptorPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 2),
|
vkTools::initializers::descriptorPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 2),
|
||||||
|
// Graphics pipeline uses image samplers for display
|
||||||
vkTools::initializers::descriptorPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 4),
|
vkTools::initializers::descriptorPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 4),
|
||||||
|
// Compute pipeline uses storage images image loads and stores
|
||||||
|
vkTools::initializers::descriptorPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 2),
|
||||||
};
|
};
|
||||||
|
|
||||||
VkDescriptorPoolCreateInfo descriptorPoolInfo =
|
VkDescriptorPoolCreateInfo descriptorPoolInfo =
|
||||||
|
|
@ -630,12 +634,12 @@ public:
|
||||||
std::vector<VkDescriptorSetLayoutBinding> setLayoutBindings = {
|
std::vector<VkDescriptorSetLayoutBinding> setLayoutBindings = {
|
||||||
// Binding 0 : Sampled image (read)
|
// Binding 0 : Sampled image (read)
|
||||||
vkTools::initializers::descriptorSetLayoutBinding(
|
vkTools::initializers::descriptorSetLayoutBinding(
|
||||||
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||||
VK_SHADER_STAGE_COMPUTE_BIT,
|
VK_SHADER_STAGE_COMPUTE_BIT,
|
||||||
0),
|
0),
|
||||||
// Binding 1 : Sampled image (write)
|
// Binding 1 : Sampled image (write)
|
||||||
vkTools::initializers::descriptorSetLayoutBinding(
|
vkTools::initializers::descriptorSetLayoutBinding(
|
||||||
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||||
VK_SHADER_STAGE_COMPUTE_BIT,
|
VK_SHADER_STAGE_COMPUTE_BIT,
|
||||||
1),
|
1),
|
||||||
};
|
};
|
||||||
|
|
@ -676,12 +680,12 @@ public:
|
||||||
std::vector<VkDescriptorImageInfo> computeTexDescriptors =
|
std::vector<VkDescriptorImageInfo> computeTexDescriptors =
|
||||||
{
|
{
|
||||||
vkTools::initializers::descriptorImageInfo(
|
vkTools::initializers::descriptorImageInfo(
|
||||||
textureColorMap.sampler,
|
VK_NULL_HANDLE,
|
||||||
textureColorMap.view,
|
textureColorMap.view,
|
||||||
VK_IMAGE_LAYOUT_GENERAL),
|
VK_IMAGE_LAYOUT_GENERAL),
|
||||||
|
|
||||||
vkTools::initializers::descriptorImageInfo(
|
vkTools::initializers::descriptorImageInfo(
|
||||||
textureComputeTarget.sampler,
|
VK_NULL_HANDLE,
|
||||||
textureComputeTarget.view,
|
textureComputeTarget.view,
|
||||||
VK_IMAGE_LAYOUT_GENERAL)
|
VK_IMAGE_LAYOUT_GENERAL)
|
||||||
};
|
};
|
||||||
|
|
@ -691,13 +695,13 @@ public:
|
||||||
// Binding 0 : Sampled image (read)
|
// Binding 0 : Sampled image (read)
|
||||||
vkTools::initializers::writeDescriptorSet(
|
vkTools::initializers::writeDescriptorSet(
|
||||||
computeDescriptorSet,
|
computeDescriptorSet,
|
||||||
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||||
0,
|
0,
|
||||||
&computeTexDescriptors[0]),
|
&computeTexDescriptors[0]),
|
||||||
// Binding 1 : Sampled image (write)
|
// Binding 1 : Sampled image (write)
|
||||||
vkTools::initializers::writeDescriptorSet(
|
vkTools::initializers::writeDescriptorSet(
|
||||||
computeDescriptorSet,
|
computeDescriptorSet,
|
||||||
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||||
1,
|
1,
|
||||||
&computeTexDescriptors[1])
|
&computeTexDescriptors[1])
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue