Resolve validation layer issues with some samples.

This commit is contained in:
asuessenbach 2022-05-02 09:43:45 +02:00
parent 75e18ca7a5
commit 0fb855a4a2
23 changed files with 114 additions and 96 deletions

View File

@ -96,7 +96,8 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::DescriptorPool descriptorPool = vk::raii::su::makeDescriptorPool( device, { { vk::DescriptorType::eUniformBuffer, 1 } } ); vk::raii::DescriptorPool descriptorPool = vk::raii::su::makeDescriptorPool( device, { { vk::DescriptorType::eUniformBuffer, 1 } } );
vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, { *descriptorPool, *descriptorSetLayout } ).front() ); vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, { *descriptorPool, *descriptorSetLayout } ).front() );
vk::raii::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, nullptr } }, {} ); vk::raii::su::updateDescriptorSets(
device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, nullptr } }, {} );
vk::raii::PipelineCache pipelineCache( device, vk::PipelineCacheCreateInfo() ); vk::raii::PipelineCache pipelineCache( device, vk::PipelineCacheCreateInfo() );
vk::raii::Pipeline graphicsPipeline = vk::raii::Pipeline graphicsPipeline =

View File

@ -96,7 +96,8 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::makeDescriptorPool( device, { { vk::DescriptorType::eUniformBuffer, 1 }, { vk::DescriptorType::eCombinedImageSampler, 1 } } ); vk::raii::su::makeDescriptorPool( device, { { vk::DescriptorType::eUniformBuffer, 1 }, { vk::DescriptorType::eCombinedImageSampler, 1 } } );
vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, { *descriptorPool, *descriptorSetLayout } ).front() ); vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, { *descriptorPool, *descriptorSetLayout } ).front() );
vk::raii::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, nullptr } }, { textureData } ); vk::raii::su::updateDescriptorSets(
device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, nullptr } }, { textureData } );
vk::raii::PipelineCache pipelineCache( device, vk::PipelineCacheCreateInfo() ); vk::raii::PipelineCache pipelineCache( device, vk::PipelineCacheCreateInfo() );
vk::raii::Pipeline graphicsPipeline = vk::raii::su::makeGraphicsPipeline( device, vk::raii::Pipeline graphicsPipeline = vk::raii::su::makeGraphicsPipeline( device,

View File

@ -124,7 +124,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::DescriptorPool descriptorPool = vk::raii::su::makeDescriptorPool( device, { { vk::DescriptorType::eUniformBufferDynamic, 1 } } ); vk::raii::DescriptorPool descriptorPool = vk::raii::su::makeDescriptorPool( device, { { vk::DescriptorType::eUniformBufferDynamic, 1 } } );
vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, { *descriptorPool, *descriptorSetLayout } ).front() ); vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, { *descriptorPool, *descriptorSetLayout } ).front() );
vk::raii::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBufferDynamic, uniformBufferData.buffer, nullptr } }, {} ); vk::raii::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBufferDynamic, uniformBufferData.buffer, bufferSize, nullptr } }, {} );
vk::raii::PipelineCache pipelineCache( device, vk::PipelineCacheCreateInfo() ); vk::raii::PipelineCache pipelineCache( device, vk::PipelineCacheCreateInfo() );
vk::raii::Pipeline graphicsPipeline = vk::raii::su::makeGraphicsPipeline( device, vk::raii::Pipeline graphicsPipeline = vk::raii::su::makeGraphicsPipeline( device,

View File

@ -95,7 +95,8 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::DescriptorPool descriptorPool = vk::raii::su::makeDescriptorPool( device, { { vk::DescriptorType::eUniformBuffer, 1 } } ); vk::raii::DescriptorPool descriptorPool = vk::raii::su::makeDescriptorPool( device, { { vk::DescriptorType::eUniformBuffer, 1 } } );
vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, { *descriptorPool, *descriptorSetLayout } ).front() ); vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, { *descriptorPool, *descriptorSetLayout } ).front() );
vk::raii::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, nullptr } }, {} ); vk::raii::su::updateDescriptorSets(
device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, nullptr } }, {} );
vk::raii::PipelineCache pipelineCache( device, vk::PipelineCacheCreateInfo() ); vk::raii::PipelineCache pipelineCache( device, vk::PipelineCacheCreateInfo() );
vk::raii::Pipeline graphicsPipeline = vk::raii::su::makeGraphicsPipeline( device, vk::raii::Pipeline graphicsPipeline = vk::raii::su::makeGraphicsPipeline( device,

View File

@ -137,7 +137,8 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::makeDescriptorPool( device, { { vk::DescriptorType::eUniformBuffer, 1 }, { vk::DescriptorType::eCombinedImageSampler, 1 } } ); vk::raii::su::makeDescriptorPool( device, { { vk::DescriptorType::eUniformBuffer, 1 }, { vk::DescriptorType::eCombinedImageSampler, 1 } } );
vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, { *descriptorPool, *descriptorSetLayout } ).front() ); vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, { *descriptorPool, *descriptorSetLayout } ).front() );
vk::raii::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, nullptr } }, { textureData } ); vk::raii::su::updateDescriptorSets(
device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, nullptr } }, { textureData } );
/* VULKAN_KEY_START */ /* VULKAN_KEY_START */

