Metal: Make the MSL indices match the ones of PipelineLayout
Previously didn't tell SPIRV-Cross at which MSL resource indices the
different SPIRV binding should be, and were lucky that it's giving
indices in increasing order matched the PipelineLayout in all our
samples.
Fix this by making SPIRV->MSL compilation depend on the PipelineLayout
so we can tell SPIRV-Cross which binding goes where.
We should do the same for vertex attributes eventually as they are
hardcoded to start at kMaxBindingsPerGroup currently.
Also a couple unrelated cleanups (unused function, usage of
IterateBitSet).
diff --git a/src/backend/metal/ShaderModuleMTL.h b/src/backend/metal/ShaderModuleMTL.h
index 3896922..dde12ba 100644
--- a/src/backend/metal/ShaderModuleMTL.h
+++ b/src/backend/metal/ShaderModuleMTL.h
@@ -26,16 +26,20 @@
namespace backend {
namespace metal {
+ class PipelineLayout;
+
class ShaderModule : public ShaderModuleBase {
public:
ShaderModule(ShaderModuleBuilder* builder);
~ShaderModule();
- id<MTLFunction> GetFunction(const char* functionName) const;
- MTLSize GetLocalWorkGroupSize(const std::string& entryPoint) const;
+ struct MetalFunctionData {
+ id<MTLFunction> function;
+ MTLSize localWorkgroupSize;
+ };
+ MetalFunctionData GetFunction(const char* functionName, const PipelineLayout* layout) const;
private:
- id<MTLLibrary> mtlLibrary = nil;
spirv_cross::CompilerMSL* compiler = nullptr;
};