summaryrefslogtreecommitdiffstats
path: root/Graphics/ShaderTools
diff options
context:
space:
mode:
authorazhirnov <zh1dron@gmail.com>2020-11-05 00:43:05 +0000
committerazhirnov <zh1dron@gmail.com>2020-11-05 00:53:36 +0000
commit5e81b867be771dc7f2add0d7b403af4aeaa744db (patch)
tree0f1f3835149f8887d80d558203956fcdbb233f60 /Graphics/ShaderTools
parentfixed compilation (diff)
downloadDiligentCore-5e81b867be771dc7f2add0d7b403af4aeaa744db.tar.gz
DiligentCore-5e81b867be771dc7f2add0d7b403af4aeaa744db.zip
Added AS copy with compacting.
Added UB & SB size checks for Vulkan. Some improvements for ray tracing & tests.
Diffstat (limited to 'Graphics/ShaderTools')
-rw-r--r--Graphics/ShaderTools/include/SPIRVShaderResources.hpp11
-rw-r--r--Graphics/ShaderTools/src/SPIRVShaderResources.cpp30
2 files changed, 29 insertions, 12 deletions
diff --git a/Graphics/ShaderTools/include/SPIRVShaderResources.hpp b/Graphics/ShaderTools/include/SPIRVShaderResources.hpp
index 7e75fb07..9385ff3f 100644
--- a/Graphics/ShaderTools/include/SPIRVShaderResources.hpp
+++ b/Graphics/ShaderTools/include/SPIRVShaderResources.hpp
@@ -55,7 +55,7 @@ struct Resource;
namespace Diligent
{
-// sizeof(SPIRVShaderResourceAttribs) == 24, msvc x64
+// sizeof(SPIRVShaderResourceAttribs) == 32, msvc x64
struct SPIRVShaderResourceAttribs
{
enum ResourceType : Uint8
@@ -94,7 +94,10 @@ public:
// Offset in SPIRV words (uint32_t) of binding & descriptor set decorations in SPIRV binary
/* 16 */const uint32_t BindingDecorationOffset;
/* 20 */const uint32_t DescriptorSetDecorationOffset;
-/* 24 */ // End of structure
+
+/* 24 */const Uint32 BufferStaticSize;
+/* 28 */const Uint32 BufferStride;
+/* 32 */ // End of structure
// clang-format on
@@ -102,7 +105,9 @@ public:
const diligent_spirv_cross::Resource& Res,
const char* _Name,
ResourceType _Type,
- Uint32 _SamplerOrSepImgInd = InvalidSepSmplrOrImgInd) noexcept;
+ Uint32 _SamplerOrSepImgInd = InvalidSepSmplrOrImgInd,
+ Uint32 _BufferStaticSize = 0,
+ Uint32 _BufferStride = 0) noexcept;
bool IsValidSepSamplerAssigned() const
{
diff --git a/Graphics/ShaderTools/src/SPIRVShaderResources.cpp b/Graphics/ShaderTools/src/SPIRVShaderResources.cpp
index bb15cc06..6c4ce16e 100644
--- a/Graphics/ShaderTools/src/SPIRVShaderResources.cpp
+++ b/Graphics/ShaderTools/src/SPIRVShaderResources.cpp
@@ -109,7 +109,9 @@ SPIRVShaderResourceAttribs::SPIRVShaderResourceAttribs(const diligent_spirv_cros
const diligent_spirv_cross::Resource& Res,
const char* _Name,
ResourceType _Type,
- Uint32 _SepSmplrOrImgInd) noexcept :
+ Uint32 _SepSmplrOrImgInd,
+ Uint32 _BufferStaticSize,
+ Uint32 _BufferStride) noexcept :
// clang-format off
Name {_Name},
ArraySize {GetResourceArraySize<decltype(ArraySize)>(Compiler, Res)},
@@ -118,7 +120,9 @@ SPIRVShaderResourceAttribs::SPIRVShaderResourceAttribs(const diligent_spirv_cros
IsMS {Diligent::IsMultisample(Compiler, Res) ? Uint8{1} : Uint8{0}},
SepSmplrOrImgInd {_SepSmplrOrImgInd},
BindingDecorationOffset {GetDecorationOffset(Compiler, Res, spv::Decoration::DecorationBinding)},
- DescriptorSetDecorationOffset {GetDecorationOffset(Compiler, Res, spv::Decoration::DecorationDescriptorSet)}
+ DescriptorSetDecorationOffset {GetDecorationOffset(Compiler, Res, spv::Decoration::DecorationDescriptorSet)},
+ BufferStaticSize {_BufferStaticSize},
+ BufferStride {_BufferStride}
// clang-format on
{
VERIFY(_SepSmplrOrImgInd == SPIRVShaderResourceAttribs::InvalidSepSmplrOrImgInd ||
@@ -297,10 +301,8 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
&resources.separate_images,
&resources.separate_samplers,
&resources.subpass_inputs,
- &resources.acceleration_structures
- // clang-format off
- })
- // clang-format on
+ &resources.acceleration_structures //
+ }) //
{
for (const auto& res : *pResType)
ResourceNamesPoolSize += res.name.length() + 1;
@@ -379,12 +381,16 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
Uint32 CurrUB = 0;
for (const auto& UB : resources.uniform_buffers)
{
- const auto& name = GetUBName(Compiler, UB, ParsedIRSource);
+ const auto& name = GetUBName(Compiler, UB, ParsedIRSource);
+ const auto& Type = Compiler.get_type(UB.type_id);
+ const size_t Size = Compiler.get_declared_struct_size(Type);
new (&GetUB(CurrUB++))
SPIRVShaderResourceAttribs(Compiler,
UB,
ResourceNamesPool.CopyString(name),
- SPIRVShaderResourceAttribs::ResourceType::UniformBuffer);
+ SPIRVShaderResourceAttribs::ResourceType::UniformBuffer,
+ SPIRVShaderResourceAttribs::InvalidSepSmplrOrImgInd,
+ Uint32(Size));
}
VERIFY_EXPR(CurrUB == GetNumUBs());
}
@@ -398,11 +404,17 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
auto ResType = IsReadOnly ?
SPIRVShaderResourceAttribs::ResourceType::ROStorageBuffer :
SPIRVShaderResourceAttribs::ResourceType::RWStorageBuffer;
+ const auto& Type = Compiler.get_type(SB.type_id);
+ const size_t Size = Compiler.get_declared_struct_size(Type);
+ const size_t Stride = Compiler.get_declared_struct_size_runtime_array(Type, 1);
new (&GetSB(CurrSB++))
SPIRVShaderResourceAttribs(Compiler,
SB,
ResourceNamesPool.CopyString(SB.name),
- ResType);
+ ResType,
+ SPIRVShaderResourceAttribs::InvalidSepSmplrOrImgInd,
+ Uint32(Size),
+ Uint32(Stride));
}
VERIFY_EXPR(CurrSB == GetNumSBs());
}