2
0
Эх сурвалжийг харах

fixed gpu mem calculus wrt async textures

Nicolas Cannasse 3 жил өмнө
parent
commit
ebe311f7fd

+ 2 - 0
h3d/impl/MemoryManager.hx

@@ -226,6 +226,8 @@ class MemoryManager {
 	// ------------------------------------- TEXTURES ------------------------------------------
 
 	function memSize( t : h3d.mat.Texture ) {
+		if( t.flags.has(AsyncLoading) && t.flags.has(Loading) )
+			return 4; // 1x1 pixel
 		var size = hxd.Pixels.calcDataSize(t.width,t.height,t.format);
 		if( t.mipLevels > 0 ) {
 			for( i in 1...t.mipLevels ) {

+ 2 - 0
hxd/res/Image.hx

@@ -473,6 +473,7 @@ class Image extends Resource {
 	function asyncLoad( data : haxe.io.Bytes ) {
 		if( tex == null || tex.isDisposed() ) return;
 		tex.dispose();
+		tex.flags.unset(Loading);
 		@:privateAccess {
 			tex.format = inf.pixelFormat;
 			tex.width = inf.width;
@@ -490,6 +491,7 @@ class Image extends Resource {
 					tex.width = 1;
 					tex.height = 1;
 					tex.customMipLevels = 1;
+					tex.flags.set(Loading);
 					tex.alloc();
 					tex.uploadPixels(BLACK_1x1);
 					tex.width = inf.width;