@@ -102,6 +102,7 @@ enum VarQualifier {
Borrow( source : String );
Sampler( name : String );
Final;
+ Flat;
}
enum Prec {
@@ -801,7 +801,7 @@ class Checker {
checkConst(e);
einit = e;
- if( v.type == null ) error("Type required for variable declaration", e.pos);
+ if( v.type == null ) error("Type required for variable declaration", e.pos);
if( isImport && v.kind == Param )
continue;
@@ -874,6 +874,7 @@ class Checker {
name : v.name,
kind : v.kind,
type : v.type,
+ qualifiers : v.qualifiers
};
if( parent != null )
tv.parent = parent;
@@ -932,6 +933,7 @@ class Checker {
default: error("Sampler should be on sampler type or sampler array", pos);
case Ignore, Doc(_):
+ case Flat: if( tv.kind != Local ) error("flat only allowed on local", pos);
if( tv.type != null )
@@ -168,6 +168,7 @@ class Flatten {
type : TArray(TVec(4,VFloat),SConst(size)),
var a = new Alloc(v2,VFloat,0,0);
a.v = v;
@@ -746,6 +746,8 @@ class GlslOut {
case Input:
add( isES2 ? "attribute " : "in ");
case Var:
+ if ( Tools.hasQualifier(v, Flat) )
+ add("flat ");
add( isES2 ? "varying " : (isVertex ? "out " : "in "));
case Output:
if( isES2 ) {
@@ -78,6 +78,8 @@ class MacroParser {
v.qualifiers.push(Ignore);
case "perInstance":
v.qualifiers.push(PerInstance(1));
+ case "flat":
+ v.qualifiers.push(Flat);
default:
error("Unsupported qualifier " + m.name, m.pos);
@@ -65,6 +65,7 @@ class Printer {
case Borrow(s): "borrow(" + s + ")";
case Sampler(s): "sampler("+ s + ")";
case Final: "final";
+ case Flat: "flat";
}) + " ");
if( v.kind != defKind )
@@ -209,7 +209,7 @@ class Serializer {
for( q in v.qualifiers ) {
out.addByte(q.getIndex());
switch (q) {
- case Private, Nullable, PerObject, Shared, Ignore, Final:
+ case Private, Nullable, PerObject, Shared, Ignore, Final, Flat:
case Const(max): out.addInt32(max == null ? 0 : max);
case Name(n): writeString(n);
case Precision(p): out.addByte(p.getIndex());
@@ -439,6 +439,7 @@ class Serializer {
case 11: Borrow(readString());
case 12: Sampler(readString());
case 13: Final;
+ case 14: Flat;
default: throw "assert";
v.qualifiers.push(q);
@@ -261,8 +261,17 @@ class Splitter {
- if( v.qualifiers != null && v.qualifiers.indexOf(Final) >= 0 )
- nv.qualifiers = [Final];
+ if( v.qualifiers != null ) {
+ for ( q in v.qualifiers ) {
+ switch (q) {
+ case Final, Flat:
+ if ( nv.qualifiers == null )
+ nv.qualifiers = [];
+ nv.qualifiers.push(q);
+ case Const(_), Private, Nullable, PerObject, Name(_), Shared, Precision(_), Range(_,_), Ignore, PerInstance(_), Doc(_), Borrow(_), Sampler(_):
+ }
uniqueName(nv);
varMap.set(v,nv);