ソースを参照

Lazy loading as a texture flag.

clementlandrin 1 年間 前
コミット
7c4472961f
2 ファイル変更5 行追加1 行削除
  1. 4 0
      h3d/mat/Data.hx
  2. 1 1
      hxd/res/Image.hx

+ 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)
 	**/
 	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;

+ 1 - 1
hxd/res/Image.hx

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