nCine::RHI::Metal namespace

Metal backend for macOS and iOS, selected by WITH_RHI_METAL.

Namespaces

namespace UniformTypeInfo
Free-function helpers that classify reflected uniform types (component count, float-ness).

Classes

class MetalAttribute
Reflected metadata of a single active vertex attribute (aliased as RHI::Attribute).
class MetalBufferObject
Buffer object of the Metal backend (aliased as RHI::Buffer).
class MetalDebug
Debug-output and object-labelling stub of the Metal backend.
class MetalDevice
Pipeline-state and draw-call facade of the Metal backend (aliased as RHI::Device).
class MetalFramebuffer
Framebuffer stub of the Metal backend (aliased as RHI::Framebuffer).
class MetalRenderbuffer
Renderbuffer stub of the Metal backend (aliased as RHI::Renderbuffer).
class MetalRenderTarget
Off-screen render target of the Metal backend (aliased as RHI::RenderTarget).
class MetalRhiCapabilities
Runtime capabilities of the Metal backend.
class MetalShader
Shader-object stub of the Metal backend.
class MetalShaderProgram
Shader program of the Metal backend (aliased as RHI::ShaderProgram).
class MetalShaderUniformBlocks
Manages the uniform-block caches of a program (aliased as RHI::ShaderUniformBlocks).
class MetalShaderUniforms
Manages the loose-uniform caches of a program (aliased as RHI::ShaderUniforms).
class MetalTexture
Texture object of the Metal backend (aliased as RHI::Texture).
class MetalUniform
Reflected metadata of a single active uniform (aliased as RHI::Uniform).
class MetalUniformBlock
Reflected metadata of a single active uniform block (aliased as RHI::UniformBlock).
class MetalUniformBlockCache
Caches the contents of a uniform block (aliased as RHI::UniformBlockCache).
class MetalUniformCache
Caches the host-side value of a single uniform (aliased as RHI::UniformCache).
class MetalVertexArray
Vertex array object stub of the Metal backend (aliased as RHI::VertexArray).
class MetalVertexFormat
Vertex layout description of the Metal backend (aliased as RHI::VertexFormat).

Functions

auto MtlDevice() -> MTL::Device*
The device, or nullptr before creation / after teardown.
auto MtlQueue() -> MTL::CommandQueue*
The one command queue every frame and one-time command buffer is created from.
auto MtlHasUnifiedMemory() -> bool
true when the GPU shares memory with the CPU (Apple silicon), so Shared textures replace Managed ones
void MtlFlushFrameForReadback()
Makes the frame's work so far visible to a readback.
template<class F>
void MtlRunOneTimeCommands(F&& record)
Runs record on a one-time command buffer and waits for it.
void MtlLayerSetup(void* layer, MTL::Device* device, bool vsync)
Points the layer at device, sets its pixel format to BGRA8Unorm and its vertical-sync mode.
void MtlLayerSetDrawableSize(void* layer, std::int32_t width, std::int32_t height)
Sets the size in pixels of the drawables the layer hands out.
auto MtlLayerNextDrawable(void* layer) -> CA::MetalDrawable*
Acquires the next drawable (blocks while all are in flight; nullptr when none becomes available). The caller owns one reference.
auto MtlLayerPixelFormat(void* layer) -> std::uint32_t
MTL::PixelFormat of the layer's drawables (as an integer, matching the present pipeline's attachment)

Function documentation

MTL::Device* nCine::RHI::Metal::MtlDevice()

The device, or nullptr before creation / after teardown.

MTL::CommandQueue* nCine::RHI::Metal::MtlQueue()

The one command queue every frame and one-time command buffer is created from.

bool nCine::RHI::Metal::MtlHasUnifiedMemory()

true when the GPU shares memory with the CPU (Apple silicon), so Shared textures replace Managed ones

void nCine::RHI::Metal::MtlFlushFrameForReadback()

Makes the frame's work so far visible to a readback.

Metal command buffers execute only once committed, and the frame's buffer is committed at present time; a texture read back mid-frame would therefore see the previous frame's contents. This ends the open encoder, commits what was recorded, waits for it and opens a fresh command buffer for the rest of the frame - the readback then observes every draw issued before it, exactly like glGetTexImage after a GL draw. A no-op when no frame is active.

template<class F>
void nCine::RHI::Metal::MtlRunOneTimeCommands(F&& record)

Runs record on a one-time command buffer and waits for it.

Used by the resource classes for out-of-frame GPU work (the render-target readback copy). record receives the command buffer to encode into; the function commits it and blocks until it has completed. Does nothing when the device is not ready.

void nCine::RHI::Metal::MtlLayerSetup(void* layer, MTL::Device* device, bool vsync)

Points the layer at device, sets its pixel format to BGRA8Unorm and its vertical-sync mode.

void nCine::RHI::Metal::MtlLayerSetDrawableSize(void* layer, std::int32_t width, std::int32_t height)

Sets the size in pixels of the drawables the layer hands out.

CA::MetalDrawable* nCine::RHI::Metal::MtlLayerNextDrawable(void* layer)

Acquires the next drawable (blocks while all are in flight; nullptr when none becomes available). The caller owns one reference.

std::uint32_t nCine::RHI::Metal::MtlLayerPixelFormat(void* layer)

MTL::PixelFormat of the layer's drawables (as an integer, matching the present pipeline's attachment)