Forráskód Böngészése

refactor alloc position : now full stack available, and position extracted from user code.

Nicolas Cannasse 5 éve
szülő
commit
4776300cc2

+ 15 - 8
h2d/Graphics.hx

@@ -32,11 +32,15 @@ private class GraphicsContent extends h3d.prim.Primitive {
 	var buffers : Array<{ buf : hxd.FloatBuffer, vbuf : h3d.Buffer, idx : hxd.IndexBuffer, ibuf : h3d.Indexes }>;
 	var bufferDirty : Bool;
 	var indexDirty : Bool;
-	var allocPos : h3d.impl.AllocPos;
+	#if track_alloc
+	var allocPos : hxd.impl.AllocPos;
+	#end
 
-	public function new(allocPos) {
+	public function new() {
 		buffers = [];
-		this.allocPos = allocPos;
+		#if track_alloc
+		this.allocPos = new hxd.impl.AllocPos();
+		#end
 	}
 
 	public inline function addIndex(i) {
@@ -69,7 +73,10 @@ private class GraphicsContent extends h3d.prim.Primitive {
 
 	override function alloc( engine : h3d.Engine ) {
 		if (index.length <= 0) return ;
-		buffer = h3d.Buffer.ofFloats(tmp, 8, [RawFormat], allocPos);
+		buffer = h3d.Buffer.ofFloats(tmp, 8, [RawFormat]);
+		#if track_alloc
+		@:privateAccess buffer.allocPos = allocPos;
+		#end
 		indexes = h3d.Indexes.alloc(index);
 		for( b in buffers ) {
 			if( b.vbuf == null || b.vbuf.isDisposed() ) b.vbuf = h3d.Buffer.ofFloats(b.buf, 8, [RawFormat]);
@@ -155,9 +162,9 @@ class Graphics extends Drawable {
 	public var tile : h2d.Tile;
 	public var bevel = 0.25; //0 = not beveled, 1 = always beveled
 
-	public function new(?parent,?allocPos:h3d.impl.AllocPos) {
+	public function new(?parent) {
 		super(parent);
-		content = new GraphicsContent(allocPos);
+		content = new GraphicsContent();
 		tile = h2d.Tile.fromColor(0xFFFFFF);
 		clear();
 	}
@@ -537,7 +544,7 @@ class Graphics extends Drawable {
 		lineTo(cx, cy);
 		flush();
 	}
-	
+
 	public function drawRectanglePie( cx : Float, cy : Float, width : Float, height : Float, angleStart:Float, angleLength:Float, nsegments = 0 ) {
 		if(Math.abs(angleLength) >= Math.PI*2) {
 			return drawRect(cx-(width/2), cy-(height/2), width, height);
@@ -584,7 +591,7 @@ class Graphics extends Drawable {
 	 * @param cy control Y for end point
 	 * @param dx end X
 	 * @param dy end Y
-	 * @param nsegments = 40 
+	 * @param nsegments = 40
 	 */
 	public function cubicCurveTo( bx : Float, by : Float, cx : Float, cy : Float, dx : Float, dy : Float, nsegments = 40) {
 		var ax = tmpPoints.length == 0 ? 0 : tmpPoints[tmpPoints.length - 1].x;

+ 7 - 7
h2d/Tile.hx

@@ -194,20 +194,20 @@ class Tile {
 	}
 
 
-	public static function fromColor( color : Int, ?width = 1, ?height = 1, ?alpha = 1., ?allocPos : h3d.impl.AllocPos ) : Tile {
-		var t = new Tile(h3d.mat.Texture.fromColor(color,alpha,allocPos),0,0,1,1);
+	public static function fromColor( color : Int, ?width = 1, ?height = 1, ?alpha = 1. ) : Tile {
+		var t = new Tile(h3d.mat.Texture.fromColor(color,alpha),0,0,1,1);
 		// scale to size
 		t.width = width;
 		t.height = height;
 		return t;
 	}
 
-	public static function fromBitmap( bmp : hxd.BitmapData, ?allocPos : h3d.impl.AllocPos ) : Tile {
-		var tex = h3d.mat.Texture.fromBitmap(bmp, allocPos);
+	public static function fromBitmap( bmp : hxd.BitmapData ) : Tile {
+		var tex = h3d.mat.Texture.fromBitmap(bmp);
 		return new Tile(tex, 0, 0, bmp.width, bmp.height);
 	}
 
-	public static function autoCut( bmp : hxd.BitmapData, width : Int, ?height : Int, ?allocPos : h3d.impl.AllocPos ) {
+	public static function autoCut( bmp : hxd.BitmapData, width : Int, ?height : Int ) {
 		#if js
 		bmp.lock();
 		#end
@@ -219,7 +219,7 @@ class Tile {
 			w <<= 1;
 		while( h < bmp.height )
 			h <<= 1;
-		var tex = new h3d.mat.Texture(w, h, allocPos);
+		var tex = new h3d.mat.Texture(w, h);
 		for( y in 0...Std.int(bmp.height / height) ) {
 			var a = [];
 			tl[y] = a;
@@ -242,7 +242,7 @@ class Tile {
 		return new Tile(t, 0, 0, t.width, t.height);
 	}
 
-	public static function fromPixels( pixels : hxd.Pixels, ?allocPos : h3d.impl.AllocPos ) : Tile {
+	public static function fromPixels( pixels : hxd.Pixels ) : Tile {
 		var pix2 = pixels.makeSquare(true);
 		var t = h3d.mat.Texture.fromPixels(pix2);
 		if( pix2 != pixels ) pix2.dispose();

+ 9 - 9
h3d/Buffer.hx

@@ -34,8 +34,8 @@ enum BufferFlag {
 class Buffer {
 	public static var GUID = 0;
 	public var id : Int;
-	#if debug
-	var allocPos : h3d.impl.AllocPos;
+	#if track_alloc
+	var allocPos : hxd.impl.AllocPos;
 	var allocNext : Buffer;
 	#end
 
@@ -45,12 +45,12 @@ class Buffer {
 	public var next(default,null) : Buffer;
 	public var flags(default, null) : haxe.EnumFlags<BufferFlag>;
 
-	public function new(vertices, stride, ?flags : Array<BufferFlag>, ?allocPos : h3d.impl.AllocPos ) {
+	public function new(vertices, stride, ?flags : Array<BufferFlag> ) {
 		id = GUID++;
 		this.vertices = vertices;
 		this.flags = new haxe.EnumFlags();
-		#if debug
-		this.allocPos = allocPos;
+		#if track_alloc
+		this.allocPos = new hxd.impl.AllocPos();
 		#end
 		if( flags != null )
 			for( f in flags )
@@ -136,15 +136,15 @@ class Buffer {
 		}
 	}
 
-	public static function ofFloats( v : hxd.FloatBuffer, stride : Int, ?flags, ?allocPos ) {
+	public static function ofFloats( v : hxd.FloatBuffer, stride : Int, ?flags ) {
 		var nvert = Std.int(v.length / stride);
-		var b = new Buffer(nvert, stride, flags, allocPos);
+		var b = new Buffer(nvert, stride, flags);
 		b.uploadVector(v, 0, nvert);
 		return b;
 	}
 
-	public static function ofSubFloats( v : hxd.FloatBuffer, stride : Int, vertices : Int, ?flags, ?allocPos ) {
-		var b = new Buffer(vertices, stride, flags, allocPos);
+	public static function ofSubFloats( v : hxd.FloatBuffer, stride : Int, vertices : Int, ?flags ) {
+		var b = new Buffer(vertices, stride, flags);
 		b.uploadVector(v, 0, vertices);
 		return b;
 	}

+ 6 - 0
h3d/Indexes.hx

@@ -8,12 +8,18 @@ class Indexes {
 	var ibuf : h3d.impl.Driver.IndexBuffer;
 	public var is32(default,null) : Bool;
 	public var count(default,null) : Int;
+	#if track_alloc
+	var allocPos : hxd.impl.AllocPos;
+	#end
 
 	public function new(count,is32=false) {
 		this.mem = h3d.Engine.getCurrent().mem;
 		this.count = count;
 		this.is32 = is32;
 		mem.allocIndexes(this);
+		#if track_alloc
+		allocPos = new hxd.impl.AllocPos();
+		#end
 	}
 
 	public function isDisposed() {

+ 0 - 3
h3d/impl/AllocPos.hx

@@ -1,3 +0,0 @@
-package h3d.impl;
-
-typedef AllocPos = #if debug haxe.PosInfos #else { __alloc : Int } #end

+ 3 - 3
h3d/impl/GlDriver.hx

@@ -1241,15 +1241,15 @@ class GlDriver extends Driver {
 				case "position":
 					pos = 0;
 				case "normal":
-					if( m.stride < 6 ) throw "Buffer is missing NORMAL data, set it to RAW format ?" #if debug + @:privateAccess v.allocPos #end;
+					if( m.stride < 6 ) throw "Buffer is missing NORMAL data, set it to RAW format ?" #if track_alloc + @:privateAccess v.allocPos #end;
 					pos = 3;
 				case "uv":
-					if( m.stride < 8 ) throw "Buffer is missing UV data, set it to RAW format ?" #if debug + @:privateAccess v.allocPos #end;
+					if( m.stride < 8 ) throw "Buffer is missing UV data, set it to RAW format ?" #if track_alloc + @:privateAccess v.allocPos #end;
 					pos = 6;
 				case s:
 					pos = offset;
 					offset += a.size;
-					if( offset > m.stride ) throw "Buffer is missing '"+s+"' data, set it to RAW format ?" #if debug + @:privateAccess v.allocPos #end;
+					if( offset > m.stride ) throw "Buffer is missing '"+s+"' data, set it to RAW format ?" #if track_alloc + @:privateAccess v.allocPos #end;
 				}
 				gl.vertexAttribPointer(a.index, a.size, a.type, false, m.stride * 4, pos * 4);
 				updateDivisor(a);

+ 4 - 4
h3d/impl/ManagedBuffer.hx

@@ -23,7 +23,7 @@ class ManagedBuffer {
 	var vbuf : Driver.VertexBuffer;
 	var freeList : FreeCell;
 	var next : ManagedBuffer;
-	#if debug
+	#if track_alloc
 	var allocHead : Buffer;
 	#end
 
@@ -62,7 +62,7 @@ class ManagedBuffer {
 			b.position = p;
 			b.buffer = this;
 		};
-		#if debug
+		#if track_alloc
 		@:privateAccess b.allocNext = allocHead;
 		allocHead = b;
 		#end
@@ -112,7 +112,7 @@ class ManagedBuffer {
 			b.position = p;
 			b.buffer = this;
 		};
-		#if debug
+		#if track_alloc
 		@:privateAccess b.allocNext = allocHead;
 		allocHead = b;
 		#end
@@ -151,7 +151,7 @@ class ManagedBuffer {
 		}
 		if( nvert != 0 )
 			throw "assert";
-		#if debug
+		#if track_alloc
 		@:privateAccess {
 			var cur = allocHead, prev : Buffer = null;
 			while( cur != null ) {

+ 27 - 9
h3d/impl/MemoryManager.hx

@@ -363,44 +363,62 @@ class MemoryManager {
 		};
 	}
 
+	/**
+	 * Return statistics for currently allocated buffers and textures. Requires -D track-alloc compilation flag
+	 */
 	@:access(h3d.Buffer)
-	public function allocStats() : Array<{ file : String, line : Int, count : Int, tex : Bool, size : Int }> {
-		#if !debug
+	public function allocStats() : Array<{ position : String, count : Int, tex : Bool, size : Int, stacks : Array<{ stack : String, count : Int, size : Int }> }> {
+		#if !track_alloc
 		return [];
 		#else
 		var h = new Map();
 		var all = [];
+		inline function addStack( a : hxd.impl.AllocPos, stacks : Array<{ stack : String, count : Int, size : Int }>, size : Int ) {
+			var stackStr = a.stack.join("\n");
+			for( s in stacks )
+				if( s.stack == stackStr ) {
+					s.size += size;
+					s.count++;
+					stackStr = null;
+				}
+			if( stackStr != null )
+				stacks.push({ stack : stackStr, count : 1, size : size });
+		}
 		for( t in textures ) {
-			var key = "$"+t.allocPos.fileName + ":" + t.allocPos.lineNumber;
+			var key = "$"+t.allocPos.position;
 			var inf = h.get(key);
 			if( inf == null ) {
-				inf = { file : t.allocPos.fileName, line : t.allocPos.lineNumber, count : 0, size : 0, tex : true };
+				inf = { position : t.allocPos.position, count : 0, size : 0, tex : true, stacks : [] };
 				h.set(key, inf);
 				all.push(inf);
 			}
 			inf.count++;
-			inf.size += t.width * t.height * bpp(t);
+			var size = t.width * t.height * bpp(t);
+			inf.size += size;
+			addStack(t.allocPos, inf.stacks, size);
 		}
 		for( buf in buffers ) {
 			var buf = buf;
 			while( buf != null ) {
 				var b = buf.allocHead;
 				while( b != null ) {
-					var key = b.allocPos == null ? "null" : b.allocPos.fileName + ":" + b.allocPos.lineNumber;
+					var key = b.allocPos == null ? "null" : b.allocPos.position;
 					var inf = h.get(key);
 					if( inf == null ) {
-						inf = { file : b.allocPos != null ? b.allocPos.fileName : "", line : b.allocPos != null ? b.allocPos.lineNumber : 0, count : 0, size : 0, tex : false };
+						inf = { position : key, count : 0, size : 0, tex : false, stacks : [] };
 						h.set(key, inf);
 						all.push(inf);
 					}
 					inf.count++;
-					inf.size += b.vertices * b.buffer.stride * 4;
+					var size = b.vertices * b.buffer.stride * 4;
+					inf.size += size;
+					addStack(b.allocPos, inf.stacks, size);
 					b = b.allocNext;
 				}
 				buf = buf.next;
 			}
 		}
-		all.sort(function(a, b) return a.size == b.size ? a.line - b.line : b.size - a.size);
+		all.sort(function(a, b) return b.size - a.size);
 		return all;
 		#end
 	}

+ 2 - 2
h3d/mat/BigTexture.hx

@@ -77,12 +77,12 @@ class BigTexture {
 	var lastEvent : Float;
 	var bgColor : Int;
 
-	public function new(id, size, bgColor = 0xFF8080FF, ?allocPos : h3d.impl.AllocPos ) {
+	public function new(id, size, bgColor = 0xFF8080FF ) {
 		this.id = id;
 		this.size = size;
 		this.bgColor = bgColor;
 		space = new QuadTree(0,0,size,size);
-		tex = new h3d.mat.Texture(1, 1, allocPos);
+		tex = new h3d.mat.Texture(1, 1);
 		tex.preventAutoDispose();
 		tex.flags.set(Serialize);
 		tex.clear(bgColor);

+ 2 - 2
h3d/mat/RenderTarget.hx

@@ -5,8 +5,8 @@ class RenderTarget extends Texture {
 
 	public var scale(default, set) : Float;
 
-	public function new(scale = 1., ?format : TextureFormat, ?allocPos : h3d.impl.AllocPos ) {
-		super(0, 0, [NoAlloc, Target], format, allocPos);
+	public function new(scale = 1., ?format : TextureFormat ) {
+		super(0, 0, [NoAlloc, Target], format);
 		this.scale = scale;
 	}
 

+ 16 - 21
h3d/mat/Texture.hx

@@ -21,8 +21,8 @@ class Texture {
 
 	var t : h3d.impl.Driver.Texture;
 	var mem : h3d.impl.MemoryManager;
-	#if debug
-	var allocPos : h3d.impl.AllocPos;
+	#if track_alloc
+	var allocPos : hxd.impl.AllocPos;
 	#end
 	public var id(default, null) : Int;
 	public var name(default, null) : String;
@@ -66,7 +66,7 @@ class Texture {
 		return _lastFrame;
 	}
 
-	public function new(w, h, ?flags : Array<TextureFlags>, ?format : TextureFormat, ?allocPos : h3d.impl.AllocPos ) {
+	public function new(w, h, ?flags : Array<TextureFlags>, ?format : TextureFormat ) {
 		#if !noEngine
 		var engine = h3d.Engine.getCurrent();
 		this.mem = engine.mem;
@@ -95,8 +95,8 @@ class Texture {
 		this.filter = Linear;
 		this.wrap = Clamp;
 		bits &= 0x7FFF;
-		#if debug
-		this.allocPos = allocPos;
+		#if track_alloc
+		this.allocPos = new hxd.impl.AllocPos();
 		#end
 		if( !this.flags.has(NoAlloc) ) alloc();
 	}
@@ -121,7 +121,7 @@ class Texture {
 		}
 	}
 
-	public function clone( ?allocPos : h3d.impl.AllocPos ) {
+	public function clone() {
 		checkAlloc();
 		if( t == null ) throw "Can't clone disposed texture";
 		var old = lastFrame;
@@ -130,7 +130,7 @@ class Texture {
 		for( f in [Target,Cube,MipMapped,IsArray] )
 			if( this.flags.has(f) )
 				flags.push(f);
-		var t = new Texture(width, height, flags, format, allocPos);
+		var t = new Texture(width, height, flags, format);
 		t.name = this.name;
 		#if !macro
 		if(this.flags.has(Cube))
@@ -168,8 +168,8 @@ class Texture {
 		var str = name;
 		if( name == null ) {
 			str = "Texture_" + id;
-			#if debug
-			if( allocPos != null ) str += "(" + allocPos.className+":" + allocPos.lineNumber + ")";
+			#if track_alloc
+			if( allocPos != null ) str += "(" + allocPos.position + ")";
 			#end
 		}
 		return str+"("+width+"x"+height+")";
@@ -307,13 +307,8 @@ class Texture {
 	}
 
 	public function dispose() {
-		if( t != null ) {
+		if( t != null )
 			mem.deleteTexture(this);
-			#if debug
-			if(this.allocPos != null)
-				this.allocPos.customParams = ["#DISPOSED"];
-			#end
-		}
 	}
 
 	/**
@@ -399,14 +394,14 @@ class Texture {
 	}
 	#end
 
-	public static function fromBitmap( bmp : hxd.BitmapData, ?allocPos : h3d.impl.AllocPos ) {
-		var t = new Texture(bmp.width, bmp.height, allocPos);
+	public static function fromBitmap( bmp : hxd.BitmapData ) {
+		var t = new Texture(bmp.width, bmp.height);
 		t.uploadBitmap(bmp);
 		return t;
 	}
 
-	public static function fromPixels( pixels : hxd.Pixels, ?allocPos : h3d.impl.AllocPos ) {
-		var t = new Texture(pixels.width, pixels.height, allocPos);
+	public static function fromPixels( pixels : hxd.Pixels ) {
+		var t = new Texture(pixels.width, pixels.height);
 		t.uploadPixels(pixels);
 		return t;
 	}
@@ -414,7 +409,7 @@ class Texture {
 	/**
 		Creates a 1x1 texture using the RGB color passed as parameter.
 	**/
-	public static function fromColor( color : Int, ?alpha = 1., ?allocPos : h3d.impl.AllocPos ) {
+	public static function fromColor( color : Int, ?alpha = 1. ) {
 		var engine = h3d.Engine.getCurrent();
 		var aval = Std.int(alpha * 255);
 		if( aval < 0 ) aval = 0 else if( aval > 255 ) aval = 255;
@@ -422,7 +417,7 @@ class Texture {
 		var t = @:privateAccess engine.textureColorCache.get(key);
 		if( t != null )
 			return t;
-		var t = new Texture(1, 1, null, allocPos);
+		var t = new Texture(1, 1, null);
 		t.clear(color, alpha);
 		t.realloc = function() t.clear(color, alpha);
 		@:privateAccess engine.textureColorCache.set(key, t);

+ 4 - 4
h3d/mat/TextureArray.hx

@@ -5,21 +5,21 @@ class TextureArray extends Texture {
 
 	var layers : Int;
 
-	public function new(w, h, layers, ?flags : Array<TextureFlags>, ?format : TextureFormat, ?allocPos : h3d.impl.AllocPos ) {
+	public function new(w, h, layers, ?flags : Array<TextureFlags>, ?format : TextureFormat ) {
 		this.layers = layers;
 		if( flags == null ) flags = [];
 		flags.push(IsArray);
-		super(w,h,flags,format,allocPos);
+		super(w,h,flags,format);
 	}
 
 	override function get_layerCount() {
 		return layers;
 	}
 
-	override function clone( ?allocPos : h3d.impl.AllocPos ) {
+	override function clone() {
 		var old = lastFrame;
 		preventAutoDispose();
-		var t = new TextureArray(width, height, layers, null, format, allocPos);
+		var t = new TextureArray(width, height, layers, null, format);
 		h3d.pass.Copy.run(this, t);
 		lastFrame = old;
 		return t;

+ 2 - 2
h3d/mat/TextureChannels.hx

@@ -7,10 +7,10 @@ class TextureChannels extends Texture {
 	var channels : Array<{ r : hxd.res.Image, c : hxd.Pixels.Channel }> = [];
 	public var allowAsync : Bool = true;
 
-	public function new(w, h, ?flags : Array<TextureFlags>, ?format : TextureFormat, ?allocPos : h3d.impl.AllocPos ) {
+	public function new(w, h, ?flags : Array<TextureFlags>, ?format : TextureFormat ) {
 		if( flags == null ) flags = [];
 		flags.push(NoAlloc);
-		super(w, h, flags, format, allocPos);
+		super(w, h, flags, format);
 		pixels = new hxd.Pixels(w, h, haxe.io.Bytes.alloc(w * h * 4), Texture.nativeFormat);
 		realloc = restore;
 	}

+ 12 - 7
h3d/prim/BigPrimitive.hx

@@ -17,8 +17,8 @@ class BigPrimitive extends Primitive {
 	var idxPos : Int = 0;
 	var startIndex : Int = 0;
 	var flushing : Bool;
-	#if debug
-	var allocPos : h3d.impl.AllocPos;
+	#if track_alloc
+	var allocPos : hxd.impl.AllocPos;
 	#end
 
 	public var hasTangents = false;
@@ -27,15 +27,15 @@ class BigPrimitive extends Primitive {
 	static var PREV_BUFFER : hxd.FloatBuffer;
 	static var PREV_INDEX : hxd.IndexBuffer;
 
-	public function new(stride, isRaw=false, ?pos : h3d.impl.AllocPos ) {
+	public function new(stride, isRaw=false ) {
 		this.isRaw = isRaw;
 		buffers = [];
 		allIndexes = [];
 		bounds = new h3d.col.Bounds();
 		this.stride = stride;
 		if( stride < 3 ) throw "Minimum stride = 3";
-		#if debug
-		allocPos = pos;
+		#if track_alloc
+		allocPos = new hxd.impl.AllocPos();
 		#end
 	}
 
@@ -121,11 +121,16 @@ class BigPrimitive extends Primitive {
 		if( tmpBuf != null ) {
 			if( bufPos > 0 && idxPos > 0 ) {
 				flushing = true;
-				var b = h3d.Buffer.ofSubFloats(tmpBuf, stride, Std.int(bufPos / stride) #if debug , null, allocPos #end);
+				var b = h3d.Buffer.ofSubFloats(tmpBuf, stride, Std.int(bufPos / stride));
 				if( isRaw ) b.flags.set(RawFormat);
 				buffers.push(b);
-				allIndexes.push(h3d.Indexes.alloc(tmpIdx, 0, idxPos));
+				var idx = h3d.Indexes.alloc(tmpIdx, 0, idxPos);
+				allIndexes.push(idx);
 				flushing = false;
+				#if track_alloc
+				@:privateAccess b.allocPos = allocPos;
+				@:privateAccess idx.allocPos = allocPos;
+				#end
 			}
 			if( PREV_BUFFER == null || PREV_BUFFER.length < tmpBuf.length )
 				PREV_BUFFER = tmpBuf;

+ 38 - 0
hxd/impl/AllocPos.hx

@@ -0,0 +1,38 @@
+package hxd.impl;
+
+typedef AllocPos = #if track_alloc AllocPosImpl #else {} #end
+
+#if track_alloc
+class AllocPosImpl {
+
+	public var position : String;
+	public var stack : Array<String> = [];
+	public static var ENGINE_PACKAGES = ["h3d","hxd","h2d","haxe","sys","hrt" /* HIDE */];
+
+	public function new() {
+		var curStack = haxe.CallStack.callStack();
+		curStack.shift();
+		for( s in curStack ) {
+			switch( s ) {
+			case FilePos(_,file,line,_):
+				var idx = file.indexOf("\\std/");
+				if( idx > 0 )
+					file = file.substr(idx + 5);
+				var pos = file+":"+line;
+				stack.push(pos);
+				if( position == null ){
+					var p = file.indexOf("/");
+					var pack = p < 0 ? "" : file.substr(0,p);
+					if( ENGINE_PACKAGES.indexOf(pack) < 0 ) position = pos;
+				}
+			case Method(cl,meth):
+				// TODO
+			case CFunction, Module(_), LocalFunction(_):
+				// skip
+			}
+		}
+		if( position == null ) position = stack[0];
+	}
+
+}
+#end

+ 3 - 4
hxd/impl/Allocator.hx

@@ -1,5 +1,4 @@
 package hxd.impl;
-import h3d.impl.AllocPos;
 
 @:enum abstract BufferFlags(Int) {
 	public var Dynamic = 0;
@@ -16,8 +15,8 @@ class Allocator {
 
 	// GPU
 
-	public function allocBuffer( vertices : Int, stride : Int, flags : BufferFlags, ?pos : AllocPos ) : h3d.Buffer {
-		return new h3d.Buffer(vertices, stride, switch( flags ) { case Dynamic: [Dynamic]; case UniformDynamic: [UniformBuffer,Dynamic]; }, pos);
+	public function allocBuffer( vertices : Int, stride : Int, flags : BufferFlags ) : h3d.Buffer {
+		return new h3d.Buffer(vertices, stride, switch( flags ) { case Dynamic: [Dynamic]; case UniformDynamic: [UniformBuffer,Dynamic]; });
 	}
 
 	public function disposeBuffer( b : h3d.Buffer ) {
@@ -37,7 +36,7 @@ class Allocator {
 
 	// CPU
 
-	public function allocFloats( count : Int, ?pos : AllocPos ) : hxd.FloatBuffer {
+	public function allocFloats( count : Int ) : hxd.FloatBuffer {
 		return new hxd.FloatBuffer(count);
 	}
 

+ 2 - 3
hxd/impl/CacheAllocator.hx

@@ -1,6 +1,5 @@
 package hxd.impl;
 import hxd.impl.Allocator;
-import h3d.impl.AllocPos;
 
 private class Cache<T> {
 	public var content : Array<T> = [];
@@ -35,7 +34,7 @@ class CacheAllocator extends Allocator {
 	**/
 	public var maxKeepTime = 60.;
 
-	override function allocBuffer(vertices:Int, stride:Int, flags:BufferFlags, ?pos:AllocPos):h3d.Buffer {
+	override function allocBuffer(vertices:Int, stride:Int, flags:BufferFlags):h3d.Buffer {
 		if( vertices >= 65536 ) throw "assert";
 		var id = flags.toInt() | (stride << 3) | (vertices << 16);
 		var c = buffers.get(id);
@@ -44,7 +43,7 @@ class CacheAllocator extends Allocator {
 			if( b != null ) return b;
 		}
 		checkGC();
-		return super.allocBuffer(vertices,stride,flags,pos);
+		return super.allocBuffer(vertices,stride,flags);
 	}
 
 	override function disposeBuffer(b:h3d.Buffer) {

+ 3 - 3
hxd/inspect/StatsPanel.hx

@@ -69,7 +69,7 @@ class StatsPanel extends Panel {
 		var id = button.find("span").getAttr("id");
 		button.parent().parent().find(".detail_" + id).remove();
 
-		#if !debug
+		#if !track_alloc
 			if(!button.hasClass("hidden")) {
 				var newElement = j.query("<tr>");
 				newElement.addClass("detail_" + id);
@@ -88,7 +88,7 @@ class StatsPanel extends Panel {
 								var buf = b.allocHead;
 								while( buf != null ) {
 									var mem = buf.buffer.stride * buf.vertices * 4;
-									var name = buf.allocPos.className + ":" + buf.allocPos.lineNumber;
+									var name = buf.allocPos.position;
 									var p = m.get(name);
 									if( p == null ) {
 										p = { count : 0, mem : 0, name : name };
@@ -104,7 +104,7 @@ class StatsPanel extends Panel {
 					case "texMemTitle":
 						for( t in engine.mem.textures ) {
 							var mem = t.width * t.height * 4;
-							var name = t.allocPos.fileName + ":" + t.allocPos.lineNumber;
+							var name = t.allocPos.position;
 							var p = m.get(name);
 							if( p == null ) {
 								p = { count : 0, mem : 0, name : name };