Skip to content
Permalink
Browse files

Vulkan: Use correct aspect for D24S8 textures

  • Loading branch information...
stenzek committed Jul 31, 2019
1 parent c70da39 commit 2698e311aaec09d9b0e34fc659349f3b668a1644
Showing with 18 additions and 2 deletions.
  1. +17 −2 Source/Core/VideoBackends/Vulkan/VKTexture.cpp
  2. +1 −0 Source/Core/VideoBackends/Vulkan/VKTexture.h
@@ -138,7 +138,7 @@ bool VKTexture::CreateView(VkImageViewType type)
GetVkFormat(),
{VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
VK_COMPONENT_SWIZZLE_IDENTITY},
{GetImageAspectForFormat(GetFormat()), 0, GetLevels(), 0, GetLayers()}};
{GetImageViewAspectForFormat(GetFormat()), 0, GetLevels(), 0, GetLayers()}};

VkResult res = vkCreateImageView(g_vulkan_context->GetDevice(), &view_info, nullptr, &m_view);
if (res != VK_SUCCESS)
@@ -237,6 +237,21 @@ VkImageAspectFlags VKTexture::GetImageAspectForFormat(AbstractTextureFormat form
}
}

VkImageAspectFlags VKTexture::GetImageViewAspectForFormat(AbstractTextureFormat format)
{
switch (format)
{
case AbstractTextureFormat::D16:
case AbstractTextureFormat::D24_S8:
case AbstractTextureFormat::D32F_S8:
case AbstractTextureFormat::D32F:
return VK_IMAGE_ASPECT_DEPTH_BIT;

default:
return VK_IMAGE_ASPECT_COLOR_BIT;
}
}

void VKTexture::CopyRectangleFromTexture(const AbstractTexture* src,
const MathUtil::Rectangle<int>& src_rect, u32 src_layer,
u32 src_level, const MathUtil::Rectangle<int>& dst_rect,
@@ -743,7 +758,7 @@ void VKStagingTexture::CopyFromTexture(const AbstractTexture* src,

// Issue the image->buffer copy, but delay it for now.
VkBufferImageCopy image_copy = {};
const VkImageAspectFlags aspect = VKTexture::GetImageAspectForFormat(src_tex->GetFormat());
const VkImageAspectFlags aspect = VKTexture::GetImageViewAspectForFormat(src_tex->GetFormat());
image_copy.bufferOffset =
static_cast<VkDeviceSize>(static_cast<size_t>(dst_rect.top) * m_config.GetStride() +
static_cast<size_t>(dst_rect.left) * m_texel_size);
@@ -37,6 +37,7 @@ class VKTexture final : public AbstractTexture
static VkFormat GetLinearFormat(VkFormat format);
static VkFormat GetVkFormatForHostTextureFormat(AbstractTextureFormat format);
static VkImageAspectFlags GetImageAspectForFormat(AbstractTextureFormat format);
static VkImageAspectFlags GetImageViewAspectForFormat(AbstractTextureFormat format);

void CopyRectangleFromTexture(const AbstractTexture* src,
const MathUtil::Rectangle<int>& src_rect, u32 src_layer,

0 comments on commit 2698e31

Please sign in to comment.
You can’t perform that action at this time.