summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-11-24 22:11:02 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-11-24 22:11:02 +0000
commit61bfee05db60a67fb8be6e72b27ba6724f0dd277 (patch)
treeb4595056fc881ccbca6fd50c7163d4df1cf54f19 /Graphics/GraphicsEngine
parentUpdated debug message about required shader resource binding object (diff)
downloadDiligentCore-61bfee05db60a67fb8be6e72b27ba6724f0dd277.tar.gz
DiligentCore-61bfee05db60a67fb8be6e72b27ba6724f0dd277.zip
Moved/renamed `IBuffer::UpdateData()` to `IDeviceContext::UpdateBuffer()`
Moved/renamed `IBuffer::CopyData()` to `IDeviceContext::CopyBuffer()`
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/BufferBase.h21
-rw-r--r--Graphics/GraphicsEngine/include/DeviceContextBase.h31
-rw-r--r--Graphics/GraphicsEngine/interface/Buffer.h20
-rw-r--r--Graphics/GraphicsEngine/interface/DeviceContext.h20
4 files changed, 51 insertions, 41 deletions
diff --git a/Graphics/GraphicsEngine/include/BufferBase.h b/Graphics/GraphicsEngine/include/BufferBase.h
index 93f752ef..f2414c82 100644
--- a/Graphics/GraphicsEngine/include/BufferBase.h
+++ b/Graphics/GraphicsEngine/include/BufferBase.h
@@ -113,12 +113,6 @@ public:
IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_Buffer, TDeviceObjectBase )
- /// Base implementation of IBuffer::UpdateData(); validates input parameters.
- virtual void UpdateData( IDeviceContext* pContext, Uint32 Offset, Uint32 Size, const PVoid pData )override = 0;
-
- /// Base implementation of IBuffer::CopyData(); validates input parameters.
- virtual void CopyData( IDeviceContext* pContext, IBuffer* pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size )override = 0;
-
/// Base implementation of IBuffer::Map(); validates input parameters.
virtual void Map( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid& pMappedData )override;
@@ -184,21 +178,6 @@ protected:
std::unique_ptr<BufferViewImplType, STDDeleter<BufferViewImplType, TBuffViewObjAllocator> > m_pDefaultSRV;
};
-template<class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator>
-void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator> :: UpdateData( IDeviceContext* pContext, Uint32 Offset, Uint32 Size, const PVoid pData )
-{
- VERIFY_BUFFER( this->m_Desc.Usage == USAGE_DEFAULT, "Only default usage buffers can be updated with UpdateData()" );
- VERIFY_BUFFER( Offset < this->m_Desc.uiSizeInBytes, "Offset (", Offset, ") exceeds the buffer size (", this->m_Desc.uiSizeInBytes, ")" );
- VERIFY_BUFFER( Size + Offset <= this->m_Desc.uiSizeInBytes, "Update region [", Offset, ",", Size + Offset, ") is out of buffer bounds [0,",this->m_Desc.uiSizeInBytes,")" );
-}
-
-template<class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator>
-void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator> :: CopyData( IDeviceContext* pContext, IBuffer* pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size )
-{
- VERIFY_BUFFER( DstOffset + Size <= this->m_Desc.uiSizeInBytes, "Destination range [", DstOffset, ",", DstOffset + Size, ") is out of buffer bounds [0,",this->m_Desc.uiSizeInBytes,")" );
- VERIFY_BUFFER( SrcOffset + Size <= pSrcBuffer->GetDesc().uiSizeInBytes, "Source range [", SrcOffset, ",", SrcOffset + Size, ") is out of buffer bounds [0,",this->m_Desc.uiSizeInBytes,")" );
-}
-
template<class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator>
void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator> :: Map( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid& pMappedData )
diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.h b/Graphics/GraphicsEngine/include/DeviceContextBase.h
index 23861605..d3afa0f3 100644
--- a/Graphics/GraphicsEngine/include/DeviceContextBase.h
+++ b/Graphics/GraphicsEngine/include/DeviceContextBase.h
@@ -108,6 +108,12 @@ public:
/// from the cached value and false otherwise.
inline bool SetRenderTargets( Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil, Uint32 Dummy = 0 );
+ /// Base implementation of IDeviceContext::UpdateBuffer(); validates input parameters.
+ virtual void UpdateBuffer(IBuffer *pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData)override = 0;
+
+ /// Base implementation of IDeviceContext::CopyBuffer(); validates input parameters.
+ virtual void CopyBuffer(IBuffer *pSrcBuffer, IBuffer *pDstBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size)override = 0;
+
/// Sets the strong pointer to the swap chain
virtual void SetSwapChain( ISwapChain* pSwapChain )override final { m_pSwapChain = pSwapChain; }
@@ -627,6 +633,29 @@ inline void DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType
m_pBoundDepthStencil.Release();
}
+
+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)
+{
+ VERIFY(pBuffer != nullptr, "Buffer must not be null");
+ const auto& BuffDesc = ValidatedCast<BufferImplType>(pBuffer)->GetDesc();
+ DEV_CHECK_ERR(BuffDesc.Usage == USAGE_DEFAULT, "Unable to update buffer '", BuffDesc.Name, "': only USAGE_DEFAULT buffers can be updated with UpdateData()");
+ DEV_CHECK_ERR(Offset < BuffDesc.uiSizeInBytes, "Unable to update buffer '", BuffDesc.Name, "': offset (", Offset, ") exceeds the buffer size (", BuffDesc.uiSizeInBytes, ")" );
+ DEV_CHECK_ERR(Size + Offset <= BuffDesc.uiSizeInBytes, "Unable to update buffer '", BuffDesc.Name, "': Update region [", Offset, ",", Size + Offset, ") is out of buffer bounds [0,", BuffDesc.uiSizeInBytes, ")" );
+}
+
+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)
+{
+ VERIFY(pSrcBuffer != nullptr, "Source buffer must not be null");
+ VERIFY(pDstBuffer != nullptr, "Destination buffer must not be null");
+ const auto& SrcBufferDesc = ValidatedCast<BufferImplType>(pSrcBuffer)->GetDesc();
+ const auto& DstBufferDesc = ValidatedCast<BufferImplType>(pDstBuffer)->GetDesc();
+ DEV_CHECK_ERR( DstOffset + Size <= DstBufferDesc.uiSizeInBytes, "Failed to copy buffer '", SrcBufferDesc.Name, "' to '", DstBufferDesc.Name, "': Destination range [", DstOffset, ",", DstOffset + Size, ") is out of buffer bounds [0,", DstBufferDesc.uiSizeInBytes, ")" );
+ DEV_CHECK_ERR( SrcOffset + Size <= SrcBufferDesc.uiSizeInBytes, "Failed to copy buffer '", SrcBufferDesc.Name, "' to '", DstBufferDesc.Name, "': Source range [", SrcOffset, ",", SrcOffset + Size, ") is out of buffer bounds [0,", SrcBufferDesc.uiSizeInBytes, ")" );
+}
+
+
#ifdef DEVELOPMENT
template<typename BaseInterface, typename BufferImplType, typename TextureViewImplType, typename PipelineStateImplType>
inline bool DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType, PipelineStateImplType> :: DvpVerifyDrawArguments(const DrawAttribs& drawAttribs)
@@ -739,7 +768,7 @@ void DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType, Pipel
}
}
-#endif
+#endif // DEVELOPMENT
}
diff --git a/Graphics/GraphicsEngine/interface/Buffer.h b/Graphics/GraphicsEngine/interface/Buffer.h
index 6be6b2c6..3f7d5ad6 100644
--- a/Graphics/GraphicsEngine/interface/Buffer.h
+++ b/Graphics/GraphicsEngine/interface/Buffer.h
@@ -153,31 +153,13 @@ public:
/// Returns the buffer description used to create the object
virtual const BufferDesc& GetDesc()const = 0;
- /// Updates the data in the buffer
-
- /// \param [in] pContext - Pointer to the device context interface to be used to perform the operation.
- /// \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 store in the buffer.
- virtual void UpdateData( class IDeviceContext *pContext, Uint32 Offset, Uint32 Size, const PVoid pData) = 0;
-
- /// Copies the data from other buffer
-
- /// \param [in] pContext - Pointer to the device context interface to be used to perform the operation.
- /// \param [in] pSrcBuffer - Source buffer to copy data from.
- /// \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 CopyData( IDeviceContext *pContext, IBuffer *pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size ) = 0;
-
/// Maps the buffer
/// \param [in] pContext - Pointer to the device context interface to be used to perform the operation.
/// \param [in] MapType - Type of the map operation. See Diligent::MAP_TYPE.
/// \param [in] MapFlags - Special map flags. See Diligent::MAP_FLAGS.
/// \param [out] pMappedData - Reference to the void pointer to store the address of the mapped region.
- virtual void Map( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData ) = 0;
+ virtual void Map( class IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData ) = 0;
/// Unmaps the previously mapped buffer
/// \param [in] pContext - Pointer to the device context interface to be used to perform the operation.
diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h
index 62adfd72..8e97e86a 100644
--- a/Graphics/GraphicsEngine/interface/DeviceContext.h
+++ b/Graphics/GraphicsEngine/interface/DeviceContext.h
@@ -526,6 +526,26 @@ public:
/// Flushes the command buffer
virtual void Flush() = 0;
+
+ /// Updates the data in the buffer
+
+ /// \param [in] pBuffer - Pointer to the buffer to updates.
+ /// \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;
+
+ /// 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] 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;
+
+
/// Sets the swap chain in the device context
/// The swap chain is used by the device context to work with the