View File

@ -104,7 +104,8 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::makeDescriptorPool( device, { { vk::DescriptorType::eUniformBuffer, 1 }, { vk::DescriptorType::eCombinedImageSampler, 1 } } ); vk::raii::su::makeDescriptorPool( device, { { vk::DescriptorType::eUniformBuffer, 1 }, { vk::DescriptorType::eCombinedImageSampler, 1 } } );
vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, { *descriptorPool, *descriptorSetLayout } ).front() ); vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, { *descriptorPool, *descriptorSetLayout } ).front() );
vk::raii::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, nullptr } }, { textureData } ); vk::raii::su::updateDescriptorSets(
device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, nullptr } }, { textureData } );
vk::raii::PipelineCache pipelineCache( device, vk::PipelineCacheCreateInfo() ); vk::raii::PipelineCache pipelineCache( device, vk::PipelineCacheCreateInfo() );

View File

@ -712,10 +712,13 @@ int main( int /*argc*/, char ** /*argv*/ )
// Create a Device with ray tracing support (besides some other extensions needed) and needed features // Create a Device with ray tracing support (besides some other extensions needed) and needed features
auto supportedFeatures = physicalDevice.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>(); auto supportedFeatures = physicalDevice.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>();
vk::raii::Device device = vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice,
vk::raii::su::makeDevice( physicalDevice,
graphicsAndPresentQueueFamilyIndex.first, graphicsAndPresentQueueFamilyIndex.first,
{ VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_NV_RAY_TRACING_EXTENSION_NAME, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME }, { VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME,
VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME,
VK_KHR_MAINTENANCE_3_EXTENSION_NAME,
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
VK_NV_RAY_TRACING_EXTENSION_NAME },
&supportedFeatures.get<vk::PhysicalDeviceFeatures2>().features, &supportedFeatures.get<vk::PhysicalDeviceFeatures2>().features,
&supportedFeatures.get<vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>() ); &supportedFeatures.get<vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>() );
@ -874,10 +877,10 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::BufferData uniformBufferData( physicalDevice, device, sizeof( UniformBufferObject ), vk::BufferUsageFlagBits::eUniformBuffer ); vk::raii::su::BufferData uniformBufferData( physicalDevice, device, sizeof( UniformBufferObject ), vk::BufferUsageFlagBits::eUniformBuffer );
vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, { *descriptorPool, *descriptorSetLayout } ).front() ); vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, { *descriptorPool, *descriptorSetLayout } ).front() );
vk::raii::su::updateDescriptorSets( vk::raii::su::updateDescriptorSets( device,
device,
descriptorSet, descriptorSet,
{ { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} }, { vk::DescriptorType::eStorageBuffer, materialBufferData.buffer, {} } }, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, {} },
{ vk::DescriptorType::eStorageBuffer, materialBufferData.buffer, VK_WHOLE_SIZE, {} } },
textures ); textures );
// RayTracing specific stuff // RayTracing specific stuff
@ -974,10 +977,10 @@ int main( int /*argc*/, char ** /*argv*/ )
{ {
vk::raii::su::updateDescriptorSets( device, vk::raii::su::updateDescriptorSets( device,
rayTracingDescriptorSets[i], rayTracingDescriptorSets[i],
{ { bindings[2].descriptorType, uniformBufferData.buffer, {} }, { { bindings[2].descriptorType, uniformBufferData.buffer, VK_WHOLE_SIZE, {} },
{ bindings[3].descriptorType, vertexBufferData.buffer, {} }, { bindings[3].descriptorType, vertexBufferData.buffer, VK_WHOLE_SIZE, {} },
{ bindings[4].descriptorType, indexBufferData.buffer, {} }, { bindings[4].descriptorType, indexBufferData.buffer, VK_WHOLE_SIZE, {} },
{ bindings[5].descriptorType, materialBufferData.buffer, {} } }, { bindings[5].descriptorType, materialBufferData.buffer, VK_WHOLE_SIZE, {} } },
textures, textures,
2 ); 2 );
} }

