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

Lazy loading as a texture flag.

clementlandrin 1 жил өмнө
parent
commit
7c4472961f

+ 4 - 0
h3d/mat/Data.hx

@@ -126,6 +126,10 @@ enum TextureFlags {
 		Allows the texture to be loaded asynchronously (requires initializating hxd.res.Image.ASYNC_LOADER)
 		Allows the texture to be loaded asynchronously (requires initializating hxd.res.Image.ASYNC_LOADER)
 	**/
 	**/
 	AsyncLoading;
 	AsyncLoading;
+	/**
+		By default, the texture are loaded from images when created. If this flag is enabled, the texture will be loaded from disk when first used.
+	**/
+	LazyLoading;
 }
 }
 
 
 typedef TextureFormat = hxd.PixelFormat;
 typedef TextureFormat = hxd.PixelFormat;

+ 1 - 1
hxd/res/Image.hx

@@ -625,7 +625,7 @@ class Image extends Resource {
 		tex.setName(entry.path);
 		tex.setName(entry.path);
 		setupTextureFlags(tex);
 		setupTextureFlags(tex);
 		// DirectX12 texture array triggers an access violation.
 		// DirectX12 texture array triggers an access violation.
-		if ( tex.flags.has(IsArray) )
+		if ( tex.flags.has(IsArray) || !tex.flags.has(LazyLoading) )
 			loadTexture();
 			loadTexture();
 		else
 		else
 			tex.realloc = () -> loadTexture();
 			tex.realloc = () -> loadTexture();