diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-07-09 19:10:46 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-07-09 19:10:46 +0000 |
| commit | ac230c36776b7d546a42f3b852ff56e66811e9e3 (patch) | |
| tree | 1edfb7618fa12154951ea3bad62309e1e190f499 /Graphics/GraphicsEngineVulkan | |
| parent | Fixed minor code review issue (diff) | |
| download | DiligentCore-ac230c36776b7d546a42f3b852ff56e66811e9e3.tar.gz DiligentCore-ac230c36776b7d546a42f3b852ff56e66811e9e3.zip | |
VK backend: fixed mipmap generation when glslang is disabled
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
4 files changed, 20 insertions, 9 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/GenerateMipsVkHelper.hpp b/Graphics/GraphicsEngineVulkan/include/GenerateMipsVkHelper.hpp index 845a70f3..298738d9 100644 --- a/Graphics/GraphicsEngineVulkan/include/GenerateMipsVkHelper.hpp +++ b/Graphics/GraphicsEngineVulkan/include/GenerateMipsVkHelper.hpp @@ -54,7 +54,7 @@ public: GenerateMipsVkHelper& operator = ( GenerateMipsVkHelper&&) = delete; // clang-format on - void GenerateMips(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, IShaderResourceBinding& SRB); + void GenerateMips(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, IShaderResourceBinding* pSRB); void CreateSRB(IShaderResourceBinding** ppSRB); void WarmUpCache(TEXTURE_FORMAT Fmt); @@ -63,7 +63,7 @@ private: std::array<RefCntAutoPtr<IPipelineState>, 4>& FindPSOs(TEXTURE_FORMAT Fmt); VkImageLayout GenerateMipsCS(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, IShaderResourceBinding& SRB, VkImageSubresourceRange& SubresRange); - VkImageLayout GenerateMipsBlit(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, IShaderResourceBinding& SRB, VkImageSubresourceRange& SubresRange) const; + VkImageLayout GenerateMipsBlit(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, VkImageSubresourceRange& SubresRange) const; RenderDeviceVkImpl& m_DeviceVkImpl; diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index 76163513..d61ddc97 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -1682,7 +1682,7 @@ void DeviceContextVkImpl::UpdateTextureRegion(const void* pSr void DeviceContextVkImpl::GenerateMips(ITextureView* pTexView) { TDeviceContextBase::GenerateMips(pTexView); - m_GenerateMipsHelper->GenerateMips(*ValidatedCast<TextureViewVkImpl>(pTexView), *this, *m_GenerateMipsSRB); + m_GenerateMipsHelper->GenerateMips(*ValidatedCast<TextureViewVkImpl>(pTexView), *this, m_GenerateMipsSRB); } static VkBufferImageCopy GetBufferImageCopyInfo(Uint32 BufferOffset, diff --git a/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp b/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp index d01d49bd..92d920df 100644 --- a/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp +++ b/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp @@ -112,10 +112,11 @@ void GenerateMipsVkHelper::GetGlImageFormat(const TextureFormatAttribs& FmtAttri std::array<RefCntAutoPtr<IPipelineState>, 4> GenerateMipsVkHelper::CreatePSOs(TEXTURE_FORMAT Fmt) { - ShaderCreateInfo CSCreateInfo; - std::array<RefCntAutoPtr<IPipelineState>, 4> PSOs; +#if !NO_GLSLANG + ShaderCreateInfo CSCreateInfo; + CSCreateInfo.Source = g_GenerateMipsCSSource; CSCreateInfo.EntryPoint = "main"; CSCreateInfo.SourceLanguage = SHADER_SOURCE_LANGUAGE_GLSL; @@ -172,6 +173,7 @@ std::array<RefCntAutoPtr<IPipelineState>, 4> GenerateMipsVkHelper::CreatePSOs(TE m_DeviceVkImpl.CreatePipelineState(PSOCreateInfo, &PSOs[NonPowOfTwo]); PSOs[NonPowOfTwo]->GetStaticVariableByName(SHADER_TYPE_COMPUTE, "CB")->Set(m_ConstantsCB); } +#endif return PSOs; } @@ -179,6 +181,7 @@ std::array<RefCntAutoPtr<IPipelineState>, 4> GenerateMipsVkHelper::CreatePSOs(TE GenerateMipsVkHelper::GenerateMipsVkHelper(RenderDeviceVkImpl& DeviceVkImpl) : m_DeviceVkImpl(DeviceVkImpl) { +#if !NO_GLSLANG BufferDesc ConstantsCBDesc; ConstantsCBDesc.Name = "Constants CB buffer"; ConstantsCBDesc.BindFlags = BIND_UNIFORM_BUFFER; @@ -189,13 +192,16 @@ GenerateMipsVkHelper::GenerateMipsVkHelper(RenderDeviceVkImpl& DeviceVkImpl) : FindPSOs(TEX_FORMAT_RGBA8_UNORM); FindPSOs(TEX_FORMAT_BGRA8_UNORM); +#endif } void GenerateMipsVkHelper::CreateSRB(IShaderResourceBinding** ppSRB) { +#if !NO_GLSLANG // All PSOs are compatible auto& PSO = FindPSOs(TEX_FORMAT_RGBA8_UNORM); PSO[0]->CreateShaderResourceBinding(ppSRB, true); +#endif } std::array<RefCntAutoPtr<IPipelineState>, 4>& GenerateMipsVkHelper::FindPSOs(TEXTURE_FORMAT Fmt) @@ -213,7 +219,7 @@ void GenerateMipsVkHelper::WarmUpCache(TEXTURE_FORMAT Fmt) FindPSOs(Fmt); } -void GenerateMipsVkHelper::GenerateMips(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, IShaderResourceBinding& SRB) +void GenerateMipsVkHelper::GenerateMips(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, IShaderResourceBinding* pSRB) { auto* pTexVk = TexView.GetTexture<TextureVkImpl>(); if (!pTexVk->IsInKnownState()) @@ -254,13 +260,16 @@ void GenerateMipsVkHelper::GenerateMips(TextureViewVkImpl& TexView, DeviceContex SubresRange.levelCount = 1; VkImageLayout AffectedMipLevelLayout; +#if !NO_GLSLANG if (TexView.HasMipLevelViews()) { - AffectedMipLevelLayout = GenerateMipsCS(TexView, Ctx, SRB, SubresRange); + VERIFY_EXPR(pSRB != nullptr); + AffectedMipLevelLayout = GenerateMipsCS(TexView, Ctx, *pSRB, SubresRange); } else +#endif { - AffectedMipLevelLayout = GenerateMipsBlit(TexView, Ctx, SRB, SubresRange); + AffectedMipLevelLayout = GenerateMipsBlit(TexView, Ctx, SubresRange); } // All affected mip levels are now in VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL state @@ -403,7 +412,7 @@ VkImageLayout GenerateMipsVkHelper::GenerateMipsCS(TextureViewVkImpl& TexView, D return VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; } -VkImageLayout GenerateMipsVkHelper::GenerateMipsBlit(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, IShaderResourceBinding& SRB, VkImageSubresourceRange& SubresRange) const +VkImageLayout GenerateMipsVkHelper::GenerateMipsBlit(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, VkImageSubresourceRange& SubresRange) const { auto* pTexVk = TexView.GetTexture<TextureVkImpl>(); const auto& TexDesc = pTexVk->GetDesc(); diff --git a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp index a124c9ab..fc8c8b04 100644 --- a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp @@ -754,6 +754,7 @@ VulkanUtilities::ImageViewWrapper TextureVkImpl::CreateImageView(TextureViewDesc bool TextureVkImpl::CheckCSBasedMipGenerationSupport(VkFormat vkFmt) const { +#if !NO_GLSLANG VERIFY_EXPR(m_Desc.MiscFlags & MISC_TEXTURE_FLAG_GENERATE_MIPS); if (m_Desc.Type == RESOURCE_DIM_TEX_2D || m_Desc.Type == RESOURCE_DIM_TEX_2D_ARRAY) { @@ -764,6 +765,7 @@ bool TextureVkImpl::CheckCSBasedMipGenerationSupport(VkFormat vkFmt) const return true; } } +#endif return false; } |
