Skip to content

Commit e86fbc1

Browse files
committed
Layout Vulkan Mesh/Task Shader payload structs in scalar manner
Fixes payload containing structs or struct arrays which are not the first member
1 parent 2c38972 commit e86fbc1

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

renderdoc/driver/vulkan/vk_postvs.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,7 @@ struct OutMeshletLayout
15071507
};
15081508

15091509
static void LayOutStorageStruct(rdcspv::Editor &editor, const rdcarray<SpecConstant> &specInfo,
1510+
const bool align,
15101511
rdcspv::SparseIdMap<rdcspv::Id> &outputTypeReplacements,
15111512
const rdcspv::DataType &type, rdcspv::Id &structType,
15121513
uint32_t &byteSize);
@@ -1522,7 +1523,8 @@ static void LayOutStorageArray(rdcspv::Editor &editor, const rdcarray<SpecConsta
15221523
// handle arrays-of-arrays and arrays-of-struts
15231524
if(arrayInnerType.type == rdcspv::DataType::StructType)
15241525
{
1525-
LayOutStorageStruct(editor, specInfo, outputTypeReplacements, arrayInnerType, innerId, size);
1526+
LayOutStorageStruct(editor, specInfo, false, outputTypeReplacements, arrayInnerType, innerId,
1527+
size);
15261528
}
15271529
else if(arrayInnerType.type == rdcspv::DataType::ArrayType)
15281530
{
@@ -1551,6 +1553,7 @@ static void LayOutStorageArray(rdcspv::Editor &editor, const rdcarray<SpecConsta
15511553
}
15521554

15531555
static void LayOutStorageStruct(rdcspv::Editor &editor, const rdcarray<SpecConstant> &specInfo,
1556+
const bool align,
15541557
rdcspv::SparseIdMap<rdcspv::Id> &outputTypeReplacements,
15551558
const rdcspv::DataType &type, rdcspv::Id &structType,
15561559
uint32_t &byteSize)
@@ -1577,12 +1580,11 @@ static void LayOutStorageStruct(rdcspv::Editor &editor, const rdcarray<SpecConst
15771580

15781581
if(childType.type == rdcspv::DataType::StructType)
15791582
{
1580-
offset = AlignUp16(offset);
1581-
LayOutStorageStruct(editor, specInfo, outputTypeReplacements, childType, memberTypeId, size);
1583+
LayOutStorageStruct(editor, specInfo, false, outputTypeReplacements, childType, memberTypeId,
1584+
size);
15821585
}
15831586
else if(childType.type == rdcspv::DataType::ArrayType)
15841587
{
1585-
offset = AlignUp16(offset);
15861588
LayOutStorageArray(editor, specInfo, outputTypeReplacements, childType, memberTypeId, size);
15871589
}
15881590
else
@@ -1609,7 +1611,9 @@ static void LayOutStorageStruct(rdcspv::Editor &editor, const rdcarray<SpecConst
16091611
editor.AddDecoration(rdcspv::OpMemberDecorate(
16101612
structType, i, rdcspv::DecorationParam<rdcspv::Decoration::Offset>(offsets[i])));
16111613

1612-
byteSize = AlignUp16(offset);
1614+
if(align)
1615+
offset = AlignUp16(offset);
1616+
byteSize = offset;
16131617
}
16141618

16151619
static void AddTaskShaderPayloadStores(const rdcarray<SpecConstant> &specInfo,
@@ -1676,7 +1680,7 @@ static void AddTaskShaderPayloadStores(const rdcarray<SpecConstant> &specInfo,
16761680

16771681
payloadBlockStructType = payloadTaskStructType = type.InnerType();
16781682
rdcspv::SparseIdMap<rdcspv::Id> outputTypeReplacements;
1679-
LayOutStorageStruct(editor, specInfo, outputTypeReplacements,
1683+
LayOutStorageStruct(editor, specInfo, true, outputTypeReplacements,
16801684
editor.GetDataType(payloadBlockStructType), payloadBlockStructType,
16811685
payloadSize);
16821686
break;
@@ -1961,7 +1965,7 @@ static void ConvertToFixedTaskFeeder(const rdcarray<SpecConstant> &specInfo,
19611965

19621966
uint32_t byteSize = 0;
19631967
rdcspv::SparseIdMap<rdcspv::Id> outputTypeReplacements;
1964-
LayOutStorageStruct(editor, specInfo, outputTypeReplacements,
1968+
LayOutStorageStruct(editor, specInfo, true, outputTypeReplacements,
19651969
editor.GetDataType(payloadBlockStructType), payloadBlockStructType,
19661970
byteSize);
19671971

@@ -2336,7 +2340,8 @@ static void AddMeshShaderOutputStores(const ShaderReflection &refl,
23362340

23372341
if(type.type == rdcspv::DataType::StructType)
23382342
{
2339-
LayOutStorageStruct(editor, specInfo, outputTypeReplacements, type, arrayInnerType, byteSize);
2343+
LayOutStorageStruct(editor, specInfo, true, outputTypeReplacements, type, arrayInnerType,
2344+
byteSize);
23402345

23412346
stride = byteSize;
23422347

0 commit comments

Comments
 (0)