From cbd1888d53ac6bafb94816d7eecf70a3bc24ecb0 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 13 Apr 2019 15:57:55 -0700 Subject: Fixed issues with D3D12 staging resources and mipmap generation in Vulkan --- Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp | 6 ++++-- Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp | 10 +--------- 2 files changed, 5 insertions(+), 11 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp b/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp index 79e60fab..4546ddac 100644 --- a/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp +++ b/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp @@ -304,9 +304,11 @@ namespace Diligent auto BottomMip = ViewDesc.NumMipLevels - 1; for (uint32_t TopMip = 0; TopMip < BottomMip; ) { - // In Vulkan all subresources of a view must be transitioned to the same layout, so + // In Vulkan, all subresources of a view must be transitioned to the same layout, so // we can't bind the entire texture and have to bind single mip level at a time - pSrcMipVar->Set(TexView.GetMipLevelSRV(TopMip)); + auto SrcMipLevelSRV = TexView.GetMipLevelSRV(TopMip); + VERIFY_EXPR(SrcMipLevelSRV != nullptr); + pSrcMipVar->Set(SrcMipLevelSRV); uint32_t SrcWidth = std::max(TexDesc.Width >> (TopMip + ViewDesc.MostDetailedMip), 1u); uint32_t SrcHeight = std::max(TexDesc.Height >> (TopMip + ViewDesc.MostDetailedMip), 1u); diff --git a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp index eaf88459..e99e45f1 100644 --- a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp @@ -573,15 +573,7 @@ void TextureVkImpl::CreateViewInternal(const TextureViewDesc& ViewDesc, ITexture new (ppMipLevelView) TextureViewVkImpl::MipLevelViewAutoPtrType(pMipLevelViewVk, STDDeleter(TexViewAllocator)); }; - if ((MipLevel % 4) == 0) - { - // Mip levles are generated 4 at a time, so we only need SRV for every 4-th level - CreateMipLevelView(TEXTURE_VIEW_SHADER_RESOURCE, MipLevel, &pMipLevelViews[MipLevel * 2]); - } - else - { - new (&pMipLevelViews[MipLevel * 2]) TextureViewVkImpl::MipLevelViewAutoPtrType{}; - } + CreateMipLevelView(TEXTURE_VIEW_SHADER_RESOURCE, MipLevel, &pMipLevelViews[MipLevel * 2]); CreateMipLevelView(TEXTURE_VIEW_UNORDERED_ACCESS, MipLevel, &pMipLevelViews[MipLevel * 2 + 1]); } pViewVk->AssignMipLevelViews(pMipLevelViews); -- cgit v1.2.3