Pārlūkot izejas kodu

force flush in sync()

ncannasse 9 gadi atpakaļ
vecāks
revīzija
c645495e56
1 mainītis faili ar 14 papildinājumiem un 1 dzēšanām
  1. 14 1
      h2d/TileGroup.hx

+ 14 - 1
h2d/TileGroup.hx

@@ -302,8 +302,12 @@ private class TileLayerContent extends h3d.prim.Primitive {
 		buffer = h3d.Buffer.ofFloats(tmp, 8, [Quads, RawFormat]);
 	}
 
-	public function doRender(engine, min, len) {
+	public inline function flush() {
 		if( buffer == null || buffer.isDisposed() ) alloc(engine);
+	}
+
+	public function doRender(engine, min, len) {
+		flush();
 		engine.renderQuadBuffer(buffer, min, len);
 	}
 
@@ -371,6 +375,15 @@ class TileGroup extends Drawable {
 		drawWith(ctx,this);
 	}
 
+
+	override function sync( ctx : RenderContext ) {
+		super.sync(ctx);
+		// On some mobile GPU, uploading while rendering does create a lot of stall.
+		// Let's make sure to force the upload before starting while we are still
+		// syncing our 2d scene.
+		content.flush();
+	}
+
 	@:allow(h2d)
 	function drawWith( ctx:RenderContext, obj : Drawable ) {
 		ctx.beginDrawObject(obj, tile.getTexture());