summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-08-21 03:35:22 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-08-21 03:35:22 +0000
commit86c84f4f12d3b78678dfec7666d8aaf1d138ecc3 (patch)
tree3b90ca13bc1e5ca49f193621aa11caca209e3307 /Graphics/GraphicsEngineD3D12
parentReworked UAV handling in D3D11 device context implementation: fixed potential... (diff)
downloadDiligentCore-86c84f4f12d3b78678dfec7666d8aaf1d138ecc3.tar.gz
DiligentCore-86c84f4f12d3b78678dfec7666d8aaf1d138ecc3.zip
Removed dummy shader variable. Added final kw to implementation classes.
Fixed https://github.com/DiligentGraphics/DiligentCore/issues/22
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h2
-rw-r--r--Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.h2
-rw-r--r--Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h2
-rw-r--r--Graphics/GraphicsEngineD3D12/include/CommandQueueD3D12Impl.h2
-rw-r--r--Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h2
-rw-r--r--Graphics/GraphicsEngineD3D12/include/FenceD3D12Impl.h2
-rw-r--r--Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.h5
-rw-r--r--Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h2
-rw-r--r--Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.h2
-rw-r--r--Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h23
-rw-r--r--Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.h2
-rw-r--r--Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h2
-rw-r--r--Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.h2
-rw-r--r--Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp1
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp24
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp10
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp16
17 files changed, 35 insertions, 66 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h
index b32ddb74..92b668ae 100644
--- a/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h
@@ -40,7 +40,7 @@ namespace Diligent
class FixedBlockMemoryAllocator;
/// Implementation of the Diligent::IBufferD3D12 interface
-class BufferD3D12Impl : public BufferBase<IBufferD3D12, RenderDeviceD3D12Impl, BufferViewD3D12Impl, FixedBlockMemoryAllocator>, public D3D12ResourceBase
+class BufferD3D12Impl final : public BufferBase<IBufferD3D12, RenderDeviceD3D12Impl, BufferViewD3D12Impl, FixedBlockMemoryAllocator>, public D3D12ResourceBase
{
public:
using TBufferBase = BufferBase<IBufferD3D12, RenderDeviceD3D12Impl, BufferViewD3D12Impl, FixedBlockMemoryAllocator>;
diff --git a/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.h
index a722cdf0..facc688c 100644
--- a/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.h
@@ -37,7 +37,7 @@ namespace Diligent
class FixedBlockMemoryAllocator;
/// Implementation of the Diligent::IBufferViewD3D12 interface
-class BufferViewD3D12Impl : public BufferViewBase<IBufferViewD3D12, RenderDeviceD3D12Impl>
+class BufferViewD3D12Impl final : public BufferViewBase<IBufferViewD3D12, RenderDeviceD3D12Impl>
{
public:
using TBufferViewBase = BufferViewBase<IBufferViewD3D12, RenderDeviceD3D12Impl>;
diff --git a/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h
index 2cb36faf..6ab4bf56 100644
--- a/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h
@@ -33,7 +33,7 @@ namespace Diligent
{
/// Implementation of the Diligent::ICommandList interface
-class CommandListD3D12Impl : public CommandListBase<ICommandList, RenderDeviceD3D12Impl>
+class CommandListD3D12Impl final : public CommandListBase<ICommandList, RenderDeviceD3D12Impl>
{
public:
using TCommandListBase = CommandListBase<ICommandList, RenderDeviceD3D12Impl>;
diff --git a/Graphics/GraphicsEngineD3D12/include/CommandQueueD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/CommandQueueD3D12Impl.h
index d30fa2b4..192210f4 100644
--- a/Graphics/GraphicsEngineD3D12/include/CommandQueueD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/CommandQueueD3D12Impl.h
@@ -33,7 +33,7 @@ namespace Diligent
{
/// Implementation of the Diligent::ICommandQueueD3D12 interface
-class CommandQueueD3D12Impl : public ObjectBase<ICommandQueueD3D12>
+class CommandQueueD3D12Impl final : public ObjectBase<ICommandQueueD3D12>
{
public:
using TBase = ObjectBase<ICommandQueueD3D12>;
diff --git a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h
index 4c65e1c2..3fd9c1f8 100644
--- a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h
@@ -40,7 +40,7 @@ namespace Diligent
{
/// Implementation of the Diligent::IDeviceContext interface
-class DeviceContextD3D12Impl : public DeviceContextBase<IDeviceContextD3D12, BufferD3D12Impl, TextureViewD3D12Impl, PipelineStateD3D12Impl>
+class DeviceContextD3D12Impl final : public DeviceContextBase<IDeviceContextD3D12, BufferD3D12Impl, TextureViewD3D12Impl, PipelineStateD3D12Impl>
{
public:
using TDeviceContextBase = DeviceContextBase<IDeviceContextD3D12, BufferD3D12Impl, TextureViewD3D12Impl, PipelineStateD3D12Impl>;
diff --git a/Graphics/GraphicsEngineD3D12/include/FenceD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/FenceD3D12Impl.h
index 4ab564d4..9a1154e6 100644
--- a/Graphics/GraphicsEngineD3D12/include/FenceD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/FenceD3D12Impl.h
@@ -37,7 +37,7 @@ namespace Diligent
class FixedBlockMemoryAllocator;
/// Implementation of the Diligent::IFenceD3D12 interface
-class FenceD3D12Impl : public FenceBase<IFenceD3D12, RenderDeviceD3D12Impl>
+class FenceD3D12Impl final : public FenceBase<IFenceD3D12, RenderDeviceD3D12Impl>
{
public:
using TFenceBase = FenceBase<IFenceD3D12, RenderDeviceD3D12Impl>;
diff --git a/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.h
index 72d66900..df7a8ff6 100644
--- a/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.h
@@ -40,7 +40,7 @@ namespace Diligent
class FixedBlockMemoryAllocator;
/// Implementation of the Diligent::IRenderDeviceD3D12 interface
-class PipelineStateD3D12Impl : public PipelineStateBase<IPipelineStateD3D12, RenderDeviceD3D12Impl>
+class PipelineStateD3D12Impl final : public PipelineStateBase<IPipelineStateD3D12, RenderDeviceD3D12Impl>
{
public:
using TPipelineStateBase = PipelineStateBase<IPipelineStateD3D12, RenderDeviceD3D12Impl>;
@@ -78,14 +78,11 @@ public:
return m_SRBMemAllocator;
}
- IShaderVariable *GetDummyShaderVar(){return &m_DummyVar;}
-
private:
/// D3D12 device
CComPtr<ID3D12PipelineState> m_pd3d12PSO;
RootSignature m_RootSig;
- DummyShaderVariable m_DummyVar;
// Must be defined before default SRB
SRBMemoryAllocator m_SRBMemAllocator;
diff --git a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h
index e0e947f9..8e63405e 100644
--- a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h
@@ -41,7 +41,7 @@ namespace Diligent
{
/// Implementation of the Diligent::IRenderDeviceD3D12 interface
-class RenderDeviceD3D12Impl : public RenderDeviceD3DBase<IRenderDeviceD3D12>
+class RenderDeviceD3D12Impl final : public RenderDeviceD3DBase<IRenderDeviceD3D12>
{
public:
using TRenderDeviceBase = RenderDeviceD3DBase<IRenderDeviceD3D12>;
diff --git a/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.h
index fb9b7681..f5869058 100644
--- a/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.h
@@ -37,7 +37,7 @@ namespace Diligent
class FixedBlockMemoryAllocator;
/// Implementation of the Diligent::ISamplerD3D12 interface
-class SamplerD3D12Impl : public SamplerBase<ISamplerD3D12, RenderDeviceD3D12Impl>
+class SamplerD3D12Impl final : public SamplerBase<ISamplerD3D12, RenderDeviceD3D12Impl>
{
public:
using TSamplerBase = SamplerBase<ISamplerD3D12, RenderDeviceD3D12Impl>;
diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h
index f70e8d32..ecc26865 100644
--- a/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h
@@ -56,13 +56,25 @@ public:
//virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override;
- virtual void BindResources( IResourceMapping* pResourceMapping, Uint32 Flags )override;
+ virtual void BindResources( IResourceMapping* pResourceMapping, Uint32 Flags )override
+ {
+ m_StaticResLayout.BindResources(pResourceMapping, Flags, &m_StaticResCache);
+ }
- virtual IShaderVariable* GetShaderVariable(const Char* Name)override final;
+ virtual IShaderVariable* GetShaderVariable(const Char* Name)override final
+ {
+ return m_StaticResLayout.GetShaderVariable(Name);
+ }
- virtual Uint32 GetVariableCount() const override final;
+ virtual Uint32 GetVariableCount() const override final
+ {
+ return m_StaticResLayout.GetVariableCount();
+ }
- virtual IShaderVariable* GetShaderVariable(Uint32 Index)override final;
+ virtual IShaderVariable* GetShaderVariable(Uint32 Index)override final
+ {
+ return m_StaticResLayout.GetShaderVariable(Index);
+ }
ID3DBlob* GetShaderByteCode(){return m_pShaderByteCode;}
const std::shared_ptr<const ShaderResourcesD3D12>& GetShaderResources()const{return m_pShaderResources;}
@@ -73,9 +85,6 @@ public:
#endif
private:
-
- DummyShaderVariable m_DummyShaderVar; ///< Dummy shader variable
-
// ShaderResources class instance must be referenced through the shared pointer, because
// it is referenced by ShaderResourceLayoutD3D12 class instances
std::shared_ptr<const ShaderResourcesD3D12> m_pShaderResources;
diff --git a/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.h
index 30153804..eca54318 100644
--- a/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.h
@@ -36,7 +36,7 @@ namespace Diligent
class ITextureViewD3D12;
class IMemoryAllocator;
/// Implementation of the Diligent::ISwapChainD3D12 interface
-class SwapChainD3D12Impl : public SwapChainD3DBase<ISwapChainD3D12, IDXGISwapChain3>
+class SwapChainD3D12Impl final : public SwapChainD3DBase<ISwapChainD3D12, IDXGISwapChain3>
{
public:
using TSwapChainBase = SwapChainD3DBase<ISwapChainD3D12, IDXGISwapChain3>;
diff --git a/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h
index 81353c01..65f0d493 100644
--- a/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h
@@ -39,7 +39,7 @@ namespace Diligent
class FixedBlockMemoryAllocator;
/// Base implementation of the Diligent::ITextureD3D12 interface
-class TextureD3D12Impl : public TextureBase<ITextureD3D12, RenderDeviceD3D12Impl, TextureViewD3D12Impl, FixedBlockMemoryAllocator>, public D3D12ResourceBase
+class TextureD3D12Impl final : public TextureBase<ITextureD3D12, RenderDeviceD3D12Impl, TextureViewD3D12Impl, FixedBlockMemoryAllocator>, public D3D12ResourceBase
{
public:
using TTextureBase = TextureBase<ITextureD3D12, RenderDeviceD3D12Impl, TextureViewD3D12Impl, FixedBlockMemoryAllocator>;
diff --git a/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.h
index b220dde8..444c32c6 100644
--- a/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.h
@@ -37,7 +37,7 @@ namespace Diligent
class FixedBlockMemoryAllocator;
/// Implementation of the Diligent::ITextureViewD3D12 interface
-class TextureViewD3D12Impl : public TextureViewBase<ITextureViewD3D12, RenderDeviceD3D12Impl>
+class TextureViewD3D12Impl final : public TextureViewBase<ITextureViewD3D12, RenderDeviceD3D12Impl>
{
public:
using TTextureViewBase = TextureViewBase<ITextureViewD3D12, RenderDeviceD3D12Impl>;
diff --git a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
index 9f1f2324..55771a03 100644
--- a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
@@ -63,7 +63,6 @@ PipelineStateD3D12Impl :: PipelineStateD3D12Impl(IReferenceCounters* pRefCo
RenderDeviceD3D12Impl* pDeviceD3D12,
const PipelineStateDesc& PipelineDesc) :
TPipelineStateBase(pRefCounters, pDeviceD3D12, PipelineDesc),
- m_DummyVar(*this),
m_SRBMemAllocator(GetRawAllocator()),
m_pDefaultShaderResBinding(nullptr, STDDeleter<ShaderResourceBindingD3D12Impl, FixedBlockMemoryAllocator>(pDeviceD3D12->GetSRBAllocator()) )
{
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp
index d92e4e14..f03d194d 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp
@@ -42,7 +42,6 @@ ShaderD3D12Impl::ShaderD3D12Impl(IReferenceCounters* pRefCounters,
TShaderBase(pRefCounters, pRenderDeviceD3D12, ShaderCreationAttribs.Desc),
ShaderD3DBase(ShaderCreationAttribs),
m_StaticResLayout(*this, GetRawAllocator()),
- m_DummyShaderVar(*this),
m_StaticResCache(ShaderResourceCacheD3D12::DbgCacheContentType::StaticShaderResources)
{
// Load shader resources
@@ -61,29 +60,6 @@ ShaderD3D12Impl::~ShaderD3D12Impl()
{
}
-void ShaderD3D12Impl::BindResources(IResourceMapping* pResourceMapping, Uint32 Flags)
-{
- m_StaticResLayout.BindResources(pResourceMapping, Flags, &m_StaticResCache);
-}
-
-IShaderVariable* ShaderD3D12Impl::GetShaderVariable(const Char* Name)
-{
- auto *pVar = m_StaticResLayout.GetShaderVariable(Name);
- if(pVar == nullptr)
- pVar = &m_DummyShaderVar;
- return pVar;
-}
-
-Uint32 ShaderD3D12Impl::GetVariableCount()const
-{
- return m_StaticResLayout.GetVariableCount();
-}
-
-IShaderVariable* ShaderD3D12Impl::GetShaderVariable(Uint32 Index)
-{
- return m_StaticResLayout.GetShaderVariable(Index);
-}
-
#ifdef VERIFY_SHADER_BINDINGS
void ShaderD3D12Impl::DbgVerifyStaticResourceBindings()
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp
index 0d15ef8b..8c70ae89 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp
@@ -92,13 +92,9 @@ IShaderVariable *ShaderResourceBindingD3D12Impl::GetVariable(SHADER_TYPE ShaderT
if (ResLayoutInd < 0)
{
LOG_ERROR("Failed to find shader variable \"", Name,"\" in shader resource binding: shader type ", GetShaderTypeLiteralName(ShaderType), " is not initialized");
- return ValidatedCast<PipelineStateD3D12Impl>(GetPipelineState())->GetDummyShaderVar();
+ return nullptr;
}
- auto* pVar = m_pResourceLayouts[ResLayoutInd].GetShaderVariable(Name);
- if(pVar == nullptr)
- pVar = ValidatedCast<PipelineStateD3D12Impl>(GetPipelineState())->GetDummyShaderVar();
-
- return pVar;
+ return m_pResourceLayouts[ResLayoutInd].GetShaderVariable(Name);
}
Uint32 ShaderResourceBindingD3D12Impl::GetVariableCount(SHADER_TYPE ShaderType) const
@@ -121,7 +117,7 @@ IShaderVariable* ShaderResourceBindingD3D12Impl::GetVariable(SHADER_TYPE ShaderT
if (ResLayoutInd < 0)
{
LOG_ERROR("Failed to find shader variable at index ", Index, " in shader resource binding: shader type ", GetShaderTypeLiteralName(ShaderType), " is not initialized");
- return ValidatedCast<PipelineStateD3D12Impl>(GetPipelineState())->GetDummyShaderVar();
+ return nullptr;
}
return m_pResourceLayouts[ResLayoutInd].GetShaderVariable(Index);
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp
index 70f9c74e..ddba7731 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp
@@ -855,30 +855,22 @@ void ShaderResourceLayoutD3D12::BindResources(IResourceMapping* pR
IShaderVariable* ShaderResourceLayoutD3D12::GetShaderVariable(const Char* Name)
{
- IShaderVariable* pVar = nullptr;
#if USE_VARIABLE_HASH_MAP
// Name will be implicitly converted to HashMapStringKey without making a copy
auto it = m_VariableHash.find( Name );
if( it != m_VariableHash.end() )
- pVar = it->second;
+ return it->second;
#else
Uint32 TotalResources = GetTotalSrvCbvUavCount();
- for(Uint32 r=0; r < TotalResources; ++r)
+ for (Uint32 r=0; r < TotalResources; ++r)
{
auto &Res = GetSrvCbvUav(r);
if (strcmp(Res.Attribs.Name, Name) == 0)
- {
- pVar = &Res;
- break;
- }
+ return &Res;
}
#endif
- if(pVar == nullptr)
- {
- LOG_ERROR_MESSAGE( "Shader variable \"", Name, "\" is not found in shader \"", GetShaderName(), "\" (", GetShaderTypeLiteralName(m_pResources->GetShaderType()), "). Attempts to set the variable will be silently ignored." );
- }
- return pVar;
+ return nullptr;
}
IShaderVariable* ShaderResourceLayoutD3D12::GetShaderVariable( Uint32 Index )