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

@ -63,16 +63,16 @@ layout(location = 1, component = 1) out; // ERROR, no global set
layout(location = 50, component = 3) out int be;
layout(location = 50, component = 0) out vec3 bf;
//layout(location = 51, component = 1) out double dfo; // ERROR, odd component
//layout(location = 52, component = 2) out dvec2 dvo; // ERROR, overflow
//layout(location = 53) out double dfo2;
//layout(location = 53, component = 2) out vec2 ffv2; // okay, fits
//layout(location = 54) out dvec4 dvec4out; // uses up location 55 too
//layout(location = 55) out float overf; // ERROR, collides with previous dvec4
//layout(location = 56, component = 1) out vec2 df2o;
//layout(location = 56, component = 3) out float sf2o;
//layout(location = 57, component = 2) out vec2 dv3o;
//layout(location = 57, component = 3) out float sf4o; // ERROR, overlapping component
layout(location = 51, component = 1) out double dfo; // ERROR, odd component
layout(location = 52, component = 2) out dvec2 dvo; // ERROR, overflow
layout(location = 53) out double dfo2;
layout(location = 53, component = 2) out vec2 ffv2; // okay, fits
layout(location = 54) out dvec4 dvec4out; // uses up location 55 too
layout(location = 55) out float overf; // ERROR, collides with previous dvec4
layout(location = 56, component = 1) out vec2 df2o;
layout(location = 56, component = 3) out float sf2o;
layout(location = 57, component = 2) out vec2 dv3o;
layout(location = 57, component = 3) out float sf4o; // ERROR, overlapping component
out bblck1 {
vec4 bbv;

View File

@ -19,6 +19,10 @@ ERROR: 0:55: 'component' : type overflows the available 4 components
ERROR: 0:57: 'component' : cannot apply to a matrix, structure, or block
ERROR: 0:58: 'component' : cannot apply to a matrix, structure, or block
ERROR: 0:61: 'location/component/index' : cannot declare a default, use a full declaration
ERROR: 0:66: 'component' : doubles cannot start on an odd-numbered component
ERROR: 0:67: 'component' : type overflows the available 4 components
ERROR: 0:71: 'location' : overlapping use of location 55
ERROR: 0:75: 'location' : overlapping use of location 57
ERROR: 0:92: 'xfb layout qualifier' : can only be used on an output
ERROR: 0:98: 'xfb_offset' : cannot declare a default, use a full declaration
ERROR: 0:108: 'xfb_buffer' : member cannot contradict block (or what block inherited from global)
@ -49,7 +53,7 @@ ERROR: 0:184: 'assign' : l-value required "gl_BaseVertexARB" (can't modify shad
ERROR: 0:185: 'assign' : l-value required "gl_BaseInstanceARB" (can't modify shader input)
ERROR: 0:186: 'assign' : l-value required "gl_DrawIDARB" (can't modify shader input)
ERROR: 0:187: 'glBaseInstanceARB' : undeclared identifier
ERROR: 49 compilation errors. No code generated.
ERROR: 53 compilation errors. No code generated.
Shader version: 440
@ -119,6 +123,16 @@ ERROR: node is still EOpNull!
0:? 'bd' (out block{layout(location=40 component=2 ) out float u, layout(location=40 component=0 ) out float v, layout(location=40 component=3 ) out float w, layout(location=40 component=1 ) out 2-component vector of float x, layout(location=41 component=3 ) out 2-component vector of float y, layout(location=42 component=1 ) out 4-component vector of float z, layout(location=42 component=1 ) out 4X4 matrix of float ba, layout(location=43 component=1 ) out structure{global int a} Ss})
0:? 'be' (layout(location=50 component=3 ) smooth out int)
0:? 'bf' (layout(location=50 component=0 ) smooth out 3-component vector of float)
0:? 'dfo' (layout(location=51 component=1 ) smooth out double)
0:? 'dvo' (layout(location=52 component=2 ) smooth out 2-component vector of double)
0:? 'dfo2' (layout(location=53 ) smooth out double)
0:? 'ffv2' (layout(location=53 component=2 ) smooth out 2-component vector of float)
0:? 'dvec4out' (layout(location=54 ) smooth out 4-component vector of double)
0:? 'overf' (layout(location=55 ) smooth out float)
0:? 'df2o' (layout(location=56 component=1 ) smooth out 2-component vector of float)
0:? 'sf2o' (layout(location=56 component=3 ) smooth out float)
0:? 'dv3o' (layout(location=57 component=2 ) smooth out 2-component vector of float)
0:? 'sf4o' (layout(location=57 component=3 ) smooth out float)
0:? 'bbinst1' (out block{out 4-component vector of float bbv})
0:? 'bbinst2' (out block{layout(xfb_buffer=0 xfb_offset=64 ) out 4-component vector of float bbv})
0:? 'bbinst3' (out block{layout(xfb_buffer=3 xfb_offset=16 ) out 4-component vector of float bbv})
@ -219,6 +233,16 @@ ERROR: node is still EOpNull!
0:? 'bd' (out block{layout(location=40 component=2 ) out float u, layout(location=40 component=0 ) out float v, layout(location=40 component=3 ) out float w, layout(location=40 component=1 ) out 2-component vector of float x, layout(location=41 component=3 ) out 2-component vector of float y, layout(location=42 component=1 ) out 4-component vector of float z, layout(location=42 component=1 ) out 4X4 matrix of float ba, layout(location=43 component=1 ) out structure{global int a} Ss})
0:? 'be' (layout(location=50 component=3 ) smooth out int)
0:? 'bf' (layout(location=50 component=0 ) smooth out 3-component vector of float)
0:? 'dfo' (layout(location=51 component=1 ) smooth out double)
0:? 'dvo' (layout(location=52 component=2 ) smooth out 2-component vector of double)
0:? 'dfo2' (layout(location=53 ) smooth out double)
0:? 'ffv2' (layout(location=53 component=2 ) smooth out 2-component vector of float)
0:? 'dvec4out' (layout(location=54 ) smooth out 4-component vector of double)
0:? 'overf' (layout(location=55 ) smooth out float)
0:? 'df2o' (layout(location=56 component=1 ) smooth out 2-component vector of float)
0:? 'sf2o' (layout(location=56 component=3 ) smooth out float)
0:? 'dv3o' (layout(location=57 component=2 ) smooth out 2-component vector of float)
0:? 'sf4o' (layout(location=57 component=3 ) smooth out float)
0:? 'bbinst1' (out block{out 4-component vector of float bbv})
0:? 'bbinst2' (out block{layout(xfb_buffer=0 xfb_offset=64 ) out 4-component vector of float bbv})
0:? 'bbinst3' (out block{layout(xfb_buffer=3 xfb_offset=16 ) out 4-component vector of float bbv})

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