summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3DBase
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-10-07 16:19:35 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-10-07 16:19:35 +0000
commit42b12901274c2aabee3ddbb9d3a012d28e5f5f7d (patch)
tree8f78dfa0d2ace8192d07671da8676498c3623ded /Graphics/GraphicsEngineD3DBase
parentFixed JNI object reference leak in AndroidFileSystem (diff)
downloadDiligentCore-42b12901274c2aabee3ddbb9d3a012d28e5f5f7d.tar.gz
DiligentCore-42b12901274c2aabee3ddbb9d3a012d28e5f5f7d.zip
Completely reworked shader resource binding implementation in OpenGL backend to make it function similar to other backends
Diffstat (limited to 'Graphics/GraphicsEngineD3DBase')
-rw-r--r--Graphics/GraphicsEngineD3DBase/include/ShaderVariableD3DBase.h48
-rw-r--r--Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp13
2 files changed, 20 insertions, 41 deletions
diff --git a/Graphics/GraphicsEngineD3DBase/include/ShaderVariableD3DBase.h b/Graphics/GraphicsEngineD3DBase/include/ShaderVariableD3DBase.h
index be1f6de9..a8716edb 100644
--- a/Graphics/GraphicsEngineD3DBase/include/ShaderVariableD3DBase.h
+++ b/Graphics/GraphicsEngineD3DBase/include/ShaderVariableD3DBase.h
@@ -23,6 +23,7 @@
#pragma once
+#include "ShaderResourceVariableBase.h"
#include "ShaderResourceVariableD3D.h"
/// \file
@@ -30,46 +31,28 @@
namespace Diligent
{
- template<typename TShaderResourceLayout>
- struct ShaderVariableD3DBase : public IShaderResourceVariableD3D
+ struct D3DVariableIDComparator
{
- ShaderVariableD3DBase(TShaderResourceLayout& ParentResLayout,
- const D3DShaderResourceAttribs& Attribs,
- SHADER_RESOURCE_VARIABLE_TYPE VariableType) :
- m_ParentResLayout (ParentResLayout),
- m_Attribs (Attribs),
- m_VariableType (VariableType)
+ bool operator() (const INTERFACE_ID& IID)const
{
+ return IID == IID_ShaderResourceVariableD3D || IID == IID_ShaderResourceVariable || IID == IID_Unknown;
}
+ };
- virtual IReferenceCounters* GetReferenceCounters()const override final
- {
- return m_ParentResLayout.GetOwner().GetReferenceCounters();
- }
-
- virtual Atomics::Long AddRef()override final
- {
- return m_ParentResLayout.GetOwner().AddRef();
- }
+ template<typename TShaderResourceLayout>
+ struct ShaderVariableD3DBase : public ShaderVariableBase<TShaderResourceLayout, IShaderResourceVariableD3D, D3DVariableIDComparator>
+ {
+ using TBase = ShaderVariableBase<TShaderResourceLayout, IShaderResourceVariableD3D, D3DVariableIDComparator>;
- virtual Atomics::Long Release()override final
+ ShaderVariableD3DBase(TShaderResourceLayout& ParentResLayout,
+ const D3DShaderResourceAttribs& Attribs,
+ SHADER_RESOURCE_VARIABLE_TYPE VariableType) :
+ TBase {ParentResLayout},
+ m_Attribs {Attribs },
+ m_VariableType {VariableType }
{
- return m_ParentResLayout.GetOwner().Release();
}
- void QueryInterface( const INTERFACE_ID& IID, IObject** ppInterface )override final
- {
- if( ppInterface == nullptr )
- return;
-
- *ppInterface = nullptr;
- if( IID == IID_ShaderResourceVariableD3D || IID == IID_ShaderResourceVariable || IID == IID_Unknown )
- {
- *ppInterface = this;
- (*ppInterface)->AddRef();
- }
- }
-
virtual SHADER_RESOURCE_VARIABLE_TYPE GetType()const override final
{
return m_VariableType;
@@ -93,7 +76,6 @@ namespace Diligent
const D3DShaderResourceAttribs& m_Attribs;
protected:
- TShaderResourceLayout& m_ParentResLayout;
const SHADER_RESOURCE_VARIABLE_TYPE m_VariableType;
};
}
diff --git a/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp b/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp
index 6bac589e..066751ea 100644
--- a/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp
+++ b/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp
@@ -117,14 +117,11 @@ Int32 ShaderResources::FindStaticSampler(const D3DShaderResourceAttribs& Resou
{
VERIFY(ResourceAttribs.GetInputType() == D3D_SIT_SAMPLER, "Sampler is expected");
- for (Uint32 s=0; s < ResourceLayoutDesc.NumStaticSamplers; ++s)
- {
- const auto& StSam = ResourceLayoutDesc.StaticSamplers[s];
- if ( ((StSam.ShaderStages & m_ShaderType) != 0) && StreqSuff(ResourceAttribs.Name, StSam.SamplerOrTextureName, m_SamplerSuffix) )
- return s;
- }
-
- return -1;
+ return Diligent::FindStaticSampler(ResourceLayoutDesc.StaticSamplers,
+ ResourceLayoutDesc.NumStaticSamplers,
+ m_ShaderType,
+ ResourceAttribs.Name,
+ m_SamplerSuffix);
}