diff --git a/RAII_Samples/05_InitSwapchain/05_InitSwapchain.cpp b/RAII_Samples/05_InitSwapchain/05_InitSwapchain.cpp index a5aba4f..e7b525a 100644 --- a/RAII_Samples/05_InitSwapchain/05_InitSwapchain.cpp +++ b/RAII_Samples/05_InitSwapchain/05_InitSwapchain.cpp @@ -160,13 +160,11 @@ int main( int /*argc*/, char ** /*argv*/ ) std::vector imageViews; imageViews.reserve( swapChainImages.size() ); - vk::ComponentMapping componentMapping( - vk::ComponentSwizzle::eR, vk::ComponentSwizzle::eG, vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eA ); - vk::ImageSubresourceRange subResourceRange( vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 ); + vk::ImageViewCreateInfo imageViewCreateInfo( + {}, {}, vk::ImageViewType::e2D, format, {}, { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } ); for ( auto image : swapChainImages ) { - vk::ImageViewCreateInfo imageViewCreateInfo( - {}, static_cast( image ), vk::ImageViewType::e2D, format, componentMapping, subResourceRange ); + imageViewCreateInfo.image = static_cast( image ); imageViews.push_back( { device, imageViewCreateInfo } ); } diff --git a/RAII_Samples/06_InitDepthBuffer/06_InitDepthBuffer.cpp b/RAII_Samples/06_InitDepthBuffer/06_InitDepthBuffer.cpp index cbb2f39..008cba0 100644 --- a/RAII_Samples/06_InitDepthBuffer/06_InitDepthBuffer.cpp +++ b/RAII_Samples/06_InitDepthBuffer/06_InitDepthBuffer.cpp @@ -92,11 +92,8 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::raii::DeviceMemory depthMemory( device, memoryAllocateInfo ); depthImage.bindMemory( *depthMemory, 0 ); - vk::ComponentMapping componentMapping( - vk::ComponentSwizzle::eR, vk::ComponentSwizzle::eG, vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eA ); - vk::ImageSubresourceRange subResourceRange( vk::ImageAspectFlagBits::eDepth, 0, 1, 0, 1 ); - vk::ImageViewCreateInfo imageViewCreateInfo( - {}, *depthImage, vk::ImageViewType::e2D, depthFormat, componentMapping, subResourceRange ); + vk::ImageViewCreateInfo imageViewCreateInfo( + {}, *depthImage, vk::ImageViewType::e2D, depthFormat, {}, { vk::ImageAspectFlagBits::eDepth, 0, 1, 0, 1 } ); vk::raii::ImageView depthView( device, imageViewCreateInfo ); /* VULKAN_HPP_KEY_END */ diff --git a/RAII_Samples/InitTexture/InitTexture.cpp b/RAII_Samples/InitTexture/InitTexture.cpp index e31b013..522e3f4 100644 --- a/RAII_Samples/InitTexture/InitTexture.cpp +++ b/RAII_Samples/InitTexture/InitTexture.cpp @@ -193,11 +193,8 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::BorderColor::eFloatOpaqueWhite ); vk::raii::Sampler sampler( device, samplerCreateInfo ); - vk::ComponentMapping componentMapping( - vk::ComponentSwizzle::eR, vk::ComponentSwizzle::eG, vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eA ); - vk::ImageSubresourceRange imageSubresourceRange( vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 ); - vk::ImageViewCreateInfo imageViewCreateInfo( - {}, *image, vk::ImageViewType::e2D, format, componentMapping, imageSubresourceRange ); + vk::ImageViewCreateInfo imageViewCreateInfo( + {}, *image, vk::ImageViewType::e2D, format, {}, { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } ); vk::raii::ImageView imageView( device, imageViewCreateInfo ); /* VULKAN_KEY_END */ diff --git a/RAII_Samples/InputAttachment/InputAttachment.cpp b/RAII_Samples/InputAttachment/InputAttachment.cpp index 2ca471c..a7bb355 100644 --- a/RAII_Samples/InputAttachment/InputAttachment.cpp +++ b/RAII_Samples/InputAttachment/InputAttachment.cpp @@ -76,7 +76,7 @@ int main( int /*argc*/, char ** /*argv*/ ) #if !defined( NDEBUG ) vk::raii::DebugUtilsMessengerEXT debugUtilsMessenger( instance, vk::su::makeDebugUtilsMessengerCreateInfoEXT() ); #endif - vk::raii::PhysicalDevice physicalDevice = std::move( vk::raii::PhysicalDevices( instance ).front() ); + vk::raii::PhysicalDevice physicalDevice = std::move( vk::raii::PhysicalDevices( instance ).front() ); vk::FormatProperties formatProperties = physicalDevice.getFormatProperties( vk::Format::eR8G8B8A8Unorm ); if ( !( formatProperties.optimalTilingFeatures & vk::FormatFeatureFlagBits::eColorAttachment ) ) @@ -96,8 +96,8 @@ int main( int /*argc*/, char ** /*argv*/ ) device, { vk::CommandPoolCreateFlagBits::eResetCommandBuffer, graphicsAndPresentQueueFamilyIndex.first } ); vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool ); - vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); - vk::raii::Queue presentQueue( device, graphicsAndPresentQueueFamilyIndex.second, 0 ); + vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 ); + vk::raii::Queue presentQueue( device, graphicsAndPresentQueueFamilyIndex.second, 0 ); vk::raii::su::SwapChainData swapChainData( physicalDevice, device, @@ -117,7 +117,7 @@ int main( int /*argc*/, char ** /*argv*/ ) // Create the image that will be used as the input attachment // The image for the color attachment is the presentable image already created as part of the SwapChainData - vk::ImageCreateInfo imageCreateInfo( {}, + vk::ImageCreateInfo imageCreateInfo( {}, vk::ImageType::e2D, swapChainData.colorFormat, vk::Extent3D( surfaceData.extent, 1 ), @@ -127,12 +127,12 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::ImageTiling::eOptimal, vk::ImageUsageFlagBits::eInputAttachment | vk::ImageUsageFlagBits::eTransferDst ); - vk::raii::Image inputImage( device, imageCreateInfo ); + vk::raii::Image inputImage( device, imageCreateInfo ); vk::MemoryRequirements memoryRequirements = inputImage.getMemoryRequirements(); uint32_t memoryTypeIndex = vk::su::findMemoryType( physicalDevice.getMemoryProperties(), memoryRequirements.memoryTypeBits, {} ); - vk::MemoryAllocateInfo memoryAllocateInfo( memoryRequirements.size, memoryTypeIndex ); + vk::MemoryAllocateInfo memoryAllocateInfo( memoryRequirements.size, memoryTypeIndex ); vk::raii::DeviceMemory inputMemory( device, memoryAllocateInfo ); inputImage.bindMemory( *inputMemory, 0 ); @@ -144,11 +144,11 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::ImageLayout::eUndefined, vk::ImageLayout::eTransferDstOptimal ); - vk::ClearColorValue clearColorValue( std::array( { { 1.0f, 1.0f, 0.0f, 0.0f } } ) ); - vk::ImageSubresourceRange imageSubresourceRange( - vk::ImageAspectFlagBits::eColor, 0, VK_REMAINING_MIP_LEVELS, 0, VK_REMAINING_ARRAY_LAYERS ); commandBuffer.clearColorImage( - *inputImage, vk::ImageLayout::eTransferDstOptimal, clearColorValue, imageSubresourceRange ); + *inputImage, + vk::ImageLayout::eTransferDstOptimal, + { std::array( { { 1.0f, 1.0f, 0.0f, 0.0f } } ) }, + { { vk::ImageAspectFlagBits::eColor, 0, VK_REMAINING_MIP_LEVELS, 0, VK_REMAINING_ARRAY_LAYERS } } ); // Set the image layout to SHADER_READONLY_OPTIMAL for use by the shaders vk::raii::su::setImageLayout( commandBuffer, @@ -157,20 +157,21 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::ImageLayout::eTransferDstOptimal, vk::ImageLayout::eShaderReadOnlyOptimal ); - vk::ComponentMapping componentMapping( - vk::ComponentSwizzle::eR, vk::ComponentSwizzle::eG, vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eA ); - imageSubresourceRange = vk::ImageSubresourceRange( vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 ); - vk::ImageViewCreateInfo imageViewCreateInfo( - {}, *inputImage, vk::ImageViewType::e2D, swapChainData.colorFormat, componentMapping, imageSubresourceRange ); + vk::ImageViewCreateInfo imageViewCreateInfo( {}, + *inputImage, + vk::ImageViewType::e2D, + swapChainData.colorFormat, + {}, + { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } ); vk::raii::ImageView inputAttachmentView( device, imageViewCreateInfo ); vk::DescriptorSetLayoutBinding layoutBinding( 0, vk::DescriptorType::eInputAttachment, 1, vk::ShaderStageFlagBits::eFragment ); - vk::DescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo( {}, layoutBinding ); - vk::raii::DescriptorSetLayout descriptorSetLayout( device, descriptorSetLayoutCreateInfo ); + vk::DescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo( {}, layoutBinding ); + vk::raii::DescriptorSetLayout descriptorSetLayout( device, descriptorSetLayoutCreateInfo ); - vk::PipelineLayoutCreateInfo pipelineLayoutCreateInfo( {}, *descriptorSetLayout ); - vk::raii::PipelineLayout pipelineLayout( device, pipelineLayoutCreateInfo ); + vk::PipelineLayoutCreateInfo pipelineLayoutCreateInfo( {}, *descriptorSetLayout ); + vk::raii::PipelineLayout pipelineLayout( device, pipelineLayoutCreateInfo ); std::array attachments = { // First attachment is the color attachment - clear at the beginning of the renderpass and transition layout to @@ -201,7 +202,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::AttachmentReference inputReference( 1, vk::ImageLayout::eShaderReadOnlyOptimal ); vk::SubpassDescription subPass( {}, vk::PipelineBindPoint::eGraphics, inputReference, colorReference ); vk::RenderPassCreateInfo renderPassCreateInfo( {}, attachments, subPass ); - vk::raii::RenderPass renderPass( device, renderPassCreateInfo ); + vk::raii::RenderPass renderPass( device, renderPassCreateInfo ); glslang::InitializeProcess(); vk::raii::ShaderModule vertexShaderModule = @@ -218,8 +219,9 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet, 1, poolSize ); vk::raii::DescriptorPool descriptorPool( device, descriptorPoolCreateInfo ); - vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( *descriptorPool, *descriptorSetLayout ); - vk::raii::DescriptorSet descriptorSet = std::move( vk::raii::DescriptorSets( device, descriptorSetAllocateInfo ).front() ); + vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( *descriptorPool, *descriptorSetLayout ); + vk::raii::DescriptorSet descriptorSet = + std::move( vk::raii::DescriptorSets( device, descriptorSetAllocateInfo ).front() ); vk::DescriptorImageInfo inputImageInfo( nullptr, *inputAttachmentView, vk::ImageLayout::eShaderReadOnlyOptimal ); vk::WriteDescriptorSet writeDescriptorSet( @@ -227,23 +229,22 @@ int main( int /*argc*/, char ** /*argv*/ ) device.updateDescriptorSets( writeDescriptorSet, nullptr ); vk::raii::PipelineCache pipelineCache( device, vk::PipelineCacheCreateInfo() ); - vk::raii::Pipeline graphicsPipeline = - vk::raii::su::makeGraphicsPipeline( device, - pipelineCache, - vertexShaderModule, - nullptr, - fragmentShaderModule, - nullptr, - 0, - {}, - vk::FrontFace::eClockwise, - false, - pipelineLayout, - renderPass ); + vk::raii::Pipeline graphicsPipeline = vk::raii::su::makeGraphicsPipeline( device, + pipelineCache, + vertexShaderModule, + nullptr, + fragmentShaderModule, + nullptr, + 0, + {}, + vk::FrontFace::eClockwise, + false, + pipelineLayout, + renderPass ); vk::raii::Semaphore imageAcquiredSemaphore( device, vk::SemaphoreCreateInfo() ); - vk::Result result; - uint32_t imageIndex; + vk::Result result; + uint32_t imageIndex; std::tie( result, imageIndex ) = swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *imageAcquiredSemaphore ); assert( result == vk::Result::eSuccess ); @@ -259,12 +260,12 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::PipelineBindPoint::eGraphics, *pipelineLayout, 0, { *descriptorSet }, nullptr ); commandBuffer.setViewport( 0, - vk::Viewport( 0.0f, - 0.0f, - static_cast( surfaceData.extent.width ), - static_cast( surfaceData.extent.height ), - 0.0f, - 1.0f ) ); + vk::Viewport( 0.0f, + 0.0f, + static_cast( surfaceData.extent.width ), + static_cast( surfaceData.extent.height ), + 0.0f, + 1.0f ) ); commandBuffer.setScissor( 0, vk::Rect2D( vk::Offset2D( 0, 0 ), surfaceData.extent ) ); commandBuffer.draw( 3, 1, 0, 0 ); diff --git a/RAII_Samples/utils/utils.hpp b/RAII_Samples/utils/utils.hpp index b762c69..033a8d9 100644 --- a/RAII_Samples/utils/utils.hpp +++ b/RAII_Samples/utils/utils.hpp @@ -313,13 +313,7 @@ namespace vk image.bindMemory( *deviceMemory, 0 ); imageView = vk::raii::ImageView( device, - vk::ImageViewCreateInfo( - {}, - *image, - vk::ImageViewType::e2D, - format, - { ComponentSwizzle::eR, ComponentSwizzle::eG, ComponentSwizzle::eB, ComponentSwizzle::eA }, - { aspectMask, 0, 1, 0, 1 } ) ); + vk::ImageViewCreateInfo( {}, *image, vk::ImageViewType::e2D, format, {}, { aspectMask, 0, 1, 0, 1 } ) ); } ImageData( std::nullptr_t ) {} @@ -440,17 +434,11 @@ namespace vk images = swapChain.getImages(); imageViews.reserve( images.size() ); - vk::ComponentMapping componentMapping( - vk::ComponentSwizzle::eR, vk::ComponentSwizzle::eG, vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eA ); - vk::ImageSubresourceRange subResourceRange( vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 ); + vk::ImageViewCreateInfo imageViewCreateInfo( + {}, {}, vk::ImageViewType::e2D, colorFormat, {}, { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } ); for ( auto image : images ) { - vk::ImageViewCreateInfo imageViewCreateInfo( {}, - static_cast( image ), - vk::ImageViewType::e2D, - colorFormat, - componentMapping, - subResourceRange ); + imageViewCreateInfo.image = static_cast( image ); imageViews.emplace_back( device, imageViewCreateInfo ); } } diff --git a/samples/05_InitSwapchain/05_InitSwapchain.cpp b/samples/05_InitSwapchain/05_InitSwapchain.cpp index 5ff5aca..7059027 100644 --- a/samples/05_InitSwapchain/05_InitSwapchain.cpp +++ b/samples/05_InitSwapchain/05_InitSwapchain.cpp @@ -166,13 +166,11 @@ int main( int /*argc*/, char ** /*argv*/ ) std::vector imageViews; imageViews.reserve( swapChainImages.size() ); - vk::ComponentMapping componentMapping( - vk::ComponentSwizzle::eR, vk::ComponentSwizzle::eG, vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eA ); - vk::ImageSubresourceRange subResourceRange( vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 ); + vk::ImageViewCreateInfo imageViewCreateInfo( + {}, {}, vk::ImageViewType::e2D, format, {}, { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } ); for ( auto image : swapChainImages ) { - vk::ImageViewCreateInfo imageViewCreateInfo( - vk::ImageViewCreateFlags(), image, vk::ImageViewType::e2D, format, componentMapping, subResourceRange ); + imageViewCreateInfo.image = image; imageViews.push_back( device.createImageView( imageViewCreateInfo ) ); } diff --git a/samples/06_InitDepthBuffer/06_InitDepthBuffer.cpp b/samples/06_InitDepthBuffer/06_InitDepthBuffer.cpp index 04ef430..ff30e46 100644 --- a/samples/06_InitDepthBuffer/06_InitDepthBuffer.cpp +++ b/samples/06_InitDepthBuffer/06_InitDepthBuffer.cpp @@ -92,15 +92,13 @@ int main( int /*argc*/, char ** /*argv*/ ) device.bindImageMemory( depthImage, depthMemory, 0 ); - vk::ComponentMapping componentMapping( - vk::ComponentSwizzle::eR, vk::ComponentSwizzle::eG, vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eA ); - vk::ImageSubresourceRange subResourceRange( vk::ImageAspectFlagBits::eDepth, 0, 1, 0, 1 ); - vk::ImageView depthView = device.createImageView( vk::ImageViewCreateInfo( vk::ImageViewCreateFlags(), - depthImage, - vk::ImageViewType::e2D, - depthFormat, - componentMapping, - subResourceRange ) ); + vk::ImageView depthView = + device.createImageView( vk::ImageViewCreateInfo( vk::ImageViewCreateFlags(), + depthImage, + vk::ImageViewType::e2D, + depthFormat, + {}, + { vk::ImageAspectFlagBits::eDepth, 0, 1, 0, 1 } ) ); // destroy depthView, depthMemory, and depthImage device.destroyImageView( depthView ); diff --git a/samples/InitTexture/InitTexture.cpp b/samples/InitTexture/InitTexture.cpp index eea6fd6..ecfcf8f 100644 --- a/samples/InitTexture/InitTexture.cpp +++ b/samples/InitTexture/InitTexture.cpp @@ -194,11 +194,8 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::BorderColor::eFloatOpaqueWhite ); vk::Sampler sampler = device.createSampler( samplerCreateInfo ); - vk::ComponentMapping componentMapping( - vk::ComponentSwizzle::eR, vk::ComponentSwizzle::eG, vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eA ); - vk::ImageSubresourceRange imageSubresourceRange( vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 ); - vk::ImageViewCreateInfo imageViewCreateInfo( - {}, image, vk::ImageViewType::e2D, format, componentMapping, imageSubresourceRange ); + vk::ImageViewCreateInfo imageViewCreateInfo( + {}, image, vk::ImageViewType::e2D, format, {}, { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } ); vk::ImageView imageView = device.createImageView( imageViewCreateInfo ); /* VULKAN_KEY_END */ diff --git a/samples/InputAttachment/InputAttachment.cpp b/samples/InputAttachment/InputAttachment.cpp index fa60166..1e3d3f3 100644 --- a/samples/InputAttachment/InputAttachment.cpp +++ b/samples/InputAttachment/InputAttachment.cpp @@ -159,12 +159,13 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::ImageLayout::eTransferDstOptimal, vk::ImageLayout::eShaderReadOnlyOptimal ); - vk::ComponentMapping componentMapping( - vk::ComponentSwizzle::eR, vk::ComponentSwizzle::eG, vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eA ); - vk::ImageSubresourceRange imageSubresourceRange( vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 ); - vk::ImageViewCreateInfo imageViewCreateInfo( - {}, inputImage, vk::ImageViewType::e2D, swapChainData.colorFormat, componentMapping, imageSubresourceRange ); - vk::ImageView inputAttachmentView = device.createImageView( imageViewCreateInfo ); + vk::ImageViewCreateInfo imageViewCreateInfo( {}, + inputImage, + vk::ImageViewType::e2D, + swapChainData.colorFormat, + {}, + { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } ); + vk::ImageView inputAttachmentView = device.createImageView( imageViewCreateInfo ); vk::DescriptorSetLayoutBinding layoutBinding( 0, vk::DescriptorType::eInputAttachment, 1, vk::ShaderStageFlagBits::eFragment ); diff --git a/samples/utils/utils.cpp b/samples/utils/utils.cpp index 069b55b..1a01e1f 100644 --- a/samples/utils/utils.cpp +++ b/samples/utils/utils.cpp @@ -879,11 +879,8 @@ namespace vk device.bindImageMemory( image, deviceMemory, 0 ); - vk::ComponentMapping componentMapping( - ComponentSwizzle::eR, ComponentSwizzle::eG, ComponentSwizzle::eB, ComponentSwizzle::eA ); - vk::ImageSubresourceRange imageSubresourceRange( aspectMask, 0, 1, 0, 1 ); - vk::ImageViewCreateInfo imageViewCreateInfo( - {}, image, vk::ImageViewType::e2D, format, componentMapping, imageSubresourceRange ); + vk::ImageViewCreateInfo imageViewCreateInfo( + {}, image, vk::ImageViewType::e2D, format, {}, { aspectMask, 0, 1, 0, 1 } ); imageView = device.createImageView( imageViewCreateInfo ); } @@ -969,13 +966,11 @@ namespace vk images = device.getSwapchainImagesKHR( swapChain ); imageViews.reserve( images.size() ); - vk::ComponentMapping componentMapping( - vk::ComponentSwizzle::eR, vk::ComponentSwizzle::eG, vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eA ); - vk::ImageSubresourceRange subResourceRange( vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 ); + vk::ImageViewCreateInfo imageViewCreateInfo( + {}, {}, vk::ImageViewType::e2D, colorFormat, {}, { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } ); for ( auto image : images ) { - vk::ImageViewCreateInfo imageViewCreateInfo( - vk::ImageViewCreateFlags(), image, vk::ImageViewType::e2D, colorFormat, componentMapping, subResourceRange ); + imageViewCreateInfo.image = image; imageViews.push_back( device.createImageView( imageViewCreateInfo ) ); } }