From 0fb855a4a2b232681d9970bdcd1f63dd57d2459a Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Mon, 2 May 2022 09:43:45 +0200 Subject: [PATCH] Resolve validation layer issues with some samples. --- RAII_Samples/15_DrawCube/15_DrawCube.cpp | 3 +- .../DrawTexturedCube/DrawTexturedCube.cpp | 3 +- .../DynamicUniform/DynamicUniform.cpp | 2 +- .../OcclusionQuery/OcclusionQuery.cpp | 3 +- RAII_Samples/PipelineCache/PipelineCache.cpp | 3 +- .../PipelineDerivative/PipelineDerivative.cpp | 3 +- RAII_Samples/RayTracing/RayTracing.cpp | 33 ++++++++------- .../SecondaryCommandBuffer.cpp | 5 ++- RAII_Samples/Template/Template.cpp | 2 +- RAII_Samples/TexelBuffer/TexelBuffer.cpp | 3 +- RAII_Samples/utils/utils.hpp | 42 ++++++++++--------- samples/15_DrawCube/15_DrawCube.cpp | 2 +- samples/DrawTexturedCube/DrawTexturedCube.cpp | 2 +- samples/DynamicUniform/DynamicUniform.cpp | 2 +- samples/OcclusionQuery/OcclusionQuery.cpp | 2 +- samples/PipelineCache/PipelineCache.cpp | 2 +- .../PipelineDerivative/PipelineDerivative.cpp | 2 +- samples/RayTracing/RayTracing.cpp | 33 ++++++++------- .../SecondaryCommandBuffer.cpp | 6 ++- samples/Template/Template.cpp | 2 +- samples/TexelBuffer/TexelBuffer.cpp | 3 +- samples/utils/utils.cpp | 28 ++++++------- samples/utils/utils.hpp | 24 +++++------ 23 files changed, 114 insertions(+), 96 deletions(-) diff --git a/RAII_Samples/15_DrawCube/15_DrawCube.cpp b/RAII_Samples/15_DrawCube/15_DrawCube.cpp index 0b9afeb..361df96 100644 --- a/RAII_Samples/15_DrawCube/15_DrawCube.cpp +++ b/RAII_Samples/15_DrawCube/15_DrawCube.cpp @@ -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::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::Pipeline graphicsPipeline = diff --git a/RAII_Samples/DrawTexturedCube/DrawTexturedCube.cpp b/RAII_Samples/DrawTexturedCube/DrawTexturedCube.cpp index caaaacf..787925e 100644 --- a/RAII_Samples/DrawTexturedCube/DrawTexturedCube.cpp +++ b/RAII_Samples/DrawTexturedCube/DrawTexturedCube.cpp @@ -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::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::Pipeline graphicsPipeline = vk::raii::su::makeGraphicsPipeline( device, diff --git a/RAII_Samples/DynamicUniform/DynamicUniform.cpp b/RAII_Samples/DynamicUniform/DynamicUniform.cpp index 2b7f0de..12d3d78 100644 --- a/RAII_Samples/DynamicUniform/DynamicUniform.cpp +++ b/RAII_Samples/DynamicUniform/DynamicUniform.cpp @@ -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::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::Pipeline graphicsPipeline = vk::raii::su::makeGraphicsPipeline( device, diff --git a/RAII_Samples/OcclusionQuery/OcclusionQuery.cpp b/RAII_Samples/OcclusionQuery/OcclusionQuery.cpp index 9450877..23c2059 100644 --- a/RAII_Samples/OcclusionQuery/OcclusionQuery.cpp +++ b/RAII_Samples/OcclusionQuery/OcclusionQuery.cpp @@ -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::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::Pipeline graphicsPipeline = vk::raii::su::makeGraphicsPipeline( device, diff --git a/RAII_Samples/PipelineCache/PipelineCache.cpp b/RAII_Samples/PipelineCache/PipelineCache.cpp index 10011d5..a2807f3 100644 --- a/RAII_Samples/PipelineCache/PipelineCache.cpp +++ b/RAII_Samples/PipelineCache/PipelineCache.cpp @@ -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::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 */ diff --git a/RAII_Samples/PipelineDerivative/PipelineDerivative.cpp b/RAII_Samples/PipelineDerivative/PipelineDerivative.cpp index 1a8fa70..de2c39d 100644 --- a/RAII_Samples/PipelineDerivative/PipelineDerivative.cpp +++ b/RAII_Samples/PipelineDerivative/PipelineDerivative.cpp @@ -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::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() ); diff --git a/RAII_Samples/RayTracing/RayTracing.cpp b/RAII_Samples/RayTracing/RayTracing.cpp index 6252df7..9371407 100644 --- a/RAII_Samples/RayTracing/RayTracing.cpp +++ b/RAII_Samples/RayTracing/RayTracing.cpp @@ -712,12 +712,15 @@ int main( int /*argc*/, char ** /*argv*/ ) // Create a Device with ray tracing support (besides some other extensions needed) and needed features auto supportedFeatures = physicalDevice.getFeatures2(); - vk::raii::Device device = - vk::raii::su::makeDevice( physicalDevice, - graphicsAndPresentQueueFamilyIndex.first, - { VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_NV_RAY_TRACING_EXTENSION_NAME, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME }, - &supportedFeatures.get().features, - &supportedFeatures.get() ); + vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, + graphicsAndPresentQueueFamilyIndex.first, + { 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().features, + &supportedFeatures.get() ); // setup stuff per frame std::vector perFrameData; @@ -874,11 +877,11 @@ int main( int /*argc*/, char ** /*argv*/ ) 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::su::updateDescriptorSets( - device, - descriptorSet, - { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} }, { vk::DescriptorType::eStorageBuffer, materialBufferData.buffer, {} } }, - textures ); + vk::raii::su::updateDescriptorSets( device, + descriptorSet, + { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, {} }, + { vk::DescriptorType::eStorageBuffer, materialBufferData.buffer, VK_WHOLE_SIZE, {} } }, + textures ); // RayTracing specific stuff @@ -974,10 +977,10 @@ int main( int /*argc*/, char ** /*argv*/ ) { vk::raii::su::updateDescriptorSets( device, rayTracingDescriptorSets[i], - { { bindings[2].descriptorType, uniformBufferData.buffer, {} }, - { bindings[3].descriptorType, vertexBufferData.buffer, {} }, - { bindings[4].descriptorType, indexBufferData.buffer, {} }, - { bindings[5].descriptorType, materialBufferData.buffer, {} } }, + { { bindings[2].descriptorType, uniformBufferData.buffer, VK_WHOLE_SIZE, {} }, + { bindings[3].descriptorType, vertexBufferData.buffer, VK_WHOLE_SIZE, {} }, + { bindings[4].descriptorType, indexBufferData.buffer, VK_WHOLE_SIZE, {} }, + { bindings[5].descriptorType, materialBufferData.buffer, VK_WHOLE_SIZE, {} } }, textures, 2 ); } diff --git a/RAII_Samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp b/RAII_Samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp index f03fc71..6f813d3 100644 --- a/RAII_Samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp +++ b/RAII_Samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp @@ -129,9 +129,10 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::DescriptorSets descriptorSets( device, descriptorSetAllocateInfo ); assert( descriptorSets.size() == 2 ); - vk::raii::su::updateDescriptorSets( device, descriptorSets[0], { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} } }, greenTextureData ); 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 */ diff --git a/RAII_Samples/Template/Template.cpp b/RAII_Samples/Template/Template.cpp index 08d4e57..c609e33 100644 --- a/RAII_Samples/Template/Template.cpp +++ b/RAII_Samples/Template/Template.cpp @@ -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::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::Pipeline graphicsPipeline = vk::raii::su::makeGraphicsPipeline( device, diff --git a/RAII_Samples/TexelBuffer/TexelBuffer.cpp b/RAII_Samples/TexelBuffer/TexelBuffer.cpp index 6b599dc..8471b6b 100644 --- a/RAII_Samples/TexelBuffer/TexelBuffer.cpp +++ b/RAII_Samples/TexelBuffer/TexelBuffer.cpp @@ -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::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::Pipeline graphicsPipeline = vk::raii::su::makeGraphicsPipeline( diff --git a/RAII_Samples/utils/utils.hpp b/RAII_Samples/utils/utils.hpp index a05a49a..dacf083 100644 --- a/RAII_Samples/utils/utils.hpp +++ b/RAII_Samples/utils/utils.hpp @@ -815,11 +815,12 @@ namespace vk ; } - void updateDescriptorSets( vk::raii::Device const & device, - vk::raii::DescriptorSet const & descriptorSet, - std::vector> const & bufferData, - vk::raii::su::TextureData const & textureData, - uint32_t bindingOffset = 0 ) + void updateDescriptorSets( + vk::raii::Device const & device, + vk::raii::DescriptorSet const & descriptorSet, + std::vector> const & bufferData, + vk::raii::su::TextureData const & textureData, + uint32_t bindingOffset = 0 ) { std::vector bufferInfos; bufferInfos.reserve( bufferData.size() ); @@ -827,16 +828,16 @@ namespace vk std::vector writeDescriptorSets; writeDescriptorSets.reserve( bufferData.size() + 1 ); 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; - if ( std::get<2>( bhd ) ) + if ( std::get<3>( bd ) ) { - bufferView = **std::get<2>( bhd ); + bufferView = **std::get<3>( bd ); } 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 ); @@ -845,11 +846,12 @@ namespace vk device.updateDescriptorSets( writeDescriptorSets, nullptr ); } - void updateDescriptorSets( vk::raii::Device const & device, - vk::raii::DescriptorSet const & descriptorSet, - std::vector> const & bufferData, - std::vector const & textureData, - uint32_t bindingOffset = 0 ) + void updateDescriptorSets( + vk::raii::Device const & device, + vk::raii::DescriptorSet const & descriptorSet, + std::vector> const & bufferData, + std::vector const & textureData, + uint32_t bindingOffset = 0 ) { std::vector bufferInfos; bufferInfos.reserve( bufferData.size() ); @@ -857,16 +859,16 @@ namespace vk std::vector writeDescriptorSets; writeDescriptorSets.reserve( bufferData.size() + ( textureData.empty() ? 0 : 1 ) ); 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; - if ( std::get<2>( bhd ) ) + if ( std::get<3>( bd ) ) { - bufferView = **std::get<2>( bhd ); + bufferView = **std::get<3>( bd ); } 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 imageInfos; diff --git a/samples/15_DrawCube/15_DrawCube.cpp b/samples/15_DrawCube/15_DrawCube.cpp index 9b7d8c7..ec30541 100644 --- a/samples/15_DrawCube/15_DrawCube.cpp +++ b/samples/15_DrawCube/15_DrawCube.cpp @@ -88,7 +88,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout ); 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::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device, diff --git a/samples/DrawTexturedCube/DrawTexturedCube.cpp b/samples/DrawTexturedCube/DrawTexturedCube.cpp index 4191774..6b6ee5e 100644 --- a/samples/DrawTexturedCube/DrawTexturedCube.cpp +++ b/samples/DrawTexturedCube/DrawTexturedCube.cpp @@ -96,7 +96,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout ); 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::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device, diff --git a/samples/DynamicUniform/DynamicUniform.cpp b/samples/DynamicUniform/DynamicUniform.cpp index 78f2152..73f3a1a 100644 --- a/samples/DynamicUniform/DynamicUniform.cpp +++ b/samples/DynamicUniform/DynamicUniform.cpp @@ -131,7 +131,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout ); 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::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device, diff --git a/samples/OcclusionQuery/OcclusionQuery.cpp b/samples/OcclusionQuery/OcclusionQuery.cpp index 214f21c..79fc92d 100644 --- a/samples/OcclusionQuery/OcclusionQuery.cpp +++ b/samples/OcclusionQuery/OcclusionQuery.cpp @@ -88,7 +88,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout ); 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::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device, diff --git a/samples/PipelineCache/PipelineCache.cpp b/samples/PipelineCache/PipelineCache.cpp index d057445..dbd7d93 100644 --- a/samples/PipelineCache/PipelineCache.cpp +++ b/samples/PipelineCache/PipelineCache.cpp @@ -135,7 +135,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout ); 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 */ diff --git a/samples/PipelineDerivative/PipelineDerivative.cpp b/samples/PipelineDerivative/PipelineDerivative.cpp index bc2c9fb..8abaf58 100644 --- a/samples/PipelineDerivative/PipelineDerivative.cpp +++ b/samples/PipelineDerivative/PipelineDerivative.cpp @@ -103,7 +103,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout ); 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() ); diff --git a/samples/RayTracing/RayTracing.cpp b/samples/RayTracing/RayTracing.cpp index 940079b..f9c5f5d 100644 --- a/samples/RayTracing/RayTracing.cpp +++ b/samples/RayTracing/RayTracing.cpp @@ -710,12 +710,15 @@ int main( int /*argc*/, char ** /*argv*/ ) // Create a Device with ray tracing support (besides some other extensions needed) and needed features auto supportedFeatures = physicalDevice.getFeatures2(); - vk::Device device = - vk::su::createDevice( physicalDevice, - graphicsAndPresentQueueFamilyIndex.first, - { VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_NV_RAY_TRACING_EXTENSION_NAME, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME }, - &supportedFeatures.get().features, - &supportedFeatures.get() ); + vk::Device device = vk::su::createDevice( physicalDevice, + graphicsAndPresentQueueFamilyIndex.first, + { 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().features, + &supportedFeatures.get() ); // setup stuff per frame std::array perFrameData; @@ -876,11 +879,11 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout ); vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front(); - vk::su::updateDescriptorSets( - device, - descriptorSet, - { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} }, { vk::DescriptorType::eStorageBuffer, materialBufferData.buffer, {} } }, - textures ); + vk::su::updateDescriptorSets( device, + descriptorSet, + { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, {} }, + { vk::DescriptorType::eStorageBuffer, materialBufferData.buffer, VK_WHOLE_SIZE, {} } }, + textures ); // RayTracing specific stuff @@ -972,10 +975,10 @@ int main( int /*argc*/, char ** /*argv*/ ) { vk::su::updateDescriptorSets( device, rayTracingDescriptorSets[i], - { { bindings[2].descriptorType, uniformBufferData.buffer, {} }, - { bindings[3].descriptorType, vertexBufferData.buffer, {} }, - { bindings[4].descriptorType, indexBufferData.buffer, {} }, - { bindings[5].descriptorType, materialBufferData.buffer, {} } }, + { { bindings[2].descriptorType, uniformBufferData.buffer, VK_WHOLE_SIZE, {} }, + { bindings[3].descriptorType, vertexBufferData.buffer, VK_WHOLE_SIZE, {} }, + { bindings[4].descriptorType, indexBufferData.buffer, VK_WHOLE_SIZE, {} }, + { bindings[5].descriptorType, materialBufferData.buffer, VK_WHOLE_SIZE, {} } }, textures, 2 ); } diff --git a/samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp b/samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp index 28ebdd4..d144fe2 100644 --- a/samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp +++ b/samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp @@ -129,8 +129,10 @@ int main( int /*argc*/, char ** /*argv*/ ) std::vector descriptorSets = device.allocateDescriptorSets( descriptorSetAllocateInfo ); assert( descriptorSets.size() == 2 ); - vk::su::updateDescriptorSets( device, descriptorSets[0], { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} } }, greenTextureData ); - vk::su::updateDescriptorSets( device, descriptorSets[1], { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} } }, checkeredTextureData ); + vk::su::updateDescriptorSets( + 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 */ diff --git a/samples/Template/Template.cpp b/samples/Template/Template.cpp index 4fad9e9..b29d5ee 100644 --- a/samples/Template/Template.cpp +++ b/samples/Template/Template.cpp @@ -96,7 +96,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout ); 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::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device, diff --git a/samples/TexelBuffer/TexelBuffer.cpp b/samples/TexelBuffer/TexelBuffer.cpp index 4db0784..2c6ee78 100644 --- a/samples/TexelBuffer/TexelBuffer.cpp +++ b/samples/TexelBuffer/TexelBuffer.cpp @@ -124,7 +124,8 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::DescriptorPool descriptorPool = vk::su::createDescriptorPool( device, { { vk::DescriptorType::eUniformTexelBuffer, 1 } } ); vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout ); 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::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device, diff --git a/samples/utils/utils.cpp b/samples/utils/utils.cpp index 8b573cd..b15a4d9 100644 --- a/samples/utils/utils.cpp +++ b/samples/utils/utils.cpp @@ -680,11 +680,11 @@ namespace vk device.destroyFence( fence ); } - void updateDescriptorSets( vk::Device const & device, - vk::DescriptorSet const & descriptorSet, - std::vector> const & bufferData, - vk::su::TextureData const & textureData, - uint32_t bindingOffset ) + void updateDescriptorSets( vk::Device const & device, + vk::DescriptorSet const & descriptorSet, + std::vector> const & bufferData, + vk::su::TextureData const & textureData, + uint32_t bindingOffset ) { std::vector bufferInfos; bufferInfos.reserve( bufferData.size() ); @@ -694,8 +694,8 @@ namespace vk uint32_t dstBinding = bindingOffset; for ( auto const & bd : bufferData ) { - bufferInfos.emplace_back( std::get<1>( bd ), 0, VK_WHOLE_SIZE ); - writeDescriptorSets.emplace_back( descriptorSet, dstBinding++, 0, 1, std::get<0>( bd ), nullptr, &bufferInfos.back(), &std::get<2>( bd ) ); + 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<3>( bd ) ); } vk::DescriptorImageInfo imageInfo( textureData.sampler, textureData.imageData->imageView, vk::ImageLayout::eShaderReadOnlyOptimal ); @@ -704,11 +704,11 @@ namespace vk device.updateDescriptorSets( writeDescriptorSets, nullptr ); } - void updateDescriptorSets( vk::Device const & device, - vk::DescriptorSet const & descriptorSet, - std::vector> const & bufferData, - std::vector const & textureData, - uint32_t bindingOffset ) + void updateDescriptorSets( vk::Device const & device, + vk::DescriptorSet const & descriptorSet, + std::vector> const & bufferData, + std::vector const & textureData, + uint32_t bindingOffset ) { std::vector bufferInfos; bufferInfos.reserve( bufferData.size() ); @@ -718,8 +718,8 @@ namespace vk uint32_t dstBinding = bindingOffset; for ( auto const & bd : bufferData ) { - bufferInfos.emplace_back( std::get<1>( bd ), 0, VK_WHOLE_SIZE ); - writeDescriptorSets.emplace_back( descriptorSet, dstBinding++, 0, 1, std::get<0>( bd ), nullptr, &bufferInfos.back(), &std::get<2>( bd ) ); + 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<3>( bd ) ); } std::vector imageInfos; diff --git a/samples/utils/utils.hpp b/samples/utils/utils.hpp index 16ea5f9..c23c6e7 100644 --- a/samples/utils/utils.hpp +++ b/samples/utils/utils.hpp @@ -298,8 +298,8 @@ namespace vk void setImage( vk::Device const & device, vk::CommandBuffer const & commandBuffer, ImageGenerator const & imageGenerator ) { void * data = needsStaging - ? device.mapMemory( stagingBufferData->deviceMemory, 0, device.getBufferMemoryRequirements( stagingBufferData->buffer ).size ) - : device.mapMemory( imageData->deviceMemory, 0, device.getImageMemoryRequirements( imageData->image ).size ); + ? device.mapMemory( stagingBufferData->deviceMemory, 0, device.getBufferMemoryRequirements( stagingBufferData->buffer ).size ) + : device.mapMemory( imageData->deviceMemory, 0, device.getImageMemoryRequirements( imageData->image ).size ); imageGenerator( data, extent ); device.unmapMemory( needsStaging ? stagingBufferData->deviceMemory : imageData->deviceMemory ); @@ -429,16 +429,16 @@ namespace vk vk::PresentModeKHR pickPresentMode( std::vector const & presentModes ); vk::SurfaceFormatKHR pickSurfaceFormat( std::vector const & formats ); void submitAndWait( vk::Device const & device, vk::Queue const & queue, vk::CommandBuffer const & commandBuffer ); - void updateDescriptorSets( vk::Device const & device, - vk::DescriptorSet const & descriptorSet, - std::vector> const & bufferData, - vk::su::TextureData const & textureData, - uint32_t bindingOffset = 0 ); - void updateDescriptorSets( vk::Device const & device, - vk::DescriptorSet const & descriptorSet, - std::vector> const & bufferData, - std::vector const & textureData, - uint32_t bindingOffset = 0 ); + void updateDescriptorSets( vk::Device const & device, + vk::DescriptorSet const & descriptorSet, + std::vector> const & bufferData, + vk::su::TextureData const & textureData, + uint32_t bindingOffset = 0 ); + void updateDescriptorSets( vk::Device const & device, + vk::DescriptorSet const & descriptorSet, + std::vector> const & bufferData, + std::vector const & textureData, + uint32_t bindingOffset = 0 ); } // namespace su } // namespace vk