From 5739e2f60fcc48737f70dfb09a05409e12be9c8c Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sun, 10 Dec 2017 20:06:07 +0100 Subject: [PATCH] [dxvk] Added component mapping to image view info --- src/dxvk/dxvk_image.cpp | 8 +------- src/dxvk/dxvk_image.h | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/dxvk/dxvk_image.cpp b/src/dxvk/dxvk_image.cpp index d5729351c..7f21e813a 100644 --- a/src/dxvk/dxvk_image.cpp +++ b/src/dxvk/dxvk_image.cpp @@ -63,12 +63,6 @@ namespace dxvk { const Rc& image, const DxvkImageViewCreateInfo& info) : m_vkd(vkd), m_image(image), m_info(info) { - VkComponentMapping componentMapping; - componentMapping.r = VK_COMPONENT_SWIZZLE_IDENTITY; - componentMapping.g = VK_COMPONENT_SWIZZLE_IDENTITY; - componentMapping.b = VK_COMPONENT_SWIZZLE_IDENTITY; - componentMapping.a = VK_COMPONENT_SWIZZLE_IDENTITY; - VkImageSubresourceRange subresourceRange; subresourceRange.aspectMask = info.aspect; subresourceRange.baseMipLevel = info.minLevel; @@ -83,7 +77,7 @@ namespace dxvk { viewInfo.image = image->handle(); viewInfo.viewType = info.type; viewInfo.format = info.format; - viewInfo.components = componentMapping; + viewInfo.components = info.swizzle; viewInfo.subresourceRange = subresourceRange; if (m_vkd->vkCreateImageView(m_vkd->device(), &viewInfo, nullptr, &m_view) != VK_SUCCESS) diff --git a/src/dxvk/dxvk_image.h b/src/dxvk/dxvk_image.h index 0dd8b83e8..df1414cae 100644 --- a/src/dxvk/dxvk_image.h +++ b/src/dxvk/dxvk_image.h @@ -60,17 +60,26 @@ namespace dxvk { */ struct DxvkImageViewCreateInfo { /// Image view dimension - VkImageViewType type; + VkImageViewType type = VK_IMAGE_VIEW_TYPE_2D; /// Pixel format - VkFormat format; + VkFormat format = VK_FORMAT_UNDEFINED; /// Subresources to use in the view - VkImageAspectFlags aspect; - uint32_t minLevel; - uint32_t numLevels; - uint32_t minLayer; - uint32_t numLayers; + VkImageAspectFlags aspect = 0; + + uint32_t minLevel = 0; + uint32_t numLevels = 0; + uint32_t minLayer = 0; + uint32_t numLayers = 0; + + /// Component mapping. Defaults to identity. + VkComponentMapping swizzle = { + VK_COMPONENT_SWIZZLE_IDENTITY, + VK_COMPONENT_SWIZZLE_IDENTITY, + VK_COMPONENT_SWIZZLE_IDENTITY, + VK_COMPONENT_SWIZZLE_IDENTITY, + }; };