Introduce constructors on nullptr_t for the RAII handle classes.

This commit is contained in:
asuessenbach 2021-10-11 17:49:13 +02:00
parent 9f86befbaa
commit c3f32b8538
30 changed files with 479 additions and 1154 deletions

View File

@ -37,7 +37,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );

View File

@ -49,12 +49,12 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
vk::Format colorFormat = vk::Format colorFormat =
vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( **surfaceData.pSurface ) ).format; vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( *surfaceData.surface ) ).format;
vk::Format depthFormat = vk::Format::eD16Unorm; vk::Format depthFormat = vk::Format::eD16Unorm;
/* VULKAN_HPP_KEY_START */ /* VULKAN_HPP_KEY_START */

View File

@ -37,13 +37,13 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 64, 64 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 64, 64 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
vk::raii::su::SwapChainData swapChainData( physicalDevice, vk::raii::su::SwapChainData swapChainData( physicalDevice,
device, device,
*surfaceData.pSurface, surfaceData.surface,
surfaceData.extent, surfaceData.extent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eColorAttachment |
vk::ImageUsageFlagBits::eTransferSrc, vk::ImageUsageFlagBits::eTransferSrc,
@ -59,7 +59,7 @@ int main( int /*argc*/, char ** /*argv*/ )
/* VULKAN_KEY_START */ /* VULKAN_KEY_START */
std::array<vk::ImageView, 2> attachments; std::array<vk::ImageView, 2> attachments;
attachments[1] = **depthBufferData.pImageView; attachments[1] = *depthBufferData.imageView;
std::vector<vk::raii::Framebuffer> framebuffers; std::vector<vk::raii::Framebuffer> framebuffers;
framebuffers.reserve( swapChainData.imageViews.size() ); framebuffers.reserve( swapChainData.imageViews.size() );

View File

@ -48,7 +48,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 64, 64 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 64, 64 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
@ -60,7 +60,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SwapChainData swapChainData( physicalDevice, vk::raii::su::SwapChainData swapChainData( physicalDevice,
device, device,
*surfaceData.pSurface, surfaceData.surface,
surfaceData.extent, surfaceData.extent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eColorAttachment |
vk::ImageUsageFlagBits::eTransferSrc, vk::ImageUsageFlagBits::eTransferSrc,
@ -74,7 +74,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::makeRenderPass( device, swapChainData.colorFormat, depthBufferData.format ); vk::raii::su::makeRenderPass( device, swapChainData.colorFormat, depthBufferData.format );
std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers( std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers(
device, renderPass, swapChainData.imageViews, &*depthBufferData.pImageView, surfaceData.extent ); device, renderPass, swapChainData.imageViews, &depthBufferData.imageView, surfaceData.extent );
/* VULKAN_KEY_START */ /* VULKAN_KEY_START */
@ -104,7 +104,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::Result result; vk::Result result;
uint32_t imageIndex; uint32_t imageIndex;
std::tie( result, imageIndex ) = std::tie( result, imageIndex ) =
swapChainData.pSwapChain->acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore ); swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore );
assert( result == vk::Result::eSuccess ); assert( result == vk::Result::eSuccess );
assert( imageIndex < swapChainData.images.size() ); assert( imageIndex < swapChainData.images.size() );

View File

@ -51,12 +51,12 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
vk::Format colorFormat = vk::Format colorFormat =
vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( **surfaceData.pSurface ) ).format; vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( *surfaceData.surface ) ).format;
vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, vk::Format::eD16Unorm ); vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, vk::Format::eD16Unorm );
vk::raii::DescriptorSetLayout descriptorSetLayout = vk::raii::su::makeDescriptorSetLayout( vk::raii::DescriptorSetLayout descriptorSetLayout = vk::raii::su::makeDescriptorSetLayout(

View File

@ -52,7 +52,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
@ -65,7 +65,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SwapChainData swapChainData( physicalDevice, vk::raii::su::SwapChainData swapChainData( physicalDevice,
device, device,
*surfaceData.pSurface, surfaceData.surface,
surfaceData.extent, surfaceData.extent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eColorAttachment |
vk::ImageUsageFlagBits::eTransferSrc, vk::ImageUsageFlagBits::eTransferSrc,
@ -85,7 +85,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } ); vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } );
vk::Format colorFormat = vk::Format colorFormat =
vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( **surfaceData.pSurface ) ).format; vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( *surfaceData.surface ) ).format;
vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format ); vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format );
glslang::InitializeProcess(); glslang::InitializeProcess();
@ -96,7 +96,7 @@ int main( int /*argc*/, char ** /*argv*/ )
glslang::FinalizeProcess(); glslang::FinalizeProcess();
std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers( std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers(
device, renderPass, swapChainData.imageViews, &*depthBufferData.pImageView, surfaceData.extent ); device, renderPass, swapChainData.imageViews, &depthBufferData.imageView, surfaceData.extent );
vk::raii::su::BufferData vertexBufferData( vk::raii::su::BufferData vertexBufferData(
physicalDevice, device, sizeof( coloredCubeData ), vk::BufferUsageFlagBits::eVertexBuffer ); physicalDevice, device, sizeof( coloredCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
@ -133,7 +133,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::Result result; vk::Result result;
uint32_t imageIndex; uint32_t imageIndex;
std::tie( result, imageIndex ) = std::tie( result, imageIndex ) =
swapChainData.pSwapChain->acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore ); swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore );
assert( result == vk::Result::eSuccess ); assert( result == vk::Result::eSuccess );
assert( imageIndex < swapChainData.images.size() ); assert( imageIndex < swapChainData.images.size() );
@ -172,7 +172,7 @@ int main( int /*argc*/, char ** /*argv*/ )
while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) ) while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) )
; ;
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex ); vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
result = presentQueue.presentKHR( presentInfoKHR ); result = presentQueue.presentKHR( presentInfoKHR );
switch ( result ) switch ( result )
{ {

View File

@ -36,7 +36,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 640, 640 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 640, 640 ) );
vk::SurfaceCapabilitiesKHR surfaceCapabilities = physicalDevice.getSurfaceCapabilitiesKHR( **surfaceData.pSurface ); vk::SurfaceCapabilitiesKHR surfaceCapabilities = physicalDevice.getSurfaceCapabilitiesKHR( *surfaceData.surface );
if ( !( surfaceCapabilities.supportedUsageFlags & vk::ImageUsageFlagBits::eTransferDst ) ) if ( !( surfaceCapabilities.supportedUsageFlags & vk::ImageUsageFlagBits::eTransferDst ) )
{ {
std::cout << "Surface cannot be destination of blit - abort \n"; std::cout << "Surface cannot be destination of blit - abort \n";
@ -44,7 +44,7 @@ int main( int /*argc*/, char ** /*argv*/ )
} }
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
@ -57,7 +57,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SwapChainData swapChainData( physicalDevice, vk::raii::su::SwapChainData swapChainData( physicalDevice,
device, device,
*surfaceData.pSurface, surfaceData.surface,
surfaceData.extent, surfaceData.extent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eColorAttachment |
vk::ImageUsageFlagBits::eTransferSrc | vk::ImageUsageFlagBits::eTransferSrc |
@ -79,7 +79,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::Result result; vk::Result result;
uint32_t imageIndex; uint32_t imageIndex;
std::tie( result, imageIndex ) = std::tie( result, imageIndex ) =
swapChainData.pSwapChain->acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore ); swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore );
assert( result == vk::Result::eSuccess ); assert( result == vk::Result::eSuccess );
assert( imageIndex < swapChainData.images.size() ); assert( imageIndex < swapChainData.images.size() );
@ -227,7 +227,7 @@ int main( int /*argc*/, char ** /*argv*/ )
; ;
/* Now present the image in the window */ /* Now present the image in the window */
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex ); vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
result = presentQueue.presentKHR( presentInfoKHR ); result = presentQueue.presentKHR( presentInfoKHR );
switch ( result ) switch ( result )
{ {

View File

@ -43,7 +43,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
@ -56,7 +56,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SwapChainData swapChainData( physicalDevice, vk::raii::su::SwapChainData swapChainData( physicalDevice,
device, device,
*surfaceData.pSurface, surfaceData.surface,
surfaceData.extent, surfaceData.extent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eColorAttachment |
vk::ImageUsageFlagBits::eTransferSrc, vk::ImageUsageFlagBits::eTransferSrc,
@ -83,7 +83,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } ); vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } );
vk::Format colorFormat = vk::Format colorFormat =
vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( **surfaceData.pSurface ) ).format; vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( *surfaceData.surface ) ).format;
vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format ); vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format );
glslang::InitializeProcess(); glslang::InitializeProcess();
@ -94,7 +94,7 @@ int main( int /*argc*/, char ** /*argv*/ )
glslang::FinalizeProcess(); glslang::FinalizeProcess();
std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers( std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers(
device, renderPass, swapChainData.imageViews, &*depthBufferData.pImageView, surfaceData.extent ); device, renderPass, swapChainData.imageViews, &depthBufferData.imageView, surfaceData.extent );
vk::raii::su::BufferData vertexBufferData( vk::raii::su::BufferData vertexBufferData(
physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer ); physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
@ -133,7 +133,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::Result result; vk::Result result;
uint32_t imageIndex; uint32_t imageIndex;
std::tie( result, imageIndex ) = std::tie( result, imageIndex ) =
swapChainData.pSwapChain->acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore ); swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore );
assert( result == vk::Result::eSuccess ); assert( result == vk::Result::eSuccess );
assert( imageIndex < swapChainData.images.size() ); assert( imageIndex < swapChainData.images.size() );
@ -173,7 +173,7 @@ int main( int /*argc*/, char ** /*argv*/ )
while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) ) while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) )
; ;
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex ); vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
result = presentQueue.presentKHR( presentInfoKHR ); result = presentQueue.presentKHR( presentInfoKHR );
switch ( result ) switch ( result )
{ {

View File

@ -47,7 +47,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
@ -60,7 +60,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SwapChainData swapChainData( physicalDevice, vk::raii::su::SwapChainData swapChainData( physicalDevice,
device, device,
*surfaceData.pSurface, surfaceData.surface,
surfaceData.extent, surfaceData.extent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eColorAttachment |
vk::ImageUsageFlagBits::eTransferSrc, vk::ImageUsageFlagBits::eTransferSrc,
@ -71,7 +71,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::DepthBufferData depthBufferData( physicalDevice, device, vk::Format::eD16Unorm, surfaceData.extent ); vk::raii::su::DepthBufferData depthBufferData( physicalDevice, device, vk::Format::eD16Unorm, surfaceData.extent );
vk::Format colorFormat = vk::Format colorFormat =
vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( **surfaceData.pSurface ) ).format; vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( *surfaceData.surface ) ).format;
vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format ); vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format );
glslang::InitializeProcess(); glslang::InitializeProcess();
@ -82,7 +82,7 @@ int main( int /*argc*/, char ** /*argv*/ )
glslang::FinalizeProcess(); glslang::FinalizeProcess();
std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers( std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers(
device, renderPass, swapChainData.imageViews, &*depthBufferData.pImageView, surfaceData.extent ); device, renderPass, swapChainData.imageViews, &depthBufferData.imageView, surfaceData.extent );
vk::raii::su::BufferData vertexBufferData( vk::raii::su::BufferData vertexBufferData(
physicalDevice, device, sizeof( coloredCubeData ), vk::BufferUsageFlagBits::eVertexBuffer ); physicalDevice, device, sizeof( coloredCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
@ -160,7 +160,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::Result result; vk::Result result;
uint32_t imageIndex; uint32_t imageIndex;
std::tie( result, imageIndex ) = std::tie( result, imageIndex ) =
swapChainData.pSwapChain->acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore ); swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore );
assert( result == vk::Result::eSuccess ); assert( result == vk::Result::eSuccess );
assert( imageIndex < swapChainData.images.size() ); assert( imageIndex < swapChainData.images.size() );
@ -209,7 +209,7 @@ int main( int /*argc*/, char ** /*argv*/ )
while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) ) while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) )
; ;
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex ); vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
result = presentQueue.presentKHR( presentInfoKHR ); result = presentQueue.presentKHR( presentInfoKHR );
switch ( result ) switch ( result )
{ {

View File

@ -55,7 +55,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
@ -68,7 +68,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SwapChainData swapChainData( physicalDevice, vk::raii::su::SwapChainData swapChainData( physicalDevice,
device, device,
*surfaceData.pSurface, surfaceData.surface,
surfaceData.extent, surfaceData.extent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eColorAttachment |
vk::ImageUsageFlagBits::eTransferSrc, vk::ImageUsageFlagBits::eTransferSrc,
@ -84,7 +84,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::copyToDevice( uniformBufferData.deviceMemory, mvpcMatrix ); vk::raii::su::copyToDevice( uniformBufferData.deviceMemory, mvpcMatrix );
vk::Format colorFormat = vk::Format colorFormat =
vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( **surfaceData.pSurface ) ).format; vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( *surfaceData.surface ) ).format;
vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format ); vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format );
glslang::InitializeProcess(); glslang::InitializeProcess();
@ -95,7 +95,7 @@ int main( int /*argc*/, char ** /*argv*/ )
glslang::FinalizeProcess(); glslang::FinalizeProcess();
std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers( std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers(
device, renderPass, swapChainData.imageViews, &*depthBufferData.pImageView, surfaceData.extent ); device, renderPass, swapChainData.imageViews, &depthBufferData.imageView, surfaceData.extent );
vk::raii::su::BufferData vertexBufferData( vk::raii::su::BufferData vertexBufferData(
physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer ); physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
@ -136,7 +136,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::DescriptorBufferInfo bufferInfo( *uniformBufferData.buffer, 0, sizeof( glm::mat4x4 ) ); vk::DescriptorBufferInfo bufferInfo( *uniformBufferData.buffer, 0, sizeof( glm::mat4x4 ) );
vk::DescriptorImageInfo imageInfo( vk::DescriptorImageInfo imageInfo(
*textureData.sampler, **textureData.pImageData->pImageView, vk::ImageLayout::eShaderReadOnlyOptimal ); *textureData.sampler, *textureData.imageData.imageView, vk::ImageLayout::eShaderReadOnlyOptimal );
std::array<vk::WriteDescriptorSet, 2> writeDescriptorSets = { std::array<vk::WriteDescriptorSet, 2> writeDescriptorSets = {
vk::WriteDescriptorSet( *descriptorSet, 0, 0, vk::DescriptorType::eUniformBuffer, {}, bufferInfo ), vk::WriteDescriptorSet( *descriptorSet, 0, 0, vk::DescriptorType::eUniformBuffer, {}, bufferInfo ),
vk::WriteDescriptorSet( *descriptorSet, 1, 0, vk::DescriptorType::eCombinedImageSampler, imageInfo ) vk::WriteDescriptorSet( *descriptorSet, 1, 0, vk::DescriptorType::eCombinedImageSampler, imageInfo )
@ -164,7 +164,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::Result result; vk::Result result;
uint32_t imageIndex; uint32_t imageIndex;
std::tie( result, imageIndex ) = std::tie( result, imageIndex ) =
swapChainData.pSwapChain->acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore ); swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore );
assert( result == vk::Result::eSuccess ); assert( result == vk::Result::eSuccess );
assert( imageIndex < swapChainData.images.size() ); assert( imageIndex < swapChainData.images.size() );
@ -194,7 +194,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::submitAndWait( device, graphicsQueue, commandBuffer ); vk::raii::su::submitAndWait( device, graphicsQueue, commandBuffer );
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex ); vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
result = presentQueue.presentKHR( presentInfoKHR ); result = presentQueue.presentKHR( presentInfoKHR );
switch ( result ) switch ( result )
{ {

View File

@ -52,7 +52,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 50, 50 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 50, 50 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
@ -101,27 +101,27 @@ int main( int /*argc*/, char ** /*argv*/ )
// bind memory // bind memory
image.bindMemory( *imageMemory, 0 ); image.bindMemory( *imageMemory, 0 );
std::unique_ptr<vk::raii::Buffer> pTextureBuffer; vk::raii::Buffer textureBuffer = nullptr;
std::unique_ptr<vk::raii::DeviceMemory> pTextureBufferMemory; vk::raii::DeviceMemory textureBufferMemory = nullptr;
if ( needsStaging ) if ( needsStaging )
{ {
// Need a staging buffer to map and copy texture into // Need a staging buffer to map and copy texture into
vk::BufferCreateInfo bufferCreateInfo( vk::BufferCreateInfo bufferCreateInfo(
{}, surfaceData.extent.width * surfaceData.extent.height * 4, vk::BufferUsageFlagBits::eTransferSrc ); {}, surfaceData.extent.width * surfaceData.extent.height * 4, vk::BufferUsageFlagBits::eTransferSrc );
pTextureBuffer = vk::raii::su::make_unique<vk::raii::Buffer>( device, bufferCreateInfo ); textureBuffer = vk::raii::Buffer( device, bufferCreateInfo );
memoryRequirements = pTextureBuffer->getMemoryRequirements(); memoryRequirements = textureBuffer.getMemoryRequirements();
memoryTypeIndex = memoryTypeIndex =
vk::su::findMemoryType( physicalDevice.getMemoryProperties(), vk::su::findMemoryType( physicalDevice.getMemoryProperties(),
memoryRequirements.memoryTypeBits, memoryRequirements.memoryTypeBits,
vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent ); vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent );
// allocate memory // allocate memory
memoryAllocateInfo = vk::MemoryAllocateInfo( memoryRequirements.size, memoryTypeIndex ); memoryAllocateInfo = vk::MemoryAllocateInfo( memoryRequirements.size, memoryTypeIndex );
pTextureBufferMemory = vk::raii::su::make_unique<vk::raii::DeviceMemory>( device, memoryAllocateInfo ); textureBufferMemory = vk::raii::DeviceMemory( device, memoryAllocateInfo );
// bind memory // bind memory
pTextureBuffer->bindMemory( **pTextureBufferMemory, 0 ); textureBuffer.bindMemory( *textureBufferMemory, 0 );
} }
else else
{ {
@ -129,7 +129,7 @@ int main( int /*argc*/, char ** /*argv*/ )
image.getSubresourceLayout( vk::ImageSubresource( vk::ImageAspectFlagBits::eColor ) ); image.getSubresourceLayout( vk::ImageSubresource( vk::ImageAspectFlagBits::eColor ) );
} }
void * data = needsStaging ? pTextureBufferMemory->mapMemory( 0, memoryRequirements.size, vk::MemoryMapFlags() ) void * data = needsStaging ? textureBufferMemory.mapMemory( 0, memoryRequirements.size, vk::MemoryMapFlags() )
: imageMemory.mapMemory( 0, memoryRequirements.size, vk::MemoryMapFlags() ); : imageMemory.mapMemory( 0, memoryRequirements.size, vk::MemoryMapFlags() );
// Checkerboard of 16x16 pixel squares // Checkerboard of 16x16 pixel squares
@ -147,7 +147,7 @@ int main( int /*argc*/, char ** /*argv*/ )
} }
} }
needsStaging ? pTextureBufferMemory->unmapMemory() : imageMemory.unmapMemory(); needsStaging ? textureBufferMemory.unmapMemory() : imageMemory.unmapMemory();
commandBuffer.begin( vk::CommandBufferBeginInfo() ); commandBuffer.begin( vk::CommandBufferBeginInfo() );
if ( needsStaging ) if ( needsStaging )
@ -161,7 +161,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::ImageSubresourceLayers( vk::ImageAspectFlagBits::eColor, 0, 0, 1 ), vk::ImageSubresourceLayers( vk::ImageAspectFlagBits::eColor, 0, 0, 1 ),
vk::Offset3D( 0, 0, 0 ), vk::Offset3D( 0, 0, 0 ),
vk::Extent3D( surfaceData.extent, 1 ) ); vk::Extent3D( surfaceData.extent, 1 ) );
commandBuffer.copyBufferToImage( **pTextureBuffer, *image, vk::ImageLayout::eTransferDstOptimal, copyRegion ); commandBuffer.copyBufferToImage( *textureBuffer, *image, vk::ImageLayout::eTransferDstOptimal, copyRegion );
// Set the layout for the texture image from eTransferDstOptimal to SHADER_READ_ONLY // Set the layout for the texture image from eTransferDstOptimal to SHADER_READ_ONLY
vk::raii::su::setImageLayout( vk::raii::su::setImageLayout(
commandBuffer, *image, format, vk::ImageLayout::eTransferDstOptimal, vk::ImageLayout::eShaderReadOnlyOptimal ); commandBuffer, *image, format, vk::ImageLayout::eTransferDstOptimal, vk::ImageLayout::eShaderReadOnlyOptimal );

