From 17b24246757390d29be93ce3447745e7b4936f5a Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 24 Nov 2018 20:31:42 -0800 Subject: Renamed/moved ITexture::Map() to IDeviceContext::MapTextureSubresource() Renamed/moved ITexture::Unmap() to IDeviceContext::UnmapTextureSubresource() --- .../include/DeviceContextD3D11Impl.h | 11 ++++++ .../GraphicsEngineD3D11/include/TextureBaseD3D11.h | 10 ----- .../src/DeviceContextD3D11Impl.cpp | 43 ++++++++++++++++++++++ .../GraphicsEngineD3D11/src/TextureBaseD3D11.cpp | 41 --------------------- 4 files changed, 54 insertions(+), 51 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h index 4cacc4cc..2daacb70 100755 --- a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h @@ -103,6 +103,17 @@ public: Uint32 DstY, Uint32 DstZ)override final; + virtual void MapTextureSubresource( ITexture* pTexture, + Uint32 MipLevel, + Uint32 ArraySlice, + MAP_TYPE MapType, + Uint32 MapFlags, + const Box* pMapRegion, + MappedTextureSubresource& MappedData )override final; + + + virtual void UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice)override final; + virtual void FinishFrame()override final; virtual void TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers)override final; diff --git a/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h b/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h index 5330766f..0e4e20bf 100644 --- a/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h +++ b/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h @@ -52,16 +52,6 @@ public: virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; - virtual void Map( IDeviceContext* pContext, - Uint32 MipLevel, - Uint32 ArraySlice, - MAP_TYPE MapType, - Uint32 MapFlags, - const Box* pMapRegion, - MappedTextureSubresource& MappedData )override final; - - virtual void Unmap(IDeviceContext *pContext, Uint32 MipLevel, Uint32 ArraySlice)override final; - virtual ID3D11Resource* GetD3D11Texture()override final{ return m_pd3d11Texture; } virtual void* GetNativeHandle()override final { return GetD3D11Texture(); } diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index 51ea643d..0a933d58 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -1050,6 +1050,49 @@ namespace Diligent } + void DeviceContextD3D11Impl::MapTextureSubresource( ITexture* pTexture, + Uint32 MipLevel, + Uint32 ArraySlice, + MAP_TYPE MapType, + Uint32 MapFlags, + const Box* pMapRegion, + MappedTextureSubresource& MappedData ) + { + TDeviceContextBase::MapTextureSubresource(pTexture, MipLevel, ArraySlice, MapType, MapFlags, pMapRegion, MappedData); + + auto* pTexD3D11 = ValidatedCast(pTexture); + const auto& TexDesc = pTexD3D11->GetDesc(); + D3D11_MAP d3d11MapType = static_cast(0); + UINT d3d11MapFlags = 0; + MapParamsToD3D11MapParams(MapType, MapFlags, d3d11MapType, d3d11MapFlags); + + auto Subresource = D3D11CalcSubresource(MipLevel, ArraySlice, TexDesc.MipLevels); + D3D11_MAPPED_SUBRESOURCE MappedTex; + auto hr = m_pd3d11DeviceContext->Map(pTexD3D11->GetD3D11Texture(), Subresource, d3d11MapType, d3d11MapFlags, &MappedTex); + if( FAILED(hr) ) + { + VERIFY_EXPR( hr == DXGI_ERROR_WAS_STILL_DRAWING ); + MappedData = MappedTextureSubresource(); + } + else + { + MappedData.pData = MappedTex.pData; + MappedData.Stride = MappedTex.RowPitch; + MappedData.DepthStride = MappedTex.DepthPitch; + } + } + + void DeviceContextD3D11Impl::UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice) + { + TDeviceContextBase::UnmapTextureSubresource( pTexture, MipLevel, ArraySlice); + + auto* pTexD3D11 = ValidatedCast(pTexture); + const auto& TexDesc = pTexD3D11->GetDesc(); + auto Subresource = D3D11CalcSubresource(MipLevel, ArraySlice, TexDesc.MipLevels); + m_pd3d11DeviceContext->Unmap(pTexD3D11->GetD3D11Texture(), Subresource); + } + + void DeviceContextD3D11Impl::FinishFrame() { } diff --git a/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp index 1250d090..7928d919 100644 --- a/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp @@ -142,49 +142,8 @@ void TextureBaseD3D11 :: PrepareD3D11InitData(const TextureData& InitData, Uint3 } } - TextureBaseD3D11 :: ~TextureBaseD3D11() { } -void TextureBaseD3D11 :: Map(IDeviceContext* pContext, - Uint32 MipLevel, - Uint32 ArraySlice, - MAP_TYPE MapType, - Uint32 MapFlags, - const Box* pMapRegion, - MappedTextureSubresource& MappedData) -{ - TTextureBase::Map(pContext, MipLevel, ArraySlice, MapType, MapFlags, pMapRegion, MappedData); - - auto* pd3d11DeviceContext = static_cast(pContext)->GetD3D11DeviceContext(); - D3D11_MAP d3d11MapType = static_cast(0); - UINT d3d11MapFlags = 0; - MapParamsToD3D11MapParams(MapType, MapFlags, d3d11MapType, d3d11MapFlags); - - auto Subresource = D3D11CalcSubresource(MipLevel, ArraySlice, m_Desc.MipLevels); - D3D11_MAPPED_SUBRESOURCE MappedTex; - auto hr = pd3d11DeviceContext->Map(m_pd3d11Texture, Subresource, d3d11MapType, d3d11MapFlags, &MappedTex); - if( FAILED(hr) ) - { - VERIFY_EXPR( hr == DXGI_ERROR_WAS_STILL_DRAWING ); - MappedData = MappedTextureSubresource(); - } - else - { - MappedData.pData = MappedTex.pData; - MappedData.Stride = MappedTex.RowPitch; - MappedData.DepthStride = MappedTex.DepthPitch; - } -} - -void TextureBaseD3D11::Unmap( IDeviceContext* pContext, Uint32 MipLevel, Uint32 ArraySlice) -{ - TTextureBase::Unmap( pContext, MipLevel, ArraySlice); - - auto* pd3d11DeviceContext = static_cast(pContext)->GetD3D11DeviceContext(); - auto Subresource = D3D11CalcSubresource(MipLevel, ArraySlice, m_Desc.MipLevels); - pd3d11DeviceContext->Unmap(m_pd3d11Texture, Subresource); -} - } -- cgit v1.2.3