Browse Source

fixes for sampler change

Nicolas Cannasse 1 year ago
parent
commit
b02ab0ad2f
1 changed files with 11 additions and 9 deletions
  1. 11 9
      hxsl/Flatten.hx

+ 11 - 9
hxsl/Flatten.hx

@@ -230,7 +230,7 @@ class Flatten {
 			if( !v.type.equals(t) ) {
 			if( !v.type.equals(t) ) {
 				switch( v.type ) {
 				switch( v.type ) {
 				case TChannel(_) if( t.match(TSampler(T2D,false)) ):
 				case TChannel(_) if( t.match(TSampler(T2D,false)) ):
-				case TArray(t2,SConst(n)) if( t2 == t ):
+				case TArray(t2,SConst(n)) if( t2.equals(t) ):
 					count = n;
 					count = n;
 				default:
 				default:
 					continue;
 					continue;
@@ -358,6 +358,13 @@ class Flatten {
 		}
 		}
 	}
 	}
 
 
+	function addTextureFormat(dim,arr,rw=0) {
+		for( f in textureFormats )
+			if( f.dim == dim && f.arr == arr && f.rw == rw )
+				return;
+		textureFormats.push({ dim : dim, arr : arr, rw : rw });
+	}
+
 	function gatherVar( v : TVar ) {
 	function gatherVar( v : TVar ) {
 		switch( v.type ) {
 		switch( v.type ) {
 		case TStruct(vl):
 		case TStruct(vl):
@@ -369,14 +376,9 @@ class Flatten {
 			case TRWTexture(_,_,chans): chans;
 			case TRWTexture(_,_,chans): chans;
 			default: 0;
 			default: 0;
 			}
 			}
-			var found = false;
-			for( f in textureFormats )
-				if( f.dim == dim && f.arr == arr && f.rw == rw ) {
-					found = true;
-					break;
-				}
-			if( !found )
-				textureFormats.push({ dim : dim, arr : arr, rw : rw });
+			addTextureFormat(dim,arr,rw);
+		case TChannel(_):
+			addTextureFormat(T2D,false);
 		default:
 		default:
 		}
 		}
 		switch( v.kind ) {
 		switch( v.kind ) {