Removed explicit setting of the ComponentMapping for ImageViews in samples to RGBA, as the default of Identity does the same.

This commit is contained in:
asuessenbach
2021-11-11 11:49:07 +01:00
parent d8c9f4f0ee
commit 9b7adb35ee
10 changed files with 79 additions and 109 deletions

View File

@@ -166,13 +166,11 @@ int main( int /*argc*/, char ** /*argv*/ )
std::vector<vk::ImageView> 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 ) );
}

View File

@@ -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 );

View File

@@ -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 */

View File

@@ -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 );

View File

@@ -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 ) );
}
}