#pragma once #include #include #if MLN_WEBGPU_IMPL_DAWN #include #elif MLN_WEBGPU_IMPL_WGPU #include #endif #include #include namespace mbgl { class ProgramParameters; namespace gfx { class ShaderRegistry; } namespace webgpu { class Context; class RendererBackend : public gfx::RendererBackend { public: explicit RendererBackend(gfx::ContextMode); ~RendererBackend() override; // getDefaultRenderable() is pure virtual - must be implemented by platform backends // Platform backends typically inherit from gfx::Renderable and return *this void initShaders(gfx::ShaderRegistry&, const ProgramParameters&) override; // Platform-specific surface creation void setSurface(void* nativeWindow); // WebGPU-specific methods void setInstance(void* instance); void setDevice(WGPUDevice device); void setQueue(WGPUQueue queue); void* getInstance() const; WGPUDevice getDevice() const; WGPUQueue getQueue() const; void* getSurface() const; // Surface texture access - can be overridden by platform backends virtual void* getCurrentTextureView(); virtual void* getDepthStencilView(); virtual mbgl::Size getFramebufferSize() const; void setDepthStencilFormat(wgpu::TextureFormat); wgpu::TextureFormat getDepthStencilFormat() const; void setColorFormat(wgpu::TextureFormat); wgpu::TextureFormat getColorFormat() const; protected: std::unique_ptr createContext() override; void activate() override; void deactivate() override; private: class Impl; std::unique_ptr impl; }; } // namespace webgpu } // namespace mbgl