View File

@ -88,7 +88,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
@ -101,7 +101,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SwapChainData swapChainData( physicalDevice, vk::raii::su::SwapChainData swapChainData( physicalDevice,
device, device,
*surfaceData.pSurface, surfaceData.surface,
surfaceData.extent, surfaceData.extent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eColorAttachment |
vk::ImageUsageFlagBits::eTransferSrc, vk::ImageUsageFlagBits::eTransferSrc,
@ -245,7 +245,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::Result result; vk::Result result;
uint32_t imageIndex; uint32_t imageIndex;
std::tie( result, imageIndex ) = std::tie( result, imageIndex ) =
swapChainData.pSwapChain->acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore ); swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore );
assert( result == vk::Result::eSuccess ); assert( result == vk::Result::eSuccess );
assert( imageIndex < swapChainData.images.size() ); assert( imageIndex < swapChainData.images.size() );
@ -275,7 +275,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::submitAndWait( device, graphicsQueue, commandBuffer ); vk::raii::su::submitAndWait( device, graphicsQueue, commandBuffer );
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex ); vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
result = presentQueue.presentKHR( presentInfoKHR ); result = presentQueue.presentKHR( presentInfoKHR );
switch ( result ) switch ( result )
{ {

View File

@ -112,7 +112,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
@ -125,7 +125,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SwapChainData swapChainData( physicalDevice, vk::raii::su::SwapChainData swapChainData( physicalDevice,
device, device,
*surfaceData.pSurface, surfaceData.surface,
surfaceData.extent, surfaceData.extent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eColorAttachment |
vk::ImageUsageFlagBits::eTransferSrc, vk::ImageUsageFlagBits::eTransferSrc,
@ -146,7 +146,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::copyToDevice( uniformBufferData.deviceMemory, mvpcMatrix ); vk::raii::su::copyToDevice( uniformBufferData.deviceMemory, mvpcMatrix );
vk::Format colorFormat = vk::Format colorFormat =
vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( **surfaceData.pSurface ) ).format; vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( *surfaceData.surface ) ).format;
vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format ); vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format );
glslang::InitializeProcess(); glslang::InitializeProcess();
@ -157,7 +157,7 @@ int main( int /*argc*/, char ** /*argv*/ )
glslang::FinalizeProcess(); glslang::FinalizeProcess();
std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers( std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers(
device, renderPass, swapChainData.imageViews, &*depthBufferData.pImageView, surfaceData.extent ); device, renderPass, swapChainData.imageViews, &depthBufferData.imageView, surfaceData.extent );
vk::raii::su::BufferData vertexBufferData( vk::raii::su::BufferData vertexBufferData(
physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer ); physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
@ -198,7 +198,7 @@ int main( int /*argc*/, char ** /*argv*/ )
// Populate with info about our uniform buffer // Populate with info about our uniform buffer
vk::DescriptorBufferInfo uniformBufferInfo( *uniformBufferData.buffer, 0, sizeof( glm::mat4x4 ) ); vk::DescriptorBufferInfo uniformBufferInfo( *uniformBufferData.buffer, 0, sizeof( glm::mat4x4 ) );
vk::DescriptorImageInfo textureImageInfo( vk::DescriptorImageInfo textureImageInfo(
*textureData.sampler, **textureData.pImageData->pImageView, vk::ImageLayout::eShaderReadOnlyOptimal ); *textureData.sampler, *textureData.imageData.imageView, vk::ImageLayout::eShaderReadOnlyOptimal );
std::array<vk::WriteDescriptorSet, 2> writeDescriptorSets = { std::array<vk::WriteDescriptorSet, 2> writeDescriptorSets = {
{ vk::WriteDescriptorSet( *descriptorSets[0], 0, 0, vk::DescriptorType::eUniformBuffer, {}, uniformBufferInfo ), { vk::WriteDescriptorSet( *descriptorSets[0], 0, 0, vk::DescriptorType::eUniformBuffer, {}, uniformBufferInfo ),
vk::WriteDescriptorSet( vk::WriteDescriptorSet(
@ -228,7 +228,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::Result result; vk::Result result;
uint32_t imageIndex; uint32_t imageIndex;
std::tie( result, imageIndex ) = std::tie( result, imageIndex ) =
swapChainData.pSwapChain->acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore ); swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore );
assert( result == vk::Result::eSuccess ); assert( result == vk::Result::eSuccess );
assert( imageIndex < swapChainData.images.size() ); assert( imageIndex < swapChainData.images.size() );
@ -266,7 +266,7 @@ int main( int /*argc*/, char ** /*argv*/ )
while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) ) while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) )
; ;
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex ); vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
result = presentQueue.presentKHR( presentInfoKHR ); result = presentQueue.presentKHR( presentInfoKHR );
switch ( result ) switch ( result )
{ {

View File

@ -50,7 +50,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
@ -63,7 +63,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SwapChainData swapChainData( physicalDevice, vk::raii::su::SwapChainData swapChainData( physicalDevice,
device, device,
*surfaceData.pSurface, surfaceData.surface,
surfaceData.extent, surfaceData.extent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eColorAttachment |
vk::ImageUsageFlagBits::eTransferSrc, vk::ImageUsageFlagBits::eTransferSrc,
@ -83,7 +83,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } ); vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } );
vk::Format colorFormat = vk::Format colorFormat =
vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( **surfaceData.pSurface ) ).format; vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( *surfaceData.surface ) ).format;
vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format ); vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format );
glslang::InitializeProcess(); glslang::InitializeProcess();
@ -94,7 +94,7 @@ int main( int /*argc*/, char ** /*argv*/ )
glslang::FinalizeProcess(); glslang::FinalizeProcess();
std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers( std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers(
device, renderPass, swapChainData.imageViews, &*depthBufferData.pImageView, surfaceData.extent ); device, renderPass, swapChainData.imageViews, &depthBufferData.imageView, surfaceData.extent );
vk::raii::su::BufferData vertexBufferData( vk::raii::su::BufferData vertexBufferData(
physicalDevice, device, sizeof( coloredCubeData ), vk::BufferUsageFlagBits::eVertexBuffer ); physicalDevice, device, sizeof( coloredCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
@ -132,7 +132,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::Result result; vk::Result result;
uint32_t imageIndex; uint32_t imageIndex;
std::tie( result, imageIndex ) = std::tie( result, imageIndex ) =
swapChainData.pSwapChain->acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore ); swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore );
assert( result == vk::Result::eSuccess ); assert( result == vk::Result::eSuccess );
assert( imageIndex < swapChainData.images.size() ); assert( imageIndex < swapChainData.images.size() );
@ -232,7 +232,7 @@ int main( int /*argc*/, char ** /*argv*/ )
while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) ) while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) )
; ;
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex ); vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
result = presentQueue.presentKHR( presentInfoKHR ); result = presentQueue.presentKHR( presentInfoKHR );
switch ( result ) switch ( result )
{ {

View File

@ -84,7 +84,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
@ -97,7 +97,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SwapChainData swapChainData( physicalDevice, vk::raii::su::SwapChainData swapChainData( physicalDevice,
device, device,
*surfaceData.pSurface, surfaceData.surface,
surfaceData.extent, surfaceData.extent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eColorAttachment |
vk::ImageUsageFlagBits::eTransferSrc, vk::ImageUsageFlagBits::eTransferSrc,
@ -124,7 +124,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } ); vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } );
vk::Format colorFormat = vk::Format colorFormat =
vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( **surfaceData.pSurface ) ).format; vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( *surfaceData.surface ) ).format;
vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format ); vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format );
glslang::InitializeProcess(); glslang::InitializeProcess();
@ -135,7 +135,7 @@ int main( int /*argc*/, char ** /*argv*/ )
glslang::FinalizeProcess(); glslang::FinalizeProcess();
std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers( std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers(
device, renderPass, swapChainData.imageViews, &*depthBufferData.pImageView, surfaceData.extent ); device, renderPass, swapChainData.imageViews, &depthBufferData.imageView, surfaceData.extent );
vk::raii::su::BufferData vertexBufferData( vk::raii::su::BufferData vertexBufferData(
physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer ); physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
@ -316,7 +316,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::Result result; vk::Result result;
uint32_t imageIndex; uint32_t imageIndex;
std::tie( result, imageIndex ) = std::tie( result, imageIndex ) =
swapChainData.pSwapChain->acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore ); swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore );
assert( result == vk::Result::eSuccess ); assert( result == vk::Result::eSuccess );
assert( imageIndex < swapChainData.images.size() ); assert( imageIndex < swapChainData.images.size() );
@ -354,7 +354,7 @@ int main( int /*argc*/, char ** /*argv*/ )
while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) ) while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) )
; ;
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex ); vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
result = presentQueue.presentKHR( presentInfoKHR ); result = presentQueue.presentKHR( presentInfoKHR );
switch ( result ) switch ( result )
{ {

View File

@ -51,7 +51,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
@ -64,7 +64,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SwapChainData swapChainData( physicalDevice, vk::raii::su::SwapChainData swapChainData( physicalDevice,
device, device,
*surfaceData.pSurface, surfaceData.surface,
surfaceData.extent, surfaceData.extent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eColorAttachment |
vk::ImageUsageFlagBits::eTransferSrc, vk::ImageUsageFlagBits::eTransferSrc,
@ -91,7 +91,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } ); vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } );
vk::Format colorFormat = vk::Format colorFormat =
vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( **surfaceData.pSurface ) ).format; vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( *surfaceData.surface ) ).format;
vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format ); vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format );
glslang::InitializeProcess(); glslang::InitializeProcess();
@ -102,7 +102,7 @@ int main( int /*argc*/, char ** /*argv*/ )
glslang::FinalizeProcess(); glslang::FinalizeProcess();
std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers( std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers(
device, renderPass, swapChainData.imageViews, &*depthBufferData.pImageView, surfaceData.extent ); device, renderPass, swapChainData.imageViews, &depthBufferData.imageView, surfaceData.extent );
vk::raii::su::BufferData vertexBufferData( vk::raii::su::BufferData vertexBufferData(
physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer ); physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
@ -252,7 +252,7 @@ void main()
vk::Result result; vk::Result result;
uint32_t imageIndex; uint32_t imageIndex;
std::tie( result, imageIndex ) = std::tie( result, imageIndex ) =
swapChainData.pSwapChain->acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore ); swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore );
assert( result == vk::Result::eSuccess ); assert( result == vk::Result::eSuccess );
assert( imageIndex < swapChainData.images.size() ); assert( imageIndex < swapChainData.images.size() );
@ -290,7 +290,7 @@ void main()
while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) ) while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) )
; ;
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex ); vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
result = presentQueue.presentKHR( presentInfoKHR ); result = presentQueue.presentKHR( presentInfoKHR );
switch ( result ) switch ( result )
{ {

View File

@ -93,7 +93,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
@ -106,7 +106,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SwapChainData swapChainData( physicalDevice, vk::raii::su::SwapChainData swapChainData( physicalDevice,
device, device,
*surfaceData.pSurface, surfaceData.surface,
surfaceData.extent, surfaceData.extent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eColorAttachment |
vk::ImageUsageFlagBits::eTransferSrc, vk::ImageUsageFlagBits::eTransferSrc,
@ -122,7 +122,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::copyToDevice( uniformBufferData.deviceMemory, mvpcMatrix ); vk::raii::su::copyToDevice( uniformBufferData.deviceMemory, mvpcMatrix );
vk::Format colorFormat = vk::Format colorFormat =
vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( **surfaceData.pSurface ) ).format; vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( *surfaceData.surface ) ).format;
vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format ); vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format );
glslang::InitializeProcess(); glslang::InitializeProcess();
@ -133,7 +133,7 @@ int main( int /*argc*/, char ** /*argv*/ )
glslang::FinalizeProcess(); glslang::FinalizeProcess();
std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers( std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers(
device, renderPass, swapChainData.imageViews, &*depthBufferData.pImageView, surfaceData.extent ); device, renderPass, swapChainData.imageViews, &depthBufferData.imageView, surfaceData.extent );
vk::raii::su::BufferData vertexBufferData( vk::raii::su::BufferData vertexBufferData(
physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer ); physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
@ -201,7 +201,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::Result result; vk::Result result;
uint32_t imageIndex; uint32_t imageIndex;
std::tie( result, imageIndex ) = std::tie( result, imageIndex ) =
swapChainData.pSwapChain->acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore ); swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore );
assert( result == vk::Result::eSuccess ); assert( result == vk::Result::eSuccess );
assert( imageIndex < swapChainData.images.size() ); assert( imageIndex < swapChainData.images.size() );
@ -239,7 +239,7 @@ int main( int /*argc*/, char ** /*argv*/ )
while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) ) while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) )
; ;
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex ); vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
result = presentQueue.presentKHR( presentInfoKHR ); result = presentQueue.presentKHR( presentInfoKHR );
switch ( result ) switch ( result )
{ {

View File

@ -77,7 +77,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::Device device =
vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, deviceExtensions ); vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, deviceExtensions );
@ -91,7 +91,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SwapChainData swapChainData( physicalDevice, vk::raii::su::SwapChainData swapChainData( physicalDevice,
device, device,
*surfaceData.pSurface, surfaceData.surface,
surfaceData.extent, surfaceData.extent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eColorAttachment |
vk::ImageUsageFlagBits::eTransferSrc, vk::ImageUsageFlagBits::eTransferSrc,
@ -121,7 +121,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } ); vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } );
vk::Format colorFormat = vk::Format colorFormat =
vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( **surfaceData.pSurface ) ).format; vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( *surfaceData.surface ) ).format;
vk::raii::RenderPass renderPass = vk::raii::RenderPass renderPass =
vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format ); vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format );
@ -133,7 +133,7 @@ int main( int /*argc*/, char ** /*argv*/ )
glslang::FinalizeProcess(); glslang::FinalizeProcess();
std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers( std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers(
device, renderPass, swapChainData.imageViews, &*depthBufferData.pImageView, surfaceData.extent ); device, renderPass, swapChainData.imageViews, &depthBufferData.imageView, surfaceData.extent );
vk::raii::su::BufferData vertexBufferData( vk::raii::su::BufferData vertexBufferData(
physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer ); physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
@ -160,7 +160,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::Result result; vk::Result result;
uint32_t imageIndex; uint32_t imageIndex;
std::tie( result, imageIndex ) = std::tie( result, imageIndex ) =
swapChainData.pSwapChain->acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore ); swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore );
assert( result == vk::Result::eSuccess ); assert( result == vk::Result::eSuccess );
assert( imageIndex < swapChainData.images.size() ); assert( imageIndex < swapChainData.images.size() );
@ -174,7 +174,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::DescriptorBufferInfo bufferInfo( *uniformBufferData.buffer, 0, sizeof( glm::mat4x4 ) ); vk::DescriptorBufferInfo bufferInfo( *uniformBufferData.buffer, 0, sizeof( glm::mat4x4 ) );
vk::DescriptorImageInfo imageInfo( vk::DescriptorImageInfo imageInfo(
*textureData.sampler, **textureData.pImageData->pImageView, vk::ImageLayout::eShaderReadOnlyOptimal ); *textureData.sampler, *textureData.imageData.imageView, vk::ImageLayout::eShaderReadOnlyOptimal );
vk::WriteDescriptorSet writeDescriptorSets[2] = { vk::WriteDescriptorSet writeDescriptorSets[2] = {
vk::WriteDescriptorSet( {}, 0, 0, vk::DescriptorType::eUniformBuffer, {}, bufferInfo ), vk::WriteDescriptorSet( {}, 0, 0, vk::DescriptorType::eUniformBuffer, {}, bufferInfo ),
vk::WriteDescriptorSet( {}, 1, 0, vk::DescriptorType::eCombinedImageSampler, imageInfo ) vk::WriteDescriptorSet( {}, 1, 0, vk::DescriptorType::eCombinedImageSampler, imageInfo )
@ -207,7 +207,7 @@ int main( int /*argc*/, char ** /*argv*/ )
while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) ) while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) )
; ;
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex ); vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
result = presentQueue.presentKHR( presentInfoKHR ); result = presentQueue.presentKHR( presentInfoKHR );
switch ( result ) switch ( result )
{ {

View File

@ -81,18 +81,18 @@ static_assert( sizeof( GeometryInstanceData ) == 64, "GeometryInstanceData struc
struct AccelerationStructureData struct AccelerationStructureData
{ {
std::shared_ptr<vk::raii::AccelerationStructureNV> pAcclerationStructure; vk::raii::AccelerationStructureNV acclerationStructure = nullptr;
std::unique_ptr<vk::raii::su::BufferData> pScratchBufferData; vk::raii::su::BufferData scratchBufferData = nullptr;
std::unique_ptr<vk::raii::su::BufferData> pResultBufferData; vk::raii::su::BufferData resultBufferData = nullptr;
std::unique_ptr<vk::raii::su::BufferData> pInstanceBufferData; vk::raii::su::BufferData instanceBufferData = nullptr;
}; };
AccelerationStructureData createAccelerationStructureData( AccelerationStructureData createAccelerationStructureData(
vk::raii::PhysicalDevice const & physicalDevice, vk::raii::PhysicalDevice const & physicalDevice,
vk::raii::Device const & device, vk::raii::Device const & device,
vk::raii::CommandBuffer const & commandBuffer, vk::raii::CommandBuffer const & commandBuffer,
std::vector<std::pair<std::shared_ptr<vk::raii::AccelerationStructureNV>, glm::mat4x4>> const & instances, std::vector<std::pair<vk::raii::AccelerationStructureNV &, glm::mat4x4 &>> const & instances,
std::vector<vk::GeometryNV> const & geometries ) std::vector<vk::GeometryNV> const & geometries )
{ {
assert( instances.empty() ^ geometries.empty() ); assert( instances.empty() ^ geometries.empty() );
@ -103,51 +103,48 @@ AccelerationStructureData createAccelerationStructureData(
vk::AccelerationStructureInfoNV accelerationStructureInfo( vk::AccelerationStructureInfoNV accelerationStructureInfo(
accelerationStructureType, {}, vk::su::checked_cast<uint32_t>( instances.size() ), geometries ); accelerationStructureType, {}, vk::su::checked_cast<uint32_t>( instances.size() ), geometries );
vk::AccelerationStructureCreateInfoNV accelerationStructureCreateInfoNV( 0, accelerationStructureInfo ); vk::AccelerationStructureCreateInfoNV accelerationStructureCreateInfoNV( 0, accelerationStructureInfo );
accelerationStructureData.pAcclerationStructure = accelerationStructureData.acclerationStructure =
std::make_shared<vk::raii::AccelerationStructureNV>( device, accelerationStructureCreateInfoNV ); vk::raii::AccelerationStructureNV( device, accelerationStructureCreateInfoNV );
vk::AccelerationStructureMemoryRequirementsInfoNV objectRequirements( vk::AccelerationStructureMemoryRequirementsInfoNV objectRequirements(
vk::AccelerationStructureMemoryRequirementsTypeNV::eObject, **accelerationStructureData.pAcclerationStructure ); vk::AccelerationStructureMemoryRequirementsTypeNV::eObject, *accelerationStructureData.acclerationStructure );
vk::DeviceSize resultSizeInBytes = vk::DeviceSize resultSizeInBytes =
device.getAccelerationStructureMemoryRequirementsNV( objectRequirements ).memoryRequirements.size; device.getAccelerationStructureMemoryRequirementsNV( objectRequirements ).memoryRequirements.size;
assert( 0 < resultSizeInBytes ); assert( 0 < resultSizeInBytes );
accelerationStructureData.pResultBufferData = accelerationStructureData.resultBufferData = vk::raii::su::BufferData( physicalDevice,
vk::raii::su::make_unique<vk::raii::su::BufferData>( physicalDevice, device,
device, resultSizeInBytes,
resultSizeInBytes, vk::BufferUsageFlagBits::eRayTracingNV,
vk::BufferUsageFlagBits::eRayTracingNV, vk::MemoryPropertyFlagBits::eDeviceLocal );
vk::MemoryPropertyFlagBits::eDeviceLocal );
vk::AccelerationStructureMemoryRequirementsInfoNV buildScratchRequirements( vk::AccelerationStructureMemoryRequirementsInfoNV buildScratchRequirements(
vk::AccelerationStructureMemoryRequirementsTypeNV::eBuildScratch, vk::AccelerationStructureMemoryRequirementsTypeNV::eBuildScratch, *accelerationStructureData.acclerationStructure );
**accelerationStructureData.pAcclerationStructure );
vk::AccelerationStructureMemoryRequirementsInfoNV updateScratchRequirements( vk::AccelerationStructureMemoryRequirementsInfoNV updateScratchRequirements(
vk::AccelerationStructureMemoryRequirementsTypeNV::eUpdateScratch, vk::AccelerationStructureMemoryRequirementsTypeNV::eUpdateScratch,
**accelerationStructureData.pAcclerationStructure ); *accelerationStructureData.acclerationStructure );
vk::DeviceSize scratchSizeInBytes = std::max( vk::DeviceSize scratchSizeInBytes = std::max(
device.getAccelerationStructureMemoryRequirementsNV( buildScratchRequirements ).memoryRequirements.size, device.getAccelerationStructureMemoryRequirementsNV( buildScratchRequirements ).memoryRequirements.size,
device.getAccelerationStructureMemoryRequirementsNV( updateScratchRequirements ).memoryRequirements.size ); device.getAccelerationStructureMemoryRequirementsNV( updateScratchRequirements ).memoryRequirements.size );
assert( 0 < scratchSizeInBytes ); assert( 0 < scratchSizeInBytes );
accelerationStructureData.pScratchBufferData = accelerationStructureData.scratchBufferData = vk::raii::su::BufferData( physicalDevice,
vk::raii::su::make_unique<vk::raii::su::BufferData>( physicalDevice, device,
device, scratchSizeInBytes,
scratchSizeInBytes, vk::BufferUsageFlagBits::eRayTracingNV,
vk::BufferUsageFlagBits::eRayTracingNV, vk::MemoryPropertyFlagBits::eDeviceLocal );
vk::MemoryPropertyFlagBits::eDeviceLocal );
if ( !instances.empty() ) if ( !instances.empty() )
{ {
accelerationStructureData.pInstanceBufferData = accelerationStructureData.instanceBufferData =
vk::raii::su::make_unique<vk::raii::su::BufferData>( physicalDevice, vk::raii::su::BufferData( physicalDevice,
device, device,
instances.size() * sizeof( GeometryInstanceData ), instances.size() * sizeof( GeometryInstanceData ),
vk::BufferUsageFlagBits::eRayTracingNV ); vk::BufferUsageFlagBits::eRayTracingNV );
std::vector<GeometryInstanceData> geometryInstanceData; std::vector<GeometryInstanceData> geometryInstanceData;
for ( size_t i = 0; i < instances.size(); i++ ) for ( size_t i = 0; i < instances.size(); i++ )
{ {
uint64_t accelerationStructureHandle = instances[i].first->getHandle<uint64_t>(); uint64_t accelerationStructureHandle = instances[i].first.getHandle<uint64_t>();
// For each instance we set its instance index to its index i in the instance vector, and set // For each instance we set its instance index to its index i in the instance vector, and set
// its hit group index to 2*i. The hit group index defines which entry of the shader binding // its hit group index to 2*i. The hit group index defines which entry of the shader binding
@ -161,16 +158,16 @@ AccelerationStructureData createAccelerationStructureData(
static_cast<uint8_t>( vk::GeometryInstanceFlagBitsNV::eTriangleCullDisable ), static_cast<uint8_t>( vk::GeometryInstanceFlagBitsNV::eTriangleCullDisable ),
accelerationStructureHandle ); accelerationStructureHandle );
} }
accelerationStructureData.pInstanceBufferData->upload( geometryInstanceData ); accelerationStructureData.instanceBufferData.upload( geometryInstanceData );
} }
device.bindAccelerationStructureMemoryNV( vk::BindAccelerationStructureMemoryInfoNV( device.bindAccelerationStructureMemoryNV( vk::BindAccelerationStructureMemoryInfoNV(
**accelerationStructureData.pAcclerationStructure, *accelerationStructureData.pResultBufferData->deviceMemory ) ); *accelerationStructureData.acclerationStructure, *accelerationStructureData.resultBufferData.deviceMemory ) );
vk::Buffer instanceData; vk::Buffer instanceData;
if ( accelerationStructureData.pInstanceBufferData ) if ( *accelerationStructureData.instanceBufferData.buffer )
{ {
instanceData = *accelerationStructureData.pInstanceBufferData->buffer; instanceData = *accelerationStructureData.instanceBufferData.buffer;
} }
vk::AccelerationStructureInfoNV accelerationStructureInfoNV( vk::AccelerationStructureInfoNV accelerationStructureInfoNV(
accelerationStructureType, {}, vk::su::checked_cast<uint32_t>( instances.size() ), geometries ); accelerationStructureType, {}, vk::su::checked_cast<uint32_t>( instances.size() ), geometries );
@ -178,9 +175,9 @@ AccelerationStructureData createAccelerationStructureData(
instanceData, instanceData,
0, 0,
false, false,
**accelerationStructureData.pAcclerationStructure, *accelerationStructureData.acclerationStructure,
nullptr, nullptr,
*accelerationStructureData.pScratchBufferData->buffer, *accelerationStructureData.scratchBufferData.buffer,
0 ); 0 );
vk::MemoryBarrier memoryBarrier( vk::MemoryBarrier memoryBarrier(
@ -788,7 +785,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::DepthBufferData depthBufferData( physicalDevice, device, depthFormat, windowExtent ); vk::raii::su::DepthBufferData depthBufferData( physicalDevice, device, depthFormat, windowExtent );
std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers( std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers(
device, renderPass, swapChainData.imageViews, &*depthBufferData.pImageView, windowExtent ); device, renderPass, swapChainData.imageViews, &depthBufferData.imageView, windowExtent );
bool samplerAnisotropy = !!supportedFeatures.get<vk::PhysicalDeviceFeatures2>().features.samplerAnisotropy; bool samplerAnisotropy = !!supportedFeatures.get<vk::PhysicalDeviceFeatures2>().features.samplerAnisotropy;
@ -962,12 +959,12 @@ int main( int /*argc*/, char ** /*argv*/ )
{}, {},
{ vk::GeometryNV( vk::GeometryTypeNV::eTriangles, geometryDataNV ) } ); { vk::GeometryNV( vk::GeometryTypeNV::eTriangles, geometryDataNV ) } );
topLevelAS = topLevelAS = createAccelerationStructureData(
createAccelerationStructureData( physicalDevice, physicalDevice,
device, device,
commandBuffer, commandBuffer,
{ std::make_pair( bottomLevelAS.pAcclerationStructure, transform ) }, { std::make_pair( std::ref( bottomLevelAS.acclerationStructure ), std::ref( transform ) ) },
std::vector<vk::GeometryNV>() ); std::vector<vk::GeometryNV>() );
} ); } );
// create raytracing descriptor set // create raytracing descriptor set
@ -1043,7 +1040,7 @@ int main( int /*argc*/, char ** /*argv*/ )
// Bind ray tracing specific descriptor sets into pNext of a vk::WriteDescriptorSet // Bind ray tracing specific descriptor sets into pNext of a vk::WriteDescriptorSet
vk::WriteDescriptorSetAccelerationStructureNV writeDescriptorSetAcceleration( 1, vk::WriteDescriptorSetAccelerationStructureNV writeDescriptorSetAcceleration( 1,
&**topLevelAS.pAcclerationStructure ); &*topLevelAS.acclerationStructure );
std::vector<vk::WriteDescriptorSet> accelerationDescriptionSets; std::vector<vk::WriteDescriptorSet> accelerationDescriptionSets;
for ( size_t i = 0; i < rayTracingDescriptorSets.size(); i++ ) for ( size_t i = 0; i < rayTracingDescriptorSets.size(); i++ )
{ {
@ -1211,7 +1208,7 @@ int main( int /*argc*/, char ** /*argv*/ )
surface, surface,
windowExtent, windowExtent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eStorage, vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eStorage,
&*swapChainData.pSwapChain, &swapChainData.swapChain,
graphicsAndPresentQueueFamilyIndex.first, graphicsAndPresentQueueFamilyIndex.first,
graphicsAndPresentQueueFamilyIndex.second ); graphicsAndPresentQueueFamilyIndex.second );
depthBufferData = vk::raii::su::DepthBufferData( depthBufferData = vk::raii::su::DepthBufferData(
@ -1229,7 +1226,7 @@ int main( int /*argc*/, char ** /*argv*/ )
} ); } );
framebuffers = vk::raii::su::makeFramebuffers( framebuffers = vk::raii::su::makeFramebuffers(
device, renderPass, swapChainData.imageViews, &*depthBufferData.pImageView, windowExtent ); device, renderPass, swapChainData.imageViews, &depthBufferData.imageView, windowExtent );
} }
// update the uniformBufferObject // update the uniformBufferObject
@ -1245,7 +1242,7 @@ int main( int /*argc*/, char ** /*argv*/ )
// frame begin // frame begin
vk::Result result; vk::Result result;
uint32_t backBufferIndex; uint32_t backBufferIndex;
std::tie( result, backBufferIndex ) = swapChainData.pSwapChain->acquireNextImage( std::tie( result, backBufferIndex ) = swapChainData.swapChain.acquireNextImage(
vk::su::FenceTimeout, *perFrameData[frameIndex].presentCompleteSemaphore ); vk::su::FenceTimeout, *perFrameData[frameIndex].presentCompleteSemaphore );
assert( result == vk::Result::eSuccess ); assert( result == vk::Result::eSuccess );
@ -1337,7 +1334,7 @@ int main( int /*argc*/, char ** /*argv*/ )
&*perFrameData[frameIndex].renderCompleteSemaphore ); &*perFrameData[frameIndex].renderCompleteSemaphore );
graphicsQueue.submit( submitInfo, *perFrameData[frameIndex].fence ); graphicsQueue.submit( submitInfo, *perFrameData[frameIndex].fence );
vk::PresentInfoKHR presentInfoKHR( vk::PresentInfoKHR presentInfoKHR(
*perFrameData[frameIndex].renderCompleteSemaphore, **swapChainData.pSwapChain, backBufferIndex ); *perFrameData[frameIndex].renderCompleteSemaphore, *swapChainData.swapChain, backBufferIndex );
result = presentQueue.presentKHR( presentInfoKHR ); result = presentQueue.presentKHR( presentInfoKHR );
switch ( result ) switch ( result )
{ {

View File

@ -53,7 +53,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
@ -66,7 +66,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SwapChainData swapChainData( physicalDevice, vk::raii::su::SwapChainData swapChainData( physicalDevice,
device, device,
*surfaceData.pSurface, surfaceData.surface,
surfaceData.extent, surfaceData.extent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eColorAttachment |
vk::ImageUsageFlagBits::eTransferSrc, vk::ImageUsageFlagBits::eTransferSrc,
@ -88,7 +88,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } ); vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } );
vk::Format colorFormat = vk::Format colorFormat =
vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( **surfaceData.pSurface ) ).format; vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( *surfaceData.surface ) ).format;
vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device,
colorFormat, colorFormat,
depthBufferData.format, depthBufferData.format,
@ -103,7 +103,7 @@ int main( int /*argc*/, char ** /*argv*/ )
glslang::FinalizeProcess(); glslang::FinalizeProcess();
std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers( std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers(
device, renderPass, swapChainData.imageViews, &*depthBufferData.pImageView, surfaceData.extent ); device, renderPass, swapChainData.imageViews, &depthBufferData.imageView, surfaceData.extent );
vk::raii::su::BufferData vertexBufferData( vk::raii::su::BufferData vertexBufferData(
physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer ); physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
@ -162,7 +162,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::Result result; vk::Result result;
uint32_t imageIndex; uint32_t imageIndex;
std::tie( result, imageIndex ) = std::tie( result, imageIndex ) =
swapChainData.pSwapChain->acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore ); swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore );
assert( result == vk::Result::eSuccess ); assert( result == vk::Result::eSuccess );
assert( imageIndex < swapChainData.images.size() ); assert( imageIndex < swapChainData.images.size() );
@ -239,7 +239,7 @@ int main( int /*argc*/, char ** /*argv*/ )
while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) ) while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) )
; ;
result = presentQueue.presentKHR( vk::PresentInfoKHR( {}, **swapChainData.pSwapChain, imageIndex, {} ) ); result = presentQueue.presentKHR( vk::PresentInfoKHR( {}, *swapChainData.swapChain, imageIndex, {} ) );
switch ( result ) switch ( result )
{ {
case vk::Result::eSuccess: break; case vk::Result::eSuccess: break;

View File

@ -81,7 +81,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
@ -94,7 +94,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SwapChainData swapChainData( physicalDevice, vk::raii::su::SwapChainData swapChainData( physicalDevice,
device, device,
*surfaceData.pSurface, surfaceData.surface,
surfaceData.extent, surfaceData.extent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eColorAttachment |
vk::ImageUsageFlagBits::eTransferSrc, vk::ImageUsageFlagBits::eTransferSrc,
@ -110,7 +110,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::copyToDevice( uniformBufferData.deviceMemory, mvpcMatrix ); vk::raii::su::copyToDevice( uniformBufferData.deviceMemory, mvpcMatrix );
vk::Format colorFormat = vk::Format colorFormat =
vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( **surfaceData.pSurface ) ).format; vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( *surfaceData.surface ) ).format;
vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format ); vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format );
glslang::InitializeProcess(); glslang::InitializeProcess();
@ -121,7 +121,7 @@ int main( int /*argc*/, char ** /*argv*/ )
glslang::FinalizeProcess(); glslang::FinalizeProcess();
std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers( std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers(
device, renderPass, swapChainData.imageViews, &*depthBufferData.pImageView, surfaceData.extent ); device, renderPass, swapChainData.imageViews, &depthBufferData.imageView, surfaceData.extent );
vk::raii::su::BufferData vertexBufferData( vk::raii::su::BufferData vertexBufferData(
physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer ); physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
@ -187,7 +187,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::DescriptorBufferInfo bufferInfo( *uniformBufferData.buffer, 0, sizeof( glm::mat4x4 ) ); vk::DescriptorBufferInfo bufferInfo( *uniformBufferData.buffer, 0, sizeof( glm::mat4x4 ) );
vk::DescriptorImageInfo imageInfo( vk::DescriptorImageInfo imageInfo(
*textureData.sampler, **textureData.pImageData->pImageView, vk::ImageLayout::eShaderReadOnlyOptimal ); *textureData.sampler, *textureData.imageData.imageView, vk::ImageLayout::eShaderReadOnlyOptimal );
vk::DescriptorImageInfo samplerInfo( *sampler, {}, {} ); vk::DescriptorImageInfo samplerInfo( *sampler, {}, {} );
std::array<vk::WriteDescriptorSet, 3> descriptorWrites = { std::array<vk::WriteDescriptorSet, 3> descriptorWrites = {
{ vk::WriteDescriptorSet( *descriptorSet, 0, 0, vk::DescriptorType::eUniformBuffer, {}, bufferInfo ), { vk::WriteDescriptorSet( *descriptorSet, 0, 0, vk::DescriptorType::eUniformBuffer, {}, bufferInfo ),
@ -218,7 +218,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::Result result; vk::Result result;
uint32_t imageIndex; uint32_t imageIndex;
std::tie( result, imageIndex ) = std::tie( result, imageIndex ) =
swapChainData.pSwapChain->acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore ); swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore );
assert( result == vk::Result::eSuccess ); assert( result == vk::Result::eSuccess );
assert( imageIndex < swapChainData.images.size() ); assert( imageIndex < swapChainData.images.size() );
@ -257,7 +257,7 @@ int main( int /*argc*/, char ** /*argv*/ )
while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) ) while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) )
; ;
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex ); vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
result = presentQueue.presentKHR( presentInfoKHR ); result = presentQueue.presentKHR( presentInfoKHR );
switch ( result ) switch ( result )
{ {

View File

@ -102,7 +102,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::DisplayNativeHdrSurfaceCapabilitiesAMD, vk::DisplayNativeHdrSurfaceCapabilitiesAMD,
vk::SharedPresentSurfaceCapabilitiesKHR, vk::SharedPresentSurfaceCapabilitiesKHR,
vk::SurfaceCapabilitiesFullScreenExclusiveEXT, vk::SurfaceCapabilitiesFullScreenExclusiveEXT,
vk::SurfaceProtectedCapabilitiesKHR>( { **surfaceData.pSurface } ); vk::SurfaceProtectedCapabilitiesKHR>( { *surfaceData.surface } );
vk::SurfaceCapabilitiesKHR const & surfaceCapabilities = vk::SurfaceCapabilitiesKHR const & surfaceCapabilities =
surfaceCapabilities2.get<vk::SurfaceCapabilities2KHR>().surfaceCapabilities; surfaceCapabilities2.get<vk::SurfaceCapabilities2KHR>().surfaceCapabilities;
@ -153,7 +153,7 @@ int main( int /*argc*/, char ** /*argv*/ )
else else
{ {
vk::SurfaceCapabilitiesKHR surfaceCapabilities = vk::SurfaceCapabilitiesKHR surfaceCapabilities =
physicalDevices[i].getSurfaceCapabilitiesKHR( **surfaceData.pSurface ); physicalDevices[i].getSurfaceCapabilitiesKHR( *surfaceData.surface );
cout( surfaceCapabilities ); cout( surfaceCapabilities );
} }
} }

