#include #include #include #include #include #include #include #include #include // ... shader_manifest.hpp #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace mbgl { namespace mtl { RendererBackend::RendererBackend(const gfx::ContextMode contextMode_) : gfx::RendererBackend(contextMode_), device(NS::TransferPtr(MTL::CreateSystemDefaultDevice())), commandQueue(NS::TransferPtr(device->newCommandQueue())) { assert(device); assert(commandQueue); } RendererBackend::~RendererBackend() = default; std::unique_ptr RendererBackend::createContext() { return std::make_unique(*this); } PremultipliedImage RendererBackend::readFramebuffer(const Size& size) { return PremultipliedImage(size); // return getContext().readFramebuffer(size); } void RendererBackend::assumeFramebufferBinding(const mtl::FramebufferID fbo) { /*getContext().bindFramebuffer.setCurrentValue(fbo); if (fbo != ImplicitFramebufferBinding) { assert(mtl::value::BindFramebuffer::Get() == getContext().bindFramebuffer.getCurrentValue()); }*/ } void RendererBackend::assumeViewport(int32_t x, int32_t y, const Size& size) { /*getContext().viewport.setCurrentValue({x, y, size}); assert(mtl::value::Viewport::Get() == getContext().viewport.getCurrentValue());*/ } void RendererBackend::assumeScissorTest(bool enabled) { /*getContext().scissorTest.setCurrentValue(enabled); assert(mtl::value::ScissorTest::Get() == getContext().scissorTest.getCurrentValue());*/ } bool RendererBackend::implicitFramebufferBound() { return false; // return getContext().bindFramebuffer.getCurrentValue() == ImplicitFramebufferBinding; } void RendererBackend::setFramebufferBinding(const mtl::FramebufferID fbo) { /*getContext().bindFramebuffer = fbo; if (fbo != ImplicitFramebufferBinding) { assert(mtl::value::BindFramebuffer::Get() == getContext().bindFramebuffer.getCurrentValue()); }*/ } void RendererBackend::setViewport(int32_t x, int32_t y, const Size& size) { /*getContext().viewport = {x, y, size}; assert(mtl::value::Viewport::Get() == getContext().viewport.getCurrentValue());*/ } void RendererBackend::setScissorTest(bool enabled) { /*getContext().scissorTest = enabled; assert(mtl::value::ScissorTest::Get() == getContext().scissorTest.getCurrentValue());*/ } /// @brief Register a list of types with a shader registry instance /// @tparam ...ShaderID Pack of BuiltIn:: shader IDs /// @param registry A shader registry instance /// @param programParameters ProgramParameters used to initialize each instance template void registerTypes(gfx::ShaderRegistry& registry, const ProgramParameters& programParameters) { /// The following fold expression will create a shader for every type /// in the parameter pack and register it with the shader registry. /// Registration calls are wrapped in a lambda that throws on registration /// failure, we shouldn't expect registration to faill unless the shader /// registry instance provided already has conflicting programs present. ( [&]() { using namespace std::string_literals; using ShaderClass = shaders::ShaderSource; auto group = std::make_shared>(programParameters); if (!registry.registerShaderGroup(std::move(group), ShaderClass::name)) { assert(!"duplicate shader group"); throw std::runtime_error("Failed to register "s + ShaderClass::name + " with shader registry!"); } }(), ...); } void RendererBackend::initShaders(gfx::ShaderRegistry& shaders, const ProgramParameters& programParameters) { registerTypes(shaders, programParameters); } } // namespace mtl } // namespace mbgl