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() --- .../GraphicsEngine/include/DeviceContextBase.h | 35 ++++++++++++++++++++++ Graphics/GraphicsEngine/include/TextureBase.h | 30 ------------------- Graphics/GraphicsEngine/interface/DeviceContext.h | 25 ++++++++++++++++ Graphics/GraphicsEngine/interface/Texture.h | 24 --------------- 4 files changed, 60 insertions(+), 54 deletions(-) (limited to 'Graphics/GraphicsEngine') diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.h b/Graphics/GraphicsEngine/include/DeviceContextBase.h index 1345702b..d80eca83 100644 --- a/Graphics/GraphicsEngine/include/DeviceContextBase.h +++ b/Graphics/GraphicsEngine/include/DeviceContextBase.h @@ -130,6 +130,18 @@ public: Uint32 DstY, Uint32 DstZ )override = 0; + /// Base implementaiton of IDeviceContext::MapTextureSubresource() + virtual void MapTextureSubresource(ITexture* pTexture, + Uint32 MipLevel, + Uint32 ArraySlice, + MAP_TYPE MapType, + Uint32 MapFlags, + const Box* pMapRegion, + MappedTextureSubresource& MappedData)override = 0; + + /// Base implementaiton of IDeviceContext::UnmapTextureSubresource() + virtual void UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice)override = 0; + /// Sets the strong pointer to the swap chain virtual void SetSwapChain( ISwapChain* pSwapChain )override final { m_pSwapChain = pSwapChain; } @@ -702,6 +714,29 @@ inline void DeviceContextBaseGetDesc(), DstMipLevel, DstSlice, DstX, DstY, DstZ ); } +template +inline void DeviceContextBase :: + MapTextureSubresource(ITexture* pTexture, + Uint32 MipLevel, + Uint32 ArraySlice, + MAP_TYPE MapType, + Uint32 MapFlags, + const Box* pMapRegion, + MappedTextureSubresource& MappedData) +{ + VERIFY(pTexture, "pTexture must not be null"); + ValidateMapTextureParams(pTexture->GetDesc(), MipLevel, ArraySlice, MapType, MapFlags, pMapRegion); +} + +template +inline void DeviceContextBase :: + UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice) +{ + VERIFY(pTexture, "pTexture must not be null"); + DEV_CHECK_ERR(MipLevel < pTexture->GetDesc().MipLevels, "Mip level is out of range"); + DEV_CHECK_ERR(ArraySlice < pTexture->GetDesc().ArraySize, "Array slice is out of range"); +} + #ifdef DEVELOPMENT template diff --git a/Graphics/GraphicsEngine/include/TextureBase.h b/Graphics/GraphicsEngine/include/TextureBase.h index 08598346..1a9e11c1 100644 --- a/Graphics/GraphicsEngine/include/TextureBase.h +++ b/Graphics/GraphicsEngine/include/TextureBase.h @@ -141,18 +141,6 @@ public: CreateViewInternal( ViewDesc, ppView, false ); } - /// Base implementaiton of ITexture::Map() - virtual void Map(IDeviceContext* pContext, - Uint32 MipLevel, - Uint32 ArraySlice, - MAP_TYPE MapType, - Uint32 MapFlags, - const Box* pMapRegion, - MappedTextureSubresource& MappedData)override = 0; - - /// Base implementaiton of ITexture::Unmap() - virtual void Unmap( IDeviceContext* pContext, Uint32 MipLevel, Uint32 ArraySlice)override = 0; - /// Creates default texture views. /// @@ -487,22 +475,4 @@ void TextureBase -void TextureBase :: Map( - IDeviceContext* pContext, - Uint32 MipLevel, - Uint32 ArraySlice, - MAP_TYPE MapType, - Uint32 MapFlags, - const Box* pMapRegion, - MappedTextureSubresource& MappedData) -{ - ValidateMapTextureParams(this->GetDesc(), MipLevel, ArraySlice, MapType, MapFlags, pMapRegion); -} - -template -void TextureBase :: Unmap(IDeviceContext* pContext, Uint32 MipLevel, Uint32 ArraySlice) -{ -} - } diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h index d1bcc4ff..f8f9adb1 100644 --- a/Graphics/GraphicsEngine/interface/DeviceContext.h +++ b/Graphics/GraphicsEngine/interface/DeviceContext.h @@ -582,6 +582,31 @@ public: Uint32 DstZ) = 0; + /// Maps the texture subresource + + /// \param [in] pTexture - Pointer to the texture to map. + /// \param [in] MipLevel - Mip level to map. + /// \param [in] ArraySlice - Array slice to map. This parameter must be 0 for non-array textures. + /// \param [in] MapType - Type of the map operation. See Diligent::MAP_TYPE. + /// \param [in] MapFlags - Special map flags. See Diligent::MAP_FLAGS. + /// \param [in] pMapRegion - Texture region to map. If this parameter is null, the entire subresource is mapped. + /// \param [out] MappedData - Mapped texture region data + /// + /// \remarks This method is supported in D3D11, D3D12 and Vulkan backends. In D3D11 backend, only the entire + /// subresource can be mapped, so pMapRegion must either be null, or cover the entire subresource. + /// In D3D11 and Vulkan backends, dynamic textures are no different from non-dynamic textures, and mapping + /// with MAP_FLAG_DISCARD has exactly the same behavior + virtual void MapTextureSubresource( ITexture* pTexture, + Uint32 MipLevel, + Uint32 ArraySlice, + MAP_TYPE MapType, + Uint32 MapFlags, + const Box* pMapRegion, + MappedTextureSubresource& MappedData ) = 0; + + /// Unmaps the texture subresource + virtual void UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice) = 0; + /// Sets the swap chain in the device context /// The swap chain is used by the device context to work with the diff --git a/Graphics/GraphicsEngine/interface/Texture.h b/Graphics/GraphicsEngine/interface/Texture.h index ff7688d7..b8c84409 100644 --- a/Graphics/GraphicsEngine/interface/Texture.h +++ b/Graphics/GraphicsEngine/interface/Texture.h @@ -304,30 +304,6 @@ public: /// Release() must *NOT* be called. virtual ITextureView* GetDefaultView( TEXTURE_VIEW_TYPE ViewType ) = 0; - /// Map the texture - - /// \param [in] pContext - Pointer to the device context interface to be used to perform the operation. - /// \param [in] MipLevel - Mip level to map. - /// \param [in] ArraySlice - Array slice to map. This parameter must be 0 for non-array textures. - /// \param [in] MapType - Type of the map operation. See Diligent::MAP_TYPE. - /// \param [in] MapFlags - Special map flags. See Diligent::MAP_FLAGS. - /// \param [in] pMapRegion - Texture region to map. If this parameter is null, the entire subresource is mapped. - /// \param [out] MappedData - Mapped texture region data - /// - /// \remarks This method is supported in D3D11, D3D12 and Vulkan backends. In D3D11 backend, only the entire - /// subresource can be mapped, so pMapRegion must either be null, or cover the entire subresource. - /// In D3D11 and Vulkan backends, dynamic textures are no different from non-dynamic textures, and mapping - /// with MAP_FLAG_DISCARD has exactly the same behavior - virtual void Map( IDeviceContext* pContext, - Uint32 MipLevel, - Uint32 ArraySlice, - MAP_TYPE MapType, - Uint32 MapFlags, - const Box* pMapRegion, - MappedTextureSubresource& MappedData ) = 0; - - /// Unmap the textute - virtual void Unmap(IDeviceContext *pContext, Uint32 MipLevel, Uint32 ArraySlice) = 0; /// Returns native texture handle specific to the underlying graphics API -- cgit v1.2.3