View File

@ -129,9 +129,10 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::DescriptorSets descriptorSets( device, descriptorSetAllocateInfo ); vk::raii::DescriptorSets descriptorSets( device, descriptorSetAllocateInfo );
assert( descriptorSets.size() == 2 ); assert( descriptorSets.size() == 2 );
vk::raii::su::updateDescriptorSets( device, descriptorSets[0], { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} } }, greenTextureData );
vk::raii::su::updateDescriptorSets( vk::raii::su::updateDescriptorSets(
device, descriptorSets[1], { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} } }, checkeredTextureData ); device, descriptorSets[0], { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, {} } }, greenTextureData );
vk::raii::su::updateDescriptorSets(
device, descriptorSets[1], { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, {} } }, checkeredTextureData );
/* VULKAN_KEY_START */ /* VULKAN_KEY_START */

View File

@ -96,7 +96,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::makeDescriptorPool( device, { { vk::DescriptorType::eUniformBuffer, 1 }, { vk::DescriptorType::eCombinedImageSampler, 1 } } ); vk::raii::su::makeDescriptorPool( device, { { vk::DescriptorType::eUniformBuffer, 1 }, { vk::DescriptorType::eCombinedImageSampler, 1 } } );
vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, { *descriptorPool, *descriptorSetLayout } ).front() ); vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, { *descriptorPool, *descriptorSetLayout } ).front() );
vk::raii::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, nullptr } }, { textureData } ); vk::raii::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, nullptr } }, { textureData } );
vk::raii::PipelineCache pipelineCache( device, vk::PipelineCacheCreateInfo() ); vk::raii::PipelineCache pipelineCache( device, vk::PipelineCacheCreateInfo() );
vk::raii::Pipeline graphicsPipeline = vk::raii::su::makeGraphicsPipeline( device, vk::raii::Pipeline graphicsPipeline = vk::raii::su::makeGraphicsPipeline( device,

View File

@ -127,7 +127,8 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::DescriptorPool descriptorPool = vk::raii::su::makeDescriptorPool( device, { { vk::DescriptorType::eUniformTexelBuffer, 1 } } ); vk::raii::DescriptorPool descriptorPool = vk::raii::su::makeDescriptorPool( device, { { vk::DescriptorType::eUniformTexelBuffer, 1 } } );
vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, { *descriptorPool, *descriptorSetLayout } ).front() ); vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, { *descriptorPool, *descriptorSetLayout } ).front() );
vk::raii::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformTexelBuffer, texelBufferData.buffer, &texelBufferView } }, {} ); vk::raii::su::updateDescriptorSets(
device, descriptorSet, { { vk::DescriptorType::eUniformTexelBuffer, texelBufferData.buffer, VK_WHOLE_SIZE, &texelBufferView } }, {} );
vk::raii::PipelineCache pipelineCache( device, vk::PipelineCacheCreateInfo() ); vk::raii::PipelineCache pipelineCache( device, vk::PipelineCacheCreateInfo() );
vk::raii::Pipeline graphicsPipeline = vk::raii::su::makeGraphicsPipeline( vk::raii::Pipeline graphicsPipeline = vk::raii::su::makeGraphicsPipeline(

View File

@ -815,9 +815,10 @@ namespace vk
; ;
} }
void updateDescriptorSets( vk::raii::Device const & device, void updateDescriptorSets(
vk::raii::Device const & device,
vk::raii::DescriptorSet const & descriptorSet, vk::raii::DescriptorSet const & descriptorSet,
std::vector<std::tuple<vk::DescriptorType, vk::raii::Buffer const &, vk::raii::BufferView const *>> const & bufferData, std::vector<std::tuple<vk::DescriptorType, vk::raii::Buffer const &, vk::DeviceSize, vk::raii::BufferView const *>> const & bufferData,
vk::raii::su::TextureData const & textureData, vk::raii::su::TextureData const & textureData,
uint32_t bindingOffset = 0 ) uint32_t bindingOffset = 0 )
{ {
@ -827,16 +828,16 @@ namespace vk
std::vector<vk::WriteDescriptorSet> writeDescriptorSets; std::vector<vk::WriteDescriptorSet> writeDescriptorSets;
writeDescriptorSets.reserve( bufferData.size() + 1 ); writeDescriptorSets.reserve( bufferData.size() + 1 );
uint32_t dstBinding = bindingOffset; uint32_t dstBinding = bindingOffset;
for ( auto const & bhd : bufferData ) for ( auto const & bd : bufferData )
{ {
bufferInfos.emplace_back( *std::get<1>( bhd ), 0, VK_WHOLE_SIZE ); bufferInfos.emplace_back( *std::get<1>( bd ), 0, std::get<2>( bd ) );
vk::BufferView bufferView; vk::BufferView bufferView;
if ( std::get<2>( bhd ) ) if ( std::get<3>( bd ) )
{ {
bufferView = **std::get<2>( bhd ); bufferView = **std::get<3>( bd );
} }
writeDescriptorSets.emplace_back( writeDescriptorSets.emplace_back(
*descriptorSet, dstBinding++, 0, 1, std::get<0>( bhd ), nullptr, &bufferInfos.back(), std::get<2>( bhd ) ? &bufferView : nullptr ); *descriptorSet, dstBinding++, 0, 1, std::get<0>( bd ), nullptr, &bufferInfos.back(), std::get<3>( bd ) ? &bufferView : nullptr );
} }
vk::DescriptorImageInfo imageInfo( *textureData.sampler, *textureData.imageData.imageView, vk::ImageLayout::eShaderReadOnlyOptimal ); vk::DescriptorImageInfo imageInfo( *textureData.sampler, *textureData.imageData.imageView, vk::ImageLayout::eShaderReadOnlyOptimal );
@ -845,9 +846,10 @@ namespace vk
device.updateDescriptorSets( writeDescriptorSets, nullptr ); device.updateDescriptorSets( writeDescriptorSets, nullptr );
} }
void updateDescriptorSets( vk::raii::Device const & device, void updateDescriptorSets(
vk::raii::Device const & device,
vk::raii::DescriptorSet const & descriptorSet, vk::raii::DescriptorSet const & descriptorSet,
std::vector<std::tuple<vk::DescriptorType, vk::raii::Buffer const &, vk::raii::BufferView const *>> const & bufferData, std::vector<std::tuple<vk::DescriptorType, vk::raii::Buffer const &, vk::DeviceSize, vk::raii::BufferView const *>> const & bufferData,
std::vector<vk::raii::su::TextureData> const & textureData, std::vector<vk::raii::su::TextureData> const & textureData,
uint32_t bindingOffset = 0 ) uint32_t bindingOffset = 0 )
{ {
@ -857,16 +859,16 @@ namespace vk
std::vector<vk::WriteDescriptorSet> writeDescriptorSets; std::vector<vk::WriteDescriptorSet> writeDescriptorSets;
writeDescriptorSets.reserve( bufferData.size() + ( textureData.empty() ? 0 : 1 ) ); writeDescriptorSets.reserve( bufferData.size() + ( textureData.empty() ? 0 : 1 ) );
uint32_t dstBinding = bindingOffset; uint32_t dstBinding = bindingOffset;
for ( auto const & bhd : bufferData ) for ( auto const & bd : bufferData )
{ {
bufferInfos.emplace_back( *std::get<1>( bhd ), 0, VK_WHOLE_SIZE ); bufferInfos.emplace_back( *std::get<1>( bd ), 0, std::get<2>( bd ) );
vk::BufferView bufferView; vk::BufferView bufferView;
if ( std::get<2>( bhd ) ) if ( std::get<3>( bd ) )
{ {
bufferView = **std::get<2>( bhd ); bufferView = **std::get<3>( bd );
} }
writeDescriptorSets.emplace_back( writeDescriptorSets.emplace_back(
*descriptorSet, dstBinding++, 0, 1, std::get<0>( bhd ), nullptr, &bufferInfos.back(), std::get<2>( bhd ) ? &bufferView : nullptr ); *descriptorSet, dstBinding++, 0, 1, std::get<0>( bd ), nullptr, &bufferInfos.back(), std::get<3>( bd ) ? &bufferView : nullptr );
} }
std::vector<vk::DescriptorImageInfo> imageInfos; std::vector<vk::DescriptorImageInfo> imageInfos;

View File

@ -88,7 +88,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout ); vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout );
vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front(); vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front();
vk::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} } }, {} ); vk::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, {} } }, {} );
vk::PipelineCache pipelineCache = device.createPipelineCache( vk::PipelineCacheCreateInfo() ); vk::PipelineCache pipelineCache = device.createPipelineCache( vk::PipelineCacheCreateInfo() );
vk::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device, vk::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device,

