summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorazhirnov <zh1dron@gmail.com>2021-01-26 07:16:33 +0000
committerazhirnov <zh1dron@gmail.com>2021-01-26 07:16:33 +0000
commit21bc76cb707adbd844395a07c7e7f0ecf5c881db (patch)
treee1b95f6b03e3bb92a90c3437a764aa0e936df8c7 /Graphics/GraphicsEngineVulkan
parentallow to combine graphics PRS with mesh pipeline (diff)
downloadDiligentCore-21bc76cb707adbd844395a07c7e7f0ecf5c881db.tar.gz
DiligentCore-21bc76cb707adbd844395a07c7e7f0ecf5c881db.zip
minor improvements
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.hpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.hpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp30
-rw-r--r--Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp75
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp9
6 files changed, 72 insertions, 48 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.hpp
index 70ff48f4..00ca6f64 100644
--- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.hpp
@@ -487,7 +487,7 @@ private:
using ShaderResourceArray = std::array<ShaderResourceBindingVkImpl*, MAX_RESOURCE_SIGNATURES>;
using VkDescSetArray = std::array<VkDescriptorSet, MAX_RESOURCE_SIGNATURES * MAX_DESCR_SET_PER_SIGNATURE>;
using Bitfield = Uint8;
- static_assert(sizeof(Bitfield) * 8 >= MAX_RESOURCE_SIGNATURES, "AZ TODO");
+ static_assert(sizeof(Bitfield) * 8 >= MAX_RESOURCE_SIGNATURES, "not enought space to store MAX_RESOURCE_SIGNATURES bits");
Bitfield ActiveSRBMask = 0; // indicates which SRB is active in current PSO
Bitfield PendingSRB = 0; // 1 bit if new descriptor set must be bound
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp
index 84ce03d9..56ccf5c6 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp
@@ -52,7 +52,7 @@ public:
ShaderResourceBindingVkImpl(IReferenceCounters* pRefCounters,
PipelineResourceSignatureVkImpl* pPRS,
- bool IsPSOInternal);
+ bool IsDeviceInternal);
~ShaderResourceBindingVkImpl();
IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_ShaderResourceBindingVk, TBase)
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.hpp b/Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.hpp
index 831542f6..ad05cd9d 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.hpp
@@ -63,12 +63,12 @@
#include "ShaderResourceVariableBase.hpp"
#include "ShaderResourceCacheVk.hpp"
+#include "PipelineResourceSignatureVkImpl.hpp"
namespace Diligent
{
class ShaderVariableVkImpl;
-class PipelineResourceSignatureVkImpl;
// sizeof(ShaderVariableManagerVk) == 32 (x64, msvc, Release)
class ShaderVariableManagerVk
diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
index 2817a53a..eb24d1f9 100644
--- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
@@ -994,6 +994,11 @@ void PipelineStateVkImpl::Destruct()
bool PipelineStateVkImpl::IsCompatibleWith(const IPipelineState* pPSO) const
{
+ VERIFY_EXPR(pPSO != nullptr);
+
+ if (pPSO == this)
+ return true;
+
const auto& lhs = m_PipelineLayout;
const auto& rhs = ValidatedCast<const PipelineStateVkImpl>(pPSO)->m_PipelineLayout;
@@ -1015,8 +1020,11 @@ void PipelineStateVkImpl::CreateShaderResourceBinding(IShaderResourceBinding** p
*ppShaderResourceBinding = nullptr;
if (GetResourceSignatureCount() != 1)
+ {
+ LOG_ERROR_MESSAGE("PipelineState::CreateShaderResourceBinding is only allowed for pipelines that use a single "
+ "resource signature. Use IPipelineResourceSignature::CreateShaderResourceBinding instead.");
return;
-
+ }
return GetResourceSignature(0)->CreateShaderResourceBinding(ppShaderResourceBinding, InitStaticResources);
}
@@ -1024,8 +1032,11 @@ IShaderResourceVariable* PipelineStateVkImpl::GetStaticVariableByName(SHADER_TYP
const Char* Name)
{
if (GetResourceSignatureCount() != 1)
+ {
+ LOG_ERROR_MESSAGE("PipelineState::GetStaticVariableByName is only allowed for pipelines that use a single "
+ "resource signature. Use IPipelineResourceSignature::GetStaticVariableByName instead.");
return nullptr;
-
+ }
return GetResourceSignature(0)->GetStaticVariableByName(ShaderType, Name);
}
@@ -1033,24 +1044,33 @@ IShaderResourceVariable* PipelineStateVkImpl::GetStaticVariableByIndex(SHADER_TY
Uint32 Index)
{
if (GetResourceSignatureCount() != 1)
+ {
+ LOG_ERROR_MESSAGE("PipelineState::GetStaticVariableByIndex is only allowed for pipelines that use a single "
+ "resource signature. Use IPipelineResourceSignature::GetStaticVariableByIndex instead.");
return nullptr;
-
+ }
return GetResourceSignature(0)->GetStaticVariableByIndex(ShaderType, Index);
}
Uint32 PipelineStateVkImpl::GetStaticVariableCount(SHADER_TYPE ShaderType) const
{
if (GetResourceSignatureCount() != 1)
+ {
+ LOG_ERROR_MESSAGE("PipelineState::GetStaticVariableCount is only allowed for pipelines that use a single "
+ "resource signature. Use IPipelineResourceSignature::GetStaticVariableCount instead.");
return 0;
-
+ }
return GetResourceSignature(0)->GetStaticVariableCount(ShaderType);
}
void PipelineStateVkImpl::BindStaticResources(Uint32 ShaderFlags, IResourceMapping* pResourceMapping, Uint32 Flags)
{
if (GetResourceSignatureCount() != 1)
+ {
+ LOG_ERROR_MESSAGE("PipelineState::BindStaticResources is only allowed for pipelines that use a single "
+ "resource signature. Use IPipelineResourceSignature::BindStaticResources instead.");
return;
-
+ }
return GetResourceSignature(0)->BindStaticResources(ShaderFlags, pResourceMapping, Flags);
}
diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
index dcf812b6..bd956877 100644
--- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
@@ -752,13 +752,14 @@ void RenderDeviceVkImpl::CreateRenderPass(const RenderPassDesc& Desc, IRenderPas
void RenderDeviceVkImpl::CreateFramebuffer(const FramebufferDesc& Desc, IFramebuffer** ppFramebuffer)
{
- CreateDeviceObject("Framebuffer", Desc, ppFramebuffer,
- [&]() //
- {
- FramebufferVkImpl* pFramebufferVk(NEW_RC_OBJ(m_FramebufferAllocator, "FramebufferVkImpl instance", FramebufferVkImpl)(this, Desc));
- pFramebufferVk->QueryInterface(IID_Framebuffer, reinterpret_cast<IObject**>(ppFramebuffer));
- OnCreateDeviceObject(pFramebufferVk);
- });
+ CreateDeviceObject(
+ "Framebuffer", Desc, ppFramebuffer,
+ [&]() //
+ {
+ FramebufferVkImpl* pFramebufferVk(NEW_RC_OBJ(m_FramebufferAllocator, "FramebufferVkImpl instance", FramebufferVkImpl)(this, Desc));
+ pFramebufferVk->QueryInterface(IID_Framebuffer, reinterpret_cast<IObject**>(ppFramebuffer));
+ OnCreateDeviceObject(pFramebufferVk);
+ });
}
void RenderDeviceVkImpl::CreateBLASFromVulkanResource(VkAccelerationStructureKHR vkBLAS,
@@ -780,13 +781,14 @@ void RenderDeviceVkImpl::CreateBLASFromVulkanResource(VkAccelerationStructureKHR
void RenderDeviceVkImpl::CreateBLAS(const BottomLevelASDesc& Desc,
IBottomLevelAS** ppBLAS)
{
- CreateDeviceObject("BottomLevelAS", Desc, ppBLAS,
- [&]() //
- {
- BottomLevelASVkImpl* pBottomLevelASVk(NEW_RC_OBJ(m_BLASAllocator, "BottomLevelASVkImpl instance", BottomLevelASVkImpl)(this, Desc));
- pBottomLevelASVk->QueryInterface(IID_BottomLevelAS, reinterpret_cast<IObject**>(ppBLAS));
- OnCreateDeviceObject(pBottomLevelASVk);
- });
+ CreateDeviceObject(
+ "BottomLevelAS", Desc, ppBLAS,
+ [&]() //
+ {
+ BottomLevelASVkImpl* pBottomLevelASVk(NEW_RC_OBJ(m_BLASAllocator, "BottomLevelASVkImpl instance", BottomLevelASVkImpl)(this, Desc));
+ pBottomLevelASVk->QueryInterface(IID_BottomLevelAS, reinterpret_cast<IObject**>(ppBLAS));
+ OnCreateDeviceObject(pBottomLevelASVk);
+ });
}
void RenderDeviceVkImpl::CreateTLASFromVulkanResource(VkAccelerationStructureKHR vkTLAS,
@@ -808,25 +810,27 @@ void RenderDeviceVkImpl::CreateTLASFromVulkanResource(VkAccelerationStructureKHR
void RenderDeviceVkImpl::CreateTLAS(const TopLevelASDesc& Desc,
ITopLevelAS** ppTLAS)
{
- CreateDeviceObject("TopLevelAS", Desc, ppTLAS,
- [&]() //
- {
- TopLevelASVkImpl* pTopLevelASVk(NEW_RC_OBJ(m_TLASAllocator, "TopLevelASVkImpl instance", TopLevelASVkImpl)(this, Desc));
- pTopLevelASVk->QueryInterface(IID_TopLevelAS, reinterpret_cast<IObject**>(ppTLAS));
- OnCreateDeviceObject(pTopLevelASVk);
- });
+ CreateDeviceObject(
+ "TopLevelAS", Desc, ppTLAS,
+ [&]() //
+ {
+ TopLevelASVkImpl* pTopLevelASVk(NEW_RC_OBJ(m_TLASAllocator, "TopLevelASVkImpl instance", TopLevelASVkImpl)(this, Desc));
+ pTopLevelASVk->QueryInterface(IID_TopLevelAS, reinterpret_cast<IObject**>(ppTLAS));
+ OnCreateDeviceObject(pTopLevelASVk);
+ });
}
void RenderDeviceVkImpl::CreateSBT(const ShaderBindingTableDesc& Desc,
IShaderBindingTable** ppSBT)
{
- CreateDeviceObject("ShaderBindingTable", Desc, ppSBT,
- [&]() //
- {
- ShaderBindingTableVkImpl* pSBTVk(NEW_RC_OBJ(m_SBTAllocator, "ShaderBindingTableVkImpl instance", ShaderBindingTableVkImpl)(this, Desc));
- pSBTVk->QueryInterface(IID_ShaderBindingTable, reinterpret_cast<IObject**>(ppSBT));
- OnCreateDeviceObject(pSBTVk);
- });
+ CreateDeviceObject(
+ "ShaderBindingTable", Desc, ppSBT,
+ [&]() //
+ {
+ ShaderBindingTableVkImpl* pSBTVk(NEW_RC_OBJ(m_SBTAllocator, "ShaderBindingTableVkImpl instance", ShaderBindingTableVkImpl)(this, Desc));
+ pSBTVk->QueryInterface(IID_ShaderBindingTable, reinterpret_cast<IObject**>(ppSBT));
+ OnCreateDeviceObject(pSBTVk);
+ });
}
void RenderDeviceVkImpl::CreatePipelineResourceSignature(const PipelineResourceSignatureDesc& Desc,
@@ -839,13 +843,14 @@ void RenderDeviceVkImpl::CreatePipelineResourceSignature(const PipelineResourceS
IPipelineResourceSignature** ppSignature,
bool IsDeviceInternal)
{
- CreateDeviceObject("PipelineResourceSignature", Desc, ppSignature,
- [&]() //
- {
- PipelineResourceSignatureVkImpl* pPRSVk(NEW_RC_OBJ(m_PipeResSignAllocator, "PipelineResourceSignatureVkImpl instance", PipelineResourceSignatureVkImpl)(this, Desc, IsDeviceInternal));
- pPRSVk->QueryInterface(IID_PipelineResourceSignature, reinterpret_cast<IObject**>(ppSignature));
- OnCreateDeviceObject(pPRSVk);
- });
+ CreateDeviceObject(
+ "PipelineResourceSignature", Desc, ppSignature,
+ [&]() //
+ {
+ PipelineResourceSignatureVkImpl* pPRSVk(NEW_RC_OBJ(m_PipeResSignAllocator, "PipelineResourceSignatureVkImpl instance", PipelineResourceSignatureVkImpl)(this, Desc, IsDeviceInternal));
+ pPRSVk->QueryInterface(IID_PipelineResourceSignature, reinterpret_cast<IObject**>(ppSignature));
+ OnCreateDeviceObject(pPRSVk);
+ });
}
} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp
index 7e05e8bc..dbf43c26 100644
--- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp
@@ -37,23 +37,22 @@ namespace Diligent
ShaderResourceBindingVkImpl::ShaderResourceBindingVkImpl(IReferenceCounters* pRefCounters,
PipelineResourceSignatureVkImpl* pPRS,
- bool IsPSOInternal) :
+ bool IsDeviceInternal) :
// clang-format off
TBase
{
pRefCounters,
pPRS,
- IsPSOInternal
+ IsDeviceInternal
},
- m_ShaderResourceCache{ShaderResourceCacheVk::CacheContentType::SRB}
+ m_ShaderResourceCache{ShaderResourceCacheVk::CacheContentType::SRB},
+ m_NumShaders{static_cast<decltype(m_NumShaders)>(pPRS->GetNumShaderStages())}
// clang-format on
{
try
{
m_ShaderVarIndex.fill(-1);
- m_NumShaders = static_cast<decltype(m_NumShaders)>(pPRS->GetNumShaderStages());
-
FixedLinearAllocator MemPool{GetRawAllocator()};
MemPool.AddSpace<ShaderVariableManagerVk>(m_NumShaders);
MemPool.Reserve();