#pragma once #include "../ShaderModule.h" #include "../Types.h" #include #include #include #include #import struct glslopt_shader; CC_BACKEND_BEGIN class ShaderModuleMTL : public ShaderModule { public: ShaderModuleMTL(id mtlDevice, ShaderStage stage, const std::string& source); ~ShaderModuleMTL(); inline id getMTLFunction() const { return _mtlFunction; } inline const std::shared_ptr& getUniformBuffer() const { return _uniformBuffer; } inline const std::unordered_map& getUniforms() const { return _uniformInfos; } inline const int getMaxLocation() const { return _maxLocation; } inline const std::unordered_map getAttributeInfo() const { return _attributeInfo; } private: void parseAttibute(id mtlDevice, glslopt_shader* shader); void parseUniform(id mtlDevice, glslopt_shader* shader); void parseTexture(id mtlDevice, glslopt_shader* shader); id _mtlFunction = nil; std::shared_ptr _uniformBuffer = nullptr; std::unordered_map _uniformInfos; std::unordered_map _attributeInfo; int _maxLocation = -1; }; CC_BACKEND_END