From 3494f0538a108730f9bb25d79416136d2b329af4 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 25 Nov 2018 12:08:42 -0800 Subject: Renamed/moved IBuffer::Map() to IDeviceContext::MapBuffer() Renamed/moved IBuffer::Unmap() to IDeviceContext::UnmapBuffer() Closed https://github.com/DiligentGraphics/DiligentCore/issues/30 (Removed map type, map flag parameters from IBuffer::Unmap function) --- .../GraphicsEngineD3D11/include/BufferD3D11Impl.h | 2 -- .../include/DeviceContextD3D11Impl.h | 4 ++++ .../GraphicsEngineD3D11/src/BufferD3D11Impl.cpp | 24 ---------------------- .../src/DeviceContextD3D11Impl.cpp | 22 ++++++++++++++++++++ 4 files changed, 26 insertions(+), 26 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.h index 93aaa715..e5420763 100644 --- a/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.h @@ -60,8 +60,6 @@ public: virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; - virtual void Map( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData )override final; - virtual void Unmap( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags )override final; virtual ID3D11Buffer* GetD3D11Buffer()override final{ return m_pd3d11Buffer; } virtual void* GetNativeHandle()override final { return GetD3D11Buffer(); } diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h index 206af852..4a8a0fb1 100755 --- a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h @@ -90,6 +90,10 @@ public: virtual void CopyBuffer(IBuffer *pSrcBuffer, Uint32 SrcOffset, IBuffer *pDstBuffer, Uint32 DstOffset, Uint32 Size)override final; + virtual void MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, Uint32 MapFlags, PVoid& pMappedData)override final; + + 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 CopyTexture(ITexture* pSrcTexture, diff --git a/Graphics/GraphicsEngineD3D11/src/BufferD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/BufferD3D11Impl.cpp index b2af447b..eaa44cd1 100644 --- a/Graphics/GraphicsEngineD3D11/src/BufferD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/BufferD3D11Impl.cpp @@ -178,30 +178,6 @@ BufferD3D11Impl :: ~BufferD3D11Impl() IMPLEMENT_QUERY_INTERFACE( BufferD3D11Impl, IID_BufferD3D11, TBufferBase ) -void BufferD3D11Impl :: Map(IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid& pMappedData) -{ - TBufferBase::Map( pContext, MapType, MapFlags, pMappedData ); - - auto *pd3d11DeviceContext = static_cast(pContext)->GetD3D11DeviceContext(); - D3D11_MAP d3d11MapType = static_cast(0); - UINT d3d11MapFlags = 0; - MapParamsToD3D11MapParams(MapType, MapFlags, d3d11MapType, d3d11MapFlags); - - D3D11_MAPPED_SUBRESOURCE MappedBuff; - HRESULT hr = pd3d11DeviceContext->Map(m_pd3d11Buffer, 0, d3d11MapType, d3d11MapFlags, &MappedBuff); - - pMappedData = SUCCEEDED(hr) ? MappedBuff.pData : nullptr; - - VERIFY( pMappedData || (MapFlags & MAP_FLAG_DO_NOT_WAIT) && (hr == DXGI_ERROR_WAS_STILL_DRAWING), "Map failed" ); -} - -void BufferD3D11Impl::Unmap( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags ) -{ - TBufferBase::Unmap( pContext, MapType, MapFlags ); - - auto *pd3d11DeviceContext = static_cast(pContext)->GetD3D11DeviceContext(); - pd3d11DeviceContext->Unmap(m_pd3d11Buffer, 0); -} void BufferD3D11Impl::CreateViewInternal( const BufferViewDesc& OrigViewDesc, IBufferView** ppView, bool bIsDefaultView ) { diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index 03bf0795..bf8845b3 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -973,6 +973,28 @@ namespace Diligent } + void DeviceContextD3D11Impl::MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, Uint32 MapFlags, PVoid& pMappedData) + { + TDeviceContextBase::MapBuffer(pBuffer, MapType, MapFlags, pMappedData); + + auto* pBufferD3D11 = ValidatedCast(pBuffer); + D3D11_MAP d3d11MapType = static_cast(0); + UINT d3d11MapFlags = 0; + MapParamsToD3D11MapParams(MapType, MapFlags, d3d11MapType, d3d11MapFlags); + + D3D11_MAPPED_SUBRESOURCE MappedBuff; + HRESULT hr = m_pd3d11DeviceContext->Map(pBufferD3D11->m_pd3d11Buffer, 0, d3d11MapType, d3d11MapFlags, &MappedBuff); + DEV_CHECK_ERR(SUCCEEDED(hr), "Failed to map buffer '", pBufferD3D11->GetDesc().Name, "'"); + pMappedData = SUCCEEDED(hr) ? MappedBuff.pData : nullptr; + } + + void DeviceContextD3D11Impl::UnmapBuffer(IBuffer* pBuffer) + { + TDeviceContextBase::UnmapBuffer(pBuffer); + auto* pBufferD3D11 = ValidatedCast(pBuffer); + m_pd3d11DeviceContext->Unmap(pBufferD3D11->m_pd3d11Buffer, 0); + } + void DeviceContextD3D11Impl::UpdateTexture(ITexture* pTexture, Uint32 MipLevel, Uint32 Slice, -- cgit v1.2.3