Go to the documentation of this file.
100 const diligent_spirv_cross::Resource& Res,
103 Uint32 _BufferStaticSize = 0,
104 Uint32 _BufferStride = 0) noexcept;
121 static_assert(
sizeof(SPIRVShaderResourceAttribs) %
sizeof(
void*) == 0,
"Size of SPIRVShaderResourceAttribs struct must be multiple of sizeof(void*)");
136 static_assert(
sizeof(
SPIRVShaderStageInputAttribs) %
sizeof(
void*) == 0,
"Size of SPIRVShaderStageInputAttribs struct must be multiple of sizeof(void*)");
144 std::vector<uint32_t> spirv_binary,
146 const char* CombinedSamplerSuffix,
147 bool LoadShaderStageInputs,
148 std::string& EntryPoint);
162 Uint32 GetNumSBs ()const noexcept{
return (m_StorageImageOffset - m_StorageBufferOffset); }
163 Uint32 GetNumImgs ()const noexcept{
return (m_SampledImageOffset - m_StorageImageOffset); }
165 Uint32 GetNumACs ()const noexcept{
return (m_SeparateSamplerOffset - m_AtomicCounterOffset); }
188 VERIFY(n < m_NumShaderStageInputs,
"Shader stage input index (", n,
") is out of range. Total input count: ", m_NumShaderStageInputs);
209 template <
typename THandleUB,
212 typename THandleSmplImg,
214 typename THandleSepSmpl,
215 typename THandleSepImg,
216 typename THandleInptAtt,
217 typename THandleAccelStruct>
220 THandleImg HandleImg,
221 THandleSmplImg HandleSmplImg,
223 THandleSepSmpl HandleSepSmpl,
224 THandleSepImg HandleSepImg,
225 THandleInptAtt HandleInptAtt,
226 THandleAccelStruct HandleAccelStruct)
const
230 const auto& UB =
GetUB(n);
236 const auto& SB =
GetSB(n);
242 const auto& Img =
GetImg(n);
249 HandleSmplImg(SmplImg, n);
254 const auto& AC =
GetAC(n);
261 HandleSepSmpl(SepSmpl, n);
267 HandleSepImg(SepImg, n);
273 HandleInptAtt(InptAtt, n);
279 HandleAccelStruct(AccelStruct, n);
282 static_assert(
Uint32{SPIRVShaderResourceAttribs::ResourceType::NumResourceTypes} == 12,
"Please handle the new resource type here, if needed");
285 template <
typename THandler>
309 const ResourceCounters& Counters,
310 Uint32 NumShaderStageInputs,
311 size_t ResourceNamesPoolSize,
316 VERIFY(n < NumResources,
"Resource index (", n,
") is out of range. Total resource count: ", NumResources);
321 const SPIRVShaderResourceAttribs& GetResAttribs(
Uint32 n,
Uint32 NumResources,
Uint32 Offset)
const noexcept
323 VERIFY(n < NumResources,
"Resource index (", n,
") is out of range. Total resource count: ", NumResources);
325 return reinterpret_cast<SPIRVShaderResourceAttribs*
>(m_MemoryBuffer.get())[Offset + n];
330 SPIRVShaderResourceAttribs&
GetUB (
Uint32 n)noexcept{
return GetResAttribs(n,
GetNumUBs(), 0 ); }
331 SPIRVShaderResourceAttribs&
GetSB (
Uint32 n)noexcept{
return GetResAttribs(n,
GetNumSBs(), m_StorageBufferOffset ); }
332 SPIRVShaderResourceAttribs&
GetImg (
Uint32 n)noexcept{
return GetResAttribs(n,
GetNumImgs(), m_StorageImageOffset ); }
334 SPIRVShaderResourceAttribs&
GetAC (
Uint32 n)noexcept{
return GetResAttribs(n,
GetNumACs(), m_AtomicCounterOffset ); }
350 std::unique_ptr<void, STDDeleterRawMem<void>> m_MemoryBuffer;
352 const char* m_CombinedSamplerSuffix =
nullptr;
353 const char* m_ShaderName =
nullptr;
355 using OffsetType =
Uint16;
356 OffsetType m_StorageBufferOffset = 0;
357 OffsetType m_StorageImageOffset = 0;
358 OffsetType m_SampledImageOffset = 0;
359 OffsetType m_AtomicCounterOffset = 0;
360 OffsetType m_SeparateSamplerOffset = 0;
361 OffsetType m_SeparateImageOffset = 0;
362 OffsetType m_InputAttachmentOffset = 0;
363 OffsetType m_AccelStructOffset = 0;
364 OffsetType m_TotalResources = 0;
365 OffsetType m_NumShaderStageInputs = 0;
370 bool m_IsHLSLSource =
false;
Uint32 GetNumSBs() const noexcept
Definition: SPIRVShaderResources.hpp:162
std::string DumpResources()
Definition: SPIRVShaderResources.cpp:668
@ InputAttachment
Definition: SPIRVShaderResources.hpp:73
~SPIRVShaderResources()
Definition: SPIRVShaderResources.cpp:631
const uint32_t BindingDecorationOffset
Definition: SPIRVShaderResources.hpp:89
const Uint8 IsMS
Definition: SPIRVShaderResources.hpp:86
Uint32 GetNumSmpldImgs() const noexcept
Definition: SPIRVShaderResources.hpp:164
Uint32 NumSepSmplrs
Definition: SPIRVShaderResources.hpp:200
bool IsUsingCombinedSamplers() const
Definition: SPIRVShaderResources.hpp:301
SHADER_TYPE
Describes the shader type.
Definition: GraphicsTypes.h:65
SHADER_RESOURCE_TYPE
Describes shader resource type.
Definition: Shader.h:356
Definition: SPIRVShaderResources.hpp:49
Uint32 GetNumImgs() const noexcept
Definition: SPIRVShaderResources.hpp:163
Uint32 GetNumACs() const noexcept
Definition: SPIRVShaderResources.hpp:165
@ SeparateImage
Definition: SPIRVShaderResources.hpp:71
@ AtomicCounter
Definition: SPIRVShaderResources.hpp:70
Definition: SPIRVShaderResources.hpp:59
const SPIRVShaderResourceAttribs & GetAC(Uint32 n) const noexcept
Definition: SPIRVShaderResources.hpp:177
static SHADER_RESOURCE_TYPE GetShaderResourceType(ResourceType Type)
Definition: SPIRVShaderResources.cpp:128
@ SampledImage
Definition: SPIRVShaderResources.hpp:69
Definition: SPIRVShaderResources.hpp:193
Uint32 NumACs
Definition: SPIRVShaderResources.hpp:199
Uint32 GetNumSepImgs() const noexcept
Definition: SPIRVShaderResources.hpp:167
const Uint32 BufferStride
Definition: SPIRVShaderResources.hpp:93
SPIRVShaderResources(IMemoryAllocator &Allocator, IRenderDevice *pRenderDevice, std::vector< uint32_t > spirv_binary, const ShaderDesc &shaderDesc, const char *CombinedSamplerSuffix, bool LoadShaderStageInputs, std::string &EntryPoint)
Definition: SPIRVShaderResources.cpp:244
bool IsHLSLSource() const
Definition: SPIRVShaderResources.hpp:305
SPIRVShaderResourceAttribs(const diligent_spirv_cross::Compiler &Compiler, const diligent_spirv_cross::Resource &Res, const char *_Name, ResourceType _Type, Uint32 _BufferStaticSize=0, Uint32 _BufferStride=0) noexcept
Definition: SPIRVShaderResources.cpp:108
const SPIRVShaderResourceAttribs & GetInptAtt(Uint32 n) const noexcept
Definition: SPIRVShaderResources.hpp:180
Uint32 NumSBs
Definition: SPIRVShaderResources.hpp:196
SHADER_TYPE GetShaderType() const noexcept
Definition: SPIRVShaderResources.hpp:206
const Uint8 ResourceDim
Definition: SPIRVShaderResources.hpp:85
@ RWStorageBuffer
Definition: SPIRVShaderResources.hpp:65
@ ROStorageBuffer
Definition: SPIRVShaderResources.hpp:64
const char * GetShaderName() const
Definition: SPIRVShaderResources.hpp:300
Render device interface.
Definition: RenderDevice.h:75
@ SeparateSampler
Definition: SPIRVShaderResources.hpp:72
@ AccelerationStructure
Definition: SPIRVShaderResources.hpp:74
const uint32_t DescriptorSetDecorationOffset
Definition: SPIRVShaderResources.hpp:90
Uint32 GetNumAccelStructs() const noexcept
Definition: SPIRVShaderResources.hpp:169
const SPIRVShaderResourceAttribs & GetSmpldImg(Uint32 n) const noexcept
Definition: SPIRVShaderResources.hpp:176
Shader description.
Definition: Shader.h:110
Uint32 NumSepImgs
Definition: SPIRVShaderResources.hpp:201
@ NumResourceTypes
Definition: SPIRVShaderResources.hpp:75
Uint32 GetTotalResources() const noexcept
Definition: SPIRVShaderResources.hpp:170
Diligent::SPIRVShaderResources class.
Definition: SPIRVShaderResources.hpp:139
Uint32 NumInptAtts
Definition: SPIRVShaderResources.hpp:202
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
@ SHADER_TYPE_UNKNOWN
Unknown shader type.
Definition: GraphicsTypes.h:67
void ProcessResources(THandler Handler) const
Definition: SPIRVShaderResources.hpp:286
const SPIRVShaderResourceAttribs & GetAccelStruct(Uint32 n) const noexcept
Definition: SPIRVShaderResources.hpp:181
@ UniformTexelBuffer
Definition: SPIRVShaderResources.hpp:66
Uint32 NumSmpldImgs
Definition: SPIRVShaderResources.hpp:198
const SPIRVShaderResourceAttribs & GetUB(Uint32 n) const noexcept
Definition: SPIRVShaderResources.hpp:173
Uint32 NumUBs
Definition: SPIRVShaderResources.hpp:195
const SPIRVShaderStageInputAttribs & GetShaderStageInputAttribs(Uint32 n) const noexcept
Definition: SPIRVShaderResources.hpp:186
ShaderResourceDesc GetResourceDesc() const
Definition: SPIRVShaderResources.hpp:106
const char *const Name
Definition: SPIRVShaderResources.hpp:82
Base interface for a raw memory allocator.
Definition: MemoryAllocator.h:41
Uint32 GetNumUBs() const noexcept
Definition: SPIRVShaderResources.hpp:161
bool IsMultisample() const
Definition: SPIRVShaderResources.hpp:116
Uint32 GetNumSepSmplrs() const noexcept
Definition: SPIRVShaderResources.hpp:166
ResourceType
Definition: SPIRVShaderResources.hpp:61
@ StorageTexelBuffer
Definition: SPIRVShaderResources.hpp:67
uint16_t Uint16
16-bit unsigned integer
Definition: BasicTypes.h:52
Shader resource description.
Definition: Shader.h:390
@ StorageImage
Definition: SPIRVShaderResources.hpp:68
uint8_t Uint8
8-bit unsigned integer
Definition: BasicTypes.h:53
const SPIRVShaderResourceAttribs & GetResource(Uint32 n) const noexcept
Definition: SPIRVShaderResources.hpp:182
#define VERIFY_EXPR(...)
Definition: DebugUtilities.hpp:79
const Uint32 BufferStaticSize
Definition: SPIRVShaderResources.hpp:92
#define VERIFY(...)
Definition: DebugUtilities.hpp:76
Implementation of a simple fixed-size string pool.
Definition: StringPool.hpp:42
@ UniformBuffer
Definition: SPIRVShaderResources.hpp:63
const char * GetCombinedSamplerSuffix() const
Definition: SPIRVShaderResources.hpp:299
RESOURCE_DIMENSION GetResourceDimension() const
Definition: SPIRVShaderResources.hpp:111
const ResourceType Type
Definition: SPIRVShaderResources.hpp:84
const SPIRVShaderResourceAttribs & GetImg(Uint32 n) const noexcept
Definition: SPIRVShaderResources.hpp:175
const Uint16 ArraySize
Definition: SPIRVShaderResources.hpp:83
RESOURCE_DIMENSION
Describes resource dimension.
Definition: GraphicsTypes.h:256
Uint32 NumImgs
Definition: SPIRVShaderResources.hpp:197
const SPIRVShaderResourceAttribs & GetSepSmplr(Uint32 n) const noexcept
Definition: SPIRVShaderResources.hpp:178
Uint32 NumAccelStructs
Definition: SPIRVShaderResources.hpp:203
const SPIRVShaderResourceAttribs & GetSepImg(Uint32 n) const noexcept
Definition: SPIRVShaderResources.hpp:179
Uint32 GetNumInptAtts() const noexcept
Definition: SPIRVShaderResources.hpp:168
SPIRVShaderResources & operator=(const SPIRVShaderResources &)=delete
Uint32 GetNumShaderStageInputs() const noexcept
Definition: SPIRVShaderResources.hpp:171
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
void ProcessResources(THandleUB HandleUB, THandleSB HandleSB, THandleImg HandleImg, THandleSmplImg HandleSmplImg, THandleAC HandleAC, THandleSepSmpl HandleSepSmpl, THandleSepImg HandleSepImg, THandleInptAtt HandleInptAtt, THandleAccelStruct HandleAccelStruct) const
Definition: SPIRVShaderResources.hpp:218
const SPIRVShaderResourceAttribs & GetSB(Uint32 n) const noexcept
Definition: SPIRVShaderResources.hpp:174