浏览代码

per-context instance

ncannasse 7 年之前
父节点
当前提交
bc48be6317
共有 1 个文件被更改,包括 7 次插入3 次删除
  1. 7 3
      h3d/pass/Copy.hx

+ 7 - 3
h3d/pass/Copy.hx

@@ -50,11 +50,15 @@ class Copy extends ScreenFx<CopyShader> {
 		engine.popTarget();
 	}
 
-	static var inst : Copy;
 	public static function run( from : h3d.mat.Texture, to : h3d.mat.Texture, ?blend : h3d.mat.BlendMode, ?pass : h3d.mat.Pass ) {
-		if( to != null && from != null && (blend == null || blend == None) && pass == null && h3d.Engine.getCurrent().driver.copyTexture(from, to) )
+		var engine = h3d.Engine.getCurrent();
+		if( to != null && from != null && (blend == null || blend == None) && pass == null && engine.driver.copyTexture(from, to) )
 			return;
-		if( inst == null ) inst = new Copy();
+		var inst : Copy = @:privateAccess engine.resCache.get(Copy);
+		if( inst == null ) {
+			inst = new Copy();
+			@:privateAccess engine.resCache.set(Copy, inst);
+		}
 		return inst.apply(from, to, blend, pass);
 	}