Browse Source

metal: fix varying matrices and arrays.

Sasha Szpakowski 1 year ago
parent
commit
59e18df392
1 changed files with 8 additions and 2 deletions
  1. 8 2
      src/modules/graphics/metal/Shader.mm

+ 8 - 2
src/modules/graphics/metal/Shader.mm

@@ -476,9 +476,15 @@ void Shader::compileFromGLSLang(id<MTLDevice> device, const glslang::TProgram &p
 
 
 			for (const auto &varying : resources.stage_outputs)
 			for (const auto &varying : resources.stage_outputs)
 			{
 			{
-//				printf("vertex shader output %s: %d\n", inp.name.c_str(), msl.get_decoration(inp.id, spv::DecorationLocation));
 				varyings[varying.name] = nextVaryingLocation;
 				varyings[varying.name] = nextVaryingLocation;
-				msl.set_decoration(varying.id, spv::DecorationLocation, nextVaryingLocation++);
+				msl.set_decoration(varying.id, spv::DecorationLocation, nextVaryingLocation);
+
+				const auto &type = msl.get_type(varying.base_type_id);
+				int count = type.array.empty() ? 1 : type.array[0];
+				if (type.op == spv::OpTypeMatrix)
+					count *= type.columns;
+
+				nextVaryingLocation += count;
 			}
 			}
 		}
 		}
 		else if (stageindex == SHADERSTAGE_PIXEL)
 		else if (stageindex == SHADERSTAGE_PIXEL)