浏览代码

remove globals not supported by directx, allow setLayout with optional params

Nicolas Cannasse 1 年之前
父节点
当前提交
b4e0a34d5d
共有 3 个文件被更改,包括 12 次插入6 次删除
  1. 2 2
      hxsl/Ast.hx
  2. 6 2
      hxsl/Checker.hx
  3. 4 2
      hxsl/GlslOut.hx

+ 2 - 2
hxsl/Ast.hx

@@ -298,10 +298,10 @@ enum TGlobal {
 	ImageStore;
 	ComputeVar_GlobalInvocation;
 	ComputeVar_LocalInvocation;
-	ComputeVar_NumWorkGroups;
 	ComputeVar_WorkGroup;
-	ComputeVar_WorkGroupSize;
 	ComputeVar_LocalInvocationIndex;
+	//ComputeVar_NumWorkGroups - no DirectX support
+	//ComputeVar_WorkGroupSize - no DirectX support
 }
 
 enum Component {

+ 6 - 2
hxsl/Checker.hx

@@ -179,7 +179,11 @@ class Checker {
 			case IntBitsToFloat, UintBitsToFloat:
 				[for( i => t in genType ) { args : [ { name: "x", type: genIType[i] } ], ret: t }];
 			case SetLayout:
-				[{ args : [{ name : "x", type : TInt },{ name : "y", type : TInt },{ name : "z", type : TInt }], ret : TVoid }];
+				[
+					{ args : [{ name : "x", type : TInt },{ name : "y", type : TInt },{ name : "z", type : TInt }], ret : TVoid },
+					{ args : [{ name : "x", type : TInt },{ name : "y", type : TInt }], ret : TVoid },
+					{ args : [{ name : "x", type : TInt }], ret : TVoid }
+				];
 			case ImageStore:
 				[];
 			case VertexID, InstanceID, FragCoord, FrontFacing:
@@ -195,7 +199,7 @@ class Checker {
 					gvars.set(vname, vl);
 				}
 				var vt = switch( g ) {
-				case ComputeVar_GlobalInvocation, ComputeVar_LocalInvocation, ComputeVar_NumWorkGroups, ComputeVar_WorkGroup, ComputeVar_WorkGroupSize:
+				case ComputeVar_GlobalInvocation, ComputeVar_LocalInvocation, ComputeVar_WorkGroup:
 					ivec3;
 				case ComputeVar_LocalInvocationIndex:
 					TInt;

+ 4 - 2
hxsl/GlslOut.hx

@@ -75,9 +75,7 @@ class GlslOut {
 		set(ComputeVar_LocalInvocation, "ivec3(gl_LocalInvocationID)");
 		set(ComputeVar_GlobalInvocation, "ivec3(gl_GlobalInvocationID)");
 		set(ComputeVar_LocalInvocationIndex, "int(gl_LocalInvocationIndex)");
-		set(ComputeVar_NumWorkGroups, "ivec3(gl_NumWorkGroups)");
 		set(ComputeVar_WorkGroup, "ivec3(gl_WorkGroup)");
-		set(ComputeVar_WorkGroupSize, "ivec3(gl_WorkGroupSize)");
 
 		for( g in gl )
 			KWDS.set(g, true);
@@ -770,6 +768,10 @@ class GlslOut {
 		case TGlobal(g): m.set(g,true);
 		case TCall({ e : TGlobal(SetLayout) }, [{ e : TConst(CInt(x)) }, { e : TConst(CInt(y)) }, { e : TConst(CInt(z)) }]):
 			computeLayout = [x,y,z];
+		case TCall({ e : TGlobal(SetLayout) }, [{ e : TConst(CInt(x)) }, { e : TConst(CInt(y)) }]):
+			computeLayout = [x,y,1];
+		case TCall({ e : TGlobal(SetLayout) }, [{ e : TConst(CInt(x)) }]):
+			computeLayout = [x,1,1];
 		default: hxsl.Tools.iter(e,collectGlobals.bind(m));
 		}
 	}