mirror of
https://github.com/KhronosGroup/Vulkan-Hpp
synced 2024-11-09 14:10:07 +00:00
Introduce constructors on nullptr_t for the RAII handle classes.
This commit is contained in:
parent
9f86befbaa
commit
c3f32b8538
@ -37,7 +37,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
|
@ -49,12 +49,12 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
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;
|
||||
|
||||
/* VULKAN_HPP_KEY_START */
|
||||
|
@ -37,13 +37,13 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 64, 64 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
vk::raii::su::SwapChainData swapChainData( physicalDevice,
|
||||
device,
|
||||
*surfaceData.pSurface,
|
||||
surfaceData.surface,
|
||||
surfaceData.extent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment |
|
||||
vk::ImageUsageFlagBits::eTransferSrc,
|
||||
@ -59,7 +59,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
/* VULKAN_KEY_START */
|
||||
|
||||
std::array<vk::ImageView, 2> attachments;
|
||||
attachments[1] = **depthBufferData.pImageView;
|
||||
attachments[1] = *depthBufferData.imageView;
|
||||
|
||||
std::vector<vk::raii::Framebuffer> framebuffers;
|
||||
framebuffers.reserve( swapChainData.imageViews.size() );
|
||||
|
@ -48,7 +48,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 64, 64 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
@ -60,7 +60,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::raii::su::SwapChainData swapChainData( physicalDevice,
|
||||
device,
|
||||
*surfaceData.pSurface,
|
||||
surfaceData.surface,
|
||||
surfaceData.extent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment |
|
||||
vk::ImageUsageFlagBits::eTransferSrc,
|
||||
@ -74,7 +74,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::makeRenderPass( device, swapChainData.colorFormat, depthBufferData.format );
|
||||
|
||||
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 */
|
||||
|
||||
@ -104,7 +104,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::Result result;
|
||||
uint32_t 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( imageIndex < swapChainData.images.size() );
|
||||
|
||||
|
@ -51,12 +51,12 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
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::DescriptorSetLayout descriptorSetLayout = vk::raii::su::makeDescriptorSetLayout(
|
||||
|
@ -52,7 +52,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
@ -65,7 +65,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::raii::su::SwapChainData swapChainData( physicalDevice,
|
||||
device,
|
||||
*surfaceData.pSurface,
|
||||
surfaceData.surface,
|
||||
surfaceData.extent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment |
|
||||
vk::ImageUsageFlagBits::eTransferSrc,
|
||||
@ -85,7 +85,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } );
|
||||
|
||||
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 );
|
||||
|
||||
glslang::InitializeProcess();
|
||||
@ -96,7 +96,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
glslang::FinalizeProcess();
|
||||
|
||||
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(
|
||||
physicalDevice, device, sizeof( coloredCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
|
||||
@ -133,7 +133,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::Result result;
|
||||
uint32_t 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( 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 ) )
|
||||
;
|
||||
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex );
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
|
||||
result = presentQueue.presentKHR( presentInfoKHR );
|
||||
switch ( result )
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
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 ) )
|
||||
{
|
||||
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 =
|
||||
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface );
|
||||
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
|
||||
vk::raii::Device device = vk::raii::su::makeDevice(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
@ -57,7 +57,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::raii::su::SwapChainData swapChainData( physicalDevice,
|
||||
device,
|
||||
*surfaceData.pSurface,
|
||||
surfaceData.surface,
|
||||
surfaceData.extent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment |
|
||||
vk::ImageUsageFlagBits::eTransferSrc |
|
||||
@ -79,7 +79,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::Result result;
|
||||
uint32_t 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( imageIndex < swapChainData.images.size() );
|
||||
|
||||
@ -227,7 +227,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
;
|
||||
|
||||
/* 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 );
|
||||
switch ( result )
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
@ -56,7 +56,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::raii::su::SwapChainData swapChainData( physicalDevice,
|
||||
device,
|
||||
*surfaceData.pSurface,
|
||||
surfaceData.surface,
|
||||
surfaceData.extent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment |
|
||||
vk::ImageUsageFlagBits::eTransferSrc,
|
||||
@ -83,7 +83,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } );
|
||||
|
||||
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 );
|
||||
|
||||
glslang::InitializeProcess();
|
||||
@ -94,7 +94,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
glslang::FinalizeProcess();
|
||||
|
||||
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(
|
||||
physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
|
||||
@ -133,7 +133,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::Result result;
|
||||
uint32_t 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( 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 ) )
|
||||
;
|
||||
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex );
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
|
||||
result = presentQueue.presentKHR( presentInfoKHR );
|
||||
switch ( result )
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
@ -60,7 +60,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::raii::su::SwapChainData swapChainData( physicalDevice,
|
||||
device,
|
||||
*surfaceData.pSurface,
|
||||
surfaceData.surface,
|
||||
surfaceData.extent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment |
|
||||
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::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 );
|
||||
|
||||
glslang::InitializeProcess();
|
||||
@ -82,7 +82,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
glslang::FinalizeProcess();
|
||||
|
||||
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(
|
||||
physicalDevice, device, sizeof( coloredCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
|
||||
@ -160,7 +160,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::Result result;
|
||||
uint32_t 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( 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 ) )
|
||||
;
|
||||
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex );
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
|
||||
result = presentQueue.presentKHR( presentInfoKHR );
|
||||
switch ( result )
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
@ -68,7 +68,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::raii::su::SwapChainData swapChainData( physicalDevice,
|
||||
device,
|
||||
*surfaceData.pSurface,
|
||||
surfaceData.surface,
|
||||
surfaceData.extent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment |
|
||||
vk::ImageUsageFlagBits::eTransferSrc,
|
||||
@ -84,7 +84,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::copyToDevice( uniformBufferData.deviceMemory, mvpcMatrix );
|
||||
|
||||
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 );
|
||||
|
||||
glslang::InitializeProcess();
|
||||
@ -95,7 +95,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
glslang::FinalizeProcess();
|
||||
|
||||
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(
|
||||
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::DescriptorImageInfo imageInfo(
|
||||
*textureData.sampler, **textureData.pImageData->pImageView, vk::ImageLayout::eShaderReadOnlyOptimal );
|
||||
*textureData.sampler, *textureData.imageData.imageView, vk::ImageLayout::eShaderReadOnlyOptimal );
|
||||
std::array<vk::WriteDescriptorSet, 2> writeDescriptorSets = {
|
||||
vk::WriteDescriptorSet( *descriptorSet, 0, 0, vk::DescriptorType::eUniformBuffer, {}, bufferInfo ),
|
||||
vk::WriteDescriptorSet( *descriptorSet, 1, 0, vk::DescriptorType::eCombinedImageSampler, imageInfo )
|
||||
@ -164,7 +164,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::Result result;
|
||||
uint32_t 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( imageIndex < swapChainData.images.size() );
|
||||
|
||||
@ -194,7 +194,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
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 );
|
||||
switch ( result )
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 50, 50 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
@ -101,27 +101,27 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
// bind memory
|
||||
image.bindMemory( *imageMemory, 0 );
|
||||
|
||||
std::unique_ptr<vk::raii::Buffer> pTextureBuffer;
|
||||
std::unique_ptr<vk::raii::DeviceMemory> pTextureBufferMemory;
|
||||
vk::raii::Buffer textureBuffer = nullptr;
|
||||
vk::raii::DeviceMemory textureBufferMemory = nullptr;
|
||||
if ( needsStaging )
|
||||
{
|
||||
// Need a staging buffer to map and copy texture into
|
||||
vk::BufferCreateInfo bufferCreateInfo(
|
||||
{}, 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 =
|
||||
vk::su::findMemoryType( physicalDevice.getMemoryProperties(),
|
||||
memoryRequirements.memoryTypeBits,
|
||||
vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent );
|
||||
|
||||
// allocate memory
|
||||
memoryAllocateInfo = vk::MemoryAllocateInfo( memoryRequirements.size, memoryTypeIndex );
|
||||
pTextureBufferMemory = vk::raii::su::make_unique<vk::raii::DeviceMemory>( device, memoryAllocateInfo );
|
||||
memoryAllocateInfo = vk::MemoryAllocateInfo( memoryRequirements.size, memoryTypeIndex );
|
||||
textureBufferMemory = vk::raii::DeviceMemory( device, memoryAllocateInfo );
|
||||
|
||||
// bind memory
|
||||
pTextureBuffer->bindMemory( **pTextureBufferMemory, 0 );
|
||||
textureBuffer.bindMemory( *textureBufferMemory, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -129,7 +129,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
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() );
|
||||
|
||||
// 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() );
|
||||
if ( needsStaging )
|
||||
@ -161,7 +161,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::ImageSubresourceLayers( vk::ImageAspectFlagBits::eColor, 0, 0, 1 ),
|
||||
vk::Offset3D( 0, 0, 0 ),
|
||||
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
|
||||
vk::raii::su::setImageLayout(
|
||||
commandBuffer, *image, format, vk::ImageLayout::eTransferDstOptimal, vk::ImageLayout::eShaderReadOnlyOptimal );
|
||||
|
@ -88,7 +88,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
@ -101,7 +101,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::raii::su::SwapChainData swapChainData( physicalDevice,
|
||||
device,
|
||||
*surfaceData.pSurface,
|
||||
surfaceData.surface,
|
||||
surfaceData.extent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment |
|
||||
vk::ImageUsageFlagBits::eTransferSrc,
|
||||
@ -245,7 +245,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::Result result;
|
||||
uint32_t 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( imageIndex < swapChainData.images.size() );
|
||||
|
||||
@ -275,7 +275,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
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 );
|
||||
switch ( result )
|
||||
{
|
||||
|
@ -112,7 +112,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
@ -125,7 +125,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::raii::su::SwapChainData swapChainData( physicalDevice,
|
||||
device,
|
||||
*surfaceData.pSurface,
|
||||
surfaceData.surface,
|
||||
surfaceData.extent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment |
|
||||
vk::ImageUsageFlagBits::eTransferSrc,
|
||||
@ -146,7 +146,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::copyToDevice( uniformBufferData.deviceMemory, mvpcMatrix );
|
||||
|
||||
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 );
|
||||
|
||||
glslang::InitializeProcess();
|
||||
@ -157,7 +157,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
glslang::FinalizeProcess();
|
||||
|
||||
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(
|
||||
physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
|
||||
@ -198,7 +198,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
// Populate with info about our uniform buffer
|
||||
vk::DescriptorBufferInfo uniformBufferInfo( *uniformBufferData.buffer, 0, sizeof( glm::mat4x4 ) );
|
||||
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 = {
|
||||
{ vk::WriteDescriptorSet( *descriptorSets[0], 0, 0, vk::DescriptorType::eUniformBuffer, {}, uniformBufferInfo ),
|
||||
vk::WriteDescriptorSet(
|
||||
@ -228,7 +228,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::Result result;
|
||||
uint32_t 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( 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 ) )
|
||||
;
|
||||
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex );
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
|
||||
result = presentQueue.presentKHR( presentInfoKHR );
|
||||
switch ( result )
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
@ -63,7 +63,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::raii::su::SwapChainData swapChainData( physicalDevice,
|
||||
device,
|
||||
*surfaceData.pSurface,
|
||||
surfaceData.surface,
|
||||
surfaceData.extent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment |
|
||||
vk::ImageUsageFlagBits::eTransferSrc,
|
||||
@ -83,7 +83,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } );
|
||||
|
||||
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 );
|
||||
|
||||
glslang::InitializeProcess();
|
||||
@ -94,7 +94,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
glslang::FinalizeProcess();
|
||||
|
||||
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(
|
||||
physicalDevice, device, sizeof( coloredCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
|
||||
@ -132,7 +132,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::Result result;
|
||||
uint32_t 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( 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 ) )
|
||||
;
|
||||
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex );
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
|
||||
result = presentQueue.presentKHR( presentInfoKHR );
|
||||
switch ( result )
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
@ -97,7 +97,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::raii::su::SwapChainData swapChainData( physicalDevice,
|
||||
device,
|
||||
*surfaceData.pSurface,
|
||||
surfaceData.surface,
|
||||
surfaceData.extent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment |
|
||||
vk::ImageUsageFlagBits::eTransferSrc,
|
||||
@ -124,7 +124,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } );
|
||||
|
||||
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 );
|
||||
|
||||
glslang::InitializeProcess();
|
||||
@ -135,7 +135,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
glslang::FinalizeProcess();
|
||||
|
||||
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(
|
||||
physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
|
||||
@ -316,7 +316,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::Result result;
|
||||
uint32_t 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( 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 ) )
|
||||
;
|
||||
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex );
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
|
||||
result = presentQueue.presentKHR( presentInfoKHR );
|
||||
switch ( result )
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
@ -64,7 +64,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::raii::su::SwapChainData swapChainData( physicalDevice,
|
||||
device,
|
||||
*surfaceData.pSurface,
|
||||
surfaceData.surface,
|
||||
surfaceData.extent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment |
|
||||
vk::ImageUsageFlagBits::eTransferSrc,
|
||||
@ -91,7 +91,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } );
|
||||
|
||||
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 );
|
||||
|
||||
glslang::InitializeProcess();
|
||||
@ -102,7 +102,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
glslang::FinalizeProcess();
|
||||
|
||||
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(
|
||||
physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
|
||||
@ -252,7 +252,7 @@ void main()
|
||||
vk::Result result;
|
||||
uint32_t 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( imageIndex < swapChainData.images.size() );
|
||||
|
||||
@ -290,7 +290,7 @@ void main()
|
||||
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 );
|
||||
switch ( result )
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
@ -106,7 +106,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::raii::su::SwapChainData swapChainData( physicalDevice,
|
||||
device,
|
||||
*surfaceData.pSurface,
|
||||
surfaceData.surface,
|
||||
surfaceData.extent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment |
|
||||
vk::ImageUsageFlagBits::eTransferSrc,
|
||||
@ -122,7 +122,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::copyToDevice( uniformBufferData.deviceMemory, mvpcMatrix );
|
||||
|
||||
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 );
|
||||
|
||||
glslang::InitializeProcess();
|
||||
@ -133,7 +133,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
glslang::FinalizeProcess();
|
||||
|
||||
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(
|
||||
physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
|
||||
@ -201,7 +201,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::Result result;
|
||||
uint32_t 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( 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 ) )
|
||||
;
|
||||
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex );
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
|
||||
result = presentQueue.presentKHR( presentInfoKHR );
|
||||
switch ( result )
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
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( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, deviceExtensions );
|
||||
|
||||
@ -91,7 +91,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::raii::su::SwapChainData swapChainData( physicalDevice,
|
||||
device,
|
||||
*surfaceData.pSurface,
|
||||
surfaceData.surface,
|
||||
surfaceData.extent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment |
|
||||
vk::ImageUsageFlagBits::eTransferSrc,
|
||||
@ -121,7 +121,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } );
|
||||
|
||||
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 );
|
||||
|
||||
@ -133,7 +133,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
glslang::FinalizeProcess();
|
||||
|
||||
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(
|
||||
physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
|
||||
@ -160,7 +160,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::Result result;
|
||||
uint32_t 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( imageIndex < swapChainData.images.size() );
|
||||
|
||||
@ -174,7 +174,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::DescriptorBufferInfo bufferInfo( *uniformBufferData.buffer, 0, sizeof( glm::mat4x4 ) );
|
||||
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( {}, 0, 0, vk::DescriptorType::eUniformBuffer, {}, bufferInfo ),
|
||||
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 ) )
|
||||
;
|
||||
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex );
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
|
||||
result = presentQueue.presentKHR( presentInfoKHR );
|
||||
switch ( result )
|
||||
{
|
||||
|
@ -81,18 +81,18 @@ static_assert( sizeof( GeometryInstanceData ) == 64, "GeometryInstanceData struc
|
||||
|
||||
struct AccelerationStructureData
|
||||
{
|
||||
std::shared_ptr<vk::raii::AccelerationStructureNV> pAcclerationStructure;
|
||||
std::unique_ptr<vk::raii::su::BufferData> pScratchBufferData;
|
||||
std::unique_ptr<vk::raii::su::BufferData> pResultBufferData;
|
||||
std::unique_ptr<vk::raii::su::BufferData> pInstanceBufferData;
|
||||
vk::raii::AccelerationStructureNV acclerationStructure = nullptr;
|
||||
vk::raii::su::BufferData scratchBufferData = nullptr;
|
||||
vk::raii::su::BufferData resultBufferData = nullptr;
|
||||
vk::raii::su::BufferData instanceBufferData = nullptr;
|
||||
};
|
||||
|
||||
AccelerationStructureData createAccelerationStructureData(
|
||||
vk::raii::PhysicalDevice const & physicalDevice,
|
||||
vk::raii::Device const & device,
|
||||
vk::raii::CommandBuffer const & commandBuffer,
|
||||
std::vector<std::pair<std::shared_ptr<vk::raii::AccelerationStructureNV>, glm::mat4x4>> const & instances,
|
||||
std::vector<vk::GeometryNV> const & geometries )
|
||||
vk::raii::PhysicalDevice const & physicalDevice,
|
||||
vk::raii::Device const & device,
|
||||
vk::raii::CommandBuffer const & commandBuffer,
|
||||
std::vector<std::pair<vk::raii::AccelerationStructureNV &, glm::mat4x4 &>> const & instances,
|
||||
std::vector<vk::GeometryNV> const & geometries )
|
||||
{
|
||||
assert( instances.empty() ^ geometries.empty() );
|
||||
|
||||
@ -103,51 +103,48 @@ AccelerationStructureData createAccelerationStructureData(
|
||||
vk::AccelerationStructureInfoNV accelerationStructureInfo(
|
||||
accelerationStructureType, {}, vk::su::checked_cast<uint32_t>( instances.size() ), geometries );
|
||||
vk::AccelerationStructureCreateInfoNV accelerationStructureCreateInfoNV( 0, accelerationStructureInfo );
|
||||
accelerationStructureData.pAcclerationStructure =
|
||||
std::make_shared<vk::raii::AccelerationStructureNV>( device, accelerationStructureCreateInfoNV );
|
||||
accelerationStructureData.acclerationStructure =
|
||||
vk::raii::AccelerationStructureNV( device, accelerationStructureCreateInfoNV );
|
||||
|
||||
vk::AccelerationStructureMemoryRequirementsInfoNV objectRequirements(
|
||||
vk::AccelerationStructureMemoryRequirementsTypeNV::eObject, **accelerationStructureData.pAcclerationStructure );
|
||||
vk::AccelerationStructureMemoryRequirementsTypeNV::eObject, *accelerationStructureData.acclerationStructure );
|
||||
vk::DeviceSize resultSizeInBytes =
|
||||
device.getAccelerationStructureMemoryRequirementsNV( objectRequirements ).memoryRequirements.size;
|
||||
assert( 0 < resultSizeInBytes );
|
||||
accelerationStructureData.pResultBufferData =
|
||||
vk::raii::su::make_unique<vk::raii::su::BufferData>( physicalDevice,
|
||||
device,
|
||||
resultSizeInBytes,
|
||||
vk::BufferUsageFlagBits::eRayTracingNV,
|
||||
vk::MemoryPropertyFlagBits::eDeviceLocal );
|
||||
accelerationStructureData.resultBufferData = vk::raii::su::BufferData( physicalDevice,
|
||||
device,
|
||||
resultSizeInBytes,
|
||||
vk::BufferUsageFlagBits::eRayTracingNV,
|
||||
vk::MemoryPropertyFlagBits::eDeviceLocal );
|
||||
|
||||
vk::AccelerationStructureMemoryRequirementsInfoNV buildScratchRequirements(
|
||||
vk::AccelerationStructureMemoryRequirementsTypeNV::eBuildScratch,
|
||||
**accelerationStructureData.pAcclerationStructure );
|
||||
vk::AccelerationStructureMemoryRequirementsTypeNV::eBuildScratch, *accelerationStructureData.acclerationStructure );
|
||||
vk::AccelerationStructureMemoryRequirementsInfoNV updateScratchRequirements(
|
||||
vk::AccelerationStructureMemoryRequirementsTypeNV::eUpdateScratch,
|
||||
**accelerationStructureData.pAcclerationStructure );
|
||||
*accelerationStructureData.acclerationStructure );
|
||||
vk::DeviceSize scratchSizeInBytes = std::max(
|
||||
device.getAccelerationStructureMemoryRequirementsNV( buildScratchRequirements ).memoryRequirements.size,
|
||||
device.getAccelerationStructureMemoryRequirementsNV( updateScratchRequirements ).memoryRequirements.size );
|
||||
assert( 0 < scratchSizeInBytes );
|
||||
|
||||
accelerationStructureData.pScratchBufferData =
|
||||
vk::raii::su::make_unique<vk::raii::su::BufferData>( physicalDevice,
|
||||
device,
|
||||
scratchSizeInBytes,
|
||||
vk::BufferUsageFlagBits::eRayTracingNV,
|
||||
vk::MemoryPropertyFlagBits::eDeviceLocal );
|
||||
accelerationStructureData.scratchBufferData = vk::raii::su::BufferData( physicalDevice,
|
||||
device,
|
||||
scratchSizeInBytes,
|
||||
vk::BufferUsageFlagBits::eRayTracingNV,
|
||||
vk::MemoryPropertyFlagBits::eDeviceLocal );
|
||||
|
||||
if ( !instances.empty() )
|
||||
{
|
||||
accelerationStructureData.pInstanceBufferData =
|
||||
vk::raii::su::make_unique<vk::raii::su::BufferData>( physicalDevice,
|
||||
device,
|
||||
instances.size() * sizeof( GeometryInstanceData ),
|
||||
vk::BufferUsageFlagBits::eRayTracingNV );
|
||||
accelerationStructureData.instanceBufferData =
|
||||
vk::raii::su::BufferData( physicalDevice,
|
||||
device,
|
||||
instances.size() * sizeof( GeometryInstanceData ),
|
||||
vk::BufferUsageFlagBits::eRayTracingNV );
|
||||
|
||||
std::vector<GeometryInstanceData> geometryInstanceData;
|
||||
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
|
||||
// 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 ),
|
||||
accelerationStructureHandle );
|
||||
}
|
||||
accelerationStructureData.pInstanceBufferData->upload( geometryInstanceData );
|
||||
accelerationStructureData.instanceBufferData.upload( geometryInstanceData );
|
||||
}
|
||||
|
||||
device.bindAccelerationStructureMemoryNV( vk::BindAccelerationStructureMemoryInfoNV(
|
||||
**accelerationStructureData.pAcclerationStructure, *accelerationStructureData.pResultBufferData->deviceMemory ) );
|
||||
*accelerationStructureData.acclerationStructure, *accelerationStructureData.resultBufferData.deviceMemory ) );
|
||||
|
||||
vk::Buffer instanceData;
|
||||
if ( accelerationStructureData.pInstanceBufferData )
|
||||
if ( *accelerationStructureData.instanceBufferData.buffer )
|
||||
{
|
||||
instanceData = *accelerationStructureData.pInstanceBufferData->buffer;
|
||||
instanceData = *accelerationStructureData.instanceBufferData.buffer;
|
||||
}
|
||||
vk::AccelerationStructureInfoNV accelerationStructureInfoNV(
|
||||
accelerationStructureType, {}, vk::su::checked_cast<uint32_t>( instances.size() ), geometries );
|
||||
@ -178,9 +175,9 @@ AccelerationStructureData createAccelerationStructureData(
|
||||
instanceData,
|
||||
0,
|
||||
false,
|
||||
**accelerationStructureData.pAcclerationStructure,
|
||||
*accelerationStructureData.acclerationStructure,
|
||||
nullptr,
|
||||
*accelerationStructureData.pScratchBufferData->buffer,
|
||||
*accelerationStructureData.scratchBufferData.buffer,
|
||||
0 );
|
||||
|
||||
vk::MemoryBarrier memoryBarrier(
|
||||
@ -788,7 +785,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::raii::su::DepthBufferData depthBufferData( physicalDevice, device, depthFormat, windowExtent );
|
||||
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;
|
||||
|
||||
@ -962,12 +959,12 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
{},
|
||||
{ vk::GeometryNV( vk::GeometryTypeNV::eTriangles, geometryDataNV ) } );
|
||||
|
||||
topLevelAS =
|
||||
createAccelerationStructureData( physicalDevice,
|
||||
device,
|
||||
commandBuffer,
|
||||
{ std::make_pair( bottomLevelAS.pAcclerationStructure, transform ) },
|
||||
std::vector<vk::GeometryNV>() );
|
||||
topLevelAS = createAccelerationStructureData(
|
||||
physicalDevice,
|
||||
device,
|
||||
commandBuffer,
|
||||
{ std::make_pair( std::ref( bottomLevelAS.acclerationStructure ), std::ref( transform ) ) },
|
||||
std::vector<vk::GeometryNV>() );
|
||||
} );
|
||||
|
||||
// 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
|
||||
vk::WriteDescriptorSetAccelerationStructureNV writeDescriptorSetAcceleration( 1,
|
||||
&**topLevelAS.pAcclerationStructure );
|
||||
&*topLevelAS.acclerationStructure );
|
||||
std::vector<vk::WriteDescriptorSet> accelerationDescriptionSets;
|
||||
for ( size_t i = 0; i < rayTracingDescriptorSets.size(); i++ )
|
||||
{
|
||||
@ -1211,7 +1208,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
surface,
|
||||
windowExtent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eStorage,
|
||||
&*swapChainData.pSwapChain,
|
||||
&swapChainData.swapChain,
|
||||
graphicsAndPresentQueueFamilyIndex.first,
|
||||
graphicsAndPresentQueueFamilyIndex.second );
|
||||
depthBufferData = vk::raii::su::DepthBufferData(
|
||||
@ -1229,7 +1226,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
} );
|
||||
|
||||
framebuffers = vk::raii::su::makeFramebuffers(
|
||||
device, renderPass, swapChainData.imageViews, &*depthBufferData.pImageView, windowExtent );
|
||||
device, renderPass, swapChainData.imageViews, &depthBufferData.imageView, windowExtent );
|
||||
}
|
||||
|
||||
// update the uniformBufferObject
|
||||
@ -1245,7 +1242,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
// frame begin
|
||||
vk::Result result;
|
||||
uint32_t backBufferIndex;
|
||||
std::tie( result, backBufferIndex ) = swapChainData.pSwapChain->acquireNextImage(
|
||||
std::tie( result, backBufferIndex ) = swapChainData.swapChain.acquireNextImage(
|
||||
vk::su::FenceTimeout, *perFrameData[frameIndex].presentCompleteSemaphore );
|
||||
assert( result == vk::Result::eSuccess );
|
||||
|
||||
@ -1337,7 +1334,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
&*perFrameData[frameIndex].renderCompleteSemaphore );
|
||||
graphicsQueue.submit( submitInfo, *perFrameData[frameIndex].fence );
|
||||
vk::PresentInfoKHR presentInfoKHR(
|
||||
*perFrameData[frameIndex].renderCompleteSemaphore, **swapChainData.pSwapChain, backBufferIndex );
|
||||
*perFrameData[frameIndex].renderCompleteSemaphore, *swapChainData.swapChain, backBufferIndex );
|
||||
result = presentQueue.presentKHR( presentInfoKHR );
|
||||
switch ( result )
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
@ -66,7 +66,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::raii::su::SwapChainData swapChainData( physicalDevice,
|
||||
device,
|
||||
*surfaceData.pSurface,
|
||||
surfaceData.surface,
|
||||
surfaceData.extent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment |
|
||||
vk::ImageUsageFlagBits::eTransferSrc,
|
||||
@ -88,7 +88,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } );
|
||||
|
||||
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,
|
||||
@ -103,7 +103,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
glslang::FinalizeProcess();
|
||||
|
||||
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(
|
||||
physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
|
||||
@ -162,7 +162,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::Result result;
|
||||
uint32_t 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( 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 ) )
|
||||
;
|
||||
|
||||
result = presentQueue.presentKHR( vk::PresentInfoKHR( {}, **swapChainData.pSwapChain, imageIndex, {} ) );
|
||||
result = presentQueue.presentKHR( vk::PresentInfoKHR( {}, *swapChainData.swapChain, imageIndex, {} ) );
|
||||
switch ( result )
|
||||
{
|
||||
case vk::Result::eSuccess: break;
|
||||
|
@ -81,7 +81,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
@ -94,7 +94,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::raii::su::SwapChainData swapChainData( physicalDevice,
|
||||
device,
|
||||
*surfaceData.pSurface,
|
||||
surfaceData.surface,
|
||||
surfaceData.extent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment |
|
||||
vk::ImageUsageFlagBits::eTransferSrc,
|
||||
@ -110,7 +110,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::copyToDevice( uniformBufferData.deviceMemory, mvpcMatrix );
|
||||
|
||||
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 );
|
||||
|
||||
glslang::InitializeProcess();
|
||||
@ -121,7 +121,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
glslang::FinalizeProcess();
|
||||
|
||||
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(
|
||||
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::DescriptorImageInfo imageInfo(
|
||||
*textureData.sampler, **textureData.pImageData->pImageView, vk::ImageLayout::eShaderReadOnlyOptimal );
|
||||
*textureData.sampler, *textureData.imageData.imageView, vk::ImageLayout::eShaderReadOnlyOptimal );
|
||||
vk::DescriptorImageInfo samplerInfo( *sampler, {}, {} );
|
||||
std::array<vk::WriteDescriptorSet, 3> descriptorWrites = {
|
||||
{ vk::WriteDescriptorSet( *descriptorSet, 0, 0, vk::DescriptorType::eUniformBuffer, {}, bufferInfo ),
|
||||
@ -218,7 +218,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::Result result;
|
||||
uint32_t 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( 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 ) )
|
||||
;
|
||||
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex );
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
|
||||
result = presentQueue.presentKHR( presentInfoKHR );
|
||||
switch ( result )
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::DisplayNativeHdrSurfaceCapabilitiesAMD,
|
||||
vk::SharedPresentSurfaceCapabilitiesKHR,
|
||||
vk::SurfaceCapabilitiesFullScreenExclusiveEXT,
|
||||
vk::SurfaceProtectedCapabilitiesKHR>( { **surfaceData.pSurface } );
|
||||
vk::SurfaceProtectedCapabilitiesKHR>( { *surfaceData.surface } );
|
||||
|
||||
vk::SurfaceCapabilitiesKHR const & surfaceCapabilities =
|
||||
surfaceCapabilities2.get<vk::SurfaceCapabilities2KHR>().surfaceCapabilities;
|
||||
@ -153,7 +153,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
else
|
||||
{
|
||||
vk::SurfaceCapabilitiesKHR surfaceCapabilities =
|
||||
physicalDevices[i].getSurfaceCapabilitiesKHR( **surfaceData.pSurface );
|
||||
physicalDevices[i].getSurfaceCapabilitiesKHR( *surfaceData.surface );
|
||||
cout( surfaceCapabilities );
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
{
|
||||
std::cout << "PhysicalDevice " << i << "\n";
|
||||
std::vector<vk::SurfaceFormatKHR> surfaceFormats =
|
||||
physicalDevices[i].getSurfaceFormatsKHR( **surfaceData.pSurface );
|
||||
physicalDevices[i].getSurfaceFormatsKHR( *surfaceData.surface );
|
||||
for ( size_t j = 0; j < surfaceFormats.size(); j++ )
|
||||
{
|
||||
std::cout << "\tFormat " << j << "\n";
|
||||
|
@ -43,7 +43,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
@ -56,7 +56,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::raii::su::SwapChainData swapChainData( physicalDevice,
|
||||
device,
|
||||
*surfaceData.pSurface,
|
||||
surfaceData.surface,
|
||||
surfaceData.extent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment |
|
||||
vk::ImageUsageFlagBits::eTransferSrc,
|
||||
@ -83,7 +83,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } );
|
||||
|
||||
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 );
|
||||
|
||||
glslang::InitializeProcess();
|
||||
@ -94,7 +94,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
glslang::FinalizeProcess();
|
||||
|
||||
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(
|
||||
physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
|
||||
@ -131,7 +131,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::Result result;
|
||||
uint32_t 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( 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 ) )
|
||||
;
|
||||
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex );
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
|
||||
result = presentQueue.presentKHR( presentInfoKHR );
|
||||
switch ( result )
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
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(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
@ -98,7 +98,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
vk::raii::su::SwapChainData swapChainData( physicalDevice,
|
||||
device,
|
||||
*surfaceData.pSurface,
|
||||
surfaceData.surface,
|
||||
surfaceData.extent,
|
||||
vk::ImageUsageFlagBits::eColorAttachment |
|
||||
vk::ImageUsageFlagBits::eTransferSrc,
|
||||
@ -118,7 +118,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::raii::PipelineLayout pipelineLayout( device, { {}, *descriptorSetLayout } );
|
||||
|
||||
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 );
|
||||
|
||||
glslang::InitializeProcess();
|
||||
@ -163,7 +163,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::Result result;
|
||||
uint32_t 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( 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 ) )
|
||||
;
|
||||
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, **swapChainData.pSwapChain, imageIndex );
|
||||
vk::PresentInfoKHR presentInfoKHR( nullptr, *swapChainData.swapChain, imageIndex );
|
||||
result = presentQueue.presentKHR( presentInfoKHR );
|
||||
switch ( result )
|
||||
{
|
||||
|
@ -217,6 +217,8 @@ namespace vk
|
||||
buffer.bindMemory( *deviceMemory, 0 );
|
||||
}
|
||||
|
||||
BufferData( std::nullptr_t ) {}
|
||||
|
||||
template <typename DataType>
|
||||
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 !
|
||||
vk::raii::Buffer buffer;
|
||||
vk::raii::DeviceMemory deviceMemory;
|
||||
vk::raii::Buffer buffer = nullptr;
|
||||
vk::raii::DeviceMemory deviceMemory = nullptr;
|
||||
#if !defined( NDEBUG )
|
||||
private:
|
||||
vk::DeviceSize m_size;
|
||||
@ -309,7 +311,7 @@ namespace vk
|
||||
device, physicalDevice.getMemoryProperties(), image.getMemoryRequirements(), memoryProperties ) )
|
||||
{
|
||||
image.bindMemory( *deviceMemory, 0 );
|
||||
pImageView = vk::raii::su::make_unique<vk::raii::ImageView>(
|
||||
imageView = vk::raii::ImageView(
|
||||
device,
|
||||
vk::ImageViewCreateInfo(
|
||||
{},
|
||||
@ -320,10 +322,12 @@ namespace vk
|
||||
{ aspectMask, 0, 1, 0, 1 } ) );
|
||||
}
|
||||
|
||||
vk::Format format;
|
||||
vk::raii::Image image;
|
||||
vk::raii::DeviceMemory deviceMemory;
|
||||
std::unique_ptr<vk::raii::ImageView> pImageView;
|
||||
ImageData( std::nullptr_t ) {}
|
||||
|
||||
vk::Format format;
|
||||
vk::raii::Image image = nullptr;
|
||||
vk::raii::DeviceMemory deviceMemory = nullptr;
|
||||
vk::raii::ImageView imageView = nullptr;
|
||||
};
|
||||
|
||||
struct DepthBufferData : public ImageData
|
||||
@ -354,12 +358,12 @@ namespace vk
|
||||
glfwCreateWindowSurface( static_cast<VkInstance>( *instance ), window.handle, nullptr, &_surface );
|
||||
if ( err != VK_SUCCESS )
|
||||
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::su::WindowData window;
|
||||
std::unique_ptr<vk::raii::SurfaceKHR> pSurface;
|
||||
vk::Extent2D extent;
|
||||
vk::su::WindowData window;
|
||||
vk::raii::SurfaceKHR surface = nullptr;
|
||||
};
|
||||
|
||||
struct SwapChainData
|
||||
@ -431,9 +435,9 @@ namespace vk
|
||||
swapChainCreateInfo.queueFamilyIndexCount = 2;
|
||||
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() );
|
||||
vk::ComponentMapping componentMapping(
|
||||
@ -451,10 +455,10 @@ namespace vk
|
||||
}
|
||||
}
|
||||
|
||||
vk::Format colorFormat;
|
||||
std::unique_ptr<vk::raii::SwapchainKHR> pSwapChain;
|
||||
std::vector<VkImage> images;
|
||||
std::vector<vk::raii::ImageView> imageViews;
|
||||
vk::Format colorFormat;
|
||||
vk::raii::SwapchainKHR swapChain = nullptr;
|
||||
std::vector<VkImage> images;
|
||||
std::vector<vk::raii::ImageView> imageViews;
|
||||
};
|
||||
|
||||
struct TextureData
|
||||
@ -484,7 +488,6 @@ namespace vk
|
||||
0.0f,
|
||||
0.0f,
|
||||
vk::BorderColor::eFloatOpaqueBlack } )
|
||||
|
||||
{
|
||||
vk::FormatProperties formatProperties = physicalDevice.getFormatProperties( format );
|
||||
|
||||
@ -497,7 +500,7 @@ namespace vk
|
||||
if ( needsStaging )
|
||||
{
|
||||
assert( ( formatProperties.optimalTilingFeatures & formatFeatureFlags ) == formatFeatureFlags );
|
||||
pStagingBufferData = vk::raii::su::make_unique<BufferData>(
|
||||
stagingBufferData = BufferData(
|
||||
physicalDevice, device, extent.width * extent.height * 4, vk::BufferUsageFlagBits::eTransferSrc );
|
||||
imageTiling = vk::ImageTiling::eOptimal;
|
||||
usageFlags |= vk::ImageUsageFlagBits::eTransferDst;
|
||||
@ -509,15 +512,15 @@ namespace vk
|
||||
initialLayout = vk::ImageLayout::ePreinitialized;
|
||||
requirements = vk::MemoryPropertyFlagBits::eHostCoherent | vk::MemoryPropertyFlagBits::eHostVisible;
|
||||
}
|
||||
pImageData = vk::raii::su::make_unique<ImageData>( physicalDevice,
|
||||
device,
|
||||
format,
|
||||
extent,
|
||||
imageTiling,
|
||||
usageFlags | vk::ImageUsageFlagBits::eSampled,
|
||||
initialLayout,
|
||||
requirements,
|
||||
vk::ImageAspectFlagBits::eColor );
|
||||
imageData = ImageData( physicalDevice,
|
||||
device,
|
||||
format,
|
||||
extent,
|
||||
imageTiling,
|
||||
usageFlags | vk::ImageUsageFlagBits::eSampled,
|
||||
initialLayout,
|
||||
requirements,
|
||||
vk::ImageAspectFlagBits::eColor );
|
||||
}
|
||||
|
||||
template <typename ImageGenerator>
|
||||
@ -525,17 +528,17 @@ namespace vk
|
||||
{
|
||||
void * data =
|
||||
needsStaging
|
||||
? pStagingBufferData->deviceMemory.mapMemory( 0, pStagingBufferData->buffer.getMemoryRequirements().size )
|
||||
: pImageData->deviceMemory.mapMemory( 0, pImageData->image.getMemoryRequirements().size );
|
||||
? stagingBufferData.deviceMemory.mapMemory( 0, stagingBufferData.buffer.getMemoryRequirements().size )
|
||||
: imageData.deviceMemory.mapMemory( 0, imageData.image.getMemoryRequirements().size );
|
||||
imageGenerator( data, extent );
|
||||
needsStaging ? pStagingBufferData->deviceMemory.unmapMemory() : pImageData->deviceMemory.unmapMemory();
|
||||
needsStaging ? stagingBufferData.deviceMemory.unmapMemory() : imageData.deviceMemory.unmapMemory();
|
||||
|
||||
if ( needsStaging )
|
||||
{
|
||||
// Since we're going to blit to the texture image, set its layout to eTransferDstOptimal
|
||||
vk::raii::su::setImageLayout( commandBuffer,
|
||||
*pImageData->image,
|
||||
pImageData->format,
|
||||
*imageData.image,
|
||||
imageData.format,
|
||||
vk::ImageLayout::eUndefined,
|
||||
vk::ImageLayout::eTransferDstOptimal );
|
||||
vk::BufferImageCopy copyRegion( 0,
|
||||
@ -545,11 +548,11 @@ namespace vk
|
||||
vk::Offset3D( 0, 0, 0 ),
|
||||
vk::Extent3D( extent, 1 ) );
|
||||
commandBuffer.copyBufferToImage(
|
||||
*pStagingBufferData->buffer, *pImageData->image, vk::ImageLayout::eTransferDstOptimal, copyRegion );
|
||||
// Set the layout for the texture image from eTransferDstOptimal to SHADER_READ_ONLY
|
||||
*stagingBufferData.buffer, *imageData.image, vk::ImageLayout::eTransferDstOptimal, copyRegion );
|
||||
// Set the layout for the texture image from eTransferDstOptimal to eShaderReadOnlyOptimal
|
||||
vk::raii::su::setImageLayout( commandBuffer,
|
||||
*pImageData->image,
|
||||
pImageData->format,
|
||||
*imageData.image,
|
||||
imageData.format,
|
||||
vk::ImageLayout::eTransferDstOptimal,
|
||||
vk::ImageLayout::eShaderReadOnlyOptimal );
|
||||
}
|
||||
@ -557,19 +560,19 @@ namespace vk
|
||||
{
|
||||
// If we can use the linear tiled image as a texture, just do it
|
||||
vk::raii::su::setImageLayout( commandBuffer,
|
||||
*pImageData->image,
|
||||
pImageData->format,
|
||||
*imageData.image,
|
||||
imageData.format,
|
||||
vk::ImageLayout::ePreinitialized,
|
||||
vk::ImageLayout::eShaderReadOnlyOptimal );
|
||||
}
|
||||
}
|
||||
|
||||
vk::Format format;
|
||||
vk::Extent2D extent;
|
||||
bool needsStaging;
|
||||
std::unique_ptr<BufferData> pStagingBufferData;
|
||||
std::unique_ptr<ImageData> pImageData;
|
||||
vk::raii::Sampler sampler;
|
||||
vk::Format format;
|
||||
vk::Extent2D extent;
|
||||
bool needsStaging;
|
||||
BufferData stagingBufferData = nullptr;
|
||||
ImageData imageData = nullptr;
|
||||
vk::raii::Sampler sampler;
|
||||
};
|
||||
|
||||
std::pair<uint32_t, uint32_t>
|
||||
@ -957,7 +960,7 @@ namespace vk
|
||||
}
|
||||
|
||||
vk::DescriptorImageInfo imageInfo(
|
||||
*textureData.sampler, **textureData.pImageData->pImageView, vk::ImageLayout::eShaderReadOnlyOptimal );
|
||||
*textureData.sampler, *textureData.imageData.imageView, vk::ImageLayout::eShaderReadOnlyOptimal );
|
||||
writeDescriptorSets.emplace_back(
|
||||
*descriptorSet, dstBinding, 0, vk::DescriptorType::eCombinedImageSampler, imageInfo, nullptr, nullptr );
|
||||
|
||||
@ -1002,8 +1005,7 @@ namespace vk
|
||||
imageInfos.reserve( textureData.size() );
|
||||
for ( auto const & thd : textureData )
|
||||
{
|
||||
imageInfos.emplace_back(
|
||||
*thd.sampler, **thd.pImageData->pImageView, vk::ImageLayout::eShaderReadOnlyOptimal );
|
||||
imageInfos.emplace_back( *thd.sampler, *thd.imageData.imageView, vk::ImageLayout::eShaderReadOnlyOptimal );
|
||||
}
|
||||
writeDescriptorSets.emplace_back( *descriptorSet,
|
||||
dstBinding,
|
||||
|
@ -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.
|
||||
|
||||
#### 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
|
||||
|
||||
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.
|
||||
|
@ -575,13 +575,9 @@ ${contextMembers}
|
||||
class InstanceDispatcher : public DispatchLoaderBase
|
||||
{
|
||||
public:
|
||||
InstanceDispatcher( PFN_vkGetInstanceProcAddr getProcAddr )
|
||||
: vkGetInstanceProcAddr( getProcAddr )
|
||||
{}
|
||||
InstanceDispatcher( PFN_vkGetInstanceProcAddr getProcAddr ) : vkGetInstanceProcAddr( getProcAddr ) {}
|
||||
|
||||
#if defined( VULKAN_HPP_RAII_ENABLE_DEFAULT_CONSTRUCTORS )
|
||||
InstanceDispatcher() = default;
|
||||
#endif
|
||||
InstanceDispatcher( std::nullptr_t ) : DispatchLoaderBase( nullptr ) {}
|
||||
|
||||
void init( VkInstance instance )
|
||||
{
|
||||
@ -602,21 +598,17 @@ ${instanceMembers}
|
||||
std::string deviceDispatcherTemplate = R"(
|
||||
class DeviceDispatcher : public DispatchLoaderBase
|
||||
{
|
||||
public:
|
||||
DeviceDispatcher( PFN_vkGetDeviceProcAddr getProcAddr )
|
||||
: vkGetDeviceProcAddr( getProcAddr )
|
||||
{}
|
||||
public:
|
||||
DeviceDispatcher( PFN_vkGetDeviceProcAddr getProcAddr ) : vkGetDeviceProcAddr( getProcAddr ) {}
|
||||
|
||||
#if defined( VULKAN_HPP_RAII_ENABLE_DEFAULT_CONSTRUCTORS )
|
||||
DeviceDispatcher() = default;
|
||||
#endif
|
||||
DeviceDispatcher( std::nullptr_t ) : DispatchLoaderBase( nullptr ) {}
|
||||
|
||||
void init( VkDevice device )
|
||||
{
|
||||
void init( VkDevice device )
|
||||
{
|
||||
${deviceAssignments}
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
${deviceMembers}
|
||||
};
|
||||
)";
|
||||
@ -7319,13 +7311,10 @@ ${enter} class ${handleType}
|
||||
public:
|
||||
${singularConstructors}
|
||||
${upgradeConstructor}
|
||||
${handleType}( std::nullptr_t ) {}
|
||||
${destructor}
|
||||
|
||||
#if defined( VULKAN_HPP_RAII_ENABLE_DEFAULT_CONSTRUCTORS )
|
||||
${handleType}() = default;
|
||||
#else
|
||||
${handleType}() = delete;
|
||||
#endif
|
||||
${handleType}( ${handleType} const & ) = delete;
|
||||
${handleType}( ${handleType} && rhs ) VULKAN_HPP_NOEXCEPT
|
||||
: ${moveConstructorInitializerList}
|
||||
@ -7351,18 +7340,6 @@ ${getConstructorSuccessCode}
|
||||
VULKAN_HPP_ASSERT( m_dispatcher${dispatcherAccess}getVkHeaderVersion() == VK_HEADER_VERSION );
|
||||
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}
|
||||
|
||||
private:
|
||||
@ -7399,11 +7376,7 @@ ${enter} class ${handleType}s : public std::vector<VULKAN_HPP_NAMESPACE::VULKAN
|
||||
public:
|
||||
${arrayConstructors}
|
||||
|
||||
#if defined( VULKAN_HPP_RAII_ENABLE_DEFAULT_CONSTRUCTORS )
|
||||
${handleType}s() = default;
|
||||
#else
|
||||
${handleType}s() = delete;
|
||||
#endif
|
||||
${handleType}s( ${handleType}s const & ) = delete;
|
||||
${handleType}s( ${handleType}s && rhs ) = default;
|
||||
${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" ) );
|
||||
}
|
||||
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 + " )";
|
||||
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" )
|
||||
{
|
||||
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" )
|
||||
{
|
||||
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" )
|
||||
{
|
||||
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
|
||||
{
|
||||
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 )";
|
||||
@ -16571,15 +16548,24 @@ int main( int argc, char ** argv )
|
||||
static const std::string dispatchLoaderBase = R"(
|
||||
class DispatchLoaderBase
|
||||
{
|
||||
#if !defined(NDEBUG)
|
||||
public:
|
||||
DispatchLoaderBase() = default;
|
||||
DispatchLoaderBase( std::nullptr_t )
|
||||
#if !defined( NDEBUG )
|
||||
: m_valid( false )
|
||||
#endif
|
||||
{}
|
||||
|
||||
#if !defined( NDEBUG )
|
||||
size_t getVkHeaderVersion() const
|
||||
{
|
||||
VULKAN_HPP_ASSERT( m_valid );
|
||||
return vkHeaderVersion;
|
||||
}
|
||||
|
||||
private:
|
||||
size_t vkHeaderVersion = VK_HEADER_VERSION;
|
||||
bool m_valid = true;
|
||||
#endif
|
||||
};
|
||||
)";
|
||||
|
@ -1385,15 +1385,24 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
|
||||
class DispatchLoaderBase
|
||||
{
|
||||
#if !defined( NDEBUG )
|
||||
public:
|
||||
DispatchLoaderBase() = default;
|
||||
DispatchLoaderBase( std::nullptr_t )
|
||||
#if !defined( NDEBUG )
|
||||
: m_valid( false )
|
||||
#endif
|
||||
{}
|
||||
|
||||
#if !defined( NDEBUG )
|
||||
size_t getVkHeaderVersion() const
|
||||
{
|
||||
VULKAN_HPP_ASSERT( m_valid );
|
||||
return vkHeaderVersion;
|
||||
}
|
||||
|
||||
private:
|
||||
size_t vkHeaderVersion = VK_HEADER_VERSION;
|
||||
bool m_valid = true;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user