Explorar o código

MeshBatch : Reduced allocation for countBuffer

TothBenoit hai 1 ano
pai
achega
bc7d41d4a9
Modificáronse 1 ficheiros con 5 adicións e 3 borrados
  1. 5 3
      h3d/scene/MeshBatch.hx

+ 5 - 3
h3d/scene/MeshBatch.hx

@@ -271,7 +271,7 @@ class MeshBatch extends MultiMaterial {
 	inline function isCountBufferAllowed() {
 		#if hlsdl
 		return h3d.impl.GlDriver.hasMultiIndirectCount;
-		#else		
+		#else
 		return true;
 		#end
 	}
@@ -935,8 +935,10 @@ class MeshBatch extends MultiMaterial {
 						computeShader.instanceData = buf;
 						computeShader.matIndex = p.matIndex;
 						computeShader.commandBuffer = p.commandBuffers[i];
-						countBytes = haxe.io.Bytes.alloc(4*4);
-						countBytes.setInt32(0, 0);
+						if ( countBytes == null ) {
+							countBytes = haxe.io.Bytes.alloc(4*4);
+							countBytes.setInt32(0, 0);
+						}
 						p.countBuffers[i].uploadBytes(countBytes, 0, 1);
 						computeShader.countBuffer = p.countBuffers[i];
 						computeShader.startInstanceOffset = emittedCount;