Skip to content

Commit 77f07ed

Browse files
Fix FIFOBufferAllocator.hx vertex mismatch on buffer larger than 65536
1 parent 5d01387 commit 77f07ed

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

hxd/impl/FIFOBufferAllocator.hx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,29 @@ class FIFOBufferAllocator extends Allocator {
7777
public var maxMemSize : Int = 512 * 1024 * 1024;
7878

7979
override function allocBuffer(vertices:Int, format:hxd.BufferFormat, flags:BufferFlags=Dynamic):h3d.Buffer {
80-
if( vertices >= 65536 ) {
81-
switch ( flags ) {
82-
case UniformReadWrite:
83-
default: throw "assert";
84-
}
85-
}
80+
if( vertices >= 65536 )
81+
return super.allocBuffer(vertices, format, flags);
8682
checkFrame();
8783
var id = flags.toInt() | (format.uid << 3) | (vertices << 16);
8884
var c = buffers.get(id);
8985
if( c != null ) {
9086
var b = c.get();
91-
if( b != null ) return b;
87+
if( b != null ) {
88+
if ( b.vertices != vertices )
89+
throw "Buffer signature mismatch";
90+
return b;
91+
}
9292
}
9393
checkGC();
9494
return super.allocBuffer(vertices,format,flags);
9595
}
9696

9797
override function disposeBuffer(b:h3d.Buffer) {
9898
if( b.isDisposed() ) return;
99+
if ( b.vertices >= 65536 ) {
100+
b.dispose();
101+
return;
102+
}
99103
var id = fromBufferFlags(b.flags).toInt() | (b.format.uid << 3) | (b.vertices << 16);
100104
var c = buffers.get(id);
101105
if( c == null ) {

0 commit comments

Comments
 (0)