summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-02-28 05:15:52 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-02-28 05:15:52 +0000
commit59f58900fed7fa5c2ed490d31252950b55308175 (patch)
treea3c5adccae3cf197ccdf514255d01c9e3156970b /Graphics/GraphicsEngineVulkan
parentFixed PipelineLayoutVk (diff)
downloadDiligentCore-59f58900fed7fa5c2ed490d31252950b55308175.tar.gz
DiligentCore-59f58900fed7fa5c2ed490d31252950b55308175.zip
Keeping copy of a shader name in SPIRVShaderResources
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h15
-rw-r--r--Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp4
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp37
3 files changed, 16 insertions, 40 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h
index f49bc342..b4712d70 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h
@@ -107,12 +107,15 @@ namespace Diligent
{
/// Diligent::ShaderResourceLayoutVk class
-// sizeof(ShaderResourceLayoutVk)==64 (MS compiler, x64) - TODO: verify
+// sizeof(ShaderResourceLayoutVk)==56 (MS compiler, x64) - TODO: verify
class ShaderResourceLayoutVk
{
public:
- ShaderResourceLayoutVk(IObject& Owner,
- const VulkanUtilities::VulkanLogicalDevice& LogicalDevice);
+ ShaderResourceLayoutVk(const VulkanUtilities::VulkanLogicalDevice& LogicalDevice) :
+ m_LogicalDevice(LogicalDevice)
+ {
+ }
+
ShaderResourceLayoutVk (const ShaderResourceLayoutVk&) = delete;
ShaderResourceLayoutVk (ShaderResourceLayoutVk&&) = delete;
@@ -271,7 +274,10 @@ public:
void CommitDynamicResources(const ShaderResourceCacheVk& ResourceCache,
VkDescriptorSet vkDynamicDescriptorSet)const;
- const Char* GetShaderName()const;
+ const Char* GetShaderName()const
+ {
+ return m_pResources->GetShaderName();
+ }
const VkResource& GetResource(SHADER_RESOURCE_VARIABLE_TYPE VarType, Uint32 r)const
{
@@ -329,7 +335,6 @@ private:
return reinterpret_cast<ImmutableSamplerPtrType*>(ResourceMemoryEnd)[n];
}
- IObject& m_Owner;
const VulkanUtilities::VulkanLogicalDevice& m_LogicalDevice;
std::unique_ptr<void, STDDeleterRawMem<void> > m_ResourceBuffer;
diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
index 2a60ce96..14f4c962 100644
--- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
@@ -163,7 +163,7 @@ PipelineStateVkImpl :: PipelineStateVkImpl(IReferenceCounters* pRefCounters
m_StaticVarsMgrs = reinterpret_cast<ShaderVariableManagerVk*>(pStaticVarMgrRawMem);
for (Uint32 s=0; s < m_NumShaders; ++s)
{
- new (m_ShaderResourceLayouts + s) ShaderResourceLayoutVk(*this, LogicalDevice);
+ new (m_ShaderResourceLayouts + s) ShaderResourceLayoutVk(LogicalDevice);
auto* pShaderVk = GetShader<const ShaderVkImpl>(s);
ShaderResources[s] = pShaderVk->GetShaderResources();
ShaderSPIRVs[s] = pShaderVk->GetSPIRV();
@@ -172,7 +172,7 @@ PipelineStateVkImpl :: PipelineStateVkImpl(IReferenceCounters* pRefCounters
const auto ShaderTypeInd = GetShaderTypeIndex(ShaderType);
m_ResourceLayoutIndex[ShaderTypeInd] = static_cast<Int8>(s);
- auto* pStaticResLayout = new (m_ShaderResourceLayouts + m_NumShaders + s) ShaderResourceLayoutVk(*this, LogicalDevice);
+ auto* pStaticResLayout = new (m_ShaderResourceLayouts + m_NumShaders + s) ShaderResourceLayoutVk(LogicalDevice);
auto* pStaticResCache = new (m_StaticResCaches + s) ShaderResourceCacheVk(ShaderResourceCacheVk::DbgCacheContentType::StaticShaderResources);
pStaticResLayout->InitializeStaticResourceLayout(ShaderResources[s], ShaderResLayoutAllocator, PipelineDesc.Layout, m_StaticResCaches[s]);
diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp
index 546fd01e..a0835334 100644
--- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp
@@ -90,13 +90,6 @@ static SHADER_RESOURCE_VARIABLE_TYPE GetShaderVariableType(SHADER_TYPE
}
-ShaderResourceLayoutVk::ShaderResourceLayoutVk(IObject& Owner,
- const VulkanUtilities::VulkanLogicalDevice& LogicalDevice) :
- m_Owner(Owner),
- m_LogicalDevice(LogicalDevice)
-{
-}
-
ShaderResourceLayoutVk::~ShaderResourceLayoutVk()
{
auto* Resources = reinterpret_cast<VkResource*>(m_ResourceBuffer.get());
@@ -521,14 +514,16 @@ bool ShaderResourceLayoutVk::VkResource::UpdateCachedResource(ShaderResourceCach
// We cannot use ValidatedCast<> here as the resource retrieved from the
// resource mapping can be of wrong type
RefCntAutoPtr<IDeviceObject> pResource(pObject, InterfaceId);
- if(pResource)
+ if (pResource)
{
if (GetVariableType() != SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC && DstRes.pObject != nullptr)
{
if (DstRes.pObject != pResource)
{
auto VarTypeStr = GetShaderVariableTypeLiteralName(GetVariableType());
- LOG_ERROR_MESSAGE("Non-null resource is already bound to ", VarTypeStr, " shader variable '", SpirvAttribs.GetPrintName(ArrayInd), "' in shader '", ParentResLayout.GetShaderName(), "'. Attempring to bind another resource is an error and will be ignored. Use another shader resource binding instance or label the variable as dynamic.");
+ LOG_ERROR_MESSAGE("Non-null resource is already bound to ", VarTypeStr, " shader variable '", SpirvAttribs.GetPrintName(ArrayInd),
+ "' in shader '", ParentResLayout.GetShaderName(), "'. Attempring to bind another resource is an error and will be ignored. "
+ "Use another shader resource binding instance or label the variable as dynamic.");
}
// Do not update resource if one is already bound unless it is dynamic. This may be
@@ -932,30 +927,6 @@ bool ShaderResourceLayoutVk::dvpVerifyBindings(const ShaderResourceCacheVk& Reso
}
#endif
-
-const Char* ShaderResourceLayoutVk::GetShaderName()const
-{
- RefCntAutoPtr<IPipelineState> pPSO(&m_Owner, IID_PipelineState);
- if (pPSO)
- {
- auto* pPSOVk = pPSO.RawPtr<PipelineStateVkImpl>();
- auto* ppShaders = pPSOVk->GetShaders();
- auto NumShaders = pPSOVk->GetNumShaders();
- for (Uint32 s = 0; s < NumShaders; ++s)
- {
- const auto& ShaderDesc = ppShaders[s]->GetDesc();
- if (ShaderDesc.ShaderType == m_pResources->GetShaderType())
- return ShaderDesc.Name;
- }
- UNEXPECTED("Shader not found");
- }
- else
- {
- UNEXPECTED("Shader resource layout owner must be a shader or a pipeline state");
- }
- return "";
-}
-
void ShaderResourceLayoutVk::InitializeResourceMemoryInCache(ShaderResourceCacheVk& ResourceCache)const
{
auto TotalResources = GetTotalResourceCount();