summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-11-23 19:48:42 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-11-23 19:48:42 +0000
commit77c5b1a0013d897db74a30431a5349f9ac64c309 (patch)
treee2b9d0f21acb592d1d4497b16be219caf3a5b9e8 /Graphics/GraphicsEngine
parentMerge branch 'master' (diff)
downloadDiligentCore-77c5b1a0013d897db74a30431a5349f9ac64c309.tar.gz
DiligentCore-77c5b1a0013d897db74a30431a5349f9ac64c309.zip
clang-formatted GraphicsEngine project
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/BufferBase.h145
-rw-r--r--Graphics/GraphicsEngine/include/BufferViewBase.h47
-rw-r--r--Graphics/GraphicsEngine/include/CommandListBase.h18
-rw-r--r--Graphics/GraphicsEngine/include/DefaultShaderSourceStreamFactory.h4
-rw-r--r--Graphics/GraphicsEngine/include/Defines.h1
-rw-r--r--Graphics/GraphicsEngine/include/DeviceContextBase.h704
-rw-r--r--Graphics/GraphicsEngine/include/DeviceObjectBase.h77
-rw-r--r--Graphics/GraphicsEngine/include/EngineFactoryBase.h43
-rw-r--r--Graphics/GraphicsEngine/include/EngineMemory.h26
-rw-r--r--Graphics/GraphicsEngine/include/FenceBase.h16
-rw-r--r--Graphics/GraphicsEngine/include/PipelineStateBase.h160
-rw-r--r--Graphics/GraphicsEngine/include/RenderDeviceBase.h483
-rw-r--r--Graphics/GraphicsEngine/include/ResourceMappingImpl.h138
-rw-r--r--Graphics/GraphicsEngine/include/SamplerBase.h22
-rw-r--r--Graphics/GraphicsEngine/include/ShaderBase.h24
-rw-r--r--Graphics/GraphicsEngine/include/ShaderResourceBindingBase.h33
-rw-r--r--Graphics/GraphicsEngine/include/ShaderResourceVariableBase.h142
-rw-r--r--Graphics/GraphicsEngine/include/StateObjectsRegistry.h306
-rw-r--r--Graphics/GraphicsEngine/include/SwapChainBase.h44
-rw-r--r--Graphics/GraphicsEngine/include/TextureBase.h377
-rw-r--r--Graphics/GraphicsEngine/include/TextureViewBase.h64
-rw-r--r--Graphics/GraphicsEngine/interface/APIInfo.h118
-rw-r--r--Graphics/GraphicsEngine/interface/BlendState.h92
-rw-r--r--Graphics/GraphicsEngine/interface/Buffer.h50
-rw-r--r--Graphics/GraphicsEngine/interface/BufferView.h28
-rw-r--r--Graphics/GraphicsEngine/interface/CommandList.h7
-rw-r--r--Graphics/GraphicsEngine/interface/Constants.h25
-rw-r--r--Graphics/GraphicsEngine/interface/DepthStencilState.h30
-rw-r--r--Graphics/GraphicsEngine/interface/DeviceCaps.h2
-rw-r--r--Graphics/GraphicsEngine/interface/DeviceContext.h50
-rw-r--r--Graphics/GraphicsEngine/interface/DeviceObject.h8
-rw-r--r--Graphics/GraphicsEngine/interface/EngineFactory.h8
-rw-r--r--Graphics/GraphicsEngine/interface/Fence.h11
-rw-r--r--Graphics/GraphicsEngine/interface/GraphicsTypes.h134
-rw-r--r--Graphics/GraphicsEngine/interface/InputLayout.h2
-rw-r--r--Graphics/GraphicsEngine/interface/MapHelper.h106
-rw-r--r--Graphics/GraphicsEngine/interface/PipelineState.h24
-rw-r--r--Graphics/GraphicsEngine/interface/RasterizerState.h20
-rw-r--r--Graphics/GraphicsEngine/interface/RenderDevice.h76
-rw-r--r--Graphics/GraphicsEngine/interface/ResourceMapping.h212
-rw-r--r--Graphics/GraphicsEngine/interface/Sampler.h38
-rw-r--r--Graphics/GraphicsEngine/interface/Shader.h102
-rw-r--r--Graphics/GraphicsEngine/interface/ShaderResourceBinding.h20
-rw-r--r--Graphics/GraphicsEngine/interface/ShaderResourceVariable.h18
-rw-r--r--Graphics/GraphicsEngine/interface/SwapChain.h19
-rw-r--r--Graphics/GraphicsEngine/interface/Texture.h54
-rw-r--r--Graphics/GraphicsEngine/interface/TextureView.h22
-rw-r--r--Graphics/GraphicsEngine/src/APIInfo.cpp4
-rw-r--r--Graphics/GraphicsEngine/src/DefaultShaderSourceStreamFactory.cpp52
-rw-r--r--Graphics/GraphicsEngine/src/EngineMemory.cpp7
-rw-r--r--Graphics/GraphicsEngine/src/ResourceMapping.cpp139
-rw-r--r--Graphics/GraphicsEngine/src/Texture.cpp195
52 files changed, 2330 insertions, 2217 deletions
diff --git a/Graphics/GraphicsEngine/include/BufferBase.h b/Graphics/GraphicsEngine/include/BufferBase.h
index d3e6a574..6ab6d43c 100644
--- a/Graphics/GraphicsEngine/include/BufferBase.h
+++ b/Graphics/GraphicsEngine/include/BufferBase.h
@@ -48,8 +48,8 @@ namespace Diligent
/// (Diligent::BufferViewD3D11Impl, Diligent::BufferViewD3D12Impl,
/// Diligent::BufferViewGLImpl or Diligent::BufferViewVkImpl)
/// \tparam TBuffViewObjAllocator - type of the allocator that is used to allocate memory for the buffer view object instances
-template<class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator>
-class BufferBase : public DeviceObjectBase <BaseInterface, RenderDeviceImplType, BufferDesc>
+template <class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator>
+class BufferBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, BufferDesc>
{
public:
using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, BufferDesc>;
@@ -57,23 +57,30 @@ public:
/// \param pRefCounters - reference counters object that controls the lifetime of this buffer.
/// \param BuffViewObjAllocator - allocator that is used to allocate memory for the buffer view instances.
/// This parameter is only used for debug purposes.
- /// \param pDevice - pointer to the device.
- /// \param BuffDesc - buffer description.
- /// \param bIsDeviceInternal - flag indicating if the buffer is an internal device object and
- /// must not keep a strong reference to the device.
- BufferBase( IReferenceCounters* pRefCounters,
- TBuffViewObjAllocator& BuffViewObjAllocator,
- RenderDeviceImplType* pDevice,
- const BufferDesc& BuffDesc,
- bool bIsDeviceInternal) :
- TDeviceObjectBase( pRefCounters, pDevice, BuffDesc, bIsDeviceInternal),
+ /// \param pDevice - pointer to the device.
+ /// \param BuffDesc - buffer description.
+ /// \param bIsDeviceInternal - flag indicating if the buffer is an internal device object and
+ /// must not keep a strong reference to the device.
+ BufferBase(IReferenceCounters* pRefCounters,
+ TBuffViewObjAllocator& BuffViewObjAllocator,
+ RenderDeviceImplType* pDevice,
+ const BufferDesc& BuffDesc,
+ bool bIsDeviceInternal) :
+ TDeviceObjectBase{pRefCounters, pDevice, BuffDesc, bIsDeviceInternal},
#ifdef _DEBUG
- m_dbgBuffViewAllocator(BuffViewObjAllocator),
+ m_dbgBuffViewAllocator{BuffViewObjAllocator},
#endif
- m_pDefaultUAV(nullptr, STDDeleter<BufferViewImplType, TBuffViewObjAllocator>(BuffViewObjAllocator) ),
- m_pDefaultSRV(nullptr, STDDeleter<BufferViewImplType, TBuffViewObjAllocator>(BuffViewObjAllocator) )
+ m_pDefaultUAV{nullptr, STDDeleter<BufferViewImplType, TBuffViewObjAllocator>(BuffViewObjAllocator)},
+ m_pDefaultSRV{nullptr, STDDeleter<BufferViewImplType, TBuffViewObjAllocator>(BuffViewObjAllocator)}
{
-# define VERIFY_BUFFER(Expr, ...) if (!(Expr)) LOG_ERROR_AND_THROW("Buffer '", this->m_Desc.Name ? this->m_Desc.Name : "", "': ", ##__VA_ARGS__)
+#define VERIFY_BUFFER(Expr, ...) \
+ do \
+ { \
+ if (!(Expr)) \
+ { \
+ LOG_ERROR_AND_THROW("Buffer '", this->m_Desc.Name ? this->m_Desc.Name : "", "': ", ##__VA_ARGS__); \
+ } \
+ } while (false)
Uint32 AllowedBindFlags =
BIND_VERTEX_BUFFER | BIND_INDEX_BUFFER | BIND_UNIFORM_BUFFER |
@@ -84,48 +91,47 @@ public:
"BIND_SHADER_RESOURCE (8), BIND_STREAM_OUTPUT (16), BIND_UNORDERED_ACCESS (128), "
"BIND_INDIRECT_DRAW_ARGS (256)";
- VERIFY_BUFFER( (BuffDesc.BindFlags & ~AllowedBindFlags) == 0, "Incorrect bind flags specified (", BuffDesc.BindFlags & ~AllowedBindFlags, "). Only the following flags are allowed:\n", strAllowedBindFlags );
-
- if( (this->m_Desc.BindFlags & BIND_UNORDERED_ACCESS) ||
- (this->m_Desc.BindFlags & BIND_SHADER_RESOURCE) )
+ VERIFY_BUFFER((BuffDesc.BindFlags & ~AllowedBindFlags) == 0, "Incorrect bind flags specified (", BuffDesc.BindFlags & ~AllowedBindFlags, "). Only the following flags are allowed:\n", strAllowedBindFlags);
+
+ if ((this->m_Desc.BindFlags & BIND_UNORDERED_ACCESS) ||
+ (this->m_Desc.BindFlags & BIND_SHADER_RESOURCE))
{
- VERIFY_BUFFER( this->m_Desc.Mode > BUFFER_MODE_UNDEFINED && this->m_Desc.Mode < BUFFER_MODE_NUM_MODES, GetBufferModeString(this->m_Desc.Mode), " is not a valid mode for a buffer created with BIND_SHADER_RESOURCE or BIND_UNORDERED_ACCESS flags" );
+ VERIFY_BUFFER(this->m_Desc.Mode > BUFFER_MODE_UNDEFINED && this->m_Desc.Mode < BUFFER_MODE_NUM_MODES, GetBufferModeString(this->m_Desc.Mode), " is not a valid mode for a buffer created with BIND_SHADER_RESOURCE or BIND_UNORDERED_ACCESS flags");
if (this->m_Desc.Mode == BUFFER_MODE_STRUCTURED || this->m_Desc.Mode == BUFFER_MODE_FORMATTED)
{
- VERIFY_BUFFER( this->m_Desc.ElementByteStride != 0, "Element stride must not be zero for structured and formatted buffers" );
+ VERIFY_BUFFER(this->m_Desc.ElementByteStride != 0, "Element stride must not be zero for structured and formatted buffers");
}
else if (this->m_Desc.Mode == BUFFER_MODE_RAW)
{
-
}
}
-# undef VERIFY_BUFFER
+#undef VERIFY_BUFFER
Uint64 DeviceQueuesMask = pDevice->GetCommandQueueMask();
- DEV_CHECK_ERR( (this->m_Desc.CommandQueueMask & DeviceQueuesMask) != 0, "No bits in the command queue mask (0x", std::hex, this->m_Desc.CommandQueueMask, ") correspond to one of ", pDevice->GetCommandQueueCount(), " available device command queues");
+ DEV_CHECK_ERR((this->m_Desc.CommandQueueMask & DeviceQueuesMask) != 0, "No bits in the command queue mask (0x", std::hex, this->m_Desc.CommandQueueMask, ") correspond to one of ", pDevice->GetCommandQueueCount(), " available device command queues");
this->m_Desc.CommandQueueMask &= DeviceQueuesMask;
}
- IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_Buffer, TDeviceObjectBase )
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_Buffer, TDeviceObjectBase)
/// Implementation of IBuffer::CreateView(); calls CreateViewInternal() virtual function
/// that creates buffer view for the specific engine implementation.
- virtual void CreateView( const struct BufferViewDesc& ViewDesc, IBufferView** ppView )override;
+ virtual void CreateView(const struct BufferViewDesc& ViewDesc, IBufferView** ppView) override;
/// Implementation of IBuffer::GetDefaultView().
- virtual IBufferView* GetDefaultView( BUFFER_VIEW_TYPE ViewType )override;
+ virtual IBufferView* GetDefaultView(BUFFER_VIEW_TYPE ViewType) override;
/// Creates default buffer views.
- ///
+ ///
/// - Creates default shader resource view addressing the entire buffer if Diligent::BIND_SHADER_RESOURCE flag is set
- /// - Creates default unordered access view addressing the entire buffer if Diligent::BIND_UNORDERED_ACCESS flag is set
+ /// - Creates default unordered access view addressing the entire buffer if Diligent::BIND_UNORDERED_ACCESS flag is set
///
/// The function calls CreateViewInternal().
void CreateDefaultViews();
- virtual void SetState(RESOURCE_STATE State)override final
+ virtual void SetState(RESOURCE_STATE State) override final
{
this->m_State = State;
}
@@ -135,25 +141,24 @@ public:
return this->m_State;
}
- bool IsInKnownState() const
+ bool IsInKnownState() const
{
return this->m_State != RESOURCE_STATE_UNKNOWN;
}
- bool CheckState(RESOURCE_STATE State)const
+ bool CheckState(RESOURCE_STATE State) const
{
- VERIFY((State & (State-1)) == 0, "Single state is expected");
+ VERIFY((State & (State - 1)) == 0, "Single state is expected");
VERIFY(IsInKnownState(), "Buffer state is unknown");
return (this->m_State & State) == State;
}
protected:
-
/// Pure virtual function that creates buffer view for the specific engine implementation.
- virtual void CreateViewInternal( const struct BufferViewDesc& ViewDesc, IBufferView **ppView, bool bIsDefaultView ) = 0;
+ virtual void CreateViewInternal(const struct BufferViewDesc& ViewDesc, IBufferView** ppView, bool bIsDefaultView) = 0;
/// Corrects buffer view description and validates view parameters.
- void CorrectBufferViewDesc( struct BufferViewDesc& ViewDesc );
+ void CorrectBufferViewDesc(struct BufferViewDesc& ViewDesc);
#ifdef _DEBUG
TBuffViewObjAllocator& m_dbgBuffViewAllocator;
@@ -162,17 +167,17 @@ protected:
RESOURCE_STATE m_State = RESOURCE_STATE_UNKNOWN;
/// Default UAV addressing the entire buffer
- std::unique_ptr<BufferViewImplType, STDDeleter<BufferViewImplType, TBuffViewObjAllocator> > m_pDefaultUAV;
+ std::unique_ptr<BufferViewImplType, STDDeleter<BufferViewImplType, TBuffViewObjAllocator>> m_pDefaultUAV;
/// Default SRV addressing the entire buffer
- std::unique_ptr<BufferViewImplType, STDDeleter<BufferViewImplType, TBuffViewObjAllocator> > m_pDefaultSRV;
+ std::unique_ptr<BufferViewImplType, STDDeleter<BufferViewImplType, TBuffViewObjAllocator>> m_pDefaultSRV;
};
-template<class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator>
-void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator> :: CreateView( const struct BufferViewDesc &ViewDesc, IBufferView **ppView )
+template <class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator>
+void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator>::CreateView(const struct BufferViewDesc& ViewDesc, IBufferView** ppView)
{
DEV_CHECK_ERR(ViewDesc.ViewType != BUFFER_VIEW_UNDEFINED, "Buffer view type is not specified");
if (ViewDesc.ViewType == BUFFER_VIEW_SHADER_RESOURCE)
@@ -182,30 +187,30 @@ void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffVi
else
UNEXPECTED("Unexpected buffer view type");
- CreateViewInternal( ViewDesc, ppView, false );
+ CreateViewInternal(ViewDesc, ppView, false);
}
-template<class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator>
-void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator> :: CorrectBufferViewDesc(struct BufferViewDesc& ViewDesc)
+template <class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator>
+void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator>::CorrectBufferViewDesc(struct BufferViewDesc& ViewDesc)
{
- if( ViewDesc.ByteWidth == 0 )
+ if (ViewDesc.ByteWidth == 0)
{
DEV_CHECK_ERR(this->m_Desc.uiSizeInBytes > ViewDesc.ByteOffset, "Byte offset (", ViewDesc.ByteOffset, ") exceeds buffer size (", this->m_Desc.uiSizeInBytes, ")");
ViewDesc.ByteWidth = this->m_Desc.uiSizeInBytes - ViewDesc.ByteOffset;
}
- if( ViewDesc.ByteOffset + ViewDesc.ByteWidth > this->m_Desc.uiSizeInBytes )
- LOG_ERROR_AND_THROW( "Buffer view range [", ViewDesc.ByteOffset, ", ", ViewDesc.ByteOffset + ViewDesc.ByteWidth, ") is out of the buffer boundaries [0, ", this->m_Desc.uiSizeInBytes, ")." );
- if( (this->m_Desc.BindFlags & BIND_UNORDERED_ACCESS) ||
- (this->m_Desc.BindFlags & BIND_SHADER_RESOURCE) )
+ if (ViewDesc.ByteOffset + ViewDesc.ByteWidth > this->m_Desc.uiSizeInBytes)
+ LOG_ERROR_AND_THROW("Buffer view range [", ViewDesc.ByteOffset, ", ", ViewDesc.ByteOffset + ViewDesc.ByteWidth, ") is out of the buffer boundaries [0, ", this->m_Desc.uiSizeInBytes, ").");
+ if ((this->m_Desc.BindFlags & BIND_UNORDERED_ACCESS) ||
+ (this->m_Desc.BindFlags & BIND_SHADER_RESOURCE))
{
if (this->m_Desc.Mode == BUFFER_MODE_STRUCTURED || this->m_Desc.Mode == BUFFER_MODE_FORMATTED)
{
- VERIFY( this->m_Desc.ElementByteStride != 0, "Element byte stride is zero" );
- if( (ViewDesc.ByteOffset % this->m_Desc.ElementByteStride) != 0 )
- LOG_ERROR_AND_THROW( "Buffer view byte offset (", ViewDesc.ByteOffset, ") is not multiple of element byte stride (", this->m_Desc.ElementByteStride, ")." );
- if( (ViewDesc.ByteWidth % this->m_Desc.ElementByteStride) != 0 )
- LOG_ERROR_AND_THROW( "Buffer view byte width (", ViewDesc.ByteWidth, ") is not multiple of element byte stride (", this->m_Desc.ElementByteStride, ")." );
+ VERIFY(this->m_Desc.ElementByteStride != 0, "Element byte stride is zero");
+ if ((ViewDesc.ByteOffset % this->m_Desc.ElementByteStride) != 0)
+ LOG_ERROR_AND_THROW("Buffer view byte offset (", ViewDesc.ByteOffset, ") is not multiple of element byte stride (", this->m_Desc.ElementByteStride, ").");
+ if ((ViewDesc.ByteWidth % this->m_Desc.ElementByteStride) != 0)
+ LOG_ERROR_AND_THROW("Buffer view byte width (", ViewDesc.ByteWidth, ") is not multiple of element byte stride (", this->m_Desc.ElementByteStride, ").");
}
if (this->m_Desc.Mode == BUFFER_MODE_FORMATTED && ViewDesc.Format.ValueType == VT_UNDEFINED)
@@ -217,11 +222,11 @@ void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffVi
LOG_ERROR_AND_THROW("Incorrect number of components (", Uint32{ViewDesc.Format.NumComponents}, "). 1, 2, 3, or 4 are allowed values");
if (ViewDesc.Format.ValueType == VT_FLOAT32 || ViewDesc.Format.ValueType == VT_FLOAT16)
ViewDesc.Format.IsNormalized = false;
- auto ViewElementStride = GetValueSize( ViewDesc.Format.ValueType ) * Uint32{ViewDesc.Format.NumComponents};
+ auto ViewElementStride = GetValueSize(ViewDesc.Format.ValueType) * Uint32{ViewDesc.Format.NumComponents};
if (this->m_Desc.Mode == BUFFER_MODE_RAW && this->m_Desc.ElementByteStride == 0)
LOG_ERROR_AND_THROW("To enable formatted views of a raw buffer, element byte must be specified during buffer initialization");
if (ViewElementStride != this->m_Desc.ElementByteStride)
- LOG_ERROR_AND_THROW("Buffer element byte stride (", this->m_Desc.ElementByteStride, ") is not consistent with the size (", ViewElementStride, ") defined by the format of the view (", GetBufferFormatString(ViewDesc.Format), ')' );
+ LOG_ERROR_AND_THROW("Buffer element byte stride (", this->m_Desc.ElementByteStride, ") is not consistent with the size (", ViewElementStride, ") defined by the format of the view (", GetBufferFormatString(ViewDesc.Format), ')');
}
if (this->m_Desc.Mode == BUFFER_MODE_RAW && ViewDesc.Format.ValueType == VT_UNDEFINED)
@@ -232,19 +237,19 @@ void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffVi
}
}
-template<class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator>
-IBufferView* BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator> ::GetDefaultView( BUFFER_VIEW_TYPE ViewType )
+template <class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator>
+IBufferView* BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator>::GetDefaultView(BUFFER_VIEW_TYPE ViewType)
{
- switch( ViewType )
+ switch (ViewType)
{
- case BUFFER_VIEW_SHADER_RESOURCE: return m_pDefaultSRV.get();
+ case BUFFER_VIEW_SHADER_RESOURCE: return m_pDefaultSRV.get();
case BUFFER_VIEW_UNORDERED_ACCESS: return m_pDefaultUAV.get();
- default: UNEXPECTED( "Unknown view type" ); return nullptr;
+ default: UNEXPECTED("Unknown view type"); return nullptr;
}
}
-template<class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator>
-void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator> :: CreateDefaultViews()
+template <class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator>
+void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator>::CreateDefaultViews()
{
// Create default views for structured and raw buffers. For formatted buffers we do not know the view format, so
// cannot create views.
@@ -254,9 +259,9 @@ void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffVi
BufferViewDesc ViewDesc;
ViewDesc.ViewType = BUFFER_VIEW_UNORDERED_ACCESS;
IBufferView* pUAV = nullptr;
- CreateViewInternal( ViewDesc, &pUAV, true );
- m_pDefaultUAV.reset( static_cast<BufferViewImplType*>(pUAV) );
- VERIFY( m_pDefaultUAV->GetDesc().ViewType == BUFFER_VIEW_UNORDERED_ACCESS, "Unexpected view type" );
+ CreateViewInternal(ViewDesc, &pUAV, true);
+ m_pDefaultUAV.reset(static_cast<BufferViewImplType*>(pUAV));
+ VERIFY(m_pDefaultUAV->GetDesc().ViewType == BUFFER_VIEW_UNORDERED_ACCESS, "Unexpected view type");
}
if (this->m_Desc.BindFlags & BIND_SHADER_RESOURCE && (this->m_Desc.Mode == BUFFER_MODE_STRUCTURED || this->m_Desc.Mode == BUFFER_MODE_RAW))
@@ -264,10 +269,10 @@ void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffVi
BufferViewDesc ViewDesc;
ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE;
IBufferView* pSRV = nullptr;
- CreateViewInternal( ViewDesc, &pSRV, true );
- m_pDefaultSRV.reset( static_cast<BufferViewImplType*>(pSRV) );
- VERIFY( m_pDefaultSRV->GetDesc().ViewType == BUFFER_VIEW_SHADER_RESOURCE, "Unexpected view type" );
+ CreateViewInternal(ViewDesc, &pSRV, true);
+ m_pDefaultSRV.reset(static_cast<BufferViewImplType*>(pSRV));
+ VERIFY(m_pDefaultSRV->GetDesc().ViewType == BUFFER_VIEW_SHADER_RESOURCE, "Unexpected view type");
}
}
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/BufferViewBase.h b/Graphics/GraphicsEngine/include/BufferViewBase.h
index 0623d497..5c688aef 100644
--- a/Graphics/GraphicsEngine/include/BufferViewBase.h
+++ b/Graphics/GraphicsEngine/include/BufferViewBase.h
@@ -45,55 +45,54 @@ class IBuffer;
/// \tparam RenderDeviceImplType - type of the render device implementation
/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl,
/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl)
-template<class BaseInterface, class RenderDeviceImplType>
+template <class BaseInterface, class RenderDeviceImplType>
class BufferViewBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, BufferViewDesc>
{
public:
using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, BufferViewDesc>;
/// \param pRefCounters - reference counters object that controls the lifetime of this buffer view.
- /// \param pDevice - pointer to the render device.
- /// \param ViewDesc - buffer view description.
- /// \param pBuffer - pointer to the buffer that the view is to be created for.
- /// \param bIsDefaultView - flag indicating if the view is default view, and is thus
- /// part of the buffer object. In this case the view will attach
- /// to the buffer's reference counters.
- BufferViewBase( IReferenceCounters* pRefCounters,
- RenderDeviceImplType* pDevice,
- const BufferViewDesc& ViewDesc,
- IBuffer* pBuffer,
- bool bIsDefaultView ) :
- // Default views are created as part of the buffer, so we cannot not keep strong
- // reference to the buffer to avoid cyclic links. Instead, we will attach to the
+ /// \param pDevice - pointer to the render device.
+ /// \param ViewDesc - buffer view description.
+ /// \param pBuffer - pointer to the buffer that the view is to be created for.
+ /// \param bIsDefaultView - flag indicating if the view is default view, and is thus
+ /// part of the buffer object. In this case the view will attach
+ /// to the buffer's reference counters.
+ BufferViewBase(IReferenceCounters* pRefCounters,
+ RenderDeviceImplType* pDevice,
+ const BufferViewDesc& ViewDesc,
+ IBuffer* pBuffer,
+ bool bIsDefaultView) :
+ // Default views are created as part of the buffer, so we cannot not keep strong
+ // reference to the buffer to avoid cyclic links. Instead, we will attach to the
// reference counters of the buffer.
- TDeviceObjectBase( pRefCounters, pDevice, ViewDesc),
- m_pBuffer( pBuffer ),
+ TDeviceObjectBase(pRefCounters, pDevice, ViewDesc),
+ m_pBuffer{pBuffer},
// For non-default view, we will keep strong reference to buffer
- m_spBuffer(bIsDefaultView ? nullptr : pBuffer)
+ m_spBuffer{bIsDefaultView ? nullptr : pBuffer}
{}
- IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_BufferView, TDeviceObjectBase )
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_BufferView, TDeviceObjectBase)
/// Implementation of IBufferView::GetBuffer()
- virtual IBuffer* GetBuffer()override final
+ virtual IBuffer* GetBuffer() override final
{
return m_pBuffer;
}
- template<typename BufferType>
+ template <typename BufferType>
BufferType* GetBuffer()
{
return ValidatedCast<BufferType>(m_pBuffer);
}
- template<typename BufferType>
- BufferType* GetBuffer()const
+ template <typename BufferType>
+ BufferType* GetBuffer() const
{
return ValidatedCast<BufferType>(m_pBuffer);
}
protected:
-
/// Pointer to the buffer
IBuffer* const m_pBuffer;
@@ -102,4 +101,4 @@ protected:
RefCntAutoPtr<IBuffer> m_spBuffer;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/CommandListBase.h b/Graphics/GraphicsEngine/include/CommandListBase.h
index 0ac464a7..d1c752f4 100644
--- a/Graphics/GraphicsEngine/include/CommandListBase.h
+++ b/Graphics/GraphicsEngine/include/CommandListBase.h
@@ -39,30 +39,30 @@ struct CommandListDesc : public DeviceObjectAttribs
/// Template class implementing base functionality for a command list object.
-/// \tparam BaseInterface - base interface that this class will inheret
+/// \tparam BaseInterface - base interface that this class will inheret
/// (Diligent::ICommandListD3D11, Diligent::ICommandListD3D12 or Diligent::ICommandListVk).
/// \tparam RenderDeviceImplType - type of the render device implementation
/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl,
/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl)
-template<class BaseInterface, class RenderDeviceImplType>
+template <class BaseInterface, class RenderDeviceImplType>
class CommandListBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, CommandListDesc>
{
public:
using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, CommandListDesc>;
/// \param pRefCounters - reference counters object that controls the lifetime of this command list.
- /// \param pDevice - pointer to the device.
- /// \param bIsDeviceInternal - flag indicating if the CommandList is an internal device object and
- /// must not keep a strong reference to the device.
- CommandListBase( IReferenceCounters* pRefCounters, RenderDeviceImplType* pDevice, bool bIsDeviceInternal = false ) :
- TDeviceObjectBase( pRefCounters, pDevice, CommandListDesc(), bIsDeviceInternal )
+ /// \param pDevice - pointer to the device.
+ /// \param bIsDeviceInternal - flag indicating if the CommandList is an internal device object and
+ /// must not keep a strong reference to the device.
+ CommandListBase(IReferenceCounters* pRefCounters, RenderDeviceImplType* pDevice, bool bIsDeviceInternal = false) :
+ TDeviceObjectBase{pRefCounters, pDevice, CommandListDesc(), bIsDeviceInternal}
{}
~CommandListBase()
{
}
- IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_CommandList, TDeviceObjectBase )
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_CommandList, TDeviceObjectBase)
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/DefaultShaderSourceStreamFactory.h b/Graphics/GraphicsEngine/include/DefaultShaderSourceStreamFactory.h
index c256cacc..84860a24 100644
--- a/Graphics/GraphicsEngine/include/DefaultShaderSourceStreamFactory.h
+++ b/Graphics/GraphicsEngine/include/DefaultShaderSourceStreamFactory.h
@@ -32,7 +32,7 @@ namespace Diligent
/// Creates default shader source stream factory
/// \param [in] SearchDirectories - Semicolon-seprated list of search directories.
/// \param [out] ppShaderSourceStreamFactory - Memory address where pointer to the shader source stream factory will be written.
-void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories,
+void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories,
IShaderSourceInputStreamFactory** ppShaderSourceStreamFactory);
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/Defines.h b/Graphics/GraphicsEngine/include/Defines.h
index 8fc06aa4..e8997cc7 100644
--- a/Graphics/GraphicsEngine/include/Defines.h
+++ b/Graphics/GraphicsEngine/include/Defines.h
@@ -22,4 +22,3 @@
*/
#pragma once
-
diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.h b/Graphics/GraphicsEngine/include/DeviceContextBase.h
index 4ca3e286..c822dacf 100644
--- a/Graphics/GraphicsEngine/include/DeviceContextBase.h
+++ b/Graphics/GraphicsEngine/include/DeviceContextBase.h
@@ -44,31 +44,31 @@ namespace Diligent
{
/// Describes input vertex stream
-template<typename BufferImplType>
+template <typename BufferImplType>
struct VertexStreamInfo
{
- VertexStreamInfo(){}
+ VertexStreamInfo() {}
/// Strong reference to the buffer object
RefCntAutoPtr<BufferImplType> pBuffer;
- Uint32 Offset = 0; ///< Offset in bytes
+ Uint32 Offset = 0; ///< Offset in bytes
};
/// Base implementation of the device context.
/// \tparam BaseInterface - base interface that this class will inheret.
-/// \tparam ImplementationTraits - implementation traits that define specific implementation details
+/// \tparam ImplementationTraits - implementation traits that define specific implementation details
/// (texture implemenation type, buffer implementation type, etc.)
-/// \remarks Device context keeps strong references to all objects currently bound to
+/// \remarks Device context keeps strong references to all objects currently bound to
/// the pipeline: buffers, states, samplers, shaders, etc.
/// The context also keeps strong references to the device and
/// the swap chain.
-template<typename BaseInterface, typename ImplementationTraits>
+template <typename BaseInterface, typename ImplementationTraits>
class DeviceContextBase : public ObjectBase<BaseInterface>
{
public:
using TObjectBase = ObjectBase<BaseInterface>;
- using DeviceImplType = typename ImplementationTraits::DeviceType;
+ using DeviceImplType = typename ImplementationTraits::DeviceType;
using BufferImplType = typename ImplementationTraits::BufferType;
using TextureImplType = typename ImplementationTraits::TextureType;
using PipelineStateImplType = typename ImplementationTraits::PipelineStateType;
@@ -78,9 +78,11 @@ public:
/// \param pRenderDevice - render device.
/// \param bIsDeferred - flag indicating if this instance is a deferred context
DeviceContextBase(IReferenceCounters* pRefCounters, DeviceImplType* pRenderDevice, bool bIsDeferred) :
+ // clang-format off
TObjectBase {pRefCounters },
m_pDevice {pRenderDevice},
m_bIsDeferred{bIsDeferred }
+ // clang-format on
{
}
@@ -88,18 +90,18 @@ public:
{
}
- IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_DeviceContext, TObjectBase )
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_DeviceContext, TObjectBase)
- /// Base implementation of IDeviceContext::SetVertexBuffers(); validates parameters and
+ /// Base implementation of IDeviceContext::SetVertexBuffers(); validates parameters and
/// caches references to the buffers.
- inline virtual void SetVertexBuffers( Uint32 StartSlot,
- Uint32 NumBuffersSet,
- IBuffer** ppBuffers,
- Uint32* pOffsets,
- RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
- SET_VERTEX_BUFFERS_FLAGS Flags )override = 0;
+ inline virtual void SetVertexBuffers(Uint32 StartSlot,
+ Uint32 NumBuffersSet,
+ IBuffer** ppBuffers,
+ Uint32* pOffsets,
+ RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
+ SET_VERTEX_BUFFERS_FLAGS Flags) override = 0;
- inline virtual void InvalidateState()override = 0;
+ inline virtual void InvalidateState() override = 0;
/// Base implementation of IDeviceContext::CommitShaderResources(); validates parameters.
inline bool CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding,
@@ -107,20 +109,20 @@ public:
int);
/// Base implementation of IDeviceContext::SetIndexBuffer(); caches the strong reference to the index buffer
- inline virtual void SetIndexBuffer( IBuffer* pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode )override = 0;
+ inline virtual void SetIndexBuffer(IBuffer* pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override = 0;
/// Caches the viewports
- inline void SetViewports( Uint32 NumViewports, const Viewport* pViewports, Uint32& RTWidth, Uint32& RTHeight );
+ inline void SetViewports(Uint32 NumViewports, const Viewport* pViewports, Uint32& RTWidth, Uint32& RTHeight);
/// Caches the scissor rects
- inline void SetScissorRects( Uint32 NumRects, const Rect* pRects, Uint32& RTWidth, Uint32& RTHeight );
+ inline void SetScissorRects(Uint32 NumRects, const Rect* pRects, Uint32& RTWidth, Uint32& RTHeight);
/// Caches the render target and depth stencil views. Returns true if any view is different
/// from the cached value and false otherwise.
- inline bool SetRenderTargets( Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil);
+ inline bool SetRenderTargets(Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil);
/// Base implementation of IDeviceContext::UpdateBuffer(); validates input parameters.
- virtual void UpdateBuffer(IBuffer* pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override = 0;
+ virtual void UpdateBuffer(IBuffer* pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override = 0;
/// Base implementation of IDeviceContext::CopyBuffer(); validates input parameters.
virtual void CopyBuffer(IBuffer* pSrcBuffer,
@@ -129,20 +131,25 @@ public:
IBuffer* pDstBuffer,
Uint32 DstOffset,
Uint32 Size,
- RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode)override = 0;
+ RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode) override = 0;
/// Base implementation of IDeviceContext::MapBuffer(); validates input parameters.
- virtual void MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData)override = 0;
+ virtual void MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData) override = 0;
/// Base implementation of IDeviceContext::UnmapBuffer()
- virtual void UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType)override = 0;
+ virtual void UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType) 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,
- RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode )override = 0;
+ virtual void UpdateTexture(ITexture* pTexture,
+ Uint32 MipLevel,
+ Uint32 Slice,
+ const Box& DstBox,
+ const TextureSubResData& SubresData,
+ RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode,
+ RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode) override = 0;
/// Base implementaiton of IDeviceContext::CopyTexture(); validates input parameters
- virtual void CopyTexture( const CopyTextureAttribs& CopyAttribs )override = 0;
+ virtual void CopyTexture(const CopyTextureAttribs& CopyAttribs) override = 0;
/// Base implementaiton of IDeviceContext::MapTextureSubresource()
virtual void MapTextureSubresource(ITexture* pTexture,
@@ -151,25 +158,25 @@ public:
MAP_TYPE MapType,
MAP_FLAGS MapFlags,
const Box* pMapRegion,
- MappedTextureSubresource& MappedData)override = 0;
+ MappedTextureSubresource& MappedData) override = 0;
/// Base implementaiton of IDeviceContext::UnmapTextureSubresource()
- virtual void UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice)override = 0;
+ virtual void UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice) override = 0;
- virtual void GenerateMips(ITextureView* pTexView)override = 0;
+ virtual void GenerateMips(ITextureView* pTexView) override = 0;
/// Sets the strong pointer to the swap chain
- virtual void SetSwapChain( ISwapChain* pSwapChain )override final { m_pSwapChain = pSwapChain; }
+ virtual void SetSwapChain(ISwapChain* pSwapChain) override final { m_pSwapChain = pSwapChain; }
virtual void ResolveTextureSubresource(ITexture* pSrcTexture,
ITexture* pDstTexture,
- const ResolveTextureSubresourceAttribs& ResolveAttribs)override = 0;
+ const ResolveTextureSubresourceAttribs& ResolveAttribs) override = 0;
/// Returns the swap chain
ISwapChain* GetSwapChain() { return m_pSwapChain; }
/// Returns true if currently bound frame buffer is the default frame buffer
- inline bool IsDefaultFBBound(){ return m_IsDefaultFramebufferBound; }
+ inline bool IsDefaultFBBound() { return m_IsDefaultFramebufferBound; }
/// Returns currently bound pipeline state and blend factors
inline void GetPipelineState(IPipelineState** ppPSO, float* BlendFactors, Uint32& StencilRef);
@@ -178,14 +185,14 @@ public:
inline void GetRenderTargets(Uint32& NumRenderTargets, ITextureView** ppRTVs, ITextureView** ppDSV);
/// Returns currently set viewports
- inline void GetViewports( Uint32& NumViewports, Viewport* pViewports );
+ inline void GetViewports(Uint32& NumViewports, Viewport* pViewports);
/// Returns the render device
- IRenderDevice *GetDevice(){return m_pDevice;}
+ IRenderDevice* GetDevice() { return m_pDevice; }
inline void ResetRenderTargets();
- bool IsDeferred()const{return m_bIsDeferred;}
+ bool IsDeferred() const { return m_bIsDeferred; }
protected:
inline bool SetBlendFactors(const float* BlendFactors, int Dummy);
@@ -198,6 +205,7 @@ protected:
inline void ClearStateCache();
#ifdef DEVELOPMENT
+ // clang-format off
bool DvpVerifyDrawArguments (const DrawAttribs& Attribs)const;
bool DvpVerifyDrawIndexedArguments (const DrawIndexedAttribs& Attribs)const;
bool DvpVerifyDrawIndirectArguments (const DrawIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer)const;
@@ -223,18 +231,19 @@ protected:
void DvpVerifyStateTransitionDesc(const StateTransitionDesc& Barrier)const {}
bool DvpVerifyTextureState(const TextureImplType& Texture, RESOURCE_STATE RequiredState, const char* OperationName)const {return true;}
bool DvpVerifyBufferState (const BufferImplType& Buffer, RESOURCE_STATE RequiredState, const char* OperationName)const {return true;}
+ // clang-format on
#endif
/// Strong reference to the device.
RefCntAutoPtr<DeviceImplType> m_pDevice;
-
+
/// Strong reference to the swap chain. Swap chain holds
/// weak reference to the immediate context.
RefCntAutoPtr<ISwapChain> m_pSwapChain;
/// Vertex streams. Every stream holds strong reference to the buffer
VertexStreamInfo<BufferImplType> m_VertexStreams[MaxBufferSlots];
-
+
/// Number of bound vertex streams
Uint32 m_NumVertexStreams = 0;
@@ -251,18 +260,18 @@ protected:
/// Offset from the beginning of the index buffer to the start of the index data, in bytes.
Uint32 m_IndexDataStartOffset = 0;
- /// Current stencil reference value
+ /// Current stencil reference value
Uint32 m_StencilRef = 0;
- /// Curent blend factors
- Float32 m_BlendFactors[4] = { -1, -1, -1, -1 };
+ /// Curent blend factors
+ Float32 m_BlendFactors[4] = {-1, -1, -1, -1};
- /// Current viewports
+ /// Current viewports
Viewport m_Viewports[MaxViewports];
/// Number of current viewports
Uint32 m_NumViewports = 0;
- /// Current scissor rects
+ /// Current scissor rects
Rect m_ScissorRects[MaxViewports];
/// Number of current scissor rects
Uint32 m_NumScissorRects = 0;
@@ -278,7 +287,7 @@ protected:
Uint32 m_FramebufferHeight = 0;
/// Number of array slices in the currently bound framebuffer
Uint32 m_FramebufferSlices = 0;
- /// Flag indicating if default render target & depth-stencil
+ /// Flag indicating if default render target & depth-stencil
/// buffer are currently bound
bool m_IsDefaultFramebufferBound = false;
@@ -289,7 +298,7 @@ protected:
const bool m_bIsDeferred = false;
#ifdef _DEBUG
- // std::unordered_map is unbelievably slow. Keeping track of mapped buffers
+ // std::unordered_map is unbelievably slow. Keeping track of mapped buffers
// in release builds is not feasible
struct DbgMappedBufferInfo
{
@@ -300,30 +309,30 @@ protected:
};
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
- SetVertexBuffers( Uint32 StartSlot,
- Uint32 NumBuffersSet,
- IBuffer** ppBuffers,
- Uint32* pOffsets,
- RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
- SET_VERTEX_BUFFERS_FLAGS Flags )
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::
+ SetVertexBuffers(Uint32 StartSlot,
+ Uint32 NumBuffersSet,
+ IBuffer** ppBuffers,
+ Uint32* pOffsets,
+ RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
+ SET_VERTEX_BUFFERS_FLAGS Flags)
{
#ifdef DEVELOPMENT
- if ( StartSlot >= MaxBufferSlots )
+ if (StartSlot >= MaxBufferSlots)
{
- LOG_ERROR_MESSAGE( "Start vertex buffer slot ", StartSlot, " is out of allowed range [0, ", MaxBufferSlots-1, "]." );
+ LOG_ERROR_MESSAGE("Start vertex buffer slot ", StartSlot, " is out of allowed range [0, ", MaxBufferSlots - 1, "].");
return;
}
- if ( StartSlot + NumBuffersSet > MaxBufferSlots )
+ if (StartSlot + NumBuffersSet > MaxBufferSlots)
{
- LOG_ERROR_MESSAGE( "The range of vertex buffer slots being set [", StartSlot, ", ", StartSlot + NumBuffersSet - 1, "] is out of allowed range [0, ", MaxBufferSlots - 1, "]." );
+ LOG_ERROR_MESSAGE("The range of vertex buffer slots being set [", StartSlot, ", ", StartSlot + NumBuffersSet - 1, "] is out of allowed range [0, ", MaxBufferSlots - 1, "].");
NumBuffersSet = MaxBufferSlots - StartSlot;
}
#endif
- if ( Flags & SET_VERTEX_BUFFERS_FLAG_RESET )
+ if (Flags & SET_VERTEX_BUFFERS_FLAG_RESET)
{
// Reset only these buffer slots that are not being set.
// It is very important to not reset buffers that stay unchanged
@@ -334,38 +343,39 @@ inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
m_VertexStreams[s] = VertexStreamInfo<BufferImplType>{};
m_NumVertexStreams = 0;
}
- m_NumVertexStreams = std::max(m_NumVertexStreams, StartSlot + NumBuffersSet );
-
- for( Uint32 Buff = 0; Buff < NumBuffersSet; ++Buff )
+ m_NumVertexStreams = std::max(m_NumVertexStreams, StartSlot + NumBuffersSet);
+
+ for (Uint32 Buff = 0; Buff < NumBuffersSet; ++Buff)
{
- auto &CurrStream = m_VertexStreams[StartSlot + Buff];
+ auto& CurrStream = m_VertexStreams[StartSlot + Buff];
CurrStream.pBuffer = ppBuffers ? ValidatedCast<BufferImplType>(ppBuffers[Buff]) : nullptr;
- CurrStream.Offset = pOffsets ? pOffsets[Buff] : 0;
+ CurrStream.Offset = pOffsets ? pOffsets[Buff] : 0;
#ifdef DEVELOPMENT
- if ( CurrStream.pBuffer )
+ if (CurrStream.pBuffer)
{
- const auto &BuffDesc = CurrStream.pBuffer->GetDesc();
- if ( !(BuffDesc.BindFlags & BIND_VERTEX_BUFFER) )
+ const auto& BuffDesc = CurrStream.pBuffer->GetDesc();
+ if (!(BuffDesc.BindFlags & BIND_VERTEX_BUFFER))
{
- LOG_ERROR_MESSAGE( "Buffer '", BuffDesc.Name ? BuffDesc.Name : "", "' being bound as vertex buffer to slot ", Buff," was not created with BIND_VERTEX_BUFFER flag" );
+ LOG_ERROR_MESSAGE("Buffer '", BuffDesc.Name ? BuffDesc.Name : "", "' being bound as vertex buffer to slot ", Buff, " was not created with BIND_VERTEX_BUFFER flag");
}
}
#endif
}
// Remove null buffers from the end of the array
- while(m_NumVertexStreams > 0 && !m_VertexStreams[m_NumVertexStreams-1].pBuffer)
+ while (m_NumVertexStreams > 0 && !m_VertexStreams[m_NumVertexStreams - 1].pBuffer)
m_VertexStreams[m_NumVertexStreams--] = VertexStreamInfo<BufferImplType>{};
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> :: SetPipelineState(PipelineStateImplType* pPipelineState, int /*Dummy*/)
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::
+ SetPipelineState(PipelineStateImplType* pPipelineState, int /*Dummy*/)
{
m_pPipelineState = pPipelineState;
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
- CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, int)
+template <typename BaseInterface, typename ImplementationTraits>
+inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::
+ CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, int)
{
#ifdef DEVELOPMENT
if (!m_pPipelineState)
@@ -386,66 +396,66 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
return true;
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> :: InvalidateState()
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::InvalidateState()
{
- DeviceContextBase<BaseInterface,ImplementationTraits> :: ClearStateCache();
+ DeviceContextBase<BaseInterface, ImplementationTraits>::ClearStateCache();
m_IsDefaultFramebufferBound = false;
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
- SetIndexBuffer( IBuffer* pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode )
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::
+ SetIndexBuffer(IBuffer* pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)
{
- m_pIndexBuffer = ValidatedCast<BufferImplType>(pIndexBuffer);
+ m_pIndexBuffer = ValidatedCast<BufferImplType>(pIndexBuffer);
m_IndexDataStartOffset = ByteOffset;
#ifdef DEVELOPMENT
if (m_pIndexBuffer)
{
const auto& BuffDesc = m_pIndexBuffer->GetDesc();
- if ( !(BuffDesc.BindFlags & BIND_INDEX_BUFFER) )
+ if (!(BuffDesc.BindFlags & BIND_INDEX_BUFFER))
{
- LOG_ERROR_MESSAGE( "Buffer '", BuffDesc.Name ? BuffDesc.Name : "", "' being bound as index buffer was not created with BIND_INDEX_BUFFER flag" );
+ LOG_ERROR_MESSAGE("Buffer '", BuffDesc.Name ? BuffDesc.Name : "", "' being bound as index buffer was not created with BIND_INDEX_BUFFER flag");
}
}
#endif
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> :: GetPipelineState(IPipelineState** ppPSO, float* BlendFactors, Uint32& StencilRef)
-{
- VERIFY( ppPSO != nullptr, "Null pointer provided null" );
- VERIFY(* ppPSO == nullptr, "Memory address contains a pointer to a non-null blend state" );
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::GetPipelineState(IPipelineState** ppPSO, float* BlendFactors, Uint32& StencilRef)
+{
+ VERIFY(ppPSO != nullptr, "Null pointer provided null");
+ VERIFY(*ppPSO == nullptr, "Memory address contains a pointer to a non-null blend state");
if (m_pPipelineState)
{
- m_pPipelineState->QueryInterface( IID_PipelineState, reinterpret_cast<IObject**>( ppPSO ) );
+ m_pPipelineState->QueryInterface(IID_PipelineState, reinterpret_cast<IObject**>(ppPSO));
}
else
{
- * ppPSO = nullptr;
+ *ppPSO = nullptr;
}
- for( Uint32 f = 0; f < 4; ++f )
+ for (Uint32 f = 0; f < 4; ++f)
BlendFactors[f] = m_BlendFactors[f];
StencilRef = m_StencilRef;
};
-template<typename BaseInterface, typename ImplementationTraits>
-inline bool DeviceContextBase<BaseInterface,ImplementationTraits> :: SetBlendFactors(const float* BlendFactors, int)
+template <typename BaseInterface, typename ImplementationTraits>
+inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetBlendFactors(const float* BlendFactors, int)
{
bool FactorsDiffer = false;
- for( Uint32 f = 0; f < 4; ++f )
+ for (Uint32 f = 0; f < 4; ++f)
{
- if ( m_BlendFactors[f] != BlendFactors[f] )
+ if (m_BlendFactors[f] != BlendFactors[f])
FactorsDiffer = true;
m_BlendFactors[f] = BlendFactors[f];
}
return FactorsDiffer;
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline bool DeviceContextBase<BaseInterface,ImplementationTraits> :: SetStencilRef(Uint32 StencilRef, int)
+template <typename BaseInterface, typename ImplementationTraits>
+inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetStencilRef(Uint32 StencilRef, int)
{
if (m_StencilRef != StencilRef)
{
@@ -455,80 +465,80 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> :: SetStencilR
return false;
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
- SetViewports( Uint32 NumViewports, const Viewport* pViewports, Uint32& RTWidth, Uint32& RTHeight )
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::
+ SetViewports(Uint32 NumViewports, const Viewport* pViewports, Uint32& RTWidth, Uint32& RTHeight)
{
- if ( RTWidth == 0 || RTHeight == 0 )
+ if (RTWidth == 0 || RTHeight == 0)
{
- RTWidth = m_FramebufferWidth;
+ RTWidth = m_FramebufferWidth;
RTHeight = m_FramebufferHeight;
}
VERIFY(NumViewports < MaxViewports, "Number of viewports (", NumViewports, ") exceeds the limit (", MaxViewports, ")");
m_NumViewports = std::min(MaxViewports, NumViewports);
-
- Viewport DefaultVP( 0, 0, static_cast<float>(RTWidth), static_cast<float>(RTHeight) );
+
+ Viewport DefaultVP(0, 0, static_cast<float>(RTWidth), static_cast<float>(RTHeight));
// If no viewports are specified, use default viewport
- if ( m_NumViewports == 1 && pViewports == nullptr )
+ if (m_NumViewports == 1 && pViewports == nullptr)
{
pViewports = &DefaultVP;
}
- for( Uint32 vp = 0; vp < m_NumViewports; ++vp )
+ for (Uint32 vp = 0; vp < m_NumViewports; ++vp)
{
m_Viewports[vp] = pViewports[vp];
- VERIFY( m_Viewports[vp].Width >= 0, "Incorrect viewport width (", m_Viewports[vp].Width, ")" );
- VERIFY( m_Viewports[vp].Height >= 0 , "Incorrect viewport height (", m_Viewports[vp].Height, ")" );
- VERIFY( m_Viewports[vp].MaxDepth >= m_Viewports[vp].MinDepth, "Incorrect viewport depth range [", m_Viewports[vp].MinDepth, ", ", m_Viewports[vp].MaxDepth, "]" );
+ VERIFY(m_Viewports[vp].Width >= 0, "Incorrect viewport width (", m_Viewports[vp].Width, ")");
+ VERIFY(m_Viewports[vp].Height >= 0, "Incorrect viewport height (", m_Viewports[vp].Height, ")");
+ VERIFY(m_Viewports[vp].MaxDepth >= m_Viewports[vp].MinDepth, "Incorrect viewport depth range [", m_Viewports[vp].MinDepth, ", ", m_Viewports[vp].MaxDepth, "]");
}
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> :: GetViewports( Uint32 &NumViewports, Viewport* pViewports )
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::GetViewports(Uint32& NumViewports, Viewport* pViewports)
{
NumViewports = m_NumViewports;
- if ( pViewports )
+ if (pViewports)
{
- for( Uint32 vp = 0; vp < m_NumViewports; ++vp )
+ for (Uint32 vp = 0; vp < m_NumViewports; ++vp)
pViewports[vp] = m_Viewports[vp];
}
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
- SetScissorRects( Uint32 NumRects, const Rect* pRects, Uint32& RTWidth, Uint32& RTHeight )
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::
+ SetScissorRects(Uint32 NumRects, const Rect* pRects, Uint32& RTWidth, Uint32& RTHeight)
{
- if ( RTWidth == 0 || RTHeight == 0 )
+ if (RTWidth == 0 || RTHeight == 0)
{
- RTWidth = m_FramebufferWidth;
+ RTWidth = m_FramebufferWidth;
RTHeight = m_FramebufferHeight;
}
VERIFY(NumRects < MaxViewports, "Number of scissor rects (", NumRects, ") exceeds the limit (", MaxViewports, ")");
m_NumScissorRects = std::min(MaxViewports, NumRects);
- for( Uint32 sr = 0; sr < m_NumScissorRects; ++sr )
+ for (Uint32 sr = 0; sr < m_NumScissorRects; ++sr)
{
m_ScissorRects[sr] = pRects[sr];
- VERIFY( m_ScissorRects[sr].left <= m_ScissorRects[sr].right, "Incorrect horizontal bounds for a scissor rect [", m_ScissorRects[sr].left, ", ", m_ScissorRects[sr].right, ")" );
- VERIFY( m_ScissorRects[sr].top <= m_ScissorRects[sr].bottom, "Incorrect vertical bounds for a scissor rect [", m_ScissorRects[sr].top, ", ", m_ScissorRects[sr].bottom, ")" );
+ VERIFY(m_ScissorRects[sr].left <= m_ScissorRects[sr].right, "Incorrect horizontal bounds for a scissor rect [", m_ScissorRects[sr].left, ", ", m_ScissorRects[sr].right, ")");
+ VERIFY(m_ScissorRects[sr].top <= m_ScissorRects[sr].bottom, "Incorrect vertical bounds for a scissor rect [", m_ScissorRects[sr].top, ", ", m_ScissorRects[sr].bottom, ")");
}
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
- SetRenderTargets( Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil )
+template <typename BaseInterface, typename ImplementationTraits>
+inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::
+ SetRenderTargets(Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil)
{
bool bBindRenderTargets = false;
- m_FramebufferWidth = 0;
- m_FramebufferHeight = 0;
- m_FramebufferSlices = 0;
-
- ITextureView* pDefaultRTV = nullptr;
- bool IsDefaultFrambuffer = NumRenderTargets == 0 && pDepthStencil == nullptr;
- bBindRenderTargets = (m_IsDefaultFramebufferBound != IsDefaultFrambuffer);
- m_IsDefaultFramebufferBound = IsDefaultFrambuffer;
+ m_FramebufferWidth = 0;
+ m_FramebufferHeight = 0;
+ m_FramebufferSlices = 0;
+
+ ITextureView* pDefaultRTV = nullptr;
+ bool IsDefaultFrambuffer = NumRenderTargets == 0 && pDepthStencil == nullptr;
+ bBindRenderTargets = (m_IsDefaultFramebufferBound != IsDefaultFrambuffer);
+ m_IsDefaultFramebufferBound = IsDefaultFrambuffer;
if (m_IsDefaultFramebufferBound)
{
VERIFY(m_pSwapChain, "Swap chain is not initialized in the device context");
@@ -538,19 +548,19 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
if (pDefaultRTV != nullptr)
{
NumRenderTargets = 1;
- ppRenderTargets = &pDefaultRTV;
+ ppRenderTargets = &pDefaultRTV;
}
const auto& SwapChainDesc = m_pSwapChain->GetDesc();
- m_FramebufferWidth = SwapChainDesc.Width;
- m_FramebufferHeight = SwapChainDesc.Height;
- m_FramebufferSlices = 1;
+ m_FramebufferWidth = SwapChainDesc.Width;
+ m_FramebufferHeight = SwapChainDesc.Height;
+ m_FramebufferSlices = 1;
}
if (NumRenderTargets != m_NumBoundRenderTargets)
{
bBindRenderTargets = true;
- for (Uint32 rt = NumRenderTargets; rt < m_NumBoundRenderTargets; ++rt )
+ for (Uint32 rt = NumRenderTargets; rt < m_NumBoundRenderTargets; ++rt)
m_pBoundRenderTargets[rt].Release();
m_NumBoundRenderTargets = NumRenderTargets;
@@ -561,26 +571,26 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
auto* pRTView = ppRenderTargets[rt];
if (pRTView)
{
- const auto &RTVDesc = pRTView->GetDesc();
+ const auto& RTVDesc = pRTView->GetDesc();
#ifdef DEVELOPMENT
if (RTVDesc.ViewType != TEXTURE_VIEW_RENDER_TARGET)
- LOG_ERROR("Texture view object named '", RTVDesc.Name ? RTVDesc.Name : "", "' has incorrect view type (", GetTexViewTypeLiteralName(RTVDesc.ViewType), "). Render target view is expected" );
+ LOG_ERROR("Texture view object named '", RTVDesc.Name ? RTVDesc.Name : "", "' has incorrect view type (", GetTexViewTypeLiteralName(RTVDesc.ViewType), "). Render target view is expected");
#endif
// Use this RTV to set the render target size
if (m_FramebufferWidth == 0)
{
- auto* pTex = pRTView->GetTexture();
- const auto &TexDesc = pTex->GetDesc();
- m_FramebufferWidth = std::max(TexDesc.Width >> RTVDesc.MostDetailedMip, 1U);
+ auto* pTex = pRTView->GetTexture();
+ const auto& TexDesc = pTex->GetDesc();
+ m_FramebufferWidth = std::max(TexDesc.Width >> RTVDesc.MostDetailedMip, 1U);
m_FramebufferHeight = std::max(TexDesc.Height >> RTVDesc.MostDetailedMip, 1U);
m_FramebufferSlices = RTVDesc.NumArraySlices;
}
else
{
#ifdef DEVELOPMENT
- const auto &TexDesc = pRTView->GetTexture()->GetDesc();
- if (m_FramebufferWidth != std::max(TexDesc.Width >> RTVDesc.MostDetailedMip, 1U))
- LOG_ERROR("Render target width (", std::max(TexDesc.Width >> RTVDesc.MostDetailedMip, 1U), ") specified by RTV '", RTVDesc.Name, "' is inconsistent with the width of previously bound render targets (", m_FramebufferWidth, ")");
+ const auto& TexDesc = pRTView->GetTexture()->GetDesc();
+ if (m_FramebufferWidth != std::max(TexDesc.Width >> RTVDesc.MostDetailedMip, 1U))
+ LOG_ERROR("Render target width (", std::max(TexDesc.Width >> RTVDesc.MostDetailedMip, 1U), ") specified by RTV '", RTVDesc.Name, "' is inconsistent with the width of previously bound render targets (", m_FramebufferWidth, ")");
if (m_FramebufferHeight != std::max(TexDesc.Height >> RTVDesc.MostDetailedMip, 1U))
LOG_ERROR("Render target height (", std::max(TexDesc.Height >> RTVDesc.MostDetailedMip, 1U), ") specified by RTV '", RTVDesc.Name, "' is inconsistent with the height of previously bound render targets (", m_FramebufferHeight, ")");
if (m_FramebufferSlices != RTVDesc.NumArraySlices)
@@ -595,7 +605,7 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
if (m_pBoundRenderTargets[rt] != pRTView)
{
m_pBoundRenderTargets[rt] = ValidatedCast<TextureViewImplType>(pRTView);
- bBindRenderTargets = true;
+ bBindRenderTargets = true;
}
}
@@ -604,23 +614,23 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
const auto& DSVDesc = pDepthStencil->GetDesc();
#ifdef DEVELOPMENT
if (DSVDesc.ViewType != TEXTURE_VIEW_DEPTH_STENCIL)
- LOG_ERROR("Texture view object named '", DSVDesc.Name ? DSVDesc.Name : "", "' has incorrect view type (", GetTexViewTypeLiteralName(DSVDesc.ViewType), "). Depth stencil view is expected" );
+ LOG_ERROR("Texture view object named '", DSVDesc.Name ? DSVDesc.Name : "", "' has incorrect view type (", GetTexViewTypeLiteralName(DSVDesc.ViewType), "). Depth stencil view is expected");
#endif
// Use depth stencil size to set render target size
if (m_FramebufferWidth == 0)
{
- auto* pTex = pDepthStencil->GetTexture();
+ auto* pTex = pDepthStencil->GetTexture();
const auto& TexDesc = pTex->GetDesc();
- m_FramebufferWidth = std::max(TexDesc.Width >> DSVDesc.MostDetailedMip, 1U);
+ m_FramebufferWidth = std::max(TexDesc.Width >> DSVDesc.MostDetailedMip, 1U);
m_FramebufferHeight = std::max(TexDesc.Height >> DSVDesc.MostDetailedMip, 1U);
m_FramebufferSlices = DSVDesc.NumArraySlices;
}
else
{
#ifdef DEVELOPMENT
- const auto &TexDesc = pDepthStencil->GetTexture()->GetDesc();
- if (m_FramebufferWidth != std::max(TexDesc.Width >> DSVDesc.MostDetailedMip, 1U))
+ const auto& TexDesc = pDepthStencil->GetTexture()->GetDesc();
+ if (m_FramebufferWidth != std::max(TexDesc.Width >> DSVDesc.MostDetailedMip, 1U))
LOG_ERROR("Depth-stencil target width (", std::max(TexDesc.Width >> DSVDesc.MostDetailedMip, 1U), ") specified by DSV '", DSVDesc.Name, "' is inconsistent with the width of previously bound render targets (", m_FramebufferWidth, ")");
if (m_FramebufferHeight != std::max(TexDesc.Height >> DSVDesc.MostDetailedMip, 1U))
LOG_ERROR("Depth-stencil target height (", std::max(TexDesc.Height >> DSVDesc.MostDetailedMip, 1U), ") specified by DSV '", DSVDesc.Name, "' is inconsistent with the height of previously bound render targets (", m_FramebufferHeight, ")");
@@ -633,7 +643,7 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
if (m_pBoundDepthStencil != pDepthStencil)
{
m_pBoundDepthStencil = ValidatedCast<TextureViewImplType>(pDepthStencil);
- bBindRenderTargets = true;
+ bBindRenderTargets = true;
}
@@ -642,47 +652,47 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
return bBindRenderTargets;
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
- GetRenderTargets( Uint32 &NumRenderTargets, ITextureView** ppRTVs, ITextureView** ppDSV )
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::
+ GetRenderTargets(Uint32& NumRenderTargets, ITextureView** ppRTVs, ITextureView** ppDSV)
{
NumRenderTargets = m_NumBoundRenderTargets;
- if ( ppRTVs )
+ if (ppRTVs)
{
- for( Uint32 rt = 0; rt < NumRenderTargets; ++rt )
+ for (Uint32 rt = 0; rt < NumRenderTargets; ++rt)
{
- VERIFY( ppRTVs[rt] == nullptr, "Non-null pointer found in RTV array element #", rt );
+ VERIFY(ppRTVs[rt] == nullptr, "Non-null pointer found in RTV array element #", rt);
auto pBoundRTV = m_pBoundRenderTargets[rt];
- if ( pBoundRTV )
- pBoundRTV->QueryInterface( IID_TextureView, reinterpret_cast<IObject**>(ppRTVs + rt) );
+ if (pBoundRTV)
+ pBoundRTV->QueryInterface(IID_TextureView, reinterpret_cast<IObject**>(ppRTVs + rt));
else
ppRTVs[rt] = nullptr;
}
- for( Uint32 rt = NumRenderTargets; rt < MaxRenderTargets; ++rt )
+ for (Uint32 rt = NumRenderTargets; rt < MaxRenderTargets; ++rt)
{
- VERIFY( ppRTVs[rt] == nullptr, "Non-null pointer found in RTV array element #", rt );
+ VERIFY(ppRTVs[rt] == nullptr, "Non-null pointer found in RTV array element #", rt);
ppRTVs[rt] = nullptr;
}
}
- if ( ppDSV )
+ if (ppDSV)
{
- VERIFY(* ppDSV == nullptr, "Non-null DSV pointer found" );
- if ( m_pBoundDepthStencil )
- m_pBoundDepthStencil->QueryInterface( IID_TextureView, reinterpret_cast<IObject**>(ppDSV) );
+ VERIFY(*ppDSV == nullptr, "Non-null DSV pointer found");
+ if (m_pBoundDepthStencil)
+ m_pBoundDepthStencil->QueryInterface(IID_TextureView, reinterpret_cast<IObject**>(ppDSV));
else
- * ppDSV = nullptr;
+ *ppDSV = nullptr;
}
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> :: ClearStateCache()
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::ClearStateCache()
{
- for(Uint32 stream=0; stream < m_NumVertexStreams; ++stream)
+ for (Uint32 stream = 0; stream < m_NumVertexStreams; ++stream)
m_VertexStreams[stream] = VertexStreamInfo<BufferImplType>{};
#ifdef _DEBUG
- for(Uint32 stream=m_NumVertexStreams; stream < _countof(m_VertexStreams); ++stream)
+ for (Uint32 stream = m_NumVertexStreams; stream < _countof(m_VertexStreams); ++stream)
{
VERIFY(m_VertexStreams[stream].pBuffer == nullptr, "Unexpected non-null buffer");
VERIFY(m_VertexStreams[stream].Offset == 0, "Unexpected non-zero offset");
@@ -697,22 +707,22 @@ inline void DeviceContextBase<BaseInterface,ImplementationTraits> :: ClearStateC
m_StencilRef = 0;
- for( int i = 0; i < 4; ++i )
+ for (int i = 0; i < 4; ++i)
m_BlendFactors[i] = -1;
- for(Uint32 vp=0; vp < m_NumViewports; ++vp)
+ for (Uint32 vp = 0; vp < m_NumViewports; ++vp)
m_Viewports[vp] = Viewport();
m_NumViewports = 0;
- for(Uint32 sr=0; sr < m_NumScissorRects; ++sr)
+ for (Uint32 sr = 0; sr < m_NumScissorRects; ++sr)
m_ScissorRects[sr] = Rect();
m_NumScissorRects = 0;
ResetRenderTargets();
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> :: ResetRenderTargets()
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::ResetRenderTargets()
{
for (Uint32 rt = 0; rt < m_NumBoundRenderTargets; ++rt)
m_pBoundRenderTargets[rt].Release();
@@ -722,55 +732,55 @@ inline void DeviceContextBase<BaseInterface,ImplementationTraits> :: ResetRender
VERIFY(m_pBoundRenderTargets[rt] == nullptr, "Non-null render target found");
}
#endif
- m_NumBoundRenderTargets = 0;
- m_FramebufferWidth = 0;
- m_FramebufferHeight = 0;
- m_FramebufferSlices = 0;
+ m_NumBoundRenderTargets = 0;
+ m_FramebufferWidth = 0;
+ m_FramebufferHeight = 0;
+ m_FramebufferSlices = 0;
m_IsDefaultFramebufferBound = false;
m_pBoundDepthStencil.Release();
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
- UpdateBuffer(IBuffer* pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::
+ UpdateBuffer(IBuffer* pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)
{
VERIFY(pBuffer != nullptr, "Buffer must not be null");
#ifdef DEVELOPMENT
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, ")" );
+ 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, ")");
#endif
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
- CopyBuffer(IBuffer* pSrcBuffer,
- Uint32 SrcOffset,
- RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode,
- IBuffer* pDstBuffer,
- Uint32 DstOffset,
- Uint32 Size,
- RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode)
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::
+ CopyBuffer(IBuffer* pSrcBuffer,
+ Uint32 SrcOffset,
+ RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode,
+ IBuffer* pDstBuffer,
+ Uint32 DstOffset,
+ Uint32 Size,
+ RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode)
{
VERIFY(pSrcBuffer != nullptr, "Source buffer must not be null");
VERIFY(pDstBuffer != nullptr, "Destination buffer must not be null");
#ifdef DEVELOPMENT
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, ")" );
+ 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, ")");
#endif
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
- MapBuffer( IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData )
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::
+ MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData)
{
VERIFY(pBuffer, "pBuffer must not be null");
-
+
const auto& BuffDesc = pBuffer->GetDesc();
#ifdef _DEBUG
@@ -779,45 +789,45 @@ inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
#endif
pMappedData = nullptr;
- switch( MapType )
+ switch (MapType)
{
- case MAP_READ:
- DEV_CHECK_ERR( BuffDesc.Usage == USAGE_STAGING, "Only buffers with usage USAGE_STAGING can be read from" );
- DEV_CHECK_ERR( (BuffDesc.CPUAccessFlags & CPU_ACCESS_READ), "Buffer being mapped for reading was not created with CPU_ACCESS_READ flag" );
- DEV_CHECK_ERR( (MapFlags & MAP_FLAG_DISCARD) == 0, "MAP_FLAG_DISCARD is not valid when mapping buffer for reading" );
- break;
+ case MAP_READ:
+ DEV_CHECK_ERR(BuffDesc.Usage == USAGE_STAGING, "Only buffers with usage USAGE_STAGING can be read from");
+ DEV_CHECK_ERR((BuffDesc.CPUAccessFlags & CPU_ACCESS_READ), "Buffer being mapped for reading was not created with CPU_ACCESS_READ flag");
+ DEV_CHECK_ERR((MapFlags & MAP_FLAG_DISCARD) == 0, "MAP_FLAG_DISCARD is not valid when mapping buffer for reading");
+ break;
- case MAP_WRITE:
- DEV_CHECK_ERR( BuffDesc.Usage == USAGE_DYNAMIC || BuffDesc.Usage == USAGE_STAGING, "Only buffers with usage USAGE_STAGING or USAGE_DYNAMIC can be mapped for writing" );
- DEV_CHECK_ERR( (BuffDesc.CPUAccessFlags & CPU_ACCESS_WRITE), "Buffer being mapped for writing was not created with CPU_ACCESS_WRITE flag" );
- break;
+ case MAP_WRITE:
+ DEV_CHECK_ERR(BuffDesc.Usage == USAGE_DYNAMIC || BuffDesc.Usage == USAGE_STAGING, "Only buffers with usage USAGE_STAGING or USAGE_DYNAMIC can be mapped for writing");
+ DEV_CHECK_ERR((BuffDesc.CPUAccessFlags & CPU_ACCESS_WRITE), "Buffer being mapped for writing was not created with CPU_ACCESS_WRITE flag");
+ break;
- case MAP_READ_WRITE:
- DEV_CHECK_ERR( BuffDesc.Usage == USAGE_STAGING, "Only buffers with usage USAGE_STAGING can be mapped for reading and writing" );
- DEV_CHECK_ERR( (BuffDesc.CPUAccessFlags & CPU_ACCESS_WRITE), "Buffer being mapped for reading & writing was not created with CPU_ACCESS_WRITE flag" );
- DEV_CHECK_ERR( (BuffDesc.CPUAccessFlags & CPU_ACCESS_READ), "Buffer being mapped for reading & writing was not created with CPU_ACCESS_READ flag" );
- DEV_CHECK_ERR( (MapFlags & MAP_FLAG_DISCARD) == 0, "MAP_FLAG_DISCARD is not valid when mapping buffer for reading and writing" );
- break;
+ case MAP_READ_WRITE:
+ DEV_CHECK_ERR(BuffDesc.Usage == USAGE_STAGING, "Only buffers with usage USAGE_STAGING can be mapped for reading and writing");
+ DEV_CHECK_ERR((BuffDesc.CPUAccessFlags & CPU_ACCESS_WRITE), "Buffer being mapped for reading & writing was not created with CPU_ACCESS_WRITE flag");
+ DEV_CHECK_ERR((BuffDesc.CPUAccessFlags & CPU_ACCESS_READ), "Buffer being mapped for reading & writing was not created with CPU_ACCESS_READ flag");
+ DEV_CHECK_ERR((MapFlags & MAP_FLAG_DISCARD) == 0, "MAP_FLAG_DISCARD is not valid when mapping buffer for reading and writing");
+ break;
- default: UNEXPECTED( "Unknown map type" );
+ default: UNEXPECTED("Unknown map type");
}
-
+
if (BuffDesc.Usage == USAGE_DYNAMIC)
{
DEV_CHECK_ERR((MapFlags & (MAP_FLAG_DISCARD | MAP_FLAG_DO_NOT_SYNCHRONIZE)) != 0 && MapType == MAP_WRITE, "Dynamic buffers can only be mapped for writing with MAP_FLAG_DISCARD or MAP_FLAG_DO_NOT_SYNCHRONIZE flag");
DEV_CHECK_ERR((MapFlags & (MAP_FLAG_DISCARD | MAP_FLAG_DO_NOT_SYNCHRONIZE)) != (MAP_FLAG_DISCARD | MAP_FLAG_DO_NOT_SYNCHRONIZE), "When mapping dynamic buffer, only one of MAP_FLAG_DISCARD or MAP_FLAG_DO_NOT_SYNCHRONIZE flags must be specified");
}
- if ( (MapFlags & MAP_FLAG_DISCARD) != 0 )
+ if ((MapFlags & MAP_FLAG_DISCARD) != 0)
{
- DEV_CHECK_ERR( BuffDesc.Usage == USAGE_DYNAMIC || BuffDesc.Usage == USAGE_STAGING, "Only dynamic and staging buffers can be mapped with discard flag" );
- DEV_CHECK_ERR( MapType == MAP_WRITE, "MAP_FLAG_DISCARD is only valid when mapping buffer for writing" );
+ DEV_CHECK_ERR(BuffDesc.Usage == USAGE_DYNAMIC || BuffDesc.Usage == USAGE_STAGING, "Only dynamic and staging buffers can be mapped with discard flag");
+ DEV_CHECK_ERR(MapType == MAP_WRITE, "MAP_FLAG_DISCARD is only valid when mapping buffer for writing");
}
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
- UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType)
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::
+ UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType)
{
VERIFY(pBuffer, "pBuffer must not be null");
#ifdef _DEBUG
@@ -829,107 +839,112 @@ inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
- UpdateTexture(ITexture* pTexture, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData,
- RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode)
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::
+ UpdateTexture(ITexture* pTexture, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData, RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode)
{
- VERIFY( pTexture != nullptr, "pTexture must not be null" );
- ValidateUpdateTextureParams( pTexture->GetDesc(), MipLevel, Slice, DstBox, SubresData );
+ VERIFY(pTexture != nullptr, "pTexture must not be null");
+ ValidateUpdateTextureParams(pTexture->GetDesc(), MipLevel, Slice, DstBox, SubresData);
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
- CopyTexture( const CopyTextureAttribs& CopyAttribs )
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::
+ CopyTexture(const CopyTextureAttribs& CopyAttribs)
{
- VERIFY( CopyAttribs.pSrcTexture, "Src texture must not be null" );
- VERIFY( CopyAttribs.pDstTexture, "Dst texture must not be null" );
- ValidateCopyTextureParams( CopyAttribs );
+ VERIFY(CopyAttribs.pSrcTexture, "Src texture must not be null");
+ VERIFY(CopyAttribs.pDstTexture, "Dst texture must not be null");
+ ValidateCopyTextureParams(CopyAttribs);
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
- MapTextureSubresource(ITexture* pTexture,
- Uint32 MipLevel,
- Uint32 ArraySlice,
- MAP_TYPE MapType,
- MAP_FLAGS MapFlags,
- const Box* pMapRegion,
- MappedTextureSubresource& MappedData)
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::
+ MapTextureSubresource(ITexture* pTexture,
+ Uint32 MipLevel,
+ Uint32 ArraySlice,
+ MAP_TYPE MapType,
+ MAP_FLAGS MapFlags,
+ const Box* pMapRegion,
+ MappedTextureSubresource& MappedData)
{
VERIFY(pTexture, "pTexture must not be null");
ValidateMapTextureParams(pTexture->GetDesc(), MipLevel, ArraySlice, MapType, MapFlags, pMapRegion);
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
- UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice)
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::
+ 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");
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
- GenerateMips(ITextureView* pTexView)
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::
+ GenerateMips(ITextureView* pTexView)
{
VERIFY(pTexView != nullptr, "pTexView must not be null");
#ifdef DEVELOPMENT
const auto& ViewDesc = pTexView->GetDesc();
DEV_CHECK_ERR(ViewDesc.ViewType == TEXTURE_VIEW_SHADER_RESOURCE, "Shader resource view '", ViewDesc.Name,
- "' can't be used to generate mipmaps because its type is ", GetTexViewTypeLiteralName(ViewDesc.ViewType), ". Required view type: TEXTURE_VIEW_SHADER_RESOURCE." );
+ "' can't be used to generate mipmaps because its type is ", GetTexViewTypeLiteralName(ViewDesc.ViewType), ". Required view type: TEXTURE_VIEW_SHADER_RESOURCE.");
DEV_CHECK_ERR((ViewDesc.Flags & TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION) != 0, "Shader resource view '", ViewDesc.Name,
"' was not created with TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION flag and can't be used to generate mipmaps.");
#endif
}
-template<typename BaseInterface, typename ImplementationTraits>
-void DeviceContextBase<BaseInterface,ImplementationTraits> ::
- ResolveTextureSubresource(ITexture* pSrcTexture,
- ITexture* pDstTexture,
- const ResolveTextureSubresourceAttribs& ResolveAttribs)
+template <typename BaseInterface, typename ImplementationTraits>
+void DeviceContextBase<BaseInterface, ImplementationTraits>::
+ ResolveTextureSubresource(ITexture* pSrcTexture,
+ ITexture* pDstTexture,
+ const ResolveTextureSubresourceAttribs& ResolveAttribs)
{
#ifdef DEVELOPMENT
VERIFY_EXPR(pSrcTexture != nullptr && pDstTexture != nullptr);
const auto& SrcTexDesc = pSrcTexture->GetDesc();
const auto& DstTexDesc = pDstTexture->GetDesc();
- DEV_CHECK_ERR(SrcTexDesc.SampleCount > 1, "Source texture '", SrcTexDesc.Name, "' of a resolve operation is not multi-sampled");
- DEV_CHECK_ERR(DstTexDesc.SampleCount == 1, "Destination texture '", DstTexDesc.Name, "' of a resolve operation is multi-sampled");
+ DEV_CHECK_ERR(SrcTexDesc.SampleCount > 1,
+ "Source texture '", SrcTexDesc.Name, "' of a resolve operation is not multi-sampled");
+ DEV_CHECK_ERR(DstTexDesc.SampleCount == 1,
+ "Destination texture '", DstTexDesc.Name, "' of a resolve operation is multi-sampled");
auto SrcMipLevelProps = GetMipLevelProperties(SrcTexDesc, ResolveAttribs.SrcMipLevel);
auto DstMipLevelProps = GetMipLevelProperties(DstTexDesc, ResolveAttribs.DstMipLevel);
DEV_CHECK_ERR(SrcMipLevelProps.LogicalWidth == DstMipLevelProps.LogicalWidth && SrcMipLevelProps.LogicalHeight == DstMipLevelProps.LogicalHeight,
- "The size (", SrcMipLevelProps.LogicalWidth, "x", SrcMipLevelProps.LogicalHeight, ") of the source subresource of a resolve operation "
- "(texture '", SrcTexDesc.Name, "', mip ", ResolveAttribs.SrcMipLevel, ", slice ", ResolveAttribs.SrcSlice,
+ "The size (", SrcMipLevelProps.LogicalWidth, "x", SrcMipLevelProps.LogicalHeight,
+ ") of the source subresource of a resolve operation (texture '",
+ SrcTexDesc.Name, "', mip ", ResolveAttribs.SrcMipLevel, ", slice ", ResolveAttribs.SrcSlice,
") does not match the size (", DstMipLevelProps.LogicalWidth, "x", DstMipLevelProps.LogicalHeight,
") of the destination subresource (texture '", DstTexDesc.Name, "', mip ", ResolveAttribs.DstMipLevel, ", slice ",
ResolveAttribs.DstSlice, ")");
- const auto& SrcFmtAttribs = GetTextureFormatAttribs(SrcTexDesc.Format);
- const auto& DstFmtAttribs = GetTextureFormatAttribs(DstTexDesc.Format);
+ const auto& SrcFmtAttribs = GetTextureFormatAttribs(SrcTexDesc.Format);
+ const auto& DstFmtAttribs = GetTextureFormatAttribs(DstTexDesc.Format);
const auto& ResolveFmtAttribs = GetTextureFormatAttribs(ResolveAttribs.Format);
if (!SrcFmtAttribs.IsTypeless && !DstFmtAttribs.IsTypeless)
{
- DEV_CHECK_ERR(SrcTexDesc.Format == DstTexDesc.Format, "Source (", SrcFmtAttribs.Name, ") and destination (", DstFmtAttribs.Name, ") texture formats "
- "of a resolve operation must match exaclty or be compatible typeless formats");
+ DEV_CHECK_ERR(SrcTexDesc.Format == DstTexDesc.Format,
+ "Source (", SrcFmtAttribs.Name, ") and destination (", DstFmtAttribs.Name,
+ ") texture formats of a resolve operation must match exaclty or be compatible typeless formats");
DEV_CHECK_ERR(ResolveAttribs.Format == TEX_FORMAT_UNKNOWN || SrcTexDesc.Format == ResolveAttribs.Format, "Invalid format of a resolve operation");
}
if (SrcFmtAttribs.IsTypeless && DstFmtAttribs.IsTypeless)
{
- DEV_CHECK_ERR(ResolveAttribs.Format != TEX_FORMAT_UNKNOWN, "Format of a resolve operation must not be unknown when both src and dst texture formats are typeless");
+ DEV_CHECK_ERR(ResolveAttribs.Format != TEX_FORMAT_UNKNOWN,
+ "Format of a resolve operation must not be unknown when both src and dst texture formats are typeless");
}
if (SrcFmtAttribs.IsTypeless || DstFmtAttribs.IsTypeless)
{
- DEV_CHECK_ERR(!ResolveFmtAttribs.IsTypeless, "Format of a resolve operation must not be typeless when one of the texture formats is typeless");
+ DEV_CHECK_ERR(!ResolveFmtAttribs.IsTypeless,
+ "Format of a resolve operation must not be typeless when one of the texture formats is typeless");
}
#endif
}
#ifdef DEVELOPMENT
-template<typename BaseInterface, typename ImplementationTraits>
-inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
- DvpVerifyDrawArguments(const DrawAttribs& Attribs)const
+template <typename BaseInterface, typename ImplementationTraits>
+inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::
+ DvpVerifyDrawArguments(const DrawAttribs& Attribs) const
{
if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0)
return true;
@@ -954,9 +969,9 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
return true;
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
- DvpVerifyDrawIndexedArguments(const DrawIndexedAttribs& Attribs)const
+template <typename BaseInterface, typename ImplementationTraits>
+inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::
+ DvpVerifyDrawIndexedArguments(const DrawIndexedAttribs& Attribs) const
{
if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0)
return true;
@@ -969,16 +984,18 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
if (m_pPipelineState->GetDesc().IsComputePipeline)
{
- LOG_ERROR_MESSAGE("DrawIndexed command arguments are invalid: pipeline state '", m_pPipelineState->GetDesc().Name, "' is a compute pipeline.");
+ LOG_ERROR_MESSAGE("DrawIndexed command arguments are invalid: pipeline state '",
+ m_pPipelineState->GetDesc().Name, "' is a compute pipeline.");
return false;
}
if (Attribs.IndexType != VT_UINT16 && Attribs.IndexType != VT_UINT32)
{
- LOG_ERROR_MESSAGE("DrawIndexed command arguments are invalid: IndexType (", GetValueTypeString(Attribs.IndexType), ") must be VT_UINT16 or VT_UINT32.");
+ LOG_ERROR_MESSAGE("DrawIndexed command arguments are invalid: IndexType (",
+ GetValueTypeString(Attribs.IndexType), ") must be VT_UINT16 or VT_UINT32.");
return false;
}
-
+
if (!m_pIndexBuffer)
{
LOG_ERROR_MESSAGE("DrawIndexed command arguments are invalid: no index buffer is bound.");
@@ -993,9 +1010,9 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
return true;
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
- DvpVerifyDrawIndirectArguments(const DrawIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer)const
+template <typename BaseInterface, typename ImplementationTraits>
+inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::
+ DvpVerifyDrawIndirectArguments(const DrawIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer) const
{
if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0)
return true;
@@ -1008,7 +1025,9 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
if (m_pPipelineState->GetDesc().IsComputePipeline)
{
- LOG_ERROR_MESSAGE("DrawIndirect command arguments are invalid: pipeline state '", m_pPipelineState->GetDesc().Name, "' is a compute pipeline.");
+
+ LOG_ERROR_MESSAGE("DrawIndirect command arguments are invalid: pipeline state '",
+ m_pPipelineState->GetDesc().Name, "' is a compute pipeline.");
return false;
}
@@ -1030,9 +1049,9 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
return true;
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
- DvpVerifyDrawIndexedIndirectArguments(const DrawIndexedIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer)const
+template <typename BaseInterface, typename ImplementationTraits>
+inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::
+ DvpVerifyDrawIndexedIndirectArguments(const DrawIndexedIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer) const
{
if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0)
return true;
@@ -1045,16 +1064,18 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
if (m_pPipelineState->GetDesc().IsComputePipeline)
{
- LOG_ERROR_MESSAGE("DrawIndexedIndirect command arguments are invalid: pipeline state '", m_pPipelineState->GetDesc().Name, "' is a compute pipeline.");
+ LOG_ERROR_MESSAGE("DrawIndexedIndirect command arguments are invalid: pipeline state '",
+ m_pPipelineState->GetDesc().Name, "' is a compute pipeline.");
return false;
}
if (Attribs.IndexType != VT_UINT16 && Attribs.IndexType != VT_UINT32)
{
- LOG_ERROR_MESSAGE("DrawIndexedIndirect command arguments are invalid: IndexType (", GetValueTypeString(Attribs.IndexType), ") must be VT_UINT16 or VT_UINT32.");
+ LOG_ERROR_MESSAGE("DrawIndexedIndirect command arguments are invalid: IndexType (",
+ GetValueTypeString(Attribs.IndexType), ") must be VT_UINT16 or VT_UINT32.");
return false;
}
-
+
if (!m_pIndexBuffer)
{
LOG_ERROR_MESSAGE("DrawIndexedIndirect command arguments are invalid: no index buffer is bound.");
@@ -1079,9 +1100,9 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
return true;
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
- DvpVerifyRenderTargets()const
+template <typename BaseInterface, typename ImplementationTraits>
+inline void DeviceContextBase<BaseInterface, ImplementationTraits>::
+ DvpVerifyRenderTargets() const
{
if (!m_pPipelineState)
{
@@ -1090,19 +1111,20 @@ inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
}
TEXTURE_FORMAT BoundRTVFormats[8] = {TEX_FORMAT_UNKNOWN};
- TEXTURE_FORMAT BoundDSVFormat = TEX_FORMAT_UNKNOWN;
- Uint32 NumBoundRTVs = 0;
+ TEXTURE_FORMAT BoundDSVFormat = TEX_FORMAT_UNKNOWN;
+ Uint32 NumBoundRTVs = 0;
if (m_IsDefaultFramebufferBound)
{
if (m_pSwapChain)
{
BoundRTVFormats[0] = m_pSwapChain->GetDesc().ColorBufferFormat;
- BoundDSVFormat = m_pSwapChain->GetDesc().DepthBufferFormat;
- NumBoundRTVs = 1;
+ BoundDSVFormat = m_pSwapChain->GetDesc().DepthBufferFormat;
+ NumBoundRTVs = 1;
}
else
{
- LOG_WARNING_MESSAGE("Failed to get bound render targets and depth-stencil buffer: swap chain is not initialized in the device context");
+ LOG_WARNING_MESSAGE("Failed to get bound render targets and depth-stencil buffer: "
+ "swap chain is not initialized in the device context");
return;
}
}
@@ -1120,34 +1142,40 @@ inline void DeviceContextBase<BaseInterface,ImplementationTraits> ::
BoundDSVFormat = m_pBoundDepthStencil ? m_pBoundDepthStencil->GetDesc().Format : TEX_FORMAT_UNKNOWN;
}
- const auto& PSODesc = m_pPipelineState->GetDesc();
+ const auto& PSODesc = m_pPipelineState->GetDesc();
const auto& GraphicsPipeline = PSODesc.GraphicsPipeline;
if (GraphicsPipeline.NumRenderTargets != NumBoundRTVs)
{
- LOG_WARNING_MESSAGE("Number of currently bound render targets (", NumBoundRTVs, ") does not match the number of outputs specified by the PSO '", PSODesc.Name, "' (", Uint32{GraphicsPipeline.NumRenderTargets}, ")." );
+ LOG_WARNING_MESSAGE("Number of currently bound render targets (", NumBoundRTVs,
+ ") does not match the number of outputs specified by the PSO '", PSODesc.Name,
+ "' (", Uint32{GraphicsPipeline.NumRenderTargets}, ").");
}
if (BoundDSVFormat != GraphicsPipeline.DSVFormat)
{
- LOG_WARNING_MESSAGE("Currently bound depth-stencil buffer format (", GetTextureFormatAttribs(BoundDSVFormat).Name, ") does not match the DSV format specified by the PSO '", PSODesc.Name, "' (", GetTextureFormatAttribs(GraphicsPipeline.DSVFormat).Name, ")." );
+ LOG_WARNING_MESSAGE("Currently bound depth-stencil buffer format (", GetTextureFormatAttribs(BoundDSVFormat).Name,
+ ") does not match the DSV format specified by the PSO '", PSODesc.Name,
+ "' (", GetTextureFormatAttribs(GraphicsPipeline.DSVFormat).Name, ").");
}
-
+
for (Uint32 rt = 0; rt < NumBoundRTVs; ++rt)
{
auto BoundFmt = BoundRTVFormats[rt];
- auto PSOFmt = GraphicsPipeline.RTVFormats[rt];
+ auto PSOFmt = GraphicsPipeline.RTVFormats[rt];
if (BoundFmt != PSOFmt)
{
- LOG_WARNING_MESSAGE("Render target bound to slot ", rt, " (", GetTextureFormatAttribs(BoundFmt).Name, ") does not match the RTV format specified by the PSO '", PSODesc.Name, "' (", GetTextureFormatAttribs(PSOFmt).Name, ")." );
+ LOG_WARNING_MESSAGE("Render target bound to slot ", rt, " (", GetTextureFormatAttribs(BoundFmt).Name,
+ ") does not match the RTV format specified by the PSO '", PSODesc.Name,
+ "' (", GetTextureFormatAttribs(PSOFmt).Name, ").");
}
}
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
- DvpVerifyDispatchArguments(const DispatchComputeAttribs& Attribs)const
+template <typename BaseInterface, typename ImplementationTraits>
+inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::
+ DvpVerifyDispatchArguments(const DispatchComputeAttribs& Attribs) const
{
if (!m_pPipelineState)
{
@@ -1157,7 +1185,8 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
if (!m_pPipelineState->GetDesc().IsComputePipeline)
{
- LOG_ERROR_MESSAGE("DispatchCompute command arguments are invalid: pipeline state '", m_pPipelineState->GetDesc().Name, "' is a graphics pipeline.");
+ LOG_ERROR_MESSAGE("DispatchCompute command arguments are invalid: pipeline state '", m_pPipelineState->GetDesc().Name,
+ "' is a graphics pipeline.");
return false;
}
@@ -1173,9 +1202,9 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
return true;
}
-template<typename BaseInterface, typename ImplementationTraits>
-inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
- DvpVerifyDispatchIndirectArguments(const DispatchComputeIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer)const
+template <typename BaseInterface, typename ImplementationTraits>
+inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::
+ DvpVerifyDispatchIndirectArguments(const DispatchComputeIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer) const
{
if (!m_pPipelineState)
{
@@ -1185,7 +1214,8 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
if (!m_pPipelineState->GetDesc().IsComputePipeline)
{
- LOG_ERROR_MESSAGE("DispatchComputeIndirect command arguments are invalid: pipeline state '", m_pPipelineState->GetDesc().Name, "' is a graphics pipeline.");
+ LOG_ERROR_MESSAGE("DispatchComputeIndirect command arguments are invalid: pipeline state '",
+ m_pPipelineState->GetDesc().Name, "' is a graphics pipeline.");
return false;
}
@@ -1208,9 +1238,9 @@ inline bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
}
-template<typename BaseInterface, typename ImplementationTraits>
-void DeviceContextBase<BaseInterface,ImplementationTraits> ::
- DvpVerifyStateTransitionDesc(const StateTransitionDesc& Barrier)const
+template <typename BaseInterface, typename ImplementationTraits>
+void DeviceContextBase<BaseInterface, ImplementationTraits>::
+ DvpVerifyStateTransitionDesc(const StateTransitionDesc& Barrier) const
{
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");
@@ -1218,24 +1248,30 @@ void DeviceContextBase<BaseInterface,ImplementationTraits> ::
if (Barrier.pTexture)
{
const auto& TexDesc = Barrier.pTexture->GetDesc();
-
+
DEV_CHECK_ERR(VerifyResourceStates(Barrier.NewState, true), "Invlaid new state specified for texture '", TexDesc.Name, "'");
OldState = Barrier.OldState != RESOURCE_STATE_UNKNOWN ? Barrier.OldState : Barrier.pTexture->GetState();
- DEV_CHECK_ERR(OldState != RESOURCE_STATE_UNKNOWN, "The state of texture '", TexDesc.Name, "' is unknown to the engine and is not explicitly specified in the barrier");
+ DEV_CHECK_ERR(OldState != RESOURCE_STATE_UNKNOWN,
+ "The state of texture '", TexDesc.Name,
+ "' is unknown to the engine and is not explicitly specified in the barrier");
DEV_CHECK_ERR(VerifyResourceStates(OldState, true), "Invlaid old state specified for texture '", TexDesc.Name, "'");
- DEV_CHECK_ERR(Barrier.FirstMipLevel < TexDesc.MipLevels, "First mip level (", Barrier.FirstMipLevel, ") specified by the barrier is "
- "out of range. Texture '", TexDesc.Name, "' has only ", TexDesc.MipLevels, " mip level(s)");
+ DEV_CHECK_ERR(Barrier.FirstMipLevel < TexDesc.MipLevels, "First mip level (", Barrier.FirstMipLevel,
+ ") specified by the barrier is out of range. Texture '",
+ TexDesc.Name, "' has only ", TexDesc.MipLevels, " mip level(s)");
DEV_CHECK_ERR(Barrier.MipLevelsCount == StateTransitionDesc::RemainingMipLevels || Barrier.FirstMipLevel + Barrier.MipLevelsCount <= TexDesc.MipLevels,
- "Mip level range ", Barrier.FirstMipLevel, "..", Barrier.FirstMipLevel+Barrier.MipLevelsCount-1, " "
- "specified by the barrier is out of range. Texture '", TexDesc.Name, "' has only ", TexDesc.MipLevels, " mip level(s)");
+ "Mip level range ", Barrier.FirstMipLevel, "..", Barrier.FirstMipLevel + Barrier.MipLevelsCount - 1,
+ " specified by the barrier is out of range. Texture '",
+ TexDesc.Name, "' has only ", TexDesc.MipLevels, " mip level(s)");
- DEV_CHECK_ERR(Barrier.FirstArraySlice < TexDesc.ArraySize, "First array slice (", Barrier.FirstArraySlice, ") specified by the barrier is "
- "out of range. Array size of texture '", TexDesc.Name, "' is ", TexDesc.ArraySize);
+ DEV_CHECK_ERR(Barrier.FirstArraySlice < TexDesc.ArraySize, "First array slice (", Barrier.FirstArraySlice,
+ ") specified by the barrier is out of range. Array size of texture '",
+ TexDesc.Name, "' is ", TexDesc.ArraySize);
DEV_CHECK_ERR(Barrier.ArraySliceCount == StateTransitionDesc::RemainingArraySlices || Barrier.FirstArraySlice + Barrier.ArraySliceCount <= TexDesc.ArraySize,
- "Array slice range ", Barrier.FirstArraySlice, "..", Barrier.FirstArraySlice+Barrier.ArraySliceCount-1, " "
- "specified by the barrier is out of range. Array size of texture '", TexDesc.Name, "' is ", TexDesc.ArraySize);
-
+ "Array slice range ", Barrier.FirstArraySlice, "..", Barrier.FirstArraySlice + Barrier.ArraySliceCount - 1,
+ " specified by the barrier is out of range. Array size of texture '",
+ TexDesc.Name, "' is ", TexDesc.ArraySize);
+
auto DevType = m_pDevice->GetDeviceCaps().DevType;
if (DevType != DeviceType::D3D12 && DevType != DeviceType::Vulkan)
{
@@ -1265,30 +1301,30 @@ void DeviceContextBase<BaseInterface,ImplementationTraits> ::
}
}
-template<typename BaseInterface, typename ImplementationTraits>
-bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
- DvpVerifyTextureState(const TextureImplType& Texture, RESOURCE_STATE RequiredState, const char* OperationName)const
+template <typename BaseInterface, typename ImplementationTraits>
+bool DeviceContextBase<BaseInterface, ImplementationTraits>::
+ DvpVerifyTextureState(const TextureImplType& Texture, RESOURCE_STATE RequiredState, const char* OperationName) const
{
if (Texture.IsInKnownState() && !Texture.CheckState(RequiredState))
{
- LOG_ERROR_MESSAGE(OperationName, " requires texture '", Texture.GetDesc().Name, "' to be transitioned to ", GetResourceStateString(RequiredState), " state. "
- "Actual texture state: ", GetResourceStateString(Texture.GetState()), ". "
- "Use appropriate state transiton flags or explicitly transition the texture using IDeviceContext::TransitionResourceStates() method.");
+ LOG_ERROR_MESSAGE(OperationName, " requires texture '", Texture.GetDesc().Name, "' to be transitioned to ", GetResourceStateString(RequiredState),
+ " state. Actual texture state: ", GetResourceStateString(Texture.GetState()),
+ ". Use appropriate state transiton flags or explicitly transition the texture using IDeviceContext::TransitionResourceStates() method.");
return false;
}
return true;
}
-template<typename BaseInterface, typename ImplementationTraits>
-bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
- DvpVerifyBufferState(const BufferImplType& Buffer, RESOURCE_STATE RequiredState, const char* OperationName)const
+template <typename BaseInterface, typename ImplementationTraits>
+bool DeviceContextBase<BaseInterface, ImplementationTraits>::
+ DvpVerifyBufferState(const BufferImplType& Buffer, RESOURCE_STATE RequiredState, const char* OperationName) const
{
if (Buffer.IsInKnownState() && !Buffer.CheckState(RequiredState))
{
- LOG_ERROR_MESSAGE(OperationName, " requires buffer '", Buffer.GetDesc().Name, "' to be transitioned to ", GetResourceStateString(RequiredState), " state. "
- "Actual buffer state: ", GetResourceStateString(Buffer.GetState()), ". "
- "Use appropriate state transiton flags or explicitly transition the buffer using IDeviceContext::TransitionResourceStates() method.");
+ LOG_ERROR_MESSAGE(OperationName, " requires buffer '", Buffer.GetDesc().Name, "' to be transitioned to ", GetResourceStateString(RequiredState),
+ " state. Actual buffer state: ", GetResourceStateString(Buffer.GetState()),
+ ". Use appropriate state transiton flags or explicitly transition the buffer using IDeviceContext::TransitionResourceStates() method.");
return false;
}
@@ -1297,4 +1333,4 @@ bool DeviceContextBase<BaseInterface,ImplementationTraits> ::
#endif // DEVELOPMENT
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/DeviceObjectBase.h b/Graphics/GraphicsEngine/include/DeviceObjectBase.h
index 44011d8c..cc403b13 100644
--- a/Graphics/GraphicsEngine/include/DeviceObjectBase.h
+++ b/Graphics/GraphicsEngine/include/DeviceObjectBase.h
@@ -35,9 +35,9 @@
namespace Diligent
{
-
+
/// Template class implementing base functionality for a device object
-template<class BaseInterface, typename RenderDeviceImplType, typename ObjectDescType>
+template <class BaseInterface, typename RenderDeviceImplType, typename ObjectDescType>
class DeviceObjectBase : public ObjectBase<BaseInterface>
{
public:
@@ -48,14 +48,16 @@ public:
/// \param ObjDesc - object description.
/// \param bIsDeviceInternal - flag indicating if the object is an internal device object
/// and must not keep a strong reference to the device.
- DeviceObjectBase( IReferenceCounters* pRefCounters,
- RenderDeviceImplType* pDevice,
- const ObjectDescType& ObjDesc,
- bool bIsDeviceInternal = false) :
- TBase(pRefCounters),
- m_pDevice (pDevice),
- m_Desc (ObjDesc),
- m_bIsDeviceInternal(bIsDeviceInternal)
+ DeviceObjectBase(IReferenceCounters* pRefCounters,
+ RenderDeviceImplType* pDevice,
+ const ObjectDescType& ObjDesc,
+ bool bIsDeviceInternal = false) :
+ // clang-format off
+ TBase {pRefCounters},
+ m_pDevice {pDevice },
+ m_Desc {ObjDesc },
+ m_bIsDeviceInternal{bIsDeviceInternal}
+ //clang-format on
{
// Do not keep strong reference to the device if the object is an internal device object
if (!m_bIsDeviceInternal)
@@ -65,15 +67,15 @@ public:
if (ObjDesc.Name != nullptr)
{
- auto size = strlen(ObjDesc.Name) + 1;
+ auto size = strlen(ObjDesc.Name) + 1;
auto* NameCopy = ALLOCATE(GetStringAllocator(), "Object name copy", char, size);
memcpy(NameCopy, ObjDesc.Name, size);
m_Desc.Name = NameCopy;
}
else
{
- size_t size = 16 + 2 + 1; // 0x12345678
- auto* AddressStr = ALLOCATE(GetStringAllocator(), "Object address string", char, size);
+ size_t size = 16 + 2 + 1; // 0x12345678
+ auto* AddressStr = ALLOCATE(GetStringAllocator(), "Object address string", char, size);
snprintf(AddressStr, size, "0x%llX", static_cast<unsigned long long>(reinterpret_cast<size_t>(this)));
m_Desc.Name = AddressStr;
}
@@ -85,10 +87,12 @@ public:
//m_pDevice->AddResourceToHash( this ); - ERROR!
}
+ // clang-format off
DeviceObjectBase (const DeviceObjectBase& ) = delete;
DeviceObjectBase ( DeviceObjectBase&&) = delete;
DeviceObjectBase& operator = (const DeviceObjectBase& ) = delete;
DeviceObjectBase& operator = ( DeviceObjectBase&&) = delete;
+ // clang-format on
virtual ~DeviceObjectBase()
{
@@ -100,43 +104,42 @@ public:
}
}
- inline virtual Atomics::Long Release()override final
+ inline virtual Atomics::Long Release() override final
{
// Render device owns allocators for all types of device objects,
- // so it must be destroyed after all device objects are released.
- // Consider the following scenario: an object A owns the last strong
+ // so it must be destroyed after all device objects are released.
+ // Consider the following scenario: an object A owns the last strong
// reference to the device:
- //
+ //
// 1. A::~A() completes
// 2. A::~DeviceObjectBase() completes
// 3. A::m_pDevice is released
// Render device is destroyed, all allocators are invalid
- // 4. RefCountersImpl::ObjectWrapperBase::DestroyObject() calls
+ // 4. RefCountersImpl::ObjectWrapperBase::DestroyObject() calls
// m_pAllocator->Free(m_pObject) - crash!
-
+
RefCntAutoPtr<RenderDeviceImplType> pDevice;
return TBase::Release(
- [&]()
- {
- // We must keep the device alive while the object is being destroyed
- // Note that internal device objects do not keep strong reference to the device
- if (!m_bIsDeviceInternal)
- {
- pDevice = m_pDevice;
- }
- }
- );
+ [&]() // clang-format off
+ { // clang-format on
+ // We must keep the device alive while the object is being destroyed
+ // Note that internal device objects do not keep strong reference to the device
+ if (!m_bIsDeviceInternal)
+ {
+ pDevice = m_pDevice;
+ }
+ });
}
- IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_DeviceObject, TBase )
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_DeviceObject, TBase)
- virtual const ObjectDescType& GetDesc()const override final
+ virtual const ObjectDescType& GetDesc() const override final
{
return m_Desc;
}
/// Returns unique identifier
- virtual Int32 GetUniqueID()const override final
+ virtual Int32 GetUniqueID() const override final
{
/// \note
/// This unique ID is used to unambiguously identify device object for
@@ -153,19 +156,19 @@ public:
return Id1 == Id2;
}
- RenderDeviceImplType* GetDevice()const{return m_pDevice;}
-
+ RenderDeviceImplType* GetDevice() const { return m_pDevice; }
+
protected:
/// Pointer to the device
RenderDeviceImplType* const m_pDevice;
/// Object description
ObjectDescType m_Desc;
-
- // Template argument is only used to separate counters for
+
+ // Template argument is only used to separate counters for
// different groups of objects
UniqueIdHelper<BaseInterface> m_UniqueID;
const bool m_bIsDeviceInternal;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/EngineFactoryBase.h b/Graphics/GraphicsEngine/include/EngineFactoryBase.h
index 12294dcd..54815a06 100644
--- a/Graphics/GraphicsEngine/include/EngineFactoryBase.h
+++ b/Graphics/GraphicsEngine/include/EngineFactoryBase.h
@@ -40,19 +40,21 @@ const APIInfo& GetAPIInfo();
/// \tparam BaseInterface - base interface that this class will inheret
/// (Diligent::IEngineFactoryD3D11, Diligent::IEngineFactoryD3D12,
/// Diligent::IEngineFactoryVk or Diligent::IEngineFactoryOpenGL).
-template<class BaseInterface>
+template <class BaseInterface>
class EngineFactoryBase : public BaseInterface
{
public:
using CounterValueType = IReferenceCounters::CounterValueType;
- EngineFactoryBase(const INTERFACE_ID& FactoryIID)noexcept :
+ EngineFactoryBase(const INTERFACE_ID& FactoryIID) noexcept :
+ // clang-format off
m_FactoryIID {FactoryIID},
m_RefCounters {*this }
+ // clang-format on
{
}
- virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override final
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final
{
if (ppInterface == nullptr)
return;
@@ -65,17 +67,17 @@ public:
}
}
- virtual CounterValueType AddRef()override final
+ virtual CounterValueType AddRef() override final
{
return m_RefCounters.AddStrongRef();
}
- virtual CounterValueType Release()override final
+ virtual CounterValueType Release() override final
{
return m_RefCounters.ReleaseStrongRef();
}
- virtual IReferenceCounters* GetReferenceCounters()const override final
+ virtual IReferenceCounters* GetReferenceCounters() const override final
{
return const_cast<IReferenceCounters*>(static_cast<const IReferenceCounters*>(&m_RefCounters));
}
@@ -85,8 +87,8 @@ public:
return Diligent::GetAPIInfo();
}
- virtual void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories,
- IShaderSourceInputStreamFactory** ppShaderSourceFactory)const override final
+ virtual void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories,
+ IShaderSourceInputStreamFactory** ppShaderSourceFactory) const override final
{
Diligent::CreateDefaultShaderSourceStreamFactory(SearchDirectories, ppShaderSourceFactory);
}
@@ -95,8 +97,8 @@ private:
class DummyReferenceCounters final : public IReferenceCounters
{
public:
- DummyReferenceCounters(EngineFactoryBase& Factory)noexcept :
- m_Factory {Factory}
+ DummyReferenceCounters(EngineFactoryBase& Factory) noexcept :
+ m_Factory{Factory}
{
m_lNumStrongReferences = 0;
m_lNumWeakReferences = 0;
@@ -108,44 +110,45 @@ private:
return Atomics::AtomicIncrement(m_lNumStrongReferences);
}
- virtual CounterValueType ReleaseStrongRef()override final
+ virtual CounterValueType ReleaseStrongRef() override final
{
return Atomics::AtomicDecrement(m_lNumStrongReferences);
}
- virtual CounterValueType AddWeakRef()override final
+ virtual CounterValueType AddWeakRef() override final
{
return Atomics::AtomicIncrement(m_lNumWeakReferences);
}
-
- virtual CounterValueType ReleaseWeakRef()override final
+
+ virtual CounterValueType ReleaseWeakRef() override final
{
return Atomics::AtomicDecrement(m_lNumWeakReferences);
}
- virtual void GetObject(IObject** ppObject)override final
+ virtual void GetObject(IObject** ppObject) override final
{
if (ppObject != nullptr)
m_Factory.QueryInterface(IID_Unknown, ppObject);
}
- virtual CounterValueType GetNumStrongRefs()const override final
+ virtual CounterValueType GetNumStrongRefs() const override final
{
return m_lNumStrongReferences;
}
- virtual CounterValueType GetNumWeakRefs()const override final
+ virtual CounterValueType GetNumWeakRefs() const override final
{
return m_lNumWeakReferences;
}
+
private:
- EngineFactoryBase& m_Factory;
+ EngineFactoryBase& m_Factory;
Atomics::AtomicLong m_lNumStrongReferences;
Atomics::AtomicLong m_lNumWeakReferences;
};
- const INTERFACE_ID m_FactoryIID;
+ const INTERFACE_ID m_FactoryIID;
DummyReferenceCounters m_RefCounters;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/EngineMemory.h b/Graphics/GraphicsEngine/include/EngineMemory.h
index bfa37f94..7c52fb08 100644
--- a/Graphics/GraphicsEngine/include/EngineMemory.h
+++ b/Graphics/GraphicsEngine/include/EngineMemory.h
@@ -30,20 +30,20 @@
namespace Diligent
{
- /// Sets raw memory allocator. This function must be called before any memory allocation/deallocation function
- /// is called.
- void SetRawAllocator(IMemoryAllocator *pRawAllocator);
+/// Sets raw memory allocator. This function must be called before any memory allocation/deallocation function
+/// is called.
+void SetRawAllocator(IMemoryAllocator* pRawAllocator);
- /// Returns raw memory allocator
- IMemoryAllocator& GetRawAllocator();
+/// Returns raw memory allocator
+IMemoryAllocator& GetRawAllocator();
- IMemoryAllocator& GetStringAllocator();
+IMemoryAllocator& GetStringAllocator();
-#define ALLOCATE_RAW(Allocator, Desc, Size) (Allocator).Allocate(Size, Desc, __FILE__, __LINE__)
+#define ALLOCATE_RAW(Allocator, Desc, Size) (Allocator).Allocate(Size, Desc, __FILE__, __LINE__)
#define ALLOCATE(Allocator, Desc, Type, Count) reinterpret_cast<Type*>(ALLOCATE_RAW(Allocator, Desc, sizeof(Type) * (Count)))
-#define FREE(Allocator, Ptr) Allocator.Free(Ptr)
+#define FREE(Allocator, Ptr) Allocator.Free(Ptr)
-}
+} // namespace Diligent
#if 0
@@ -68,10 +68,10 @@ inline void operator delete[](void* Ptr, const char* dbgDescription, const char*
Diligent::GetRawAllocator().Free(Ptr);
}
-#define MemAlloc(Size, Desc) GetRawAllocator().Allocate(Size, Desc, __FILE__, __LINE__)
-#define MemFree(Ptr) GetRawAllocator().Free(Ptr)
-#define New(Desc) new(Desc, __FILE__, __LINE__)
-#define Delete delete
+# define MemAlloc(Size, Desc) GetRawAllocator().Allocate(Size, Desc, __FILE__, __LINE__)
+# define MemFree(Ptr) GetRawAllocator().Free(Ptr)
+# define New(Desc) new (Desc, __FILE__, __LINE__)
+# define Delete delete
#endif \ No newline at end of file
diff --git a/Graphics/GraphicsEngine/include/FenceBase.h b/Graphics/GraphicsEngine/include/FenceBase.h
index 4c13677c..f71e1c45 100644
--- a/Graphics/GraphicsEngine/include/FenceBase.h
+++ b/Graphics/GraphicsEngine/include/FenceBase.h
@@ -42,7 +42,7 @@ class IFence;
/// (Diligent::IFenceD3D11, Diligent::IFenceD3D12,
/// Diligent::IFenceGL or Diligent::IFenceVk).
/// \tparam RenderDeviceImplType - type of the render device implementation
-template<class BaseInterface, class RenderDeviceImplType>
+template <class BaseInterface, class RenderDeviceImplType>
class FenceBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, FenceDesc>
{
public:
@@ -50,18 +50,18 @@ public:
/// \param pRefCounters - reference counters object that controls the lifetime of this command list.
/// \param Desc - fence description
- /// \param pDevice - pointer to the device.
- /// \param bIsDeviceInternal - flag indicating if the Fence is an internal device object and
- /// must not keep a strong reference to the device.
- FenceBase( IReferenceCounters* pRefCounters, RenderDeviceImplType* pDevice, const FenceDesc& Desc, bool bIsDeviceInternal = false ) :
- TDeviceObjectBase( pRefCounters, pDevice, Desc, bIsDeviceInternal )
+ /// \param pDevice - pointer to the device.
+ /// \param bIsDeviceInternal - flag indicating if the Fence is an internal device object and
+ /// must not keep a strong reference to the device.
+ FenceBase(IReferenceCounters* pRefCounters, RenderDeviceImplType* pDevice, const FenceDesc& Desc, bool bIsDeviceInternal = false) :
+ TDeviceObjectBase{pRefCounters, pDevice, Desc, bIsDeviceInternal}
{}
~FenceBase()
{
}
- IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_Fence, TDeviceObjectBase )
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_Fence, TDeviceObjectBase)
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/PipelineStateBase.h b/Graphics/GraphicsEngine/include/PipelineStateBase.h
index f4a7a9bf..bcd03b3f 100644
--- a/Graphics/GraphicsEngine/include/PipelineStateBase.h
+++ b/Graphics/GraphicsEngine/include/PipelineStateBase.h
@@ -47,42 +47,42 @@ namespace Diligent
/// \tparam RenderDeviceImplType - type of the render device implementation
/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl,
/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl)
-template<class BaseInterface, class RenderDeviceImplType>
+template <class BaseInterface, class RenderDeviceImplType>
class PipelineStateBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, PipelineStateDesc>
{
public:
using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, PipelineStateDesc>;
/// \param pRefCounters - reference counters object that controls the lifetime of this PSO
- /// \param pDevice - pointer to the device.
- /// \param PSODesc - pipeline state description.
- /// \param bIsDeviceInternal - flag indicating if the blend state is an internal device object and
- /// must not keep a strong reference to the device.
- PipelineStateBase( IReferenceCounters* pRefCounters,
- RenderDeviceImplType* pDevice,
- const PipelineStateDesc& PSODesc,
- bool bIsDeviceInternal = false ) :
- TDeviceObjectBase {pRefCounters, pDevice, PSODesc, bIsDeviceInternal},
+ /// \param pDevice - pointer to the device.
+ /// \param PSODesc - pipeline state description.
+ /// \param bIsDeviceInternal - flag indicating if the blend state is an internal device object and
+ /// must not keep a strong reference to the device.
+ PipelineStateBase(IReferenceCounters* pRefCounters,
+ RenderDeviceImplType* pDevice,
+ const PipelineStateDesc& PSODesc,
+ bool bIsDeviceInternal = false) :
+ TDeviceObjectBase{pRefCounters, pDevice, PSODesc, bIsDeviceInternal},
m_NumShaders{0}
{
- const auto& SrcLayout = PSODesc.ResourceLayout;
- size_t StringPoolSize = 0;
+ const auto& SrcLayout = PSODesc.ResourceLayout;
+ size_t StringPoolSize = 0;
if (SrcLayout.Variables != nullptr)
{
- for (Uint32 i=0; i < SrcLayout.NumVariables; ++i)
+ for (Uint32 i = 0; i < SrcLayout.NumVariables; ++i)
StringPoolSize += strlen(SrcLayout.Variables[i].Name) + 1;
}
-
+
if (SrcLayout.StaticSamplers != nullptr)
{
- for (Uint32 i=0; i < SrcLayout.NumStaticSamplers; ++i)
+ for (Uint32 i = 0; i < SrcLayout.NumStaticSamplers; ++i)
StringPoolSize += strlen(SrcLayout.StaticSamplers[i].SamplerOrTextureName) + 1;
}
if (!PSODesc.IsComputePipeline)
{
const auto& InputLayout = PSODesc.GraphicsPipeline.InputLayout;
- for (Uint32 i=0; i < InputLayout.NumElements; ++i)
+ for (Uint32 i = 0; i < InputLayout.NumElements; ++i)
StringPoolSize += strlen(InputLayout.LayoutElements[i].HLSLSemantic) + 1;
}
else
@@ -98,10 +98,10 @@ public:
ShaderResourceVariableDesc* Variables =
ALLOCATE(GetRawAllocator(), "Memory for ShaderResourceVariableDesc array", ShaderResourceVariableDesc, SrcLayout.NumVariables);
DstLayout.Variables = Variables;
- for (Uint32 i=0; i < SrcLayout.NumVariables; ++i)
+ for (Uint32 i = 0; i < SrcLayout.NumVariables; ++i)
{
VERIFY(SrcLayout.Variables[i].Name != nullptr, "Variable name can't be null");
- Variables[i] = SrcLayout.Variables[i];
+ Variables[i] = SrcLayout.Variables[i];
Variables[i].Name = m_StringPool.CopyString(SrcLayout.Variables[i].Name);
}
}
@@ -111,22 +111,22 @@ public:
StaticSamplerDesc* StaticSamplers =
ALLOCATE(GetRawAllocator(), "Memory for StaticSamplerDesc array", StaticSamplerDesc, SrcLayout.NumStaticSamplers);
DstLayout.StaticSamplers = StaticSamplers;
- for (Uint32 i=0; i < SrcLayout.NumStaticSamplers; ++i)
+ for (Uint32 i = 0; i < SrcLayout.NumStaticSamplers; ++i)
{
VERIFY(SrcLayout.StaticSamplers[i].SamplerOrTextureName != nullptr, "Static sampler or texture name can't be null");
#ifdef DEVELOPMENT
- const auto &BorderColor = SrcLayout.StaticSamplers[i].Desc.BorderColor;
- if( !( (BorderColor[0] == 0 && BorderColor[1] == 0 && BorderColor[2] == 0 && BorderColor[3] == 0) ||
- (BorderColor[0] == 0 && BorderColor[1] == 0 && BorderColor[2] == 0 && BorderColor[3] == 1) ||
- (BorderColor[0] == 1 && BorderColor[1] == 1 && BorderColor[2] == 1 && BorderColor[3] == 1) ) )
+ const auto& BorderColor = SrcLayout.StaticSamplers[i].Desc.BorderColor;
+ if (!((BorderColor[0] == 0 && BorderColor[1] == 0 && BorderColor[2] == 0 && BorderColor[3] == 0) ||
+ (BorderColor[0] == 0 && BorderColor[1] == 0 && BorderColor[2] == 0 && BorderColor[3] == 1) ||
+ (BorderColor[0] == 1 && BorderColor[1] == 1 && BorderColor[2] == 1 && BorderColor[3] == 1)))
{
LOG_WARNING_MESSAGE("Static sampler for variable \"", SrcLayout.StaticSamplers[i].SamplerOrTextureName, "\" specifies border color (",
- BorderColor[0], ", ", BorderColor[1], ", ", BorderColor[2], ", ", BorderColor[3], "). "
- "D3D12 static samplers only allow transparent black (0,0,0,0), opaque black (0,0,0,1) or opaque white (1,1,1,1) as border colors");
+ BorderColor[0], ", ", BorderColor[1], ", ", BorderColor[2], ", ", BorderColor[3],
+ "). D3D12 static samplers only allow transparent black (0,0,0,0), opaque black (0,0,0,1) or opaque white (1,1,1,1) as border colors");
}
#endif
- StaticSamplers[i] = SrcLayout.StaticSamplers[i];
+ StaticSamplers[i] = SrcLayout.StaticSamplers[i];
StaticSamplers[i].SamplerOrTextureName = m_StringPool.CopyString(SrcLayout.StaticSamplers[i].SamplerOrTextureName);
}
}
@@ -134,32 +134,33 @@ public:
if (this->m_Desc.IsComputePipeline)
{
- const auto &ComputePipeline = PSODesc.ComputePipeline;
+ const auto& ComputePipeline = PSODesc.ComputePipeline;
if (ComputePipeline.pCS == nullptr)
{
- LOG_ERROR_AND_THROW( "Compute shader is not provided" );
+ LOG_ERROR_AND_THROW("Compute shader is not provided");
}
-#define VALIDATE_SHADER_TYPE(Shader, ExpectedType, ShaderName)\
- if (Shader && Shader->GetDesc().ShaderType != ExpectedType) \
- { \
- LOG_ERROR_AND_THROW( GetShaderTypeLiteralName(Shader->GetDesc().ShaderType), " is not a valid type for ", ShaderName, " shader" );\
- }
+#define VALIDATE_SHADER_TYPE(Shader, ExpectedType, ShaderName) \
+ if (Shader && Shader->GetDesc().ShaderType != ExpectedType) \
+ { \
+ LOG_ERROR_AND_THROW(GetShaderTypeLiteralName(Shader->GetDesc().ShaderType), " is not a valid type for ", ShaderName, " shader"); \
+ }
+
VALIDATE_SHADER_TYPE(ComputePipeline.pCS, SHADER_TYPE_COMPUTE, "compute")
m_pCS = ComputePipeline.pCS;
m_ppShaders[0] = ComputePipeline.pCS;
- m_NumShaders = 1;
+ m_NumShaders = 1;
}
else
{
const auto& GraphicsPipeline = PSODesc.GraphicsPipeline;
- VALIDATE_SHADER_TYPE(GraphicsPipeline.pVS, SHADER_TYPE_VERTEX, "vertex")
- VALIDATE_SHADER_TYPE(GraphicsPipeline.pPS, SHADER_TYPE_PIXEL, "pixel")
+ VALIDATE_SHADER_TYPE(GraphicsPipeline.pVS, SHADER_TYPE_VERTEX, "vertex")
+ VALIDATE_SHADER_TYPE(GraphicsPipeline.pPS, SHADER_TYPE_PIXEL, "pixel")
VALIDATE_SHADER_TYPE(GraphicsPipeline.pGS, SHADER_TYPE_GEOMETRY, "geometry")
- VALIDATE_SHADER_TYPE(GraphicsPipeline.pHS, SHADER_TYPE_HULL, "hull")
- VALIDATE_SHADER_TYPE(GraphicsPipeline.pDS, SHADER_TYPE_DOMAIN, "domain")
+ VALIDATE_SHADER_TYPE(GraphicsPipeline.pHS, SHADER_TYPE_HULL, "hull")
+ VALIDATE_SHADER_TYPE(GraphicsPipeline.pDS, SHADER_TYPE_DOMAIN, "domain")
#undef VALIDATE_SHADER_TYPE
m_pVS = GraphicsPipeline.pVS;
@@ -173,7 +174,7 @@ public:
if (GraphicsPipeline.pGS) m_ppShaders[m_NumShaders++] = GraphicsPipeline.pGS;
if (GraphicsPipeline.pHS) m_ppShaders[m_NumShaders++] = GraphicsPipeline.pHS;
if (GraphicsPipeline.pDS) m_ppShaders[m_NumShaders++] = GraphicsPipeline.pDS;
-
+
DEV_CHECK_ERR(m_NumShaders > 0, "There must be at least one shader in the Pipeline State");
for (Uint32 rt = GraphicsPipeline.NumRenderTargets; rt < _countof(GraphicsPipeline.RTVFormats); ++rt)
@@ -186,7 +187,7 @@ public:
}
}
- const auto& InputLayout = PSODesc.GraphicsPipeline.InputLayout;
+ const auto& InputLayout = PSODesc.GraphicsPipeline.InputLayout;
LayoutElement* pLayoutElements = nullptr;
if (InputLayout.NumElements > 0)
{
@@ -198,7 +199,7 @@ public:
pLayoutElements[Elem] = InputLayout.LayoutElements[Elem];
pLayoutElements[Elem].HLSLSemantic = m_StringPool.CopyString(InputLayout.LayoutElements[Elem].HLSLSemantic);
}
-
+
// Correct description and compute offsets and tight strides
std::array<Uint32, MaxBufferSlots> Strides, TightStrides = {};
@@ -206,17 +207,17 @@ public:
for (auto& Stride : Strides)
Stride = LayoutElement::AutoStride;
- for (Uint32 i=0; i < InputLayout.NumElements; ++i)
+ for (Uint32 i = 0; i < InputLayout.NumElements; ++i)
{
auto& LayoutElem = pLayoutElements[i];
- if( LayoutElem.ValueType == VT_FLOAT32 || LayoutElem.ValueType == VT_FLOAT16 )
+ if (LayoutElem.ValueType == VT_FLOAT32 || LayoutElem.ValueType == VT_FLOAT16)
LayoutElem.IsNormalized = false; // Floating point values cannot be normalized
auto BuffSlot = LayoutElem.BufferSlot;
if (BuffSlot >= Strides.size())
{
- UNEXPECTED("Buffer slot (", BuffSlot, ") exceeds maximum allowed value (", Strides.size()-1, ")");
+ UNEXPECTED("Buffer slot (", BuffSlot, ") exceeds maximum allowed value (", Strides.size() - 1, ")");
continue;
}
m_BufferSlotsUsed = std::max(m_BufferSlotsUsed, BuffSlot + 1);
@@ -234,10 +235,11 @@ public:
// Verify that the value is consistent with the previously specified stride, if any
if (Strides[BuffSlot] != LayoutElement::AutoStride && Strides[BuffSlot] != LayoutElem.Stride)
{
- LOG_ERROR_MESSAGE("Inconsistent strides are specified for buffer slot ", BuffSlot, ". "
- "Input element at index ", LayoutElem.InputIndex, " explicitly specifies stride ", LayoutElem.Stride, ", "
- "while current value is ", Strides[BuffSlot], ". Specify consistent strides or use "
- "LayoutElement::AutoStride to allow the engine compute strides automatically.");
+ LOG_ERROR_MESSAGE("Inconsistent strides are specified for buffer slot ", BuffSlot,
+ ". Input element at index ", LayoutElem.InputIndex, " explicitly specifies stride ",
+ LayoutElem.Stride, ", while current value is ", Strides[BuffSlot],
+ ". Specify consistent strides or use LayoutElement::AutoStride to allow "
+ "the engine compute strides automatically.");
}
Strides[BuffSlot] = LayoutElem.Stride;
}
@@ -245,7 +247,7 @@ public:
CurrAutoStride = std::max(CurrAutoStride, LayoutElem.RelativeOffset + LayoutElem.NumComponents * GetValueSize(LayoutElem.ValueType));
}
- for (Uint32 i=0; i < InputLayout.NumElements; ++i)
+ for (Uint32 i = 0; i < InputLayout.NumElements; ++i)
{
auto& LayoutElem = pLayoutElements[i];
@@ -259,8 +261,9 @@ public:
{
if (Strides[BuffSlot] < TightStrides[BuffSlot])
{
- LOG_ERROR_MESSAGE("Stride ", Strides[BuffSlot], " explicitly specified for slot ", BuffSlot, " is smaller than the "
- "minimum stride ", TightStrides[BuffSlot], " required to accomodate all input elements.");
+ LOG_ERROR_MESSAGE("Stride ", Strides[BuffSlot], " explicitly specified for slot ", BuffSlot,
+ " is smaller than the minimum stride ", TightStrides[BuffSlot],
+ " required to accomodate all input elements.");
}
}
if (LayoutElem.Stride == LayoutElement::AutoStride)
@@ -272,9 +275,9 @@ public:
m_pStrides = ALLOCATE(GetRawAllocator(), "Raw memory for buffer strides", Uint32, m_BufferSlotsUsed);
// Set strides for all unused slots to 0
- for (Uint32 i=0; i < m_BufferSlotsUsed; ++i)
+ for (Uint32 i = 0; i < m_BufferSlotsUsed; ++i)
{
- auto Stride = Strides[i];
+ auto Stride = Strides[i];
m_pStrides[i] = Stride != LayoutElement::AutoStride ? Stride : 0;
}
}
@@ -283,7 +286,9 @@ public:
VERIFY_EXPR(m_StringPool.GetRemainingSize() == 0);
Uint64 DeviceQueuesMask = pDevice->GetCommandQueueMask();
- DEV_CHECK_ERR( (this->m_Desc.CommandQueueMask & DeviceQueuesMask) != 0, "No bits in the command queue mask (0x", std::hex, this->m_Desc.CommandQueueMask, ") correspond to one of ", pDevice->GetCommandQueueCount(), " available device command queues");
+ DEV_CHECK_ERR((this->m_Desc.CommandQueueMask & DeviceQueuesMask) != 0,
+ "No bits in the command queue mask (0x", std::hex, this->m_Desc.CommandQueueMask,
+ ") correspond to one of ", pDevice->GetCommandQueueCount(), " available device command queues");
this->m_Desc.CommandQueueMask &= DeviceQueuesMask;
}
@@ -318,36 +323,36 @@ public:
RawAllocator.Free(m_pStrides);
}
- IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_PipelineState, TDeviceObjectBase )
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_PipelineState, TDeviceObjectBase)
- Uint32 GetBufferStride(Uint32 BufferSlot)const
- {
+ Uint32 GetBufferStride(Uint32 BufferSlot) const
+ {
return BufferSlot < m_BufferSlotsUsed ? m_pStrides[BufferSlot] : 0;
}
- Uint32 GetNumBufferSlotsUsed()const
+ Uint32 GetNumBufferSlotsUsed() const
{
return m_BufferSlotsUsed;
}
- IShader* GetVS(){return m_pVS;}
- IShader* GetPS(){return m_pPS;}
- IShader* GetGS(){return m_pGS;}
- IShader* GetDS(){return m_pDS;}
- IShader* GetHS(){return m_pHS;}
- IShader* GetCS(){return m_pCS;}
+ IShader* GetVS() { return m_pVS; }
+ IShader* GetPS() { return m_pPS; }
+ IShader* GetGS() { return m_pGS; }
+ IShader* GetDS() { return m_pDS; }
+ IShader* GetHS() { return m_pHS; }
+ IShader* GetCS() { return m_pCS; }
- IShader* const* GetShaders()const{return m_ppShaders;}
- Uint32 GetNumShaders()const{return m_NumShaders;}
+ IShader* const* GetShaders() const { return m_ppShaders; }
+ Uint32 GetNumShaders() const { return m_NumShaders; }
- template<typename ShaderType>
+ template <typename ShaderType>
ShaderType* GetShader(Uint32 ShaderInd)
{
VERIFY_EXPR(ShaderInd < m_NumShaders);
return ValidatedCast<ShaderType>(m_ppShaders[ShaderInd]);
}
- template<typename ShaderType>
- ShaderType* GetShader(Uint32 ShaderInd)const
+ template <typename ShaderType>
+ ShaderType* GetShader(Uint32 ShaderInd) const
{
VERIFY_EXPR(ShaderInd < m_NumShaders);
return ValidatedCast<ShaderType>(m_ppShaders[ShaderInd]);
@@ -355,26 +360,27 @@ public:
// This function only compares shader resource layout hashes, so
// it can potentially give false negatives
- bool IsIncompatibleWith(const IPipelineState* pPSO)const
+ bool IsIncompatibleWith(const IPipelineState* pPSO) const
{
return m_ShaderResourceLayoutHash != ValidatedCast<const PipelineStateBase>(pPSO)->m_ShaderResourceLayoutHash;
}
protected:
-
- Uint32 m_BufferSlotsUsed = 0;
- Uint32 m_NumShaders = 0; ///< Number of shaders that this PSO uses
- Uint32* m_pStrides = nullptr;
+ Uint32 m_BufferSlotsUsed = 0;
+ Uint32 m_NumShaders = 0; ///< Number of shaders that this PSO uses
+ Uint32* m_pStrides = nullptr;
StringPool m_StringPool;
+
RefCntAutoPtr<IShader> m_pVS; ///< Strong reference to the vertex shader
RefCntAutoPtr<IShader> m_pPS; ///< Strong reference to the pixel shader
RefCntAutoPtr<IShader> m_pGS; ///< Strong reference to the geometry shader
RefCntAutoPtr<IShader> m_pDS; ///< Strong reference to the domain shader
RefCntAutoPtr<IShader> m_pHS; ///< Strong reference to the hull shader
RefCntAutoPtr<IShader> m_pCS; ///< Strong reference to the compute shader
- IShader* m_ppShaders[5] = {}; ///< Array of pointers to the shaders used by this PSO
- size_t m_ShaderResourceLayoutHash = 0;///< Hash computed from the shader resource layout
+
+ IShader* m_ppShaders[5] = {}; ///< Array of pointers to the shaders used by this PSO
+ size_t m_ShaderResourceLayoutHash = 0; ///< Hash computed from the shader resource layout
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/RenderDeviceBase.h b/Graphics/GraphicsEngine/include/RenderDeviceBase.h
index c373df1d..a9aed5d3 100644
--- a/Graphics/GraphicsEngine/include/RenderDeviceBase.h
+++ b/Graphics/GraphicsEngine/include/RenderDeviceBase.h
@@ -42,129 +42,129 @@
namespace std
{
- /// Hash function specialization for Diligent::SamplerDesc structure.
- template<>
- struct hash<Diligent::SamplerDesc>
+/// Hash function specialization for Diligent::SamplerDesc structure.
+template <>
+struct hash<Diligent::SamplerDesc>
+{
+ size_t operator()(const Diligent::SamplerDesc& SamDesc) const
{
- size_t operator()( const Diligent::SamplerDesc& SamDesc ) const
- {
- // Sampler name is ignored in comparison operator
- // and should not be hashed
- return Diligent::ComputeHash( // SamDesc.Name,
- static_cast<int>(SamDesc.MinFilter),
- static_cast<int>(SamDesc.MagFilter),
- static_cast<int>(SamDesc.MipFilter),
- static_cast<int>(SamDesc.AddressU),
- static_cast<int>(SamDesc.AddressV),
- static_cast<int>(SamDesc.AddressW),
- SamDesc.MipLODBias,
- SamDesc.MaxAnisotropy,
- static_cast<int>(SamDesc.ComparisonFunc),
- SamDesc.BorderColor[0],
- SamDesc.BorderColor[1],
- SamDesc.BorderColor[2],
- SamDesc.BorderColor[3],
- SamDesc.MinLOD, SamDesc.MaxLOD );
- }
- };
+ // Sampler name is ignored in comparison operator
+ // and should not be hashed
+ return Diligent::ComputeHash( // SamDesc.Name,
+ static_cast<int>(SamDesc.MinFilter),
+ static_cast<int>(SamDesc.MagFilter),
+ static_cast<int>(SamDesc.MipFilter),
+ static_cast<int>(SamDesc.AddressU),
+ static_cast<int>(SamDesc.AddressV),
+ static_cast<int>(SamDesc.AddressW),
+ SamDesc.MipLODBias,
+ SamDesc.MaxAnisotropy,
+ static_cast<int>(SamDesc.ComparisonFunc),
+ SamDesc.BorderColor[0],
+ SamDesc.BorderColor[1],
+ SamDesc.BorderColor[2],
+ SamDesc.BorderColor[3],
+ SamDesc.MinLOD, SamDesc.MaxLOD);
+ }
+};
- /// Hash function specialization for Diligent::StencilOpDesc structure.
- template<>
- struct hash<Diligent::StencilOpDesc>
+/// Hash function specialization for Diligent::StencilOpDesc structure.
+template <>
+struct hash<Diligent::StencilOpDesc>
+{
+ size_t operator()(const Diligent::StencilOpDesc& StOpDesc) const
{
- size_t operator()( const Diligent::StencilOpDesc& StOpDesc ) const
- {
- return Diligent::ComputeHash( static_cast<int>( StOpDesc.StencilFailOp ),
- static_cast<int>( StOpDesc.StencilDepthFailOp ),
- static_cast<int>( StOpDesc.StencilPassOp ),
- static_cast<int>( StOpDesc.StencilFunc ) );
- }
- };
+ return Diligent::ComputeHash(static_cast<int>(StOpDesc.StencilFailOp),
+ static_cast<int>(StOpDesc.StencilDepthFailOp),
+ static_cast<int>(StOpDesc.StencilPassOp),
+ static_cast<int>(StOpDesc.StencilFunc));
+ }
+};
- /// Hash function specialization for Diligent::DepthStencilStateDesc structure.
- template<>
- struct hash<Diligent::DepthStencilStateDesc>
+/// Hash function specialization for Diligent::DepthStencilStateDesc structure.
+template <>
+struct hash<Diligent::DepthStencilStateDesc>
+{
+ size_t operator()(const Diligent::DepthStencilStateDesc& DepthStencilDesc) const
{
- size_t operator()( const Diligent::DepthStencilStateDesc& DepthStencilDesc ) const
- {
- return Diligent::ComputeHash( DepthStencilDesc.DepthEnable,
- DepthStencilDesc.DepthWriteEnable,
- static_cast<int>(DepthStencilDesc.DepthFunc),
- DepthStencilDesc.StencilEnable,
- DepthStencilDesc.StencilReadMask,
- DepthStencilDesc.StencilWriteMask,
- DepthStencilDesc.FrontFace,
- DepthStencilDesc.BackFace );
- }
- };
+ return Diligent::ComputeHash(DepthStencilDesc.DepthEnable,
+ DepthStencilDesc.DepthWriteEnable,
+ static_cast<int>(DepthStencilDesc.DepthFunc),
+ DepthStencilDesc.StencilEnable,
+ DepthStencilDesc.StencilReadMask,
+ DepthStencilDesc.StencilWriteMask,
+ DepthStencilDesc.FrontFace,
+ DepthStencilDesc.BackFace);
+ }
+};
- /// Hash function specialization for Diligent::RasterizerStateDesc structure.
- template<>
- struct hash<Diligent::RasterizerStateDesc>
+/// Hash function specialization for Diligent::RasterizerStateDesc structure.
+template <>
+struct hash<Diligent::RasterizerStateDesc>
+{
+ size_t operator()(const Diligent::RasterizerStateDesc& RasterizerDesc) const
{
- size_t operator()( const Diligent::RasterizerStateDesc& RasterizerDesc ) const
- {
- return Diligent::ComputeHash( static_cast<int>( RasterizerDesc.FillMode ),
- static_cast<int>( RasterizerDesc.CullMode ),
- RasterizerDesc.FrontCounterClockwise,
- RasterizerDesc.DepthBias,
- RasterizerDesc.DepthBiasClamp,
- RasterizerDesc.SlopeScaledDepthBias,
- RasterizerDesc.DepthClipEnable,
- RasterizerDesc.ScissorEnable,
- RasterizerDesc.AntialiasedLineEnable );
- }
- };
+ return Diligent::ComputeHash(static_cast<int>(RasterizerDesc.FillMode),
+ static_cast<int>(RasterizerDesc.CullMode),
+ RasterizerDesc.FrontCounterClockwise,
+ RasterizerDesc.DepthBias,
+ RasterizerDesc.DepthBiasClamp,
+ RasterizerDesc.SlopeScaledDepthBias,
+ RasterizerDesc.DepthClipEnable,
+ RasterizerDesc.ScissorEnable,
+ RasterizerDesc.AntialiasedLineEnable);
+ }
+};
- /// Hash function specialization for Diligent::BlendStateDesc structure.
- template<>
- struct hash<Diligent::BlendStateDesc>
+/// Hash function specialization for Diligent::BlendStateDesc structure.
+template <>
+struct hash<Diligent::BlendStateDesc>
+{
+ size_t operator()(const Diligent::BlendStateDesc& BSDesc) const
{
- size_t operator()( const Diligent::BlendStateDesc& BSDesc ) const
+ std::size_t Seed = 0;
+ for (int i = 0; i < Diligent::BlendStateDesc::MaxRenderTargets; ++i)
{
- std::size_t Seed = 0;
- for( int i = 0; i < Diligent::BlendStateDesc::MaxRenderTargets; ++i )
- {
- const auto& rt = BSDesc.RenderTargets[i];
- Diligent::HashCombine( Seed,
- rt.BlendEnable,
- static_cast<int>( rt.SrcBlend ),
- static_cast<int>( rt.DestBlend ),
- static_cast<int>( rt.BlendOp ),
- static_cast<int>( rt.SrcBlendAlpha ),
- static_cast<int>( rt.DestBlendAlpha ),
- static_cast<int>( rt.BlendOpAlpha ),
- rt.RenderTargetWriteMask );
- }
- Diligent::HashCombine( Seed,
- BSDesc.AlphaToCoverageEnable,
- BSDesc.IndependentBlendEnable );
- return Seed;
+ const auto& rt = BSDesc.RenderTargets[i];
+ Diligent::HashCombine(Seed,
+ rt.BlendEnable,
+ static_cast<int>(rt.SrcBlend),
+ static_cast<int>(rt.DestBlend),
+ static_cast<int>(rt.BlendOp),
+ static_cast<int>(rt.SrcBlendAlpha),
+ static_cast<int>(rt.DestBlendAlpha),
+ static_cast<int>(rt.BlendOpAlpha),
+ rt.RenderTargetWriteMask);
}
- };
+ Diligent::HashCombine(Seed,
+ BSDesc.AlphaToCoverageEnable,
+ BSDesc.IndependentBlendEnable);
+ return Seed;
+ }
+};
- /// Hash function specialization for Diligent::TextureViewDesc structure.
- template<>
- struct hash<Diligent::TextureViewDesc>
+/// Hash function specialization for Diligent::TextureViewDesc structure.
+template <>
+struct hash<Diligent::TextureViewDesc>
+{
+ size_t operator()(const Diligent::TextureViewDesc& TexViewDesc) const
{
- size_t operator()( const Diligent::TextureViewDesc& TexViewDesc ) const
- {
- std::size_t Seed = 0;
- Diligent::HashCombine( Seed,
- static_cast<Diligent::Int32>(TexViewDesc.ViewType),
- static_cast<Diligent::Int32>(TexViewDesc.TextureDim),
- static_cast<Diligent::Int32>(TexViewDesc.Format),
- TexViewDesc.MostDetailedMip,
- TexViewDesc.NumMipLevels,
- TexViewDesc.FirstArraySlice,
- TexViewDesc.NumArraySlices,
- static_cast<Diligent::Uint32>(TexViewDesc.AccessFlags),
- static_cast<Diligent::Uint32>(TexViewDesc.Flags));
- return Seed;
- }
- };
-}
+ std::size_t Seed = 0;
+ Diligent::HashCombine(Seed,
+ static_cast<Diligent::Int32>(TexViewDesc.ViewType),
+ static_cast<Diligent::Int32>(TexViewDesc.TextureDim),
+ static_cast<Diligent::Int32>(TexViewDesc.Format),
+ TexViewDesc.MostDetailedMip,
+ TexViewDesc.NumMipLevels,
+ TexViewDesc.FirstArraySlice,
+ TexViewDesc.NumArraySlices,
+ static_cast<Diligent::Uint32>(TexViewDesc.AccessFlags),
+ static_cast<Diligent::Uint32>(TexViewDesc.Flags));
+ return Seed;
+ }
+};
+} // namespace std
namespace Diligent
{
@@ -178,11 +178,10 @@ namespace Diligent
/// Device context, swap chain and all object the device creates
/// keep strong reference to the device.
/// Device only holds weak reference to the immediate context.
-template<typename BaseInterface>
+template <typename BaseInterface>
class RenderDeviceBase : public ObjectBase<BaseInterface>
{
public:
-
using TObjectBase = ObjectBase<BaseInterface>;
/// Describes the sizes of device objects
@@ -219,124 +218,125 @@ public:
/// \param pRefCounters - reference counters object that controls the lifetime of this render device
/// \param RawMemAllocator - allocator that will be used to allocate memory for all device objects (including render device itself)
/// \param pEngineFactory - engine factory that was used to create this device
- /// \param NumDeferredContexts - number of deferred device contexts
+ /// \param NumDeferredContexts - number of deferred device contexts
/// \param ObjectSizes - device object sizes
///
/// \remarks Render device uses fixed block allocators (see FixedBlockMemoryAllocator) to allocate memory for
/// device objects. The object sizes provided to constructor are used to initialize the allocators.
RenderDeviceBase(IReferenceCounters* pRefCounters,
- IMemoryAllocator& RawMemAllocator,
+ IMemoryAllocator& RawMemAllocator,
IEngineFactory* pEngineFactory,
Uint32 NumDeferredContexts,
const DeviceObjectSizes& ObjectSizes) :
- TObjectBase (pRefCounters),
- m_pEngineFactory (pEngineFactory),
- m_SamplersRegistry (RawMemAllocator, "sampler"),
- m_TextureFormatsInfo (TEX_FORMAT_NUM_FORMATS, TextureFormatInfoExt(), STD_ALLOCATOR_RAW_MEM(TextureFormatInfoExt, RawMemAllocator, "Allocator for vector<TextureFormatInfoExt>") ),
- m_TexFmtInfoInitFlags (TEX_FORMAT_NUM_FORMATS, false, STD_ALLOCATOR_RAW_MEM(bool, RawMemAllocator, "Allocator for vector<bool>") ),
- m_wpDeferredContexts (NumDeferredContexts, RefCntWeakPtr<IDeviceContext>(), STD_ALLOCATOR_RAW_MEM(RefCntWeakPtr<IDeviceContext>, RawMemAllocator, "Allocator for vector< RefCntWeakPtr<IDeviceContext> >")),
- m_RawMemAllocator (RawMemAllocator),
- m_TexObjAllocator (RawMemAllocator, ObjectSizes.TextureObjSize, 64),
- m_TexViewObjAllocator (RawMemAllocator, ObjectSizes.TexViewObjSize, 64),
- m_BufObjAllocator (RawMemAllocator, ObjectSizes.BufferObjSize, 128),
- m_BuffViewObjAllocator (RawMemAllocator, ObjectSizes.BuffViewObjSize, 128),
- m_ShaderObjAllocator (RawMemAllocator, ObjectSizes.ShaderObjSize, 32),
- m_SamplerObjAllocator (RawMemAllocator, ObjectSizes.SamplerObjSize, 32),
- m_PSOAllocator (RawMemAllocator, ObjectSizes.PSOSize, 128),
- m_SRBAllocator (RawMemAllocator, ObjectSizes.SRBSize, 1024),
- m_ResMappingAllocator (RawMemAllocator, sizeof(ResourceMappingImpl), 16),
- m_FenceAllocator (RawMemAllocator, ObjectSizes.FenceSize, 16)
+ // clang-format off
+ TObjectBase {pRefCounters},
+ m_pEngineFactory {pEngineFactory},
+ m_SamplersRegistry {RawMemAllocator, "sampler"},
+ m_TextureFormatsInfo {TEX_FORMAT_NUM_FORMATS, TextureFormatInfoExt(), STD_ALLOCATOR_RAW_MEM(TextureFormatInfoExt, RawMemAllocator, "Allocator for vector<TextureFormatInfoExt>")},
+ m_TexFmtInfoInitFlags {TEX_FORMAT_NUM_FORMATS, false, STD_ALLOCATOR_RAW_MEM(bool, RawMemAllocator, "Allocator for vector<bool>")},
+ m_wpDeferredContexts {NumDeferredContexts, RefCntWeakPtr<IDeviceContext>(), STD_ALLOCATOR_RAW_MEM(RefCntWeakPtr<IDeviceContext>, RawMemAllocator, "Allocator for vector< RefCntWeakPtr<IDeviceContext> >")},
+ m_RawMemAllocator {RawMemAllocator},
+ m_TexObjAllocator {RawMemAllocator, ObjectSizes.TextureObjSize, 64 },
+ m_TexViewObjAllocator {RawMemAllocator, ObjectSizes.TexViewObjSize, 64 },
+ m_BufObjAllocator {RawMemAllocator, ObjectSizes.BufferObjSize, 128 },
+ m_BuffViewObjAllocator {RawMemAllocator, ObjectSizes.BuffViewObjSize, 128 },
+ m_ShaderObjAllocator {RawMemAllocator, ObjectSizes.ShaderObjSize, 32 },
+ m_SamplerObjAllocator {RawMemAllocator, ObjectSizes.SamplerObjSize, 32 },
+ m_PSOAllocator {RawMemAllocator, ObjectSizes.PSOSize, 128 },
+ m_SRBAllocator {RawMemAllocator, ObjectSizes.SRBSize, 1024},
+ m_ResMappingAllocator {RawMemAllocator, sizeof(ResourceMappingImpl), 16 },
+ m_FenceAllocator {RawMemAllocator, ObjectSizes.FenceSize, 16 }
+ // clang-format on
{
// Initialize texture format info
- for( Uint32 Fmt = TEX_FORMAT_UNKNOWN; Fmt < TEX_FORMAT_NUM_FORMATS; ++Fmt )
- static_cast<TextureFormatAttribs&>(m_TextureFormatsInfo[Fmt]) = GetTextureFormatAttribs( static_cast<TEXTURE_FORMAT>(Fmt) );
+ for (Uint32 Fmt = TEX_FORMAT_UNKNOWN; Fmt < TEX_FORMAT_NUM_FORMATS; ++Fmt)
+ static_cast<TextureFormatAttribs&>(m_TextureFormatsInfo[Fmt]) = GetTextureFormatAttribs(static_cast<TEXTURE_FORMAT>(Fmt));
// https://msdn.microsoft.com/en-us/library/windows/desktop/ff471325(v=vs.85).aspx
TEXTURE_FORMAT FilterableFormats[] =
- {
- TEX_FORMAT_RGBA32_FLOAT, // OpenGL ES3.1 does not require this format to be filterable
- TEX_FORMAT_RGBA16_FLOAT,
- TEX_FORMAT_RGBA16_UNORM,
- TEX_FORMAT_RGBA16_SNORM,
- TEX_FORMAT_RG32_FLOAT, // OpenGL ES3.1 does not require this format to be filterable
- TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS,
- //TEX_FORMAT_R10G10B10A2_UNORM,
- TEX_FORMAT_R11G11B10_FLOAT,
- TEX_FORMAT_RGBA8_UNORM,
- TEX_FORMAT_RGBA8_UNORM_SRGB,
- TEX_FORMAT_RGBA8_SNORM,
- TEX_FORMAT_RG16_FLOAT,
- TEX_FORMAT_RG16_UNORM,
- TEX_FORMAT_RG16_SNORM,
- TEX_FORMAT_R32_FLOAT, // OpenGL ES3.1 does not require this format to be filterable
- TEX_FORMAT_R24_UNORM_X8_TYPELESS,
- TEX_FORMAT_RG8_UNORM,
- TEX_FORMAT_RG8_SNORM,
- TEX_FORMAT_R16_FLOAT,
- TEX_FORMAT_R16_UNORM,
- TEX_FORMAT_R16_SNORM,
- TEX_FORMAT_R8_UNORM,
- TEX_FORMAT_R8_SNORM,
- TEX_FORMAT_A8_UNORM,
- TEX_FORMAT_RGB9E5_SHAREDEXP,
- TEX_FORMAT_RG8_B8G8_UNORM,
- TEX_FORMAT_G8R8_G8B8_UNORM,
- TEX_FORMAT_BC1_UNORM,
- TEX_FORMAT_BC1_UNORM_SRGB,
- TEX_FORMAT_BC2_UNORM,
- TEX_FORMAT_BC2_UNORM_SRGB,
- TEX_FORMAT_BC3_UNORM,
- TEX_FORMAT_BC3_UNORM_SRGB,
- TEX_FORMAT_BC4_UNORM,
- TEX_FORMAT_BC4_SNORM,
- TEX_FORMAT_BC5_UNORM,
- TEX_FORMAT_BC5_SNORM,
- TEX_FORMAT_B5G6R5_UNORM
- };
- for( Uint32 fmt = 0; fmt < _countof(FilterableFormats); ++fmt )
- m_TextureFormatsInfo[ FilterableFormats[fmt] ].Filterable = true;
+ {
+ TEX_FORMAT_RGBA32_FLOAT, // OpenGL ES3.1 does not require this format to be filterable
+ TEX_FORMAT_RGBA16_FLOAT,
+ TEX_FORMAT_RGBA16_UNORM,
+ TEX_FORMAT_RGBA16_SNORM,
+ TEX_FORMAT_RG32_FLOAT, // OpenGL ES3.1 does not require this format to be filterable
+ TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS,
+ //TEX_FORMAT_R10G10B10A2_UNORM,
+ TEX_FORMAT_R11G11B10_FLOAT,
+ TEX_FORMAT_RGBA8_UNORM,
+ TEX_FORMAT_RGBA8_UNORM_SRGB,
+ TEX_FORMAT_RGBA8_SNORM,
+ TEX_FORMAT_RG16_FLOAT,
+ TEX_FORMAT_RG16_UNORM,
+ TEX_FORMAT_RG16_SNORM,
+ TEX_FORMAT_R32_FLOAT, // OpenGL ES3.1 does not require this format to be filterable
+ TEX_FORMAT_R24_UNORM_X8_TYPELESS,
+ TEX_FORMAT_RG8_UNORM,
+ TEX_FORMAT_RG8_SNORM,
+ TEX_FORMAT_R16_FLOAT,
+ TEX_FORMAT_R16_UNORM,
+ TEX_FORMAT_R16_SNORM,
+ TEX_FORMAT_R8_UNORM,
+ TEX_FORMAT_R8_SNORM,
+ TEX_FORMAT_A8_UNORM,
+ TEX_FORMAT_RGB9E5_SHAREDEXP,
+ TEX_FORMAT_RG8_B8G8_UNORM,
+ TEX_FORMAT_G8R8_G8B8_UNORM,
+ TEX_FORMAT_BC1_UNORM,
+ TEX_FORMAT_BC1_UNORM_SRGB,
+ TEX_FORMAT_BC2_UNORM,
+ TEX_FORMAT_BC2_UNORM_SRGB,
+ TEX_FORMAT_BC3_UNORM,
+ TEX_FORMAT_BC3_UNORM_SRGB,
+ TEX_FORMAT_BC4_UNORM,
+ TEX_FORMAT_BC4_SNORM,
+ TEX_FORMAT_BC5_UNORM,
+ TEX_FORMAT_BC5_SNORM,
+ TEX_FORMAT_B5G6R5_UNORM};
+ for (Uint32 fmt = 0; fmt < _countof(FilterableFormats); ++fmt)
+ m_TextureFormatsInfo[FilterableFormats[fmt]].Filterable = true;
}
~RenderDeviceBase()
{
}
- IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_RenderDevice, ObjectBase<BaseInterface> )
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_RenderDevice, ObjectBase<BaseInterface>)
// It is important to have final implementation of Release() method to avoid
// virtual calls
- inline virtual IReferenceCounters::CounterValueType Release()override final
+ inline virtual IReferenceCounters::CounterValueType Release() override final
{
return TObjectBase::Release();
}
/// Implementation of IRenderDevice::CreateResourceMapping().
- virtual void CreateResourceMapping( const ResourceMappingDesc &MappingDesc, IResourceMapping **ppMapping )override final;
-
+ virtual void CreateResourceMapping(const ResourceMappingDesc& MappingDesc, IResourceMapping** ppMapping) override final;
+
/// Implementation of IRenderDevice::GetDeviceCaps().
- virtual const DeviceCaps& GetDeviceCaps()const override final
+ virtual const DeviceCaps& GetDeviceCaps() const override final
{
return m_DeviceCaps;
}
/// Implementation of IRenderDevice::GetTextureFormatInfo().
- virtual const TextureFormatInfo& GetTextureFormatInfo(TEXTURE_FORMAT TexFormat)override final
+ virtual const TextureFormatInfo& GetTextureFormatInfo(TEXTURE_FORMAT TexFormat) override final
{
- VERIFY( TexFormat >= TEX_FORMAT_UNKNOWN && TexFormat < TEX_FORMAT_NUM_FORMATS, "Texture format out of range" );
+ VERIFY(TexFormat >= TEX_FORMAT_UNKNOWN && TexFormat < TEX_FORMAT_NUM_FORMATS, "Texture format out of range");
const auto& TexFmtInfo = m_TextureFormatsInfo[TexFormat];
- VERIFY( TexFmtInfo.Format == TexFormat, "Sanity check failed" );
+ VERIFY(TexFmtInfo.Format == TexFormat, "Sanity check failed");
return TexFmtInfo;
}
/// Implementation of IRenderDevice::GetTextureFormatInfoExt().
- virtual const TextureFormatInfoExt& GetTextureFormatInfoExt( TEXTURE_FORMAT TexFormat )override final
+ virtual const TextureFormatInfoExt& GetTextureFormatInfoExt(TEXTURE_FORMAT TexFormat) override final
{
- VERIFY( TexFormat >= TEX_FORMAT_UNKNOWN && TexFormat < TEX_FORMAT_NUM_FORMATS, "Texture format out of range" );
+ VERIFY(TexFormat >= TEX_FORMAT_UNKNOWN && TexFormat < TEX_FORMAT_NUM_FORMATS, "Texture format out of range");
const auto& TexFmtInfo = m_TextureFormatsInfo[TexFormat];
- VERIFY( TexFmtInfo.Format == TexFormat, "Sanity check failed" );
- if( !m_TexFmtInfoInitFlags[TexFormat] )
+ VERIFY(TexFmtInfo.Format == TexFormat, "Sanity check failed");
+ if (!m_TexFmtInfoInitFlags[TexFormat])
{
- if( TexFmtInfo.Supported )
+ if (TexFmtInfo.Supported)
TestTextureFormat(TexFormat);
m_TexFmtInfoInitFlags[TexFormat] = true;
}
@@ -352,42 +352,41 @@ public:
{
}
- StateObjectsRegistry<SamplerDesc>& GetSamplerRegistry(){ return m_SamplersRegistry; }
-
+ StateObjectsRegistry<SamplerDesc>& GetSamplerRegistry() { return m_SamplersRegistry; }
+
/// Set weak reference to the immediate context
void SetImmediateContext(IDeviceContext* pImmediateContext)
{
- VERIFY( m_wpImmediateContext.Lock() == nullptr, "Immediate context has already been set" );
+ VERIFY(m_wpImmediateContext.Lock() == nullptr, "Immediate context has already been set");
m_wpImmediateContext = pImmediateContext;
}
/// Set weak reference to the deferred context
void SetDeferredContext(size_t Ctx, IDeviceContext* pDeferredCtx)
{
- VERIFY( m_wpDeferredContexts[Ctx].Lock() == nullptr, "Deferred context has already been set" );
+ VERIFY(m_wpDeferredContexts[Ctx].Lock() == nullptr, "Deferred context has already been set");
m_wpDeferredContexts[Ctx] = pDeferredCtx;
}
/// Returns number of deferred contexts
- size_t GetNumDeferredContexts()const
+ size_t GetNumDeferredContexts() const
{
return m_wpDeferredContexts.size();
}
- RefCntAutoPtr<IDeviceContext> GetImmediateContext(){ return m_wpImmediateContext.Lock(); }
- RefCntAutoPtr<IDeviceContext> GetDeferredContext(size_t Ctx){ return m_wpDeferredContexts[Ctx].Lock(); }
+ RefCntAutoPtr<IDeviceContext> GetImmediateContext() { return m_wpImmediateContext.Lock(); }
+ RefCntAutoPtr<IDeviceContext> GetDeferredContext(size_t Ctx) { return m_wpDeferredContexts[Ctx].Lock(); }
- FixedBlockMemoryAllocator& GetTexViewObjAllocator(){return m_TexViewObjAllocator;}
- FixedBlockMemoryAllocator& GetBuffViewObjAllocator(){return m_BuffViewObjAllocator;}
- FixedBlockMemoryAllocator& GetSRBAllocator(){return m_SRBAllocator;}
+ FixedBlockMemoryAllocator& GetTexViewObjAllocator() { return m_TexViewObjAllocator; }
+ FixedBlockMemoryAllocator& GetBuffViewObjAllocator() { return m_BuffViewObjAllocator; }
+ FixedBlockMemoryAllocator& GetSRBAllocator() { return m_SRBAllocator; }
protected:
-
virtual void TestTextureFormat(TEXTURE_FORMAT TexFormat) = 0;
/// Helper template function to facilitate device object creation
- template<typename TObjectType, typename TObjectDescType, typename TObjectConstructor>
- void CreateDeviceObject( const Char *ObjectTypeName, const TObjectDescType &Desc, TObjectType **ppObject, TObjectConstructor ConstructObject );
+ template <typename TObjectType, typename TObjectDescType, typename TObjectConstructor>
+ void CreateDeviceObject(const Char* ObjectTypeName, const TObjectDescType& Desc, TObjectType** ppObject, TObjectConstructor ConstructObject);
RefCntAutoPtr<IEngineFactory> m_pEngineFactory;
@@ -396,46 +395,46 @@ protected:
// All state object registries hold raw pointers.
// This is safe because every object unregisters itself
// when it is deleted.
- StateObjectsRegistry<SamplerDesc> m_SamplersRegistry; ///< Sampler state registry
- std::vector<TextureFormatInfoExt, STDAllocatorRawMem<TextureFormatInfoExt> > m_TextureFormatsInfo;
- std::vector<bool, STDAllocatorRawMem<bool> > m_TexFmtInfoInitFlags;
-
+ StateObjectsRegistry<SamplerDesc> m_SamplersRegistry; ///< Sampler state registry
+ std::vector<TextureFormatInfoExt, STDAllocatorRawMem<TextureFormatInfoExt>> m_TextureFormatsInfo;
+ std::vector<bool, STDAllocatorRawMem<bool>> m_TexFmtInfoInitFlags;
+
/// Weak reference to the immediate context. Immediate context holds strong reference
/// to the device, so we must use weak reference to avoid circular dependencies.
RefCntWeakPtr<IDeviceContext> m_wpImmediateContext;
- /// Weak references to deferred contexts.
- std::vector< RefCntWeakPtr<IDeviceContext>, STDAllocatorRawMem<RefCntWeakPtr<IDeviceContext> > > m_wpDeferredContexts;
-
- IMemoryAllocator& m_RawMemAllocator; ///< Raw memory allocator
- FixedBlockMemoryAllocator m_TexObjAllocator; ///< Allocator for texture objects
- FixedBlockMemoryAllocator m_TexViewObjAllocator; ///< Allocator for texture view objects
- FixedBlockMemoryAllocator m_BufObjAllocator; ///< Allocator for buffer objects
- FixedBlockMemoryAllocator m_BuffViewObjAllocator; ///< Allocator for buffer view objects
- FixedBlockMemoryAllocator m_ShaderObjAllocator; ///< Allocator for shader objects
- FixedBlockMemoryAllocator m_SamplerObjAllocator; ///< Allocator for sampler objects
- FixedBlockMemoryAllocator m_PSOAllocator; ///< Allocator for pipeline state objects
- FixedBlockMemoryAllocator m_SRBAllocator; ///< Allocator for shader resource binding objects
- FixedBlockMemoryAllocator m_ResMappingAllocator; ///< Allocator for resource mapping objects
- FixedBlockMemoryAllocator m_FenceAllocator; ///< Allocator for fence objects
+ /// Weak references to deferred contexts.
+ std::vector<RefCntWeakPtr<IDeviceContext>, STDAllocatorRawMem<RefCntWeakPtr<IDeviceContext>>> m_wpDeferredContexts;
+
+ IMemoryAllocator& m_RawMemAllocator; ///< Raw memory allocator
+ FixedBlockMemoryAllocator m_TexObjAllocator; ///< Allocator for texture objects
+ FixedBlockMemoryAllocator m_TexViewObjAllocator; ///< Allocator for texture view objects
+ FixedBlockMemoryAllocator m_BufObjAllocator; ///< Allocator for buffer objects
+ FixedBlockMemoryAllocator m_BuffViewObjAllocator; ///< Allocator for buffer view objects
+ FixedBlockMemoryAllocator m_ShaderObjAllocator; ///< Allocator for shader objects
+ FixedBlockMemoryAllocator m_SamplerObjAllocator; ///< Allocator for sampler objects
+ FixedBlockMemoryAllocator m_PSOAllocator; ///< Allocator for pipeline state objects
+ FixedBlockMemoryAllocator m_SRBAllocator; ///< Allocator for shader resource binding objects
+ FixedBlockMemoryAllocator m_ResMappingAllocator; ///< Allocator for resource mapping objects
+ FixedBlockMemoryAllocator m_FenceAllocator; ///< Allocator for fence objects
};
-template<typename BaseInterface>
-void RenderDeviceBase<BaseInterface>::CreateResourceMapping( const ResourceMappingDesc &MappingDesc, IResourceMapping **ppMapping )
+template <typename BaseInterface>
+void RenderDeviceBase<BaseInterface>::CreateResourceMapping(const ResourceMappingDesc& MappingDesc, IResourceMapping** ppMapping)
{
- VERIFY( ppMapping != nullptr, "Null pointer provided" );
- if( ppMapping == nullptr )
+ VERIFY(ppMapping != nullptr, "Null pointer provided");
+ if (ppMapping == nullptr)
return;
- VERIFY( *ppMapping == nullptr, "Overwriting reference to existing object may cause memory leaks" );
+ VERIFY(*ppMapping == nullptr, "Overwriting reference to existing object may cause memory leaks");
- auto* pResourceMapping( NEW_RC_OBJ(m_ResMappingAllocator, "ResourceMappingImpl instance", ResourceMappingImpl)(GetRawAllocator()) );
- pResourceMapping->QueryInterface( IID_ResourceMapping, reinterpret_cast<IObject**>(ppMapping) );
- if( MappingDesc.pEntries )
+ auto* pResourceMapping(NEW_RC_OBJ(m_ResMappingAllocator, "ResourceMappingImpl instance", ResourceMappingImpl)(GetRawAllocator()));
+ pResourceMapping->QueryInterface(IID_ResourceMapping, reinterpret_cast<IObject**>(ppMapping));
+ if (MappingDesc.pEntries)
{
- for( auto* pEntry = MappingDesc.pEntries; pEntry->Name && pEntry->pObject; ++pEntry )
+ for (auto* pEntry = MappingDesc.pEntries; pEntry->Name && pEntry->pObject; ++pEntry)
{
- (*ppMapping)->AddResourceArray( pEntry->Name, pEntry->ArrayIndex, &pEntry->pObject, 1, true );
+ (*ppMapping)->AddResourceArray(pEntry->Name, pEntry->ArrayIndex, &pEntry->pObject, 1, true);
}
}
}
@@ -448,15 +447,15 @@ void RenderDeviceBase<BaseInterface>::CreateResourceMapping( const ResourceMappi
/// \param Desc - object description
/// \param ppObject - memory address where the pointer to the created object will be stored
/// \param ConstructObject - function that constructs the object
-template<typename BaseInterface>
-template<typename TObjectType, typename TObjectDescType, typename TObjectConstructor>
-void RenderDeviceBase<BaseInterface> :: CreateDeviceObject( const Char *ObjectTypeName, const TObjectDescType &Desc, TObjectType **ppObject, TObjectConstructor ConstructObject )
+template <typename BaseInterface>
+template <typename TObjectType, typename TObjectDescType, typename TObjectConstructor>
+void RenderDeviceBase<BaseInterface>::CreateDeviceObject(const Char* ObjectTypeName, const TObjectDescType& Desc, TObjectType** ppObject, TObjectConstructor ConstructObject)
{
- VERIFY( ppObject != nullptr, "Null pointer provided" );
- if(!ppObject)
+ VERIFY(ppObject != nullptr, "Null pointer provided");
+ if (!ppObject)
return;
- VERIFY(*ppObject == nullptr, "Overwriting reference to existing object may cause memory leaks" );
+ VERIFY(*ppObject == nullptr, "Overwriting reference to existing object may cause memory leaks");
// Do not release *ppObject here!
// Should this happen, RefCntAutoPtr<> will take care of this!
//if( *ppObject )
@@ -471,24 +470,24 @@ void RenderDeviceBase<BaseInterface> :: CreateDeviceObject( const Char *ObjectTy
{
ConstructObject();
}
- catch( const std::runtime_error & )
+ catch (const std::runtime_error&)
{
- VERIFY( *ppObject == nullptr, "Object was created despite error" );
- if( *ppObject )
+ VERIFY(*ppObject == nullptr, "Object was created despite error");
+ if (*ppObject)
{
(*ppObject)->Release();
*ppObject = nullptr;
}
- auto ObjectDescString = GetObjectDescString( Desc );
- if( ObjectDescString.length() )
+ auto ObjectDescString = GetObjectDescString(Desc);
+ if (ObjectDescString.length())
{
- LOG_ERROR( "Failed to create ", ObjectTypeName, " object \"", Desc.Name ? Desc.Name : "", "\"\n", ObjectDescString );
+ LOG_ERROR("Failed to create ", ObjectTypeName, " object '", Desc.Name ? Desc.Name : "", "'\n", ObjectDescString);
}
else
{
- LOG_ERROR( "Failed to create ", ObjectTypeName, " object \"", Desc.Name ? Desc.Name : "", "\"" );
+ LOG_ERROR("Failed to create ", ObjectTypeName, " object '", Desc.Name ? Desc.Name : "", "'");
}
}
}
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/ResourceMappingImpl.h b/Graphics/GraphicsEngine/include/ResourceMappingImpl.h
index 6ea3c992..5e228c89 100644
--- a/Graphics/GraphicsEngine/include/ResourceMappingImpl.h
+++ b/Graphics/GraphicsEngine/include/ResourceMappingImpl.h
@@ -34,99 +34,99 @@
namespace Diligent
{
- struct ResMappingHashKey
+struct ResMappingHashKey
+{
+ ResMappingHashKey(const Char* Str, bool bMakeCopy, Uint32 ArrInd) :
+ StrKey{Str, bMakeCopy},
+ ArrayIndex{ArrInd}
{
- ResMappingHashKey(const Char* Str, bool bMakeCopy, Uint32 ArrInd):
- StrKey(Str, bMakeCopy),
- ArrayIndex(ArrInd)
- {
- }
+ }
- ResMappingHashKey(ResMappingHashKey&& rhs) :
- StrKey(std::move(rhs.StrKey)),
- ArrayIndex(rhs.ArrayIndex)
- {}
+ ResMappingHashKey(ResMappingHashKey&& rhs) :
+ StrKey{std::move(rhs.StrKey)},
+ ArrayIndex{rhs.ArrayIndex}
+ {}
- bool operator == (const ResMappingHashKey& RHS)const
- {
- return StrKey == RHS.StrKey && ArrayIndex == RHS.ArrayIndex;
- }
+ bool operator==(const ResMappingHashKey& RHS) const
+ {
+ return StrKey == RHS.StrKey && ArrayIndex == RHS.ArrayIndex;
+ }
- size_t GetHash()const
+ size_t GetHash() const
+ {
+ if (Hash == 0)
{
- if( Hash == 0 )
- {
- Hash = ComputeHash( StrKey.GetHash(), ArrayIndex );
- }
-
- return Hash;
+ Hash = ComputeHash(StrKey.GetHash(), ArrayIndex);
}
+ return Hash;
+ }
- ResMappingHashKey ( const ResMappingHashKey& ) = delete;
- ResMappingHashKey& operator = ( const ResMappingHashKey& ) = delete;
- ResMappingHashKey& operator = ( ResMappingHashKey&& ) = delete;
+ // clang-format off
+ ResMappingHashKey ( const ResMappingHashKey& ) = delete;
+ ResMappingHashKey& operator = ( const ResMappingHashKey& ) = delete;
+ ResMappingHashKey& operator = ( ResMappingHashKey&& ) = delete;
+ // clang-format on
- HashMapStringKey StrKey;
- Uint32 ArrayIndex;
- mutable size_t Hash = 0;
- };
-}
+ HashMapStringKey StrKey;
+ Uint32 ArrayIndex;
+ mutable size_t Hash = 0;
+};
+} // namespace Diligent
namespace std
{
- template<>
- struct hash<Diligent::ResMappingHashKey>
+template <>
+struct hash<Diligent::ResMappingHashKey>
+{
+ size_t operator()(const Diligent::ResMappingHashKey& Key) const
{
- size_t operator()( const Diligent::ResMappingHashKey& Key ) const
- {
- return Key.GetHash();
- }
- };
-}
+ return Key.GetHash();
+ }
+};
+} // namespace std
namespace Diligent
{
- class FixedBlockMemoryAllocator;
+class FixedBlockMemoryAllocator;
- /// Implementation of the resource mapping
- class ResourceMappingImpl : public ObjectBase<IResourceMapping>
- {
- public:
- typedef ObjectBase<IResourceMapping> TObjectBase;
+/// Implementation of the resource mapping
+class ResourceMappingImpl : public ObjectBase<IResourceMapping>
+{
+public:
+ typedef ObjectBase<IResourceMapping> TObjectBase;
- /// \param pRefCounters - reference counters object that controls the lifetime of this resource mapping
- /// \param RawMemAllocator - raw memory allocator that is used by the m_HashTable member
- ResourceMappingImpl(IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator) :
- TObjectBase(pRefCounters),
- m_HashTable(STD_ALLOCATOR_RAW_MEM(HashTableElem, RawMemAllocator, "Allocator for unordered_map< ResMappingHashKey, RefCntAutoPtr<IDeviceObject> >") )
- {}
+ /// \param pRefCounters - reference counters object that controls the lifetime of this resource mapping
+ /// \param RawMemAllocator - raw memory allocator that is used by the m_HashTable member
+ ResourceMappingImpl(IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator) :
+ TObjectBase(pRefCounters),
+ m_HashTable(STD_ALLOCATOR_RAW_MEM(HashTableElem, RawMemAllocator, "Allocator for unordered_map< ResMappingHashKey, RefCntAutoPtr<IDeviceObject> >"))
+ {}
- ~ResourceMappingImpl();
+ ~ResourceMappingImpl();
- virtual void QueryInterface( const INTERFACE_ID& IID, IObject** ppInterface )override final;
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final;
- /// Implementation of IResourceMapping::AddResource()
- virtual void AddResource( const Char* Name, IDeviceObject* pObject, bool bIsUnique )override final;
+ /// Implementation of IResourceMapping::AddResource()
+ virtual void AddResource(const Char* Name, IDeviceObject* pObject, bool bIsUnique) override final;
- /// Implementation of IResourceMapping::AddResourceArray()
- virtual void AddResourceArray( const Char* Name, Uint32 StartIndex, IDeviceObject* const* ppObjects, Uint32 NumElements, bool bIsUnique )override final;
+ /// Implementation of IResourceMapping::AddResourceArray()
+ virtual void AddResourceArray(const Char* Name, Uint32 StartIndex, IDeviceObject* const* ppObjects, Uint32 NumElements, bool bIsUnique) override final;
- /// Implementation of IResourceMapping::RemoveResourceByName()
- virtual void RemoveResourceByName( const Char* Name, Uint32 ArrayIndex )override final;
-
- /// Implementation of IResourceMapping::GetResource()
- virtual void GetResource( const Char* Name, IDeviceObject** ppResource, Uint32 ArrayIndex )override final;
+ /// Implementation of IResourceMapping::RemoveResourceByName()
+ virtual void RemoveResourceByName(const Char* Name, Uint32 ArrayIndex) override final;
- /// Returns number of resources in the resource mapping.
- virtual size_t GetSize()override final;
+ /// Implementation of IResourceMapping::GetResource()
+ virtual void GetResource(const Char* Name, IDeviceObject** ppResource, Uint32 ArrayIndex) override final;
- private:
+ /// Returns number of resources in the resource mapping.
+ virtual size_t GetSize() override final;
- ThreadingTools::LockHelper Lock();
+private:
+ ThreadingTools::LockHelper Lock();
- ThreadingTools::LockFlag m_LockFlag;
- typedef std::pair<const ResMappingHashKey, RefCntAutoPtr<IDeviceObject> > HashTableElem;
- std::unordered_map< ResMappingHashKey, RefCntAutoPtr<IDeviceObject>, std::hash<ResMappingHashKey>, std::equal_to<ResMappingHashKey>, STDAllocatorRawMem<HashTableElem> > m_HashTable;
- };
-}
+ ThreadingTools::LockFlag m_LockFlag;
+ typedef std::pair<const ResMappingHashKey, RefCntAutoPtr<IDeviceObject>> HashTableElem;
+ std::unordered_map<ResMappingHashKey, RefCntAutoPtr<IDeviceObject>, std::hash<ResMappingHashKey>, std::equal_to<ResMappingHashKey>, STDAllocatorRawMem<HashTableElem>> m_HashTable;
+};
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/SamplerBase.h b/Graphics/GraphicsEngine/include/SamplerBase.h
index cc2fec39..819d1d5c 100644
--- a/Graphics/GraphicsEngine/include/SamplerBase.h
+++ b/Graphics/GraphicsEngine/include/SamplerBase.h
@@ -41,30 +41,30 @@ namespace Diligent
/// \tparam RenderDeviceImplType - type of the render device implementation
/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl,
/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl)
-template<class BaseInterface, class RenderDeviceImplType>
+template <class BaseInterface, class RenderDeviceImplType>
class SamplerBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, SamplerDesc>
{
public:
using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, SamplerDesc>;
/// \param pRefCounters - reference counters object that controls the lifetime of this sampler.
- /// \param pDevice - pointer to the device.
- /// \param SamDesc - sampler description.
- /// \param bIsDeviceInternal - flag indicating if the sampler is an internal device object and
- /// must not keep a strong reference to the device.
- SamplerBase( IReferenceCounters* pRefCounters, RenderDeviceImplType* pDevice, const SamplerDesc& SamDesc, bool bIsDeviceInternal = false ) :
- TDeviceObjectBase( pRefCounters, pDevice, SamDesc, bIsDeviceInternal )
+ /// \param pDevice - pointer to the device.
+ /// \param SamDesc - sampler description.
+ /// \param bIsDeviceInternal - flag indicating if the sampler is an internal device object and
+ /// must not keep a strong reference to the device.
+ SamplerBase(IReferenceCounters* pRefCounters, RenderDeviceImplType* pDevice, const SamplerDesc& SamDesc, bool bIsDeviceInternal = false) :
+ TDeviceObjectBase{pRefCounters, pDevice, SamDesc, bIsDeviceInternal}
{}
~SamplerBase()
{
- /// \note Destructor cannot directly remove the object from the registry as this may cause a
+ /// \note Destructor cannot directly remove the object from the registry as this may cause a
/// deadlock.
- auto &SamplerRegistry = this->GetDevice()->GetSamplerRegistry();
+ auto& SamplerRegistry = this->GetDevice()->GetSamplerRegistry();
SamplerRegistry.ReportDeletedObject();
}
- IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_Sampler, TDeviceObjectBase )
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_Sampler, TDeviceObjectBase)
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/ShaderBase.h b/Graphics/GraphicsEngine/include/ShaderBase.h
index 0ee22970..03b3a94f 100644
--- a/Graphics/GraphicsEngine/include/ShaderBase.h
+++ b/Graphics/GraphicsEngine/include/ShaderBase.h
@@ -50,8 +50,9 @@ inline Int32 GetShaderTypeIndex(SHADER_TYPE Type)
Int32 ShaderIndex = PlatformMisc::GetLSB(Type);
#ifdef _DEBUG
- switch( Type )
+ switch (Type)
{
+ // clang-format off
case SHADER_TYPE_UNKNOWN: VERIFY_EXPR(ShaderIndex == -1); break;
case SHADER_TYPE_VERTEX: VERIFY_EXPR(ShaderIndex == 0); break;
case SHADER_TYPE_PIXEL: VERIFY_EXPR(ShaderIndex == 1); break;
@@ -59,9 +60,10 @@ inline Int32 GetShaderTypeIndex(SHADER_TYPE Type)
case SHADER_TYPE_HULL: VERIFY_EXPR(ShaderIndex == 3); break;
case SHADER_TYPE_DOMAIN: VERIFY_EXPR(ShaderIndex == 4); break;
case SHADER_TYPE_COMPUTE: VERIFY_EXPR(ShaderIndex == 5); break;
- default: UNEXPECTED( "Unexpected shader type (", Type, ")" ); break;
+ // clang-format on
+ default: UNEXPECTED("Unexpected shader type (", Type, ")"); break;
}
- VERIFY( Type == GetShaderTypeFromIndex(ShaderIndex), "Incorrect shader type index" );
+ VERIFY(Type == GetShaderTypeFromIndex(ShaderIndex), "Incorrect shader type index");
#endif
return ShaderIndex;
}
@@ -82,23 +84,23 @@ static const int CSInd = GetShaderTypeIndex(SHADER_TYPE_COMPUTE);
/// \tparam RenderDeviceImplType - type of the render device implementation
/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl,
/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl)
-template<class BaseInterface, class RenderDeviceImplType>
+template <class BaseInterface, class RenderDeviceImplType>
class ShaderBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, ShaderDesc>
{
public:
using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, ShaderDesc>;
/// \param pRefCounters - reference counters object that controls the lifetime of this shader.
- /// \param pDevice - pointer to the device.
- /// \param ShdrDesc - shader description.
- /// \param bIsDeviceInternal - flag indicating if the shader is an internal device object and
- /// must not keep a strong reference to the device.
+ /// \param pDevice - pointer to the device.
+ /// \param ShdrDesc - shader description.
+ /// \param bIsDeviceInternal - flag indicating if the shader is an internal device object and
+ /// must not keep a strong reference to the device.
ShaderBase(IReferenceCounters* pRefCounters, RenderDeviceImplType* pDevice, const ShaderDesc& ShdrDesc, bool bIsDeviceInternal = false) :
- TDeviceObjectBase(pRefCounters, pDevice, ShdrDesc, bIsDeviceInternal)
+ TDeviceObjectBase{pRefCounters, pDevice, ShdrDesc, bIsDeviceInternal}
{
}
- IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_Shader, TDeviceObjectBase )
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_Shader, TDeviceObjectBase)
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.h b/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.h
index 62d9870f..4297f0f0 100644
--- a/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.h
+++ b/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.h
@@ -36,52 +36,51 @@ namespace Diligent
/// Template class implementing base functionality for a shader resource binding
-/// \tparam BaseInterface - base interface that this class will inheret
+/// \tparam BaseInterface - base interface that this class will inheret
/// (Diligent::IShaderResourceBindingGL, Diligent::IShaderResourceBindingD3D11,
/// Diligent::IShaderResourceBindingD3D12 or Diligent::IShaderResourceBindingVk).
-template<class BaseInterface>
+template <class BaseInterface>
class ShaderResourceBindingBase : public ObjectBase<BaseInterface>
{
public:
typedef ObjectBase<BaseInterface> TObjectBase;
/// \param pRefCounters - reference counters object that controls the lifetime of this SRB.
- /// \param pPSO - pipeline state that this SRB belongs to.
- /// \param IsInternal - flag indicating if the shader resource binding is an internal PSO object and
- /// must not keep a strong reference to the PSO.
- ShaderResourceBindingBase( IReferenceCounters* pRefCounters, IPipelineState* pPSO, bool IsInternal = false ) :
- TObjectBase( pRefCounters ),
- m_spPSO( IsInternal ? nullptr : pPSO ),
- m_pPSO( pPSO )
+ /// \param pPSO - pipeline state that this SRB belongs to.
+ /// \param IsInternal - flag indicating if the shader resource binding is an internal PSO object and
+ /// must not keep a strong reference to the PSO.
+ ShaderResourceBindingBase(IReferenceCounters* pRefCounters, IPipelineState* pPSO, bool IsInternal = false) :
+ TObjectBase{pRefCounters},
+ m_spPSO{IsInternal ? nullptr : pPSO},
+ m_pPSO{pPSO}
{}
- IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_ShaderResourceBinding, TObjectBase )
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_ShaderResourceBinding, TObjectBase)
/// Implementation of IShaderResourceBinding::GetPipelineState().
- virtual IPipelineState* GetPipelineState()override final
+ virtual IPipelineState* GetPipelineState() override final
{
return m_pPSO;
}
- template<typename PSOType>
+ template <typename PSOType>
PSOType* GetPipelineState()
{
return ValidatedCast<PSOType>(m_pPSO);
}
- template<typename PSOType>
- PSOType* GetPipelineState()const
+ template <typename PSOType>
+ PSOType* GetPipelineState() const
{
return ValidatedCast<PSOType>(m_pPSO);
}
protected:
-
/// Strong reference to PSO. We must use strong reference, because
/// shader resource binding uses PSO's memory allocator to allocate
/// memory for shader resource cache.
RefCntAutoPtr<IPipelineState> m_spPSO;
- IPipelineState* const m_pPSO;
+ IPipelineState* const m_pPSO;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/ShaderResourceVariableBase.h b/Graphics/GraphicsEngine/include/ShaderResourceVariableBase.h
index 5227f84a..ea13fb54 100644
--- a/Graphics/GraphicsEngine/include/ShaderResourceVariableBase.h
+++ b/Graphics/GraphicsEngine/include/ShaderResourceVariableBase.h
@@ -36,7 +36,7 @@
namespace Diligent
{
-template<typename TNameCompare>
+template <typename TNameCompare>
SHADER_RESOURCE_VARIABLE_TYPE GetShaderVariableType(SHADER_TYPE ShaderStage,
SHADER_RESOURCE_VARIABLE_TYPE DefaultVariableType,
const ShaderResourceVariableDesc* Variables,
@@ -46,7 +46,7 @@ SHADER_RESOURCE_VARIABLE_TYPE GetShaderVariableType(SHADER_TYPE
for (Uint32 v = 0; v < NumVars; ++v)
{
const auto& CurrVarDesc = Variables[v];
- if ( ((CurrVarDesc.ShaderStages & ShaderStage) != 0) && NameCompare(CurrVarDesc.Name) )
+ if (((CurrVarDesc.ShaderStages & ShaderStage) != 0) && NameCompare(CurrVarDesc.Name))
{
return CurrVarDesc.Type;
}
@@ -60,12 +60,11 @@ inline SHADER_RESOURCE_VARIABLE_TYPE GetShaderVariableType(SHADER_TYPE
const ShaderResourceVariableDesc* Variables,
Uint32 NumVars)
{
- return GetShaderVariableType(ShaderStage, DefaultVariableType, Variables, NumVars,
- [&](const char* VarName)
- {
- return strcmp(VarName, Name) == 0;
- }
- );
+ return GetShaderVariableType(ShaderStage, DefaultVariableType, Variables, NumVars,
+ [&](const char* VarName) // clang-format off
+ { // clang-format on
+ return strcmp(VarName, Name) == 0;
+ });
}
inline SHADER_RESOURCE_VARIABLE_TYPE GetShaderVariableType(SHADER_TYPE ShaderStage,
@@ -75,18 +74,17 @@ inline SHADER_RESOURCE_VARIABLE_TYPE GetShaderVariableType(SHADER_TYPE
return GetShaderVariableType(ShaderStage, Name, LayoutDesc.DefaultVariableType, LayoutDesc.Variables, LayoutDesc.NumVariables);
}
-inline SHADER_RESOURCE_VARIABLE_TYPE GetShaderVariableType(SHADER_TYPE ShaderStage,
- const String& Name,
- SHADER_RESOURCE_VARIABLE_TYPE DefaultVariableType,
- const ShaderResourceVariableDesc* Variables,
- Uint32 NumVars)
+inline SHADER_RESOURCE_VARIABLE_TYPE GetShaderVariableType(SHADER_TYPE ShaderStage,
+ const String& Name,
+ SHADER_RESOURCE_VARIABLE_TYPE DefaultVariableType,
+ const ShaderResourceVariableDesc* Variables,
+ Uint32 NumVars)
{
- return GetShaderVariableType(ShaderStage, DefaultVariableType, Variables, NumVars,
- [&](const char* VarName)
- {
- return Name.compare(VarName) == 0;
- }
- );
+ return GetShaderVariableType(ShaderStage, DefaultVariableType, Variables, NumVars,
+ [&](const char* VarName) // clang-format off
+ { // clang-format on
+ return Name.compare(VarName) == 0;
+ });
}
inline SHADER_RESOURCE_VARIABLE_TYPE GetShaderVariableType(SHADER_TYPE ShaderStage,
@@ -96,18 +94,18 @@ inline SHADER_RESOURCE_VARIABLE_TYPE GetShaderVariableType(SHADER_TYPE
return GetShaderVariableType(ShaderStage, Name, LayoutDesc.DefaultVariableType, LayoutDesc.Variables, LayoutDesc.NumVariables);
}
-inline bool IsAllowedType(SHADER_RESOURCE_VARIABLE_TYPE VarType, Uint32 AllowedTypeBits)noexcept
+inline bool IsAllowedType(SHADER_RESOURCE_VARIABLE_TYPE VarType, Uint32 AllowedTypeBits) noexcept
{
return ((1 << VarType) & AllowedTypeBits) != 0;
}
-inline Uint32 GetAllowedTypeBits(const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, Uint32 NumAllowedTypes)noexcept
+inline Uint32 GetAllowedTypeBits(const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, Uint32 NumAllowedTypes) noexcept
{
- if(AllowedVarTypes == nullptr)
+ if (AllowedVarTypes == nullptr)
return 0xFFFFFFFF;
Uint32 AllowedTypeBits = 0;
- for(Uint32 i=0; i < NumAllowedTypes; ++i)
+ for (Uint32 i = 0; i < NumAllowedTypes; ++i)
AllowedTypeBits |= 1 << AllowedVarTypes[i];
return AllowedTypeBits;
}
@@ -118,10 +116,10 @@ inline Int32 FindStaticSampler(const StaticSamplerDesc* StaticSamplers,
const char* ResourceName,
const char* SamplerSuffix)
{
- for (Uint32 s=0; s < NumStaticSamplers; ++s)
+ for (Uint32 s = 0; s < NumStaticSamplers; ++s)
{
const auto& StSam = StaticSamplers[s];
- if ( ((StSam.ShaderStages & ShaderType) != 0) && StreqSuff(ResourceName, StSam.SamplerOrTextureName, SamplerSuffix) )
+ if (((StSam.ShaderStages & ShaderType) != 0) && StreqSuff(ResourceName, StSam.SamplerOrTextureName, SamplerSuffix))
return s;
}
@@ -131,15 +129,15 @@ inline Int32 FindStaticSampler(const StaticSamplerDesc* StaticSamplers,
-template<typename ResourceAttribsType,
- typename BufferImplType>
-bool VerifyConstantBufferBinding(const ResourceAttribsType& Attribs,
- SHADER_RESOURCE_VARIABLE_TYPE VarType,
- Uint32 ArrayIndex,
- const IDeviceObject* pBuffer,
- const BufferImplType* pBufferImpl,
- const IDeviceObject* pCachedBuffer,
- const char* ShaderName = nullptr)
+template <typename ResourceAttribsType,
+ typename BufferImplType>
+bool VerifyConstantBufferBinding(const ResourceAttribsType& Attribs,
+ SHADER_RESOURCE_VARIABLE_TYPE VarType,
+ Uint32 ArrayIndex,
+ const IDeviceObject* pBuffer,
+ const BufferImplType* pBufferImpl,
+ const IDeviceObject* pCachedBuffer,
+ const char* ShaderName = nullptr)
{
if (pBuffer != nullptr && pBufferImpl == nullptr)
{
@@ -167,7 +165,7 @@ bool VerifyConstantBufferBinding(const ResourceAttribsType& Attribs,
LOG_ERROR_MESSAGE(ss.str());
BindingOK = false;
}
-
+
if (VarType != SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC && pCachedBuffer != nullptr && pCachedBuffer != pBufferImpl)
{
auto VarTypeStr = GetShaderVariableTypeLiteralName(VarType);
@@ -177,7 +175,7 @@ bool VerifyConstantBufferBinding(const ResourceAttribsType& Attribs,
<< " shader variable '" << Attribs.GetPrintName(ArrayIndex) << '\'';
if (ShaderName != nullptr)
{
- ss << " in shader '" << ShaderName << '\'';
+ ss << " in shader '" << ShaderName << '\'';
}
ss << ". Attempting to bind ";
if (pBufferImpl)
@@ -197,42 +195,42 @@ bool VerifyConstantBufferBinding(const ResourceAttribsType& Attribs,
return BindingOK;
}
-template<typename TViewTypeEnum>
+template <typename TViewTypeEnum>
const char* GetResourceTypeName();
-template<>
+template <>
inline const char* GetResourceTypeName<TEXTURE_VIEW_TYPE>()
{
return "texture view";
}
-template<>
+template <>
inline const char* GetResourceTypeName<BUFFER_VIEW_TYPE>()
{
return "buffer view";
}
-template<typename ResourceAttribsType,
- typename ResourceViewImplType,
- typename ViewTypeEnumType>
-bool VerifyResourceViewBinding(const ResourceAttribsType& Attribs,
- SHADER_RESOURCE_VARIABLE_TYPE VarType,
- Uint32 ArrayIndex,
- const IDeviceObject* pView,
- const ResourceViewImplType* pViewImpl,
- std::initializer_list<ViewTypeEnumType> ExpectedViewTypes,
- const IDeviceObject* pCachedView,
- const char* ShaderName = nullptr)
+template <typename ResourceAttribsType,
+ typename ResourceViewImplType,
+ typename ViewTypeEnumType>
+bool VerifyResourceViewBinding(const ResourceAttribsType& Attribs,
+ SHADER_RESOURCE_VARIABLE_TYPE VarType,
+ Uint32 ArrayIndex,
+ const IDeviceObject* pView,
+ const ResourceViewImplType* pViewImpl,
+ std::initializer_list<ViewTypeEnumType> ExpectedViewTypes,
+ const IDeviceObject* pCachedView,
+ const char* ShaderName = nullptr)
{
const char* ExpectedResourceType = GetResourceTypeName<ViewTypeEnumType>();
-
+
if (pView && !pViewImpl)
{
std::stringstream ss;
ss << "Failed to bind resource '" << pView->GetDesc().Name << "' to variable '" << Attribs.GetPrintName(ArrayIndex) << '\'';
if (ShaderName != nullptr)
{
- ss << " in shader '" << ShaderName << '\'';
+ ss << " in shader '" << ShaderName << '\'';
}
ss << ". Invalid resource type: " << ExpectedResourceType << " is expected.";
LOG_ERROR_MESSAGE(ss.str());
@@ -242,9 +240,9 @@ bool VerifyResourceViewBinding(const ResourceAttribsType& Attribs,
bool BindingOK = true;
if (pViewImpl)
{
- auto ViewType = pViewImpl->GetDesc().ViewType;
+ auto ViewType = pViewImpl->GetDesc().ViewType;
bool IsExpectedViewType = false;
- for(auto ExpectedViewType : ExpectedViewTypes)
+ for (auto ExpectedViewType : ExpectedViewTypes)
{
if (ExpectedViewType == ViewType)
IsExpectedViewType = true;
@@ -259,11 +257,11 @@ bool VerifyResourceViewBinding(const ResourceAttribsType& Attribs,
<< Attribs.GetPrintName(ArrayIndex) << '\'';
if (ShaderName != nullptr)
{
- ss << " in shader '" << ShaderName << '\'';
+ ss << " in shader '" << ShaderName << '\'';
}
ss << ". Incorrect view type: ";
bool IsFirstViewType = true;
- for(auto ExpectedViewType : ExpectedViewTypes)
+ for (auto ExpectedViewType : ExpectedViewTypes)
{
if (!IsFirstViewType)
{
@@ -281,13 +279,13 @@ bool VerifyResourceViewBinding(const ResourceAttribsType& Attribs,
if (VarType != SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC && pCachedView != nullptr && pCachedView != pViewImpl)
{
- auto VarTypeStr = GetShaderVariableTypeLiteralName(VarType);
+ auto VarTypeStr = GetShaderVariableTypeLiteralName(VarType);
std::stringstream ss;
ss << "Non-null resource '" << pCachedView->GetDesc().Name << "' is already bound to " << VarTypeStr
<< " shader variable '" << Attribs.GetPrintName(ArrayIndex) << '\'';
if (ShaderName != nullptr)
{
- ss << " in shader '" << ShaderName << '\'';
+ ss << " in shader '" << ShaderName << '\'';
}
ss << ". Attempting to bind ";
if (pViewImpl)
@@ -310,39 +308,39 @@ inline void VerifyAndCorrectSetArrayArguments(const char* Name, Uint32 ArraySize
{
if (FirstElement >= ArraySize)
{
- LOG_ERROR_MESSAGE("SetArray arguments are invalid for '", Name,"' variable: FirstElement (", FirstElement, ") is out of allowed range 0 .. ", ArraySize-1);
- FirstElement = ArraySize-1;
+ LOG_ERROR_MESSAGE("SetArray arguments are invalid for '", Name, "' variable: FirstElement (", FirstElement, ") is out of allowed range 0 .. ", ArraySize - 1);
+ FirstElement = ArraySize - 1;
NumElements = 0;
}
if (FirstElement + NumElements > ArraySize)
{
- LOG_ERROR_MESSAGE("SetArray arguments are invalid for '", Name,"' variable: specified element range (", FirstElement, " .. ",
- FirstElement + NumElements-1, ") is out of array bounds 0 .. ", ArraySize-1);
+ LOG_ERROR_MESSAGE("SetArray arguments are invalid for '", Name, "' variable: specified element range (", FirstElement, " .. ",
+ FirstElement + NumElements - 1, ") is out of array bounds 0 .. ", ArraySize - 1);
NumElements = ArraySize - FirstElement;
}
}
struct DefaultShaderVariableIDComparator
{
- bool operator() (const INTERFACE_ID& IID)const
+ bool operator()(const INTERFACE_ID& IID) const
{
return IID == IID_ShaderResourceVariable || IID == IID_Unknown;
}
};
/// Base implementation of a shader variable
-template<typename ResourceLayoutType,
- typename ResourceVariableBaseInterface = IShaderResourceVariable,
- typename VariableIDComparator = DefaultShaderVariableIDComparator>
+template <typename ResourceLayoutType,
+ typename ResourceVariableBaseInterface = IShaderResourceVariable,
+ typename VariableIDComparator = DefaultShaderVariableIDComparator>
struct ShaderVariableBase : public ResourceVariableBaseInterface
{
- ShaderVariableBase(ResourceLayoutType& ParentResLayout) :
+ ShaderVariableBase(ResourceLayoutType& ParentResLayout) :
m_ParentResLayout(ParentResLayout)
{
}
- void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override final
+ void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final
{
if (ppInterface == nullptr)
return;
@@ -355,17 +353,17 @@ struct ShaderVariableBase : public ResourceVariableBaseInterface
}
}
- virtual Atomics::Long AddRef()override final
+ virtual Atomics::Long AddRef() override final
{
return m_ParentResLayout.GetOwner().AddRef();
}
- virtual Atomics::Long Release()override final
+ virtual Atomics::Long Release() override final
{
return m_ParentResLayout.GetOwner().Release();
}
- virtual IReferenceCounters* GetReferenceCounters()const override final
+ virtual IReferenceCounters* GetReferenceCounters() const override final
{
return m_ParentResLayout.GetOwner().GetReferenceCounters();
}
@@ -374,4 +372,4 @@ protected:
ResourceLayoutType& m_ParentResLayout;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/StateObjectsRegistry.h b/Graphics/GraphicsEngine/include/StateObjectsRegistry.h
index 5aefc444..f08b95ce 100644
--- a/Graphics/GraphicsEngine/include/StateObjectsRegistry.h
+++ b/Graphics/GraphicsEngine/include/StateObjectsRegistry.h
@@ -32,176 +32,178 @@
namespace Diligent
{
- /// Template class implementing state object registry
-
- /// \tparam ResourceDescType - type of the resource description. The type must have
- /// operator== and a hash function defined.
+/// Template class implementing state object registry
+
+/// \tparam ResourceDescType - type of the resource description. The type must have
+/// operator== and a hash function defined.
+///
+/// \remarks
+/// The following strategies do not work:
+/// - To store raw pointers and remove the object from the registry in the
+/// object's destructor. In this case other thread may obtain a reference
+/// to the object while it is being deleted. This scenario is possible if one thread
+/// has just entered the destructor, but other is executing Find() and entered
+/// the protection section.
+/// - Strong pointers will cause circular references and result in memory leaks.
+/// \remarks
+/// Only weak pointers provide thread-safe solution. The object is either atomically destroyed,
+/// so that no other thread can obtain a reference to it through weak pointers. Or it is atomically
+/// locked, so that strong reference is obtained. In this case no other thread can destroy the object,
+/// because there is at least one strong reference now. Note however that removing the object from the
+/// registry in the object's destructor may cause a deadlock at the point where Find() locks the weak pointer:
+/// if other thread has started dtor, the object will be locked by Diligent::RefCountedObject::Release().
+/// If after that this thread locks the registry first, it will be waiting for the object to unlock in
+/// Diligent::RefCntWeakPtr::Lock(), while the dtor thread will be waiting for the registry to unlock.
+template <typename ResourceDescType>
+class StateObjectsRegistry
+{
+public:
+ /// Number of outstanding deleted objects to purge the registry.
+ static constexpr int DeletedObjectsToPurge = 32;
+
+ StateObjectsRegistry(IMemoryAllocator& RawAllocator, const Char* RegistryName) :
+ m_DescToObjHashMap{STD_ALLOCATOR_RAW_MEM(HashMapElem, RawAllocator, "Allocator for unordered_map<ResourceDescType, RefCntWeakPtr<IDeviceObject> >")},
+ m_RegistryName{RegistryName}
+ {}
+
+ ~StateObjectsRegistry()
+ {
+ // Object registry is part of the device, and every device
+ // object holds a strong reference to the device. So device
+ // is destroyed after all device objects are destroyed, and there
+ // may only be expired references in the registry. After we
+ // purge it, the registry must be empty.
+ Purge();
+ VERIFY(m_DescToObjHashMap.empty(), "DescToObjHashMap is not empty");
+ }
+
+ /// Adds a new object to the registry
+
+ /// \param [in] ObjectDesc - object description.
+ /// \param [in] pObject - pointer to the object.
///
- /// \remarks
- /// The following strategies do not work:
- /// - To store raw pointers and remove the object from the registry in the
- /// object's destructor. In this case other thread may obtain a reference
- /// to the object while it is being deleted. This scenario is possible if one thread
- /// has just entered the destructor, but other is executing Find() and entered
- /// the protection section.
- /// - Strong pointers will cause circular references and result in memory leaks.
- /// \remarks
- /// Only weak pointers provide thread-safe solution. The object is either atomically destroyed,
- /// so that no other thread can obtain a reference to it through weak pointers. Or it is atomically
- /// locked, so that strong reference is obtained. In this case no other thread can destroy the object,
- /// because there is at least one strong reference now. Note however that removing the object from the
- /// registry in the object's destructor may cause a deadlock at the point where Find() locks the weak pointer:
- /// if other thread has started dtor, the object will be locked by Diligent::RefCountedObject::Release().
- /// If after that this thread locks the registry first, it will be waiting for the object to unlock in
- /// Diligent::RefCntWeakPtr::Lock(), while the dtor thread will be waiting for the registry to unlock.
- template<typename ResourceDescType>
- class StateObjectsRegistry
+ /// Besides adding a new object, the function also checks the number of
+ /// outstanding deleted objects and calls Purge() if the number has reached
+ /// the threshold value DeletedObjectsToPurge. Creating a state object is
+ /// assumed to be an expensive operation and should be performed during
+ /// the initialization. Occasional purge operations should not add significant
+ /// cost to it.
+ void Add(const ResourceDescType& ObjectDesc, IDeviceObject* pObject)
{
- public:
- /// Number of outstanding deleted objects to purge the registry.
- static constexpr int DeletedObjectsToPurge = 32;
-
- StateObjectsRegistry(IMemoryAllocator& RawAllocator, const Char* RegistryName) :
- m_DescToObjHashMap(STD_ALLOCATOR_RAW_MEM(HashMapElem, RawAllocator, "Allocator for unordered_map<ResourceDescType, RefCntWeakPtr<IDeviceObject> >") ),
- m_RegistryName( RegistryName )
- {}
-
- ~StateObjectsRegistry()
+ ThreadingTools::LockHelper Lock(m_LockFlag);
+
+ // If the number of outstanding deleted objects reached the threshold value,
+ // purge the registry. Since we have exclusive access now, it is safe
+ // to do.
+ if (m_NumDeletedObjects >= DeletedObjectsToPurge)
{
- // Object registry is part of the device, and every device
- // object holds a strong reference to the device. So device
- // is destroyed after all device objects are destroyed, and there
- // may only be expired references in the registry. After we
- // purge it, the registry must be empty.
Purge();
- VERIFY( m_DescToObjHashMap.empty(), "DescToObjHashMap is not empty" );
+ m_NumDeletedObjects = 0;
}
- /// Adds a new object to the registry
-
- /// \param [in] ObjectDesc - object description.
- /// \param [in] pObject - pointer to the object.
- ///
- /// Besides adding a new object, the function also checks the number of
- /// outstanding deleted objects and calls Purge() if the number has reached
- /// the threshold value DeletedObjectsToPurge. Creating a state object is
- /// assumed to be an expensive operation and should be performed during
- /// the initialization. Occasional purge operations should not add significant
- /// cost to it.
- void Add( const ResourceDescType& ObjectDesc, IDeviceObject* pObject )
+ // Try to construct the new element in place
+ auto Elems = m_DescToObjHashMap.emplace(std::make_pair(ObjectDesc, Diligent::RefCntWeakPtr<IDeviceObject>(pObject)));
+ // It is theorertically possible that the same object can be found
+ // in the registry. This might happen if two threads try to create
+ // the same object at the same time. They both will not find the
+ // object and then will create and try to add it.
+ //
+ // If the object already exists, we replace the existing reference.
+ // This is safer as there might be scenarios where existing reference
+ // might be expired. For instance, two threads try to create the same
+ // object which is not in the registry. The first thread creates
+ // the object, adds it to the registry and then releases it. After that
+ // the second thread creates the same object and tries to add it to
+ // the registry. It will find an existing expired reference to the
+ // object.
+ if (!Elems.second)
{
- ThreadingTools::LockHelper Lock( m_LockFlag );
+ VERIFY(Elems.first->first == ObjectDesc, "Incorrect object description");
+ LOG_WARNING_MESSAGE("Object named '", Elems.first->first.Name,
+ "' with the same description already exists in the registry."
+ "Replacing with the new object named '",
+ ObjectDesc.Name ? ObjectDesc.Name : "", "'.");
+ Elems.first->second = pObject;
+ }
+ }
- // If the number of outstanding deleted objects reached the threshold value,
- // purge the registry. Since we have exclusive access now, it is safe
- // to do.
- if( m_NumDeletedObjects >= DeletedObjectsToPurge )
- {
- Purge();
- m_NumDeletedObjects = 0;
- }
+ /// Finds the object in the registry
+ void Find(const ResourceDescType& Desc, IDeviceObject** ppObject)
+ {
+ VERIFY(*ppObject == nullptr, "Overwriting reference to existing object may cause memory leaks");
+ *ppObject = nullptr;
+ ThreadingTools::LockHelper Lock(m_LockFlag);
- // Try to construct the new element in place
- auto Elems = m_DescToObjHashMap.emplace( std::make_pair( ObjectDesc, Diligent::RefCntWeakPtr<IDeviceObject>(pObject) ) );
- // It is theorertically possible that the same object can be found
- // in the registry. This might happen if two threads try to create
- // the same object at the same time. They both will not find the
- // object and then will create and try to add it.
- //
- // If the object already exists, we replace the existing reference.
- // This is safer as there might be scenarios where existing reference
- // might be expired. For instance, two threads try to create the same
- // object which is not in the registry. The first thread creates
- // the object, adds it to the registry and then releases it. After that
- // the second thread creates the same object and tries to add it to
- // the registry. It will find an existing expired reference to the
- // object.
- if( !Elems.second )
+ auto It = m_DescToObjHashMap.find(Desc);
+ if (It != m_DescToObjHashMap.end())
+ {
+ // Try to obtain strong reference to the object.
+ // This is an atomic operation and we either get
+ // a new strong reference or object has been destroyed
+ // and we get null.
+ auto pObject = It->second.Lock();
+ if (pObject)
{
- VERIFY( Elems.first->first == ObjectDesc, "Incorrect object description" );
- LOG_WARNING_MESSAGE( "Object named \"", Elems.first->first.Name, "\" with the same description already exists in the registry."
- "Replacing with the new object named \"", ObjectDesc.Name ? ObjectDesc.Name : "", "\".");
- Elems.first->second = pObject;
+ *ppObject = pObject.Detach();
+ //LOG_INFO_MESSAGE( "Equivalent of the requested state object named \"", Desc.Name ? Desc.Name : "", "\" found in the ", m_RegistryName, " registry. Reusing existing object.");
}
- }
-
- /// Finds the object in the registry
- void Find( const ResourceDescType& Desc, IDeviceObject** ppObject )
- {
- VERIFY( *ppObject == nullptr, "Overwriting reference to existing object may cause memory leaks" );
- *ppObject = nullptr;
- ThreadingTools::LockHelper Lock( m_LockFlag );
-
- auto It = m_DescToObjHashMap.find( Desc );
- if( It != m_DescToObjHashMap.end() )
+ else
{
- // Try to obtain strong reference to the object.
- // This is an atomic operation and we either get
- // a new strong reference or object has been destroyed
- // and we get null.
- auto pObject = It->second.Lock();
- if( pObject )
- {
- *ppObject = pObject.Detach();
- //LOG_INFO_MESSAGE( "Equivalent of the requested state object named \"", Desc.Name ? Desc.Name : "", "\" found in the ", m_RegistryName, " registry. Reusing existing object.");
- }
- else
- {
- // Expired object found: remove it from the map
- m_DescToObjHashMap.erase(It);
- Atomics::AtomicDecrement(m_NumDeletedObjects);
- }
+ // Expired object found: remove it from the map
+ m_DescToObjHashMap.erase(It);
+ Atomics::AtomicDecrement(m_NumDeletedObjects);
}
}
+ }
- /// Purges outstanding deleted objects from the registry
- void Purge()
+ /// Purges outstanding deleted objects from the registry
+ void Purge()
+ {
+ Uint32 NumPurgedObjects = 0;
+ auto It = m_DescToObjHashMap.begin();
+ while (It != m_DescToObjHashMap.end())
{
- Uint32 NumPurgedObjects = 0;
- auto It = m_DescToObjHashMap.begin();
- while( It != m_DescToObjHashMap.end() )
+ auto NextIt = It;
+ ++NextIt;
+ // Note that IsValid() is not a thread-safe function in the sense that it
+ // can give false positive results. The only thread-safe way to check if the
+ // object is alive is to lock the weak pointer, but that requires thread
+ // synchronization. We will immediately unlock the pointer anyway, so we
+ // want to detect 100% expired pointers. IsValid() does provide that information
+ // because once a weak pointer becomes invalid, it will be invalid
+ // until it is destroyed. It is not a problem if we miss an expired weak
+ // pointer as it will definitiely be removed next time.
+ if (!It->second.IsValid())
{
- auto NextIt = It;
- ++NextIt;
- // Note that IsValid() is not a thread-safe function in the sense that it
- // can give false positive results. The only thread-safe way to check if the
- // object is alive is to lock the weak pointer, but that requires thread
- // synchronization. We will immediately unlock the pointer anyway, so we
- // want to detect 100% expired pointers. IsValid() does provide that information
- // because once a weak pointer becomes invalid, it will be invalid
- // until it is destroyed. It is not a problem if we miss an expired weak
- // pointer as it will definitiely be removed next time.
- if( !It->second.IsValid() )
- {
- m_DescToObjHashMap.erase( It );
- ++NumPurgedObjects;
- }
-
- It = NextIt;
+ m_DescToObjHashMap.erase(It);
+ ++NumPurgedObjects;
}
- LOG_INFO_MESSAGE( "Purged ", NumPurgedObjects, " deleted objects from the ", m_RegistryName, " registry" );
- }
- /// Increments the number of outstanding deleted objects.
- /// When this number reaches DeletedObjectsToPurge, Purge() will
- /// be called.
- void ReportDeletedObject()
- {
- Atomics::AtomicIncrement(m_NumDeletedObjects);
+ It = NextIt;
}
+ LOG_INFO_MESSAGE("Purged ", NumPurgedObjects, " deleted objects from the ", m_RegistryName, " registry");
+ }
+
+ /// Increments the number of outstanding deleted objects.
+ /// When this number reaches DeletedObjectsToPurge, Purge() will
+ /// be called.
+ void ReportDeletedObject()
+ {
+ Atomics::AtomicIncrement(m_NumDeletedObjects);
+ }
+
+private:
+ /// Lock flag to protect the m_DescToObjHashMap
+ ThreadingTools::LockFlag m_LockFlag;
+
+ /// Nmber of outstanding deleted objects that have not been purged
+ Atomics::AtomicLong m_NumDeletedObjects;
+
+ /// Hash map that stores weak pointers to the referenced objects
+ typedef std::pair<const ResourceDescType, RefCntWeakPtr<IDeviceObject>> HashMapElem;
+ std::unordered_map<ResourceDescType, RefCntWeakPtr<IDeviceObject>, std::hash<ResourceDescType>, std::equal_to<ResourceDescType>, STDAllocatorRawMem<HashMapElem>> m_DescToObjHashMap;
- private:
- /// Lock flag to protect the m_DescToObjHashMap
- ThreadingTools::LockFlag m_LockFlag;
-
- /// Nmber of outstanding deleted objects that have not been purged
- Atomics::AtomicLong m_NumDeletedObjects;
-
- /// Hash map that stores weak pointers to the referenced objects
- typedef std::pair< const ResourceDescType, RefCntWeakPtr<IDeviceObject> > HashMapElem;
- std::unordered_map<ResourceDescType, RefCntWeakPtr<IDeviceObject>, std::hash<ResourceDescType>, std::equal_to<ResourceDescType>, STDAllocatorRawMem<HashMapElem> > m_DescToObjHashMap;
-
- /// Registry name used for debug output
- const String m_RegistryName;
- };
-}
+ /// Registry name used for debug output
+ const String m_RegistryName;
+};
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/SwapChainBase.h b/Graphics/GraphicsEngine/include/SwapChainBase.h
index e5330c77..7890ef47 100644
--- a/Graphics/GraphicsEngine/include/SwapChainBase.h
+++ b/Graphics/GraphicsEngine/include/SwapChainBase.h
@@ -39,56 +39,60 @@ namespace Diligent
/// Base implementation of the swap chain.
-/// \tparam BaseInterface - base interface that this class will inheret
+/// \tparam BaseInterface - base interface that this class will inheret
/// (Diligent::ISwapChainGL, Diligent::ISwapChainD3D11,
/// Diligent::ISwapChainD3D12 or Diligent::ISwapChainVk).
/// \remarks Swap chain holds the strong reference to the device and a weak reference to the
/// immediate context.
-template<class BaseInterface>
+template <class BaseInterface>
class SwapChainBase : public ObjectBase<BaseInterface>
{
public:
typedef ObjectBase<BaseInterface> TObjectBase;
/// \param pRefCounters - reference counters object that controls the lifetime of this swap chain.
- /// \param pDevice - pointer to the device.
- /// \param pDeviceContext - pointer to the device context.
- /// \param SCDesc - swap chain description
+ /// \param pDevice - pointer to the device.
+ /// \param pDeviceContext - pointer to the device context.
+ /// \param SCDesc - swap chain description
SwapChainBase(IReferenceCounters* pRefCounters,
IRenderDevice* pDevice,
IDeviceContext* pDeviceContext,
const SwapChainDesc& SCDesc) :
+ // clang-format off
TObjectBase {pRefCounters},
m_pRenderDevice {pDevice },
m_wpDeviceContext {pDeviceContext},
m_SwapChainDesc {SCDesc }
+ // clang-format on
{
}
+ // clang-format off
SwapChainBase (const SwapChainBase&) = delete;
SwapChainBase ( SwapChainBase&&) = delete;
SwapChainBase& operator = (const SwapChainBase&) = delete;
SwapChainBase& operator = ( SwapChainBase&&) = delete;
+ // clang-format on
~SwapChainBase()
{
}
- IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_SwapChain, TObjectBase )
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_SwapChain, TObjectBase)
/// Implementation of ISwapChain::GetDesc()
- virtual const SwapChainDesc& GetDesc()const override final
+ virtual const SwapChainDesc& GetDesc() const override final
{
return m_SwapChainDesc;
}
-
+
protected:
- bool Resize( Uint32 NewWidth, Uint32 NewHeight, Int32 Dummy = 0/*To be different from virtual function*/ )
+ bool Resize(Uint32 NewWidth, Uint32 NewHeight, Int32 Dummy = 0 /*To be different from virtual function*/)
{
- if( NewWidth != 0 && NewHeight != 0 &&
- (m_SwapChainDesc.Width != NewWidth || m_SwapChainDesc.Height != NewHeight) )
+ if (NewWidth != 0 && NewHeight != 0 &&
+ (m_SwapChainDesc.Width != NewWidth || m_SwapChainDesc.Height != NewHeight))
{
- m_SwapChainDesc.Width = NewWidth;
+ m_SwapChainDesc.Width = NewWidth;
m_SwapChainDesc.Height = NewHeight;
LOG_INFO_MESSAGE("Resizing the swap chain to ", m_SwapChainDesc.Width, "x", m_SwapChainDesc.Height);
return true;
@@ -97,13 +101,13 @@ protected:
return false;
}
- template<typename DeviceContextImplType>
+ template <typename DeviceContextImplType>
bool UnbindRenderTargets(DeviceContextImplType* pImmediateCtx,
ITextureView* ppBackBufferRTVs[],
Uint32 NumBackBufferRTVs,
ITextureView* pDSV)
{
- bool RebindRenderTargets = false;
+ bool RebindRenderTargets = false;
bool UnbindRenderTargets = false;
if (m_SwapChainDesc.IsPrimary)
{
@@ -112,12 +116,12 @@ protected:
else
{
std::array<ITextureView*, MaxRenderTargets> pBoundRTVs = {};
- RefCntAutoPtr<ITextureView> pBoundDSV;
- Uint32 NumRenderTargets = 0;
+ RefCntAutoPtr<ITextureView> pBoundDSV;
+ Uint32 NumRenderTargets = 0;
pImmediateCtx->GetRenderTargets(NumRenderTargets, pBoundRTVs.data(), &pBoundDSV);
- for (Uint32 i=0; i < NumRenderTargets; ++i)
+ for (Uint32 i = 0; i < NumRenderTargets; ++i)
{
- for (Uint32 j=0; j < NumBackBufferRTVs; ++j)
+ for (Uint32 j = 0; j < NumBackBufferRTVs; ++j)
{
if (pBoundRTVs[i] == ppBackBufferRTVs[j])
UnbindRenderTargets = true;
@@ -141,7 +145,7 @@ protected:
/// Strong reference to the render device
RefCntAutoPtr<IRenderDevice> m_pRenderDevice;
-
+
/// Weak references to the immediate device context. The context holds
/// the strong reference to the swap chain.
RefCntWeakPtr<IDeviceContext> m_wpDeviceContext;
@@ -150,4 +154,4 @@ protected:
SwapChainDesc m_SwapChainDesc;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/TextureBase.h b/Graphics/GraphicsEngine/include/TextureBase.h
index 063fc13e..65f73d14 100644
--- a/Graphics/GraphicsEngine/include/TextureBase.h
+++ b/Graphics/GraphicsEngine/include/TextureBase.h
@@ -40,14 +40,14 @@ namespace Diligent
struct CopyTextureAttribs;
void ValidateTextureDesc(const TextureDesc& TexDesc);
-void ValidateUpdateTextureParams( const TextureDesc& TexDesc, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData );
-void ValidateCopyTextureParams( const CopyTextureAttribs& CopyAttribs );
-void ValidateMapTextureParams(const TextureDesc& TexDesc,
- Uint32 MipLevel,
- Uint32 ArraySlice,
- MAP_TYPE MapType,
- Uint32 MapFlags,
- const Box* pMapRegion);
+void ValidateUpdateTextureParams(const TextureDesc& TexDesc, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData);
+void ValidateCopyTextureParams(const CopyTextureAttribs& CopyAttribs);
+void ValidateMapTextureParams(const TextureDesc& TexDesc,
+ Uint32 MipLevel,
+ Uint32 ArraySlice,
+ MAP_TYPE MapType,
+ Uint32 MapFlags,
+ const Box* pMapRegion);
/// Base implementation of the ITexture interface
@@ -61,7 +61,7 @@ void ValidateMapTextureParams(const TextureDesc& TexDesc,
/// (Diligent::TextureViewD3D11Impl, Diligent::TextureViewD3D12Impl,
/// Diligent::TextureViewGLImpl or Diligent::TextureViewVkImpl).
/// \tparam TTexViewObjAllocator - type of the allocator that is used to allocate memory for the texture view object instances
-template<class BaseInterface, class TRenderDeviceImpl, class TTextureViewImpl, class TTexViewObjAllocator>
+template <class BaseInterface, class TRenderDeviceImpl, class TTextureViewImpl, class TTexViewObjAllocator>
class TextureBase : public DeviceObjectBase<BaseInterface, TRenderDeviceImpl, TextureDesc>
{
public:
@@ -70,16 +70,16 @@ public:
/// \param pRefCounters - reference counters object that controls the lifetime of this texture.
/// \param TexViewObjAllocator - allocator that is used to allocate memory for the instances of the texture view object.
/// This parameter is only used for debug purposes.
- /// \param pDevice - pointer to the device
- /// \param Desc - texture description
- /// \param bIsDeviceInternal - flag indicating if the texture is an internal device object and
- /// must not keep a strong reference to the device
- TextureBase( IReferenceCounters* pRefCounters,
- TTexViewObjAllocator& TexViewObjAllocator,
- TRenderDeviceImpl* pDevice,
- const TextureDesc& Desc,
- bool bIsDeviceInternal = false ) :
- TDeviceObjectBase( pRefCounters, pDevice, Desc, bIsDeviceInternal ),
+ /// \param pDevice - pointer to the device
+ /// \param Desc - texture description
+ /// \param bIsDeviceInternal - flag indicating if the texture is an internal device object and
+ /// must not keep a strong reference to the device
+ TextureBase(IReferenceCounters* pRefCounters,
+ TTexViewObjAllocator& TexViewObjAllocator,
+ TRenderDeviceImpl* pDevice,
+ const TextureDesc& Desc,
+ bool bIsDeviceInternal = false) :
+ TDeviceObjectBase(pRefCounters, pDevice, Desc, bIsDeviceInternal),
#ifdef _DEBUG
m_dbgTexViewObjAllocator(TexViewObjAllocator),
#endif
@@ -88,44 +88,46 @@ public:
m_pDefaultDSV(nullptr, STDDeleter<TTextureViewImpl, TTexViewObjAllocator>(TexViewObjAllocator)),
m_pDefaultUAV(nullptr, STDDeleter<TTextureViewImpl, TTexViewObjAllocator>(TexViewObjAllocator))
{
- if( this->m_Desc.MipLevels == 0 )
+ if (this->m_Desc.MipLevels == 0)
{
// Compute the number of levels in the full mipmap chain
- if( this->m_Desc.Type == RESOURCE_DIM_TEX_1D ||
- this->m_Desc.Type == RESOURCE_DIM_TEX_1D_ARRAY )
+ if (this->m_Desc.Type == RESOURCE_DIM_TEX_1D ||
+ this->m_Desc.Type == RESOURCE_DIM_TEX_1D_ARRAY)
{
this->m_Desc.MipLevels = ComputeMipLevelsCount(this->m_Desc.Width);
}
- else if( this->m_Desc.Type == RESOURCE_DIM_TEX_2D ||
- this->m_Desc.Type == RESOURCE_DIM_TEX_2D_ARRAY ||
- this->m_Desc.Type == RESOURCE_DIM_TEX_CUBE ||
- this->m_Desc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY )
- {
- this->m_Desc.MipLevels = ComputeMipLevelsCount( this->m_Desc.Width, this->m_Desc.Height );
+ else if (this->m_Desc.Type == RESOURCE_DIM_TEX_2D ||
+ this->m_Desc.Type == RESOURCE_DIM_TEX_2D_ARRAY ||
+ this->m_Desc.Type == RESOURCE_DIM_TEX_CUBE ||
+ this->m_Desc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY)
+ {
+ this->m_Desc.MipLevels = ComputeMipLevelsCount(this->m_Desc.Width, this->m_Desc.Height);
}
- else if( this->m_Desc.Type == RESOURCE_DIM_TEX_3D )
+ else if (this->m_Desc.Type == RESOURCE_DIM_TEX_3D)
{
- this->m_Desc.MipLevels = ComputeMipLevelsCount( this->m_Desc.Width, this->m_Desc.Height, this->m_Desc.Depth );
+ this->m_Desc.MipLevels = ComputeMipLevelsCount(this->m_Desc.Width, this->m_Desc.Height, this->m_Desc.Depth);
}
else
{
- UNEXPECTED( "Unknown texture type" );
+ UNEXPECTED("Unknown texture type");
}
}
Uint64 DeviceQueuesMask = pDevice->GetCommandQueueMask();
- DEV_CHECK_ERR( (this->m_Desc.CommandQueueMask & DeviceQueuesMask) != 0, "No bits in the command queue mask (0x", std::hex, this->m_Desc.CommandQueueMask, ") correspond to one of ", pDevice->GetCommandQueueCount(), " available device command queues");
+ DEV_CHECK_ERR((this->m_Desc.CommandQueueMask & DeviceQueuesMask) != 0,
+ "No bits in the command queue mask (0x", std::hex, this->m_Desc.CommandQueueMask,
+ ") correspond to one of ", pDevice->GetCommandQueueCount(), " available device command queues");
this->m_Desc.CommandQueueMask &= DeviceQueuesMask;
// Validate correctness of texture description
- ValidateTextureDesc( this->m_Desc );
+ ValidateTextureDesc(this->m_Desc);
}
- IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_Texture, TDeviceObjectBase )
-
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_Texture, TDeviceObjectBase)
+
/// Implementaiton of ITexture::CreateView(); calls CreateViewInternal() virtual function that
/// creates texture view for the specific engine implementation.
- virtual void CreateView( const struct TextureViewDesc& ViewDesc, ITextureView** ppView )override
+ virtual void CreateView(const struct TextureViewDesc& ViewDesc, ITextureView** ppView) override
{
DEV_CHECK_ERR(ViewDesc.ViewType != TEXTURE_VIEW_UNDEFINED, "Texture view type is not specified");
if (ViewDesc.ViewType == TEXTURE_VIEW_SHADER_RESOURCE)
@@ -139,7 +141,7 @@ public:
else
UNEXPECTED("Unexpected texture view type");
- CreateViewInternal( ViewDesc, ppView, false );
+ CreateViewInternal(ViewDesc, ppView, false);
}
/// Creates default texture views.
@@ -153,7 +155,7 @@ public:
/// The function calls CreateViewInternal().
void CreateDefaultViews();
- virtual void SetState(RESOURCE_STATE State)override final
+ virtual void SetState(RESOURCE_STATE State) override final
{
this->m_State = State;
}
@@ -163,38 +165,39 @@ public:
return this->m_State;
}
- bool IsInKnownState() const
+ bool IsInKnownState() const
{
return this->m_State != RESOURCE_STATE_UNKNOWN;
}
- bool CheckState(RESOURCE_STATE State)const
+ bool CheckState(RESOURCE_STATE State) const
{
- VERIFY((State & (State-1)) == 0, "Single state is expected");
+ VERIFY((State & (State - 1)) == 0, "Single state is expected");
VERIFY(IsInKnownState(), "Texture state is unknown");
return (this->m_State & State) == State;
}
/// Implementation of ITexture::GetDefaultView().
- virtual ITextureView* GetDefaultView( TEXTURE_VIEW_TYPE ViewType )override
+ virtual ITextureView* GetDefaultView(TEXTURE_VIEW_TYPE ViewType) override
{
- switch( ViewType )
+ switch (ViewType)
{
+ // clang-format off
case TEXTURE_VIEW_SHADER_RESOURCE: return m_pDefaultSRV.get();
case TEXTURE_VIEW_RENDER_TARGET: return m_pDefaultRTV.get();
case TEXTURE_VIEW_DEPTH_STENCIL: return m_pDefaultDSV.get();
case TEXTURE_VIEW_UNORDERED_ACCESS: return m_pDefaultUAV.get();
- default: UNEXPECTED( "Unknown view type" ); return nullptr;
+ // clang-format on
+ default: UNEXPECTED("Unknown view type"); return nullptr;
}
}
protected:
-
/// Pure virtual function that creates texture view for the specific engine implementation.
- virtual void CreateViewInternal( const struct TextureViewDesc& ViewDesc, ITextureView** ppView, bool bIsDefaultView ) = 0;
+ virtual void CreateViewInternal(const struct TextureViewDesc& ViewDesc, ITextureView** ppView, bool bIsDefaultView) = 0;
#ifdef _DEBUG
- TTexViewObjAllocator &m_dbgTexViewObjAllocator;
+ TTexViewObjAllocator& m_dbgTexViewObjAllocator;
#endif
// WARNING! We cannot use ITextureView here, because ITextureView has no virtual dtor!
/// Default SRV addressing the entire texture
@@ -206,44 +209,44 @@ protected:
/// Default UAV addressing the entire texture
std::unique_ptr<TTextureViewImpl, STDDeleter<TTextureViewImpl, TTexViewObjAllocator>> m_pDefaultUAV;
- void CorrectTextureViewDesc( struct TextureViewDesc& ViewDesc );
+ void CorrectTextureViewDesc(struct TextureViewDesc& ViewDesc);
RESOURCE_STATE m_State = RESOURCE_STATE_UNKNOWN;
};
-template<class BaseInterface, class TRenderDeviceImpl,class TTextureViewImpl, class TTexViewObjAllocator>
-void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObjAllocator> :: CorrectTextureViewDesc(struct TextureViewDesc& ViewDesc)
+template <class BaseInterface, class TRenderDeviceImpl, class TTextureViewImpl, class TTexViewObjAllocator>
+void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObjAllocator>::CorrectTextureViewDesc(struct TextureViewDesc& ViewDesc)
{
-#define TEX_VIEW_VALIDATION_ERROR(...) LOG_ERROR_AND_THROW( "\n Failed to create texture view '", (ViewDesc.Name ? ViewDesc.Name : ""), "' for texture '", this->m_Desc.Name, "': ", ##__VA_ARGS__ )
+#define TEX_VIEW_VALIDATION_ERROR(...) LOG_ERROR_AND_THROW("\n Failed to create texture view '", (ViewDesc.Name ? ViewDesc.Name : ""), "' for texture '", this->m_Desc.Name, "': ", ##__VA_ARGS__)
- if( !(ViewDesc.ViewType > TEXTURE_VIEW_UNDEFINED && ViewDesc.ViewType < TEXTURE_VIEW_NUM_VIEWS) )
- TEX_VIEW_VALIDATION_ERROR( "Texture view type is not specified" );
+ if (!(ViewDesc.ViewType > TEXTURE_VIEW_UNDEFINED && ViewDesc.ViewType < TEXTURE_VIEW_NUM_VIEWS))
+ TEX_VIEW_VALIDATION_ERROR("Texture view type is not specified");
- if( ViewDesc.MostDetailedMip >= this->m_Desc.MipLevels )
- TEX_VIEW_VALIDATION_ERROR( "Most detailed mip (", ViewDesc.MostDetailedMip, ") is out of range. The texture has only ", this->m_Desc.MipLevels, " mip ", (this->m_Desc.MipLevels > 1 ? "levels." : "level."));
+ if (ViewDesc.MostDetailedMip >= this->m_Desc.MipLevels)
+ TEX_VIEW_VALIDATION_ERROR("Most detailed mip (", ViewDesc.MostDetailedMip, ") is out of range. The texture has only ", this->m_Desc.MipLevels, " mip ", (this->m_Desc.MipLevels > 1 ? "levels." : "level."));
- if( ViewDesc.NumMipLevels != TextureViewDesc::RemainingMipLevels && ViewDesc.MostDetailedMip + ViewDesc.NumMipLevels > this->m_Desc.MipLevels )
- TEX_VIEW_VALIDATION_ERROR( "Most detailed mip (", ViewDesc.MostDetailedMip, ") and number of mip levels in the view (", ViewDesc.NumMipLevels, ") is out of range. The texture has only ", this->m_Desc.MipLevels, " mip ", (this->m_Desc.MipLevels > 1 ? "levels." : "level."));
+ if (ViewDesc.NumMipLevels != TextureViewDesc::RemainingMipLevels && ViewDesc.MostDetailedMip + ViewDesc.NumMipLevels > this->m_Desc.MipLevels)
+ TEX_VIEW_VALIDATION_ERROR("Most detailed mip (", ViewDesc.MostDetailedMip, ") and number of mip levels in the view (", ViewDesc.NumMipLevels, ") is out of range. The texture has only ", this->m_Desc.MipLevels, " mip ", (this->m_Desc.MipLevels > 1 ? "levels." : "level."));
- if( ViewDesc.Format == TEX_FORMAT_UNKNOWN )
- ViewDesc.Format = GetDefaultTextureViewFormat( this->m_Desc.Format, ViewDesc.ViewType, this->m_Desc.BindFlags );
+ if (ViewDesc.Format == TEX_FORMAT_UNKNOWN)
+ ViewDesc.Format = GetDefaultTextureViewFormat(this->m_Desc.Format, ViewDesc.ViewType, this->m_Desc.BindFlags);
- if( ViewDesc.TextureDim == RESOURCE_DIM_UNDEFINED )
+ if (ViewDesc.TextureDim == RESOURCE_DIM_UNDEFINED)
{
if (this->m_Desc.Type == RESOURCE_DIM_TEX_CUBE || this->m_Desc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY)
{
switch (ViewDesc.ViewType)
{
- case TEXTURE_VIEW_SHADER_RESOURCE:
+ case TEXTURE_VIEW_SHADER_RESOURCE:
ViewDesc.TextureDim = this->m_Desc.Type;
- break;
+ break;
- case TEXTURE_VIEW_RENDER_TARGET:
- case TEXTURE_VIEW_DEPTH_STENCIL:
- case TEXTURE_VIEW_UNORDERED_ACCESS:
+ case TEXTURE_VIEW_RENDER_TARGET:
+ case TEXTURE_VIEW_DEPTH_STENCIL:
+ case TEXTURE_VIEW_UNORDERED_ACCESS:
ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D_ARRAY;
- break;
+ break;
default: UNEXPECTED("Unexpected view type");
}
@@ -254,134 +257,134 @@ void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObj
}
}
- switch( this->m_Desc.Type )
+ switch (this->m_Desc.Type)
{
case RESOURCE_DIM_TEX_1D:
- if( ViewDesc.TextureDim != RESOURCE_DIM_TEX_1D )
+ if (ViewDesc.TextureDim != RESOURCE_DIM_TEX_1D)
{
- TEX_VIEW_VALIDATION_ERROR( "Incorrect texture type for Texture 1D view: only Texture 1D is allowed" );
+ TEX_VIEW_VALIDATION_ERROR("Incorrect texture type for Texture 1D view: only Texture 1D is allowed");
}
- break;
+ break;
case RESOURCE_DIM_TEX_1D_ARRAY:
- if( ViewDesc.TextureDim != RESOURCE_DIM_TEX_1D_ARRAY &&
- ViewDesc.TextureDim != RESOURCE_DIM_TEX_1D )
+ if (ViewDesc.TextureDim != RESOURCE_DIM_TEX_1D_ARRAY &&
+ ViewDesc.TextureDim != RESOURCE_DIM_TEX_1D)
{
- TEX_VIEW_VALIDATION_ERROR( "Incorrect view type for Texture 1D Array: only Texture 1D or Texture 1D Array are allowed" );
+ TEX_VIEW_VALIDATION_ERROR("Incorrect view type for Texture 1D Array: only Texture 1D or Texture 1D Array are allowed");
}
- break;
+ break;
case RESOURCE_DIM_TEX_2D:
- if(ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D_ARRAY &&
- ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D )
+ if (ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D_ARRAY &&
+ ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D)
{
- TEX_VIEW_VALIDATION_ERROR( "Incorrect texture type for Texture 2D view: only Texture 2D or Texture 2D Array are allowed" );
+ TEX_VIEW_VALIDATION_ERROR("Incorrect texture type for Texture 2D view: only Texture 2D or Texture 2D Array are allowed");
}
- break;
+ break;
case RESOURCE_DIM_TEX_2D_ARRAY:
- if( ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D_ARRAY &&
- ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D )
+ if (ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D_ARRAY &&
+ ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D)
{
- TEX_VIEW_VALIDATION_ERROR( "Incorrect texture type for Texture 2D Array view: only Texture 2D or Texture 2D Array are allowed" );
+ TEX_VIEW_VALIDATION_ERROR("Incorrect texture type for Texture 2D Array view: only Texture 2D or Texture 2D Array are allowed");
}
- break;
+ break;
case RESOURCE_DIM_TEX_3D:
- if( ViewDesc.TextureDim != RESOURCE_DIM_TEX_3D )
+ if (ViewDesc.TextureDim != RESOURCE_DIM_TEX_3D)
{
- TEX_VIEW_VALIDATION_ERROR( "Incorrect texture type for Texture 3D view: only Texture 3D is allowed" );
+ TEX_VIEW_VALIDATION_ERROR("Incorrect texture type for Texture 3D view: only Texture 3D is allowed");
}
- break;
+ break;
case RESOURCE_DIM_TEX_CUBE:
- if(ViewDesc.ViewType == TEXTURE_VIEW_SHADER_RESOURCE)
+ if (ViewDesc.ViewType == TEXTURE_VIEW_SHADER_RESOURCE)
{
- if(ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D &&
- ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D_ARRAY &&
- ViewDesc.TextureDim != RESOURCE_DIM_TEX_CUBE)
+ if (ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D &&
+ ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D_ARRAY &&
+ ViewDesc.TextureDim != RESOURCE_DIM_TEX_CUBE)
{
- TEX_VIEW_VALIDATION_ERROR( "Incorrect texture type for Texture cube SRV: Texture 2D, Texture 2D array or Texture Cube is allowed" );
+ TEX_VIEW_VALIDATION_ERROR("Incorrect texture type for Texture cube SRV: Texture 2D, Texture 2D array or Texture Cube is allowed");
}
}
else
{
- if(ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D &&
- ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D_ARRAY)
+ if (ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D &&
+ ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D_ARRAY)
{
- TEX_VIEW_VALIDATION_ERROR( "Incorrect texture type for Texture cube non-shader resource view: Texture 2D or Texture 2D array is allowed" );
+ TEX_VIEW_VALIDATION_ERROR("Incorrect texture type for Texture cube non-shader resource view: Texture 2D or Texture 2D array is allowed");
}
}
- break;
+ break;
case RESOURCE_DIM_TEX_CUBE_ARRAY:
- if(ViewDesc.ViewType == TEXTURE_VIEW_SHADER_RESOURCE)
+ if (ViewDesc.ViewType == TEXTURE_VIEW_SHADER_RESOURCE)
{
- if(ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D &&
- ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D_ARRAY &&
- ViewDesc.TextureDim != RESOURCE_DIM_TEX_CUBE &&
- ViewDesc.TextureDim != RESOURCE_DIM_TEX_CUBE_ARRAY)
+ if (ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D &&
+ ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D_ARRAY &&
+ ViewDesc.TextureDim != RESOURCE_DIM_TEX_CUBE &&
+ ViewDesc.TextureDim != RESOURCE_DIM_TEX_CUBE_ARRAY)
{
- TEX_VIEW_VALIDATION_ERROR( "Incorrect texture type for Texture cube array SRV: Texture 2D, Texture 2D array, Texture Cube or Texture Cube Array is allowed" );
+ TEX_VIEW_VALIDATION_ERROR("Incorrect texture type for Texture cube array SRV: Texture 2D, Texture 2D array, Texture Cube or Texture Cube Array is allowed");
}
}
else
{
- if(ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D &&
- ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D_ARRAY)
+ if (ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D &&
+ ViewDesc.TextureDim != RESOURCE_DIM_TEX_2D_ARRAY)
{
- TEX_VIEW_VALIDATION_ERROR( "Incorrect texture type for Texture cube array non-shader resource view: Texture 2D or Texture 2D array is allowed" );
+ TEX_VIEW_VALIDATION_ERROR("Incorrect texture type for Texture cube array non-shader resource view: Texture 2D or Texture 2D array is allowed");
}
}
- break;
+ break;
default:
- UNEXPECTED( "Unexpected texture type" );
- break;
+ UNEXPECTED("Unexpected texture type");
+ break;
}
- if ( ViewDesc.TextureDim == RESOURCE_DIM_TEX_CUBE )
+ if (ViewDesc.TextureDim == RESOURCE_DIM_TEX_CUBE)
{
- if(ViewDesc.ViewType != TEXTURE_VIEW_SHADER_RESOURCE)
- TEX_VIEW_VALIDATION_ERROR( "Unexpected view type: SRV is expected");
- if(ViewDesc.NumArraySlices != 6 && ViewDesc.NumArraySlices != 0 && ViewDesc.NumArraySlices != TextureViewDesc::RemainingArraySlices)
- TEX_VIEW_VALIDATION_ERROR( "Texture cube SRV is expected to have 6 array slices, while ", ViewDesc.NumArraySlices, " is provided" );
- if(ViewDesc.FirstArraySlice != 0)
- TEX_VIEW_VALIDATION_ERROR( "First slice (", ViewDesc.FirstArraySlice, ") must be 0 for non-array texture cube SRV" );
+ if (ViewDesc.ViewType != TEXTURE_VIEW_SHADER_RESOURCE)
+ TEX_VIEW_VALIDATION_ERROR("Unexpected view type: SRV is expected");
+ if (ViewDesc.NumArraySlices != 6 && ViewDesc.NumArraySlices != 0 && ViewDesc.NumArraySlices != TextureViewDesc::RemainingArraySlices)
+ TEX_VIEW_VALIDATION_ERROR("Texture cube SRV is expected to have 6 array slices, while ", ViewDesc.NumArraySlices, " is provided");
+ if (ViewDesc.FirstArraySlice != 0)
+ TEX_VIEW_VALIDATION_ERROR("First slice (", ViewDesc.FirstArraySlice, ") must be 0 for non-array texture cube SRV");
}
- if ( ViewDesc.TextureDim == RESOURCE_DIM_TEX_CUBE_ARRAY )
+ if (ViewDesc.TextureDim == RESOURCE_DIM_TEX_CUBE_ARRAY)
{
- if(ViewDesc.ViewType != TEXTURE_VIEW_SHADER_RESOURCE )
- TEX_VIEW_VALIDATION_ERROR( "Unexpected view type: SRV is expected");
- if(ViewDesc.NumArraySlices != TextureViewDesc::RemainingArraySlices && (ViewDesc.NumArraySlices % 6) != 0)
- TEX_VIEW_VALIDATION_ERROR( "Number of slices in texture cube array SRV is expected to be multiple of 6. ", ViewDesc.NumArraySlices, " slices is provided." );
+ if (ViewDesc.ViewType != TEXTURE_VIEW_SHADER_RESOURCE)
+ TEX_VIEW_VALIDATION_ERROR("Unexpected view type: SRV is expected");
+ if (ViewDesc.NumArraySlices != TextureViewDesc::RemainingArraySlices && (ViewDesc.NumArraySlices % 6) != 0)
+ TEX_VIEW_VALIDATION_ERROR("Number of slices in texture cube array SRV is expected to be multiple of 6. ", ViewDesc.NumArraySlices, " slices is provided.");
}
if (ViewDesc.TextureDim == RESOURCE_DIM_TEX_1D ||
ViewDesc.TextureDim == RESOURCE_DIM_TEX_2D)
{
- if(ViewDesc.FirstArraySlice != 0)
- TEX_VIEW_VALIDATION_ERROR( "First slice (", ViewDesc.FirstArraySlice, ") must be 0 for non-array texture 1D/2D views" );
+ if (ViewDesc.FirstArraySlice != 0)
+ TEX_VIEW_VALIDATION_ERROR("First slice (", ViewDesc.FirstArraySlice, ") must be 0 for non-array texture 1D/2D views");
- if(ViewDesc.NumArraySlices != TextureViewDesc::RemainingArraySlices && ViewDesc.NumArraySlices > 1)
- TEX_VIEW_VALIDATION_ERROR( "Number of slices in the view (", ViewDesc.NumArraySlices, ") must be 1 (or 0) for non-array texture 1D/2D views" );
+ if (ViewDesc.NumArraySlices != TextureViewDesc::RemainingArraySlices && ViewDesc.NumArraySlices > 1)
+ TEX_VIEW_VALIDATION_ERROR("Number of slices in the view (", ViewDesc.NumArraySlices, ") must be 1 (or 0) for non-array texture 1D/2D views");
}
- else if( ViewDesc.TextureDim == RESOURCE_DIM_TEX_1D_ARRAY ||
- ViewDesc.TextureDim == RESOURCE_DIM_TEX_2D_ARRAY ||
- ViewDesc.TextureDim == RESOURCE_DIM_TEX_CUBE ||
- ViewDesc.TextureDim == RESOURCE_DIM_TEX_CUBE_ARRAY )
+ else if (ViewDesc.TextureDim == RESOURCE_DIM_TEX_1D_ARRAY ||
+ ViewDesc.TextureDim == RESOURCE_DIM_TEX_2D_ARRAY ||
+ ViewDesc.TextureDim == RESOURCE_DIM_TEX_CUBE ||
+ ViewDesc.TextureDim == RESOURCE_DIM_TEX_CUBE_ARRAY)
{
- if( ViewDesc.FirstArraySlice >= this->m_Desc.ArraySize )
- TEX_VIEW_VALIDATION_ERROR( "First array slice (", ViewDesc.FirstArraySlice, ") exceeds the number of slices in the texture array (", this->m_Desc.ArraySize, ")" );
+ if (ViewDesc.FirstArraySlice >= this->m_Desc.ArraySize)
+ TEX_VIEW_VALIDATION_ERROR("First array slice (", ViewDesc.FirstArraySlice, ") exceeds the number of slices in the texture array (", this->m_Desc.ArraySize, ")");
- if( ViewDesc.NumArraySlices != TextureViewDesc::RemainingArraySlices && ViewDesc.FirstArraySlice + ViewDesc.NumArraySlices > this->m_Desc.ArraySize )
- TEX_VIEW_VALIDATION_ERROR( "First slice (", ViewDesc.FirstArraySlice, ") and number of slices in the view (", ViewDesc.NumArraySlices, ") specify more slices than target texture has (", this->m_Desc.ArraySize, ")" );
+ if (ViewDesc.NumArraySlices != TextureViewDesc::RemainingArraySlices && ViewDesc.FirstArraySlice + ViewDesc.NumArraySlices > this->m_Desc.ArraySize)
+ TEX_VIEW_VALIDATION_ERROR("First slice (", ViewDesc.FirstArraySlice, ") and number of slices in the view (", ViewDesc.NumArraySlices, ") specify more slices than target texture has (", this->m_Desc.ArraySize, ")");
}
- else if( ViewDesc.TextureDim == RESOURCE_DIM_TEX_3D )
+ else if (ViewDesc.TextureDim == RESOURCE_DIM_TEX_3D)
{
auto MipDepth = this->m_Desc.Depth >> ViewDesc.MostDetailedMip;
- if( ViewDesc.FirstDepthSlice + ViewDesc.NumDepthSlices > MipDepth )
- TEX_VIEW_VALIDATION_ERROR( "First slice (", ViewDesc.FirstDepthSlice, ") and number of slices in the view (", ViewDesc.NumDepthSlices, ") specify more slices than target 3D texture mip level has (", MipDepth, ")" );
+ if (ViewDesc.FirstDepthSlice + ViewDesc.NumDepthSlices > MipDepth)
+ TEX_VIEW_VALIDATION_ERROR("First slice (", ViewDesc.FirstDepthSlice, ") and number of slices in the view (", ViewDesc.NumDepthSlices, ") specify more slices than target 3D texture mip level has (", MipDepth, ")");
}
else
{
@@ -390,57 +393,57 @@ void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObj
if (GetTextureFormatAttribs(ViewDesc.Format).IsTypeless)
{
- TEX_VIEW_VALIDATION_ERROR( "Texture view format (", GetTextureFormatAttribs(ViewDesc.Format).Name, ") cannot be typeless" );
+ TEX_VIEW_VALIDATION_ERROR("Texture view format (", GetTextureFormatAttribs(ViewDesc.Format).Name, ") cannot be typeless");
}
if ((ViewDesc.Flags & TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION) != 0)
{
if ((this->m_Desc.MiscFlags & MISC_TEXTURE_FLAG_GENERATE_MIPS) == 0)
- TEX_VIEW_VALIDATION_ERROR( "TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION flag can only set if the texture was created with MISC_TEXTURE_FLAG_GENERATE_MIPS flag" );
+ TEX_VIEW_VALIDATION_ERROR("TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION flag can only set if the texture was created with MISC_TEXTURE_FLAG_GENERATE_MIPS flag");
if (ViewDesc.ViewType != TEXTURE_VIEW_SHADER_RESOURCE)
- TEX_VIEW_VALIDATION_ERROR( "TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION flag can only be used with TEXTURE_VIEW_SHADER_RESOURCE view type" );
+ TEX_VIEW_VALIDATION_ERROR("TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION flag can only be used with TEXTURE_VIEW_SHADER_RESOURCE view type");
}
#undef TEX_VIEW_VALIDATION_ERROR
- if( ViewDesc.NumMipLevels == 0 || ViewDesc.NumMipLevels == TextureViewDesc::RemainingMipLevels )
+ if (ViewDesc.NumMipLevels == 0 || ViewDesc.NumMipLevels == TextureViewDesc::RemainingMipLevels)
{
- if( ViewDesc.ViewType == TEXTURE_VIEW_SHADER_RESOURCE )
+ if (ViewDesc.ViewType == TEXTURE_VIEW_SHADER_RESOURCE)
ViewDesc.NumMipLevels = this->m_Desc.MipLevels - ViewDesc.MostDetailedMip;
else
ViewDesc.NumMipLevels = 1;
}
-
- if( ViewDesc.NumArraySlices == 0 || ViewDesc.NumArraySlices == TextureViewDesc::RemainingArraySlices )
+
+ if (ViewDesc.NumArraySlices == 0 || ViewDesc.NumArraySlices == TextureViewDesc::RemainingArraySlices)
{
- if( ViewDesc.TextureDim == RESOURCE_DIM_TEX_1D_ARRAY ||
- ViewDesc.TextureDim == RESOURCE_DIM_TEX_2D_ARRAY ||
- ViewDesc.TextureDim == RESOURCE_DIM_TEX_CUBE ||
- ViewDesc.TextureDim == RESOURCE_DIM_TEX_CUBE_ARRAY )
+ if (ViewDesc.TextureDim == RESOURCE_DIM_TEX_1D_ARRAY ||
+ ViewDesc.TextureDim == RESOURCE_DIM_TEX_2D_ARRAY ||
+ ViewDesc.TextureDim == RESOURCE_DIM_TEX_CUBE ||
+ ViewDesc.TextureDim == RESOURCE_DIM_TEX_CUBE_ARRAY)
ViewDesc.NumArraySlices = this->m_Desc.ArraySize - ViewDesc.FirstArraySlice;
- else if( ViewDesc.TextureDim == RESOURCE_DIM_TEX_3D )
+ else if (ViewDesc.TextureDim == RESOURCE_DIM_TEX_3D)
{
- auto MipDepth = this->m_Desc.Depth >> ViewDesc.MostDetailedMip;
+ auto MipDepth = this->m_Desc.Depth >> ViewDesc.MostDetailedMip;
ViewDesc.NumDepthSlices = MipDepth - ViewDesc.FirstDepthSlice;
}
else
ViewDesc.NumArraySlices = 1;
}
- if( (ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET) &&
- ( ViewDesc.Format == TEX_FORMAT_R8_SNORM || ViewDesc.Format == TEX_FORMAT_RG8_SNORM || ViewDesc.Format == TEX_FORMAT_RGBA8_SNORM ||
- ViewDesc.Format == TEX_FORMAT_R16_SNORM || ViewDesc.Format == TEX_FORMAT_RG16_SNORM || ViewDesc.Format == TEX_FORMAT_RGBA16_SNORM ) )
+ if ((ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET) &&
+ (ViewDesc.Format == TEX_FORMAT_R8_SNORM || ViewDesc.Format == TEX_FORMAT_RG8_SNORM || ViewDesc.Format == TEX_FORMAT_RGBA8_SNORM ||
+ ViewDesc.Format == TEX_FORMAT_R16_SNORM || ViewDesc.Format == TEX_FORMAT_RG16_SNORM || ViewDesc.Format == TEX_FORMAT_RGBA16_SNORM))
{
- const auto *FmtName = GetTextureFormatAttribs( ViewDesc.Format ).Name;
- LOG_WARNING_MESSAGE( FmtName, " render target view is created.\n"
- "There might be an issue in OpenGL driver on NVidia hardware: when rendering to SNORM textures, all negative values are clamped to zero.\n"
- "Use UNORM format instead." );
+ const auto* FmtName = GetTextureFormatAttribs(ViewDesc.Format).Name;
+ LOG_WARNING_MESSAGE(FmtName, " render target view is created.\n"
+ "There might be an issue in OpenGL driver on NVidia hardware: when rendering to SNORM textures, all negative values are clamped to zero.\n"
+ "Use UNORM format instead.");
}
}
-template<class BaseInterface, class TRenderDeviceImpl,class TTextureViewImpl, class TTexViewObjAllocator>
-void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObjAllocator> :: CreateDefaultViews()
+template <class BaseInterface, class TRenderDeviceImpl, class TTextureViewImpl, class TTexViewObjAllocator>
+void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObjAllocator>::CreateDefaultViews()
{
const auto& TexFmtAttribs = GetTextureFormatAttribs(this->m_Desc.Format);
if (TexFmtAttribs.ComponentType == COMPONENT_TYPE_UNDEFINED)
@@ -449,60 +452,60 @@ void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObj
return;
}
- if (this->m_Desc.BindFlags & BIND_SHADER_RESOURCE )
+ if (this->m_Desc.BindFlags & BIND_SHADER_RESOURCE)
{
TextureViewDesc ViewDesc;
ViewDesc.ViewType = TEXTURE_VIEW_SHADER_RESOURCE;
- auto ViewName = FormatString("Default SRV of texture '", this->m_Desc.Name, "'");
- ViewDesc.Name = ViewName.c_str();
-
- ITextureView *pSRV = nullptr;
+ auto ViewName = FormatString("Default SRV of texture '", this->m_Desc.Name, "'");
+ ViewDesc.Name = ViewName.c_str();
+
+ ITextureView* pSRV = nullptr;
if ((this->m_Desc.MiscFlags & MISC_TEXTURE_FLAG_GENERATE_MIPS) != 0)
ViewDesc.Flags |= TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION;
- CreateViewInternal( ViewDesc, &pSRV, true );
- m_pDefaultSRV.reset( static_cast<TTextureViewImpl*>(pSRV) );
- VERIFY( m_pDefaultSRV->GetDesc().ViewType == TEXTURE_VIEW_SHADER_RESOURCE, "Unexpected view type" );
+ CreateViewInternal(ViewDesc, &pSRV, true);
+ m_pDefaultSRV.reset(static_cast<TTextureViewImpl*>(pSRV));
+ VERIFY(m_pDefaultSRV->GetDesc().ViewType == TEXTURE_VIEW_SHADER_RESOURCE, "Unexpected view type");
}
- if(this->m_Desc.BindFlags & BIND_RENDER_TARGET )
+ if (this->m_Desc.BindFlags & BIND_RENDER_TARGET)
{
TextureViewDesc ViewDesc;
ViewDesc.ViewType = TEXTURE_VIEW_RENDER_TARGET;
- auto ViewName = FormatString("Default RTV of texture '", this->m_Desc.Name, "'");
- ViewDesc.Name = ViewName.c_str();
+ auto ViewName = FormatString("Default RTV of texture '", this->m_Desc.Name, "'");
+ ViewDesc.Name = ViewName.c_str();
- ITextureView *pRTV = nullptr;
- CreateViewInternal( ViewDesc, &pRTV, true );
- m_pDefaultRTV.reset( static_cast<TTextureViewImpl*>(pRTV) );
- VERIFY( m_pDefaultRTV->GetDesc().ViewType == TEXTURE_VIEW_RENDER_TARGET, "Unexpected view type" );
+ ITextureView* pRTV = nullptr;
+ CreateViewInternal(ViewDesc, &pRTV, true);
+ m_pDefaultRTV.reset(static_cast<TTextureViewImpl*>(pRTV));
+ VERIFY(m_pDefaultRTV->GetDesc().ViewType == TEXTURE_VIEW_RENDER_TARGET, "Unexpected view type");
}
- if(this->m_Desc.BindFlags & BIND_DEPTH_STENCIL )
+ if (this->m_Desc.BindFlags & BIND_DEPTH_STENCIL)
{
TextureViewDesc ViewDesc;
ViewDesc.ViewType = TEXTURE_VIEW_DEPTH_STENCIL;
- auto ViewName = FormatString("Default DSV of texture '", this->m_Desc.Name, "'");
- ViewDesc.Name = ViewName.c_str();
-
- ITextureView *pDSV = nullptr;
- CreateViewInternal( ViewDesc, &pDSV, true );
- m_pDefaultDSV.reset( static_cast<TTextureViewImpl*>(pDSV) );
- VERIFY( m_pDefaultDSV->GetDesc().ViewType == TEXTURE_VIEW_DEPTH_STENCIL, "Unexpected view type" );
+ auto ViewName = FormatString("Default DSV of texture '", this->m_Desc.Name, "'");
+ ViewDesc.Name = ViewName.c_str();
+
+ ITextureView* pDSV = nullptr;
+ CreateViewInternal(ViewDesc, &pDSV, true);
+ m_pDefaultDSV.reset(static_cast<TTextureViewImpl*>(pDSV));
+ VERIFY(m_pDefaultDSV->GetDesc().ViewType == TEXTURE_VIEW_DEPTH_STENCIL, "Unexpected view type");
}
- if(this->m_Desc.BindFlags & BIND_UNORDERED_ACCESS )
+ if (this->m_Desc.BindFlags & BIND_UNORDERED_ACCESS)
{
TextureViewDesc ViewDesc;
ViewDesc.ViewType = TEXTURE_VIEW_UNORDERED_ACCESS;
- auto ViewName = FormatString("Default UAV of texture '", this->m_Desc.Name, "'");
- ViewDesc.Name = ViewName.c_str();
+ auto ViewName = FormatString("Default UAV of texture '", this->m_Desc.Name, "'");
+ ViewDesc.Name = ViewName.c_str();
ViewDesc.AccessFlags = UAV_ACCESS_FLAG_READ_WRITE;
- ITextureView *pUAV = nullptr;
- CreateViewInternal( ViewDesc, &pUAV, true );
- m_pDefaultUAV.reset( static_cast<TTextureViewImpl*>(pUAV) );
- VERIFY( m_pDefaultUAV->GetDesc().ViewType == TEXTURE_VIEW_UNORDERED_ACCESS, "Unexpected view type" );
- }
+ ITextureView* pUAV = nullptr;
+ CreateViewInternal(ViewDesc, &pUAV, true);
+ m_pDefaultUAV.reset(static_cast<TTextureViewImpl*>(pUAV));
+ VERIFY(m_pDefaultUAV->GetDesc().ViewType == TEXTURE_VIEW_UNORDERED_ACCESS, "Unexpected view type");
+ }
}
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/TextureViewBase.h b/Graphics/GraphicsEngine/include/TextureViewBase.h
index 8dbb704f..2f57aaf2 100644
--- a/Graphics/GraphicsEngine/include/TextureViewBase.h
+++ b/Graphics/GraphicsEngine/include/TextureViewBase.h
@@ -36,13 +36,13 @@ namespace Diligent
/// Template class implementing base functionality for a texture view interface
-/// \tparam BaseInterface - base interface that this class will inheret
+/// \tparam BaseInterface - base interface that this class will inheret
/// (Diligent::ITextureViewD3D11, Diligent::ITextureViewD3D12,
/// Diligent::ITextureViewGL or Diligent::ITextureViewVk).
/// \tparam RenderDeviceImplType - type of the render device implementation
/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl,
/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl)
-template<class BaseInterface, class RenderDeviceImplType>
+template <class BaseInterface, class RenderDeviceImplType>
class TextureViewBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, TextureViewDesc>
{
public:
@@ -50,68 +50,68 @@ public:
/// \param pRefCounters - reference counters object that controls the lifetime of this texture view.
- /// \param pDevice - pointer to the render device.
- /// \param ViewDesc - texture view description.
- /// \param pTexture - pointer to the texture that the view is to be created for.
- /// \param bIsDefaultView - flag indicating if the view is default view, and is thus
- /// part of the texture object. In this case the view will attach
- /// to the texture's reference counters.
- TextureViewBase( IReferenceCounters* pRefCounters,
- RenderDeviceImplType* pDevice,
- const TextureViewDesc& ViewDesc,
- class ITexture* pTexture,
- bool bIsDefaultView ) :
- // Default views are created as part of the texture, so we cannot not keep strong
- // reference to the texture to avoid cyclic links. Instead, we will attach to the
+ /// \param pDevice - pointer to the render device.
+ /// \param ViewDesc - texture view description.
+ /// \param pTexture - pointer to the texture that the view is to be created for.
+ /// \param bIsDefaultView - flag indicating if the view is default view, and is thus
+ /// part of the texture object. In this case the view will attach
+ /// to the texture's reference counters.
+ TextureViewBase(IReferenceCounters* pRefCounters,
+ RenderDeviceImplType* pDevice,
+ const TextureViewDesc& ViewDesc,
+ class ITexture* pTexture,
+ bool bIsDefaultView) :
+ // Default views are created as part of the texture, so we cannot not keep strong
+ // reference to the texture to avoid cyclic links. Instead, we will attach to the
// reference counters of the texture.
- TDeviceObjectBase( pRefCounters, pDevice, ViewDesc ),
- m_pTexture( pTexture ),
+ TDeviceObjectBase(pRefCounters, pDevice, ViewDesc),
+ m_pTexture(pTexture),
// For non-default view, we will keep strong reference to texture
m_spTexture(bIsDefaultView ? nullptr : pTexture)
{}
- IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_TextureView, TDeviceObjectBase )
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_TextureView, TDeviceObjectBase)
/// Implementation of ITextureView::SetSampler()
- virtual void SetSampler( class ISampler *pSampler )override final
+ virtual void SetSampler(class ISampler* pSampler) override final
{
#ifdef DEVELOPMENT
- if( this->m_Desc.ViewType != TEXTURE_VIEW_SHADER_RESOURCE)
- LOG_ERROR("Texture view \"", this->m_Desc.Name, "\": a sampler can be attached to a shader resource view only. The view type is ", GetTexViewTypeLiteralName(this->m_Desc.ViewType) );
+ if (this->m_Desc.ViewType != TEXTURE_VIEW_SHADER_RESOURCE)
+ LOG_ERROR("Texture view \"", this->m_Desc.Name, "\": a sampler can be attached to a shader resource view only. The view type is ", GetTexViewTypeLiteralName(this->m_Desc.ViewType));
#endif
m_pSampler = pSampler;
}
/// Implementation of ITextureView::GetSampler()
- virtual ISampler* GetSampler()override final
- {
- return m_pSampler;
+ virtual ISampler* GetSampler() override final
+ {
+ return m_pSampler;
}
-
- const ISampler* GetSampler()const
+
+ const ISampler* GetSampler() const
{
return m_pSampler;
}
/// Implementation of ITextureView::GetTexture()
- virtual ITexture* GetTexture()override final
+ virtual ITexture* GetTexture() override final
{
return m_pTexture;
}
- const ITexture* GetTexture()const
+ const ITexture* GetTexture() const
{
return m_pTexture;
}
- template<typename TextureType>
+ template <typename TextureType>
TextureType* GetTexture()
{
return ValidatedCast<TextureType>(m_pTexture);
}
- template<typename TextureType>
- TextureType* GetTexture()const
+ template <typename TextureType>
+ TextureType* GetTexture() const
{
return ValidatedCast<TextureType>(m_pTexture);
}
@@ -128,4 +128,4 @@ protected:
RefCntAutoPtr<ITexture> m_spTexture;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/APIInfo.h b/Graphics/GraphicsEngine/interface/APIInfo.h
index 70f487e4..866a7693 100644
--- a/Graphics/GraphicsEngine/interface/APIInfo.h
+++ b/Graphics/GraphicsEngine/interface/APIInfo.h
@@ -36,64 +36,64 @@ namespace Diligent
/// Diligent API Info. This tructure can be used to verify API compatibility.
struct APIInfo
{
- size_t StructSize = 0;
- int APIVersion = 0;
- size_t RenderTargetBlendDescSize = 0;
- size_t BlendStateDescSize = 0;
- size_t BufferDescSize = 0;
- size_t BufferDataSize = 0;
- size_t BufferFormatSize = 0;
- size_t BufferViewDescSize = 0;
- size_t StencilOpDescSize = 0;
- size_t DepthStencilStateDescSize = 0;
- size_t SamplerCapsSize = 0;
- size_t TextureCapsSize = 0;
- size_t DeviceCapsSize = 0;
- size_t DrawAttribsSize = 0;
- size_t DispatchComputeAttribsSize = 0;
- size_t ViewportSize = 0;
- size_t RectSize = 0;
- size_t CopyTextureAttribsSize = 0;
- size_t DeviceObjectAttribsSize = 0;
- size_t HardwareAdapterAttribsSize = 0;
- size_t DisplayModeAttribsSize = 0;
- size_t SwapChainDescSize = 0;
- size_t FullScreenModeDescSize = 0;
- size_t EngineCreateInfoSize = 0;
- size_t EngineGLCreateInfoSize = 0;
- size_t EngineD3D11CreateInfoSize = 0;
- size_t EngineD3D12CreateInfoSize = 0;
- size_t EngineVkCreateInfoSize = 0;
- size_t EngineMtlCreateInfoSize = 0;
- size_t BoxSize = 0;
- size_t TextureFormatAttribsSize = 0;
- size_t TextureFormatInfoSize = 0;
- size_t TextureFormatInfoExtSize = 0;
- size_t StateTransitionDescSize = 0;
- size_t LayoutElementSize = 0;
- size_t InputLayoutDescSize = 0;
- size_t SampleDescSize = 0;
- size_t ShaderResourceVariableDescSize = 0;
- size_t StaticSamplerDescSize = 0;
- size_t PipelineResourceLayoutDescSize = 0;
- size_t GraphicsPipelineDescSize = 0;
- size_t ComputePipelineDescSize = 0;
- size_t PipelineStateDescSize = 0;
- size_t RasterizerStateDescSize = 0;
- size_t ResourceMappingEntrySize = 0;
- size_t ResourceMappingDescSize = 0;
- size_t SamplerDescSize = 0;
- size_t ShaderDescSize = 0;
- size_t ShaderMacroSize = 0;
- size_t ShaderCreateInfoSize = 0;
- size_t ShaderResourceDescSize = 0;
- size_t DepthStencilClearValueSize = 0;
- size_t OptimizedClearValueSize = 0;
- size_t TextureDescSize = 0;
- size_t TextureSubResDataSize = 0;
- size_t TextureDataSize = 0;
- size_t MappedTextureSubresourceSize = 0;
- size_t TextureViewDescSize = 0;
+ size_t StructSize = 0;
+ int APIVersion = 0;
+ size_t RenderTargetBlendDescSize = 0;
+ size_t BlendStateDescSize = 0;
+ size_t BufferDescSize = 0;
+ size_t BufferDataSize = 0;
+ size_t BufferFormatSize = 0;
+ size_t BufferViewDescSize = 0;
+ size_t StencilOpDescSize = 0;
+ size_t DepthStencilStateDescSize = 0;
+ size_t SamplerCapsSize = 0;
+ size_t TextureCapsSize = 0;
+ size_t DeviceCapsSize = 0;
+ size_t DrawAttribsSize = 0;
+ size_t DispatchComputeAttribsSize = 0;
+ size_t ViewportSize = 0;
+ size_t RectSize = 0;
+ size_t CopyTextureAttribsSize = 0;
+ size_t DeviceObjectAttribsSize = 0;
+ size_t HardwareAdapterAttribsSize = 0;
+ size_t DisplayModeAttribsSize = 0;
+ size_t SwapChainDescSize = 0;
+ size_t FullScreenModeDescSize = 0;
+ size_t EngineCreateInfoSize = 0;
+ size_t EngineGLCreateInfoSize = 0;
+ size_t EngineD3D11CreateInfoSize = 0;
+ size_t EngineD3D12CreateInfoSize = 0;
+ size_t EngineVkCreateInfoSize = 0;
+ size_t EngineMtlCreateInfoSize = 0;
+ size_t BoxSize = 0;
+ size_t TextureFormatAttribsSize = 0;
+ size_t TextureFormatInfoSize = 0;
+ size_t TextureFormatInfoExtSize = 0;
+ size_t StateTransitionDescSize = 0;
+ size_t LayoutElementSize = 0;
+ size_t InputLayoutDescSize = 0;
+ size_t SampleDescSize = 0;
+ size_t ShaderResourceVariableDescSize = 0;
+ size_t StaticSamplerDescSize = 0;
+ size_t PipelineResourceLayoutDescSize = 0;
+ size_t GraphicsPipelineDescSize = 0;
+ size_t ComputePipelineDescSize = 0;
+ size_t PipelineStateDescSize = 0;
+ size_t RasterizerStateDescSize = 0;
+ size_t ResourceMappingEntrySize = 0;
+ size_t ResourceMappingDescSize = 0;
+ size_t SamplerDescSize = 0;
+ size_t ShaderDescSize = 0;
+ size_t ShaderMacroSize = 0;
+ size_t ShaderCreateInfoSize = 0;
+ size_t ShaderResourceDescSize = 0;
+ size_t DepthStencilClearValueSize = 0;
+ size_t OptimizedClearValueSize = 0;
+ size_t TextureDescSize = 0;
+ size_t TextureSubResDataSize = 0;
+ size_t TextureDataSize = 0;
+ size_t MappedTextureSubresourceSize = 0;
+ size_t TextureViewDescSize = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/BlendState.h b/Graphics/GraphicsEngine/interface/BlendState.h
index e6bed6eb..4783a465 100644
--- a/Graphics/GraphicsEngine/interface/BlendState.h
+++ b/Graphics/GraphicsEngine/interface/BlendState.h
@@ -23,6 +23,8 @@
#pragma once
+// clang-format off
+
/// \file
/// Blend state description
@@ -36,7 +38,7 @@ namespace Diligent
/// [D3D11_BLEND]: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476086(v=vs.85).aspx
/// [D3D12_BLEND]: https://msdn.microsoft.com/en-us/library/windows/desktop/dn770338(v=vs.85).aspx
/// [glBlendFuncSeparate]: https://www.opengl.org/wiki/GLAPI/glBlendFuncSeparate
-/// This enumeration defines blend factors for alpha-blending.
+/// This enumeration defines blend factors for alpha-blending.
/// It generatlly mirrors [D3D11_BLEND][] and [D3D12_BLEND][] enumerations and is used by RenderTargetBlendDesc structure
/// to define source and destination blend factors for color and alpha channels.
/// \sa [D3D11_BLEND on MSDN][D3D11_BLEND], [D3D12_BLEND on MSDN][D3D12_BLEND], [glBlendFuncSeparate on OpenGL.org][glBlendFuncSeparate]
@@ -85,7 +87,7 @@ enum BLEND_FACTOR : Int8
/// Direct3D counterpart: D3D11_BLEND_INV_DEST_COLOR/D3D12_BLEND_INV_DEST_COLOR. OpenGL counterpart: GL_ONE_MINUS_DST_COLOR.
BLEND_FACTOR_INV_DEST_COLOR,
- /// The blend factor is (f,f,f,1), where f = min(As, 1-Ad),
+ /// The blend factor is (f,f,f,1), where f = min(As, 1-Ad),
/// As is alpha data from a pixel shader, and Ad is alpha data from a render target.\n
/// Direct3D counterpart: D3D11_BLEND_SRC_ALPHA_SAT/D3D12_BLEND_SRC_ALPHA_SAT. OpenGL counterpart: GL_SRC_ALPHA_SATURATE.
BLEND_FACTOR_SRC_ALPHA_SAT,
@@ -112,26 +114,27 @@ enum BLEND_FACTOR : Int8
/// The blend factor is 1-A, where A is the second alpha data output from a pixel shader.\n
/// Direct3D counterpart: D3D11_BLEND_INV_SRC1_ALPHA/D3D12_BLEND_INV_SRC1_ALPHA. OpenGL counterpart: GL_ONE_MINUS_SRC1_ALPHA.
- BLEND_FACTOR_INV_SRC1_ALPHA,
+ BLEND_FACTOR_INV_SRC1_ALPHA,
/// Helper value that stores the total number of blend factors in the enumeration.
BLEND_FACTOR_NUM_FACTORS
};
+
/// Blending operation
/// [D3D11_BLEND_OP]: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476088(v=vs.85).aspx
/// [D3D12_BLEND_OP]: https://msdn.microsoft.com/en-us/library/windows/desktop/dn770340(v=vs.85).aspx
/// [glBlendEquationSeparate]: https://www.opengl.org/wiki/GLAPI/glBlendEquationSeparate
/// This enumeration describes blending operation for RGB or Alpha channels and generally mirrors
-/// [D3D11_BLEND_OP][] and [D3D12_BLEND_OP][] enums. It is used by RenderTargetBlendDesc structure to define RGB and Alpha
+/// [D3D11_BLEND_OP][] and [D3D12_BLEND_OP][] enums. It is used by RenderTargetBlendDesc structure to define RGB and Alpha
/// blending operations
/// \sa [D3D11_BLEND_OP on MSDN][D3D11_BLEND_OP], [D3D12_BLEND_OP on MSDN][D3D12_BLEND_OP], [glBlendEquationSeparate on OpenGL.org][glBlendEquationSeparate]
enum BLEND_OPERATION : Int8
{
/// Undefined blend operation
BLEND_OPERATION_UNDEFINED = 0,
-
+
/// Add source and destination color components.\n
/// Direct3D counterpart: D3D11_BLEND_OP_ADD/D3D12_BLEND_OP_ADD. OpenGL counterpart: GL_FUNC_ADD.
BLEND_OPERATION_ADD,
@@ -156,33 +159,34 @@ enum BLEND_OPERATION : Int8
BLEND_OPERATION_NUM_OPERATIONS
};
+
/// Color component write flags
-/// These flags are used by RenderTargetBlendDesc structure to define
+/// These flags are used by RenderTargetBlendDesc structure to define
/// writable components of the render target
enum COLOR_MASK : Int8
{
/// Allow data to be stored in the red component.
- COLOR_MASK_RED = 1,
+ COLOR_MASK_RED = 1,
/// Allow data to be stored in the green component.
- COLOR_MASK_GREEN = 2,
+ COLOR_MASK_GREEN = 2,
/// Allow data to be stored in the blue component.
- COLOR_MASK_BLUE = 4,
+ COLOR_MASK_BLUE = 4,
/// Allow data to be stored in the alpha component.
- COLOR_MASK_ALPHA = 8,
+ COLOR_MASK_ALPHA = 8,
/// Allow data to be stored in all components.
- COLOR_MASK_ALL = ( ( ( COLOR_MASK_RED | COLOR_MASK_GREEN ) | COLOR_MASK_BLUE ) | COLOR_MASK_ALPHA )
+ COLOR_MASK_ALL = (((COLOR_MASK_RED | COLOR_MASK_GREEN) | COLOR_MASK_BLUE) | COLOR_MASK_ALPHA)
};
/// Logic operation
/// [D3D12_LOGIC_OP]: https://msdn.microsoft.com/en-us/library/windows/desktop/dn770379(v=vs.85).aspx
-/// This enumeration describes logic operation and generally mirrors [D3D12_LOGIC_OP][] enum.
+/// This enumeration describes logic operation and generally mirrors [D3D12_LOGIC_OP][] enum.
/// It is used by RenderTargetBlendDesc structure to define logic operation.
/// Only available on D3D12 engine
/// \sa [D3D12_LOGIC_OP on MSDN][D3D12_LOGIC_OP]
@@ -256,9 +260,10 @@ enum LOGIC_OPERATION : Int8
LOGIC_OP_NUM_OPERATIONS
};
+
/// Describes a blend state for a single render target
-/// This structure is used by BlendStateDesc to describe
+/// This structure is used by BlendStateDesc to describe
/// blend states for render targets
struct RenderTargetBlendDesc
{
@@ -320,16 +325,16 @@ struct RenderTargetBlendDesc
BLEND_OPERATION _BlendOpAlpha = RenderTargetBlendDesc{}.BlendOpAlpha,
LOGIC_OPERATION _LogicOp = RenderTargetBlendDesc{}.LogicOp,
Uint8 _RenderTargetWriteMask = RenderTargetBlendDesc{}.RenderTargetWriteMask) :
- BlendEnable (_BlendEnable),
- LogicOperationEnable (_LogicOperationEnable),
- SrcBlend (_SrcBlend),
- DestBlend (_DestBlend),
- BlendOp (_BlendOp),
- SrcBlendAlpha (_SrcBlendAlpha),
- DestBlendAlpha (_DestBlendAlpha),
- BlendOpAlpha (_BlendOpAlpha),
- LogicOp (_LogicOp),
- RenderTargetWriteMask(_RenderTargetWriteMask)
+ BlendEnable {_BlendEnable },
+ LogicOperationEnable {_LogicOperationEnable },
+ SrcBlend {_SrcBlend },
+ DestBlend {_DestBlend },
+ BlendOp {_BlendOp },
+ SrcBlendAlpha {_SrcBlendAlpha },
+ DestBlendAlpha {_DestBlendAlpha },
+ BlendOpAlpha {_BlendOpAlpha },
+ LogicOp {_LogicOp },
+ RenderTargetWriteMask{_RenderTargetWriteMask}
{}
/// Comparison operator tests if two structures are equivalent
@@ -353,36 +358,37 @@ struct RenderTargetBlendDesc
}
};
+
/// Blend state description
/// This structure describes the blend state and is part of the GraphicsPipelineDesc.
struct BlendStateDesc
{
- /// Specifies whether to use alpha-to-coverage as a multisampling technique
+ /// Specifies whether to use alpha-to-coverage as a multisampling technique
/// when setting a pixel to a render target. Default value: False.
Bool AlphaToCoverageEnable = False;
- /// Specifies whether to enable independent blending in simultaneous render targets.
+ /// Specifies whether to enable independent blending in simultaneous render targets.
/// If set to False, only RenderTargets[0] is used. Default value: False.
Bool IndependentBlendEnable = False;
/// Constant member defining the maximum number of render targets
static constexpr int MaxRenderTargets = 8;
- /// An array of RenderTargetBlendDesc structures that describe the blend
+ /// An array of RenderTargetBlendDesc structures that describe the blend
/// states for render targets
RenderTargetBlendDesc RenderTargets[MaxRenderTargets];
// We have to explicitly define constructors because otherwise Apple's clang fails to compile the following legitimate code:
// BlendStateDesc{False, False}
- BlendStateDesc()noexcept{}
+ BlendStateDesc() noexcept {}
BlendStateDesc(Bool _AlphaToCoverageEnable,
Bool _IndependentBlendEnable,
- const RenderTargetBlendDesc& RT0 = RenderTargetBlendDesc{})noexcept :
- AlphaToCoverageEnable (_AlphaToCoverageEnable),
- IndependentBlendEnable (_IndependentBlendEnable),
+ const RenderTargetBlendDesc& RT0 = RenderTargetBlendDesc{}) noexcept :
+ AlphaToCoverageEnable {_AlphaToCoverageEnable },
+ IndependentBlendEnable {_IndependentBlendEnable},
RenderTargets {RT0}
{
}
@@ -390,27 +396,29 @@ struct BlendStateDesc
/// Comparison operator tests if two structures are equivalent
/// \param [in] RHS - reference to the structure to perform comparison with
- /// \return
- /// - True if all members are of the two structures equal.
- /// \note The operator performs *bitwise comparison* of the two structures.
- /// That is if for instance both structures have IndependentBlendEnable set to False,
- /// but differ in render target other than 0, the operator will return False
+ /// \return
+ /// - True if all members are of the two structures equal.
+ /// \note The operator performs *bitwise comparison* of the two structures.
+ /// That is if for instance both structures have IndependentBlendEnable set to False,
+ /// but differ in render target other than 0, the operator will return False
/// even though the two blend states created from these structures will be identical.
/// - False otherwise
- bool operator == (const BlendStateDesc& RHS)const
+ bool operator==(const BlendStateDesc& RHS) const
{
bool bRTsEqual = true;
- for( int i = 0; i < MaxRenderTargets; ++i )
- if( !(RenderTargets[i] == RHS.RenderTargets[i]) )
+ for (int i = 0; i < MaxRenderTargets; ++i)
+ {
+ if (!(RenderTargets[i] == RHS.RenderTargets[i]))
{
bRTsEqual = false;
break;
}
+ }
- return bRTsEqual &&
- AlphaToCoverageEnable == RHS.AlphaToCoverageEnable &&
- IndependentBlendEnable== RHS.IndependentBlendEnable;
+ return bRTsEqual &&
+ AlphaToCoverageEnable == RHS.AlphaToCoverageEnable &&
+ IndependentBlendEnable == RHS.IndependentBlendEnable;
}
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/Buffer.h b/Graphics/GraphicsEngine/interface/Buffer.h
index 428ab99a..4c73e913 100644
--- a/Graphics/GraphicsEngine/interface/Buffer.h
+++ b/Graphics/GraphicsEngine/interface/Buffer.h
@@ -23,6 +23,8 @@
#pragma once
+// clang-format off
+
/// \file
/// Defines Diligent::IBuffer interface and related data structures
@@ -33,7 +35,7 @@ namespace Diligent
// {EC47EAD3-A2C4-44F2-81C5-5248D14F10E4}
static constexpr INTERFACE_ID IID_Buffer =
-{ 0xec47ead3, 0xa2c4, 0x44f2, { 0x81, 0xc5, 0x52, 0x48, 0xd1, 0x4f, 0x10, 0xe4 } };
+ {0xec47ead3, 0xa2c4, 0x44f2, {0x81, 0xc5, 0x52, 0x48, 0xd1, 0x4f, 0x10, 0xe4}};
/// Describes the buffer access mode.
@@ -47,7 +49,7 @@ enum BUFFER_MODE : Uint8
/// In this mode, ElementByteStride member of BufferDesc defines the buffer element size.
/// Buffer views can use different formats, but the format size must match ElementByteStride.
BUFFER_MODE_FORMATTED,
-
+
/// Structured buffer.
/// In this mode, ElementByteStride member of BufferDesc defines the structure stride.
BUFFER_MODE_STRUCTURED,
@@ -55,7 +57,7 @@ enum BUFFER_MODE : Uint8
/// Raw buffer.
/// In this mode, the buffer is accessed as raw bytes. Formatted views of a raw
/// buffer can also be created similar to formatted buffer. If formatted views
- /// are to be created, the ElementByteStride member of BufferDesc must specify the
+ /// are to be created, the ElementByteStride member of BufferDesc must specify the
/// size of the format.
BUFFER_MODE_RAW,
@@ -113,12 +115,12 @@ struct BufferDesc : DeviceObjectAttribs
BUFFER_MODE _Mode = BufferDesc{}.Mode,
Uint32 _ElementByteStride = BufferDesc{}.ElementByteStride,
Uint64 _CommandQueueMask = BufferDesc{}.CommandQueueMask)noexcept :
- uiSizeInBytes (_uiSizeInBytes),
- BindFlags (_BindFlags),
- Usage (_Usage),
- Mode (_Mode),
- ElementByteStride (_ElementByteStride),
- CommandQueueMask (_CommandQueueMask)
+ uiSizeInBytes {_uiSizeInBytes },
+ BindFlags {_BindFlags },
+ Usage {_Usage },
+ Mode {_Mode },
+ ElementByteStride {_ElementByteStride},
+ CommandQueueMask {_CommandQueueMask }
{
}
@@ -146,21 +148,21 @@ struct BufferDesc : DeviceObjectAttribs
struct BufferData
{
/// Pointer to the data
- const void* pData = nullptr;
+ const void* pData = nullptr;
/// Data size, in bytes
- Uint32 DataSize = 0;
+ Uint32 DataSize = 0;
// We have to explicitly define constructors because otherwise Apple's clang fails to compile the following legitimate code:
// BufferData{nullptr, 0}
- BufferData()noexcept{}
+ BufferData() noexcept {}
- BufferData(const void* _pData,
- Uint32 _DataSize):
- pData (_pData),
- DataSize(_DataSize)
+ BufferData(const void* _pData,
+ Uint32 _DataSize) :
+ pData {_pData },
+ DataSize{_DataSize}
{}
};
@@ -171,26 +173,26 @@ class IBuffer : public IDeviceObject
{
public:
/// Queries the specific interface, see IObject::QueryInterface() for details
- virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override = 0;
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
/// Returns the buffer description used to create the object
- virtual const BufferDesc& GetDesc()const override = 0;
-
+ virtual const BufferDesc& GetDesc() const override = 0;
+
/// Creates a new buffer view
/// \param [in] ViewDesc - View description. See Diligent::BufferViewDesc for details.
/// \param [out] ppView - Address of the memory location where the pointer to the view interface will be written to.
- ///
+ ///
/// \remarks To create a view addressing the entire buffer, set only BufferViewDesc::ViewType member
/// of the ViewDesc structure and leave all other members in their default values.\n
/// Buffer view will contain strong reference to the buffer, so the buffer will not be destroyed
/// until all views are released.\n
/// The function calls AddRef() for the created interface, so it must be released by
/// a call to Release() when it is no longer needed.
- virtual void CreateView( const struct BufferViewDesc& ViewDesc, class IBufferView** ppView ) = 0;
+ virtual void CreateView(const struct BufferViewDesc& ViewDesc, class IBufferView** ppView) = 0;
/// Returns the pointer to the default view.
-
+
/// \param [in] ViewType - Type of the requested view. See Diligent::BUFFER_VIEW_TYPE.
/// \return Pointer to the interface
///
@@ -199,7 +201,7 @@ public:
///
/// \note The function does not increase the reference counter for the returned interface, so
/// Release() must *NOT* be called.
- virtual IBufferView* GetDefaultView( BUFFER_VIEW_TYPE ViewType ) = 0;
+ virtual IBufferView* GetDefaultView(BUFFER_VIEW_TYPE ViewType) = 0;
/// Returns native buffer handle specific to the underlying graphics API
@@ -221,4 +223,4 @@ public:
virtual RESOURCE_STATE GetState() const = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/BufferView.h b/Graphics/GraphicsEngine/interface/BufferView.h
index 4d26bdc8..54e4b61d 100644
--- a/Graphics/GraphicsEngine/interface/BufferView.h
+++ b/Graphics/GraphicsEngine/interface/BufferView.h
@@ -23,6 +23,8 @@
#pragma once
+// clang-format off
+
/// \file
/// Definition of the Diligent::IBufferView interface and related data structures
@@ -33,7 +35,7 @@ namespace Diligent
// {E2E83490-E9D2-495B-9A83-ABB413A38B07}
static constexpr INTERFACE_ID IID_BufferView =
-{ 0xe2e83490, 0xe9d2, 0x495b, { 0x9a, 0x83, 0xab, 0xb4, 0x13, 0xa3, 0x8b, 0x7 } };
+ {0xe2e83490, 0xe9d2, 0x495b, {0x9a, 0x83, 0xab, 0xb4, 0x13, 0xa3, 0x8b, 0x7}};
/// Buffer format description
struct BufferFormat
@@ -61,9 +63,9 @@ struct BufferFormat
BufferFormat(VALUE_TYPE _ValueType,
Uint8 _NumComponents,
Bool _IsNormalized = BufferFormat{}.IsNormalized)noexcept :
- ValueType (_ValueType),
- NumComponents (_NumComponents),
- IsNormalized (_IsNormalized)
+ ValueType {_ValueType },
+ NumComponents {_NumComponents},
+ IsNormalized {_IsNormalized }
{}
@@ -102,10 +104,10 @@ struct BufferViewDesc : DeviceObjectAttribs
BufferFormat _Format = BufferViewDesc{}.Format,
Uint32 _ByteOffset = BufferViewDesc{}.ByteOffset,
Uint32 _ByteWidth = BufferViewDesc{}.ByteWidth)noexcept :
- ViewType (_ViewType),
- Format (_Format),
- ByteOffset (_ByteOffset),
- ByteWidth (_ByteWidth)
+ ViewType {_ViewType },
+ Format {_Format },
+ ByteOffset {_ByteOffset},
+ ByteWidth {_ByteWidth }
{}
/// Comparison operator tests if two structures are equivalent
@@ -116,7 +118,7 @@ struct BufferViewDesc : DeviceObjectAttribs
/// - False otherwise
/// \remarks
/// The operator ignores DeviceObjectAttribs::Name field.
- bool operator == (const BufferViewDesc& RHS)const
+ bool operator==(const BufferViewDesc& RHS) const
{
// Name is primarily used for debug purposes and does not affect the view.
// It is ignored in comparison operation.
@@ -138,16 +140,16 @@ class IBufferView : public IDeviceObject
{
public:
/// Queries the specific interface, see IObject::QueryInterface() for details
- virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override = 0;
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
/// Returns the buffer view description used to create the object
- virtual const BufferViewDesc& GetDesc()const override = 0;
+ virtual const BufferViewDesc& GetDesc() const override = 0;
/// Returns pointer to the referenced buffer object.
- /// The method does *NOT* call AddRef() on the returned interface,
+ /// The method does *NOT* call AddRef() on the returned interface,
/// so Release() must not be called.
virtual IBuffer* GetBuffer() = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/CommandList.h b/Graphics/GraphicsEngine/interface/CommandList.h
index b940dd22..a4af48d9 100644
--- a/Graphics/GraphicsEngine/interface/CommandList.h
+++ b/Graphics/GraphicsEngine/interface/CommandList.h
@@ -33,7 +33,7 @@ namespace Diligent
// {C38C68F2-8A8C-4ED5-B7EE-69126E75DCD8}
static constexpr INTERFACE_ID IID_CommandList =
-{ 0xc38c68f2, 0x8a8c, 0x4ed5, { 0xb7, 0xee, 0x69, 0x12, 0x6e, 0x75, 0xdc, 0xd8 } };
+ {0xc38c68f2, 0x8a8c, 0x4ed5, {0xb7, 0xee, 0x69, 0x12, 0x6e, 0x75, 0xdc, 0xd8}};
/// Command list interface
@@ -41,9 +41,6 @@ static constexpr INTERFACE_ID IID_CommandList =
/// IDeviceContext::ExecuteCommandList().
class ICommandList : public IDeviceObject
{
-public:
-
-
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/Constants.h b/Graphics/GraphicsEngine/interface/Constants.h
index aa7e63c4..112997e3 100644
--- a/Graphics/GraphicsEngine/interface/Constants.h
+++ b/Graphics/GraphicsEngine/interface/Constants.h
@@ -30,16 +30,21 @@
namespace Diligent
{
- /// Maximum number of input buffer slots.
- /// D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT == 32
- static constexpr Uint32 MaxBufferSlots = 32;
+// clang-format off
- /// Maximum number of simultaneous render targets.
- static constexpr Uint32 MaxRenderTargets = 8;
+/// Maximum number of input buffer slots.
+/// D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT == 32
+static constexpr Uint32 MaxBufferSlots = 32;
- /// Maximum number of viewports.
- static constexpr Uint32 MaxViewports = 16;
+/// Maximum number of simultaneous render targets.
+static constexpr Uint32 MaxRenderTargets = 8;
- /// Maximum number of shader stages in a pipeline.
- static constexpr Uint32 MaxShadersInPipeline = 5;
-}
+/// Maximum number of viewports.
+static constexpr Uint32 MaxViewports = 16;
+
+/// Maximum number of shader stages in a pipeline.
+static constexpr Uint32 MaxShadersInPipeline = 5;
+
+// clang-format on
+
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/DepthStencilState.h b/Graphics/GraphicsEngine/interface/DepthStencilState.h
index 6392ace8..2a5ddfa8 100644
--- a/Graphics/GraphicsEngine/interface/DepthStencilState.h
+++ b/Graphics/GraphicsEngine/interface/DepthStencilState.h
@@ -23,6 +23,8 @@
#pragma once
+// clang-format off
+
/// \file
/// Definition of data types that describe depth-stencil state
@@ -117,10 +119,10 @@ struct StencilOpDesc
STENCIL_OP _StencilDepthFailOp,
STENCIL_OP _StencilPassOp,
COMPARISON_FUNCTION _StencilFunc)noexcept :
- StencilFailOp (_StencilFailOp),
- StencilDepthFailOp (_StencilDepthFailOp),
- StencilPassOp (_StencilPassOp),
- StencilFunc (_StencilFunc)
+ StencilFailOp {_StencilFailOp },
+ StencilDepthFailOp {_StencilDepthFailOp},
+ StencilPassOp {_StencilPassOp },
+ StencilFunc {_StencilFunc }
{}
/// Tests if two structures are equivalent
@@ -129,7 +131,7 @@ struct StencilOpDesc
/// \return
/// - True if all members of the two structures are equal.
/// - False otherwise
- bool operator == (const StencilOpDesc& rhs)const
+ bool operator== (const StencilOpDesc& rhs) const
{
return StencilFailOp == rhs.StencilFailOp &&
StencilDepthFailOp == rhs.StencilDepthFailOp &&
@@ -191,14 +193,14 @@ struct DepthStencilStateDesc
Uint8 _StencilWriteMask = DepthStencilStateDesc{}.StencilWriteMask,
StencilOpDesc _FrontFace = StencilOpDesc{},
StencilOpDesc _BackFace = StencilOpDesc{})noexcept :
- DepthEnable (_DepthEnable),
- DepthWriteEnable(_DepthWriteEnable),
- DepthFunc (_DepthFunc),
- StencilEnable (_StencilEnable),
- StencilReadMask (_StencilReadMask),
- StencilWriteMask(_StencilWriteMask),
- FrontFace (_FrontFace),
- BackFace (_BackFace)
+ DepthEnable {_DepthEnable },
+ DepthWriteEnable{_DepthWriteEnable},
+ DepthFunc {_DepthFunc },
+ StencilEnable {_StencilEnable },
+ StencilReadMask {_StencilReadMask },
+ StencilWriteMask{_StencilWriteMask},
+ FrontFace {_FrontFace },
+ BackFace {_BackFace }
{}
/// Tests if two structures are equivalent
@@ -207,7 +209,7 @@ struct DepthStencilStateDesc
/// \return
/// - True if all members of the two structures are equal.
/// - False otherwise
- bool operator == (const DepthStencilStateDesc& rhs)const
+ bool operator== (const DepthStencilStateDesc& rhs) const
{
return DepthEnable == rhs.DepthEnable &&
DepthWriteEnable == rhs.DepthWriteEnable &&
diff --git a/Graphics/GraphicsEngine/interface/DeviceCaps.h b/Graphics/GraphicsEngine/interface/DeviceCaps.h
index 26914169..1d26afdd 100644
--- a/Graphics/GraphicsEngine/interface/DeviceCaps.h
+++ b/Graphics/GraphicsEngine/interface/DeviceCaps.h
@@ -23,6 +23,8 @@
#pragma once
+// clang-format off
+
/// \file
/// Definition of the device capabilities
diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h
index f631482f..f515ab84 100644
--- a/Graphics/GraphicsEngine/interface/DeviceContext.h
+++ b/Graphics/GraphicsEngine/interface/DeviceContext.h
@@ -23,6 +23,8 @@
#pragma once
+// clang-format off
+
/// \file
/// Definition of the Diligent::IDeviceContext interface and related data structures
@@ -50,7 +52,7 @@ namespace Diligent
// {DC92711B-A1BE-4319-B2BD-C662D1CC19E4}
static constexpr INTERFACE_ID IID_DeviceContext =
-{ 0xdc92711b, 0xa1be, 0x4319, { 0xb2, 0xbd, 0xc6, 0x62, 0xd1, 0xcc, 0x19, 0xe4 } };
+ {0xdc92711b, 0xa1be, 0x4319, {0xb2, 0xbd, 0xc6, 0x62, 0xd1, 0xcc, 0x19, 0xe4}};
/// Draw command flags
enum DRAW_FLAGS : Uint8
@@ -476,12 +478,12 @@ struct Viewport
Viewport(Float32 _TopLeftX, Float32 _TopLeftY,
Float32 _Width, Float32 _Height,
Float32 _MinDepth = 0, Float32 _MaxDepth = 1)noexcept :
- TopLeftX (_TopLeftX),
- TopLeftY (_TopLeftY),
- Width (_Width ),
- Height (_Height ),
- MinDepth (_MinDepth),
- MaxDepth (_MaxDepth)
+ TopLeftX {_TopLeftX},
+ TopLeftY {_TopLeftY},
+ Width {_Width },
+ Height {_Height },
+ MinDepth {_MinDepth},
+ MaxDepth {_MaxDepth}
{}
Viewport()noexcept{}
@@ -503,10 +505,10 @@ struct Rect
/// Initializes the structure
Rect(Int32 _left, Int32 _top, Int32 _right, Int32 _bottom)noexcept :
- left ( _left ),
- top ( _top ),
- right ( _right ),
- bottom( _bottom )
+ left {_left },
+ top {_top },
+ right {_right },
+ bottom {_bottom}
{}
Rect()noexcept{}
@@ -565,10 +567,10 @@ struct CopyTextureAttribs
RESOURCE_STATE_TRANSITION_MODE _SrcTextureTransitionMode,
ITexture* _pDstTexture,
RESOURCE_STATE_TRANSITION_MODE _DstTextureTransitionMode)noexcept :
- pSrcTexture (_pSrcTexture),
- SrcTextureTransitionMode(_SrcTextureTransitionMode),
- pDstTexture (_pDstTexture),
- DstTextureTransitionMode(_DstTextureTransitionMode)
+ pSrcTexture {_pSrcTexture },
+ SrcTextureTransitionMode{_SrcTextureTransitionMode},
+ pDstTexture {_pDstTexture },
+ DstTextureTransitionMode{_DstTextureTransitionMode}
{}
};
@@ -1056,7 +1058,7 @@ public:
/// \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 MapBuffer( IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData ) = 0;
+ virtual void MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData) = 0;
/// Unmaps the previously mapped buffer.
@@ -1064,7 +1066,7 @@ public:
/// \param [in] pBuffer - Pointer to the buffer to unmap.
/// \param [in] MapType - Type of the map operation. This parameter must match the type that was
/// provided to the Map() method.
- virtual void UnmapBuffer( IBuffer* pBuffer, MAP_TYPE MapType ) = 0;
+ virtual void UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType) = 0;
/// Updates the data in the texture.
@@ -1107,13 +1109,13 @@ public:
/// 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,
- MAP_FLAGS MapFlags,
- const Box* pMapRegion,
- MappedTextureSubresource& MappedData ) = 0;
+ virtual void MapTextureSubresource(ITexture* pTexture,
+ Uint32 MipLevel,
+ Uint32 ArraySlice,
+ MAP_TYPE MapType,
+ MAP_FLAGS MapFlags,
+ const Box* pMapRegion,
+ MappedTextureSubresource& MappedData) = 0;
/// Unmaps the texture subresource.
diff --git a/Graphics/GraphicsEngine/interface/DeviceObject.h b/Graphics/GraphicsEngine/interface/DeviceObject.h
index 1d175cf5..1d080017 100644
--- a/Graphics/GraphicsEngine/interface/DeviceObject.h
+++ b/Graphics/GraphicsEngine/interface/DeviceObject.h
@@ -34,18 +34,18 @@ namespace Diligent
// {5B4CCA0B-5075-4230-9759-F48769EE5502}
static constexpr INTERFACE_ID IID_DeviceObject =
-{ 0x5b4cca0b, 0x5075, 0x4230, { 0x97, 0x59, 0xf4, 0x87, 0x69, 0xee, 0x55, 0x2 } };
+ {0x5b4cca0b, 0x5075, 0x4230, {0x97, 0x59, 0xf4, 0x87, 0x69, 0xee, 0x55, 0x2}};
/// Base interface for all objects created by the render device Diligent::IRenderDevice
class IDeviceObject : public IObject
{
public:
/// Queries the specific interface, see IObject::QueryInterface() for details
- virtual void QueryInterface( const INTERFACE_ID& IID, IObject** ppInterface )override = 0;
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
/// Returns the object description
- virtual const DeviceObjectAttribs& GetDesc()const = 0;
+ virtual const DeviceObjectAttribs& GetDesc() const = 0;
/// Returns unique identifier assigned to an object
@@ -67,4 +67,4 @@ public:
virtual Int32 GetUniqueID() const = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/EngineFactory.h b/Graphics/GraphicsEngine/interface/EngineFactory.h
index b8ae3a03..6bb79e71 100644
--- a/Graphics/GraphicsEngine/interface/EngineFactory.h
+++ b/Graphics/GraphicsEngine/interface/EngineFactory.h
@@ -36,7 +36,7 @@ class IShaderSourceInputStreamFactory;
// {D932B052-4ED6-4729-A532-F31DEEC100F3}
static constexpr INTERFACE_ID IID_EngineFactory =
-{ 0xd932b052, 0x4ed6, 0x4729, { 0xa5, 0x32, 0xf3, 0x1d, 0xee, 0xc1, 0x0, 0xf3 } };
+ {0xd932b052, 0x4ed6, 0x4729, {0xa5, 0x32, 0xf3, 0x1d, 0xee, 0xc1, 0x0, 0xf3}};
/// Engine factory base interface
@@ -49,8 +49,8 @@ public:
/// Creates default shader source input stream factory
/// \param [in] SearchDirectories - Semicolon-seprated list of search directories.
/// \param [out] ppShaderSourceStreamFactory - Memory address where pointer to the shader source stream factory will be written.
- virtual void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories,
- IShaderSourceInputStreamFactory** ppShaderSourceFactory)const = 0;
+ virtual void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories,
+ IShaderSourceInputStreamFactory** ppShaderSourceFactory) const = 0;
#if PLATFORM_ANDROID
/// On Android platform, it is necessary to initialize the file system before
@@ -61,4 +61,4 @@ public:
#endif
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/Fence.h b/Graphics/GraphicsEngine/interface/Fence.h
index 5e9fab85..6006e6ba 100644
--- a/Graphics/GraphicsEngine/interface/Fence.h
+++ b/Graphics/GraphicsEngine/interface/Fence.h
@@ -33,12 +33,11 @@ namespace Diligent
// {3B19184D-32AB-4701-84F4-9A0C03AE1672}
static constexpr INTERFACE_ID IID_Fence =
-{ 0x3b19184d, 0x32ab, 0x4701, { 0x84, 0xf4, 0x9a, 0xc, 0x3, 0xae, 0x16, 0x72 } };
+ {0x3b19184d, 0x32ab, 0x4701, {0x84, 0xf4, 0x9a, 0xc, 0x3, 0xae, 0x16, 0x72}};
/// Buffer description
struct FenceDesc : DeviceObjectAttribs
{
-
};
/// Fence interface
@@ -51,10 +50,10 @@ class IFence : public IDeviceObject
{
public:
/// Queries the specific interface, see IObject::QueryInterface() for details
- virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override = 0;
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
/// Returns the fence description used to create the object
- virtual const FenceDesc& GetDesc()const override = 0;
+ virtual const FenceDesc& GetDesc() const override = 0;
/// Returns the last completed value signaled by the GPU
@@ -63,8 +62,8 @@ public:
/// IDeviceContext::SignalFence().
virtual Uint64 GetCompletedValue() = 0;
- /// Resets the fence to the specified value.
+ /// Resets the fence to the specified value.
virtual void Reset(Uint64 Value) = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h
index 449f2b84..da4152c4 100644
--- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h
+++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h
@@ -23,6 +23,8 @@
#pragma once
+// clang-format off
+
/// \file
/// Contains basic graphics engine type defintions
@@ -1079,7 +1081,7 @@ namespace Diligent
DeviceObjectAttribs()noexcept{}
explicit DeviceObjectAttribs(const Char* _Name) :
- Name(_Name)
+ Name{_Name}
{}
};
@@ -1235,14 +1237,14 @@ namespace Diligent
Float32 _DefaultDepthValue = SwapChainDesc{}.DefaultDepthValue,
Uint8 _DefaultStencilValue = SwapChainDesc{}.DefaultStencilValue,
bool _IsPrimary = SwapChainDesc{}.IsPrimary) :
- Width (_Width),
- Height (_Height),
- ColorBufferFormat (_ColorBufferFormat),
- DepthBufferFormat (_DepthBufferFormat),
- BufferCount (_BufferCount),
- DefaultDepthValue (_DefaultDepthValue),
- DefaultStencilValue (_DefaultStencilValue),
- IsPrimary (_IsPrimary)
+ Width {_Width },
+ Height {_Height },
+ ColorBufferFormat {_ColorBufferFormat },
+ DepthBufferFormat {_DepthBufferFormat },
+ BufferCount {_BufferCount },
+ DefaultDepthValue {_DefaultDepthValue },
+ DefaultStencilValue {_DefaultStencilValue},
+ IsPrimary {_IsPrimary }
{}
};
@@ -1507,15 +1509,15 @@ namespace Diligent
Uint32 _NumStorageBufferDescriptors,
Uint32 _NumUniformTexelBufferDescriptors,
Uint32 _NumStorageTexelBufferDescriptors)noexcept :
- MaxDescriptorSets (_MaxDescriptorSets ),
- NumSeparateSamplerDescriptors (_NumSeparateSamplerDescriptors ),
- NumCombinedSamplerDescriptors (_NumCombinedSamplerDescriptors ),
- NumSampledImageDescriptors (_NumSampledImageDescriptors ),
- NumStorageImageDescriptors (_NumStorageImageDescriptors ),
- NumUniformBufferDescriptors (_NumUniformBufferDescriptors ),
- NumStorageBufferDescriptors (_NumStorageBufferDescriptors ),
- NumUniformTexelBufferDescriptors(_NumUniformTexelBufferDescriptors),
- NumStorageTexelBufferDescriptors(_NumStorageTexelBufferDescriptors)
+ MaxDescriptorSets {_MaxDescriptorSets },
+ NumSeparateSamplerDescriptors {_NumSeparateSamplerDescriptors },
+ NumCombinedSamplerDescriptors {_NumCombinedSamplerDescriptors },
+ NumSampledImageDescriptors {_NumSampledImageDescriptors },
+ NumStorageImageDescriptors {_NumStorageImageDescriptors },
+ NumUniformBufferDescriptors {_NumUniformBufferDescriptors },
+ NumStorageBufferDescriptors {_NumStorageBufferDescriptors },
+ NumUniformTexelBufferDescriptors{_NumUniformTexelBufferDescriptors},
+ NumStorageTexelBufferDescriptors{_NumStorageTexelBufferDescriptors}
{
// On clang aggregate initialization fails to compile if
// structure members have default initializers
@@ -1570,7 +1572,6 @@ namespace Diligent
/// Attributes of the Metal-based engine implementation
struct EngineMtlCreateInfo : public EngineCreateInfo
{
-
};
@@ -1587,18 +1588,21 @@ namespace Diligent
Box(Uint32 _MinX, Uint32 _MaxX,
Uint32 _MinY, Uint32 _MaxY,
Uint32 _MinZ, Uint32 _MaxZ) :
- MinX(_MinX), MaxX(_MaxX),
- MinY(_MinY), MaxY(_MaxY),
- MinZ(_MinZ), MaxZ(_MaxZ)
+ MinX {_MinX},
+ MaxX {_MaxX},
+ MinY {_MinY},
+ MaxY {_MaxY},
+ MinZ {_MinZ},
+ MaxZ {_MaxZ}
{}
Box(Uint32 _MinX, Uint32 _MaxX,
Uint32 _MinY, Uint32 _MaxY) :
- Box(_MinX, _MaxX, _MinY, _MaxY, 0, 1)
+ Box{_MinX, _MaxX, _MinY, _MaxY, 0, 1}
{}
Box(Uint32 _MinX, Uint32 _MaxX) :
- Box(_MinX, _MaxX, 0, 0, 0, 1)
+ Box{_MinX, _MaxX, 0, 0, 0, 1}
{}
Box(){}
@@ -1649,29 +1653,29 @@ namespace Diligent
{
/// Literal texture format name (for instance, for TEX_FORMAT_RGBA8_UNORM format, this
/// will be "TEX_FORMAT_RGBA8_UNORM")
- const Char* Name;
+ const Char* Name = "TEX_FORMAT_UNKNOWN";
/// Texture format, see Diligent::TEXTURE_FORMAT for a list of supported texture formats
- TEXTURE_FORMAT Format;
+ TEXTURE_FORMAT Format = TEX_FORMAT_UNKNOWN;
/// Size of one component in bytes (for instance, for TEX_FORMAT_RGBA8_UNORM format, this will be 1)
/// For compressed formats, this is the block size in bytes (for TEX_FORMAT_BC1_UNORM format, this will be 8)
- Uint8 ComponentSize;
+ Uint8 ComponentSize = 0;
/// Number of components
- Uint8 NumComponents;
+ Uint8 NumComponents = 0;
/// Component type, see Diligent::COMPONENT_TYPE for details.
- COMPONENT_TYPE ComponentType;
+ COMPONENT_TYPE ComponentType = COMPONENT_TYPE_UNDEFINED;
/// Bool flag indicating if the format is a typeless format
- bool IsTypeless;
+ bool IsTypeless = false;
/// For block-compressed formats, compression block width
- Uint8 BlockWidth;
+ Uint8 BlockWidth = 0;
/// For block-compressed formats, compression block height
- Uint8 BlockHeight;
+ Uint8 BlockHeight = 0;
/// For non-compressed formats, returns the texel size.
/// For block-compressed formats, returns the block size.
@@ -1689,27 +1693,18 @@ namespace Diligent
bool _IsTypeless,
Uint8 _BlockWidth,
Uint8 _BlockHeight)noexcept :
- Name (_Name),
- Format (_Format),
- ComponentSize(_ComponentSize),
- NumComponents(_NumComponents),
- ComponentType(_ComponentType),
- IsTypeless (_IsTypeless),
- BlockWidth (_BlockWidth),
- BlockHeight (_BlockHeight)
+ Name {_Name },
+ Format {_Format },
+ ComponentSize{_ComponentSize},
+ NumComponents{_NumComponents},
+ ComponentType{_ComponentType},
+ IsTypeless {_IsTypeless },
+ BlockWidth {_BlockWidth },
+ BlockHeight {_BlockHeight }
{
}
- TextureFormatAttribs()noexcept :
- Name ("TEX_FORMAT_UNKNOWN"),
- Format (TEX_FORMAT_UNKNOWN),
- ComponentSize(0),
- NumComponents(0),
- ComponentType(COMPONENT_TYPE_UNDEFINED),
- IsTypeless (false),
- BlockWidth (0),
- BlockHeight (0)
- {}
+ TextureFormatAttribs()noexcept {}
};
/// Basic texture format description
@@ -1893,32 +1888,43 @@ namespace Diligent
Uint32 _ArraySliceCount = RemainingArraySlices,
STATE_TRANSITION_TYPE _TransitionType = STATE_TRANSITION_TYPE_IMMEDIATE,
bool _UpdateState = false)noexcept :
- pTexture (_pTexture),
- FirstMipLevel (_FirstMipLevel),
- MipLevelsCount (_MipLevelsCount),
- FirstArraySlice (_FirstArraySlice),
- ArraySliceCount (_ArraySliceCount),
- OldState (_OldState),
- NewState (_NewState),
- TransitionType (_TransitionType),
- UpdateResourceState (_UpdateState)
+ pTexture {_pTexture },
+ FirstMipLevel {_FirstMipLevel },
+ MipLevelsCount {_MipLevelsCount },
+ FirstArraySlice {_FirstArraySlice},
+ ArraySliceCount {_ArraySliceCount},
+ OldState {_OldState },
+ NewState {_NewState },
+ TransitionType {_TransitionType },
+ UpdateResourceState {_UpdateState }
{}
StateTransitionDesc(ITexture* _pTexture,
RESOURCE_STATE _OldState,
RESOURCE_STATE _NewState,
bool _UpdateState)noexcept :
- StateTransitionDesc(_pTexture, _OldState, _NewState, 0, RemainingMipLevels, 0, RemainingArraySlices, STATE_TRANSITION_TYPE_IMMEDIATE, _UpdateState)
+ StateTransitionDesc
+ {
+ _pTexture,
+ _OldState,
+ _NewState,
+ 0,
+ RemainingMipLevels,
+ 0,
+ RemainingArraySlices,
+ STATE_TRANSITION_TYPE_IMMEDIATE,
+ _UpdateState
+ }
{}
StateTransitionDesc(IBuffer* _pBuffer,
RESOURCE_STATE _OldState,
RESOURCE_STATE _NewState,
bool _UpdateState)noexcept :
- pBuffer (_pBuffer),
- OldState (_OldState),
- NewState (_NewState),
- UpdateResourceState (_UpdateState)
+ pBuffer {_pBuffer },
+ OldState {_OldState },
+ NewState {_NewState },
+ UpdateResourceState {_UpdateState}
{}
};
}
diff --git a/Graphics/GraphicsEngine/interface/InputLayout.h b/Graphics/GraphicsEngine/interface/InputLayout.h
index 82bcb985..f8b0737d 100644
--- a/Graphics/GraphicsEngine/interface/InputLayout.h
+++ b/Graphics/GraphicsEngine/interface/InputLayout.h
@@ -23,6 +23,8 @@
#pragma once
+// clang-format off
+
/// \file
/// Definition input layout
diff --git a/Graphics/GraphicsEngine/interface/MapHelper.h b/Graphics/GraphicsEngine/interface/MapHelper.h
index c6686b0b..7728c1a3 100644
--- a/Graphics/GraphicsEngine/interface/MapHelper.h
+++ b/Graphics/GraphicsEngine/interface/MapHelper.h
@@ -46,57 +46,62 @@ namespace Diligent
/// MapHelper<float> UniformData( pDeviceContext, pUniformBuff, MAP_WRITE, MAP_FLAG_DISCARD );
/// UniformData[0] = UniformData[1] = UniformData[2] = UniformData[3] = 1;
/// }
-template<typename DataType, bool KeepStrongReferences = false>
+template <typename DataType, bool KeepStrongReferences = false>
class MapHelper
{
public:
-
/// Initializes the class member with null values
+ // clang-format off
MapHelper() :
- m_pBuffer (nullptr),
- m_pContext (nullptr),
- m_pMappedData (nullptr),
- m_MapType (static_cast<MAP_TYPE>(-1)),
- m_MapFlags (static_cast<Uint32>(-1))
+ m_pBuffer {nullptr},
+ m_pContext {nullptr},
+ m_pMappedData {nullptr},
+ m_MapType {static_cast<MAP_TYPE>(-1)},
+ m_MapFlags {static_cast<Uint32>(-1) }
+ // clang-format on
{
}
/// Initializes the object and maps the provided resource.
/// See Map() for details.
- MapHelper( IDeviceContext* pContext, IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags ) :
+ MapHelper(IDeviceContext* pContext, IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags) :
MapHelper()
{
Map(pContext, pBuffer, MapType, MapFlags);
}
/// Move constructor: takes over resource ownership from Helper
+ // clang-format off
MapHelper(MapHelper&& Helper) :
- m_pBuffer (std::move(Helper.m_pBuffer)),
- m_pMappedData (std::move(Helper.m_pMappedData)),
- m_pContext (std::move(Helper.m_pContext)),
- m_MapType (std::move(Helper.m_MapType)),
- m_MapFlags (std::move(Helper.m_MapFlags))
+ m_pBuffer {std::move(Helper.m_pBuffer) },
+ m_pMappedData {std::move(Helper.m_pMappedData)},
+ m_pContext {std::move(Helper.m_pContext) },
+ m_MapType {std::move(Helper.m_MapType) },
+ m_MapFlags {std::move(Helper.m_MapFlags) }
+ // clang-format on
{
- Helper.m_pBuffer = nullptr;
- Helper.m_pContext = nullptr;
- Helper.m_pMappedData = nullptr;
- Helper.m_MapType = static_cast<MAP_TYPE>(-1);
- Helper.m_MapFlags = static_cast<Uint32>(-1);
+ Helper.m_pBuffer = nullptr;
+ Helper.m_pContext = nullptr;
+ Helper.m_pMappedData = nullptr;
+ Helper.m_MapType = static_cast<MAP_TYPE>(-1);
+ Helper.m_MapFlags = static_cast<Uint32>(-1);
}
/// Move-assignement operator: takes over resource ownership from Helper
- MapHelper& operator = (MapHelper&& Helper)
+ MapHelper& operator=(MapHelper&& Helper)
{
- m_pBuffer = std::move(Helper.m_pBuffer);
- m_pMappedData = std::move(Helper.m_pMappedData);
- m_pContext = std::move( Helper.m_pContext );
- m_MapType = std::move(Helper.m_MapType);
- m_MapFlags = std::move(Helper.m_MapFlags);
- Helper.m_pBuffer = nullptr;
- Helper.m_pContext = nullptr;
- Helper.m_pMappedData = nullptr;
- Helper.m_MapType = static_cast<MAP_TYPE>(-1);
- Helper.m_MapFlags = static_cast<Uint32>(-1);
+ m_pBuffer = std::move(Helper.m_pBuffer);
+ m_pMappedData = std::move(Helper.m_pMappedData);
+ m_pContext = std::move(Helper.m_pContext);
+ m_MapType = std::move(Helper.m_MapType);
+ m_MapFlags = std::move(Helper.m_MapFlags);
+
+ Helper.m_pBuffer = nullptr;
+ Helper.m_pContext = nullptr;
+ Helper.m_pMappedData = nullptr;
+ Helper.m_MapType = static_cast<MAP_TYPE>(-1);
+ Helper.m_MapFlags = static_cast<Uint32>(-1);
+
return *this;
}
@@ -106,20 +111,20 @@ public:
/// \param pBuffer - Pointer to the buffer interface to map.
/// \param MapType - Type of the map operation, see Diligent::MAP_TYPE for details.
/// \param MapFlags - Additional map flags, see Diligent::MAP_FLAGS.
- void Map( IDeviceContext* pContext, IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags )
+ void Map(IDeviceContext* pContext, IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags)
{
VERIFY(!m_pBuffer && !m_pMappedData && !m_pContext, "Object already mapped");
Unmap();
#ifdef _DEBUG
- auto &BuffDesc = pBuffer->GetDesc();
+ auto& BuffDesc = pBuffer->GetDesc();
VERIFY(sizeof(DataType) <= BuffDesc.uiSizeInBytes, "Data type size exceeds buffer size");
#endif
pContext->MapBuffer(pBuffer, MapType, MapFlags, (PVoid&)m_pMappedData);
- if(m_pMappedData != nullptr)
+ if (m_pMappedData != nullptr)
{
m_pContext = pContext;
- m_pBuffer = pBuffer;
- m_MapType = MapType;
+ m_pBuffer = pBuffer;
+ m_MapType = MapType;
m_MapFlags = MapFlags;
}
}
@@ -127,28 +132,28 @@ public:
/// Unamps the resource and resets the object state to default.
void Unmap()
{
- if( m_pBuffer )
+ if (m_pBuffer)
{
m_pContext->UnmapBuffer(m_pBuffer, m_MapType);
- m_pBuffer = nullptr;
- m_MapType = static_cast<MAP_TYPE>(-1);
- m_MapFlags = static_cast<Uint32>(-1);
+ m_pBuffer = nullptr;
+ m_MapType = static_cast<MAP_TYPE>(-1);
+ m_MapFlags = static_cast<Uint32>(-1);
}
- m_pContext = nullptr;
- m_pMappedData = nullptr;
+ m_pContext = nullptr;
+ m_pMappedData = nullptr;
}
-
+
/// Converts mapped data pointer to DataType*
- operator DataType* (){return m_pMappedData;}
+ operator DataType*() { return m_pMappedData; }
/// Converts mapped data pointer to const DataType*
- operator const DataType* ()const{return m_pMappedData;}
+ operator const DataType*() const { return m_pMappedData; }
/// Operator ->
- DataType* operator->() {return m_pMappedData;}
+ DataType* operator->() { return m_pMappedData; }
/// Operator const ->
- const DataType* operator->() const{return m_pMappedData;}
+ const DataType* operator->() const { return m_pMappedData; }
/// Unamps the resource
~MapHelper()
@@ -160,16 +165,17 @@ private:
MapHelper(const MapHelper&);
MapHelper& operator=(const MapHelper&);
- template<typename PtrType, bool UseStrongReference>
- struct PtrTypeSelector{};
+ template <typename PtrType, bool UseStrongReference>
+ struct PtrTypeSelector
+ {};
- template<typename PtrType>
+ template <typename PtrType>
struct PtrTypeSelector<PtrType, true>
{
typedef RefCntAutoPtr<PtrType> Type;
};
- template<typename PtrType>
+ template <typename PtrType>
struct PtrTypeSelector<PtrType, false>
{
typedef PtrType* Type;
@@ -189,4 +195,4 @@ private:
Uint32 m_MapFlags;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/PipelineState.h b/Graphics/GraphicsEngine/interface/PipelineState.h
index dbe907b7..1410c067 100644
--- a/Graphics/GraphicsEngine/interface/PipelineState.h
+++ b/Graphics/GraphicsEngine/interface/PipelineState.h
@@ -23,6 +23,8 @@
#pragma once
+// clang-format off
+
/// \file
/// Definition of the Diligent::IRenderDevice interface and related data structures
@@ -55,8 +57,8 @@ struct SampleDesc
SampleDesc()noexcept{}
SampleDesc(Uint8 _Count, Uint8 _Quality) noexcept :
- Count (_Count),
- Quality (_Quality)
+ Count {_Count },
+ Quality {_Quality}
{}
};
@@ -76,9 +78,9 @@ struct ShaderResourceVariableDesc
ShaderResourceVariableDesc()noexcept{}
ShaderResourceVariableDesc(SHADER_TYPE _ShaderStages, const Char* _Name, SHADER_RESOURCE_VARIABLE_TYPE _Type)noexcept :
- ShaderStages(_ShaderStages),
- Name (_Name),
- Type (_Type)
+ ShaderStages{_ShaderStages},
+ Name {_Name },
+ Type {_Type }
{}
};
@@ -101,9 +103,9 @@ struct StaticSamplerDesc
StaticSamplerDesc(SHADER_TYPE _ShaderStages,
const Char* _SamplerOrTextureName,
const SamplerDesc& _Desc)noexcept :
- ShaderStages (_ShaderStages),
- SamplerOrTextureName(_SamplerOrTextureName),
- Desc (_Desc)
+ ShaderStages {_ShaderStages },
+ SamplerOrTextureName{_SamplerOrTextureName},
+ Desc {_Desc }
{}
};
@@ -233,11 +235,9 @@ struct PipelineStateDesc : DeviceObjectAttribs
// {06084AE5-6A71-4FE8-84B9-395DD489A28C}
static constexpr INTERFACE_ID IID_PipelineState =
-{ 0x6084ae5, 0x6a71, 0x4fe8, { 0x84, 0xb9, 0x39, 0x5d, 0xd4, 0x89, 0xa2, 0x8c } };
+ {0x6084ae5, 0x6a71, 0x4fe8, {0x84, 0xb9, 0x39, 0x5d, 0xd4, 0x89, 0xa2, 0x8c}};
-/**
- * Pipeline state interface
- */
+/// Pipeline state interface
class IPipelineState : public IDeviceObject
{
public:
diff --git a/Graphics/GraphicsEngine/interface/RasterizerState.h b/Graphics/GraphicsEngine/interface/RasterizerState.h
index 295326ab..80fc20b8 100644
--- a/Graphics/GraphicsEngine/interface/RasterizerState.h
+++ b/Graphics/GraphicsEngine/interface/RasterizerState.h
@@ -23,6 +23,8 @@
#pragma once
+// clang-format off
+
/// \file
/// Rasterizer state description
@@ -143,15 +145,15 @@ struct RasterizerStateDesc
Int32 _DepthBias = RasterizerStateDesc{}.DepthBias,
Float32 _DepthBiasClamp = RasterizerStateDesc{}.DepthBiasClamp,
Float32 _SlopeScaledDepthBias = RasterizerStateDesc{}.SlopeScaledDepthBias)noexcept :
- FillMode ( _FillMode ),
- CullMode ( _CullMode ),
- FrontCounterClockwise( _FrontCounterClockwise ),
- DepthClipEnable ( _DepthClipEnable ),
- ScissorEnable ( _ScissorEnable ),
- AntialiasedLineEnable( _AntialiasedLineEnable ),
- DepthBias ( _DepthBias ),
- DepthBiasClamp ( _DepthBiasClamp ),
- SlopeScaledDepthBias ( _SlopeScaledDepthBias )
+ FillMode {_FillMode },
+ CullMode {_CullMode },
+ FrontCounterClockwise {_FrontCounterClockwise},
+ DepthClipEnable {_DepthClipEnable },
+ ScissorEnable {_ScissorEnable },
+ AntialiasedLineEnable {_AntialiasedLineEnable},
+ DepthBias {_DepthBias },
+ DepthBiasClamp {_DepthBiasClamp },
+ SlopeScaledDepthBias {_SlopeScaledDepthBias }
{
}
diff --git a/Graphics/GraphicsEngine/interface/RenderDevice.h b/Graphics/GraphicsEngine/interface/RenderDevice.h
index fd790607..c17e5987 100644
--- a/Graphics/GraphicsEngine/interface/RenderDevice.h
+++ b/Graphics/GraphicsEngine/interface/RenderDevice.h
@@ -51,14 +51,14 @@ namespace Diligent
// {F0E9B607-AE33-4B2B-B1AF-A8B2C3104022}
static constexpr INTERFACE_ID IID_RenderDevice =
-{ 0xf0e9b607, 0xae33, 0x4b2b, { 0xb1, 0xaf, 0xa8, 0xb2, 0xc3, 0x10, 0x40, 0x22 } };
+ {0xf0e9b607, 0xae33, 0x4b2b, {0xb1, 0xaf, 0xa8, 0xb2, 0xc3, 0x10, 0x40, 0x22}};
/// Render device interface
class IRenderDevice : public IObject
{
public:
/// Queries the specific interface, see IObject::QueryInterface() for details
- virtual void QueryInterface( const INTERFACE_ID& IID, IObject** ppInterface )override = 0;
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
/// Creates a new buffer object
@@ -75,35 +75,35 @@ public:
/// Size of a uniform buffer (BIND_UNIFORM_BUFFER) must be multiple of 16.\n
/// Stride of a formatted buffer will be computed automatically from the format if
/// ElementByteStride member of buffer description is set to default value (0).
- virtual void CreateBuffer(const BufferDesc& BuffDesc,
- const BufferData* pBuffData,
+ virtual void CreateBuffer(const BufferDesc& BuffDesc,
+ const BufferData* pBuffData,
IBuffer** ppBuffer) = 0;
/// Creates a new shader object
/// \param [in] ShaderCI - Shader create info, see Diligent::ShaderCreateInfo for details.
/// \param [out] ppShader - Address of the memory location where the pointer to the
- /// shader interface will be stored.
- /// The function calls AddRef(), so that the new object will contain
+ /// shader interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
/// one reference.
- virtual void CreateShader(const ShaderCreateInfo& ShaderCI,
+ virtual void CreateShader(const ShaderCreateInfo& ShaderCI,
IShader** ppShader) = 0;
-
+
/// Creates a new texture object
/// \param [in] TexDesc - Texture description, see Diligent::TextureDesc for details.
/// \param [in] pData - Pointer to Diligent::TextureData structure that describes
/// initial texture data or nullptr if no data is provided.
/// Static textures (USAGE_STATIC) must be initialized at creation time.
- ///
+ ///
/// \param [out] ppTexture - Address of the memory location where the pointer to the
- /// texture interface will be stored.
- /// The function calls AddRef(), so that the new object will contain
+ /// texture interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
/// one reference.
- /// \remarks
+ /// \remarks
/// To create all mip levels, set the TexDesc.MipLevels to zero.\n
/// Multisampled resources cannot be initialzed with data when they are created. \n
- /// If initial data is provided, number of subresources must exactly match the number
+ /// If initial data is provided, number of subresources must exactly match the number
/// of subresources in the texture (which is the number of mip levels times the number of array slices.
/// For a 3D texture, this is just the number of mip levels).
/// For example, for a 15 x 6 x 2 2D texture array, the following array of subresources should be
@@ -111,57 +111,57 @@ public:
/// 15x6, 7x3, 3x1, 1x1, 15x6, 7x3, 3x1, 1x1.\n
/// For a 15 x 6 x 4 3D texture, the following array of subresources should be provided:\n
/// 15x6x4, 7x3x2, 3x1x1, 1x1x1
- virtual void CreateTexture(const TextureDesc& TexDesc,
- const TextureData* pData,
+ virtual void CreateTexture(const TextureDesc& TexDesc,
+ const TextureData* pData,
ITexture** ppTexture) = 0;
/// Creates a new sampler object
/// \param [in] SamDesc - Sampler description, see Diligent::SamplerDesc for details.
/// \param [out] ppSampler - Address of the memory location where the pointer to the
- /// sampler interface will be stored.
- /// The function calls AddRef(), so that the new object will contain
+ /// sampler interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
/// one reference.
- /// \remark If an application attempts to create a sampler interface with the same attributes
+ /// \remark If an application attempts to create a sampler interface with the same attributes
/// as an existing interface, the same interface will be returned.
- /// \note In D3D11, 4096 unique sampler state objects can be created on a device at a time.
- virtual void CreateSampler(const SamplerDesc& SamDesc,
+ /// \note In D3D11, 4096 unique sampler state objects can be created on a device at a time.
+ virtual void CreateSampler(const SamplerDesc& SamDesc,
ISampler** ppSampler) = 0;
/// Creates a new resource mapping
/// \param [in] MappingDesc - Resource mapping description, see Diligent::ResourceMappingDesc for details.
/// \param [out] ppMapping - Address of the memory location where the pointer to the
- /// resource mapping interface will be stored.
- /// The function calls AddRef(), so that the new object will contain
+ /// resource mapping interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
/// one reference.
- virtual void CreateResourceMapping( const ResourceMappingDesc& MappingDesc,
- IResourceMapping** ppMapping ) = 0;
+ virtual void CreateResourceMapping(const ResourceMappingDesc& MappingDesc,
+ IResourceMapping** ppMapping) = 0;
/// Creates a new pipeline state object
/// \param [in] PipelineDesc - Pipeline state description, see Diligent::PipelineStateDesc for details.
/// \param [out] ppPipelineState - Address of the memory location where the pointer to the
- /// pipeline state interface will be stored.
- /// The function calls AddRef(), so that the new object will contain
+ /// pipeline state interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
/// one reference.
- virtual void CreatePipelineState( const PipelineStateDesc& PipelineDesc,
- IPipelineState** ppPipelineState ) = 0;
+ virtual void CreatePipelineState(const PipelineStateDesc& PipelineDesc,
+ IPipelineState** ppPipelineState) = 0;
+
-
/// Creates a new pipeline state object
/// \param [in] Desc - Fence description, see Diligent::FenceDesc for details.
/// \param [out] ppFence - Address of the memory location where the pointer to the
- /// fence interface will be stored.
- /// The function calls AddRef(), so that the new object will contain
+ /// fence interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
/// one reference.
- virtual void CreateFence( const FenceDesc& Desc,
- IFence** ppFence) = 0;
+ virtual void CreateFence(const FenceDesc& Desc,
+ IFence** ppFence) = 0;
/// Gets the device capabilities, see Diligent::DeviceCaps for details
- virtual const DeviceCaps& GetDeviceCaps()const = 0;
+ virtual const DeviceCaps& GetDeviceCaps() const = 0;
/// Returns the basic texture format information.
@@ -169,7 +169,7 @@ public:
/// \param [in] TexFormat - Texture format for which to provide the information
/// \return Const reference to the TextureFormatInfo structure containing the
/// texture format description.
- virtual const TextureFormatInfo& GetTextureFormatInfo( TEXTURE_FORMAT TexFormat ) = 0;
+ virtual const TextureFormatInfo& GetTextureFormatInfo(TEXTURE_FORMAT TexFormat) = 0;
/// Returns the extended texture format information.
@@ -181,9 +181,9 @@ public:
/// \remark The first time this method is called for a particular format, it may be
/// considerably slower than GetTextureFormatInfo(). If you do not require
/// extended information, call GetTextureFormatInfo() instead.
- virtual const TextureFormatInfoExt& GetTextureFormatInfoExt( TEXTURE_FORMAT TexFormat ) = 0;
+ virtual const TextureFormatInfoExt& GetTextureFormatInfoExt(TEXTURE_FORMAT TexFormat) = 0;
- /// Purges device release queues and releases all stale resources.
+ /// Purges device release queues and releases all stale resources.
/// This method is automatically called by ISwapChain::Present().
/// \param [in] ForceRelease - Forces release of all objects. Use this option with
/// great care only if you are sure the resources are not
@@ -208,4 +208,4 @@ public:
virtual IEngineFactory* GetEngineFactory() const = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/ResourceMapping.h b/Graphics/GraphicsEngine/interface/ResourceMapping.h
index cfd66e58..c0f90a17 100644
--- a/Graphics/GraphicsEngine/interface/ResourceMapping.h
+++ b/Graphics/GraphicsEngine/interface/ResourceMapping.h
@@ -30,107 +30,111 @@
namespace Diligent
{
- // {6C1AC7A6-B429-4139-9433-9E54E93E384A}
- static constexpr INTERFACE_ID IID_ResourceMapping =
- { 0x6c1ac7a6, 0xb429, 0x4139, { 0x94, 0x33, 0x9e, 0x54, 0xe9, 0x3e, 0x38, 0x4a } };
-
- /// Describes the resourse mapping object entry
- struct ResourceMappingEntry
- {
- /// Object name
- const Char* Name = nullptr;
-
- /// Pointer to the object's interface
- IDeviceObject *pObject = nullptr;
-
- Uint32 ArrayIndex = 0;
-
- /// Initializes the structure members
-
- /// \param [in] _Name - Object name.
- /// \param [in] _pObject - Pointer to the object.
- /// \param [in] _ArrayIndex - For array resources, index in the array
- ResourceMappingEntry (const Char* _Name, IDeviceObject* _pObject, Uint32 _ArrayIndex = 0)noexcept :
- Name ( _Name ),
- pObject ( _pObject ),
- ArrayIndex(_ArrayIndex)
- {}
-
- ResourceMappingEntry()noexcept{}
- };
-
- /// Resource mapping description
- struct ResourceMappingDesc
- {
- /// Pointer to the array of resource mapping entries.
- /// The last element in the array must be default value
- /// created by ResourceMappingEntry::ResourceMappingEntry()
- ResourceMappingEntry* pEntries = nullptr;
-
- ResourceMappingDesc()noexcept{}
-
- explicit ResourceMappingDesc(ResourceMappingEntry* _pEntries)noexcept :
- pEntries(_pEntries)
- {}
- };
-
- /// Resouce mapping
-
- /// This interface provides mapping between literal names and resource pointers.
- /// It is created by IRenderDevice::CreateResourceMapping().
- /// \remarks Resource mapping holds strong references to all objects it keeps.
- class IResourceMapping : public IObject
- {
- public:
- /// Queries the specific interface, see IObject::QueryInterface() for details
- virtual void QueryInterface (const INTERFACE_ID& IID, IObject** ppInterface)override = 0;
-
- /// Adds a resource to the mapping.
-
- /// \param [in] Name - Resource name.
- /// \param [in] pObject - Pointer to the object.
- /// \param [in] bIsUnique - Flag indicating if a resource with the same name
- /// is allowed to be found in the mapping. In the latter
- /// case, the new resource replaces the existing one.
- ///
- /// \remarks Resource mapping increases the reference counter for referenced objects. So an
- /// object will not be released as long as it is in the resource mapping.
- virtual void AddResource (const Char* Name, IDeviceObject* pObject, bool bIsUnique) = 0;
-
-
- /// Adds resource array to the mapping.
-
- /// \param [in] Name - Resource array name.
- /// \param [in] StartIndex - First index in the array, where the first element will be inserted
- /// \param [in] ppObjects - Pointer to the array of objects.
- /// \param [in] NumElements - Number of elements to add
- /// \param [in] bIsUnique - Flag indicating if a resource with the same name
- /// is allowed to be found in the mapping. In the latter
- /// case, the new resource replaces the existing one.
- ///
- /// \remarks Resource mapping increases the reference counter for referenced objects. So an
- /// object will not be released as long as it is in the resource mapping.
- virtual void AddResourceArray (const Char* Name, Uint32 StartIndex, IDeviceObject* const* ppObjects, Uint32 NumElements, bool bIsUnique) = 0;
-
-
- /// Removes a resource from the mapping using its literal name.
-
- /// \param [in] Name - Name of the resource to remove.
- /// \param [in] ArrayIndex - For array resources, index in the array
- virtual void RemoveResourceByName (const Char* Name, Uint32 ArrayIndex = 0) = 0;
-
- /// Finds a resource in the mapping.
-
- /// \param [in] Name - Resource name.
- /// \param [in] ArrayIndex - for arrays, index of the array element.
- /// \param [out] ppResource - Address of the memory location where the pointer
- /// to the object with the given name will be written.
- /// If no object is found, nullptr will be written.
- /// \remarks The method increases the reference counter
- /// of the returned object, so Release() must be called.
- virtual void GetResource (const Char* Name, IDeviceObject** ppResource, Uint32 ArrayIndex = 0) = 0;
-
- /// Returns the size of the resource mapping, i.e. the number of objects.
- virtual size_t GetSize() = 0;
- };
-}
+// {6C1AC7A6-B429-4139-9433-9E54E93E384A}
+static constexpr INTERFACE_ID IID_ResourceMapping =
+ {0x6c1ac7a6, 0xb429, 0x4139, {0x94, 0x33, 0x9e, 0x54, 0xe9, 0x3e, 0x38, 0x4a}};
+
+/// Describes the resourse mapping object entry
+struct ResourceMappingEntry
+{
+ // clang-format off
+
+ /// Object name
+ const Char* Name = nullptr;
+
+ /// Pointer to the object's interface
+ IDeviceObject *pObject = nullptr;
+
+ Uint32 ArrayIndex = 0;
+
+ /// Initializes the structure members
+
+ /// \param [in] _Name - Object name.
+ /// \param [in] _pObject - Pointer to the object.
+ /// \param [in] _ArrayIndex - For array resources, index in the array
+ ResourceMappingEntry (const Char* _Name, IDeviceObject* _pObject, Uint32 _ArrayIndex = 0)noexcept :
+ Name { _Name },
+ pObject { _pObject },
+ ArrayIndex{_ArrayIndex}
+ {}
+
+ // clang-format on
+
+ ResourceMappingEntry() noexcept {}
+};
+
+/// Resource mapping description
+struct ResourceMappingDesc
+{
+ /// Pointer to the array of resource mapping entries.
+ /// The last element in the array must be default value
+ /// created by ResourceMappingEntry::ResourceMappingEntry()
+ ResourceMappingEntry* pEntries = nullptr;
+
+ ResourceMappingDesc() noexcept {}
+
+ explicit ResourceMappingDesc(ResourceMappingEntry* _pEntries) noexcept :
+ pEntries{_pEntries}
+ {}
+};
+
+/// Resouce mapping
+
+/// This interface provides mapping between literal names and resource pointers.
+/// It is created by IRenderDevice::CreateResourceMapping().
+/// \remarks Resource mapping holds strong references to all objects it keeps.
+class IResourceMapping : public IObject
+{
+public:
+ /// Queries the specific interface, see IObject::QueryInterface() for details
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
+
+ /// Adds a resource to the mapping.
+
+ /// \param [in] Name - Resource name.
+ /// \param [in] pObject - Pointer to the object.
+ /// \param [in] bIsUnique - Flag indicating if a resource with the same name
+ /// is allowed to be found in the mapping. In the latter
+ /// case, the new resource replaces the existing one.
+ ///
+ /// \remarks Resource mapping increases the reference counter for referenced objects. So an
+ /// object will not be released as long as it is in the resource mapping.
+ virtual void AddResource(const Char* Name, IDeviceObject* pObject, bool bIsUnique) = 0;
+
+
+ /// Adds resource array to the mapping.
+
+ /// \param [in] Name - Resource array name.
+ /// \param [in] StartIndex - First index in the array, where the first element will be inserted
+ /// \param [in] ppObjects - Pointer to the array of objects.
+ /// \param [in] NumElements - Number of elements to add
+ /// \param [in] bIsUnique - Flag indicating if a resource with the same name
+ /// is allowed to be found in the mapping. In the latter
+ /// case, the new resource replaces the existing one.
+ ///
+ /// \remarks Resource mapping increases the reference counter for referenced objects. So an
+ /// object will not be released as long as it is in the resource mapping.
+ virtual void AddResourceArray(const Char* Name, Uint32 StartIndex, IDeviceObject* const* ppObjects, Uint32 NumElements, bool bIsUnique) = 0;
+
+
+ /// Removes a resource from the mapping using its literal name.
+
+ /// \param [in] Name - Name of the resource to remove.
+ /// \param [in] ArrayIndex - For array resources, index in the array
+ virtual void RemoveResourceByName(const Char* Name, Uint32 ArrayIndex = 0) = 0;
+
+ /// Finds a resource in the mapping.
+
+ /// \param [in] Name - Resource name.
+ /// \param [in] ArrayIndex - for arrays, index of the array element.
+ /// \param [out] ppResource - Address of the memory location where the pointer
+ /// to the object with the given name will be written.
+ /// If no object is found, nullptr will be written.
+ /// \remarks The method increases the reference counter
+ /// of the returned object, so Release() must be called.
+ virtual void GetResource(const Char* Name, IDeviceObject** ppResource, Uint32 ArrayIndex = 0) = 0;
+
+ /// Returns the size of the resource mapping, i.e. the number of objects.
+ virtual size_t GetSize() = 0;
+};
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/Sampler.h b/Graphics/GraphicsEngine/interface/Sampler.h
index b86eb9b6..1195684e 100644
--- a/Graphics/GraphicsEngine/interface/Sampler.h
+++ b/Graphics/GraphicsEngine/interface/Sampler.h
@@ -34,17 +34,19 @@ namespace Diligent
// {595A59BF-FA81-4855-BC5E-C0E048745A95}
static constexpr INTERFACE_ID IID_Sampler =
-{ 0x595a59bf, 0xfa81, 0x4855, { 0xbc, 0x5e, 0xc0, 0xe0, 0x48, 0x74, 0x5a, 0x95 } };
+ {0x595a59bf, 0xfa81, 0x4855, {0xbc, 0x5e, 0xc0, 0xe0, 0x48, 0x74, 0x5a, 0x95}};
+
+// clang-format off
/// Sampler description
-/// This structure describes the sampler state which is used in a call to
+/// This structure describes the sampler state which is used in a call to
/// IRenderDevice::CreateSampler() to create a sampler object.
///
/// To create an anisotropic filter, all three filters must either be Diligent::FILTER_TYPE_ANISOTROPIC
/// or Diligent::FILTER_TYPE_COMPARISON_ANISOTROPIC.
///
-/// MipFilter cannot be comparison filter except for Diligent::FILTER_TYPE_ANISOTROPIC if all
+/// MipFilter cannot be comparison filter except for Diligent::FILTER_TYPE_ANISOTROPIC if all
/// three filters have that value.
///
/// Both MinFilter and MagFilter must either be regular filters or comparison filters.
@@ -116,17 +118,17 @@ struct SamplerDesc : DeviceObjectAttribs
COMPARISON_FUNCTION _ComparisonFunc = SamplerDesc{}.ComparisonFunc,
float _MinLOD = SamplerDesc{}.MinLOD,
float _MaxLOD = SamplerDesc{}.MaxLOD) :
- MinFilter (_MinFilter),
- MagFilter (_MagFilter),
- MipFilter (_MipFilter),
- AddressU (_AddressU),
- AddressV (_AddressV),
- AddressW (_AddressW),
- MipLODBias (_MipLODBias),
- MaxAnisotropy (_MaxAnisotropy),
- ComparisonFunc (_ComparisonFunc),
- MinLOD (_MinLOD),
- MaxLOD (_MaxLOD)
+ MinFilter {_MinFilter },
+ MagFilter {_MagFilter },
+ MipFilter {_MipFilter },
+ AddressU {_AddressU },
+ AddressV {_AddressV },
+ AddressW {_AddressW },
+ MipLODBias {_MipLODBias },
+ MaxAnisotropy {_MaxAnisotropy },
+ ComparisonFunc {_ComparisonFunc},
+ MinLOD {_MinLOD },
+ MaxLOD {_MaxLOD }
{
BorderColor[0] = BorderColor[1] = BorderColor[2] = BorderColor[3] = 0;
}
@@ -161,6 +163,8 @@ struct SamplerDesc : DeviceObjectAttribs
}
};
+// clang-format on
+
/// Texture sampler interface.
/// The interface holds the sampler state that can be used to perform texture filtering.
@@ -170,10 +174,10 @@ class ISampler : public IDeviceObject
{
public:
/// Queries the specific interface, see IObject::QueryInterface() for details
- virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override = 0;
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
/// Returns the sampler description used to create the object
- virtual const SamplerDesc& GetDesc()const override = 0;
+ virtual const SamplerDesc& GetDesc() const override = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/Shader.h b/Graphics/GraphicsEngine/interface/Shader.h
index 257ff4fe..91cc215b 100644
--- a/Graphics/GraphicsEngine/interface/Shader.h
+++ b/Graphics/GraphicsEngine/interface/Shader.h
@@ -35,18 +35,18 @@ namespace Diligent
// {2989B45C-143D-4886-B89C-C3271C2DCC5D}
static constexpr INTERFACE_ID IID_Shader =
-{ 0x2989b45c, 0x143d, 0x4886, { 0xb8, 0x9c, 0xc3, 0x27, 0x1c, 0x2d, 0xcc, 0x5d } };
+ {0x2989b45c, 0x143d, 0x4886, {0xb8, 0x9c, 0xc3, 0x27, 0x1c, 0x2d, 0xcc, 0x5d}};
/// Describes the shader type
enum SHADER_TYPE : Uint32
{
- SHADER_TYPE_UNKNOWN = 0x000, ///< Unknown shader type
- SHADER_TYPE_VERTEX = 0x001, ///< Vertex shader
- SHADER_TYPE_PIXEL = 0x002, ///< Pixel (fragment) shader
- SHADER_TYPE_GEOMETRY = 0x004, ///< Geometry shader
- SHADER_TYPE_HULL = 0x008, ///< Hull (tessellation control) shader
- SHADER_TYPE_DOMAIN = 0x010, ///< Domain (tessellation evaluation) shader
- SHADER_TYPE_COMPUTE = 0x020 ///< Compute shader
+ SHADER_TYPE_UNKNOWN = 0x000, ///< Unknown shader type
+ SHADER_TYPE_VERTEX = 0x001, ///< Vertex shader
+ SHADER_TYPE_PIXEL = 0x002, ///< Pixel (fragment) shader
+ SHADER_TYPE_GEOMETRY = 0x004, ///< Geometry shader
+ SHADER_TYPE_HULL = 0x008, ///< Hull (tessellation control) shader
+ SHADER_TYPE_DOMAIN = 0x010, ///< Domain (tessellation evaluation) shader
+ SHADER_TYPE_COMPUTE = 0x020 ///< Compute shader
};
DEFINE_FLAG_ENUM_OPERATORS(SHADER_TYPE);
@@ -66,74 +66,74 @@ enum SHADER_SOURCE_LANGUAGE : Uint32
/// Shader description
struct ShaderDesc : DeviceObjectAttribs
{
- /// Shader type. See Diligent::SHADER_TYPE.
- SHADER_TYPE ShaderType = SHADER_TYPE_VERTEX;
+ /// Shader type. See Diligent::SHADER_TYPE.
+ SHADER_TYPE ShaderType = SHADER_TYPE_UNKNOWN;
};
// {3EA98781-082F-4413-8C30-B9BA6D82DBB7}
static constexpr INTERFACE_ID IID_IShaderSourceInputStreamFactory =
-{ 0x3ea98781, 0x82f, 0x4413, { 0x8c, 0x30, 0xb9, 0xba, 0x6d, 0x82, 0xdb, 0xb7 } };
+ {0x3ea98781, 0x82f, 0x4413, {0x8c, 0x30, 0xb9, 0xba, 0x6d, 0x82, 0xdb, 0xb7}};
/// Shader source stream factory interface
class IShaderSourceInputStreamFactory : public IObject
{
public:
- virtual void CreateInputStream(const Diligent::Char *Name, IFileStream **ppStream) = 0;
+ virtual void CreateInputStream(const Diligent::Char* Name, IFileStream** ppStream) = 0;
};
struct ShaderMacro
{
- const Char* Name = nullptr;
- const Char* Definition = nullptr;
-
- ShaderMacro()noexcept{}
+ const Char* Name = nullptr;
+ const Char* Definition = nullptr;
+
+ ShaderMacro() noexcept {}
ShaderMacro(const Char* _Name,
- const Char* _Def)noexcept :
- Name ( _Name ),
- Definition( _Def )
+ const Char* _Def) noexcept :
+ Name{_Name},
+ Definition{_Def}
{}
};
/// Shader creation attributes
struct ShaderCreateInfo
{
- /// Source file path
+ /// Source file path
/// If source file path is provided, Source and ByteCode members must be null
const Char* FilePath = nullptr;
- /// Pointer to the shader source input stream factory.
+ /// Pointer to the shader source input stream factory.
/// The factory is used to load the shader source file if FilePath is not null.
- /// It is also used to create additional input streams for shader include files
+ /// It is also used to create additional input streams for shader include files
IShaderSourceInputStreamFactory* pShaderSourceStreamFactory = nullptr;
/// HLSL->GLSL conversion stream
-
+
/// If HLSL->GLSL converter is used to convert HLSL shader source to
/// GLSL, this member can provide pointer to the conversion stream. It is useful
/// when the same file is used to create a number of different shaders. If
/// ppConversionStream is null, the converter will parse the same file
/// every time new shader is converted. If ppConversionStream is not null,
/// the converter will write pointer to the conversion stream to *ppConversionStream
- /// the first time and will use it in all subsequent times.
- /// For all subsequent conversions, FilePath member must be the same, or
+ /// the first time and will use it in all subsequent times.
+ /// For all subsequent conversions, FilePath member must be the same, or
/// new stream will be crated and warning message will be displayed.
class IHLSL2GLSLConversionStream** ppConversionStream = nullptr;
- /// Shader source
+ /// Shader source
/// If shader source is provided, FilePath and ByteCode members must be null
const Char* Source = nullptr;
- /// Compiled shader bytecode.
-
+ /// Compiled shader bytecode.
+
/// If shader byte code is provided, FilePath and Source members must be null
- /// \note. This option is supported for D3D11, D3D12 and Vulkan backends.
+ /// \note. This option is supported for D3D11, D3D12 and Vulkan backends.
/// For D3D11 and D3D12 backends, HLSL bytecode should be provided. Vulkan
/// backend expects SPIRV bytecode.
- /// The bytecode must contain reflection information. If shaders were compiled
+ /// The bytecode must contain reflection information. If shaders were compiled
/// using fxc, make sure that /Qstrip_reflect option is *not* specified.
/// HLSL shaders need to be compiled against 4.0 profile or higher.
const void* ByteCode = nullptr;
@@ -143,12 +143,12 @@ struct ShaderCreateInfo
/// Byte code size (in bytes) must be provided if ByteCode is not null
size_t ByteCodeSize = 0;
- /// Shader entry point
+ /// Shader entry point
/// This member is ignored if ByteCode is not null
const Char* EntryPoint = "main";
- /// Shader macros
+ /// Shader macros
/// This member is ignored if ByteCode is not null
const ShaderMacro* Macros = nullptr;
@@ -157,21 +157,21 @@ struct ShaderCreateInfo
/// The CombinedSamplerSuffix member defines the suffix added to the texture variable
/// name to get corresponding sampler name. When using combined samplers,
/// the sampler assigned to the shader resource view is automatically set when
- /// the view is bound. Otherwise samplers need to be explicitly set similar to other
+ /// the view is bound. Otherwise samplers need to be explicitly set similar to other
/// shader variables.
bool UseCombinedTextureSamplers = false;
/// If UseCombinedTextureSamplers is true, defines the suffix added to the
/// texture variable name to get corresponding sampler name. For example,
- /// for default value "_sampler", a texture named "tex" will be combined
- /// with sampler named "tex_sampler".
+ /// for default value "_sampler", a texture named "tex" will be combined
+ /// with sampler named "tex_sampler".
/// If UseCombinedTextureSamplers is false, this member is ignored.
const Char* CombinedSamplerSuffix = "_sampler";
- /// Shader description. See Diligent::ShaderDesc.
+ /// Shader description. See Diligent::ShaderDesc.
ShaderDesc Desc;
- /// Shader source language. See Diligent::SHADER_SOURCE_LANGUAGE.
+ /// Shader source language. See Diligent::SHADER_SOURCE_LANGUAGE.
SHADER_SOURCE_LANGUAGE SourceLanguage = SHADER_SOURCE_LANGUAGE_DEFAULT;
@@ -184,14 +184,14 @@ struct ShaderCreateInfo
/// Minor revision
Uint8 Minor = 0;
- ShaderVersion()noexcept{}
- ShaderVersion(Uint8 _Major, Uint8 _Minor)noexcept :
- Major {_Major},
- Minor {_Minor}
+ ShaderVersion() noexcept {}
+ ShaderVersion(Uint8 _Major, Uint8 _Minor) noexcept :
+ Major{_Major},
+ Minor{_Minor}
{}
};
- /// HLSL shader model to use when compiling the shader. When default value
+ /// HLSL shader model to use when compiling the shader. When default value
/// is given (0, 0), the engine will attempt to use the highest HLSL shader model
/// supported by the device. If the shader is created from the byte code, this value
/// has no effect.
@@ -199,12 +199,12 @@ struct ShaderCreateInfo
/// \note When HLSL source is converted to GLSL, corresponding GLSL/GLESSL version will be used.
ShaderVersion HLSLVersion = ShaderVersion{};
- /// GLSL version to use when creating the shader. When default value
+ /// GLSL version to use when creating the shader. When default value
/// is given (0, 0), the engine will attempt to use the highest GLSL version
/// supported by the device.
ShaderVersion GLSLVersion = ShaderVersion{};
- /// GLES shading language version to use when creating the shader. When default value
+ /// GLES shading language version to use when creating the shader. When default value
/// is given (0, 0), the engine will attempt to use the highest GLESSL version
/// supported by the device.
ShaderVersion GLESSLVersion = ShaderVersion{};
@@ -246,6 +246,7 @@ enum SHADER_RESOURCE_TYPE : Uint8
/// Shader resource description
struct ShaderResourceDesc
{
+ // clang-format off
/// Shader resource name
const char* Name = nullptr;
@@ -254,6 +255,7 @@ struct ShaderResourceDesc
/// Array size. For non-array resource this value is 1.
Uint32 ArraySize = 0;
+ // clang-format on
};
/// Shader interface
@@ -261,16 +263,16 @@ class IShader : public IDeviceObject
{
public:
/// Queries the specific interface, see IObject::QueryInterface() for details
- virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override = 0;
-
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
+
/// Returns the shader description
- virtual const ShaderDesc& GetDesc()const override = 0;
+ virtual const ShaderDesc& GetDesc() const override = 0;
/// Returns the total number of shader resources
- virtual Uint32 GetResourceCount()const = 0;
+ virtual Uint32 GetResourceCount() const = 0;
/// Returns the pointer to the array of shader resources
- virtual ShaderResourceDesc GetResource(Uint32 Index)const = 0;
+ virtual ShaderResourceDesc GetResource(Uint32 Index) const = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/ShaderResourceBinding.h b/Graphics/GraphicsEngine/interface/ShaderResourceBinding.h
index fe16d76c..44290999 100644
--- a/Graphics/GraphicsEngine/interface/ShaderResourceBinding.h
+++ b/Graphics/GraphicsEngine/interface/ShaderResourceBinding.h
@@ -38,7 +38,7 @@ class IPipelineState;
// {061F8774-9A09-48E8-8411-B5BD20560104}
static constexpr INTERFACE_ID IID_ShaderResourceBinding =
-{ 0x61f8774, 0x9a09, 0x48e8, { 0x84, 0x11, 0xb5, 0xbd, 0x20, 0x56, 0x1, 0x4 } };
+ {0x61f8774, 0x9a09, 0x48e8, {0x84, 0x11, 0xb5, 0xbd, 0x20, 0x56, 0x1, 0x4}};
/// Shader resource binding interface
@@ -46,11 +46,11 @@ class IShaderResourceBinding : public IObject
{
public:
/// Queries the specific interface, see IObject::QueryInterface() for details
- virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override = 0;
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
/// Returns pointer to the referenced buffer object.
- /// The method calls AddRef() on the returned interface,
+ /// The method calls AddRef() on the returned interface,
/// so Release() must be called to avoid memory leaks.
virtual IPipelineState* GetPipelineState() = 0;
@@ -58,13 +58,13 @@ public:
/// \param [in] ShaderFlags - Flags that specify shader stages, for which resources will be bound.
/// Any combination of Diligent::SHADER_TYPE may be used.
- /// \param [in] pResMapping - Shader resource mapping, where required resources will be looked up
+ /// \param [in] pResMapping - Shader resource mapping, where required resources will be looked up
/// \param [in] Flags - Additional flags. See Diligent::BIND_SHADER_RESOURCES_FLAGS.
virtual void BindResources(Uint32 ShaderFlags, IResourceMapping* pResMapping, Uint32 Flags) = 0;
/// Returns variable
- /// \param [in] ShaderType - Type of the shader to look up the variable.
+ /// \param [in] ShaderType - Type of the shader to look up the variable.
/// Must be one of Diligent::SHADER_TYPE.
/// \param [in] Name - Variable name
///
@@ -82,10 +82,10 @@ public:
/// Returns variable
- /// \param [in] ShaderType - Type of the shader to look up the variable.
+ /// \param [in] ShaderType - Type of the shader to look up the variable.
/// Must be one of Diligent::SHADER_TYPE.
/// \param [in] Index - Variable index. The index must be between 0 and the total number
- /// of variables in this shader stage as returned by
+ /// of variables in this shader stage as returned by
/// IShaderResourceBinding::GetVariableCount().
/// \remark Only mutable and dynamic variables can be accessed through this method.
/// Static variables are accessed through the Shader object.
@@ -97,8 +97,8 @@ public:
/// Initializes static resources
- /// If the parent pipeline state object contain static resources
- /// (see Diligent::SHADER_RESOURCE_VARIABLE_TYPE_STATIC), this method must be called
+ /// If the parent pipeline state object contain static resources
+ /// (see Diligent::SHADER_RESOURCE_VARIABLE_TYPE_STATIC), this method must be called
/// once to initialize static resources in this shader resource binding object.
/// The method must be called after all static variables are initialized
/// in the PSO.
@@ -113,4 +113,4 @@ public:
virtual void InitializeStaticResources(const IPipelineState* pPipelineState = nullptr) = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h b/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h
index 6ec01934..262c56ec 100644
--- a/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h
+++ b/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h
@@ -36,7 +36,7 @@ namespace Diligent
// {0D57DF3F-977D-4C8F-B64C-6675814BC80C}
static constexpr INTERFACE_ID IID_ShaderResourceVariable =
-{ 0xd57df3f, 0x977d, 0x4c8f, { 0xb6, 0x4c, 0x66, 0x75, 0x81, 0x4b, 0xc8, 0xc } };
+ {0xd57df3f, 0x977d, 0x4c8f, {0xb6, 0x4c, 0x66, 0x75, 0x81, 0x4b, 0xc8, 0xc}};
/// Describes the type of the shader resource variable
@@ -44,15 +44,15 @@ enum SHADER_RESOURCE_VARIABLE_TYPE : Uint8
{
/// Shader resource bound to the variable is the same for all SRB instances.
/// It must be set *once* directly through Pipeline State object.
- SHADER_RESOURCE_VARIABLE_TYPE_STATIC = 0,
+ SHADER_RESOURCE_VARIABLE_TYPE_STATIC = 0,
- /// Shader resource bound to the variable is specific to the shader resource binding
- /// instance (see Diligent::IShaderResourceBinding). It must be set *once* through
+ /// Shader resource bound to the variable is specific to the shader resource binding
+ /// instance (see Diligent::IShaderResourceBinding). It must be set *once* through
/// Diligent::IShaderResourceBinding interface. It cannot be set through Diligent::IPipelineState
/// interface and cannot be change once bound.
SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE,
- /// Shader variable binding is dynamic. It can be set multiple times for every instance of shader resource
+ /// Shader variable binding is dynamic. It can be set multiple times for every instance of shader resource
/// binding (see Diligent::IShaderResourceBinding). It cannot be set through Diligent::IPipelineState interface.
SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC,
@@ -67,7 +67,7 @@ static_assert(SHADER_RESOURCE_VARIABLE_TYPE_STATIC == 0 && SHADER_RESOURCE_VARIA
enum BIND_SHADER_RESOURCES_FLAGS : Uint32
{
/// Indicates that static shader variable bindings are to be updated.
- BIND_SHADER_RESOURCES_UPDATE_STATIC = (0x01 << SHADER_RESOURCE_VARIABLE_TYPE_STATIC),
+ BIND_SHADER_RESOURCES_UPDATE_STATIC = (0x01 << SHADER_RESOURCE_VARIABLE_TYPE_STATIC),
/// Indicates that mutable shader variable bindings are to be updated.
BIND_SHADER_RESOURCES_UPDATE_MUTABLE = (0x01 << SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE),
@@ -81,14 +81,14 @@ enum BIND_SHADER_RESOURCES_FLAGS : Uint32
/// as if BIND_SHADER_RESOURCES_UPDATE_ALL was specified.
BIND_SHADER_RESOURCES_UPDATE_ALL = (BIND_SHADER_RESOURCES_UPDATE_STATIC | BIND_SHADER_RESOURCES_UPDATE_MUTABLE | BIND_SHADER_RESOURCES_UPDATE_DYNAMIC),
- /// If this flag is specified, all existing bindings will be preserved and
+ /// If this flag is specified, all existing bindings will be preserved and
/// only unresolved ones will be updated.
/// If this flag is not specified, every shader variable will be
/// updated if the mapping contains corresponding resource.
BIND_SHADER_RESOURCES_KEEP_EXISTING = 0x08,
/// If this flag is specified, all shader bindings are expected
- /// to be resolved after the call. If this is not the case, debug message
+ /// to be resolved after the call. If this is not the case, debug message
/// will be displayed.
/// \note Only these variables are verified that are being updated by setting
/// BIND_SHADER_RESOURCES_UPDATE_STATIC, BIND_SHADER_RESOURCES_UPDATE_MUTABLE, and
@@ -135,4 +135,4 @@ public:
virtual bool IsBound(Uint32 ArrayIndex) const = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/SwapChain.h b/Graphics/GraphicsEngine/interface/SwapChain.h
index fb3b79fb..98baa362 100644
--- a/Graphics/GraphicsEngine/interface/SwapChain.h
+++ b/Graphics/GraphicsEngine/interface/SwapChain.h
@@ -35,7 +35,7 @@ namespace Diligent
// {1C703B77-6607-4EEC-B1FE-15C82D3B4130}
static constexpr INTERFACE_ID IID_SwapChain =
-{ 0x1c703b77, 0x6607, 0x4eec, { 0xb1, 0xfe, 0x15, 0xc8, 0x2d, 0x3b, 0x41, 0x30 } };
+ {0x1c703b77, 0x6607, 0x4eec, {0xb1, 0xfe, 0x15, 0xc8, 0x2d, 0x3b, 0x41, 0x30}};
/// Swap chain interface
@@ -43,33 +43,32 @@ static constexpr INTERFACE_ID IID_SwapChain =
class ISwapChain : public IObject
{
public:
-
/// Presents a rendered image to the user
virtual void Present(Uint32 SyncInterval = 1) = 0;
/// Returns the swap chain desctription
- virtual const SwapChainDesc& GetDesc()const = 0;
+ virtual const SwapChainDesc& GetDesc() const = 0;
/// Changes the swap chain's back buffer size
/// \param [in] NewWidth - New swap chain width, in pixels
/// \param [in] NewHeight - New swap chain height, in pixels
- ///
- /// \note When resizing non-primary swap chains, the engine unbinds the
+ ///
+ /// \note When resizing non-primary swap chains, the engine unbinds the
/// swap chain buffers from the output.
- virtual void Resize( Uint32 NewWidth, Uint32 NewHeight ) = 0;
+ virtual void Resize(Uint32 NewWidth, Uint32 NewHeight) = 0;
/// Sets fullscreen mode (only supported on Win32 platform)
- virtual void SetFullscreenMode(const DisplayModeAttribs &DisplayMode) = 0;
+ virtual void SetFullscreenMode(const DisplayModeAttribs& DisplayMode) = 0;
/// Sets windowed mode (only supported on Win32 platform)
virtual void SetWindowedMode() = 0;
/// Returns render target view of the current back buffer in the swap chain
- /// \note For Direct3D12 and Vulkan backends, the function returns
+ /// \note For Direct3D12 and Vulkan backends, the function returns
/// different pointer for every offscreen buffer in the swap chain
- /// (flipped by every call to ISwapChain::Present()). For Direct3D11
+ /// (flipped by every call to ISwapChain::Present()). For Direct3D11
/// backend it always returns the same pointer. For OpenGL/GLES backends
/// the method returns null.
///
@@ -84,4 +83,4 @@ public:
virtual ITextureView* GetDepthBufferDSV() = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/Texture.h b/Graphics/GraphicsEngine/interface/Texture.h
index cc5a1ebe..d334c0ac 100644
--- a/Graphics/GraphicsEngine/interface/Texture.h
+++ b/Graphics/GraphicsEngine/interface/Texture.h
@@ -23,6 +23,8 @@
#pragma once
+// clang-format off
+
/// \file
/// Definition of the Diligent::ITexture interface and related data structures
@@ -35,7 +37,7 @@ class IDeviceContext;
// {A64B0E60-1B5E-4CFD-B880-663A1ADCBE98}
static constexpr INTERFACE_ID IID_Texture =
-{ 0xa64b0e60, 0x1b5e, 0x4cfd, { 0xb8, 0x80, 0x66, 0x3a, 0x1a, 0xdc, 0xbe, 0x98 } };
+ {0xa64b0e60, 0x1b5e, 0x4cfd,{0xb8, 0x80, 0x66, 0x3a, 0x1a, 0xdc, 0xbe, 0x98}};
/// Defines optimized depth-stencil clear value.
struct DepthStencilClearValue
@@ -52,8 +54,8 @@ struct DepthStencilClearValue
DepthStencilClearValue(Float32 _Depth,
Uint8 _Stencil)noexcept :
- Depth (_Depth),
- Stencil (_Stencil)
+ Depth {_Depth },
+ Stencil {_Stencil}
{}
};
@@ -151,19 +153,19 @@ struct TextureDesc : DeviceObjectAttribs
MISC_TEXTURE_FLAGS _MiscFlags = TextureDesc{}.MiscFlags,
OptimizedClearValue _ClearValue = TextureDesc{}.ClearValue,
Uint64 _CommandQueueMask = TextureDesc{}.CommandQueueMask) :
- Type (_Type),
- Width (_Width),
- Height (_Height),
- ArraySize (_ArraySizeOrDepth),
- Format (_Format),
- MipLevels (_MipLevels),
- SampleCount (_SampleCount),
- Usage (_Usage),
- BindFlags (_BindFlags),
- CPUAccessFlags (_CPUAccessFlags),
- MiscFlags (_MiscFlags),
- ClearValue (_ClearValue),
- CommandQueueMask (_CommandQueueMask)
+ Type {_Type },
+ Width {_Width },
+ Height {_Height },
+ ArraySize {_ArraySizeOrDepth},
+ Format {_Format },
+ MipLevels {_MipLevels },
+ SampleCount {_SampleCount },
+ Usage {_Usage },
+ BindFlags {_BindFlags },
+ CPUAccessFlags {_CPUAccessFlags },
+ MiscFlags {_MiscFlags },
+ ClearValue {_ClearValue },
+ CommandQueueMask {_CommandQueueMask}
{}
/// Tests if two structures are equivalent
@@ -239,11 +241,11 @@ struct TextureSubResData
/// Initializes the structure members to perform copy from the GPU buffer
TextureSubResData(IBuffer* _pBuffer, Uint32 _SrcOffset, Uint32 _Stride, Uint32 _DepthStride = 0)noexcept :
- pData (nullptr),
- pSrcBuffer (_pBuffer),
- SrcOffset (_SrcOffset),
- Stride (_Stride),
- DepthStride (_DepthStride)
+ pData {nullptr },
+ pSrcBuffer {_pBuffer },
+ SrcOffset {_SrcOffset },
+ Stride {_Stride },
+ DepthStride {_DepthStride}
{}
};
@@ -264,8 +266,8 @@ struct TextureData
TextureData(TextureSubResData* _pSubResources,
Uint32 _NumSubresources) noexcept :
- pSubResources (_pSubResources),
- NumSubresources (_NumSubresources)
+ pSubResources {_pSubResources },
+ NumSubresources {_NumSubresources}
{}
};
@@ -280,9 +282,9 @@ struct MappedTextureSubresource
MappedTextureSubresource(PVoid _pData,
Uint32 _Stride,
Uint32 _DepthStride = 0) noexcept :
- pData (_pData),
- Stride (_Stride),
- DepthStride (_DepthStride)
+ pData {_pData },
+ Stride {_Stride },
+ DepthStride {_DepthStride}
{}
};
diff --git a/Graphics/GraphicsEngine/interface/TextureView.h b/Graphics/GraphicsEngine/interface/TextureView.h
index cc19acf1..a9cc8b15 100644
--- a/Graphics/GraphicsEngine/interface/TextureView.h
+++ b/Graphics/GraphicsEngine/interface/TextureView.h
@@ -23,6 +23,8 @@
#pragma once
+// clang-format off
+
/// \file
/// Definition of the Diligent::ITextureView interface and related data structures
@@ -36,7 +38,7 @@ class IDeviceContext;
// {5B2EA04E-8128-45E4-AA4D-6DC7E70DC424}
static constexpr INTERFACE_ID IID_TextureView =
-{ 0x5b2ea04e, 0x8128, 0x45e4, { 0xaa, 0x4d, 0x6d, 0xc7, 0xe7, 0xd, 0xc4, 0x24 } };
+ {0x5b2ea04e, 0x8128, 0x45e4,{0xaa, 0x4d, 0x6d, 0xc7, 0xe7, 0xd, 0xc4, 0x24}};
/// Describes allowed unordered access view mode
enum UAV_ACCESS_FLAG : Uint8
@@ -136,15 +138,15 @@ struct TextureViewDesc : DeviceObjectAttribs
Uint32 _NumArrayOrDepthSlices = TextureViewDesc{}.NumArraySlices,
UAV_ACCESS_FLAG _AccessFlags = TextureViewDesc{}.AccessFlags,
TEXTURE_VIEW_FLAGS _Flags = TextureViewDesc{}.Flags)noexcept :
- ViewType (_ViewType),
- TextureDim (_TextureDim),
- Format (_Format),
- MostDetailedMip (_MostDetailedMip),
- NumMipLevels (_NumMipLevels),
- FirstArraySlice (_FirstArrayOrDepthSlice),
- NumArraySlices (_NumArrayOrDepthSlices),
- AccessFlags (_AccessFlags),
- Flags (_Flags)
+ ViewType {_ViewType },
+ TextureDim {_TextureDim },
+ Format {_Format },
+ MostDetailedMip {_MostDetailedMip },
+ NumMipLevels {_NumMipLevels },
+ FirstArraySlice {_FirstArrayOrDepthSlice},
+ NumArraySlices {_NumArrayOrDepthSlices },
+ AccessFlags {_AccessFlags },
+ Flags {_Flags }
{}
/// Tests if two structures are equivalent
diff --git a/Graphics/GraphicsEngine/src/APIInfo.cpp b/Graphics/GraphicsEngine/src/APIInfo.cpp
index 43ab7514..c50b1863 100644
--- a/Graphics/GraphicsEngine/src/APIInfo.cpp
+++ b/Graphics/GraphicsEngine/src/APIInfo.cpp
@@ -42,7 +42,7 @@ namespace Diligent
static APIInfo InitAPIInfo()
{
- APIInfo Info = {};
+ APIInfo Info = {};
Info.StructSize = sizeof(APIInfo);
Info.APIVersion = DILIGENT_API_VERSION;
@@ -114,4 +114,4 @@ const APIInfo& GetAPIInfo()
return Info;
}
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/src/DefaultShaderSourceStreamFactory.cpp b/Graphics/GraphicsEngine/src/DefaultShaderSourceStreamFactory.cpp
index e9ddb958..51a52c3c 100644
--- a/Graphics/GraphicsEngine/src/DefaultShaderSourceStreamFactory.cpp
+++ b/Graphics/GraphicsEngine/src/DefaultShaderSourceStreamFactory.cpp
@@ -33,9 +33,9 @@ namespace Diligent
class DefaultShaderSourceStreamFactory final : public ObjectBase<IShaderSourceInputStreamFactory>
{
public:
- DefaultShaderSourceStreamFactory(IReferenceCounters* pRefCounters, const Char *SearchDirectories);
+ DefaultShaderSourceStreamFactory(IReferenceCounters* pRefCounters, const Char* SearchDirectories);
- virtual void CreateInputStream(const Char *Name, IFileStream **ppStream)override final;
+ virtual void CreateInputStream(const Char* Name, IFileStream** ppStream) override final;
IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_IShaderSourceInputStreamFactory, ObjectBase<IShaderSourceInputStreamFactory>);
@@ -43,44 +43,44 @@ private:
std::vector<String> m_SearchDirectories;
};
-DefaultShaderSourceStreamFactory::DefaultShaderSourceStreamFactory(IReferenceCounters* pRefCounters, const Char* SearchDirectories) :
+DefaultShaderSourceStreamFactory::DefaultShaderSourceStreamFactory(IReferenceCounters* pRefCounters, const Char* SearchDirectories) :
ObjectBase<IShaderSourceInputStreamFactory>(pRefCounters)
{
- while( SearchDirectories )
+ while (SearchDirectories)
{
- const char* Semicolon = strchr( SearchDirectories, ';' );
- String SearchPath;
- if( Semicolon == nullptr )
+ const char* Semicolon = strchr(SearchDirectories, ';');
+ String SearchPath;
+ if (Semicolon == nullptr)
{
- SearchPath = SearchDirectories;
+ SearchPath = SearchDirectories;
SearchDirectories = nullptr;
}
else
{
- SearchPath = String( SearchDirectories, Semicolon );
+ SearchPath = String(SearchDirectories, Semicolon);
SearchDirectories = Semicolon + 1;
}
- if( SearchPath.length() > 0 )
+ if (SearchPath.length() > 0)
{
- if( SearchPath.back() != '\\' && SearchPath.back() != '/' )
- SearchPath.push_back( '\\' );
- m_SearchDirectories.push_back( SearchPath );
+ if (SearchPath.back() != '\\' && SearchPath.back() != '/')
+ SearchPath.push_back('\\');
+ m_SearchDirectories.push_back(SearchPath);
}
}
- m_SearchDirectories.push_back( "" );
+ m_SearchDirectories.push_back("");
}
-void DefaultShaderSourceStreamFactory::CreateInputStream( const Diligent::Char *Name, IFileStream **ppStream )
+void DefaultShaderSourceStreamFactory::CreateInputStream(const Diligent::Char* Name, IFileStream** ppStream)
{
- bool bFileCreated = false;
+ bool bFileCreated = false;
Diligent::RefCntAutoPtr<BasicFileStream> pBasicFileStream;
- for (const auto &SearchDir : m_SearchDirectories)
+ for (const auto& SearchDir : m_SearchDirectories)
{
- String FullPath = SearchDir + ( (Name[0] == '\\' || Name[0] == '/') ? Name + 1 : Name);
+ String FullPath = SearchDir + ((Name[0] == '\\' || Name[0] == '/') ? Name + 1 : Name);
if (!FileSystem::FileExists(FullPath.c_str()))
continue;
- pBasicFileStream = MakeNewRCObj<BasicFileStream>()( FullPath.c_str(), EFileAccessMode::Read );
+ pBasicFileStream = MakeNewRCObj<BasicFileStream>()(FullPath.c_str(), EFileAccessMode::Read);
if (pBasicFileStream->IsValid())
{
bFileCreated = true;
@@ -93,23 +93,23 @@ void DefaultShaderSourceStreamFactory::CreateInputStream( const Diligent::Char *
}
if (bFileCreated)
{
- pBasicFileStream->QueryInterface( IID_FileStream, reinterpret_cast<IObject**>(ppStream) );
+ pBasicFileStream->QueryInterface(IID_FileStream, reinterpret_cast<IObject**>(ppStream));
}
else
{
*ppStream = nullptr;
- LOG_ERROR( "Failed to create input stream for source file ", Name );
+ LOG_ERROR("Failed to create input stream for source file ", Name);
}
}
-void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories,
+void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories,
IShaderSourceInputStreamFactory** ppShaderSourceStreamFactory)
{
-
- auto& Allocator = GetRawAllocator();
- DefaultShaderSourceStreamFactory* pStreamFactory =
+
+ auto& Allocator = GetRawAllocator();
+ DefaultShaderSourceStreamFactory* pStreamFactory =
NEW_RC_OBJ(Allocator, "DefaultShaderSourceStreamFactory instance", DefaultShaderSourceStreamFactory)(SearchDirectories);
pStreamFactory->QueryInterface(IID_IShaderSourceInputStreamFactory, reinterpret_cast<IObject**>(ppShaderSourceStreamFactory));
}
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/src/EngineMemory.cpp b/Graphics/GraphicsEngine/src/EngineMemory.cpp
index 80595b64..74671f73 100644
--- a/Graphics/GraphicsEngine/src/EngineMemory.cpp
+++ b/Graphics/GraphicsEngine/src/EngineMemory.cpp
@@ -32,8 +32,9 @@
namespace Diligent
{
-static IMemoryAllocator *g_pRawAllocator;
-void SetRawAllocator(IMemoryAllocator *pRawAllocator)
+static IMemoryAllocator* g_pRawAllocator;
+
+void SetRawAllocator(IMemoryAllocator* pRawAllocator)
{
if (pRawAllocator == nullptr)
{
@@ -53,7 +54,7 @@ IMemoryAllocator& GetStringAllocator()
return GetRawAllocator();
}
-}
+} // namespace Diligent
#if 0
void* operator new(size_t Size)
diff --git a/Graphics/GraphicsEngine/src/ResourceMapping.cpp b/Graphics/GraphicsEngine/src/ResourceMapping.cpp
index cbe1b3e4..94811bda 100644
--- a/Graphics/GraphicsEngine/src/ResourceMapping.cpp
+++ b/Graphics/GraphicsEngine/src/ResourceMapping.cpp
@@ -29,93 +29,92 @@ using namespace std;
namespace Diligent
{
- ResourceMappingImpl::~ResourceMappingImpl()
- {
- }
+ResourceMappingImpl::~ResourceMappingImpl()
+{
+}
- IMPLEMENT_QUERY_INTERFACE( ResourceMappingImpl, IID_ResourceMapping, TObjectBase )
+IMPLEMENT_QUERY_INTERFACE(ResourceMappingImpl, IID_ResourceMapping, TObjectBase)
- ThreadingTools::LockHelper ResourceMappingImpl::Lock()
- {
- return ThreadingTools::LockHelper( m_LockFlag );
- }
+ThreadingTools::LockHelper ResourceMappingImpl::Lock()
+{
+ return ThreadingTools::LockHelper(m_LockFlag);
+}
- void ResourceMappingImpl::AddResourceArray( const Char *Name, Uint32 StartIndex, IDeviceObject * const* ppObjects, Uint32 NumElements, bool bIsUnique )
- {
- if( Name == nullptr || *Name == 0 )
- return;
+void ResourceMappingImpl::AddResourceArray(const Char* Name, Uint32 StartIndex, IDeviceObject* const* ppObjects, Uint32 NumElements, bool bIsUnique)
+{
+ if (Name == nullptr || *Name == 0)
+ return;
- auto LockHelper = Lock();
- for(Uint32 Elem = 0; Elem < NumElements; ++Elem)
+ auto LockHelper = Lock();
+ for (Uint32 Elem = 0; Elem < NumElements; ++Elem)
+ {
+ auto* pObject = ppObjects[Elem];
+
+ // Try to construct new element in place
+ auto Elems =
+ m_HashTable.emplace(
+ make_pair(Diligent::ResMappingHashKey(Name, true, StartIndex + Elem), // Make a copy of the source string
+ Diligent::RefCntAutoPtr<IDeviceObject>(pObject)));
+ // If there is already element with the same name, replace it
+ if (!Elems.second && Elems.first->second != pObject)
{
- auto *pObject = ppObjects[Elem];
-
- // Try to construct new element in place
- auto Elems =
- m_HashTable.emplace(
- make_pair( Diligent::ResMappingHashKey(Name, true, StartIndex+Elem), // Make a copy of the source string
- Diligent::RefCntAutoPtr<IDeviceObject>(pObject)
- )
- );
- // If there is already element with the same name, replace it
- if( !Elems.second && Elems.first->second != pObject )
+ if (bIsUnique)
{
- if( bIsUnique )
- {
- UNEXPECTED( "Resource with the same name already exists" );
- LOG_WARNING_MESSAGE(
- "Resource with name ", Name, " marked is unique, but already present in the hash.\n"
- "New resource will be used\n." );
- }
- Elems.first->second = pObject;
+ UNEXPECTED("Resource with the same name already exists");
+ LOG_WARNING_MESSAGE(
+ "Resource with name ", Name,
+ " marked is unique, but already present in the hash.\n"
+ "New resource will be used\n.");
}
+ Elems.first->second = pObject;
}
}
+}
- void ResourceMappingImpl::AddResource(const Char *Name, IDeviceObject *pObject, bool bIsUnique)
- {
- AddResourceArray( Name, 0, &pObject, 1, bIsUnique );
- }
-
- void ResourceMappingImpl::RemoveResourceByName( const Char *Name, Uint32 ArrayIndex )
- {
- if( *Name == 0 )
- return;
+void ResourceMappingImpl::AddResource(const Char* Name, IDeviceObject* pObject, bool bIsUnique)
+{
+ AddResourceArray(Name, 0, &pObject, 1, bIsUnique);
+}
- auto LockHelper = Lock();
- // Remove object with the given name
- // Name will be implicitly converted to HashMapStringKey without making a copy
- m_HashTable.erase( ResMappingHashKey(Name, false, ArrayIndex) );
- }
+void ResourceMappingImpl::RemoveResourceByName(const Char* Name, Uint32 ArrayIndex)
+{
+ if (*Name == 0)
+ return;
- void ResourceMappingImpl::GetResource( const Char *Name, IDeviceObject **ppResource, Uint32 ArrayIndex )
- {
- VERIFY(Name, "Name is null");
- if( *Name == 0 )
- return;
+ auto LockHelper = Lock();
+ // Remove object with the given name
+ // Name will be implicitly converted to HashMapStringKey without making a copy
+ m_HashTable.erase(ResMappingHashKey(Name, false, ArrayIndex));
+}
- VERIFY( ppResource, "Null pointer provided" );
- if(!ppResource)
- return;
+void ResourceMappingImpl::GetResource(const Char* Name, IDeviceObject** ppResource, Uint32 ArrayIndex)
+{
+ VERIFY(Name, "Name is null");
+ if (*Name == 0)
+ return;
- VERIFY( *ppResource == nullptr, "Overwriting reference to existing object may cause memory leaks" );
- *ppResource = nullptr;
+ VERIFY(ppResource, "Null pointer provided");
+ if (!ppResource)
+ return;
- auto LockHelper = Lock();
+ VERIFY(*ppResource == nullptr, "Overwriting reference to existing object may cause memory leaks");
+ *ppResource = nullptr;
- // Find an object with the requested name
- // Name will be implicitly converted to HashMapStringKey without making a copy
- auto It = m_HashTable.find( ResMappingHashKey(Name, false, ArrayIndex) );
- if( It != m_HashTable.end() )
- {
- *ppResource = It->second.RawPtr();
- if(*ppResource)
- (*ppResource)->AddRef();
- }
- }
+ auto LockHelper = Lock();
- size_t ResourceMappingImpl::GetSize()
+ // Find an object with the requested name
+ // Name will be implicitly converted to HashMapStringKey without making a copy
+ auto It = m_HashTable.find(ResMappingHashKey(Name, false, ArrayIndex));
+ if (It != m_HashTable.end())
{
- return m_HashTable.size();
+ *ppResource = It->second.RawPtr();
+ if (*ppResource)
+ (*ppResource)->AddRef();
}
}
+
+size_t ResourceMappingImpl::GetSize()
+{
+ return m_HashTable.size();
+}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/src/Texture.cpp b/Graphics/GraphicsEngine/src/Texture.cpp
index a9c38421..0fcebf58 100644
--- a/Graphics/GraphicsEngine/src/Texture.cpp
+++ b/Graphics/GraphicsEngine/src/Texture.cpp
@@ -28,16 +28,16 @@
namespace Diligent
{
-void ValidateTextureDesc( const TextureDesc& Desc )
+void ValidateTextureDesc(const TextureDesc& Desc)
{
#define LOG_TEXTURE_ERROR_AND_THROW(...) LOG_ERROR_AND_THROW("Texture \"", Desc.Name ? Desc.Name : "", "\": ", ##__VA_ARGS__)
-
+
if (Desc.Type == RESOURCE_DIM_UNDEFINED)
{
LOG_TEXTURE_ERROR_AND_THROW("Resource dimension is undefined");
}
- if ( !(Desc.Type >= RESOURCE_DIM_TEX_1D && Desc.Type <= RESOURCE_DIM_TEX_CUBE_ARRAY) )
+ if (!(Desc.Type >= RESOURCE_DIM_TEX_1D && Desc.Type <= RESOURCE_DIM_TEX_CUBE_ARRAY))
{
LOG_TEXTURE_ERROR_AND_THROW("Unexpected resource dimension");
}
@@ -48,10 +48,10 @@ void ValidateTextureDesc( const TextureDesc& Desc )
}
// Perform some parameter correctness check
- if( Desc.Type == RESOURCE_DIM_TEX_1D || Desc.Type == RESOURCE_DIM_TEX_1D_ARRAY )
+ if (Desc.Type == RESOURCE_DIM_TEX_1D || Desc.Type == RESOURCE_DIM_TEX_1D_ARRAY)
{
- if( Desc.Height != 1 )
- LOG_TEXTURE_ERROR_AND_THROW("Height (", Desc.Height,") of Texture 1D/Texture 1D Array must be 1");
+ if (Desc.Height != 1)
+ LOG_TEXTURE_ERROR_AND_THROW("Height (", Desc.Height, ") of Texture 1D/Texture 1D Array must be 1");
}
else
{
@@ -59,55 +59,55 @@ void ValidateTextureDesc( const TextureDesc& Desc )
LOG_TEXTURE_ERROR_AND_THROW("Texture height cannot be zero");
}
- if( Desc.Type == RESOURCE_DIM_TEX_3D && Desc.Depth == 0 )
+ if (Desc.Type == RESOURCE_DIM_TEX_3D && Desc.Depth == 0)
{
LOG_TEXTURE_ERROR_AND_THROW("3D texture depth cannot be zero");
}
- if( Desc.Type == RESOURCE_DIM_TEX_1D || Desc.Type == RESOURCE_DIM_TEX_2D )
+ if (Desc.Type == RESOURCE_DIM_TEX_1D || Desc.Type == RESOURCE_DIM_TEX_2D)
{
- if( Desc.ArraySize != 1 )
+ if (Desc.ArraySize != 1)
LOG_TEXTURE_ERROR_AND_THROW("Texture 1D/2D must have one array slice (", Desc.ArraySize, " provided). Use Texture 1D/2D array if you need more than one slice.");
}
- if( Desc.Type == RESOURCE_DIM_TEX_CUBE || Desc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY )
+ if (Desc.Type == RESOURCE_DIM_TEX_CUBE || Desc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY)
{
- if( Desc.Width != Desc.Height )
- LOG_TEXTURE_ERROR_AND_THROW("For cube map textures, texture width (", Desc.Width," provided) must match texture height (", Desc.Height, " provided)");
-
- if( Desc.ArraySize < 6 )
+ if (Desc.Width != Desc.Height)
+ LOG_TEXTURE_ERROR_AND_THROW("For cube map textures, texture width (", Desc.Width, " provided) must match texture height (", Desc.Height, " provided)");
+
+ if (Desc.ArraySize < 6)
LOG_TEXTURE_ERROR_AND_THROW("Texture cube/cube array must have at least 6 slices (", Desc.ArraySize, " provided).");
}
Uint32 MaxDim = 0;
- if( Desc.Type == RESOURCE_DIM_TEX_1D || Desc.Type == RESOURCE_DIM_TEX_1D_ARRAY )
+ if (Desc.Type == RESOURCE_DIM_TEX_1D || Desc.Type == RESOURCE_DIM_TEX_1D_ARRAY)
MaxDim = Desc.Width;
- else if( Desc.Type == RESOURCE_DIM_TEX_2D || Desc.Type == RESOURCE_DIM_TEX_2D_ARRAY || Desc.Type == RESOURCE_DIM_TEX_CUBE || Desc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY )
+ else if (Desc.Type == RESOURCE_DIM_TEX_2D || Desc.Type == RESOURCE_DIM_TEX_2D_ARRAY || Desc.Type == RESOURCE_DIM_TEX_CUBE || Desc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY)
MaxDim = std::max(Desc.Width, Desc.Height);
- else if( Desc.Type == RESOURCE_DIM_TEX_3D )
- MaxDim = std::max( std::max(Desc.Width, Desc.Height), Desc.Depth );
- VERIFY( MaxDim >= (1U << (Desc.MipLevels-1)), "Texture \"", Desc.Name ? Desc.Name : "", "\": Incorrect number of Mip levels (", Desc.MipLevels, ")" );
+ else if (Desc.Type == RESOURCE_DIM_TEX_3D)
+ MaxDim = std::max(std::max(Desc.Width, Desc.Height), Desc.Depth);
+ VERIFY(MaxDim >= (1U << (Desc.MipLevels - 1)), "Texture \"", Desc.Name ? Desc.Name : "", "\": Incorrect number of Mip levels (", Desc.MipLevels, ")");
- if( Desc.SampleCount > 1 )
+ if (Desc.SampleCount > 1)
{
- if( !(Desc.Type == RESOURCE_DIM_TEX_2D || Desc.Type == RESOURCE_DIM_TEX_2D_ARRAY) )
+ if (!(Desc.Type == RESOURCE_DIM_TEX_2D || Desc.Type == RESOURCE_DIM_TEX_2D_ARRAY))
LOG_TEXTURE_ERROR_AND_THROW("Only Texture 2D/Texture 2D Array can be multisampled");
- if( Desc.MipLevels != 1 )
+ if (Desc.MipLevels != 1)
LOG_TEXTURE_ERROR_AND_THROW("Multisampled textures must have one mip level (", Desc.MipLevels, " levels specified)");
- if( Desc.BindFlags & BIND_UNORDERED_ACCESS )
+ if (Desc.BindFlags & BIND_UNORDERED_ACCESS)
LOG_TEXTURE_ERROR_AND_THROW("UAVs are not allowed for multisampled resources");
}
- if( (Desc.BindFlags & BIND_RENDER_TARGET) &&
- ( Desc.Format == TEX_FORMAT_R8_SNORM || Desc.Format == TEX_FORMAT_RG8_SNORM || Desc.Format == TEX_FORMAT_RGBA8_SNORM ||
- Desc.Format == TEX_FORMAT_R16_SNORM || Desc.Format == TEX_FORMAT_RG16_SNORM || Desc.Format == TEX_FORMAT_RGBA16_SNORM ) )
+ if ((Desc.BindFlags & BIND_RENDER_TARGET) &&
+ (Desc.Format == TEX_FORMAT_R8_SNORM || Desc.Format == TEX_FORMAT_RG8_SNORM || Desc.Format == TEX_FORMAT_RGBA8_SNORM ||
+ Desc.Format == TEX_FORMAT_R16_SNORM || Desc.Format == TEX_FORMAT_RG16_SNORM || Desc.Format == TEX_FORMAT_RGBA16_SNORM))
{
- const auto *FmtName = GetTextureFormatAttribs( Desc.Format ).Name;
- LOG_WARNING_MESSAGE( FmtName, " texture is created with BIND_RENDER_TARGET flag set.\n"
- "There might be an issue in OpenGL driver on NVidia hardware: when rendering to SNORM textures, all negative values are clamped to zero.\n"
- "Use UNORM format instead." );
+ const auto* FmtName = GetTextureFormatAttribs(Desc.Format).Name;
+ LOG_WARNING_MESSAGE(FmtName, " texture is created with BIND_RENDER_TARGET flag set.\n"
+ "There might be an issue in OpenGL driver on NVidia hardware: when rendering to SNORM textures, all negative values are clamped to zero.\n"
+ "Use UNORM format instead.");
}
if (Desc.Usage == USAGE_STAGING)
@@ -121,7 +121,7 @@ void ValidateTextureDesc( const TextureDesc& Desc )
if (Desc.CPUAccessFlags == 0)
LOG_TEXTURE_ERROR_AND_THROW("Staging textures must specify CPU access flags");
- if ( (Desc.CPUAccessFlags & (CPU_ACCESS_READ | CPU_ACCESS_WRITE)) == (CPU_ACCESS_READ | CPU_ACCESS_WRITE))
+ if ((Desc.CPUAccessFlags & (CPU_ACCESS_READ | CPU_ACCESS_WRITE)) == (CPU_ACCESS_READ | CPU_ACCESS_WRITE))
LOG_TEXTURE_ERROR_AND_THROW("Staging textures must use exactly one of ACESS_READ or ACCESS_WRITE flags");
}
}
@@ -129,98 +129,106 @@ void ValidateTextureDesc( const TextureDesc& Desc )
void ValidateTextureRegion(const TextureDesc& TexDesc, Uint32 MipLevel, Uint32 Slice, const Box& Box)
{
-#define VERIFY_TEX_PARAMS(Expr, ...) if(!(Expr))LOG_ERROR("Texture \"", TexDesc.Name ? TexDesc.Name : "", "\": ", ##__VA_ARGS__)
+#define VERIFY_TEX_PARAMS(Expr, ...) \
+ do \
+ { \
+ if (!(Expr)) \
+ { \
+ LOG_ERROR("Texture \"", TexDesc.Name ? TexDesc.Name : "", "\": ", ##__VA_ARGS__); \
+ } \
+ } while (false)
+
#ifdef DEVELOPMENT
- VERIFY_TEX_PARAMS( MipLevel < TexDesc.MipLevels, "Mip level (", MipLevel, ") is out of allowed range [0, ", TexDesc.MipLevels-1, "]" );
- VERIFY_TEX_PARAMS( Box.MinX < Box.MaxX, "Invalid X range: ", Box.MinX, "..", Box.MaxX);
- VERIFY_TEX_PARAMS( Box.MinY < Box.MaxY, "Invalid Y range: ", Box.MinY, "..", Box.MaxY);
- VERIFY_TEX_PARAMS( Box.MinZ < Box.MaxZ, "Invalid Z range: ", Box.MinZ, "..", Box.MaxZ);
-
+ VERIFY_TEX_PARAMS(MipLevel < TexDesc.MipLevels, "Mip level (", MipLevel, ") is out of allowed range [0, ", TexDesc.MipLevels - 1, "]");
+ VERIFY_TEX_PARAMS(Box.MinX < Box.MaxX, "Invalid X range: ", Box.MinX, "..", Box.MaxX);
+ VERIFY_TEX_PARAMS(Box.MinY < Box.MaxY, "Invalid Y range: ", Box.MinY, "..", Box.MaxY);
+ VERIFY_TEX_PARAMS(Box.MinZ < Box.MaxZ, "Invalid Z range: ", Box.MinZ, "..", Box.MaxZ);
+
if (TexDesc.Type == RESOURCE_DIM_TEX_1D_ARRAY ||
TexDesc.Type == RESOURCE_DIM_TEX_2D_ARRAY ||
- TexDesc.Type == RESOURCE_DIM_TEX_CUBE ||
+ TexDesc.Type == RESOURCE_DIM_TEX_CUBE ||
TexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY)
{
- VERIFY_TEX_PARAMS( Slice < TexDesc.ArraySize, "Array slice (", Slice, ") is out of range [0,", TexDesc.ArraySize-1, "]" );
+ VERIFY_TEX_PARAMS(Slice < TexDesc.ArraySize, "Array slice (", Slice, ") is out of range [0,", TexDesc.ArraySize - 1, "]");
}
else
{
- VERIFY_TEX_PARAMS( Slice == 0, "Array slice (", Slice, ") must be 0 for non-array textures" );
+ VERIFY_TEX_PARAMS(Slice == 0, "Array slice (", Slice, ") must be 0 for non-array textures");
}
const auto& FmtAttribs = GetTextureFormatAttribs(TexDesc.Format);
Uint32 MipWidth = std::max(TexDesc.Width >> MipLevel, 1U);
- if(FmtAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED)
+ if (FmtAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED)
{
- VERIFY_EXPR( (FmtAttribs.BlockWidth & (FmtAttribs.BlockWidth-1)) == 0);
- Uint32 BlockAlignedMipWidth = (MipWidth + (FmtAttribs.BlockWidth-1)) & ~(FmtAttribs.BlockWidth-1);
- VERIFY_TEX_PARAMS( Box.MaxX <= BlockAlignedMipWidth, "Region max X coordinate (", Box.MaxX, ") is out of allowed range [0, ", BlockAlignedMipWidth, "]" );
- VERIFY_TEX_PARAMS( (Box.MinX % FmtAttribs.BlockWidth) == 0, "For compressed formats, the region min X coordinate (", Box.MinX, ") must be a multiple of block width (", Uint32{FmtAttribs.BlockWidth}, ")" );
- VERIFY_TEX_PARAMS( (Box.MaxX % FmtAttribs.BlockWidth) == 0 || Box.MaxX == MipWidth, "For compressed formats, the region max X coordinate (", Box.MaxX, ") must be a multiple of block width (", Uint32{FmtAttribs.BlockWidth}, ") or equal the mip level width (", MipWidth, ")" );
+ VERIFY_EXPR((FmtAttribs.BlockWidth & (FmtAttribs.BlockWidth - 1)) == 0);
+ Uint32 BlockAlignedMipWidth = (MipWidth + (FmtAttribs.BlockWidth - 1)) & ~(FmtAttribs.BlockWidth - 1);
+ VERIFY_TEX_PARAMS(Box.MaxX <= BlockAlignedMipWidth, "Region max X coordinate (", Box.MaxX, ") is out of allowed range [0, ", BlockAlignedMipWidth, "]");
+ VERIFY_TEX_PARAMS((Box.MinX % FmtAttribs.BlockWidth) == 0, "For compressed formats, the region min X coordinate (", Box.MinX, ") must be a multiple of block width (", Uint32{FmtAttribs.BlockWidth}, ")");
+ VERIFY_TEX_PARAMS((Box.MaxX % FmtAttribs.BlockWidth) == 0 || Box.MaxX == MipWidth, "For compressed formats, the region max X coordinate (", Box.MaxX, ") must be a multiple of block width (", Uint32{FmtAttribs.BlockWidth}, ") or equal the mip level width (", MipWidth, ")");
}
else
- VERIFY_TEX_PARAMS( Box.MaxX <= MipWidth, "Region max X coordinate (", Box.MaxX, ") is out of allowed range [0, ", MipWidth, "]" );
-
- if (TexDesc.Type != RESOURCE_DIM_TEX_1D &&
+ VERIFY_TEX_PARAMS(Box.MaxX <= MipWidth, "Region max X coordinate (", Box.MaxX, ") is out of allowed range [0, ", MipWidth, "]");
+
+ if (TexDesc.Type != RESOURCE_DIM_TEX_1D &&
TexDesc.Type != RESOURCE_DIM_TEX_1D_ARRAY)
{
Uint32 MipHeight = std::max(TexDesc.Height >> MipLevel, 1U);
- if(FmtAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED)
+ if (FmtAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED)
{
- VERIFY_EXPR( (FmtAttribs.BlockHeight & (FmtAttribs.BlockHeight-1)) == 0);
- Uint32 BlockAlignedMipHeight = (MipHeight + (FmtAttribs.BlockHeight-1)) & ~(FmtAttribs.BlockHeight-1);
- VERIFY_TEX_PARAMS( Box.MaxY <= BlockAlignedMipHeight, "Region max Y coordinate (", Box.MaxY, ") is out of allowed range [0, ", BlockAlignedMipHeight, "]" );
- VERIFY_TEX_PARAMS( (Box.MinY % FmtAttribs.BlockHeight) == 0, "For compressed formats, the region min Y coordinate (", Box.MinY, ") must be a multiple of block height (", Uint32{FmtAttribs.BlockHeight}, ")" );
- VERIFY_TEX_PARAMS( (Box.MaxY % FmtAttribs.BlockHeight) == 0 || Box.MaxY == MipHeight, "For compressed formats, the region max Y coordinate (", Box.MaxY, ") must be a multiple of block height (", Uint32{FmtAttribs.BlockHeight}, ") or equal the mip level height (", MipHeight, ")" );
+ VERIFY_EXPR((FmtAttribs.BlockHeight & (FmtAttribs.BlockHeight - 1)) == 0);
+ Uint32 BlockAlignedMipHeight = (MipHeight + (FmtAttribs.BlockHeight - 1)) & ~(FmtAttribs.BlockHeight - 1);
+ VERIFY_TEX_PARAMS(Box.MaxY <= BlockAlignedMipHeight, "Region max Y coordinate (", Box.MaxY, ") is out of allowed range [0, ", BlockAlignedMipHeight, "]");
+ VERIFY_TEX_PARAMS((Box.MinY % FmtAttribs.BlockHeight) == 0, "For compressed formats, the region min Y coordinate (", Box.MinY, ") must be a multiple of block height (", Uint32{FmtAttribs.BlockHeight}, ")");
+ VERIFY_TEX_PARAMS((Box.MaxY % FmtAttribs.BlockHeight) == 0 || Box.MaxY == MipHeight, "For compressed formats, the region max Y coordinate (", Box.MaxY, ") must be a multiple of block height (", Uint32{FmtAttribs.BlockHeight}, ") or equal the mip level height (", MipHeight, ")");
}
else
- VERIFY_TEX_PARAMS( Box.MaxY <= MipHeight, "Region max Y coordinate (", Box.MaxY, ") is out of allowed range [0, ", MipHeight, "]" );
+ VERIFY_TEX_PARAMS(Box.MaxY <= MipHeight, "Region max Y coordinate (", Box.MaxY, ") is out of allowed range [0, ", MipHeight, "]");
}
if (TexDesc.Type == RESOURCE_DIM_TEX_3D)
{
Uint32 MipDepth = std::max(TexDesc.Depth >> MipLevel, 1U);
- VERIFY_TEX_PARAMS( Box.MaxZ <= MipDepth, "Region max Z coordinate (", Box.MaxZ, ") is out of allowed range [0, ", MipDepth, "]" );
+ VERIFY_TEX_PARAMS(Box.MaxZ <= MipDepth, "Region max Z coordinate (", Box.MaxZ, ") is out of allowed range [0, ", MipDepth, "]");
}
else
{
- VERIFY_TEX_PARAMS( Box.MinZ == 0, "Region min Z (", Box.MinZ, ") must be 0 for all but 3D textures" );
- VERIFY_TEX_PARAMS( Box.MaxZ == 1, "Region max Z (", Box.MaxZ, ") must be 1 for all but 3D textures" );
+ VERIFY_TEX_PARAMS(Box.MinZ == 0, "Region min Z (", Box.MinZ, ") must be 0 for all but 3D textures");
+ VERIFY_TEX_PARAMS(Box.MaxZ == 1, "Region max Z (", Box.MaxZ, ") must be 1 for all but 3D textures");
}
#endif
}
-void ValidateUpdateTextureParams( 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);
#ifdef DEVELOPMENT
- VERIFY_TEX_PARAMS( TexDesc.SampleCount == 1, "Only non-multisampled textures can be updated with UpdateData()" );
- VERIFY_TEX_PARAMS( (SubresData.Stride & 0x03) == 0, "Texture data stride (", SubresData.Stride, ") must be at least 32-bit aligned" );
- VERIFY_TEX_PARAMS( (SubresData.DepthStride & 0x03) == 0, "Texture data depth stride (", SubresData.DepthStride, ") must be at least 32-bit aligned" );
-
- auto UpdateRegionWidth = DstBox.MaxX - DstBox.MinX;
- auto UpdateRegionHeight = DstBox.MaxY - DstBox.MinY;
- auto UpdateRegionDepth = DstBox.MaxZ - DstBox.MinZ;
- const auto& FmtAttribs = GetTextureFormatAttribs(TexDesc.Format);
- Uint32 RowSize = 0;
- Uint32 RowCount = 0;
+ VERIFY_TEX_PARAMS(TexDesc.SampleCount == 1, "Only non-multisampled textures can be updated with UpdateData()");
+ VERIFY_TEX_PARAMS((SubresData.Stride & 0x03) == 0, "Texture data stride (", SubresData.Stride, ") must be at least 32-bit aligned");
+ VERIFY_TEX_PARAMS((SubresData.DepthStride & 0x03) == 0, "Texture data depth stride (", SubresData.DepthStride, ") must be at least 32-bit aligned");
+
+ auto UpdateRegionWidth = DstBox.MaxX - DstBox.MinX;
+ auto UpdateRegionHeight = DstBox.MaxY - DstBox.MinY;
+ auto UpdateRegionDepth = DstBox.MaxZ - DstBox.MinZ;
+ const auto& FmtAttribs = GetTextureFormatAttribs(TexDesc.Format);
+ Uint32 RowSize = 0;
+ Uint32 RowCount = 0;
if (FmtAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED)
{
// Align update region size by the block size. This is only necessary when updating
// coarse mip levels. Otherwise UpdateRegionWidth/Height should be multiples of block size
- VERIFY_EXPR( (FmtAttribs.BlockWidth & (FmtAttribs.BlockWidth-1)) == 0);
- VERIFY_EXPR( (FmtAttribs.BlockHeight & (FmtAttribs.BlockHeight-1)) == 0);
- UpdateRegionWidth = (UpdateRegionWidth + (FmtAttribs.BlockWidth-1)) & ~(FmtAttribs.BlockWidth -1);
- UpdateRegionHeight = (UpdateRegionHeight + (FmtAttribs.BlockHeight-1)) & ~(FmtAttribs.BlockHeight-1);
- RowSize = UpdateRegionWidth / Uint32{FmtAttribs.BlockWidth} * Uint32{FmtAttribs.ComponentSize};
- RowCount = UpdateRegionHeight / FmtAttribs.BlockHeight;
+ VERIFY_EXPR((FmtAttribs.BlockWidth & (FmtAttribs.BlockWidth - 1)) == 0);
+ VERIFY_EXPR((FmtAttribs.BlockHeight & (FmtAttribs.BlockHeight - 1)) == 0);
+ UpdateRegionWidth = (UpdateRegionWidth + (FmtAttribs.BlockWidth - 1)) & ~(FmtAttribs.BlockWidth - 1);
+ UpdateRegionHeight = (UpdateRegionHeight + (FmtAttribs.BlockHeight - 1)) & ~(FmtAttribs.BlockHeight - 1);
+ RowSize = UpdateRegionWidth / Uint32{FmtAttribs.BlockWidth} * Uint32{FmtAttribs.ComponentSize};
+ RowCount = UpdateRegionHeight / FmtAttribs.BlockHeight;
}
else
{
- RowSize = UpdateRegionWidth * Uint32{FmtAttribs.ComponentSize} * Uint32{FmtAttribs.NumComponents};
+ RowSize = UpdateRegionWidth * Uint32{FmtAttribs.ComponentSize} * Uint32{FmtAttribs.NumComponents};
RowCount = UpdateRegionHeight;
}
DEV_CHECK_ERR(SubresData.Stride >= RowSize, "Source data stride (", SubresData.Stride, ") is below the image row size (", RowSize, ")");
@@ -229,29 +237,29 @@ void ValidateUpdateTextureParams( const TextureDesc& TexDesc, Uint32 MipLevel, U
#endif
}
-void ValidateCopyTextureParams(const CopyTextureAttribs& CopyAttribs )
+void ValidateCopyTextureParams(const CopyTextureAttribs& CopyAttribs)
{
VERIFY_EXPR(CopyAttribs.pSrcTexture != nullptr && CopyAttribs.pDstTexture != nullptr);
- Box SrcBox;
+ Box SrcBox;
const auto& SrcTexDesc = CopyAttribs.pSrcTexture->GetDesc();
const auto& DstTexDesc = CopyAttribs.pDstTexture->GetDesc();
- auto pSrcBox = CopyAttribs.pSrcBox;
- if( pSrcBox == nullptr )
+ auto pSrcBox = CopyAttribs.pSrcBox;
+ if (pSrcBox == nullptr)
{
auto MipLevelAttribs = GetMipLevelProperties(SrcTexDesc, CopyAttribs.SrcMipLevel);
- SrcBox.MaxX = MipLevelAttribs.LogicalWidth;
- SrcBox.MaxY = MipLevelAttribs.LogicalHeight;
- SrcBox.MaxZ = MipLevelAttribs.Depth;
- pSrcBox = &SrcBox;
+ SrcBox.MaxX = MipLevelAttribs.LogicalWidth;
+ SrcBox.MaxY = MipLevelAttribs.LogicalHeight;
+ SrcBox.MaxZ = MipLevelAttribs.Depth;
+ pSrcBox = &SrcBox;
}
ValidateTextureRegion(SrcTexDesc, CopyAttribs.SrcMipLevel, CopyAttribs.SrcSlice, *pSrcBox);
Box DstBox;
DstBox.MinX = CopyAttribs.DstX;
- DstBox.MaxX = DstBox.MinX + (pSrcBox->MaxX - pSrcBox->MinX);
DstBox.MinY = CopyAttribs.DstY;
- DstBox.MaxY = DstBox.MinY + (pSrcBox->MaxY - pSrcBox->MinY);
DstBox.MinZ = CopyAttribs.DstZ;
+ DstBox.MaxX = DstBox.MinX + (pSrcBox->MaxX - pSrcBox->MinX);
+ DstBox.MaxY = DstBox.MinY + (pSrcBox->MaxY - pSrcBox->MinY);
DstBox.MaxZ = DstBox.MinZ + (pSrcBox->MaxZ - pSrcBox->MinZ);
ValidateTextureRegion(DstTexDesc, CopyAttribs.DstMipLevel, CopyAttribs.DstSlice, DstBox);
}
@@ -263,24 +271,23 @@ void ValidateMapTextureParams(const TextureDesc& TexDesc,
Uint32 MapFlags,
const Box* pMapRegion)
{
- VERIFY_TEX_PARAMS( MipLevel < TexDesc.MipLevels, "Mip level (", MipLevel, ") is out of allowed range [0, ", TexDesc.MipLevels-1, "]" );
+ VERIFY_TEX_PARAMS(MipLevel < TexDesc.MipLevels, "Mip level (", MipLevel, ") is out of allowed range [0, ", TexDesc.MipLevels - 1, "]");
if (TexDesc.Type == RESOURCE_DIM_TEX_1D_ARRAY ||
TexDesc.Type == RESOURCE_DIM_TEX_2D_ARRAY ||
- TexDesc.Type == RESOURCE_DIM_TEX_CUBE ||
+ TexDesc.Type == RESOURCE_DIM_TEX_CUBE ||
TexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY)
{
- VERIFY_TEX_PARAMS( ArraySlice < TexDesc.ArraySize, "Array slice (", ArraySlice, ") is out of range [0,", TexDesc.ArraySize-1, "]" );
+ VERIFY_TEX_PARAMS(ArraySlice < TexDesc.ArraySize, "Array slice (", ArraySlice, ") is out of range [0,", TexDesc.ArraySize - 1, "]");
}
else
{
- VERIFY_TEX_PARAMS( ArraySlice == 0, "Array slice (", ArraySlice, ") must be 0 for non-array textures" );
+ VERIFY_TEX_PARAMS(ArraySlice == 0, "Array slice (", ArraySlice, ") must be 0 for non-array textures");
}
- if(pMapRegion != nullptr)
+ if (pMapRegion != nullptr)
{
ValidateTextureRegion(TexDesc, MipLevel, ArraySlice, *pMapRegion);
}
-
}
-} \ No newline at end of file
+} // namespace Diligent