From 729177f1ce788d33b9ec55b04bca2434f850ff68 Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Mon, 14 Aug 2023 11:51:13 +0200 Subject: [PATCH] Change samples from resetting command buffers to resetting command pool --- .../13_InitVertexBuffer/13_InitVertexBuffer.cpp | 3 +-- RAII_Samples/15_DrawCube/15_DrawCube.cpp | 3 +-- RAII_Samples/CopyBlitImage/CopyBlitImage.cpp | 11 ++++++----- RAII_Samples/DrawTexturedCube/DrawTexturedCube.cpp | 3 +-- RAII_Samples/DynamicUniform/DynamicUniform.cpp | 3 +-- RAII_Samples/Events/Events.cpp | 10 +++++++--- RAII_Samples/ImmutableSampler/ImmutableSampler.cpp | 3 +-- RAII_Samples/InitTexture/InitTexture.cpp | 3 +-- RAII_Samples/InputAttachment/InputAttachment.cpp | 3 +-- RAII_Samples/MultipleSets/MultipleSets.cpp | 3 +-- RAII_Samples/OcclusionQuery/OcclusionQuery.cpp | 3 +-- RAII_Samples/PipelineCache/PipelineCache.cpp | 3 +-- .../PipelineDerivative/PipelineDerivative.cpp | 3 +-- RAII_Samples/PushConstants/PushConstants.cpp | 3 +-- RAII_Samples/PushDescriptors/PushDescriptors.cpp | 3 +-- RAII_Samples/RayTracing/RayTracing.cpp | 12 ++++++++---- .../SecondaryCommandBuffer.cpp | 3 +-- .../SeparateImageSampler/SeparateImageSampler.cpp | 3 +-- RAII_Samples/Template/Template.cpp | 3 +-- RAII_Samples/TexelBuffer/TexelBuffer.cpp | 3 +-- RAII_Samples/utils/utils.hpp | 10 ++-------- samples/13_InitVertexBuffer/13_InitVertexBuffer.cpp | 2 +- samples/15_DrawCube/15_DrawCube.cpp | 2 +- samples/CopyBlitImage/CopyBlitImage.cpp | 6 ++++-- samples/DrawTexturedCube/DrawTexturedCube.cpp | 2 +- samples/DynamicUniform/DynamicUniform.cpp | 2 +- samples/Events/Events.cpp | 10 +++++++--- samples/ImmutableSampler/ImmutableSampler.cpp | 2 +- samples/InitTexture/InitTexture.cpp | 2 +- samples/InputAttachment/InputAttachment.cpp | 2 +- samples/MultipleSets/MultipleSets.cpp | 2 +- samples/OcclusionQuery/OcclusionQuery.cpp | 2 +- samples/PipelineCache/PipelineCache.cpp | 2 +- samples/PipelineDerivative/PipelineDerivative.cpp | 2 +- samples/PushConstants/PushConstants.cpp | 2 +- samples/PushDescriptors/PushDescriptors.cpp | 2 +- samples/RayTracing/RayTracing.cpp | 13 ++++++++----- .../SecondaryCommandBuffer.cpp | 2 +- .../SeparateImageSampler/SeparateImageSampler.cpp | 2 +- samples/Template/Template.cpp | 2 +- samples/TexelBuffer/TexelBuffer.cpp | 2 +- samples/utils/utils.cpp | 6 ------ samples/utils/utils.hpp | 13 +++---------- vulkan/vulkan.hpp | 2 +- 44 files changed, 80 insertions(+), 98 deletions(-) diff --git a/RAII_Samples/13_InitVertexBuffer/13_InitVertexBuffer.cpp b/RAII_Samples/13_InitVertexBuffer/13_InitVertexBuffer.cpp index 5c59d0b10..f6c4ff3cd 100644 --- a/RAII_Samples/13_InitVertexBuffer/13_InitVertexBuffer.cpp +++ b/RAII_Samples/13_InitVertexBuffer/13_InitVertexBuffer.cpp @@ -50,8 +50,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::raii::CommandPool commandPool = - vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); diff --git a/RAII_Samples/15_DrawCube/15_DrawCube.cpp b/RAII_Samples/15_DrawCube/15_DrawCube.cpp index 108c743aa..91c2acde8 100644 --- a/RAII_Samples/15_DrawCube/15_DrawCube.cpp +++ b/RAII_Samples/15_DrawCube/15_DrawCube.cpp @@ -54,8 +54,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::raii::CommandPool commandPool = - vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); diff --git a/RAII_Samples/CopyBlitImage/CopyBlitImage.cpp b/RAII_Samples/CopyBlitImage/CopyBlitImage.cpp index c309b9341..35185f9a7 100644 --- a/RAII_Samples/CopyBlitImage/CopyBlitImage.cpp +++ b/RAII_Samples/CopyBlitImage/CopyBlitImage.cpp @@ -46,8 +46,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::raii::CommandPool commandPool = - vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); @@ -140,7 +139,9 @@ int main( int /*argc*/, char ** /*argv*/ ) device.flushMappedMemoryRanges( mappedMemoryRange ); deviceMemory.unmapMemory(); - commandBuffer.reset( {} ); + // reset the command buffer by resetting the complete command pool + commandPool.reset(); + commandBuffer.begin( vk::CommandBufferBeginInfo() ); // Intend to blit from this image, set the layout accordingly @@ -151,9 +152,9 @@ int main( int /*argc*/, char ** /*argv*/ ) // Do a 32x32 blit to all of the dst image - should get big squares vk::ImageSubresourceLayers imageSubresourceLayers( vk::ImageAspectFlagBits::eColor, 0, 0, 1 ); vk::ImageBlit imageBlit( imageSubresourceLayers, - { { vk::Offset3D( 0, 0, 0 ), vk::Offset3D( 32, 32, 1 ) } }, + { { vk::Offset3D( 0, 0, 0 ), vk::Offset3D( 32, 32, 1 ) } }, imageSubresourceLayers, - { { vk::Offset3D( 0, 0, 0 ), vk::Offset3D( surfaceData.extent.width, surfaceData.extent.height, 1 ) } } ); + { { vk::Offset3D( 0, 0, 0 ), vk::Offset3D( surfaceData.extent.width, surfaceData.extent.height, 1 ) } } ); commandBuffer.blitImage( *blitSourceImage, vk::ImageLayout::eTransferSrcOptimal, blitDestinationImage, vk::ImageLayout::eTransferDstOptimal, imageBlit, vk::Filter::eLinear ); diff --git a/RAII_Samples/DrawTexturedCube/DrawTexturedCube.cpp b/RAII_Samples/DrawTexturedCube/DrawTexturedCube.cpp index 460bd200d..167652152 100644 --- a/RAII_Samples/DrawTexturedCube/DrawTexturedCube.cpp +++ b/RAII_Samples/DrawTexturedCube/DrawTexturedCube.cpp @@ -44,8 +44,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::raii::CommandPool commandPool = - vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); diff --git a/RAII_Samples/DynamicUniform/DynamicUniform.cpp b/RAII_Samples/DynamicUniform/DynamicUniform.cpp index 19340c539..76f9f653b 100644 --- a/RAII_Samples/DynamicUniform/DynamicUniform.cpp +++ b/RAII_Samples/DynamicUniform/DynamicUniform.cpp @@ -48,8 +48,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::raii::CommandPool commandPool = - vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); diff --git a/RAII_Samples/Events/Events.cpp b/RAII_Samples/Events/Events.cpp index 867645733..c556e3174 100644 --- a/RAII_Samples/Events/Events.cpp +++ b/RAII_Samples/Events/Events.cpp @@ -36,7 +36,7 @@ int main( int /*argc*/, char ** /*argv*/ ) uint32_t graphicsQueueFamilyIndex = vk::su::findGraphicsQueueFamilyIndex( physicalDevice.getQueueFamilyProperties() ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsQueueFamilyIndex, vk::su::getDeviceExtensions() ); - vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsQueueFamilyIndex } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsQueueFamilyIndex } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsQueueFamilyIndex, 0 ); @@ -71,7 +71,9 @@ int main( int /*argc*/, char ** /*argv*/ ) // Now create an event and wait for it on the GPU vk::raii::Event event( device, vk::EventCreateInfo() ); - commandBuffer.reset( vk::CommandBufferResetFlags() ); + // reset the command buffer by resetting the complete command pool of this frame + commandPool.reset(); + commandBuffer.begin( vk::CommandBufferBeginInfo() ); commandBuffer.waitEvents( { *event }, vk::PipelineStageFlagBits::eHost, vk::PipelineStageFlagBits::eBottomOfPipe, nullptr, nullptr, nullptr ); commandBuffer.end(); @@ -98,10 +100,12 @@ int main( int /*argc*/, char ** /*argv*/ ) } while ( result == vk::Result::eTimeout ); assert( result == vk::Result::eSuccess ); - commandBuffer.reset( {} ); device.resetFences( { *fence } ); event.reset(); + // reset the command buffer by resetting the complete command pool + commandPool.reset(); + // Now set the event from the GPU and wait on the CPU commandBuffer.begin( vk::CommandBufferBeginInfo() ); commandBuffer.setEvent( *event, vk::PipelineStageFlagBits::eBottomOfPipe ); diff --git a/RAII_Samples/ImmutableSampler/ImmutableSampler.cpp b/RAII_Samples/ImmutableSampler/ImmutableSampler.cpp index 2994c47ad..032e4002d 100644 --- a/RAII_Samples/ImmutableSampler/ImmutableSampler.cpp +++ b/RAII_Samples/ImmutableSampler/ImmutableSampler.cpp @@ -56,8 +56,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::raii::CommandPool commandPool = - vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); diff --git a/RAII_Samples/InitTexture/InitTexture.cpp b/RAII_Samples/InitTexture/InitTexture.cpp index 9a45dc414..09f42656f 100644 --- a/RAII_Samples/InitTexture/InitTexture.cpp +++ b/RAII_Samples/InitTexture/InitTexture.cpp @@ -53,8 +53,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::raii::CommandPool commandPool = - vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); diff --git a/RAII_Samples/InputAttachment/InputAttachment.cpp b/RAII_Samples/InputAttachment/InputAttachment.cpp index 8324fec26..d84bf8f85 100644 --- a/RAII_Samples/InputAttachment/InputAttachment.cpp +++ b/RAII_Samples/InputAttachment/InputAttachment.cpp @@ -89,8 +89,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::raii::CommandPool commandPool = - vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); diff --git a/RAII_Samples/MultipleSets/MultipleSets.cpp b/RAII_Samples/MultipleSets/MultipleSets.cpp index bcd0a52d6..06689ce2a 100644 --- a/RAII_Samples/MultipleSets/MultipleSets.cpp +++ b/RAII_Samples/MultipleSets/MultipleSets.cpp @@ -113,8 +113,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::raii::CommandPool commandPool = - vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); diff --git a/RAII_Samples/OcclusionQuery/OcclusionQuery.cpp b/RAII_Samples/OcclusionQuery/OcclusionQuery.cpp index 4e3c1ea45..44ff4d4c5 100644 --- a/RAII_Samples/OcclusionQuery/OcclusionQuery.cpp +++ b/RAII_Samples/OcclusionQuery/OcclusionQuery.cpp @@ -51,8 +51,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::raii::CommandPool commandPool = - vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); diff --git a/RAII_Samples/PipelineCache/PipelineCache.cpp b/RAII_Samples/PipelineCache/PipelineCache.cpp index 7339a914a..cdb6156c0 100644 --- a/RAII_Samples/PipelineCache/PipelineCache.cpp +++ b/RAII_Samples/PipelineCache/PipelineCache.cpp @@ -85,8 +85,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::raii::CommandPool commandPool = - vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); diff --git a/RAII_Samples/PipelineDerivative/PipelineDerivative.cpp b/RAII_Samples/PipelineDerivative/PipelineDerivative.cpp index 62ccc12f2..b6c188d45 100644 --- a/RAII_Samples/PipelineDerivative/PipelineDerivative.cpp +++ b/RAII_Samples/PipelineDerivative/PipelineDerivative.cpp @@ -52,8 +52,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::raii::CommandPool commandPool = - vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); diff --git a/RAII_Samples/PushConstants/PushConstants.cpp b/RAII_Samples/PushConstants/PushConstants.cpp index 5ba8daede..a8826b154 100644 --- a/RAII_Samples/PushConstants/PushConstants.cpp +++ b/RAII_Samples/PushConstants/PushConstants.cpp @@ -94,8 +94,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::raii::CommandPool commandPool = - vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); diff --git a/RAII_Samples/PushDescriptors/PushDescriptors.cpp b/RAII_Samples/PushDescriptors/PushDescriptors.cpp index 4e27230d9..c5e0b0f56 100644 --- a/RAII_Samples/PushDescriptors/PushDescriptors.cpp +++ b/RAII_Samples/PushDescriptors/PushDescriptors.cpp @@ -77,8 +77,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, deviceExtensions ); - vk::raii::CommandPool commandPool = - vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); diff --git a/RAII_Samples/RayTracing/RayTracing.cpp b/RAII_Samples/RayTracing/RayTracing.cpp index e22f40a11..a4727631c 100644 --- a/RAII_Samples/RayTracing/RayTracing.cpp +++ b/RAII_Samples/RayTracing/RayTracing.cpp @@ -169,7 +169,7 @@ AccelerationStructureData createAccelerationStructureData( vk::raii::PhysicalDev struct PerFrameData { PerFrameData( vk::raii::Device const & device, uint32_t queueFamilyIndex ) - : commandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, queueFamilyIndex } ) + : commandPool( device, { {}, queueFamilyIndex } ) , commandBuffer( vk::raii::su::makeCommandBuffer( device, commandPool ) ) , fence( device, vk::FenceCreateInfo( vk::FenceCreateFlagBits::eSignaled ) ) , presentCompleteSemaphore( device, vk::SemaphoreCreateInfo() ) @@ -1109,8 +1109,6 @@ int main( int /*argc*/, char ** /*argv*/ ) double startTime = glfwGetTime(); glfwPollEvents(); - vk::raii::CommandBuffer const & commandBuffer = perFrameData[frameIndex].commandBuffer; - int w, h; glfwGetWindowSize( window, &w, &h ); if ( ( w != static_cast( windowExtent.width ) ) || ( h != static_cast( windowExtent.height ) ) ) @@ -1129,7 +1127,8 @@ int main( int /*argc*/, char ** /*argv*/ ) depthBufferData = vk::raii::su::DepthBufferData( physicalDevice, device, vk::raii::su::pickDepthFormat( physicalDevice ), windowExtent ); vk::raii::su::oneTimeSubmit( - commandBuffer, + device, + perFrameData[frameIndex].commandPool, graphicsQueue, [&]( vk::raii::CommandBuffer const & commandBuffer ) { @@ -1160,6 +1159,11 @@ int main( int /*argc*/, char ** /*argv*/ ) ; device.resetFences( { *perFrameData[frameIndex].fence } ); + // reset the command buffer by resetting the complete command pool of this frame + perFrameData[frameIndex].commandPool.reset(); + + vk::raii::CommandBuffer const & commandBuffer = perFrameData[frameIndex].commandBuffer; + commandBuffer.begin( vk::CommandBufferBeginInfo( vk::CommandBufferUsageFlagBits::eOneTimeSubmit ) ); if ( appInfo.useRasterRender ) diff --git a/RAII_Samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp b/RAII_Samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp index 16c2e40f3..481610e16 100644 --- a/RAII_Samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp +++ b/RAII_Samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp @@ -54,8 +54,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::raii::CommandPool commandPool = - vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); diff --git a/RAII_Samples/SeparateImageSampler/SeparateImageSampler.cpp b/RAII_Samples/SeparateImageSampler/SeparateImageSampler.cpp index 73a74ed49..59fe18e80 100644 --- a/RAII_Samples/SeparateImageSampler/SeparateImageSampler.cpp +++ b/RAII_Samples/SeparateImageSampler/SeparateImageSampler.cpp @@ -82,8 +82,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::raii::CommandPool commandPool = - vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); diff --git a/RAII_Samples/Template/Template.cpp b/RAII_Samples/Template/Template.cpp index b5a7e5017..c0d5cf665 100644 --- a/RAII_Samples/Template/Template.cpp +++ b/RAII_Samples/Template/Template.cpp @@ -44,8 +44,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::raii::CommandPool commandPool = - vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); diff --git a/RAII_Samples/TexelBuffer/TexelBuffer.cpp b/RAII_Samples/TexelBuffer/TexelBuffer.cpp index 4e1ed380e..32897d698 100644 --- a/RAII_Samples/TexelBuffer/TexelBuffer.cpp +++ b/RAII_Samples/TexelBuffer/TexelBuffer.cpp @@ -86,8 +86,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::raii::CommandPool commandPool = - vk::raii::CommandPool( device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); + vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); diff --git a/RAII_Samples/utils/utils.hpp b/RAII_Samples/utils/utils.hpp index b8e79e93c..defd4a5e2 100644 --- a/RAII_Samples/utils/utils.hpp +++ b/RAII_Samples/utils/utils.hpp @@ -83,8 +83,9 @@ namespace vk } template - void oneTimeSubmit( vk::raii::CommandBuffer const & commandBuffer, vk::raii::Queue const & queue, Func const & func ) + void oneTimeSubmit( vk::raii::Device const & device, vk::raii::CommandPool const & commandPool, vk::raii::Queue const & queue, Func const & func ) { + vk::raii::CommandBuffer commandBuffer = std::move( vk::raii::CommandBuffers( device, { *commandPool, vk::CommandBufferLevel::ePrimary, 1 } ).front() ); commandBuffer.begin( vk::CommandBufferBeginInfo( vk::CommandBufferUsageFlagBits::eOneTimeSubmit ) ); func( commandBuffer ); commandBuffer.end(); @@ -93,13 +94,6 @@ namespace vk queue.waitIdle(); } - template - void oneTimeSubmit( vk::raii::Device const & device, vk::raii::CommandPool const & commandPool, vk::raii::Queue const & queue, Func const & func ) - { - vk::raii::CommandBuffers commandBuffers( device, { *commandPool, vk::CommandBufferLevel::ePrimary, 1 } ); - oneTimeSubmit( commandBuffers.front(), queue, func ); - } - void setImageLayout( vk::raii::CommandBuffer const & commandBuffer, vk::Image image, vk::Format format, vk::ImageLayout oldImageLayout, vk::ImageLayout newImageLayout ) { diff --git a/samples/13_InitVertexBuffer/13_InitVertexBuffer.cpp b/samples/13_InitVertexBuffer/13_InitVertexBuffer.cpp index cfc4989c3..f10d16c52 100644 --- a/samples/13_InitVertexBuffer/13_InitVertexBuffer.cpp +++ b/samples/13_InitVertexBuffer/13_InitVertexBuffer.cpp @@ -39,7 +39,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::pair graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsAndPresentQueueFamilyIndex.first ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); diff --git a/samples/15_DrawCube/15_DrawCube.cpp b/samples/15_DrawCube/15_DrawCube.cpp index 3cf30b65a..d852b5589 100644 --- a/samples/15_DrawCube/15_DrawCube.cpp +++ b/samples/15_DrawCube/15_DrawCube.cpp @@ -43,7 +43,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::pair graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsAndPresentQueueFamilyIndex.first ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); diff --git a/samples/CopyBlitImage/CopyBlitImage.cpp b/samples/CopyBlitImage/CopyBlitImage.cpp index 6cdf3e41b..3c4e57ad2 100644 --- a/samples/CopyBlitImage/CopyBlitImage.cpp +++ b/samples/CopyBlitImage/CopyBlitImage.cpp @@ -45,7 +45,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::pair graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsAndPresentQueueFamilyIndex.first ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); @@ -131,7 +131,9 @@ int main( int /*argc*/, char ** /*argv*/ ) device.flushMappedMemoryRanges( vk::MappedMemoryRange( deviceMemory, 0, memoryRequirements.size ) ); device.unmapMemory( deviceMemory ); - commandBuffer.reset( {} ); + // reset the command buffer by resetting the complete command pool + device.resetCommandPool( commandPool ); + commandBuffer.begin( vk::CommandBufferBeginInfo() ); // Intend to blit from this image, set the layout accordingly diff --git a/samples/DrawTexturedCube/DrawTexturedCube.cpp b/samples/DrawTexturedCube/DrawTexturedCube.cpp index 5989fd6b9..544ffd679 100644 --- a/samples/DrawTexturedCube/DrawTexturedCube.cpp +++ b/samples/DrawTexturedCube/DrawTexturedCube.cpp @@ -43,7 +43,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::pair graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsAndPresentQueueFamilyIndex.first ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); diff --git a/samples/DynamicUniform/DynamicUniform.cpp b/samples/DynamicUniform/DynamicUniform.cpp index 1c1163007..f3dbd8297 100644 --- a/samples/DynamicUniform/DynamicUniform.cpp +++ b/samples/DynamicUniform/DynamicUniform.cpp @@ -53,7 +53,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::pair graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsAndPresentQueueFamilyIndex.first ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); diff --git a/samples/Events/Events.cpp b/samples/Events/Events.cpp index be4f46cb8..941c4b899 100644 --- a/samples/Events/Events.cpp +++ b/samples/Events/Events.cpp @@ -36,7 +36,7 @@ int main( int /*argc*/, char ** /*argv*/ ) uint32_t graphicsQueueFamilyIndex = vk::su::findGraphicsQueueFamilyIndex( physicalDevice.getQueueFamilyProperties() ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsQueueFamilyIndex ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsQueueFamilyIndex ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsQueueFamilyIndex } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); @@ -72,7 +72,9 @@ int main( int /*argc*/, char ** /*argv*/ ) // Now create an event and wait for it on the GPU vk::Event event = device.createEvent( vk::EventCreateInfo( vk::EventCreateFlags() ) ); - commandBuffer.reset( vk::CommandBufferResetFlags() ); + // reset the command buffer by resetting the complete command pool + device.resetCommandPool( commandPool ); + commandBuffer.begin( vk::CommandBufferBeginInfo() ); commandBuffer.waitEvents( event, vk::PipelineStageFlagBits::eHost, vk::PipelineStageFlagBits::eBottomOfPipe, nullptr, nullptr, nullptr ); commandBuffer.end(); @@ -99,10 +101,12 @@ int main( int /*argc*/, char ** /*argv*/ ) } while ( result == vk::Result::eTimeout ); assert( result == vk::Result::eSuccess ); - commandBuffer.reset( {} ); device.resetFences( fence ); device.resetEvent( event ); + // reset the command buffer by resetting the complete command pool + device.resetCommandPool( commandPool ); + // Now set the event from the GPU and wait on the CPU commandBuffer.begin( vk::CommandBufferBeginInfo() ); commandBuffer.setEvent( event, vk::PipelineStageFlagBits::eBottomOfPipe ); diff --git a/samples/ImmutableSampler/ImmutableSampler.cpp b/samples/ImmutableSampler/ImmutableSampler.cpp index 6d1bcd7b2..edcaaa157 100644 --- a/samples/ImmutableSampler/ImmutableSampler.cpp +++ b/samples/ImmutableSampler/ImmutableSampler.cpp @@ -52,7 +52,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::pair graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsAndPresentQueueFamilyIndex.first ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); diff --git a/samples/InitTexture/InitTexture.cpp b/samples/InitTexture/InitTexture.cpp index 7669d2ab4..c1a26ba9d 100644 --- a/samples/InitTexture/InitTexture.cpp +++ b/samples/InitTexture/InitTexture.cpp @@ -52,7 +52,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::pair graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsAndPresentQueueFamilyIndex.first ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); diff --git a/samples/InputAttachment/InputAttachment.cpp b/samples/InputAttachment/InputAttachment.cpp index 260db21a2..0b13eeb50 100644 --- a/samples/InputAttachment/InputAttachment.cpp +++ b/samples/InputAttachment/InputAttachment.cpp @@ -88,7 +88,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::pair graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsAndPresentQueueFamilyIndex.first ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); diff --git a/samples/MultipleSets/MultipleSets.cpp b/samples/MultipleSets/MultipleSets.cpp index b8a98a60c..196721f76 100644 --- a/samples/MultipleSets/MultipleSets.cpp +++ b/samples/MultipleSets/MultipleSets.cpp @@ -102,7 +102,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::pair graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsAndPresentQueueFamilyIndex.first ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); diff --git a/samples/OcclusionQuery/OcclusionQuery.cpp b/samples/OcclusionQuery/OcclusionQuery.cpp index 8d33500b8..884d19c62 100644 --- a/samples/OcclusionQuery/OcclusionQuery.cpp +++ b/samples/OcclusionQuery/OcclusionQuery.cpp @@ -43,7 +43,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::pair graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsAndPresentQueueFamilyIndex.first ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); diff --git a/samples/PipelineCache/PipelineCache.cpp b/samples/PipelineCache/PipelineCache.cpp index 349b1874a..9af8520d5 100644 --- a/samples/PipelineCache/PipelineCache.cpp +++ b/samples/PipelineCache/PipelineCache.cpp @@ -84,7 +84,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::pair graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsAndPresentQueueFamilyIndex.first ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); diff --git a/samples/PipelineDerivative/PipelineDerivative.cpp b/samples/PipelineDerivative/PipelineDerivative.cpp index 185fadb83..784cf4405 100644 --- a/samples/PipelineDerivative/PipelineDerivative.cpp +++ b/samples/PipelineDerivative/PipelineDerivative.cpp @@ -51,7 +51,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::pair graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsAndPresentQueueFamilyIndex.first ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); diff --git a/samples/PushConstants/PushConstants.cpp b/samples/PushConstants/PushConstants.cpp index 1fd3e1275..1acbc94ad 100644 --- a/samples/PushConstants/PushConstants.cpp +++ b/samples/PushConstants/PushConstants.cpp @@ -93,7 +93,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::pair graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsAndPresentQueueFamilyIndex.first ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); diff --git a/samples/PushDescriptors/PushDescriptors.cpp b/samples/PushDescriptors/PushDescriptors.cpp index 279995613..c110c0446 100644 --- a/samples/PushDescriptors/PushDescriptors.cpp +++ b/samples/PushDescriptors/PushDescriptors.cpp @@ -81,7 +81,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::pair graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, deviceExtensions ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsAndPresentQueueFamilyIndex.first ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); diff --git a/samples/RayTracing/RayTracing.cpp b/samples/RayTracing/RayTracing.cpp index 4336195db..8f42af2da 100644 --- a/samples/RayTracing/RayTracing.cpp +++ b/samples/RayTracing/RayTracing.cpp @@ -745,8 +745,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::array perFrameData; for ( int i = 0; i < IMGUI_VK_QUEUED_FRAMES; i++ ) { - perFrameData[i].commandPool = - device.createCommandPool( vk::CommandPoolCreateInfo( vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first ) ); + perFrameData[i].commandPool = device.createCommandPool( vk::CommandPoolCreateInfo( {}, graphicsAndPresentQueueFamilyIndex.first ) ); perFrameData[i].commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( perFrameData[i].commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); perFrameData[i].fence = device.createFence( vk::FenceCreateInfo( vk::FenceCreateFlagBits::eSignaled ) ); @@ -1102,8 +1101,6 @@ int main( int /*argc*/, char ** /*argv*/ ) double startTime = glfwGetTime(); glfwPollEvents(); - vk::CommandBuffer const & commandBuffer = perFrameData[frameIndex].commandBuffer; - int w, h; glfwGetWindowSize( window, &w, &h ); if ( ( w != static_cast( windowExtent.width ) ) || ( h != static_cast( windowExtent.height ) ) ) @@ -1122,7 +1119,8 @@ int main( int /*argc*/, char ** /*argv*/ ) depthBufferData = vk::su::DepthBufferData( physicalDevice, device, vk::su::pickDepthFormat( physicalDevice ), windowExtent ); vk::su::oneTimeSubmit( - commandBuffer, + device, + perFrameData[frameIndex].commandPool, graphicsQueue, [&]( vk::CommandBuffer const & commandBuffer ) { @@ -1152,6 +1150,11 @@ int main( int /*argc*/, char ** /*argv*/ ) ; device.resetFences( perFrameData[frameIndex].fence ); + // reset the command buffer by resetting the complete command pool of this frame + device.resetCommandPool( perFrameData[frameIndex].commandPool ); + + vk::CommandBuffer const & commandBuffer = perFrameData[frameIndex].commandBuffer; + commandBuffer.begin( vk::CommandBufferBeginInfo( vk::CommandBufferUsageFlagBits::eOneTimeSubmit ) ); if ( appInfo.useRasterRender ) diff --git a/samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp b/samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp index f5674b01c..93771eac6 100644 --- a/samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp +++ b/samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp @@ -53,7 +53,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::pair graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsAndPresentQueueFamilyIndex.first ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); diff --git a/samples/SeparateImageSampler/SeparateImageSampler.cpp b/samples/SeparateImageSampler/SeparateImageSampler.cpp index fe20f464c..ec6cc5137 100644 --- a/samples/SeparateImageSampler/SeparateImageSampler.cpp +++ b/samples/SeparateImageSampler/SeparateImageSampler.cpp @@ -81,7 +81,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::pair graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsAndPresentQueueFamilyIndex.first ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); diff --git a/samples/Template/Template.cpp b/samples/Template/Template.cpp index 6d35f3580..9ff5827c7 100644 --- a/samples/Template/Template.cpp +++ b/samples/Template/Template.cpp @@ -43,7 +43,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::pair graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsAndPresentQueueFamilyIndex.first ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); diff --git a/samples/TexelBuffer/TexelBuffer.cpp b/samples/TexelBuffer/TexelBuffer.cpp index 52ec5590d..57ed8a1d1 100644 --- a/samples/TexelBuffer/TexelBuffer.cpp +++ b/samples/TexelBuffer/TexelBuffer.cpp @@ -85,7 +85,7 @@ int main( int /*argc*/, char ** /*argv*/ ) std::pair graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface ); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); - vk::CommandPool commandPool = vk::su::createCommandPool( device, graphicsAndPresentQueueFamilyIndex.first ); + vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } ); vk::CommandBuffer commandBuffer = device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); diff --git a/samples/utils/utils.cpp b/samples/utils/utils.cpp index fb02b32a6..49e88cd1f 100644 --- a/samples/utils/utils.cpp +++ b/samples/utils/utils.cpp @@ -59,12 +59,6 @@ namespace vk return ( propertyIterator != extensionProperties.end() ); } - vk::CommandPool createCommandPool( vk::Device const & device, uint32_t queueFamilyIndex ) - { - vk::CommandPoolCreateInfo commandPoolCreateInfo( vk::CommandPoolCreateFlagBits::eResetCommandBuffer, queueFamilyIndex ); - return device.createCommandPool( commandPoolCreateInfo ); - } - vk::DescriptorPool createDescriptorPool( vk::Device const & device, std::vector const & poolSizes ) { assert( !poolSizes.empty() ); diff --git a/samples/utils/utils.hpp b/samples/utils/utils.hpp index d35cf3cb1..5a88a0ee3 100644 --- a/samples/utils/utils.hpp +++ b/samples/utils/utils.hpp @@ -31,8 +31,10 @@ namespace vk const uint64_t FenceTimeout = 100000000; template - void oneTimeSubmit( vk::CommandBuffer const & commandBuffer, vk::Queue const & queue, Func const & func ) + void oneTimeSubmit( vk::Device const & device, vk::CommandPool const & commandPool, vk::Queue const & queue, Func const & func ) { + vk::CommandBuffer commandBuffer = + device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); commandBuffer.begin( vk::CommandBufferBeginInfo( vk::CommandBufferUsageFlagBits::eOneTimeSubmit ) ); func( commandBuffer ); commandBuffer.end(); @@ -40,14 +42,6 @@ namespace vk queue.waitIdle(); } - template - void oneTimeSubmit( vk::Device const & device, vk::CommandPool const & commandPool, vk::Queue const & queue, Func const & func ) - { - vk::CommandBuffer commandBuffer = - device.allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1 ) ).front(); - oneTimeSubmit( commandBuffer, queue, func ); - } - template void copyToDevice( vk::Device const & device, vk::DeviceMemory const & deviceMemory, T const * pData, size_t count, vk::DeviceSize stride = sizeof( T ) ) { @@ -360,7 +354,6 @@ namespace vk vk::MemoryRequirements const & memoryRequirements, vk::MemoryPropertyFlags memoryPropertyFlags ); bool contains( std::vector const & extensionProperties, std::string const & extensionName ); - vk::CommandPool createCommandPool( vk::Device const & device, uint32_t queueFamilyIndex ); vk::DescriptorPool createDescriptorPool( vk::Device const & device, std::vector const & poolSizes ); vk::DescriptorSetLayout createDescriptorSetLayout( vk::Device const & device, std::vector> const & bindingData, diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index 78c209da4..06d04a2a2 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -14221,7 +14221,7 @@ namespace VULKAN_HPP_NAMESPACE # elif defined( __APPLE__ ) m_library = dlopen( "libvulkan.dylib", RTLD_NOW | RTLD_LOCAL ); # elif defined( _WIN32 ) - m_library = ::LoadLibraryA( "vulkan-1.dll" ); + m_library = ::LoadLibraryA( "vulkan-1.dll" ); # else # error unsupported platform # endif