|
141 | 141 | return descStr.str();
|
142 | 142 | }
|
143 | 143 |
|
| 144 | +bool MVKPipelineLayout::isUsingMetalArgumentBuffers() { |
| 145 | + return MVKDeviceTrackingMixin::isUsingMetalArgumentBuffers() && _canUseMetalArgumentBuffers; |
| 146 | +} |
| 147 | + |
144 | 148 | MVKPipelineLayout::MVKPipelineLayout(MVKDevice* device,
|
145 | 149 | const VkPipelineLayoutCreateInfo* pCreateInfo) : MVKVulkanAPIDeviceObject(device) {
|
146 | 150 |
|
| 151 | + _canUseMetalArgumentBuffers = false; |
| 152 | + uint32_t dslCnt = pCreateInfo->setLayoutCount; |
| 153 | + _descriptorSetLayouts.reserve(dslCnt); |
| 154 | + for (uint32_t i = 0; i < dslCnt; i++) { |
| 155 | + MVKDescriptorSetLayout* pDescSetLayout = (MVKDescriptorSetLayout*)pCreateInfo->pSetLayouts[i]; |
| 156 | + pDescSetLayout->retain(); |
| 157 | + _descriptorSetLayouts.push_back(pDescSetLayout); |
| 158 | + _canUseMetalArgumentBuffers = _canUseMetalArgumentBuffers || pDescSetLayout->isUsingMetalArgumentBuffers(); |
| 159 | + } |
| 160 | + |
147 | 161 | // For pipeline layout compatibility (“compatible for set N”),
|
148 | 162 | // consume the Metal resource indexes in this order:
|
149 |
| - // - Fixed count of argument buffers for descriptor sets (if using Metal argument buffers). |
| 163 | + // - An argument buffer for each descriptor set (if using Metal argument buffers). |
150 | 164 | // - Push constants
|
151 | 165 | // - Descriptor set content
|
152 | 166 |
|
153 |
| - // If we are using Metal argument buffers, consume a fixed number |
154 |
| - // of buffer indexes for the Metal argument buffers themselves. |
| 167 | + // If we are using Metal argument buffers, consume a number of |
| 168 | + // buffer indexes covering all descriptor sets for the Metal |
| 169 | + // argument buffers themselves. |
155 | 170 | if (isUsingMetalArgumentBuffers()) {
|
156 |
| - _mtlResourceCounts.addArgumentBuffers(kMVKMaxDescriptorSetCount); |
| 171 | + _mtlResourceCounts.addArgumentBuffers(dslCnt); |
157 | 172 | }
|
158 | 173 |
|
159 | 174 | // Add push constants from config
|
|
172 | 187 |
|
173 | 188 | // Add descriptor set layouts, accumulating the resource index offsets used by the corresponding DSL,
|
174 | 189 | // and associating the current accumulated resource index offsets with each DSL as it is added.
|
175 |
| - uint32_t dslCnt = pCreateInfo->setLayoutCount; |
176 |
| - _descriptorSetLayouts.reserve(dslCnt); |
177 | 190 | for (uint32_t i = 0; i < dslCnt; i++) {
|
178 |
| - MVKDescriptorSetLayout* pDescSetLayout = (MVKDescriptorSetLayout*)pCreateInfo->pSetLayouts[i]; |
179 |
| - pDescSetLayout->retain(); |
180 |
| - _descriptorSetLayouts.push_back(pDescSetLayout); |
181 |
| - |
| 191 | + MVKDescriptorSetLayout* pDescSetLayout = _descriptorSetLayouts[i]; |
182 | 192 | MVKShaderResourceBinding adjstdDSLRezOfsts = _mtlResourceCounts;
|
183 | 193 | MVKShaderResourceBinding adjstdDSLRezCnts = pDescSetLayout->_mtlResourceCounts;
|
184 | 194 | if (pDescSetLayout->isUsingMetalArgumentBuffers()) {
|
|
0 commit comments