Pārlūkot izejas kodu

Avoid interpolation on batchShader params.

TothBenoit 5 mēneši atpakaļ
vecāks
revīzija
f89f8b763e
2 mainītis faili ar 8 papildinājumiem un 4 dzēšanām
  1. 3 3
      hxsl/HlslOut.hx
  2. 5 1
      hxsl/Linker.hx

+ 3 - 3
hxsl/HlslOut.hx

@@ -225,8 +225,6 @@ class HlslOut {
 			add('> ');
 			ident(v);
 		default:
-			if ( Tools.hasQualifier(v, Flat) )
-				add("nointerpolation ");
 			addType(v.type);
 			add(" ");
 			ident(v);
@@ -376,7 +374,7 @@ class HlslOut {
 			 }");
 		case AtomicAdd:
 			decl("int atomicAdd( RWStructuredBuffer<int> buf, int index, int data ) { int val; InterlockedAdd(buf[index], data, val); return val; }");
-		case InvLerp: 
+		case InvLerp:
 			decl("float invLerp(float v, float a, float b) { return saturate((v - a) / (b - a)); }");
 		case TextureSize:
 			var tt = args[0].t;
@@ -806,6 +804,8 @@ class HlslOut {
 		var index = 0;
 		function declVar(prefix:String, v : TVar ) {
 			add("\t");
+			if ( Tools.hasQualifier(v, Flat) )
+				add("nointerpolation ");
 			addVar(v);
 			if( v.kind == Output )
 				add(" : " + (isVertex ? SV_POSITION : SV_TARGET + (index++)));

+ 5 - 1
hxsl/Linker.hx

@@ -376,8 +376,12 @@ class Linker {
 			isBatchShader = mode == Batch && StringTools.startsWith(s.name,"batchShader_");
 			for( v in s.vars ) {
 				var v2 = allocVar(v, null, s.name);
-				if( isBatchShader && v2.v.kind == Param && !StringTools.startsWith(v2.path,"Batch_") )
+				if( isBatchShader && v2.v.kind == Param && !StringTools.startsWith(v2.path,"Batch_") ) {
 					v2.v.kind = Local;
+					if ( v2.v.qualifiers == null )
+						v2.v.qualifiers = [];
+					v2.v.qualifiers.push(Flat);
+				}
 				if( v.kind == Output ) outVars.push(v);
 			}
 			for( f in s.funs ) {