@@ -190,9 +190,10 @@ std::pair<uint32_t, uint32_t> AlignmentSizeCalculator::getAlignmentAndSize(
190
190
uint32_t alignment = 0 , size = 0 ;
191
191
std::tie (alignment, size) =
192
192
getAlignmentAndSize (elemType, rule, isRowMajor, stride);
193
- // Use element alignment for fxc rules
193
+ // Use element alignment for fxc rules and VK_EXT_scalar_block_layout
194
194
if (rule != SpirvLayoutRule::FxcCTBuffer &&
195
- rule != SpirvLayoutRule::FxcSBuffer)
195
+ rule != SpirvLayoutRule::FxcSBuffer &&
196
+ rule != SpirvLayoutRule::Scalar)
196
197
alignment = (elemCount == 3 ? 4 : elemCount) * size;
197
198
198
199
return {alignment, elemCount * size};
@@ -217,9 +218,11 @@ std::pair<uint32_t, uint32_t> AlignmentSizeCalculator::getAlignmentAndSize(
217
218
218
219
const uint32_t vecStorageSize = rowMajor ? rowCount : colCount;
219
220
220
- if (rule == SpirvLayoutRule::FxcSBuffer) {
221
+ if (rule == SpirvLayoutRule::FxcSBuffer ||
222
+ rule == SpirvLayoutRule::Scalar) {
221
223
*stride = vecStorageSize * size;
222
- // Use element alignment for fxc structured buffers
224
+ // Use element alignment for fxc structured buffers and
225
+ // VK_EXT_scalar_block_layout
223
226
return {alignment, rowCount * colCount * size};
224
227
}
225
228
@@ -274,6 +277,12 @@ std::pair<uint32_t, uint32_t> AlignmentSizeCalculator::getAlignmentAndSize(
274
277
structSize += memberSize;
275
278
}
276
279
280
+ if (rule == SpirvLayoutRule::Scalar) {
281
+ // A structure has a scalar alignment equal to the largest scalar
282
+ // alignment of any of its members in VK_EXT_scalar_block_layout.
283
+ return {maxAlignment, structSize};
284
+ }
285
+
277
286
if (rule == SpirvLayoutRule::GLSLStd140 ||
278
287
rule == SpirvLayoutRule::RelaxedGLSLStd140 ||
279
288
rule == SpirvLayoutRule::FxcCTBuffer) {
@@ -297,9 +306,11 @@ std::pair<uint32_t, uint32_t> AlignmentSizeCalculator::getAlignmentAndSize(
297
306
std::tie (alignment, size) = getAlignmentAndSize (arrayType->getElementType (),
298
307
rule, isRowMajor, stride);
299
308
300
- if (rule == SpirvLayoutRule::FxcSBuffer) {
309
+ if (rule == SpirvLayoutRule::FxcSBuffer ||
310
+ rule == SpirvLayoutRule::Scalar) {
301
311
*stride = size;
302
- // Use element alignment for fxc structured buffers
312
+ // Use element alignment for fxc structured buffers and
313
+ // VK_EXT_scalar_block_layout
303
314
return {alignment, size * elemCount};
304
315
}
305
316
0 commit comments