Skip to content

Commit fce5e23

Browse files
committed
Document Metal support in Internal rendering architecture
1 parent 8b2533d commit fce5e23

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed

contributing/development/core_and_modules/internal_rendering_architecture.rst

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ ask in the ``#rendering`` channel of the
2020
recommended to go through an OpenGL tutorial such as
2121
`LearnOpenGL <https://learnopengl.com/>`__.
2222

23-
Modern low-level APIs (Vulkan/Direct3D 12) require intermediate
23+
Modern low-level APIs (Vulkan/Direct3D 12/Metal) require intermediate
2424
knowledge of higher-level APIs (OpenGL/Direct3D 11) to be used
2525
effectively. Thankfully, contributors rarely need to work directly with
2626
low-level APIs. Godot's renderers are built entirely on OpenGL and
27-
RenderingDevice, which is our abstraction over Vulkan/Direct3D 12.
27+
RenderingDevice, which is our abstraction over Vulkan/Direct3D 12/Metal.
2828

2929
.. _doc_internal_rendering_architecture_methods:
3030

@@ -108,7 +108,7 @@ Compatibility
108108
.. note::
109109

110110
This is the only rendering method available when using the OpenGL driver.
111-
This rendering method is not available when using Vulkan or Direct3D 12.
111+
This rendering method is not available when using Vulkan, Direct3D 12 or Metal.
112112

113113
This is a traditional (non-clustered) forward renderer. It's intended for old
114114
GPUs that don't have Vulkan support, but still works very efficiently on newer
@@ -207,18 +207,23 @@ for more information.
207207
Metal
208208
^^^^^
209209

210-
Godot supports Metal rendering via `MoltenVK <https://github.com/KhronosGroup/MoltenVK>`__,
211-
as macOS and iOS do not support Vulkan natively.
212-
This is done automatically when specifying the Vulkan driver in the Project Settings.
210+
Godot provides a native Metal driver that works on all Apple Silicon hardware
211+
(macOS ARM). Compared to using the MoltenVK translation layer, this is
212+
significantly faster, particularly in CPU-bound scenarios.
213213

214-
MoltenVK makes driver maintenance easy at the cost of some performance overhead.
215-
Also, MoltenVK has several limitations that a native Metal driver implementation
216-
wouldn't have. Both the clustered and mobile
217-
:ref:`doc_internal_rendering_architecture_methods` can be used with a Metal
218-
backend via MoltenVK.
214+
Both the Forward+ and Mobile :ref:`doc_internal_rendering_architecture_methods` can be
215+
used with Metal.
216+
217+
:ref:`doc_internal_rendering_architecture_core_shaders` are shared with the
218+
Vulkan renderer. Shaders are transpiled from GLSL to :abbr:`MSL (Metal Shading Language)`
219+
using SPIRV-Cross.
219220

220-
A native Metal driver is planned in the future for better performance and
221-
compatibility.
221+
Godot also supports Metal rendering via `MoltenVK <https://github.com/KhronosGroup/MoltenVK>`__,
222+
which is used as a fallback when native Metal support is not available (e.g. on x86 macOS).
223+
224+
**This driver is still experimental and only available in Godot 4.x (TODO) and later.**
225+
See the `pull request that introduced Metal support <https://github.com/godotengine/godot/pull/88199>`__
226+
for more information.
222227

223228
OpenGL
224229
^^^^^^
@@ -242,13 +247,13 @@ Summary of rendering drivers/methods
242247

243248
The following rendering API + rendering method combinations are currently possible:
244249

245-
- Vulkan + Forward+
246-
- Vulkan + Forward Mobile
250+
- Vulkan + Forward+ (optionally through MoltenVK on macOS and iOS)
251+
- Vulkan + Forward Mobile (optionally through MoltenVK on macOS and iOS)
247252
- Direct3D 12 + Forward+
248253
- Direct3D 12 + Forward Mobile
249-
- Metal + Forward+ (via MoltenVK)
250-
- Metal + Forward Mobile (via MoltenVK)
251-
- OpenGL + Compatibility
254+
- Metal + Forward+
255+
- Metal + Forward Mobile
256+
- OpenGL + Compatibility (optionally through ANGLE on Windows and macOS)
252257

253258
Each combination has its own limitations and performance characteristics. Make
254259
sure to test your changes on all rendering methods if possible before opening a
@@ -265,10 +270,10 @@ To make the complexity of modern low-level graphics APIs more manageable,
265270
Godot uses its own abstraction called RenderingDevice.
266271

267272
This means that when writing code for modern rendering methods, you don't
268-
actually use the Vulkan or Direct3D 12 APIs directly. While this is still
273+
actually use the Vulkan, Direct3D 12 or Metal APIs directly. While this is still
269274
lower-level than an API like OpenGL, this makes working on the renderer easier,
270275
as RenderingDevice will abstract many API-specific quirks for you. The
271-
RenderingDevice presents a similar level of abstraction as Metal or WebGPU.
276+
RenderingDevice presents a similar level of abstraction as WebGPU.
272277

273278
**Vulkan RenderingDevice implementation:**
274279

@@ -278,6 +283,10 @@ RenderingDevice presents a similar level of abstraction as Metal or WebGPU.
278283

279284
- `drivers/d3d12/rendering_device_driver_d3d12.cpp <https://github.com/godotengine/godot/blob/master/drivers/d3d12/rendering_device_driver_d3d12.cpp>`__
280285

286+
**Metal RenderingDevice implementation:**
287+
288+
- `drivers/metal/rendering_device_driver_metal.mm <https://github.com/godotengine/godot/blob/master/drivers/metal/rendering_device_driver_metal.mm>`__
289+
281290
Core rendering classes architecture
282291
-----------------------------------
283292

@@ -731,8 +740,8 @@ Occlusion culling
731740
^^^^^^^^^^^^^^^^^
732741

733742
While modern GPUs can handle drawing a lot of triangles, the number of draw
734-
calls in complex scenes can still be a bottleneck (even with Vulkan and Direct3D
735-
12).
743+
calls in complex scenes can still be a bottleneck (even with Vulkan, Direct3D 12
744+
and Metal).
736745

737746
Godot 4 supports occlusion culling to reduce overdraw (when the depth prepass
738747
is disabled) and reduce vertex throughput.

0 commit comments

Comments
 (0)