Resolve validation layer issues with some samples.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
@@ -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() );
|
||||
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user