From bda7a3d7a68dbbaf4894332e2278c0970a61a74e Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 13 Apr 2019 07:40:08 -0700 Subject: Improved mipmap generation in D3D12 backend --- Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp b/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp index 3d53a03a..79e60fab 100644 --- a/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp +++ b/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp @@ -208,13 +208,16 @@ namespace Diligent return; } - DEV_CHECK_ERR(TexView.GetDesc().NumMipLevels > 1, "Number of mip levels in the view must be greater than 1"); - const auto OriginalState = pTexVk->GetState(); const auto OriginalLayout = pTexVk->GetLayout(); const auto& TexDesc = pTexVk->GetDesc(); const auto& ViewDesc = TexView.GetDesc(); + DEV_CHECK_ERR(ViewDesc.NumMipLevels > 1, "Number of mip levels in the view must be greater than 1"); + DEV_CHECK_ERR(OriginalState != RESOURCE_STATE_UNDEFINED, + "Attempting to generate mipmaps for texture '", TexDesc.Name, "' which is in RESOURCE_STATE_UNDEFINED state ." + "This is not expected in Vulkan backend as textures are transition to a defined state when created."); + const auto& FmtAttribs = GetTextureFormatAttribs(ViewDesc.Format); VkImageSubresourceRange SubresRange = {}; if (FmtAttribs.ComponentType == COMPONENT_TYPE_DEPTH) @@ -257,6 +260,7 @@ namespace Diligent } else { + VERIFY(OriginalLayout != VK_IMAGE_LAYOUT_UNDEFINED, "Original layout must not be undefined"); SubresRange.baseMipLevel = ViewDesc.MostDetailedMip; SubresRange.levelCount = ViewDesc.NumMipLevels; // Transition all affected subresources back to original layout @@ -345,7 +349,7 @@ namespace Diligent *MappedData = { - static_cast(TopMip), + static_cast(TopMip), // Mip levels are relateive to the view's most detailed mip static_cast(NumMips), 0, // Array slices are relative to the view's first array slice 0, // Unused -- cgit v1.2.3