From 590c98bfe02f1758f3828b8e3cc813c0dbee654e Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 1 Sep 2018 12:02:31 -0700 Subject: Updated texture map/unmap intererface; implemented texture mapping in D3D12 --- Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h | 11 +++++++++-- Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp | 16 ++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h b/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h index 1284c52e..662220a4 100644 --- a/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h +++ b/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h @@ -65,8 +65,15 @@ public: virtual void UpdateData( IDeviceContext *pContext, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData )override final; //virtual void CopyData(CTexture *pSrcTexture, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size); - virtual void Map( IDeviceContext *pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags, MappedTextureSubresource &MappedData )override final; - virtual void Unmap( IDeviceContext *pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags )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; } diff --git a/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp index 625b6668..e672cf86 100644 --- a/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp @@ -213,15 +213,22 @@ void TextureBaseD3D11 :: CopyData(IDeviceContext* pContext, pd3d11DeviceContext->CopySubresourceRegion(m_pd3d11Texture, DstSubRes, DstX, DstY, DstZ, pSrTextureBaseD3D11->GetD3D11Texture(), SrcSubRes, pD3D11SrcBox); } -void TextureBaseD3D11 :: Map( IDeviceContext* pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags, MappedTextureSubresource& MappedData ) +void TextureBaseD3D11 :: Map(IDeviceContext* pContext, + Uint32 MipLevel, + Uint32 ArraySlice, + MAP_TYPE MapType, + Uint32 MapFlags, + const Box* pMapRegion, + MappedTextureSubresource& MappedData) { - TTextureBase::Map( pContext, Subresource, MapType, MapFlags, 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) ) @@ -237,11 +244,12 @@ void TextureBaseD3D11 :: Map( IDeviceContext* pContext, Uint32 Subresource, MAP_ } } -void TextureBaseD3D11::Unmap( IDeviceContext* pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags ) +void TextureBaseD3D11::Unmap( IDeviceContext* pContext, Uint32 MipLevel, Uint32 ArraySlice) { - TTextureBase::Unmap( pContext, Subresource, MapType, MapFlags ); + 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