Răsfoiți Sursa

sort draw calls with same shader per texture

ncannasse 10 ani în urmă
părinte
comite
ffd449ce68
2 a modificat fișierele cu 8 adăugiri și 1 ștergeri
  1. 7 0
      h3d/pass/Default.hx
  2. 1 1
      h3d/shader/Manager.hx

+ 7 - 0
h3d/pass/Default.hx

@@ -78,6 +78,13 @@ class Default extends Base {
 			}
 			p.shader = manager.compileShaders(shaders);
 			p.shaders = shaders;
+			var t = p.shader.fragment.textures2D;
+			if( t == null )
+				p.texture = 0;
+			else {
+				var t : h3d.mat.Texture = manager.getParamValue(t, shaders);
+				p.texture = t == null ? 0 : t.id;
+			}
 			p = p.next;
 		}
 	}

+ 1 - 1
h3d/shader/Manager.hx

@@ -133,7 +133,7 @@ class Manager {
 		return 0;
 	}
 
-	inline function getParamValue( p : hxsl.RuntimeShader.AllocParam, shaders : hxsl.ShaderList ) : Dynamic {
+	public inline function getParamValue( p : hxsl.RuntimeShader.AllocParam, shaders : hxsl.ShaderList ) : Dynamic {
 		if( p.perObjectGlobal != null ) {
 			var v = globals.fastGet(p.perObjectGlobal.gid);
 			if( v == null ) throw "Missing global value " + p.perObjectGlobal.path;