Skip to content

Commit 8fe08b5

Browse files
committed
InstanceBuffer : Added optionnal triCount param to avoid updateTriCount cost
1 parent f3940e7 commit 8fe08b5

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

h3d/impl/InstanceBuffer.hx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ class InstanceBuffer {
3737
this.startIndex = startIndex;
3838
}
3939

40-
function updateTriCount(commandCount : Int, bytes : haxe.io.Bytes)
41-
{
40+
function updateTriCount(commandCount : Int, bytes : haxe.io.Bytes) {
4241
triCount = 0;
4342
for( i in 0...commandCount ) {
4443
var idxCount = bytes.getInt32(i * ELEMENT_SIZE);
@@ -48,18 +47,21 @@ class InstanceBuffer {
4847
}
4948
}
5049

51-
public function uploadBytes(commandCount : Int, bytes : haxe.io.Bytes) {
52-
updateTriCount(commandCount, bytes);
50+
public function uploadBytes(commandCount : Int, bytes : haxe.io.Bytes, triCount = -1) {
51+
this.triCount = triCount;
52+
if ( triCount < 0 )
53+
updateTriCount(commandCount, bytes);
5354
this.commandCount = commandCount;
5455
this.indexCount = 0;
5556
driver = h3d.Engine.getCurrent().driver;
5657
driver.uploadInstanceBufferBytes(this, 0, commandCount, bytes, 0);
5758
}
5859

59-
public function allocFromBytes(commandCount : Int, bytes : haxe.io.Bytes) {
60+
public function allocFromBytes(commandCount : Int, bytes : haxe.io.Bytes, triCount = -1 ) {
6061
dispose();
61-
62-
updateTriCount(commandCount, bytes);
62+
this.triCount = triCount;
63+
if ( triCount < 0 )
64+
updateTriCount(commandCount, bytes);
6365
this.commandCount = this.maxCommandCount = commandCount;
6466
this.indexCount = 0;
6567
driver = h3d.Engine.getCurrent().driver;

0 commit comments

Comments
 (0)