From 583f60ce9f3bec7625393f94ee3693934ae5791b Mon Sep 17 00:00:00 2001 From: assiduous Date: Tue, 24 Dec 2019 09:10:27 -0800 Subject: Reworked ClearRenderTarget and ClearDepthStencil methods to not take nullptr --- .../src/DeviceContextD3D11Impl.cpp | 36 +++++----------------- 1 file changed, 8 insertions(+), 28 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index 676c6d73..1c0328b5 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -911,20 +911,11 @@ void DeviceContextD3D11Impl::ClearDepthStencil(ITextureView* pV Uint8 Stencil, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) { - if (pView == nullptr) - { - if (m_pBoundDepthStencil == nullptr) - { - LOG_ERROR_MESSAGE("ClearDepthStencil(nullptr, ...) is invalid because no depth-stencil buffer is currently bound."); - return; - } - pView = m_pBoundDepthStencil; - } + if (!TDeviceContextBase::ClearDepthStencil(pView)) + return; + + VERIFY_EXPR(pView != nullptr); -#ifdef DEVELOPMENT - const auto& ViewDesc = pView->GetDesc(); - VERIFY(ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL, "Incorrect view type: depth stencil is expected"); -#endif auto* pViewD3D11 = ValidatedCast(pView); auto* pd3d11DSV = static_cast(pViewD3D11->GetD3D11View()); @@ -938,22 +929,11 @@ void DeviceContextD3D11Impl::ClearDepthStencil(ITextureView* pV void DeviceContextD3D11Impl::ClearRenderTarget(ITextureView* pView, const float* RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) { - if (pView == nullptr) - { - 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; - } - pView = m_pBoundRenderTargets[0]; - } + if (!TDeviceContextBase::ClearRenderTarget(pView)) + return; + + VERIFY_EXPR(pView != nullptr); -#ifdef DEVELOPMENT - const auto& ViewDesc = pView->GetDesc(); - VERIFY(ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET, "Incorrect view type: render target is expected"); -#endif auto* pViewD3D11 = ValidatedCast(pView); auto* pd3d11RTV = static_cast(pViewD3D11->GetD3D11View()); -- cgit v1.2.3