diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-11-24 23:45:15 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-11-24 23:45:15 +0000 |
| commit | df67308c3b1236ff4c9445a17393f665e1ddd452 (patch) | |
| tree | d7f21995a5154546234865764111da6a90cceee8 /Graphics/GraphicsEngine | |
| parent | Moved/renamed `IBuffer::UpdateData()` to `IDeviceContext::UpdateBuffer()` (diff) | |
| download | DiligentCore-df67308c3b1236ff4c9445a17393f665e1ddd452.tar.gz DiligentCore-df67308c3b1236ff4c9445a17393f665e1ddd452.zip | |
Renamed/moved ITexture::UpdateData() to IDeviceContext::UpdateTexture()
Renamed/moved IBuffer::CopyData() to IDeviceContext::CopyTexture()
Diffstat (limited to 'Graphics/GraphicsEngine')
| -rw-r--r-- | Graphics/GraphicsEngine/include/DeviceContextBase.h | 60 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/include/TextureBase.h | 49 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/DeviceContext.h | 42 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/Texture.h | 37 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/src/Texture.cpp | 4 |
5 files changed, 102 insertions, 90 deletions
diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.h b/Graphics/GraphicsEngine/include/DeviceContextBase.h index d3afa0f3..fb9eef55 100644 --- a/Graphics/GraphicsEngine/include/DeviceContextBase.h +++ b/Graphics/GraphicsEngine/include/DeviceContextBase.h @@ -36,6 +36,7 @@ #include "SwapChain.h" #include "ValidatedCast.h" #include "GraphicsAccessories.h" +#include "TextureBase.h" namespace Diligent { @@ -114,6 +115,22 @@ public: /// Base implementation of IDeviceContext::CopyBuffer(); validates input parameters. virtual void CopyBuffer(IBuffer *pSrcBuffer, IBuffer *pDstBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size)override = 0; + /// Base implementaiton of IDeviceContext::UpdateData(); validates input parameters + virtual void UpdateTexture( ITexture* pTexture, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData )override = 0; + + /// Base implementaiton of IDeviceContext::CopyTexture(); validates input parameters + virtual void CopyTexture( ITexture* pSrcTexture, + Uint32 SrcMipLevel, + Uint32 SrcSlice, + const Box *pSrcBox, + ITexture* pDstTexture, + Uint32 DstMipLevel, + Uint32 DstSlice, + Uint32 DstX, + Uint32 DstY, + Uint32 DstZ )override = 0; + + /// Sets the strong pointer to the swap chain virtual void SetSwapChain( ISwapChain* pSwapChain )override final { m_pSwapChain = pSwapChain; } @@ -635,7 +652,8 @@ inline void DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType template<typename BaseInterface, typename BufferImplType, typename TextureViewImplType, typename PipelineStateImplType> -inline void DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType, PipelineStateImplType> :: UpdateBuffer(IBuffer* pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData) +inline void DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType, PipelineStateImplType> :: + UpdateBuffer(IBuffer* pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData) { VERIFY(pBuffer != nullptr, "Buffer must not be null"); const auto& BuffDesc = ValidatedCast<BufferImplType>(pBuffer)->GetDesc(); @@ -645,7 +663,8 @@ inline void DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType } template<typename BaseInterface, typename BufferImplType, typename TextureViewImplType, typename PipelineStateImplType> -inline void DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType, PipelineStateImplType> :: CopyBuffer(IBuffer *pSrcBuffer, IBuffer *pDstBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size) +inline void DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType, PipelineStateImplType> :: + CopyBuffer(IBuffer *pSrcBuffer, IBuffer *pDstBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size) { VERIFY(pSrcBuffer != nullptr, "Source buffer must not be null"); VERIFY(pDstBuffer != nullptr, "Destination buffer must not be null"); @@ -656,9 +675,38 @@ inline void DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType } +template<typename BaseInterface, typename BufferImplType, typename TextureViewImplType, typename PipelineStateImplType> +inline void DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType, PipelineStateImplType> :: + UpdateTexture( ITexture* pTexture, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData ) +{ + VERIFY( pTexture != nullptr, "pTexture must not be null" ); + ValidateUpdateTextureParams( pTexture->GetDesc(), MipLevel, Slice, DstBox, SubresData ); +} + +template<typename BaseInterface, typename BufferImplType, typename TextureViewImplType, typename PipelineStateImplType> +inline void DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType, PipelineStateImplType> :: + CopyTexture( ITexture* pSrcTexture, + Uint32 SrcMipLevel, + Uint32 SrcSlice, + const Box* pSrcBox, + ITexture* pDstTexture, + Uint32 DstMipLevel, + Uint32 DstSlice, + Uint32 DstX, + Uint32 DstY, + Uint32 DstZ ) +{ + VERIFY( pSrcTexture, "pSrcTexture must not be null" ); + VERIFY( pDstTexture, "pSrcTexture must not be null" ); + ValidateCopyTextureParams( pSrcTexture->GetDesc(), SrcMipLevel, SrcSlice, pSrcBox, + pDstTexture->GetDesc(), DstMipLevel, DstSlice, DstX, DstY, DstZ ); +} + + #ifdef DEVELOPMENT template<typename BaseInterface, typename BufferImplType, typename TextureViewImplType, typename PipelineStateImplType> -inline bool DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType, PipelineStateImplType> :: DvpVerifyDrawArguments(const DrawAttribs& drawAttribs) +inline bool DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType, PipelineStateImplType> :: + DvpVerifyDrawArguments(const DrawAttribs& drawAttribs) { if (!m_pPipelineState) { @@ -694,7 +742,8 @@ inline bool DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType } template<typename BaseInterface, typename BufferImplType, typename TextureViewImplType, typename PipelineStateImplType> -inline bool DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType, PipelineStateImplType> :: DvpVerifyDispatchArguments(const DispatchComputeAttribs &DispatchAttrs) +inline bool DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType, PipelineStateImplType> :: + DvpVerifyDispatchArguments(const DispatchComputeAttribs& DispatchAttrs) { if (!m_pPipelineState) { @@ -724,7 +773,8 @@ inline bool DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType } template<typename BaseInterface, typename BufferImplType, typename TextureViewImplType, typename PipelineStateImplType> -void DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType, PipelineStateImplType> :: DvpVerifyStateTransitionDesc(const StateTransitionDesc& Barrier) +void DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType, PipelineStateImplType> :: + DvpVerifyStateTransitionDesc(const StateTransitionDesc& Barrier) { DEV_CHECK_ERR((Barrier.pTexture != nullptr) ^ (Barrier.pBuffer != nullptr), "Exactly one of pTexture or pBuffer members of StateTransitionDesc must not be null"); DEV_CHECK_ERR(Barrier.NewState != RESOURCE_STATE_UNKNOWN, "New resource state can't be unknown"); diff --git a/Graphics/GraphicsEngine/include/TextureBase.h b/Graphics/GraphicsEngine/include/TextureBase.h index 234f2f0e..08598346 100644 --- a/Graphics/GraphicsEngine/include/TextureBase.h +++ b/Graphics/GraphicsEngine/include/TextureBase.h @@ -37,10 +37,10 @@ namespace Diligent { void ValidateTextureDesc(const TextureDesc& TexDesc); -void ValidateUpdateDataParams( const TextureDesc &TexDesc, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData ); -void VliadateCopyTextureDataParams( const TextureDesc& SrcTexDesc, Uint32 SrcMipLevel, Uint32 SrcSlice, const Box* pSrcBox, - const TextureDesc& DstTexDesc, Uint32 DstMipLevel, Uint32 DstSlice, - Uint32 DstX, Uint32 DstY, Uint32 DstZ ); +void ValidateUpdateTextureParams( const TextureDesc &TexDesc, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData ); +void ValidateCopyTextureParams( const TextureDesc& SrcTexDesc, Uint32 SrcMipLevel, Uint32 SrcSlice, const Box* pSrcBox, + const TextureDesc& DstTexDesc, Uint32 DstMipLevel, Uint32 DstSlice, + Uint32 DstX, Uint32 DstY, Uint32 DstZ ); void ValidateMapTextureParams(const TextureDesc& TexDesc, Uint32 MipLevel, Uint32 ArraySlice, @@ -141,21 +141,6 @@ public: CreateViewInternal( ViewDesc, ppView, false ); } - /// Base implementaiton of ITexture::UpdateData(); validates input parameters - virtual void UpdateData( IDeviceContext* pContext, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData )override = 0; - - /// Base implementaiton of ITexture::CopyData(); validates input parameters - virtual void CopyData( IDeviceContext* pContext, - ITexture* pSrcTexture, - Uint32 SrcMipLevel, - Uint32 SrcSlice, - const Box *pSrcBox, - Uint32 DstMipLevel, - Uint32 DstSlice, - Uint32 DstX, - Uint32 DstY, - Uint32 DstZ )override = 0; - /// Base implementaiton of ITexture::Map() virtual void Map(IDeviceContext* pContext, Uint32 MipLevel, @@ -502,32 +487,6 @@ void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObj } } - -template<class BaseInterface, class TRenderDeviceImpl,class TTextureViewImpl, class TTexViewObjAllocator> -void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObjAllocator> :: UpdateData( IDeviceContext* pContext, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData ) -{ - ValidateUpdateDataParams( this->m_Desc, MipLevel, Slice, DstBox, SubresData ); -} - -template<class BaseInterface, class TRenderDeviceImpl,class TTextureViewImpl, class TTexViewObjAllocator> -void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObjAllocator> :: CopyData( - IDeviceContext* pContext, - ITexture* pSrcTexture, - Uint32 SrcMipLevel, - Uint32 SrcSlice, - const Box *pSrcBox, - Uint32 DstMipLevel, - Uint32 DstSlice, - Uint32 DstX, - Uint32 DstY, - Uint32 DstZ ) -{ - VERIFY( pContext, "pContext is null" ); - VERIFY( pSrcTexture, "pSrcTexture is null" ); - VliadateCopyTextureDataParams( pSrcTexture->GetDesc(), SrcMipLevel, SrcSlice, pSrcBox, - this->GetDesc(), DstMipLevel, DstSlice, DstX, DstY, DstZ ); -} - template<class BaseInterface, class TRenderDeviceImpl,class TTextureViewImpl, class TTexViewObjAllocator> void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObjAllocator> :: Map( IDeviceContext* pContext, diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h index 8e97e86a..fe35d44b 100644 --- a/Graphics/GraphicsEngine/interface/DeviceContext.h +++ b/Graphics/GraphicsEngine/interface/DeviceContext.h @@ -533,17 +533,53 @@ public: /// \param [in] Offset - Offset in bytes from the beginning of the buffer to the update region. /// \param [in] Size - Size in bytes of the data region to update. /// \param [in] pData - Pointer to the data to write to the buffer. - virtual void UpdateBuffer(IBuffer *pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData) = 0; + virtual void UpdateBuffer(IBuffer* pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData) = 0; /// Copies the data from one buffer to another /// \param [in] pSrcBuffer - Source buffer to copy data from. - /// \param [in] pSrcBuffer - Destination buffer to copy data to. + /// \param [in] pDstBuffer - Destination buffer to copy data to. /// \param [in] SrcOffset - Offset in bytes from the beginning of the source buffer to the beginning of data to copy. /// \param [in] DstOffset - Offset in bytes from the beginning of the destination buffer to the beginning /// of the destination region. /// \param [in] Size - Size in bytes of data to copy. - virtual void CopyBuffer(IBuffer *pSrcBuffer, IBuffer *pDstBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size) = 0; + virtual void CopyBuffer(IBuffer* pSrcBuffer, IBuffer* pDstBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size) = 0; + + + /// Updates the data in the texture + + /// \param [in] pTexture - Pointer to the device context interface to be used to perform the operation. + /// \param [in] MipLevel - Mip level of the texture subresource to update. + /// \param [in] Slice - Array slice. Should be 0 for non-array textures. + /// \param [in] DstBox - Destination region on the texture to update. + /// \param [in] SubresData - Source data to copy to the texture. + virtual void UpdateTexture(ITexture* pTexture, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData) = 0; + + /// Copies data from one texture to another + + /// \param [in] pSrcTexture - Source texture to copy data from + /// \param [in] SrcMipLevel - Mip level of the source texture to copy data from. + /// \param [in] SrcSlice - Array slice of the source texture to copy data from. + /// Should be 0 for non-array textures. + /// \param [in] pSrcBox - Source region to copy. + /// Use nullptr to copy the entire subresource. + /// \param [in] pDstTexture - Destination texture to copy data to + /// \param [in] DstMipLevel - Mip level to copy data to. + /// \param [in] DstSlice - Array slice to copy data to. + /// Must be 0 for non-array textures. + /// \param [in] DstX - X offset on the destination subresource + /// \param [in] DstY - Y offset on the destination subresource + /// \param [in] DstZ - Z offset on the destination subresource + virtual void CopyTexture(ITexture* pSrcTexture, + Uint32 SrcMipLevel, + Uint32 SrcSlice, + const Box *pSrcBox, + ITexture* pDstTexture, + Uint32 DstMipLevel, + Uint32 DstSlice, + Uint32 DstX, + Uint32 DstY, + Uint32 DstZ) = 0; /// Sets the swap chain in the device context diff --git a/Graphics/GraphicsEngine/interface/Texture.h b/Graphics/GraphicsEngine/interface/Texture.h index e6dd2e9b..ff7688d7 100644 --- a/Graphics/GraphicsEngine/interface/Texture.h +++ b/Graphics/GraphicsEngine/interface/Texture.h @@ -31,6 +31,8 @@ namespace Diligent { +class IDeviceContext; + // {A64B0E60-1B5E-4CFD-B880-663A1ADCBE98} static constexpr INTERFACE_ID IID_Texture = { 0xa64b0e60, 0x1b5e, 0x4cfd, { 0xb8, 0x80, 0x66, 0x3a, 0x1a, 0xdc, 0xbe, 0x98 } }; @@ -302,41 +304,6 @@ public: /// Release() must *NOT* be called. virtual ITextureView* GetDefaultView( TEXTURE_VIEW_TYPE ViewType ) = 0; - /// Updates the data in the texture - - /// \param [in] pContext - Pointer to the device context interface to be used to perform the operation. - /// \param [in] MipLevel - Mip level of the texture subresource to update. - /// \param [in] Slice - Array slice. Should be 0 for non-array textures. - /// \param [in] DstBox - Destination region on the texture to update. - /// \param [in] SubresData - Source data to copy to the texture. - virtual void UpdateData( class IDeviceContext *pContext, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData ) = 0; - - /// Copies data from another texture - - /// \param [in] pContext - Pointer to the device context interface to be used to perform the operation. - /// \param [in] pSrcTexture - Source texture for the copy operation - /// \param [in] SrcMipLevel - Mip level of the source texture to copy data from. - /// \param [in] SrcSlice - Array slice of the source texture to copy data from. - /// Should be 0 for non-array textures. - /// \param [in] pSrcBox - Source region to copy. - /// Use nullptr to copy the entire subresource. - /// \param [in] DstMipLevel - Mip level to copy data to. - /// \param [in] DstSlice - Array slice to copy data to. - /// Must be 0 for non-array textures. - /// \param [in] DstX - X offset on the destination subresource - /// \param [in] DstY - Y offset on the destination subresource - /// \param [in] DstZ - Z offset on the destination subresource - virtual void CopyData(IDeviceContext *pContext, - ITexture *pSrcTexture, - Uint32 SrcMipLevel, - Uint32 SrcSlice, - const Box *pSrcBox, - Uint32 DstMipLevel, - Uint32 DstSlice, - Uint32 DstX, - Uint32 DstY, - Uint32 DstZ) = 0; - /// Map the texture /// \param [in] pContext - Pointer to the device context interface to be used to perform the operation. diff --git a/Graphics/GraphicsEngine/src/Texture.cpp b/Graphics/GraphicsEngine/src/Texture.cpp index 62c66047..7276d956 100644 --- a/Graphics/GraphicsEngine/src/Texture.cpp +++ b/Graphics/GraphicsEngine/src/Texture.cpp @@ -176,7 +176,7 @@ void ValidateTextureRegion(const TextureDesc& TexDesc, Uint32 MipLevel, Uint32 S #endif } -void ValidateUpdateDataParams( const TextureDesc& TexDesc, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData ) +void ValidateUpdateTextureParams( const TextureDesc& TexDesc, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData ) { VERIFY((SubresData.pData != nullptr) ^ (SubresData.pSrcBuffer != nullptr), "Either CPU data pointer (pData) or GPU buffer (pSrcBuffer) must not be null, but not both"); ValidateTextureRegion(TexDesc, MipLevel, Slice, DstBox); @@ -214,7 +214,7 @@ void ValidateUpdateDataParams( const TextureDesc& TexDesc, Uint32 MipLevel, Uint #endif } -void VliadateCopyTextureDataParams( const TextureDesc &SrcTexDesc, Uint32 SrcMipLevel, Uint32 SrcSlice, const Box *pSrcBox, +void ValidateCopyTextureParams( const TextureDesc &SrcTexDesc, Uint32 SrcMipLevel, Uint32 SrcSlice, const Box *pSrcBox, const TextureDesc &DstTexDesc, Uint32 DstMipLevel, Uint32 DstSlice, Uint32 DstX, Uint32 DstY, Uint32 DstZ ) { |
