summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2019-12-24 17:10:27 +0000
committerassiduous <assiduous@diligentgraphics.com>2019-12-24 17:10:27 +0000
commit583f60ce9f3bec7625393f94ee3693934ae5791b (patch)
treef2ac411359d021f7d07956cec650f6fc567710a5 /Graphics/GraphicsEngineVulkan
parentDisabled SetRenderTarget(0, nullptr, nullptr) usage (fixed https://github.com... (diff)
downloadDiligentCore-583f60ce9f3bec7625393f94ee3693934ae5791b.tar.gz
DiligentCore-583f60ce9f3bec7625393f94ee3693934ae5791b.zip
Reworked ClearRenderTarget and ClearDepthStencil methods to not take nullptr
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp58
-rw-r--r--Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp7
2 files changed, 18 insertions, 47 deletions
diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
index a508b4e9..330fdcb9 100644
--- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
@@ -609,28 +609,12 @@ void DeviceContextVkImpl::ClearDepthStencil(ITextureView* pView
Uint8 Stencil,
RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)
{
- ITextureViewVk* pVkDSV = nullptr;
- if (pView != nullptr)
- {
- pVkDSV = ValidatedCast<ITextureViewVk>(pView);
-#ifdef DEVELOPMENT
- const auto& ViewDesc = pVkDSV->GetDesc();
- if (ViewDesc.ViewType != TEXTURE_VIEW_DEPTH_STENCIL)
- {
- LOG_ERROR("The type (", GetTexViewTypeLiteralName(ViewDesc.ViewType), ") of texture view '", pView->GetDesc().Name, "' is incorrect for ClearDepthStencil operation. Depth-stencil view (TEXTURE_VIEW_DEPTH_STENCIL) must be provided.");
- return;
- }
-#endif
- }
- else
- {
- if (m_pBoundDepthStencil == nullptr)
- {
- LOG_ERROR_MESSAGE("ClearDepthStencil(nullptr, ...) is invalid because no depth-stencil buffer is currently bound.");
- return;
- }
- pVkDSV = m_pBoundDepthStencil;
- }
+ if (!TDeviceContextBase::ClearDepthStencil(pView))
+ return;
+
+ VERIFY_EXPR(pView != nullptr);
+
+ auto* pVkDSV = ValidatedCast<ITextureViewVk>(pView);
EnsureVkCmdBuffer();
@@ -721,30 +705,12 @@ VkClearColorValue ClearValueToVkClearValue(const float* RGBA, TEXTURE_FORMAT Tex
void DeviceContextVkImpl::ClearRenderTarget(ITextureView* pView, const float* RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)
{
- ITextureViewVk* pVkRTV = nullptr;
- if (pView != nullptr)
- {
-#ifdef DEVELOPMENT
- const auto& ViewDesc = pView->GetDesc();
- if (ViewDesc.ViewType != TEXTURE_VIEW_RENDER_TARGET)
- {
- LOG_ERROR("The type (", GetTexViewTypeLiteralName(ViewDesc.ViewType), ") of texture view '", pView->GetDesc().Name, "' is incorrect for ClearRenderTarget operation. Render target view (TEXTURE_VIEW_RENDER_TARGET) must be provided.");
- return;
- }
-#endif
- pVkRTV = ValidatedCast<ITextureViewVk>(pView);
- }
- else
- {
- if (m_NumBoundRenderTargets != 1)
- {
- LOG_ERROR_MESSAGE("ClearRenderTarget(nullptr, ...) semantic is only allowed when single render target is bound to the context. ",
- m_NumBoundRenderTargets, " render ",
- (m_NumBoundRenderTargets != 1 ? "targets are" : "target is"), " currently bound");
- return;
- }
- pVkRTV = m_pBoundRenderTargets[0];
- }
+ if (!TDeviceContextBase::ClearRenderTarget(pView))
+ return;
+
+ VERIFY_EXPR(pView != nullptr);
+
+ auto* pVkRTV = ValidatedCast<ITextureViewVk>(pView);
static constexpr float Zero[4] = {0.f, 0.f, 0.f, 0.f};
if (RGBA == nullptr)
diff --git a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
index 98be4ccb..6dd304ac 100644
--- a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
@@ -513,10 +513,15 @@ VkResult SwapChainVkImpl::AcquireNextImage(DeviceContextVkImpl* pDeviceCtxVk)
if (!m_SwapChainImagesInitialized[m_BackBufferIndex])
{
// Vulkan validation layers do not like uninitialized memory.
- // Clear back buffer first time we acquire it. This will use vkCmdClearColorImage()
+ // Clear back buffer first time we acquire it.
+
+ ITextureView* pRTV = GetCurrentBackBufferRTV();
+ ITextureView* pDSV = GetDepthBufferDSV();
+ pDeviceCtxVk->SetRenderTargets(1, &pRTV, pDSV, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
pDeviceCtxVk->ClearRenderTarget(GetCurrentBackBufferRTV(), nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
m_SwapChainImagesInitialized[m_BackBufferIndex] = true;
}
+ pDeviceCtxVk->SetRenderTargets(0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_NONE);
}
return res;