@@ -43,77 +43,53 @@ class NBL_API IGPUDescriptorSet : public asset::IDescriptorSet<const IGPUDescrip
43
43
return false ;
44
44
}
45
45
46
- inline core::smart_refctd_ptr<asset::IDescriptor>* getAllDescriptors (const asset::IDescriptor::E_TYPE type) const
47
- {
48
- auto * baseAddress = m_pool->getDescriptorStorage (type);
49
- if (baseAddress == nullptr )
50
- return nullptr ;
46
+ protected:
47
+ virtual ~IGPUDescriptorSet ();
51
48
52
- const auto offset = m_descriptorStorageOffsets.data [static_cast <uint32_t >(type)];
53
- if (offset == ~0u )
54
- return nullptr ;
49
+ private:
50
+ friend class ILogicalDevice ;
55
51
56
- return baseAddress + offset;
57
- }
52
+ inline void incrementVersion () { m_version.fetch_add (1ull ); }
58
53
59
- inline core::smart_refctd_ptr<IGPUSampler>* getAllMutableSamplers () const
54
+ // TODO(achal): Don't know yet if we want to keep these.
55
+ inline void processWrite (const IGPUDescriptorSet::SWriteDescriptorSet& write)
60
56
{
61
- auto * baseAddress = m_pool->getMutableSamplerStorage ();
62
- if (baseAddress == nullptr )
63
- return nullptr ;
57
+ assert (write.dstSet == this );
64
58
65
- const auto poolOffset = m_descriptorStorageOffsets.data [static_cast <uint32_t >(asset::IDescriptor::E_TYPE::ET_COUNT)];
66
- if (poolOffset == ~0u )
67
- return nullptr ;
59
+ auto * descriptors = getDescriptors (write.descriptorType , write.binding );
60
+ auto * samplers = getMutableSamplers (write.binding );
61
+ for (auto j = 0 ; j < write.count ; ++j)
62
+ {
63
+ descriptors[j] = write.info [j].desc ;
68
64
69
- return baseAddress + poolOffset;
65
+ if (samplers)
66
+ samplers[j] = write.info [j].info .image .sampler ;
67
+ }
70
68
}
71
69
72
- inline uint32_t getDescriptorStorageOffset (const asset::IDescriptor::E_TYPE type) const { return m_descriptorStorageOffsets.data [static_cast <uint32_t >(type)]; }
73
- inline uint32_t getMutableSamplerStorageOffset () const { return m_descriptorStorageOffsets.data [static_cast <uint32_t >(asset::IDescriptor::E_TYPE::ET_COUNT)]; }
70
+ #if 0
71
+ inline void processCopy(const IGPUDescriptorSet::SCopyDescriptorSet& copy)
72
+ {
73
+ assert(copy.dstSet == this);
74
74
75
- protected:
76
- virtual ~IGPUDescriptorSet ()
77
- {
78
- if (!isZombie ())
75
+ for (uint32_t t = 0; t < static_cast<uint32_t>(asset::IDescriptor::E_TYPE::ET_COUNT); ++t)
79
76
{
80
- const bool allowsFreeing = m_pool->m_flags & IDescriptorPool::ECF_FREE_DESCRIPTOR_SET_BIT;
81
- for (auto i = 0u ; i < static_cast <uint32_t >(asset::IDescriptor::E_TYPE::ET_COUNT); ++i)
82
- {
83
- // There is no descriptor of such type in the set.
84
- if (m_descriptorStorageOffsets.data [i] == ~0u )
85
- continue ;
86
-
87
- const auto type = static_cast <asset::IDescriptor::E_TYPE>(i);
88
-
89
- const uint32_t allocatedOffset = getDescriptorStorageOffset (type);
90
- assert (allocatedOffset != ~0u );
91
-
92
- const uint32_t count = m_layout->getTotalDescriptorCount (type);
93
- assert (count != 0u );
94
-
95
- std::destroy_n (m_pool->getDescriptorStorage (type) + allocatedOffset, count);
96
-
97
- if (allowsFreeing)
98
- m_pool->m_descriptorAllocators [i]->free (allocatedOffset, count);
99
- }
100
-
101
- const auto mutableSamplerCount = m_layout->getTotalMutableSamplerCount ();
102
- if (mutableSamplerCount > 0 )
103
- {
104
- const uint32_t allocatedOffset = getMutableSamplerStorageOffset ();
105
- assert (allocatedOffset != ~0u );
106
-
107
- std::destroy_n (m_pool->getMutableSamplerStorage () + allocatedOffset, mutableSamplerCount);
108
-
109
- if (allowsFreeing)
110
- m_pool->m_descriptorAllocators [static_cast <uint32_t >(asset::IDescriptor::E_TYPE::ET_COUNT)]->free (allocatedOffset, mutableSamplerCount);
111
- }
112
- }
113
- }
77
+ const auto type = static_cast<asset::IDescriptor::E_TYPE>(t);
114
78
115
- private:
116
- friend class ILogicalDevice ;
79
+ auto* srcDescriptors = srcDS->getDescriptors(type, pDescriptorCopies[i].srcBinding);
80
+ auto* srcSamplers = srcDS->getMutableSamplers(pDescriptorCopies[i].srcBinding);
81
+
82
+ auto* dstDescriptors = dstDS->getDescriptors(type, pDescriptorCopies[i].dstBinding);
83
+ auto* dstSamplers = dstDS->getMutableSamplers(pDescriptorCopies[i].dstBinding);
84
+
85
+ if (srcDescriptors && dstDescriptors)
86
+ std::copy_n(srcDescriptors, pDescriptorCopies[i].count, dstDescriptors);
87
+
88
+ if (srcSamplers && dstSamplers)
89
+ std::copy_n(srcSamplers, pDescriptorCopies[i].count, dstSamplers);
90
+ }
91
+ }
92
+ #endif
117
93
118
94
// This assumes that descriptors of a particular type in the set will always be contiguous in pool's storage memory, regardless of which binding in the set they belong to.
119
95
inline core::smart_refctd_ptr<asset::IDescriptor>* getDescriptors (const asset::IDescriptor::E_TYPE type, const uint32_t binding) const
@@ -142,7 +118,34 @@ class NBL_API IGPUDescriptorSet : public asset::IDescriptorSet<const IGPUDescrip
142
118
return samplers + localOffset;
143
119
}
144
120
145
- inline void incrementVersion () { m_version.fetch_add (1ull ); }
121
+ inline core::smart_refctd_ptr<asset::IDescriptor>* getAllDescriptors (const asset::IDescriptor::E_TYPE type) const
122
+ {
123
+ auto * baseAddress = m_pool->getDescriptorStorage (type);
124
+ if (baseAddress == nullptr )
125
+ return nullptr ;
126
+
127
+ const auto offset = m_descriptorStorageOffsets.data [static_cast <uint32_t >(type)];
128
+ if (offset == ~0u )
129
+ return nullptr ;
130
+
131
+ return baseAddress + offset;
132
+ }
133
+
134
+ inline core::smart_refctd_ptr<IGPUSampler>* getAllMutableSamplers () const
135
+ {
136
+ auto * baseAddress = m_pool->getMutableSamplerStorage ();
137
+ if (baseAddress == nullptr )
138
+ return nullptr ;
139
+
140
+ const auto poolOffset = m_descriptorStorageOffsets.data [static_cast <uint32_t >(asset::IDescriptor::E_TYPE::ET_COUNT)];
141
+ if (poolOffset == ~0u )
142
+ return nullptr ;
143
+
144
+ return baseAddress + poolOffset;
145
+ }
146
+
147
+ inline uint32_t getDescriptorStorageOffset (const asset::IDescriptor::E_TYPE type) const { return m_descriptorStorageOffsets.data [static_cast <uint32_t >(type)]; }
148
+ inline uint32_t getMutableSamplerStorageOffset () const { return m_descriptorStorageOffsets.data [static_cast <uint32_t >(asset::IDescriptor::E_TYPE::ET_COUNT)]; }
146
149
147
150
std::atomic_uint64_t m_version;
148
151
const uint32_t m_parentPoolVersion;
0 commit comments