summaryrefslogtreecommitdiffstats
path: root/Graphics
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-04-25 05:17:09 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-04-25 05:17:09 +0000
commitf3698c9127d6e384eabe779b8fb3519c94e0babb (patch)
tree9e24ffe8d89b58d464766d7c03ecabe4fe62d466 /Graphics
parentAdded slerp; updated Quaternion in math lib (diff)
downloadDiligentCore-f3698c9127d6e384eabe779b8fb3519c94e0babb.tar.gz
DiligentCore-f3698c9127d6e384eabe779b8fb3519c94e0babb.zip
Added IShaderResourceVariable::IsBound method (updated API version to 240024)
Diffstat (limited to 'Graphics')
-rw-r--r--Graphics/GraphicsEngine/interface/APIInfo.h2
-rw-r--r--Graphics/GraphicsEngine/interface/ShaderResourceVariable.h12
-rw-r--r--Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h38
-rwxr-xr-xGraphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp39
-rw-r--r--Graphics/GraphicsEngineD3D12/include/ShaderVariableD3D12.h5
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/GLProgramResources.h6
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.h5
7 files changed, 58 insertions, 49 deletions
diff --git a/Graphics/GraphicsEngine/interface/APIInfo.h b/Graphics/GraphicsEngine/interface/APIInfo.h
index f1c89e58..fd6ef747 100644
--- a/Graphics/GraphicsEngine/interface/APIInfo.h
+++ b/Graphics/GraphicsEngine/interface/APIInfo.h
@@ -26,7 +26,7 @@
/// \file
/// Diligent API information
-#define DILIGENT_API_VERSION 240023
+#define DILIGENT_API_VERSION 240024
#include "../../../Primitives/interface/BasicTypes.h"
diff --git a/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h b/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h
index 1bf9fdfd..477c7380 100644
--- a/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h
+++ b/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h
@@ -120,13 +120,19 @@ public:
virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements) = 0;
/// Returns the shader resource variable type
- virtual SHADER_RESOURCE_VARIABLE_TYPE GetType()const = 0;
+ virtual SHADER_RESOURCE_VARIABLE_TYPE GetType() const = 0;
/// Returns shader resource description. See Diligent::ShaderResourceDesc.
- virtual ShaderResourceDesc GetResourceDesc()const = 0;
+ virtual ShaderResourceDesc GetResourceDesc() const = 0;
/// Returns the variable index that can be used to access the variable.
- virtual Uint32 GetIndex()const = 0;
+ virtual Uint32 GetIndex() const = 0;
+
+ /// Returns true if non-null resource is bound to this variable.
+
+ /// \param [in] ArrayIndex - Resource array index. Must be 0 for
+ /// non-array variables.
+ virtual bool IsBound(Uint32 ArrayIndex) const = 0;
};
}
diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h b/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h
index bfc39727..d19a611b 100644
--- a/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h
+++ b/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h
@@ -87,7 +87,11 @@ public:
BindResource(ppObjects[elem], FirstElement+elem);
}
- __forceinline bool IsBound(Uint32 ArrayIndex)const;
+ virtual bool IsBound(Uint32 ArrayIndex)const override final
+ {
+ VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount);
+ return m_ParentResLayout.m_ResourceCache.IsCBBound(m_Attribs.BindPoint + ArrayIndex);
+ }
};
struct TexSRVBindInfo final : ShaderVariableD3D11Base
@@ -110,7 +114,12 @@ public:
BindResource(ppObjects[elem], FirstElement+elem);
}
- __forceinline bool IsBound(Uint32 ArrayIndex)const;
+ virtual bool IsBound(Uint32 ArrayIndex)const override final
+ {
+ VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount);
+ return m_ParentResLayout.m_ResourceCache.IsSRVBound(m_Attribs.BindPoint + ArrayIndex, true);
+ }
+
bool ValidSamplerAssigned() const {return SamplerIndex != InvalidSamplerIndex;}
@@ -136,7 +145,11 @@ public:
BindResource(ppObjects[elem], FirstElement+elem);
}
- __forceinline bool IsBound(Uint32 ArrayIndex)const;
+ __forceinline virtual bool IsBound(Uint32 ArrayIndex)const override final
+ {
+ VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount);
+ return m_ParentResLayout.m_ResourceCache.IsUAVBound(m_Attribs.BindPoint + ArrayIndex, true);
+ }
};
struct BuffUAVBindInfo final : ShaderVariableD3D11Base
@@ -157,7 +170,12 @@ public:
BindResource(ppObjects[elem], FirstElement+elem);
}
- __forceinline bool IsBound(Uint32 ArrayIndex)const;
+ virtual bool IsBound(Uint32 ArrayIndex)const override final
+ {
+ VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount);
+ return m_ParentResLayout.m_ResourceCache.IsUAVBound(m_Attribs.BindPoint + ArrayIndex, false);
+ }
+
};
struct BuffSRVBindInfo final : ShaderVariableD3D11Base
@@ -178,7 +196,11 @@ public:
BindResource(ppObjects[elem], FirstElement+elem);
}
- __forceinline bool IsBound(Uint32 ArrayIndex)const;
+ virtual bool IsBound(Uint32 ArrayIndex)const override final
+ {
+ VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount);
+ return m_ParentResLayout.m_ResourceCache.IsSRVBound(m_Attribs.BindPoint + ArrayIndex, false);
+ }
};
struct SamplerBindInfo final : ShaderVariableD3D11Base
@@ -199,7 +221,11 @@ public:
BindResource(ppObjects[elem], FirstElement+elem);
}
- __forceinline bool IsBound(Uint32 ArrayIndex)const;
+ virtual bool IsBound(Uint32 ArrayIndex)const override final
+ {
+ VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount);
+ return m_ParentResLayout.m_ResourceCache.IsSamplerBound(m_Attribs.BindPoint + ArrayIndex);
+ }
};
// dbgResourceCache is only used for sanity check and as a remainder that the resource cache must be alive
diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp
index 4ac61366..7f8623b0 100755
--- a/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp
@@ -441,13 +441,6 @@ void ShaderResourceLayoutD3D11::ConstBuffBindInfo::BindResource(IDeviceObject* p
-bool ShaderResourceLayoutD3D11::ConstBuffBindInfo::IsBound(Uint32 ArrayIndex)const
-{
- VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount);
- return m_ParentResLayout.m_ResourceCache.IsCBBound(m_Attribs.BindPoint + ArrayIndex);
-}
-
-
#ifdef DEVELOPMENT
template<typename TResourceViewType, ///< Type of the view (ITextureViewD3D11 or IBufferViewD3D11)
@@ -665,38 +658,6 @@ void ShaderResourceLayoutD3D11::BuffUAVBindInfo::BindResource(IDeviceObject* pVi
}
-bool ShaderResourceLayoutD3D11::TexSRVBindInfo::IsBound(Uint32 ArrayIndex)const
-{
- VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount);
- return m_ParentResLayout.m_ResourceCache.IsSRVBound(m_Attribs.BindPoint + ArrayIndex, true);
-}
-
-
-bool ShaderResourceLayoutD3D11::BuffSRVBindInfo::IsBound(Uint32 ArrayIndex)const
-{
- VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount);
- return m_ParentResLayout.m_ResourceCache.IsSRVBound(m_Attribs.BindPoint + ArrayIndex, false);
-}
-
-bool ShaderResourceLayoutD3D11::TexUAVBindInfo::IsBound(Uint32 ArrayIndex)const
-{
- VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount);
- return m_ParentResLayout.m_ResourceCache.IsUAVBound(m_Attribs.BindPoint + ArrayIndex, true);
-}
-
-bool ShaderResourceLayoutD3D11::BuffUAVBindInfo::IsBound(Uint32 ArrayIndex)const
-{
- VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount);
- return m_ParentResLayout.m_ResourceCache.IsUAVBound(m_Attribs.BindPoint + ArrayIndex, false);
-}
-
-bool ShaderResourceLayoutD3D11::SamplerBindInfo::IsBound(Uint32 ArrayIndex)const
-{
- VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount);
- return m_ParentResLayout.m_ResourceCache.IsSamplerBound(m_Attribs.BindPoint + ArrayIndex);
-}
-
-
// Helper template class that facilitates binding CBs, SRVs, and UAVs
class BindResourceHelper
diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderVariableD3D12.h b/Graphics/GraphicsEngineD3D12/include/ShaderVariableD3D12.h
index 69cc3829..6a8b3130 100644
--- a/Graphics/GraphicsEngineD3D12/include/ShaderVariableD3D12.h
+++ b/Graphics/GraphicsEngineD3D12/include/ShaderVariableD3D12.h
@@ -191,6 +191,11 @@ public:
return m_ParentManager.GetVariableIndex(*this);
}
+ virtual bool IsBound(Uint32 ArrayIndex) const override final
+ {
+ return m_Resource.IsBound(ArrayIndex, m_ParentManager.m_ResourceCache);
+ }
+
const ShaderResourceLayoutD3D12::D3D12Resource& GetResource()const
{
return m_Resource;
diff --git a/Graphics/GraphicsEngineOpenGL/include/GLProgramResources.h b/Graphics/GraphicsEngineOpenGL/include/GLProgramResources.h
index 0e076db6..b0ebfa06 100644
--- a/Graphics/GraphicsEngineOpenGL/include/GLProgramResources.h
+++ b/Graphics/GraphicsEngineOpenGL/include/GLProgramResources.h
@@ -128,6 +128,12 @@ namespace Diligent
return VariableIndex;
}
+ virtual bool IsBound(Uint32 ArrayIndex) const override final
+ {
+ VERIFY(ArrayIndex < ArraySize, "Array index (", ArrayIndex, ") is out of range");
+ return pResources[ArrayIndex] != nullptr;
+ }
+
virtual ShaderResourceDesc GetResourceDesc()const override final
{
ShaderResourceDesc ResourceDesc;
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.h b/Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.h
index b67fcf5e..65d5b05c 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.h
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.h
@@ -184,6 +184,11 @@ public:
return m_ParentManager.GetVariableIndex(*this);
}
+ virtual bool IsBound(Uint32 ArrayIndex) const override final
+ {
+ return m_Resource.IsBound(ArrayIndex, m_ParentManager.m_ResourceCache);
+ }
+
const ShaderResourceLayoutVk::VkResource& GetResource()const
{
return m_Resource;