SPV: Fix #807: use --hlsl-offsets to allow hlsl-style offsets in a buffer.
Corresponds to the EShMsgHlslOffsets flag in messages. Works for both GLSL and HLSL.
This commit is contained in:
@@ -2728,7 +2728,23 @@ void TGlslangToSpvTraverser::updateMemberOffset(const glslang::TType& /*structTy
|
||||
int memberSize;
|
||||
int dummyStride;
|
||||
int memberAlignment = glslangIntermediate->getBaseAlignment(memberType, memberSize, dummyStride, explicitLayout == glslang::ElpStd140, matrixLayout == glslang::ElmRowMajor);
|
||||
|
||||
// Adjust alignment for HLSL rules
|
||||
if (glslangIntermediate->usingHlslOFfsets() &&
|
||||
! memberType.isArray() && memberType.isVector()) {
|
||||
int dummySize;
|
||||
int componentAlignment = glslangIntermediate->getBaseAlignmentScalar(memberType, dummySize);
|
||||
if (componentAlignment <= 4)
|
||||
memberAlignment = componentAlignment;
|
||||
}
|
||||
|
||||
// Bump up to member alignment
|
||||
glslang::RoundToPow2(currentOffset, memberAlignment);
|
||||
|
||||
// Bump up to vec4 if there is a bad straddle
|
||||
if (glslangIntermediate->improperStraddle(memberType, memberSize, currentOffset))
|
||||
glslang::RoundToPow2(currentOffset, 16);
|
||||
|
||||
nextOffset = currentOffset + memberSize;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user