From 466dff5b223bd3f4af7963fec546ff179a745556 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 2 Dec 2018 09:39:49 -0800 Subject: Added explicit state transition control to UpdateBuffer and UpdateTexture commands --- .../include/DeviceContextD3D11Impl.h | 24 +++++++++------ .../GraphicsEngineD3D11/include/TextureBaseD3D11.h | 3 +- .../src/DeviceContextD3D11Impl.cpp | 36 ++++++++++------------ 3 files changed, 33 insertions(+), 30 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h index 030bb518..08ec67ad 100755 --- a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h @@ -30,7 +30,7 @@ #include "DeviceContextBase.h" #include "ShaderD3D11Impl.h" #include "BufferD3D11Impl.h" -#include "TextureViewD3D11Impl.h" +#include "TextureBaseD3D11.h" #include "PipelineStateD3D11Impl.h" #ifdef _DEBUG @@ -41,10 +41,10 @@ namespace Diligent { /// Implementation of the Diligent::IDeviceContextD3D11 interface -class DeviceContextD3D11Impl final : public DeviceContextBase +class DeviceContextD3D11Impl final : public DeviceContextBase { public: - using TDeviceContextBase = DeviceContextBase; + using TDeviceContextBase = DeviceContextBase; DeviceContextD3D11Impl(IReferenceCounters* pRefCounters, IMemoryAllocator& Allocator, @@ -93,7 +93,11 @@ public: virtual void Flush()override final; - virtual void UpdateBuffer(IBuffer* pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData)override final; + virtual void UpdateBuffer(IBuffer* pBuffer, + Uint32 Offset, + Uint32 Size, + const PVoid pData, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final; virtual void CopyBuffer(IBuffer* pSrcBuffer, Uint32 SrcOffset, IBuffer* pDstBuffer, Uint32 DstOffset, Uint32 Size)override final; @@ -101,11 +105,13 @@ public: virtual void UnmapBuffer(IBuffer* pBuffer)override final; - virtual void UpdateTexture(ITexture* pTexture, - Uint32 MipLevel, - Uint32 Slice, - const Box& DstBox, - const TextureSubResData& SubresData)override final; + virtual void UpdateTexture(ITexture* pTexture, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData, + RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final; virtual void CopyTexture(ITexture* pSrcTexture, Uint32 SrcMipLevel, diff --git a/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h b/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h index 0e4e20bf..a28427b2 100644 --- a/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h +++ b/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h @@ -41,7 +41,8 @@ class FixedBlockMemoryAllocator; class TextureBaseD3D11 : public TextureBase { public: - typedef TextureBase TTextureBase; + using TTextureBase = TextureBase; + using ViewImplType = TextureViewD3D11Impl; TextureBaseD3D11(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index 50a0161d..d93caaa3 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -938,9 +938,13 @@ namespace Diligent m_pd3d11DeviceContext->Flush(); } - void DeviceContextD3D11Impl::UpdateBuffer(IBuffer* pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData) + void DeviceContextD3D11Impl::UpdateBuffer(IBuffer* pBuffer, + Uint32 Offset, + Uint32 Size, + const PVoid pData, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) { - TDeviceContextBase::UpdateBuffer(pBuffer, Offset, Size, pData); + TDeviceContextBase::UpdateBuffer(pBuffer, Offset, Size, pData, StateTransitionMode); auto* pBufferD3D11Impl = ValidatedCast( pBuffer ); @@ -995,13 +999,15 @@ namespace Diligent m_pd3d11DeviceContext->Unmap(pBufferD3D11->m_pd3d11Buffer, 0); } - void DeviceContextD3D11Impl::UpdateTexture(ITexture* pTexture, - Uint32 MipLevel, - Uint32 Slice, - const Box& DstBox, - const TextureSubResData& SubresData) + void DeviceContextD3D11Impl::UpdateTexture(ITexture* pTexture, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData, + RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, + RESOURCE_STATE_TRANSITION_MODE DstTextureTransitionMode) { - TDeviceContextBase::UpdateTexture( pTexture, MipLevel, Slice, DstBox, SubresData ); + TDeviceContextBase::UpdateTexture( pTexture, MipLevel, Slice, DstBox, SubresData, SrcBufferTransitionMode, DstTextureTransitionMode ); auto* pTexD3D11 = ValidatedCast(pTexture); const auto& Desc = pTexD3D11->GetDesc(); @@ -1525,12 +1531,7 @@ namespace Diligent #ifdef DEVELOPMENT else if (Flags & SET_RENDER_TARGETS_FLAG_VERIFY_STATES) { - if (pTex->IsInKnownState() && !pTex->CheckState(RESOURCE_STATE_RENDER_TARGET)) - { - LOG_ERROR_MESSAGE("Texture '", pTex->GetDesc().Name, "' being set as render target at slot ", RT, " is not transitioned to RESOURCE_STATE_RENDER_TARGET state. " - "Actual texture state: ", GetResourceStateString(pTex->GetState()), ". " - "Use SET_RENDER_TARGETS_FLAG_TRANSITION_COLOR flag or explicitly transition the resource using IDeviceContext::TransitionResourceStates() method."); - } + DvpVerifyTextureState(*pTex, RESOURCE_STATE_RENDER_TARGET, "Setting render targets (DeviceContextD3D11Impl::SetRenderTargets)"); } #endif } @@ -1548,12 +1549,7 @@ namespace Diligent #ifdef DEVELOPMENT else if(Flags & SET_RENDER_TARGETS_FLAG_VERIFY_STATES) { - if (pTex->IsInKnownState() && !pTex->CheckState(RESOURCE_STATE_DEPTH_WRITE)) - { - LOG_ERROR_MESSAGE("Texture '", pTex->GetDesc().Name, "' being set as depth-stencil buffer is not transitioned to RESOURCE_STATE_DEPTH_WRITE state. " - "Actual texture state: ", GetResourceStateString(pTex->GetState()), ". " - "Use SET_RENDER_TARGETS_FLAG_TRANSITION_DEPTH flag or explicitly transition the resource using IDeviceContext::TransitionResourceStates() method."); - } + DvpVerifyTextureState(*pTex, RESOURCE_STATE_DEPTH_WRITE, "Setting depth-stencil buffer (DeviceContextD3D11Impl::SetRenderTargets)"); } #endif } -- cgit v1.2.3