瀏覽代碼

Fix bug where too many buffer (more than 4) in a same shader have their access offsetted.

borisrp 6 月之前
父節點
當前提交
565d19f29a
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      hxsl/Flatten.hx

+ 6 - 1
hxsl/Flatten.hx

@@ -247,7 +247,12 @@ class Flatten {
 	}
 
 	inline function readOffset( a : Alloc, stride : Int, delta : TExpr, index : Int, pos ) : TExpr {
-		var index = (a.t == null ? a.pos : a.pos >> 2) + index;
+		var index = switch( a.g.type ) {
+			case TBuffer(_,_,_) :
+				index;
+			default :
+				(a.t == null ? a.pos : a.pos >> 2) + index;
+		}
 		var offset : TExpr = mkAdd(delta,index,pos);
 		return { e : TArray({ e : TVar(a.g), t : a.g.type, p : pos }, offset), t : TVec(4,a.t), p:pos };
 	}