Explorar o código

Support shader_debug_dump flag on non-sys JS target. (#1258)

Pavel Alexandrov hai 8 meses
pai
achega
2726fba056
Modificáronse 1 ficheiros con 9 adicións e 0 borrados
  1. 9 0
      hxsl/Cache.hx

+ 9 - 0
hxsl/Cache.hx

@@ -243,8 +243,17 @@ class Cache {
 
 
 		#if shader_debug_dump
 		#if shader_debug_dump
 		var shaderId = @:privateAccess RuntimeShader.UID;
 		var shaderId = @:privateAccess RuntimeShader.UID;
+		#if ( js && !sys )
+		if( shaderId == 0 ) js.Syntax.code("window.shaders = [];");
+		js.Syntax.code("window.shaders[{0}] = '';", shaderId);
+		var dbg: { writeString: String->Void, close:Void->Void } = {
+			writeString: (str: String) -> { js.Syntax.code("window.shaders[{0}] += {1}", shaderId, str); },
+			close: () -> {}
+		};
+		#else
 		if( shaderId == 0 ) try sys.FileSystem.createDirectory("shaders") catch( e : Dynamic ) {};
 		if( shaderId == 0 ) try sys.FileSystem.createDirectory("shaders") catch( e : Dynamic ) {};
 		var dbg = sys.io.File.write("shaders/"+shaderId+"_dump.c");
 		var dbg = sys.io.File.write("shaders/"+shaderId+"_dump.c");
+		#end
 		var oldTrace = haxe.Log.trace;
 		var oldTrace = haxe.Log.trace;
 		haxe.Log.trace = function(msg,?pos) dbg.writeString(haxe.Log.formatOutput(msg,pos)+"\n");
 		haxe.Log.trace = function(msg,?pos) dbg.writeString(haxe.Log.formatOutput(msg,pos)+"\n");
 		if( dbg != null ) {
 		if( dbg != null ) {