View File

@ -96,7 +96,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout ); vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout );
vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front(); vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front();
vk::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} } }, textureData ); vk::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, {} } }, textureData );
vk::PipelineCache pipelineCache = device.createPipelineCache( vk::PipelineCacheCreateInfo() ); vk::PipelineCache pipelineCache = device.createPipelineCache( vk::PipelineCacheCreateInfo() );
vk::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device, vk::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device,

View File

@ -131,7 +131,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout ); vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout );
vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front(); vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front();
vk::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBufferDynamic, uniformBufferData.buffer, {} } }, {} ); vk::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBufferDynamic, uniformBufferData.buffer, bufferSize, {} } }, {} );
vk::PipelineCache pipelineCache = device.createPipelineCache( vk::PipelineCacheCreateInfo() ); vk::PipelineCache pipelineCache = device.createPipelineCache( vk::PipelineCacheCreateInfo() );
vk::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device, vk::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device,

View File

@ -88,7 +88,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout ); vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout );
vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front(); vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front();
vk::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} } }, {} ); vk::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, {} } }, {} );
vk::PipelineCache pipelineCache = device.createPipelineCache( vk::PipelineCacheCreateInfo() ); vk::PipelineCache pipelineCache = device.createPipelineCache( vk::PipelineCacheCreateInfo() );
vk::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device, vk::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device,

