소스 검색

Add optional loading % to hxsl cache generation

Leonardo Jeanteur 1 년 전
부모
커밋
5f4748bd7f
2개의 변경된 파일11개의 추가작업 그리고 4개의 파일을 삭제
  1. 9 1
      hxsl/CacheFile.hx
  2. 2 3
      hxsl/CacheFileBuilder.hx

+ 9 - 1
hxsl/CacheFile.hx

@@ -83,7 +83,7 @@ class CacheFile extends Cache {
 
 	static var HEX = "0123456789abcdef";
 
-	function load() {
+	function load(showProgress=false) {
 		isLoading = true;
 		var t0 = haxe.Timer.stamp();
 		var wait = [];
@@ -113,12 +113,20 @@ class CacheFile extends Cache {
 			}
 		}
 		if( wait.length > 0 ) {
+			var fullCount = wait.length;
 			waitCount += wait.length;
 			#if hlmulti
 			for( r in wait ) {
+				if (showProgress && (waitCount % 5 == 0 || waitCount <= 1)) {
+					var progress = Std.int((1 - (waitCount / fullCount)) * 1000) / 10;
+					Sys.print('$progress%\t(${fullCount - waitCount}/$fullCount)  \r');
+				}
+
 				addNewShader(r);
 				hxd.System.timeoutTick();
 			}
+			if (showProgress)
+				Sys.println("");
 			#else
 			haxe.Timer.delay(function() {
 				for( r in wait ) {

+ 2 - 3
hxsl/CacheFileBuilder.hx

@@ -21,9 +21,9 @@ private class CustomCacheFile extends CacheFile {
 		super(true, true);
 	}
 
-	override function load() {
+	override function load(showProgress=true) {
 		allowSave = true;
-		super.load();
+		super.load(showProgress);
 	}
 
 	override function addSource(r:RuntimeShader) {
@@ -108,7 +108,6 @@ class CacheFileBuilder {
 
 	public function compileShader( r : RuntimeShader, rd : RuntimeShader.RuntimeShaderData ) : String {
 		hasCompiled = true;
-		Sys.print(".");
 		var s = generateShader(r, rd);
 		if( s == null )
 			return null;