summaryrefslogtreecommitdiffstats
path: root/Graphics
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-07-25 04:45:59 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-07-25 04:45:59 +0000
commit946884fb264969aa03e5d266d2349c8a74e5cf55 (patch)
treed70f8ec7977f829588e7bf8250ab1040981d3df0 /Graphics
parentUpdated DeviceContextBase to use final types for pipeline state, buffers and ... (diff)
downloadDiligentCore-946884fb264969aa03e5d266d2349c8a74e5cf55.tar.gz
DiligentCore-946884fb264969aa03e5d266d2349c8a74e5cf55.zip
Updated VertexStreamInfo to use final buffer implementation type
Diffstat (limited to 'Graphics')
-rw-r--r--Graphics/GraphicsEngine/include/DeviceContextBase.h15
-rw-r--r--Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp6
-rw-r--r--Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp10
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/VAOCache.h3
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/VAOCache.cpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp8
6 files changed, 23 insertions, 21 deletions
diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.h b/Graphics/GraphicsEngine/include/DeviceContextBase.h
index 1a291a10..037e6ba4 100644
--- a/Graphics/GraphicsEngine/include/DeviceContextBase.h
+++ b/Graphics/GraphicsEngine/include/DeviceContextBase.h
@@ -41,10 +41,11 @@ namespace Diligent
{
/// Describes input vertex stream
+template<typename BufferImplType>
struct VertexStreamInfo
{
/// Strong reference to the buffer object
- RefCntAutoPtr<IBuffer> pBuffer;
+ RefCntAutoPtr<BufferImplType> pBuffer;
Uint32 Offset = 0; ///< Offset in bytes
};
@@ -149,7 +150,7 @@ protected:
RefCntAutoPtr<ISwapChain> m_pSwapChain;
/// Vertex streams. Every stream holds strong reference to the buffer
- VertexStreamInfo m_VertexStreams[MaxBufferSlots];
+ VertexStreamInfo<BufferImplType> m_VertexStreams[MaxBufferSlots];
/// Number of bound vertex streams
Uint32 m_NumVertexStreams = 0;
@@ -227,9 +228,9 @@ inline void DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType
// It is very important to not reset buffers that stay unchanged
// as AddRef()/Release() are not free
for (Uint32 s = 0; s < StartSlot; ++s)
- m_VertexStreams[s] = VertexStreamInfo{};
+ m_VertexStreams[s] = VertexStreamInfo<BufferImplType>{};
for (Uint32 s = StartSlot + NumBuffersSet; s < m_NumVertexStreams; ++s)
- m_VertexStreams[s] = VertexStreamInfo{};
+ m_VertexStreams[s] = VertexStreamInfo<BufferImplType>{};
m_NumVertexStreams = 0;
}
m_NumVertexStreams = std::max(m_NumVertexStreams, StartSlot + NumBuffersSet );
@@ -237,7 +238,7 @@ inline void DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType
for( Uint32 Buff = 0; Buff < NumBuffersSet; ++Buff )
{
auto &CurrStream = m_VertexStreams[StartSlot + Buff];
- CurrStream.pBuffer = ppBuffers ? ppBuffers[Buff] : nullptr;
+ CurrStream.pBuffer = ppBuffers ? ValidatedCast<BufferImplType>(ppBuffers[Buff]) : nullptr;
CurrStream.Offset = pOffsets ? pOffsets[Buff] : 0;
#ifdef DEVELOPMENT
if ( CurrStream.pBuffer )
@@ -252,7 +253,7 @@ inline void DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType
}
// Remove null buffers from the end of the array
while(m_NumVertexStreams > 0 && !m_VertexStreams[m_NumVertexStreams-1].pBuffer)
- m_VertexStreams[m_NumVertexStreams--] = VertexStreamInfo{};
+ m_VertexStreams[m_NumVertexStreams--] = VertexStreamInfo<BufferImplType>{};
}
template<typename BaseInterface, typename BufferImplType, typename TextureViewImplType, typename PipelineStateImplType>
@@ -566,7 +567,7 @@ template<typename BaseInterface, typename BufferImplType, typename TextureViewIm
inline void DeviceContextBase<BaseInterface, BufferImplType, TextureViewImplType, PipelineStateImplType> :: ClearStateCache()
{
for(Uint32 stream=0; stream < m_NumVertexStreams; ++stream)
- m_VertexStreams[stream] = VertexStreamInfo();
+ m_VertexStreams[stream] = VertexStreamInfo<BufferImplType>{};
#ifdef _DEBUG
for(Uint32 stream=m_NumVertexStreams; stream < _countof(m_VertexStreams); ++stream)
{
diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp
index 0692c48c..d810911e 100644
--- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp
@@ -623,12 +623,12 @@ namespace Diligent
bool BindVBs = m_NumVertexStreams != m_NumCommittedD3D11VBs;
- const auto *Strides = pPipelineStateD3D11->GetBufferStrides();
+ const auto* Strides = pPipelineStateD3D11->GetBufferStrides();
for( UINT Slot = 0; Slot < m_NumVertexStreams; ++Slot )
{
- auto &CurrStream = m_VertexStreams[Slot];
+ auto& CurrStream = m_VertexStreams[Slot];
VERIFY( CurrStream.pBuffer, "Attempting to bind a null buffer for rendering" );
- auto* pBuffD3D11Impl = CurrStream.pBuffer.RawPtr<BufferD3D11Impl>();
+ auto* pBuffD3D11Impl = CurrStream.pBuffer.RawPtr();
ID3D11Buffer* pd3d11Buffer = pBuffD3D11Impl->m_pd3d11Buffer;
auto Stride = Strides[Slot];
auto Offset = CurrStream.Offset;
diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
index f490ff9a..2d660718 100644
--- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
@@ -249,9 +249,9 @@ namespace Diligent
{
for( UINT Buff = 0; Buff < m_NumVertexStreams; ++Buff )
{
- auto &CurrStream = m_VertexStreams[Buff];
+ auto& CurrStream = m_VertexStreams[Buff];
VERIFY( CurrStream.pBuffer, "Attempting to bind a null buffer for rendering" );
- auto *pBufferD3D12 = static_cast<BufferD3D12Impl*>(CurrStream.pBuffer.RawPtr());
+ auto* pBufferD3D12 = CurrStream.pBuffer.RawPtr();
if(!pBufferD3D12->CheckAllStates(D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER))
GraphCtx.TransitionResource(pBufferD3D12, D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER);
}
@@ -269,11 +269,11 @@ namespace Diligent
bool DynamicBufferPresent = false;
for( UINT Buff = 0; Buff < m_NumVertexStreams; ++Buff )
{
- auto &CurrStream = m_VertexStreams[Buff];
- auto &VBView = VBViews[Buff];
+ auto& CurrStream = m_VertexStreams[Buff];
+ auto& VBView = VBViews[Buff];
VERIFY( CurrStream.pBuffer, "Attempting to bind a null buffer for rendering" );
- auto *pBufferD3D12 = static_cast<BufferD3D12Impl*>(CurrStream.pBuffer.RawPtr());
+ auto *pBufferD3D12 = CurrStream.pBuffer.RawPtr();
if (pBufferD3D12->GetDesc().Usage == USAGE_DYNAMIC)
{
DynamicBufferPresent = true;
diff --git a/Graphics/GraphicsEngineOpenGL/include/VAOCache.h b/Graphics/GraphicsEngineOpenGL/include/VAOCache.h
index 5b064b50..2160d97f 100644
--- a/Graphics/GraphicsEngineOpenGL/include/VAOCache.h
+++ b/Graphics/GraphicsEngineOpenGL/include/VAOCache.h
@@ -31,6 +31,7 @@
#include "HashUtils.h"
#include "DeviceContextBase.h"
#include "BaseInterfacesGL.h"
+#include "BufferGLImpl.h"
namespace Diligent
{
@@ -50,7 +51,7 @@ public:
const GLObjectWrappers::GLVertexArrayObj& GetVAO( IPipelineState *pPSO,
IBuffer *pIndexBuffer,
- VertexStreamInfo VertexStreams[],
+ VertexStreamInfo<BufferGLImpl> VertexStreams[],
Uint32 NumVertexStreams,
class GLContextState &GLContextState);
const GLObjectWrappers::GLVertexArrayObj& GetEmptyVAO();
diff --git a/Graphics/GraphicsEngineOpenGL/src/VAOCache.cpp b/Graphics/GraphicsEngineOpenGL/src/VAOCache.cpp
index 18ad1ff8..04c2789c 100644
--- a/Graphics/GraphicsEngineOpenGL/src/VAOCache.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/VAOCache.cpp
@@ -73,7 +73,7 @@ void VAOCache::OnDestroyPSO(IPipelineState *pPSO)
const GLObjectWrappers::GLVertexArrayObj& VAOCache::GetVAO( IPipelineState *pPSO,
IBuffer *pIndexBuffer,
- VertexStreamInfo VertexStreams[],
+ VertexStreamInfo<BufferGLImpl> VertexStreams[],
Uint32 NumVertexStreams,
GLContextState &GLContextState )
{
diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
index b4cd4dc9..5cbd0ada 100644
--- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
@@ -292,9 +292,9 @@ namespace Diligent
{
for ( UINT Buff = 0; Buff < m_NumVertexStreams; ++Buff )
{
- auto &CurrStream = m_VertexStreams[Buff];
+ auto& CurrStream = m_VertexStreams[Buff];
VERIFY( CurrStream.pBuffer, "Attempting to bind a null buffer for rendering" );
- auto *pBufferVk = CurrStream.pBuffer.RawPtr<BufferVkImpl>();
+ auto* pBufferVk = CurrStream.pBuffer.RawPtr();
if (!pBufferVk->CheckAccessFlags(VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT))
BufferMemoryBarrier(*pBufferVk, VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT);
}
@@ -313,10 +313,10 @@ namespace Diligent
bool DynamicBufferPresent = false;
for ( UINT slot = 0; slot < m_NumVertexStreams; ++slot )
{
- auto &CurrStream = m_VertexStreams[slot];
+ auto& CurrStream = m_VertexStreams[slot];
VERIFY( CurrStream.pBuffer, "Attempting to bind a null buffer for rendering" );
- auto *pBufferVk = CurrStream.pBuffer.RawPtr<BufferVkImpl>();
+ auto* pBufferVk = CurrStream.pBuffer.RawPtr();
if (pBufferVk->GetDesc().Usage == USAGE_DYNAMIC)
{
DynamicBufferPresent = true;