View File

@ -135,7 +135,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout ); vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout );
vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front(); vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front();
vk::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} } }, textureData ); vk::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, {} } }, textureData );
/* VULKAN_KEY_START */ /* VULKAN_KEY_START */

View File

@ -103,7 +103,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout ); vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout );
vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front(); vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front();
vk::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} } }, textureData ); vk::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, {} } }, textureData );
vk::PipelineCache pipelineCache = device.createPipelineCache( vk::PipelineCacheCreateInfo() ); vk::PipelineCache pipelineCache = device.createPipelineCache( vk::PipelineCacheCreateInfo() );

View File

@ -710,10 +710,13 @@ int main( int /*argc*/, char ** /*argv*/ )
// Create a Device with ray tracing support (besides some other extensions needed) and needed features // Create a Device with ray tracing support (besides some other extensions needed) and needed features
auto supportedFeatures = physicalDevice.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>(); auto supportedFeatures = physicalDevice.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>();
vk::Device device = vk::Device device = vk::su::createDevice( physicalDevice,
vk::su::createDevice( physicalDevice,
graphicsAndPresentQueueFamilyIndex.first, graphicsAndPresentQueueFamilyIndex.first,
{ VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_NV_RAY_TRACING_EXTENSION_NAME, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME }, { VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME,
VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME,
VK_KHR_MAINTENANCE_3_EXTENSION_NAME,
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
VK_NV_RAY_TRACING_EXTENSION_NAME },
&supportedFeatures.get<vk::PhysicalDeviceFeatures2>().features, &supportedFeatures.get<vk::PhysicalDeviceFeatures2>().features,
&supportedFeatures.get<vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>() ); &supportedFeatures.get<vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>() );
@ -876,10 +879,10 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout ); vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout );
vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front(); vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front();
vk::su::updateDescriptorSets( vk::su::updateDescriptorSets( device,
device,
descriptorSet, descriptorSet,
{ { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} }, { vk::DescriptorType::eStorageBuffer, materialBufferData.buffer, {} } }, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, {} },
{ vk::DescriptorType::eStorageBuffer, materialBufferData.buffer, VK_WHOLE_SIZE, {} } },
textures ); textures );
// RayTracing specific stuff // RayTracing specific stuff
@ -972,10 +975,10 @@ int main( int /*argc*/, char ** /*argv*/ )
{ {
vk::su::updateDescriptorSets( device, vk::su::updateDescriptorSets( device,
rayTracingDescriptorSets[i], rayTracingDescriptorSets[i],
{ { bindings[2].descriptorType, uniformBufferData.buffer, {} }, { { bindings[2].descriptorType, uniformBufferData.buffer, VK_WHOLE_SIZE, {} },
{ bindings[3].descriptorType, vertexBufferData.buffer, {} }, { bindings[3].descriptorType, vertexBufferData.buffer, VK_WHOLE_SIZE, {} },
{ bindings[4].descriptorType, indexBufferData.buffer, {} }, { bindings[4].descriptorType, indexBufferData.buffer, VK_WHOLE_SIZE, {} },
{ bindings[5].descriptorType, materialBufferData.buffer, {} } }, { bindings[5].descriptorType, materialBufferData.buffer, VK_WHOLE_SIZE, {} } },
textures, textures,
2 ); 2 );
} }

