Merge pull request #1296 from asuessenbach/samples

Resolve validation layer issues with some samples.
This commit is contained in:
Andreas Süßenbach 2022-05-02 13:53:55 +02:00 committed by GitHub
commit 8a34163152
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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::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 =

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::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,

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::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,

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::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,

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::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 */

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::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() );

View File

@ -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::PhysicalDeviceFeatures2, vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>();
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<vk::PhysicalDeviceFeatures2>().features,
&supportedFeatures.get<vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>() );
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<vk::PhysicalDeviceFeatures2>().features,
&supportedFeatures.get<vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>() );
// setup stuff per frame
std::vector<PerFrameData> 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 );
}

View File

@ -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 */

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::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,

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::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(

View File

@ -815,11 +815,12 @@ namespace vk
;
}
void updateDescriptorSets( vk::raii::Device const & device,
vk::raii::DescriptorSet const & descriptorSet,
std::vector<std::tuple<vk::DescriptorType, vk::raii::Buffer const &, vk::raii::BufferView const *>> 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<std::tuple<vk::DescriptorType, vk::raii::Buffer const &, vk::DeviceSize, vk::raii::BufferView const *>> const & bufferData,
vk::raii::su::TextureData const & textureData,
uint32_t bindingOffset = 0 )
{
std::vector<vk::DescriptorBufferInfo> bufferInfos;
bufferInfos.reserve( bufferData.size() );
@ -827,16 +828,16 @@ namespace vk
std::vector<vk::WriteDescriptorSet> 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<std::tuple<vk::DescriptorType, vk::raii::Buffer const &, vk::raii::BufferView const *>> const & bufferData,
std::vector<vk::raii::su::TextureData> const & textureData,
uint32_t bindingOffset = 0 )
void updateDescriptorSets(
vk::raii::Device const & device,
vk::raii::DescriptorSet const & descriptorSet,
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,
uint32_t bindingOffset = 0 )
{
std::vector<vk::DescriptorBufferInfo> bufferInfos;
bufferInfos.reserve( bufferData.size() );
@ -857,16 +859,16 @@ namespace vk
std::vector<vk::WriteDescriptorSet> 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<vk::DescriptorImageInfo> imageInfos;

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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 */

View File

@ -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() );

View File

@ -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::PhysicalDeviceFeatures2, vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>();
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<vk::PhysicalDeviceFeatures2>().features,
&supportedFeatures.get<vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>() );
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<vk::PhysicalDeviceFeatures2>().features,
&supportedFeatures.get<vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>() );
// setup stuff per frame
std::array<PerFrameData, IMGUI_VK_QUEUED_FRAMES> 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 );
}

View File

@ -129,8 +129,10 @@ int main( int /*argc*/, char ** /*argv*/ )
std::vector<vk::DescriptorSet> 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 */

View File

@ -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,

View File

@ -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,

View File

@ -680,11 +680,11 @@ namespace vk
device.destroyFence( fence );
}
void updateDescriptorSets( vk::Device const & device,
vk::DescriptorSet const & descriptorSet,
std::vector<std::tuple<vk::DescriptorType, vk::Buffer const &, vk::BufferView const &>> const & bufferData,
vk::su::TextureData const & textureData,
uint32_t bindingOffset )
void updateDescriptorSets( vk::Device const & device,
vk::DescriptorSet const & descriptorSet,
std::vector<std::tuple<vk::DescriptorType, vk::Buffer const &, vk::DeviceSize, vk::BufferView const &>> const & bufferData,
vk::su::TextureData const & textureData,
uint32_t bindingOffset )
{
std::vector<vk::DescriptorBufferInfo> 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<std::tuple<vk::DescriptorType, vk::Buffer const &, vk::BufferView const &>> const & bufferData,
std::vector<vk::su::TextureData> const & textureData,
uint32_t bindingOffset )
void updateDescriptorSets( vk::Device const & device,
vk::DescriptorSet const & descriptorSet,
std::vector<std::tuple<vk::DescriptorType, vk::Buffer const &, vk::DeviceSize, vk::BufferView const &>> const & bufferData,
std::vector<vk::su::TextureData> const & textureData,
uint32_t bindingOffset )
{
std::vector<vk::DescriptorBufferInfo> 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<vk::DescriptorImageInfo> imageInfos;

View File

@ -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<vk::PresentModeKHR> const & presentModes );
vk::SurfaceFormatKHR pickSurfaceFormat( std::vector<vk::SurfaceFormatKHR> 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<std::tuple<vk::DescriptorType, vk::Buffer const &, vk::BufferView const &>> const & bufferData,
vk::su::TextureData const & textureData,
uint32_t bindingOffset = 0 );
void updateDescriptorSets( vk::Device const & device,
vk::DescriptorSet const & descriptorSet,
std::vector<std::tuple<vk::DescriptorType, vk::Buffer const &, vk::BufferView const &>> const & bufferData,
std::vector<vk::su::TextureData> const & textureData,
uint32_t bindingOffset = 0 );
void updateDescriptorSets( vk::Device const & device,
vk::DescriptorSet const & descriptorSet,
std::vector<std::tuple<vk::DescriptorType, vk::Buffer const &, vk::DeviceSize, vk::BufferView const &>> const & bufferData,
vk::su::TextureData const & textureData,
uint32_t bindingOffset = 0 );
void updateDescriptorSets( vk::Device const & device,
vk::DescriptorSet const & descriptorSet,
std::vector<std::tuple<vk::DescriptorType, vk::Buffer const &, vk::DeviceSize, vk::BufferView const &>> const & bufferData,
std::vector<vk::su::TextureData> const & textureData,
uint32_t bindingOffset = 0 );
} // namespace su
} // namespace vk