Ver código fonte

clear CacheAllocator on device lost

trethaller 5 anos atrás
pai
commit
b1c8cd2fd8
3 arquivos alterados com 10 adições e 2 exclusões
  1. 3 2
      h3d/Engine.hx
  2. 3 0
      hxd/impl/Allocator.hx
  3. 4 0
      hxd/impl/CacheAllocator.hx

+ 3 - 2
h3d/Engine.hx

@@ -227,9 +227,10 @@ class Engine {
 			width = window.width;
 			height = window.height;
 		}
-		if( disposed )
+		if( disposed ) {
+			hxd.impl.Allocator.get().onContextLost();
 			mem.onContextLost();
-		else {
+		} else {
 			mem = new h3d.impl.MemoryManager(driver);
 			mem.init();
 		}

+ 3 - 0
hxd/impl/Allocator.hx

@@ -32,6 +32,9 @@ class Allocator {
 		i.dispose();
 	}
 
+	public function onContextLost() {
+	}
+
 	// CPU
 
 	public function allocFloats( count : Int, ?pos : AllocPos ) : hxd.FloatBuffer {

+ 4 - 0
hxd/impl/CacheAllocator.hx

@@ -59,6 +59,10 @@ class CacheAllocator extends Allocator {
 		checkGC();
 	}
 
+	override function onContextLost() {
+		buffers = new Map();
+	}
+
 	public function checkGC() {
 		var t = haxe.Timer.stamp();
 		if( t - lastGC > maxKeepTime * 0.1 ) gc();