@@ -74,7 +74,8 @@ class ShaderResourceCacheVk : public ShaderResourceCacheBase
7474public:
7575 explicit ShaderResourceCacheVk (ResourceCacheContentType ContentType) noexcept :
7676 m_TotalResources{0 },
77- m_ContentType{static_cast <Uint32>(ContentType)}
77+ m_ContentType{static_cast <Uint32>(ContentType)},
78+ m_HasInlineConstants{0 }
7879 {
7980 VERIFY_EXPR (GetContentType () == ContentType);
8081 }
@@ -93,7 +94,7 @@ class ShaderResourceCacheVk : public ShaderResourceCacheBase
9394 void InitializeSets (IMemoryAllocator& MemAllocator, Uint32 NumSets, const Uint32* SetSizes);
9495 void InitializeResources (Uint32 Set, Uint32 Offset, Uint32 ArraySize, DescriptorType Type, bool HasImmutableSampler);
9596
96- // sizeof(Resource) == 32 (x64, msvc, Release)
97+ // sizeof(Resource) == 40 (x64, msvc, Release)
9798 struct Resource
9899 {
99100 explicit Resource (DescriptorType _Type, bool _HasImmutableSampler) noexcept :
@@ -120,6 +121,10 @@ class ShaderResourceCacheVk : public ShaderResourceCacheBase
120121/* 16 */ Uint64 BufferBaseOffset = 0 ;
121122/* 24 */ Uint64 BufferRangeSize = 0 ;
122123
124+ // For inline constants only - pointer to CPU-side staging buffer
125+ /* 32 */ void * pInlineConstantData = nullptr ;
126+ /* 40 */ // End of structure
127+
123128 VkDescriptorBufferInfo GetUniformBufferDescriptorWriteInfo () const ;
124129 VkDescriptorBufferInfo GetStorageBufferDescriptorWriteInfo () const ;
125130 VkDescriptorImageInfo GetImageDescriptorWriteInfo () const ;
@@ -245,13 +250,36 @@ class ShaderResourceCacheVk : public ShaderResourceCacheBase
245250 Uint32 CacheOffset,
246251 Uint32 DynamicBufferOffset);
247252
253+ // Sets inline constant data in the resource cache
254+ void SetInlineConstants (Uint32 DescrSetIndex,
255+ Uint32 CacheOffset,
256+ const void * pConstants,
257+ Uint32 FirstConstant,
258+ Uint32 NumConstants);
259+
260+ // Gets the inline constant data pointer from the resource cache
261+ const void * GetInlineConstantData (Uint32 DescrSetIndex, Uint32 BindingIndex) const ;
262+
263+ // Initialize inline constant buffer in the resource cache
264+ void InitializeInlineConstantBuffer (Uint32 DescrSetIndex,
265+ Uint32 CacheOffset,
266+ Uint32 NumConstants,
267+ void * pInlineConstantData);
268+
269+ // Sets the inline constant memory block (takes ownership, will be freed in destructor)
270+ void SetInlineConstantMemory (IMemoryAllocator& Allocator, void * pMemory)
271+ {
272+ m_pInlineConstantMemory = decltype (m_pInlineConstantMemory){
273+ pMemory,
274+ STDDeleter<void , IMemoryAllocator>(Allocator)};
275+ }
248276
249277 Uint32 GetNumDescriptorSets () const { return m_NumSets; }
250278 bool HasDynamicResources () const { return m_NumDynamicBuffers > 0 ; }
251279
252280 bool HasInlineConstants () const
253281 {
254- return false ;
282+ return m_HasInlineConstants ;
255283 }
256284
257285 ResourceCacheContentType GetContentType () const { return static_cast <ResourceCacheContentType>(m_ContentType); }
@@ -287,16 +315,22 @@ class ShaderResourceCacheVk : public ShaderResourceCacheBase
287315
288316 std::unique_ptr<void , STDDeleter<void , IMemoryAllocator>> m_pMemory;
289317
318+ // Memory for inline constant data (allocated separately, freed in destructor)
319+ std::unique_ptr<void , STDDeleter<void , IMemoryAllocator>> m_pInlineConstantMemory;
320+
290321 Uint16 m_NumSets = 0 ;
291322
292323 // Total actual number of dynamic buffers (that were created with USAGE_DYNAMIC) bound in the resource cache
293324 // regardless of the variable type. Note this variable is not equal to dynamic offsets count, which is constant.
294325 Uint16 m_NumDynamicBuffers = 0 ;
295- Uint32 m_TotalResources : 31 ;
326+ Uint32 m_TotalResources : 30 ;
296327
297328 // Indicates what types of resources are stored in the cache
298329 const Uint32 m_ContentType : 1 ;
299330
331+ // Indicates whether the cache contains inline constants
332+ Uint32 m_HasInlineConstants : 1 ;
333+
300334#ifdef DILIGENT_DEBUG
301335 // Debug array that stores flags indicating if resources in the cache have been initialized
302336 std::vector<std::vector<bool >> m_DbgInitializedResources;
0 commit comments