瀏覽代碼

more heaps_compact_mem support

Nicolas Cannasse 3 年之前
父節點
當前提交
3c13285d50
共有 4 個文件被更改,包括 13 次插入4 次删除
  1. 2 0
      h3d/impl/DirectXDriver.hx
  2. 2 0
      h3d/impl/GlDriver.hx
  3. 3 0
      hxsl/Cache.hx
  4. 6 4
      hxsl/HlslOut.hx

+ 2 - 0
h3d/impl/DirectXDriver.hx

@@ -798,7 +798,9 @@ class DirectXDriver extends h3d.impl.Driver {
 		var h = new hxsl.HlslOut();
 		if( shader.code == null ){
 			shader.code = h.run(shader.data);
+			#if !heaps_compact_mem
 			shader.data.funs = null;
+			#end
 		}
 		var bytes = getBinaryPayload(shader.vertex, shader.code);
 		if( bytes == null ) {

+ 2 - 0
h3d/impl/GlDriver.hx

@@ -285,7 +285,9 @@ class GlDriver extends Driver {
 		var s = gl.createShader(type);
 		if( shader.code == null ){
 			shader.code = glout.run(shader.data);
+			#if !heaps_compact_mem
 			shader.data.funs = null;
+			#end
 		}
 		gl.shaderSource(s, shader.code);
 		gl.compileShader(s);

+ 3 - 0
hxsl/Cache.hx

@@ -382,6 +382,9 @@ class Cache {
 		var flat = new Flatten();
 		var c = new RuntimeShaderData();
 		var data = flat.flatten(s, kind, constsToGlobal);
+		#if (hl && heaps_compact_mem)
+		data = hl.Api.compact(data, null, 0, null);
+		#end
 		var textures = [];
 		c.consts = flat.consts;
 		c.texturesCount = 0;

+ 6 - 4
hxsl/HlslOut.hx

@@ -196,10 +196,12 @@ class HlslOut {
 	function addVar( v : TVar ) {
 		switch( v.type ) {
 		case TArray(t, size), TBuffer(t,size):
-			var old = v.type;
-			v.type = t;
-			addVar(v);
-			v.type = old;
+			addVar({
+				id : v.id,
+				name : v.name,
+				type : t,
+				kind : v.kind,
+			});
 			addArraySize(size);
 		default:
 			addType(v.type);