浏览代码

fixed batching of varying

Nicolas Cannasse 5 年之前
父节点
当前提交
1643c769ac
共有 1 个文件被更改,包括 20 次插入6 次删除
  1. 20 6
      hxsl/Cache.hx

+ 20 - 6
hxsl/Cache.hx

@@ -210,6 +210,26 @@ class Cache {
 			throw e;
 		}
 
+		if( batchMode ) {
+			function checkRec( v : TVar ) {
+				if( v.qualifiers != null && v.qualifiers.indexOf(PerObject) >= 0 ) {
+					if( v.qualifiers.length == 1 ) v.qualifiers = null else {
+						v.qualifiers = v.qualifiers.copy();
+						v.qualifiers.remove(PerObject);
+					}
+					if( v.kind != Var ) v.kind = Local;
+				}
+				switch( v.type ) {
+				case TStruct(vl):
+					for( v in vl )
+						checkRec(v);
+				default:
+				}
+			}
+			for( v in s.vars )
+				checkRec(v);
+		}
+
 		#if debug
 		Printer.check(s,[for( s in shaderDatas ) s.inst.shader]);
 		#end
@@ -236,12 +256,6 @@ class Cache {
 		var prev = s;
 		var s = try new hxsl.Splitter().split(s) catch( e : Error ) { e.msg += "\n\nin\n\n"+Printer.shaderToString(s); throw e; };
 
-		if( batchMode ) {
-			for( v in s.vertex.vars )
-				if( v.qualifiers != null && v.qualifiers.indexOf(PerObject) >= 0 )
-					v.kind = Local;
-		}
-
 		#if debug
 		Printer.check(s.vertex,[prev]);
 		Printer.check(s.fragment,[prev]);