Donner SVG Editor & Engine
SVG-native editor and embeddable SVG2 + CSS3 engine in C++20, with GPU (WebGPU) and compact CPU renderers, built for correctness, security, and performance.
Loading...
Searching...
No Matches
MetalDevice.mm File Reference

Metal backend implementation for donner::gpu::metal::MetalDevice (Objective-C++). More...

import <Foundation/Foundation.h>
import <Metal/Metal.h>
#include <atomic>
#include <chrono>
#include <cstring>
#include <format>
#include <memory>
#include <mutex>
#include <optional>
#include <string>
#include <thread>
#include <vector>
#include "donner/base/Utils.h"
#include "donner/gpu/metal/MetalDevice.h"
#include "donner/gpu/shader/MslBindingMap.h"
Include dependency graph for MetalDevice.mm:

Classes

struct  donner::gpu::metal::MetalDevice::Impl
 Objective-C++ state of a MetalDevice: the Metal device and queue plus per-resource slot tables mirroring the validated slot indices handed to the on* hooks. More...
struct  donner::gpu::metal::MetalDevice::Impl::BindGroupRecord
 A bind group plus the layout slot it was created against (for per-binding visibility). More...
struct  donner::gpu::metal::MetalDevice::Impl::RenderPipelineRecord
 A compiled render pipeline plus the encoder state every draw through it uses (cull mode is encoder state in Metal, so it is applied when the pipeline binds). More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Detailed Description

Metal backend implementation for donner::gpu::metal::MetalDevice (Objective-C++).

Compiled with ARC (Bazel objc_library compiles srcs with ARC), so Metal objects held in C++ containers use implicit __strong semantics: clearing a slot to nil releases the object.


Class Documentation

◆ donner::gpu::metal::MetalDevice::Impl

struct donner::gpu::metal::MetalDevice::Impl

Objective-C++ state of a MetalDevice: the Metal device and queue plus per-resource slot tables mirroring the validated slot indices handed to the on* hooks.

Class Members
vector< optional< BindGroupLayoutDescriptor > > bindGroupLayouts Layout slots.
vector< optional< BindGroupRecord > > bindGroups Bind group slots.
vector< id< MTLBuffer > > buffers Buffer slots.
id< MTLCommandQueue > commandQueue = nil Lazily created on first submit.
shared_ptr< CompletionState > completionState Shared with completion handlers.
id< MTLDevice > device = nil The Metal device; set by Create.
vector< optional< PipelineLayoutDescriptor > > pipelineLayouts Pipeline layouts.
vector< optional< RenderPipelineRecord > > renderPipelines Render pipeline slots.
vector< id< MTLSamplerState > > samplers Sampler slots.
vector< id< MTLLibrary > > shaderLibraries Shader module slots.
vector< id< MTLTexture > > textures Texture slots.
vector< optional< uint32_t > > textureViewToTexture View slot -> texture slot.

◆ donner::gpu::metal::MetalDevice::Impl::BindGroupRecord

struct donner::gpu::metal::MetalDevice::Impl::BindGroupRecord

A bind group plus the layout slot it was created against (for per-binding visibility).

Class Members
BindGroupDescriptor descriptor Validated creation descriptor (entries).
uint32_t layoutSlot = 0 Slot of the bind group layout.

◆ donner::gpu::metal::MetalDevice::Impl::RenderPipelineRecord

struct donner::gpu::metal::MetalDevice::Impl::RenderPipelineRecord

A compiled render pipeline plus the encoder state every draw through it uses (cull mode is encoder state in Metal, so it is applied when the pipeline binds).

Class Members
CullMode cullMode = CullMode::None Pipeline cull mode.
id< MTLRenderPipelineState > state = nil Compiled pipeline state.
PrimitiveTopology topology = PrimitiveTopology::TriangleList Pipeline topology.