diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-04-14 02:05:28 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-04-14 02:05:28 +0000 |
| commit | f84eeb1bc81c75f063a37f5bce078603f5a81c7b (patch) | |
| tree | 015e92032dfec33dde9cc6b4560fe38749b30a96 /Graphics/GraphicsEngineVulkan | |
| parent | Fixed issue with layout transition when generating mipmaps (diff) | |
| download | DiligentCore-f84eeb1bc81c75f063a37f5bce078603f5a81c7b.tar.gz DiligentCore-f84eeb1bc81c75f063a37f5bce078603f5a81c7b.zip | |
Implemented generate PSO cache warmup when texture view is created
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
4 files changed, 19 insertions, 11 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h index 52b6a7aa..417f2f5b 100644 --- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h @@ -247,6 +247,8 @@ public: void ResetRenderTargets(); Int64 GetContextFrameNumber()const{return m_ContextFrameNumber;} + GenerateMipsVkHelper& GetGenerateMipsHelper(){return *m_GenerateMipsHelper;} + private: void TransitionRenderTargets(RESOURCE_STATE_TRANSITION_MODE StateTransitionMode); inline void CommitRenderPassAndFramebuffer(bool VerifyStates); diff --git a/Graphics/GraphicsEngineVulkan/include/GenerateMipsVkHelper.h b/Graphics/GraphicsEngineVulkan/include/GenerateMipsVkHelper.h index 17b20d4b..b3b65113 100644 --- a/Graphics/GraphicsEngineVulkan/include/GenerateMipsVkHelper.h +++ b/Graphics/GraphicsEngineVulkan/include/GenerateMipsVkHelper.h @@ -56,7 +56,7 @@ namespace Diligent 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); + VkImageLayout GenerateMipsBlit(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, IShaderResourceBinding& SRB, VkImageSubresourceRange& SubresRange)const; RenderDeviceVkImpl& m_DeviceVkImpl; diff --git a/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp b/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp index 9f870ee3..6b28d4ef 100644 --- a/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp +++ b/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp @@ -107,10 +107,10 @@ namespace Diligent ShaderCreateInfo CSCreateInfo; std::array<RefCntAutoPtr<IPipelineState>, 4> PSOs; - CSCreateInfo.Source = g_GenerateMipsCSSource; - CSCreateInfo.EntryPoint = "main"; - CSCreateInfo.SourceLanguage = SHADER_SOURCE_LANGUAGE_GLSL; - CSCreateInfo.Desc.ShaderType = SHADER_TYPE_COMPUTE; + CSCreateInfo.Source = g_GenerateMipsCSSource; + CSCreateInfo.EntryPoint = "main"; + CSCreateInfo.SourceLanguage = SHADER_SOURCE_LANGUAGE_GLSL; + CSCreateInfo.Desc.ShaderType = SHADER_TYPE_COMPUTE; const auto& FmtAttribs = GetTextureFormatAttribs(Fmt); bool IsGamma = FmtAttribs.ComponentType == COMPONENT_TYPE_UNORM_SRGB; @@ -167,11 +167,11 @@ namespace Diligent m_DeviceVkImpl(DeviceVkImpl) { BufferDesc ConstantsCBDesc; - ConstantsCBDesc.Name = "Constants CB buffer"; - ConstantsCBDesc.BindFlags = BIND_UNIFORM_BUFFER; - ConstantsCBDesc.Usage = USAGE_DYNAMIC; + ConstantsCBDesc.Name = "Constants CB buffer"; + ConstantsCBDesc.BindFlags = BIND_UNIFORM_BUFFER; + ConstantsCBDesc.Usage = USAGE_DYNAMIC; ConstantsCBDesc.CPUAccessFlags = CPU_ACCESS_WRITE; - ConstantsCBDesc.uiSizeInBytes = 32; + ConstantsCBDesc.uiSizeInBytes = 32; DeviceVkImpl.CreateBuffer(ConstantsCBDesc, nullptr, &m_ConstantsCB); FindPSOs(TEX_FORMAT_RGBA8_UNORM); @@ -383,7 +383,7 @@ namespace Diligent return VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; } - VkImageLayout GenerateMipsVkHelper::GenerateMipsBlit(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, IShaderResourceBinding& SRB, VkImageSubresourceRange& SubresRange) + VkImageLayout GenerateMipsVkHelper::GenerateMipsBlit(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, IShaderResourceBinding& SRB, 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 e99e45f1..8739397f 100644 --- a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp @@ -156,7 +156,6 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, { ImageCI.usage |= VK_IMAGE_USAGE_STORAGE_BIT; m_bCSBasedMipGenerationSupported = true; - // TODO: warm-up generate mips PSO cache } else { @@ -576,6 +575,13 @@ void TextureVkImpl::CreateViewInternal(const TextureViewDesc& ViewDesc, ITexture CreateMipLevelView(TEXTURE_VIEW_SHADER_RESOURCE, MipLevel, &pMipLevelViews[MipLevel * 2]); CreateMipLevelView(TEXTURE_VIEW_UNORDERED_ACCESS, MipLevel, &pMipLevelViews[MipLevel * 2 + 1]); } + + if (auto pImmediateCtx = m_pDevice->GetImmediateContext()) + { + auto& GenerateMipsHelper = pImmediateCtx.RawPtr<DeviceContextVkImpl>()->GetGenerateMipsHelper(); + GenerateMipsHelper.WarmUpCache(pViewVk->GetDesc().Format); + } + pViewVk->AssignMipLevelViews(pMipLevelViews); } } |