View File

@ -48,7 +48,7 @@ int main( int /*argc*/, char ** /*argv*/ )
{ {
std::cout << "PhysicalDevice " << i << "\n"; std::cout << "PhysicalDevice " << i << "\n";
std::vector<vk::SurfaceFormatKHR> surfaceFormats = std::vector<vk::SurfaceFormatKHR> surfaceFormats =
physicalDevices[i].getSurfaceFormatsKHR( **surfaceData.pSurface ); physicalDevices[i].getSurfaceFormatsKHR( *surfaceData.surface );
for ( size_t j = 0; j < surfaceFormats.size(); j++ ) for ( size_t j = 0; j < surfaceFormats.size(); j++ )
{ {
std::cout << "\tFormat " << j << "\n"; std::cout << "\tFormat " << j << "\n";

View File

@ -43,7 +43,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
@ -56,7 +56,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SwapChainData swapChainData( physicalDevice, vk::raii::su::SwapChainData swapChainData( physicalDevice,
device, device,
*surfaceData.pSurface, surfaceData.surface,
surfaceData.extent, surfaceData.extent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eColorAttachment |
vk::ImageUsageFlagBits::eTransferSrc, vk::ImageUsageFlagBits::eTransferSrc,
@ -83,7 +83,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } ); vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } );
vk::Format colorFormat = vk::Format colorFormat =
vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( **surfaceData.pSurface ) ).format; vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( *surfaceData.surface ) ).format;
vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format ); vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format );
glslang::InitializeProcess(); glslang::InitializeProcess();
@ -94,7 +94,7 @@ int main( int /*argc*/, char ** /*argv*/ )
glslang::FinalizeProcess(); glslang::FinalizeProcess();
std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers( std::vector<vk::raii::Framebuffer> framebuffers = vk::raii::su::makeFramebuffers(
device, renderPass, swapChainData.imageViews, &*depthBufferData.pImageView, surfaceData.extent ); device, renderPass, swapChainData.imageViews, &depthBufferData.imageView, surfaceData.extent );
vk::raii::su::BufferData vertexBufferData( vk::raii::su::BufferData vertexBufferData(
physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer ); physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
@ -131,7 +131,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::Result result; vk::Result result;
uint32_t imageIndex; uint32_t imageIndex;
std::tie( result, imageIndex ) = std::tie( result, imageIndex ) =
swapChainData.pSwapChain->acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore ); swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore );
assert( result == vk::Result::eSuccess ); assert( result == vk::Result::eSuccess );
assert( imageIndex < swapChainData.images.size() ); assert( imageIndex < swapChainData.images.size() );
@ -169,7 +169,7 @@ int main( int /*argc*/, char ** /*argv*/ )
while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) ) while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) )
; ;
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex ); vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
result = presentQueue.presentKHR( presentInfoKHR ); result = presentQueue.presentKHR( presentInfoKHR );
switch ( result ) switch ( result )
{ {

View File

@ -85,7 +85,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) ); vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface ); vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
vk::raii::Device device = vk::raii::su::makeDevice( vk::raii::Device device = vk::raii::su::makeDevice(
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() ); physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
@ -98,7 +98,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::su::SwapChainData swapChainData( physicalDevice, vk::raii::su::SwapChainData swapChainData( physicalDevice,
device, device,
*surfaceData.pSurface, surfaceData.surface,
surfaceData.extent, surfaceData.extent,
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eColorAttachment |
vk::ImageUsageFlagBits::eTransferSrc, vk::ImageUsageFlagBits::eTransferSrc,
@ -118,7 +118,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } ); vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } );
vk::Format colorFormat = vk::Format colorFormat =
vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( **surfaceData.pSurface ) ).format; vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( *surfaceData.surface ) ).format;
vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, vk::Format::eUndefined ); vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, vk::Format::eUndefined );
glslang::InitializeProcess(); glslang::InitializeProcess();
@ -163,7 +163,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::Result result; vk::Result result;
uint32_t imageIndex; uint32_t imageIndex;
std::tie( result, imageIndex ) = std::tie( result, imageIndex ) =
swapChainData.pSwapChain->acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore ); swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore );
assert( result == vk::Result::eSuccess ); assert( result == vk::Result::eSuccess );
assert( imageIndex < swapChainData.images.size() ); assert( imageIndex < swapChainData.images.size() );
@ -201,7 +201,7 @@ int main( int /*argc*/, char ** /*argv*/ )
while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) ) while ( vk::Result::eTimeout == device.waitForFences( { *drawFence }, VK_TRUE, vk::su::FenceTimeout ) )
; ;
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex ); vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
result = presentQueue.presentKHR( presentInfoKHR ); result = presentQueue.presentKHR( presentInfoKHR );
switch ( result ) switch ( result )
{ {

View File

@ -217,6 +217,8 @@ namespace vk
buffer.bindMemory( *deviceMemory, 0 ); buffer.bindMemory( *deviceMemory, 0 );
} }
BufferData( std::nullptr_t ) {}
template <typename DataType> template <typename DataType>
void upload( DataType const & data ) const void upload( DataType const & data ) const
{ {
@ -270,8 +272,8 @@ namespace vk
} }
// the order of buffer and deviceMemory here is important to get the constructor running ! // the order of buffer and deviceMemory here is important to get the constructor running !
vk::raii::Buffer buffer; vk::raii::Buffer buffer = nullptr;
vk::raii::DeviceMemory deviceMemory; vk::raii::DeviceMemory deviceMemory = nullptr;
#if !defined( NDEBUG ) #if !defined( NDEBUG )
private: private:
vk::DeviceSize m_size; vk::DeviceSize m_size;
@ -309,7 +311,7 @@ namespace vk
device, physicalDevice.getMemoryProperties(), image.getMemoryRequirements(), memoryProperties ) ) device, physicalDevice.getMemoryProperties(), image.getMemoryRequirements(), memoryProperties ) )
{ {
image.bindMemory( *deviceMemory, 0 ); image.bindMemory( *deviceMemory, 0 );
pImageView = vk::raii::su::make_unique<vk::raii::ImageView>( imageView = vk::raii::ImageView(
device, device,
vk::ImageViewCreateInfo( vk::ImageViewCreateInfo(
{}, {},
@ -320,10 +322,12 @@ namespace vk
{ aspectMask, 0, 1, 0, 1 } ) ); { aspectMask, 0, 1, 0, 1 } ) );
} }
vk::Format format; ImageData( std::nullptr_t ) {}
vk::raii::Image image;
vk::raii::DeviceMemory deviceMemory; vk::Format format;
std::unique_ptr<vk::raii::ImageView> pImageView; vk::raii::Image image = nullptr;
vk::raii::DeviceMemory deviceMemory = nullptr;
vk::raii::ImageView imageView = nullptr;
}; };
struct DepthBufferData : public ImageData struct DepthBufferData : public ImageData
@ -354,12 +358,12 @@ namespace vk
glfwCreateWindowSurface( static_cast<VkInstance>( *instance ), window.handle, nullptr, &_surface ); glfwCreateWindowSurface( static_cast<VkInstance>( *instance ), window.handle, nullptr, &_surface );
if ( err != VK_SUCCESS ) if ( err != VK_SUCCESS )
throw std::runtime_error( "Failed to create window!" ); throw std::runtime_error( "Failed to create window!" );
pSurface = vk::raii::su::make_unique<vk::raii::SurfaceKHR>( instance, _surface ); surface = vk::raii::SurfaceKHR( instance, _surface );
} }
vk::Extent2D extent; vk::Extent2D extent;
vk::su::WindowData window; vk::su::WindowData window;
std::unique_ptr<vk::raii::SurfaceKHR> pSurface; vk::raii::SurfaceKHR surface = nullptr;
}; };
struct SwapChainData struct SwapChainData
@ -431,9 +435,9 @@ namespace vk
swapChainCreateInfo.queueFamilyIndexCount = 2; swapChainCreateInfo.queueFamilyIndexCount = 2;
swapChainCreateInfo.pQueueFamilyIndices = queueFamilyIndices; swapChainCreateInfo.pQueueFamilyIndices = queueFamilyIndices;
} }
pSwapChain = vk::raii::su::make_unique<vk::raii::SwapchainKHR>( device, swapChainCreateInfo ); swapChain = vk::raii::SwapchainKHR( device, swapChainCreateInfo );
images = pSwapChain->getImages(); images = swapChain.getImages();
imageViews.reserve( images.size() ); imageViews.reserve( images.size() );
vk::ComponentMapping componentMapping( vk::ComponentMapping componentMapping(
@ -451,10 +455,10 @@ namespace vk
} }
} }
vk::Format colorFormat; vk::Format colorFormat;
std::unique_ptr<vk::raii::SwapchainKHR> pSwapChain; vk::raii::SwapchainKHR swapChain = nullptr;
std::vector<VkImage> images; std::vector<VkImage> images;
std::vector<vk::raii::ImageView> imageViews; std::vector<vk::raii::ImageView> imageViews;
}; };
struct TextureData struct TextureData
@ -484,7 +488,6 @@ namespace vk
0.0f, 0.0f,
0.0f, 0.0f,
vk::BorderColor::eFloatOpaqueBlack } ) vk::BorderColor::eFloatOpaqueBlack } )
{ {
vk::FormatProperties formatProperties = physicalDevice.getFormatProperties( format ); vk::FormatProperties formatProperties = physicalDevice.getFormatProperties( format );
@ -497,7 +500,7 @@ namespace vk
if ( needsStaging ) if ( needsStaging )
{ {
assert( ( formatProperties.optimalTilingFeatures & formatFeatureFlags ) == formatFeatureFlags ); assert( ( formatProperties.optimalTilingFeatures & formatFeatureFlags ) == formatFeatureFlags );
pStagingBufferData = vk::raii::su::make_unique<BufferData>( stagingBufferData = BufferData(
physicalDevice, device, extent.width * extent.height * 4, vk::BufferUsageFlagBits::eTransferSrc ); physicalDevice, device, extent.width * extent.height * 4, vk::BufferUsageFlagBits::eTransferSrc );
imageTiling = vk::ImageTiling::eOptimal; imageTiling = vk::ImageTiling::eOptimal;
usageFlags |= vk::ImageUsageFlagBits::eTransferDst; usageFlags |= vk::ImageUsageFlagBits::eTransferDst;
@ -509,15 +512,15 @@ namespace vk
initialLayout = vk::ImageLayout::ePreinitialized; initialLayout = vk::ImageLayout::ePreinitialized;
requirements = vk::MemoryPropertyFlagBits::eHostCoherent | vk::MemoryPropertyFlagBits::eHostVisible; requirements = vk::MemoryPropertyFlagBits::eHostCoherent | vk::MemoryPropertyFlagBits::eHostVisible;
} }
pImageData = vk::raii::su::make_unique<ImageData>( physicalDevice, imageData = ImageData( physicalDevice,
device, device,
format, format,
extent, extent,
imageTiling, imageTiling,
usageFlags | vk::ImageUsageFlagBits::eSampled, usageFlags | vk::ImageUsageFlagBits::eSampled,
initialLayout, initialLayout,
requirements, requirements,
vk::ImageAspectFlagBits::eColor ); vk::ImageAspectFlagBits::eColor );
} }
template <typename ImageGenerator> template <typename ImageGenerator>
@ -525,17 +528,17 @@ namespace vk
{ {
void * data = void * data =
needsStaging needsStaging
? pStagingBufferData->deviceMemory.mapMemory( 0, pStagingBufferData->buffer.getMemoryRequirements().size ) ? stagingBufferData.deviceMemory.mapMemory( 0, stagingBufferData.buffer.getMemoryRequirements().size )
: pImageData->deviceMemory.mapMemory( 0, pImageData->image.getMemoryRequirements().size ); : imageData.deviceMemory.mapMemory( 0, imageData.image.getMemoryRequirements().size );
imageGenerator( data, extent ); imageGenerator( data, extent );
needsStaging ? pStagingBufferData->deviceMemory.unmapMemory() : pImageData->deviceMemory.unmapMemory(); needsStaging ? stagingBufferData.deviceMemory.unmapMemory() : imageData.deviceMemory.unmapMemory();
if ( needsStaging ) if ( needsStaging )
{ {
// Since we're going to blit to the texture image, set its layout to eTransferDstOptimal // Since we're going to blit to the texture image, set its layout to eTransferDstOptimal
vk::raii::su::setImageLayout( commandBuffer, vk::raii::su::setImageLayout( commandBuffer,
*pImageData->image, *imageData.image,
pImageData->format, imageData.format,
vk::ImageLayout::eUndefined, vk::ImageLayout::eUndefined,
vk::ImageLayout::eTransferDstOptimal ); vk::ImageLayout::eTransferDstOptimal );
vk::BufferImageCopy copyRegion( 0, vk::BufferImageCopy copyRegion( 0,
@ -545,11 +548,11 @@ namespace vk
vk::Offset3D( 0, 0, 0 ), vk::Offset3D( 0, 0, 0 ),
vk::Extent3D( extent, 1 ) ); vk::Extent3D( extent, 1 ) );
commandBuffer.copyBufferToImage( commandBuffer.copyBufferToImage(
*pStagingBufferData->buffer, *pImageData->image, vk::ImageLayout::eTransferDstOptimal, copyRegion ); *stagingBufferData.buffer, *imageData.image, vk::ImageLayout::eTransferDstOptimal, copyRegion );
// Set the layout for the texture image from eTransferDstOptimal to SHADER_READ_ONLY // Set the layout for the texture image from eTransferDstOptimal to eShaderReadOnlyOptimal
vk::raii::su::setImageLayout( commandBuffer, vk::raii::su::setImageLayout( commandBuffer,
*pImageData->image, *imageData.image,
pImageData->format, imageData.format,
vk::ImageLayout::eTransferDstOptimal, vk::ImageLayout::eTransferDstOptimal,
vk::ImageLayout::eShaderReadOnlyOptimal ); vk::ImageLayout::eShaderReadOnlyOptimal );
} }
@ -557,19 +560,19 @@ namespace vk
{ {
// If we can use the linear tiled image as a texture, just do it // If we can use the linear tiled image as a texture, just do it
vk::raii::su::setImageLayout( commandBuffer, vk::raii::su::setImageLayout( commandBuffer,
*pImageData->image, *imageData.image,
pImageData->format, imageData.format,
vk::ImageLayout::ePreinitialized, vk::ImageLayout::ePreinitialized,
vk::ImageLayout::eShaderReadOnlyOptimal ); vk::ImageLayout::eShaderReadOnlyOptimal );
} }
} }
vk::Format format; vk::Format format;
vk::Extent2D extent; vk::Extent2D extent;
bool needsStaging; bool needsStaging;
std::unique_ptr<BufferData> pStagingBufferData; BufferData stagingBufferData = nullptr;
std::unique_ptr<ImageData> pImageData; ImageData imageData = nullptr;
vk::raii::Sampler sampler; vk::raii::Sampler sampler;
}; };
std::pair<uint32_t, uint32_t> std::pair<uint32_t, uint32_t>
@ -957,7 +960,7 @@ namespace vk
} }
vk::DescriptorImageInfo imageInfo( vk::DescriptorImageInfo imageInfo(
*textureData.sampler, **textureData.pImageData->pImageView, vk::ImageLayout::eShaderReadOnlyOptimal ); *textureData.sampler, *textureData.imageData.imageView, vk::ImageLayout::eShaderReadOnlyOptimal );
writeDescriptorSets.emplace_back( writeDescriptorSets.emplace_back(
*descriptorSet, dstBinding, 0, vk::DescriptorType::eCombinedImageSampler, imageInfo, nullptr, nullptr ); *descriptorSet, dstBinding, 0, vk::DescriptorType::eCombinedImageSampler, imageInfo, nullptr, nullptr );
@ -1002,8 +1005,7 @@ namespace vk
imageInfos.reserve( textureData.size() ); imageInfos.reserve( textureData.size() );
for ( auto const & thd : textureData ) for ( auto const & thd : textureData )
{ {
imageInfos.emplace_back( imageInfos.emplace_back( *thd.sampler, *thd.imageData.imageView, vk::ImageLayout::eShaderReadOnlyOptimal );
*thd.sampler, **thd.pImageData->pImageView, vk::ImageLayout::eShaderReadOnlyOptimal );
} }
writeDescriptorSets.emplace_back( *descriptorSet, writeDescriptorSets.emplace_back( *descriptorSet,
dstBinding, dstBinding,

View File

@ -576,11 +576,6 @@ By defining ```VULKAN_HPP_NO_SMART_HANDLE``` before including vulkan.hpp, the he
With C++20, the so-called spaceship-operator ```<=>``` is introduced. If that operator is supported, all the structs and classes in vulkan.hpp use the default implementation of it. As currently some implementations of this operator are very slow, and others seem to be incomplete, by defining ```VULKAN_HPP_NO_SPACESHIP_OPERATOR``` before including vulkan.hpp you can remove that operator from those structs and classes. With C++20, the so-called spaceship-operator ```<=>``` is introduced. If that operator is supported, all the structs and classes in vulkan.hpp use the default implementation of it. As currently some implementations of this operator are very slow, and others seem to be incomplete, by defining ```VULKAN_HPP_NO_SPACESHIP_OPERATOR``` before including vulkan.hpp you can remove that operator from those structs and classes.
#### VULKAN_HPP_RAII_ENABLE_DEFAULT_CONSTRUCTORS
By default, the vk::raii wrapper classes don't support default constructors. It would be a contradiction to the raii-principle.
For those who are desparate enough to ignore that restriction, you can define VULKAN_HPP_RAII_ENABLE_DEFAULT_CONSTRUCTORS. The only thing you can do with a default contructed vk::raii wrapper object is move-assigning another vk::raii wrapper object onto it. And you have to make sure that that happens before you use it.
#### VULKAN_HPP_STORAGE_API #### VULKAN_HPP_STORAGE_API
With this define you can specify whether the ```DispatchLoaderDynamic``` is imported or exported (see ```VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE```). If ```VULKAN_HPP_STORAGE_API``` is not defined externally, and ```VULKAN_HPP_STORAGE_SHARED``` is defined, depending on the ```VULKAN_HPP_STORAGE_SHARED_EXPORT``` being defined, ```VULKAN_HPP_STORAGE_API``` is either set to ```__declspec( dllexport )``` (for MSVC) / ```__attribute__( ( visibility( "default" ) ) )``` (for gcc or clang) or ```__declspec( dllimport )``` (for MSVC), respectively. For other compilers, you might specify the corresponding storage by defining ```VULKAN_HPP_STORAGE_API``` on your own. With this define you can specify whether the ```DispatchLoaderDynamic``` is imported or exported (see ```VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE```). If ```VULKAN_HPP_STORAGE_API``` is not defined externally, and ```VULKAN_HPP_STORAGE_SHARED``` is defined, depending on the ```VULKAN_HPP_STORAGE_SHARED_EXPORT``` being defined, ```VULKAN_HPP_STORAGE_API``` is either set to ```__declspec( dllexport )``` (for MSVC) / ```__attribute__( ( visibility( "default" ) ) )``` (for gcc or clang) or ```__declspec( dllimport )``` (for MSVC), respectively. For other compilers, you might specify the corresponding storage by defining ```VULKAN_HPP_STORAGE_API``` on your own.

View File

@ -575,13 +575,9 @@ ${contextMembers}
class InstanceDispatcher : public DispatchLoaderBase class InstanceDispatcher : public DispatchLoaderBase
{ {
public: public:
InstanceDispatcher( PFN_vkGetInstanceProcAddr getProcAddr ) InstanceDispatcher( PFN_vkGetInstanceProcAddr getProcAddr ) : vkGetInstanceProcAddr( getProcAddr ) {}
: vkGetInstanceProcAddr( getProcAddr )
{}
#if defined( VULKAN_HPP_RAII_ENABLE_DEFAULT_CONSTRUCTORS ) InstanceDispatcher( std::nullptr_t ) : DispatchLoaderBase( nullptr ) {}
InstanceDispatcher() = default;
#endif
void init( VkInstance instance ) void init( VkInstance instance )
{ {
@ -602,21 +598,17 @@ ${instanceMembers}
std::string deviceDispatcherTemplate = R"( std::string deviceDispatcherTemplate = R"(
class DeviceDispatcher : public DispatchLoaderBase class DeviceDispatcher : public DispatchLoaderBase
{ {
public: public:
DeviceDispatcher( PFN_vkGetDeviceProcAddr getProcAddr ) DeviceDispatcher( PFN_vkGetDeviceProcAddr getProcAddr ) : vkGetDeviceProcAddr( getProcAddr ) {}
: vkGetDeviceProcAddr( getProcAddr )
{}
#if defined( VULKAN_HPP_RAII_ENABLE_DEFAULT_CONSTRUCTORS ) DeviceDispatcher( std::nullptr_t ) : DispatchLoaderBase( nullptr ) {}
DeviceDispatcher() = default;
#endif
void init( VkDevice device ) void init( VkDevice device )
{ {
${deviceAssignments} ${deviceAssignments}
} }
public: public:
${deviceMembers} ${deviceMembers}
}; };
)"; )";
@ -7319,13 +7311,10 @@ ${enter} class ${handleType}
public: public:
${singularConstructors} ${singularConstructors}
${upgradeConstructor} ${upgradeConstructor}
${handleType}( std::nullptr_t ) {}
${destructor} ${destructor}
#if defined( VULKAN_HPP_RAII_ENABLE_DEFAULT_CONSTRUCTORS )
${handleType}() = default;
#else
${handleType}() = delete; ${handleType}() = delete;
#endif
${handleType}( ${handleType} const & ) = delete; ${handleType}( ${handleType} const & ) = delete;
${handleType}( ${handleType} && rhs ) VULKAN_HPP_NOEXCEPT ${handleType}( ${handleType} && rhs ) VULKAN_HPP_NOEXCEPT
: ${moveConstructorInitializerList} : ${moveConstructorInitializerList}
@ -7351,18 +7340,6 @@ ${getConstructorSuccessCode}
VULKAN_HPP_ASSERT( m_dispatcher${dispatcherAccess}getVkHeaderVersion() == VK_HEADER_VERSION ); VULKAN_HPP_ASSERT( m_dispatcher${dispatcherAccess}getVkHeaderVersion() == VK_HEADER_VERSION );
return ${getDispatcherReturn}m_dispatcher; return ${getDispatcherReturn}m_dispatcher;
} }
#if defined( VULKAN_HPP_RAII_ENABLE_DEFAULT_CONSTRUCTORS )
explicit operator bool() const VULKAN_HPP_NOEXCEPT
{
return m_${handleName}.operator bool();
}
bool operator!() const VULKAN_HPP_NOEXCEPT
{
return m_${handleName}.operator!();
}
#endif
${memberFunctionsDeclarations} ${memberFunctionsDeclarations}
private: private:
@ -7399,11 +7376,7 @@ ${enter} class ${handleType}s : public std::vector<VULKAN_HPP_NAMESPACE::VULKAN
public: public:
${arrayConstructors} ${arrayConstructors}
#if defined( VULKAN_HPP_RAII_ENABLE_DEFAULT_CONSTRUCTORS )
${handleType}s() = default;
#else
${handleType}s() = delete; ${handleType}s() = delete;
#endif
${handleType}s( ${handleType}s const & ) = delete; ${handleType}s( ${handleType}s const & ) = delete;
${handleType}s( ${handleType}s && rhs ) = default; ${handleType}s( ${handleType}s && rhs ) = default;
${handleType}s & operator=( ${handleType}s const & ) = delete; ${handleType}s & operator=( ${handleType}s const & ) = delete;
@ -10395,7 +10368,8 @@ std::tuple<std::string, std::string, std::string, std::string>
name = startLowerCase( stripPrefix( name, "p" ) ); name = startLowerCase( stripPrefix( name, "p" ) );
} }
memberVariables += "\n " + destructorParam.type.prefix + " " + destructorParam.type.type + " " + memberVariables += "\n " + destructorParam.type.prefix + " " + destructorParam.type.type + " " +
destructorParam.type.postfix + " m_" + name + ";"; destructorParam.type.postfix + " m_" + name +
( destructorParam.type.postfix.empty() ? "" : " = nullptr" ) + ";";
moveConstructorInitializerList += ", m_" + name + "( rhs.m_" + name + " )"; moveConstructorInitializerList += ", m_" + name + "( rhs.m_" + name + " )";
moveAssignmentInstructions += "\n m_" + name + " = rhs.m_" + name + ";"; moveAssignmentInstructions += "\n m_" + name + " = rhs.m_" + name + ";";
} }
@ -10417,20 +10391,23 @@ std::tuple<std::string, std::string, std::string, std::string>
if ( handle.first == "VkInstance" ) if ( handle.first == "VkInstance" )
{ {
memberVariables += "\n VULKAN_HPP_NAMESPACE::VULKAN_HPP_RAII_NAMESPACE::InstanceDispatcher m_dispatcher;"; memberVariables +=
"\n VULKAN_HPP_NAMESPACE::VULKAN_HPP_RAII_NAMESPACE::InstanceDispatcher m_dispatcher = nullptr;";
} }
else if ( handle.first == "VkDevice" ) else if ( handle.first == "VkDevice" )
{ {
memberVariables += "\n VULKAN_HPP_NAMESPACE::VULKAN_HPP_RAII_NAMESPACE::DeviceDispatcher m_dispatcher;"; memberVariables +=
"\n VULKAN_HPP_NAMESPACE::VULKAN_HPP_RAII_NAMESPACE::DeviceDispatcher m_dispatcher = nullptr;";
} }
else if ( handle.second.constructorIts.front()->second.params.front().type.type == "VkDevice" ) else if ( handle.second.constructorIts.front()->second.params.front().type.type == "VkDevice" )
{ {
memberVariables += "\n VULKAN_HPP_NAMESPACE::VULKAN_HPP_RAII_NAMESPACE::DeviceDispatcher const * m_dispatcher;"; memberVariables +=
"\n VULKAN_HPP_NAMESPACE::VULKAN_HPP_RAII_NAMESPACE::DeviceDispatcher const * m_dispatcher = nullptr;";
} }
else else
{ {
memberVariables += memberVariables +=
"\n VULKAN_HPP_NAMESPACE::VULKAN_HPP_RAII_NAMESPACE::InstanceDispatcher const * m_dispatcher;"; "\n VULKAN_HPP_NAMESPACE::VULKAN_HPP_RAII_NAMESPACE::InstanceDispatcher const * m_dispatcher = nullptr;";
} }
moveConstructorInitializerList += ", m_dispatcher( rhs.m_dispatcher )"; moveConstructorInitializerList += ", m_dispatcher( rhs.m_dispatcher )";
@ -16571,15 +16548,24 @@ int main( int argc, char ** argv )
static const std::string dispatchLoaderBase = R"( static const std::string dispatchLoaderBase = R"(
class DispatchLoaderBase class DispatchLoaderBase
{ {
#if !defined(NDEBUG)
public: public:
DispatchLoaderBase() = default;
DispatchLoaderBase( std::nullptr_t )
#if !defined( NDEBUG )
: m_valid( false )
#endif
{}
#if !defined( NDEBUG )
size_t getVkHeaderVersion() const size_t getVkHeaderVersion() const
{ {
VULKAN_HPP_ASSERT( m_valid );
return vkHeaderVersion; return vkHeaderVersion;
} }
private: private:
size_t vkHeaderVersion = VK_HEADER_VERSION; size_t vkHeaderVersion = VK_HEADER_VERSION;
bool m_valid = true;
#endif #endif
}; };
)"; )";

View File

@ -1385,15 +1385,24 @@ namespace VULKAN_HPP_NAMESPACE
class DispatchLoaderBase class DispatchLoaderBase
{ {
#if !defined( NDEBUG )
public: public:
DispatchLoaderBase() = default;
DispatchLoaderBase( std::nullptr_t )
#if !defined( NDEBUG )
: m_valid( false )
#endif
{}
#if !defined( NDEBUG )
size_t getVkHeaderVersion() const size_t getVkHeaderVersion() const
{ {
VULKAN_HPP_ASSERT( m_valid );
return vkHeaderVersion; return vkHeaderVersion;
} }
private: private:
size_t vkHeaderVersion = VK_HEADER_VERSION; size_t vkHeaderVersion = VK_HEADER_VERSION;
bool m_valid = true;
#endif #endif
}; };

File diff suppressed because it is too large Load Diff