Kaynağa Gözat

move linkMode from Linker to RuntimeShader, add more linker dump

Nicolas Cannasse 1 yıl önce
ebeveyn
işleme
0ba00a962a
4 değiştirilmiş dosya ile 18 ekleme ve 10 silme
  1. 1 1
      h3d/pass/ShaderManager.hx
  2. 0 1
      hxsl/Cache.hx
  3. 10 7
      hxsl/Linker.hx
  4. 7 1
      hxsl/RuntimeShader.hx

+ 1 - 1
h3d/pass/ShaderManager.hx

@@ -270,7 +270,7 @@ class ShaderManager {
 		fill(buf.fragment, s.fragment);
 	}
 
-	public function compileShaders( shaders : hxsl.ShaderList, mode : hxsl.Linker.LinkMode = Default ) {
+	public function compileShaders( shaders : hxsl.ShaderList, mode : hxsl.RuntimeShader.LinkMode = Default ) {
 		globals.resetChannels();
 		for( s in shaders ) s.updateConstants(globals);
 		currentOutput.next = shaders;

+ 0 - 1
hxsl/Cache.hx

@@ -1,7 +1,6 @@
 package hxsl;
 using hxsl.Ast;
 import hxsl.RuntimeShader;
-import hxsl.Linker.LinkMode;
 
 class BatchInstanceParams {
 

+ 10 - 7
hxsl/Linker.hx

@@ -1,12 +1,6 @@
 package hxsl;
 using hxsl.Ast;
 
-enum LinkMode {
-	Default;
-	Batch;
-	Compute;
-}
-
 private class AllocatedVar {
 	public var id : Int;
 	public var v : TVar;
@@ -56,7 +50,7 @@ class Linker {
 	var varIdMap : Map<Int,Int>;
 	var locals : Map<Int,Bool>;
 	var curInstance : Int;
-	var mode : LinkMode;
+	var mode : hxsl.RuntimeShader.LinkMode;
 	var isBatchShader : Bool;
 	var debugDepth = 0;
 
@@ -412,6 +406,15 @@ class Linker {
 		}
 		shaders.sort(sortByPriorityDesc);
 
+		var uid = 0;
+		for( s in shaders )
+			s.uid = uid++;
+
+		#if shader_debug_dump
+		for( s in shaders )
+			debug("Found shader "+s.name+":"+s.uid);
+		#end
+
 		// build dependency tree
 		var entry = new ShaderInfos("<entry>", false);
 		entry.deps = new Map();

+ 7 - 1
hxsl/RuntimeShader.hx

@@ -1,5 +1,11 @@
 package hxsl;
 
+enum LinkMode {
+	Default;
+	Batch;
+	Compute;
+}
+
 class AllocParam {
 	public var name : String;
 	public var pos : Int;
@@ -86,7 +92,7 @@ class RuntimeShader {
 		Several shaders with the different specification might still get the same resulting signature.
 	**/
 	public var signature : String;
-	public var mode : hxsl.Linker.LinkMode;
+	public var mode : LinkMode;
 	public var spec : { instances : Array<ShaderInstanceDesc>, signature : String };
 
 	public function new() {