Front-end: Fix default layout(component) widths and correct for doubles.

Replaces PR #372.
This commit is contained in:
John Kessenich
2016-07-21 15:43:00 -06:00
parent bc9e1d118a
commit c8f6903b1d
5 changed files with 52 additions and 16 deletions

View File

@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "SPIRV99.1331"
#define GLSLANG_REVISION "SPIRV99.1332"
#define GLSLANG_DATE "21-Jul-2016"

View File

@@ -4475,12 +4475,17 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
}
if (qualifier.hasComponent()) {
// "It is a compile-time error if this sequence of components gets larger than 3."
if (qualifier.layoutComponent + type.getVectorSize() > 4)
if (qualifier.layoutComponent + type.getVectorSize() * (type.getBasicType() == EbtDouble ? 2 : 1) > 4)
error(loc, "type overflows the available 4 components", "component", "");
// "It is a compile-time error to apply the component qualifier to a matrix, a structure, a block, or an array containing any of these."
if (type.isMatrix() || type.getBasicType() == EbtBlock || type.getBasicType() == EbtStruct)
error(loc, "cannot apply to a matrix, structure, or block", "component", "");
// " It is a compile-time error to use component 1 or 3 as the beginning of a double or dvec2."
if (type.getBasicType() == EbtDouble)
if (qualifier.layoutComponent & 1)
error(loc, "doubles cannot start on an odd-numbered component", "component", "");
}
switch (qualifier.storage) {

View File

@@ -664,12 +664,19 @@ int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& typ
size = computeTypeLocationSize(type);
}
// locations...
TRange locationRange(qualifier.layoutLocation, qualifier.layoutLocation + size - 1);
// components in this location slot...
TRange componentRange(0, 3);
if (qualifier.hasComponent()) {
componentRange.start = qualifier.layoutComponent;
componentRange.last = componentRange.start + type.getVectorSize() - 1;
if (qualifier.hasComponent() || type.getVectorSize() > 0) {
int consumedComponents = type.getVectorSize() * (type.getBasicType() == EbtDouble ? 2 : 1);
if (qualifier.hasComponent())
componentRange.start = qualifier.layoutComponent;
componentRange.last = componentRange.start + consumedComponents - 1;
}
// both...
TIoRange range(locationRange, componentRange, type.getBasicType(), qualifier.hasIndex() ? qualifier.layoutIndex : 0);
// check for collisions, except for vertex inputs on desktop