summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-03-02 20:53:29 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-03-02 20:53:29 +0000
commita643ee949f206c51d76432410e164f4f9810cbb8 (patch)
tree95a35e0485be5cf61dffef44e71553b25eff33d0 /Graphics/GraphicsEngineVulkan
parentSome minor (mostly cosmetic) changes to SPIRVShaderResources (diff)
downloadDiligentCore-a643ee949f206c51d76432410e164f4f9810cbb8.tar.gz
DiligentCore-a643ee949f206c51d76432410e164f4f9810cbb8.zip
Some minor changes to ShaderResourceCacheVk
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderResourceCacheVk.h15
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderResourceCacheVk.cpp26
2 files changed, 21 insertions, 20 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceCacheVk.h b/Graphics/GraphicsEngineVulkan/include/ShaderResourceCacheVk.h
index d9d1c07f..21f97b04 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceCacheVk.h
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceCacheVk.h
@@ -83,7 +83,7 @@ public:
~ShaderResourceCacheVk();
static size_t GetRequiredMemorySize(Uint32 NumSets, Uint32 SetSizes[]);
- void InitializeSets(IMemoryAllocator &MemAllocator, Uint32 NumSets, Uint32 SetSizes[]);
+ void InitializeSets(IMemoryAllocator& MemAllocator, Uint32 NumSets, Uint32 SetSizes[]);
void InitializeResources(Uint32 Set, Uint32 Offset, Uint32 ArraySize, SPIRVShaderResourceAttribs::ResourceType Type);
// sizeof(Resource) == 16 (x64, msvc, Release)
@@ -93,13 +93,14 @@ public:
Type(_Type)
{}
- Resource(const Resource&) = delete;
- Resource(Resource&&) = delete;
+ Resource (const Resource&) = delete;
+ Resource (Resource&&) = delete;
Resource& operator = (const Resource&) = delete;
Resource& operator = (Resource&&) = delete;
- const SPIRVShaderResourceAttribs::ResourceType Type;
- RefCntAutoPtr<IDeviceObject> pObject;
+/* 0 */ const SPIRVShaderResourceAttribs::ResourceType Type;
+/*1-7*/ // Unused
+/* 8 */ RefCntAutoPtr<IDeviceObject> pObject;
VkDescriptorBufferInfo GetUniformBufferDescriptorWriteInfo () const;
VkDescriptorBufferInfo GetStorageBufferDescriptorWriteInfo () const;
@@ -117,8 +118,8 @@ public:
m_pResources (pResources)
{}
- DescriptorSet(const DescriptorSet&) = delete;
- DescriptorSet(DescriptorSet&&) = delete;
+ DescriptorSet (const DescriptorSet&) = delete;
+ DescriptorSet (DescriptorSet&&) = delete;
DescriptorSet& operator = (const DescriptorSet&) = delete;
DescriptorSet& operator = (DescriptorSet&&) = delete;
diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceCacheVk.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceCacheVk.cpp
index 85f835f8..47d098f9 100644
--- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceCacheVk.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceCacheVk.cpp
@@ -38,7 +38,7 @@ namespace Diligent
size_t ShaderResourceCacheVk::GetRequiredMemorySize(Uint32 NumSets, Uint32 SetSizes[])
{
Uint32 TotalResources = 0;
- for(Uint32 t=0; t < NumSets; ++t)
+ for (Uint32 t=0; t < NumSets; ++t)
TotalResources += SetSizes[t];
auto MemorySize = NumSets * sizeof(DescriptorSet) + TotalResources * sizeof(Resource);
return MemorySize;
@@ -60,15 +60,15 @@ void ShaderResourceCacheVk::InitializeSets(IMemoryAllocator& MemAllocator, Uint3
m_pAllocator = &MemAllocator;
m_NumSets = NumSets;
m_TotalResources = 0;
- for(Uint32 t=0; t < NumSets; ++t)
+ for (Uint32 t=0; t < NumSets; ++t)
m_TotalResources += SetSizes[t];
auto MemorySize = NumSets * sizeof(DescriptorSet) + m_TotalResources * sizeof(Resource);
VERIFY_EXPR(MemorySize == GetRequiredMemorySize(NumSets, SetSizes));
if (MemorySize > 0)
{
m_pMemory = ALLOCATE( *m_pAllocator, "Memory for shader resource cache data", MemorySize);
- auto *pSets = reinterpret_cast<DescriptorSet*>(m_pMemory);
- auto *pCurrResPtr = reinterpret_cast<Resource*>(pSets + m_NumSets);
+ auto* pSets = reinterpret_cast<DescriptorSet*>(m_pMemory);
+ auto* pCurrResPtr = reinterpret_cast<Resource*>(pSets + m_NumSets);
for (Uint32 t = 0; t < NumSets; ++t)
{
new(&GetDescriptorSet(t)) DescriptorSet(SetSizes[t], SetSizes[t] > 0 ? pCurrResPtr : nullptr);
@@ -80,7 +80,7 @@ void ShaderResourceCacheVk::InitializeSets(IMemoryAllocator& MemAllocator, Uint3
void ShaderResourceCacheVk::InitializeResources(Uint32 Set, Uint32 Offset, Uint32 ArraySize, SPIRVShaderResourceAttribs::ResourceType Type)
{
- auto &DescrSet = GetDescriptorSet(Set);
+ auto& DescrSet = GetDescriptorSet(Set);
for (Uint32 res = 0; res < ArraySize; ++res)
new(&DescrSet.GetResource(Offset + res)) Resource{Type};
}
@@ -89,8 +89,8 @@ ShaderResourceCacheVk::~ShaderResourceCacheVk()
{
if (m_pMemory)
{
- auto *pResources = GetFirstResourcePtr();
- for(Uint32 res=0; res < m_TotalResources; ++res)
+ auto* pResources = GetFirstResourcePtr();
+ for (Uint32 res=0; res < m_TotalResources; ++res)
pResources[res].~Resource();
for (Uint32 t = 0; t < m_NumSets; ++t)
GetDescriptorSet(t).~DescriptorSet();
@@ -282,7 +282,7 @@ VkDescriptorBufferInfo ShaderResourceCacheVk::Resource::GetUniformBufferDescript
// If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER or VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, the offset member
// of each element of pBufferInfo must be a multiple of VkPhysicalDeviceLimits::minUniformBufferOffsetAlignment (13.2.4)
DescrBuffInfo.offset = 0;
- DescrBuffInfo.range = pBuffVk->GetDesc().uiSizeInBytes;
+ DescrBuffInfo.range = pBuffVk->GetDesc().uiSizeInBytes;
return DescrBuffInfo;
}
@@ -330,7 +330,7 @@ VkDescriptorImageInfo ShaderResourceCacheVk::Resource::GetImageDescriptorWriteIn
{
// Immutable samplers are permanently bound into the set layout; later binding a sampler
// into an immutable sampler slot in a descriptor set is not allowed (13.2.1)
- auto *pSamplerVk = ValidatedCast<const SamplerVkImpl>(pTexViewVk->GetSampler());
+ auto* pSamplerVk = ValidatedCast<const SamplerVkImpl>(pTexViewVk->GetSampler());
if (pSamplerVk != nullptr)
{
// If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER or VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
@@ -386,8 +386,8 @@ VkDescriptorImageInfo ShaderResourceCacheVk::Resource::GetSamplerDescriptorWrite
auto* pSamplerVk = pObject.RawPtr<const SamplerVkImpl>();
VkDescriptorImageInfo DescrImgInfo;
// For VK_DESCRIPTOR_TYPE_SAMPLER, only the sample member of each element of VkWriteDescriptorSet::pImageInfo is accessed (13.2.4)
- DescrImgInfo.sampler = pSamplerVk->GetVkSampler();
- DescrImgInfo.imageView = VK_NULL_HANDLE;
+ DescrImgInfo.sampler = pSamplerVk->GetVkSampler();
+ DescrImgInfo.imageView = VK_NULL_HANDLE;
DescrImgInfo.imageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
return DescrImgInfo;
}
@@ -406,11 +406,11 @@ Uint32 ShaderResourceCacheVk::GetDynamicBufferOffsets(DeviceContextVkImpl *pCtxV
// In each descriptor set, all uniform buffers for every shader stage come first,
// followed by all storage buffers for every shader stage, followed by all other resources
Uint32 OffsetInd = 0;
- for(Uint32 set=0; set < m_NumSets; ++set)
+ for (Uint32 set=0; set < m_NumSets; ++set)
{
const auto& DescrSet = GetDescriptorSet(set);
Uint32 res = 0;
- while(res < DescrSet.GetSize())
+ while (res < DescrSet.GetSize())
{
const auto& Res = DescrSet.GetResource(res);
if (Res.Type != SPIRVShaderResourceAttribs::ResourceType::UniformBuffer)