View File

@ -129,8 +129,10 @@ int main( int /*argc*/, char ** /*argv*/ )
std::vector<vk::DescriptorSet> descriptorSets = device.allocateDescriptorSets( descriptorSetAllocateInfo ); std::vector<vk::DescriptorSet> descriptorSets = device.allocateDescriptorSets( descriptorSetAllocateInfo );
assert( descriptorSets.size() == 2 ); assert( descriptorSets.size() == 2 );
vk::su::updateDescriptorSets( device, descriptorSets[0], { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} } }, greenTextureData ); vk::su::updateDescriptorSets(
vk::su::updateDescriptorSets( device, descriptorSets[1], { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} } }, checkeredTextureData ); device, descriptorSets[0], { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, {} } }, greenTextureData );
vk::su::updateDescriptorSets(
device, descriptorSets[1], { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, {} } }, checkeredTextureData );
/* VULKAN_KEY_START */ /* VULKAN_KEY_START */

View File

@ -96,7 +96,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout ); vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout );
vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front(); vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front();
vk::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} } }, textureData ); vk::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, {} } }, textureData );
vk::PipelineCache pipelineCache = device.createPipelineCache( vk::PipelineCacheCreateInfo() ); vk::PipelineCache pipelineCache = device.createPipelineCache( vk::PipelineCacheCreateInfo() );
vk::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device, vk::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device,

View File

@ -124,7 +124,8 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::DescriptorPool descriptorPool = vk::su::createDescriptorPool( device, { { vk::DescriptorType::eUniformTexelBuffer, 1 } } ); vk::DescriptorPool descriptorPool = vk::su::createDescriptorPool( device, { { vk::DescriptorType::eUniformTexelBuffer, 1 } } );
vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout ); vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout );
vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front(); vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front();
vk::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformTexelBuffer, texelBufferData.buffer, texelBufferView } }, {} ); vk::su::updateDescriptorSets(
device, descriptorSet, { { vk::DescriptorType::eUniformTexelBuffer, texelBufferData.buffer, VK_WHOLE_SIZE, texelBufferView } }, {} );
vk::PipelineCache pipelineCache = device.createPipelineCache( vk::PipelineCacheCreateInfo() ); vk::PipelineCache pipelineCache = device.createPipelineCache( vk::PipelineCacheCreateInfo() );
vk::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device, vk::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device,

View File

