Fix HLSL offsets for non-cbuffers (#3668)

This commit is contained in:
Pavel Asyutchenko 2024-07-29 19:34:50 +02:00 committed by arcady-lunarg
parent 4b73607b89
commit 9f34b25f30
4 changed files with 105 additions and 7 deletions

View file

@ -5404,13 +5404,16 @@ void TGlslangToSpvTraverser::updateMemberOffset(const glslang::TType& structType
memberAlignment = componentAlignment;
// Don't add unnecessary padding after this member
if (memberType.isMatrix()) {
if (matrixLayout == glslang::ElmRowMajor)
memberSize -= componentSize * (4 - memberType.getMatrixCols());
else
memberSize -= componentSize * (4 - memberType.getMatrixRows());
} else if (memberType.isArray())
memberSize -= componentSize * (4 - memberType.getVectorSize());
// (undo std140 bumping size to a mutliple of vec4)
if (explicitLayout == glslang::ElpStd140) {
if (memberType.isMatrix()) {
if (matrixLayout == glslang::ElmRowMajor)
memberSize -= componentSize * (4 - memberType.getMatrixCols());
else
memberSize -= componentSize * (4 - memberType.getMatrixRows());
} else if (memberType.isArray())
memberSize -= componentSize * (4 - memberType.getVectorSize());
}
}
// Bump up to member alignment