|
@@ -23,11 +23,8 @@ class Buffer {
|
|
|
var allocPos : hxd.impl.AllocPos;
|
|
|
var allocNext : Buffer;
|
|
|
#end
|
|
|
- #if multidriver
|
|
|
- var driver : h3d.impl.Driver;
|
|
|
- #end
|
|
|
+ var engine : h3d.Engine;
|
|
|
|
|
|
- var mem : h3d.impl.MemoryManager;
|
|
|
@:allow(h3d.impl.Driver) var vbuf : h3d.impl.Driver.GPUBuffer;
|
|
|
public var vertices(default,null) : Int;
|
|
|
public var format(default,null) : hxd.BufferFormat;
|
|
@@ -44,8 +41,9 @@ class Buffer {
|
|
|
if( flags != null )
|
|
|
for( f in flags )
|
|
|
this.flags.set(f);
|
|
|
+ engine = h3d.Engine.getCurrent();
|
|
|
if( !this.flags.has(NoAlloc) )
|
|
|
- @:privateAccess h3d.Engine.getCurrent().mem.allocBuffer(this);
|
|
|
+ @:privateAccess engine.mem.allocBuffer(this);
|
|
|
}
|
|
|
|
|
|
public inline function getMemSize() {
|
|
@@ -58,7 +56,7 @@ class Buffer {
|
|
|
|
|
|
public function dispose() {
|
|
|
if( vbuf != null ) {
|
|
|
- @:privateAccess mem.freeBuffer(this);
|
|
|
+ @:privateAccess engine.mem.freeBuffer(this);
|
|
|
vbuf = null;
|
|
|
}
|
|
|
}
|
|
@@ -70,7 +68,7 @@ class Buffer {
|
|
|
throw "Can't upload floats on low precision buffer";
|
|
|
if( vertices == 0 )
|
|
|
return;
|
|
|
- mem.driver.uploadBufferData(this, startVertice, vertices, buf, bufPos);
|
|
|
+ engine.driver.uploadBufferData(this, startVertice, vertices, buf, bufPos);
|
|
|
}
|
|
|
|
|
|
public function uploadBytes( data : haxe.io.Bytes, dataPos : Int, vertices : Int ) {
|
|
@@ -78,13 +76,13 @@ class Buffer {
|
|
|
throw "Invalid vertices count";
|
|
|
if( vertices == 0 )
|
|
|
return;
|
|
|
- mem.driver.uploadBufferBytes(this, 0, vertices, data, dataPos);
|
|
|
+ engine.driver.uploadBufferBytes(this, 0, vertices, data, dataPos);
|
|
|
}
|
|
|
|
|
|
public function readBytes( bytes : haxe.io.Bytes, bytesPosition : Int, vertices : Int, startVertice : Int = 0 ) {
|
|
|
if( startVertice < 0 || vertices < 0 || startVertice + vertices > this.vertices )
|
|
|
throw "Invalid vertices count";
|
|
|
- mem.driver.readBufferBytes(this, startVertice, vertices, bytes, bytesPosition);
|
|
|
+ engine.driver.readBufferBytes(this, startVertice, vertices, bytes, bytesPosition);
|
|
|
}
|
|
|
|
|
|
public static function ofFloats( v : hxd.FloatBuffer, format : hxd.BufferFormat, ?flags ) {
|