@ -682,7 +682,7 @@ namespace vk
void updateDescriptorSets( vk::Device const & device, void updateDescriptorSets( vk::Device const & device,
vk::DescriptorSet const & descriptorSet, vk::DescriptorSet const & descriptorSet,
std::vector<std::tuple<vk::DescriptorType, vk::Buffer const &, vk::BufferView const &>> const & bufferData, std::vector<std::tuple<vk::DescriptorType, vk::Buffer const &, vk::DeviceSize, vk::BufferView const &>> const & bufferData,
vk::su::TextureData const & textureData, vk::su::TextureData const & textureData,
uint32_t bindingOffset ) uint32_t bindingOffset )
{ {
@ -694,8 +694,8 @@ namespace vk
uint32_t dstBinding = bindingOffset; uint32_t dstBinding = bindingOffset;
for ( auto const & bd : bufferData ) for ( auto const & bd : bufferData )
{ {
bufferInfos.emplace_back( std::get<1>( bd ), 0, VK_WHOLE_SIZE ); bufferInfos.emplace_back( std::get<1>( bd ), 0, std::get<2>( bd ) );
writeDescriptorSets.emplace_back( descriptorSet, dstBinding++, 0, 1, std::get<0>( bd ), nullptr, &bufferInfos.back(), &std::get<2>( bd ) ); writeDescriptorSets.emplace_back( descriptorSet, dstBinding++, 0, 1, std::get<0>( bd ), nullptr, &bufferInfos.back(), &std::get<3>( bd ) );
} }
vk::DescriptorImageInfo imageInfo( textureData.sampler, textureData.imageData->imageView, vk::ImageLayout::eShaderReadOnlyOptimal ); vk::DescriptorImageInfo imageInfo( textureData.sampler, textureData.imageData->imageView, vk::ImageLayout::eShaderReadOnlyOptimal );
@ -706,7 +706,7 @@ namespace vk
void updateDescriptorSets( vk::Device const & device, void updateDescriptorSets( vk::Device const & device,
vk::DescriptorSet const & descriptorSet, vk::DescriptorSet const & descriptorSet,
std::vector<std::tuple<vk::DescriptorType, vk::Buffer const &, vk::BufferView const &>> const & bufferData, std::vector<std::tuple<vk::DescriptorType, vk::Buffer const &, vk::DeviceSize, vk::BufferView const &>> const & bufferData,
std::vector<vk::su::TextureData> const & textureData, std::vector<vk::su::TextureData> const & textureData,
uint32_t bindingOffset ) uint32_t bindingOffset )
{ {
@ -718,8 +718,8 @@ namespace vk
uint32_t dstBinding = bindingOffset; uint32_t dstBinding = bindingOffset;
for ( auto const & bd : bufferData ) for ( auto const & bd : bufferData )
{ {
bufferInfos.emplace_back( std::get<1>( bd ), 0, VK_WHOLE_SIZE ); bufferInfos.emplace_back( std::get<1>( bd ), 0, std::get<2>( bd ) );
writeDescriptorSets.emplace_back( descriptorSet, dstBinding++, 0, 1, std::get<0>( bd ), nullptr, &bufferInfos.back(), &std::get<2>( bd ) ); writeDescriptorSets.emplace_back( descriptorSet, dstBinding++, 0, 1, std::get<0>( bd ), nullptr, &bufferInfos.back(), &std::get<3>( bd ) );
} }
std::vector<vk::DescriptorImageInfo> imageInfos; std::vector<vk::DescriptorImageInfo> imageInfos;

View File

@ -431,12 +431,12 @@ namespace vk
void submitAndWait( vk::Device const & device, vk::Queue const & queue, vk::CommandBuffer const & commandBuffer ); void submitAndWait( vk::Device const & device, vk::Queue const & queue, vk::CommandBuffer const & commandBuffer );
void updateDescriptorSets( vk::Device const & device, void updateDescriptorSets( vk::Device const & device,
vk::DescriptorSet const & descriptorSet, vk::DescriptorSet const & descriptorSet,
std::vector<std::tuple<vk::DescriptorType, vk::Buffer const &, vk::BufferView const &>> const & bufferData, std::vector<std::tuple<vk::DescriptorType, vk::Buffer const &, vk::DeviceSize, vk::BufferView const &>> const & bufferData,
vk::su::TextureData const & textureData, vk::su::TextureData const & textureData,
uint32_t bindingOffset = 0 ); uint32_t bindingOffset = 0 );
void updateDescriptorSets( vk::Device const & device, void updateDescriptorSets( vk::Device const & device,
vk::DescriptorSet const & descriptorSet, vk::DescriptorSet const & descriptorSet,
std::vector<std::tuple<vk::DescriptorType, vk::Buffer const &, vk::BufferView const &>> const & bufferData, std::vector<std::tuple<vk::DescriptorType, vk::Buffer const &, vk::DeviceSize, vk::BufferView const &>> const & bufferData,
std::vector<vk::su::TextureData> const & textureData, std::vector<vk::su::TextureData> const & textureData,
uint32_t bindingOffset = 0 ); uint32_t bindingOffset = 0 );