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:
John Kessenich 2017-04-05 17:38:20 -06:00
parent 6f1e595dbc
commit 4f1403ed1b
12 changed files with 276 additions and 10 deletions

View file

@ -1047,9 +1047,9 @@ unsigned int TIntermediate::computeTypeXfbSize(const TType& type, bool& contains
const int baseAlignmentVec4Std140 = 16;
// Return the size and alignment of a scalar.
// Return the size and alignment of a component of the given type.
// The size is returned in the 'size' parameter
// Return value is the alignment of the type.
// Return value is the alignment..
int TIntermediate::getBaseAlignmentScalar(const TType& type, int& size)
{
switch (type.getBasicType()) {
@ -1219,4 +1219,14 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, b
return baseAlignmentVec4Std140;
}
// To aid the basic HLSL rule about crossing vec4 boundaries.
bool TIntermediate::improperStraddle(const TType& type, int size, int offset)
{
if (! type.isVector() || type.isArray())
return false;
return size <= 16 ? offset / 16 != (offset + size - 1) / 16
: offset % 16 != 0;
}
} // end namespace glslang