The graphics lane's device answered what the host platform answers for
maxBufferLength and the linear texture alignment, and left the framebuffer
read, tile shader and imageblock answers to the base class. Each answer
steers the guest's frameworks, so each now picks, from the answers real
Macs give, the one the lane can keep cheapest (dgpu-oracle.md):
- maxBufferLength is the host's, but at most three quarters of
recommendedMaxWorkingSetSize rounded down to 16 KiB. That is the rule the
Radeon Pro 5300M and the M3 Max answer by. The Vulkan platform answers
the driver's maxBufferSize, a terabyte on an RTX 5080 that no allocation
reaches; the 5080 now answers 12821200896.
- minimumLinearTextureAlignmentForPixelFormat: and the SPI
linearTextureAlignmentBytes and deviceLinearTextureAlignmentBytes answer
256 (or the host's, where larger), as the 5300M and the UHD 630 answer.
RADV takes a texture over dma-buf pages in place only at rows a multiple
of 256 apart, and every 256-byte layout is one the host's 16 takes.
- isFramebufferReadSupported answers no, as the 5300M does. That keeps the
guest's frameworks off attachment reads, which cost the Vulkan platform
the most.
- supportsTileShaders, supportsNonSquareTileShaders and supportsImageBlocks
answer no, as the 5300M and the UHD 630 do. The lane carries none of
them.
The bundle answers all of these from the device-info blob, never through
the base class.
WindowServer on the x86-64 guest samples the aerial wallpaper's 4K HDR video
frames through a YCBCR10_420_2P texture over plane 0 of each decoded surface,
which reads plane 1's chroma as Metal does. The bundle copied each plane into
a block of its own, so the host's texture over plane 0 had no chroma to read.
A surface's copy is now one block holding every plane, in plane order, each
from a 256-byte multiple with its rows 256 bytes apart, then the header and
the writers. A texture over any plane lies in the copy's one buffer at its
plane's offset, so every texture over the surface reads and writes the same
bytes, as Metal's over one surface do. The shared block is found by plane 0's
pages, which no other surface holds. Upload and write-back copy every plane.
A surface without planes is laid out as before.
Each TEXTURE_FROM_IOSURFACE now carries the surface's facts after its struct
(RgfxSurfaceFacts): IOSurfaceGetPixelFormat, the plane count, the size, plane
1's offset and pitch in the copy, and the YCbCr matrix. The matrix is the
surface's IOSurfaceYCbCrMatrix value, where CoreVideo leaves a propagated
kCVImageBufferYCbCrMatrixKey attachment (measured on the M3 Max under macOS
27.0.1 for all six of its constants). It is read from the surface, not
through CVPixelBufferCreateWithIOSurface, which holds the surface in use while
the pixel buffer lives.
The new shell test covers a 64 x 48 'x420' surface's one block, both planes'
textures, the facts, CPU access to plane 1, a missing plane, and a surface
without planes.
Apple2's rows need programmable sample positions, and the bundle dropped them:
a pass's setSamplePositions:count: never left the guest, and
setDepthStoreActionOptions: was a logged no-op. The device answers
areProgrammableSamplePositionsSupported from the host, so apps that asked got
the default positions with no sign of it.
A pass's positions now travel after its colour records
(RGFX_PASS_FLAG_SAMPLE_POSITIONS, RgfxRenderPassSamplePositions), and the host
sets them on its pass; RENDER_SET_DEPTH_STORE_ACTION_OPTIONS (0x104f) carries
the encoder's options to Metal, and to the Vulkan platform as late options over
a store action left Unknown, as the stencil and colour ones go.
Metal ends the process at positions it does not take (measured on the M3 Max,
macOS 27): its descriptor's setter at a count other than 2, 4 or 8 or a
coordinate outside [0, 1), its pass validation at a count the device makes no
texture of (8 there), whatever the attachments' sample count. The guest's
descriptor stops the first; the bundle answers no encoder for the second; and
the host faults a pass that holds either, so no guest bytes reach the abort.
SamplePositions joins WIRED with its cap test: Apple2 now waits only on Metal
IO queues.
A compositor commits the command buffer that draws its frame into an
IOSurface and then submits the display pipe's transaction for it, without
waiting for the buffer. The buffer rides its queue's ring and the present
ring 0, which the host takes on separate threads, so the window could show
the surface before the buffer had run, or before the host had taken it.
Each guest process that commits a buffer writing a surface's copy now names
its queue and the buffer's seqno in the copy's RgfxSurfaceWriters, four
slots past the block's header, before the commit returns, and
TEXTURE_FROM_IOSURFACE carries where they lie. A PRESENT_SURFACE reads
them, and the host's PresentQueue shows it once each named buffer's
CB_COMPLETE is posted, in the order the presents came, with no wait on
anything else: buffers of other queues or surfaces hold nothing. A queue's
destroy, or its context's close, releases what waits on it.
A process writes only slots naming its own queues: it raises its queue's
seqno, takes back a slot of a queue of its own that is gone, or claims an
empty one, and it empties its slots when its copy goes. A slot given to
another queue has its seqno emptied first, so the host's queue, seqno,
queue read never pairs one queue with another's seqno.
The bundle's argument encoders were stubs: newArgumentEncoderWithArguments:
and a function's newArgumentEncoderWithBufferIndex: answered nil, so no
app or framework could fill an argument buffer.
Each now asks the host for the layout (ARGUMENT_LAYOUT) through the
serializer's asker, the kext's submit that waits for the answer, into a
page of the region it gives back once the answer is read, and asks once
more into a block of the size the host needs where the layout outgrows the
first. The encoder parses the layout into a tree, checked whole, and writes
each argument's word where Metal's encoder writes it: in the last member
holding the index, at its element, through struct elements, and at the
arguments' offset 0 for an index no argument has. A buffer writes its GPU
address plus the offset, a texture or pipeline its resource id, nil 0. A
nested argument buffer's encoder takes its layout from the same answer.
What the wire does not carry logs its first use: a sampler's resource id
(its word is 0), a depth/stencil state's (the bytes stay), and the
argument's reflection. Indirect command buffers, acceleration structures
and function tables take only nil, which writes 0, since the device makes
none. A setter with no argument buffer set, where Metal's process ends,
writes nothing and logs it.
CA in WindowServer logged "nil buffer from memory": newBufferWithBytesNoCopy:
answered nil for every pointer outside the device region, which is all of an
app's own memory. Metal makes one over any range the process maps readable, at
any alignment and length (measured on an M3 Max at 16 KiB and, under Rosetta,
4 KiB pages: malloc'd, vm_allocate'd, read-only and file-mapped memory), and
answers nil only for a length of 0 or a range not wholly mapped.
Such a buffer now lies over a region block of its own, and its contents stay
the app's pointer. The block syncs with the memory as the IOSurface copies do:
the CPU's bytes go in at the commit of each command buffer that uses it, and the
GPU's come back when one that may write it completes, before its completion is
reported. Only the bytes each side moved since the two last agreed move, byte
by byte, so CPU and GPU writes beside each other both stand. The encoders note
each use as a read or a write, and they look up a buffer only while a shadow
lives. A null pointer gets zeroed contents of the buffer's own, and its
deallocator gets null, as Metal's does.
An Automatic heap's newBufferWithLength:options: and
newTextureWithDescriptor: answered nil, and usedSize and
maxAvailableSizeWithAlignment: answered 0 and the heap's size. The heap now
places each resource itself, as Metal's Automatic heap does on an M3 Max
under macOS 27 (RgfxHeapRanges.hpp): at the lowest free offset at its
alignment, a buffer taking its length at the device's heap buffer
alignment and a texture the size heapTextureSizeAndAlignWithDescriptor:
answers, now the host device's (HEAP_TEXTURE_SIZE_AND_ALIGN) and the bound
only where none came back. Each goes to the host as a placement at that
offset in the Placement heap the host made; its heapOffset answers 0, as
Metal's does. Its bytes go back when it is made aliasable, at once, or else
once its destroy has gone, and usedSize and maxAvailableSizeWithAlignment:
answer from the placements, 0 for a Placement heap as Metal answers. A
heap's size is the descriptor's rounded up to the 16 KiB page, as Metal's
and the host's are, and a heap texture answers its placed size as its
allocatedSize.
The lane now carries Automatic heaps, so the piece joins WIRED.
newBinaryArchiveWithDescriptor: answered nil and an error, and Apple's own
archive, which the base class made before that, needs a target architecture
the device has none of. RgfxBinaryArchive is the device's own: no compiled
code crosses the wire, so it keeps the key Metal looks each function's compile
up by (its bitcode hash, name and constants, with the state Metal's misses show
it keys by), per architecture, and writes them as a file of its own format.
Every answer is Metal's on the M3 Max (archive_probe): an empty archive from
no URL, Invalid URL for no readable file, an invalid format for any other
file, Nothing to serialize for an empty one, and a Metal archive, another GPU's
to this device, loads and misses every lookup. A pipeline create with
MTLPipelineOptionFailOnBinaryArchiveMiss answers Metal's miss, naming the
fragment then the vertex function it lacks, and compiles as before when it
names no archive or lacks the option. Where Metal asserts (no compute, vertex
or tile function) the add answers NO with Metal's words.
iconservicesagent and WindowServer's desktop capture call
newTextureViewWithPixelFormat:, which the bundle did not answer.
Every public form is made: a format alone; with type, levels and slices;
with a swizzle; and by a descriptor. Each posts TEXTURE_VIEW and makes a
texture of the view's own shape and resource id that keeps its texture. As
Metal's views do (measured on the M3 Max under macOS 27.0.1), it answers:
- its own format, type, levels and slices, and its texture's size at its
first level;
- the swizzle it names, else its texture's; a swizzle other than the default
keeps only ShaderRead and PixelFormatView of the usage, and 0x4000 and
0x10000;
- its texture as parentTexture, and the level and slice it starts at;
- its texture's buffer, IOSurface, heap, offset, aliasing and size;
- NonVolatile to setPurgeableState:, and makeAliasable changes nothing.
A view's CPU copies are its texture's at the view's levels and slices, and a
write through a view of an IOSurface texture is noted as a write of that
surface.
Metal ends the process at a view it does not make, and answers nil for one in
no format. The bundle answers nil and posts nothing for each case it can tell:
- no format;
- blocks of other bytes or size, or compressed against uncompressed;
- levels or slices outside the texture;
- a type of another family;
- a slice count the type does not take.
The host refuses any other view its platform does not make.
The wire carries no minLOD, so a descriptor view with a nonzero one is
answered nil.
newHeapWithDescriptor: made a heap of size 0, and a heap or buffer whose
GPU address found no room in the context's range, and posted its create
anyway: the first at a size the host refuses, the second at address 0,
which the host places unpinned. Metal answers nil for a heap of size 0
(measured on the Metal platform) and for a resource it cannot place, so the
app went on with a heap the host never made, and every placement in it was
a bad reference after that.
Both are now nil, and nothing is posted for them: a heap of size 0, and a
heap, a heap over host memory, a device buffer or a buffer over host memory
whose address the context's range has no room for. The block under a
Shared one goes back, as for any that could not be made.
The bundle carried only the values a process set by index, so a function
specialised by name (WindowServer's and SecurityAgent's RenderBox pipelines)
reached the host unspecialised, and the Vulkan runtime refused its compile
(NeedsInput(FunctionConstant { index: 0 })).
The bundle now reads each function's constants from its library's bytes (the
CNST table of its public metadata) and resolves the values as Metal does,
measured on macOS 27.0.1: the value at a constant's index (set by index or by
range) wins over the one under its name, values for constants the function does
not declare are ignored, a value of another type fails the function with
Metal's MTLLibraryErrorCompileFailure and words, a required constant with no
value reads 0, and an optional one stays undefined. A missing function answers
Metal's MTLLibraryErrorFunctionNotFound. A function made with no values answers
its constants from functionConstantsDictionary, and the pipelines of it are
refused where Metal asserts.
A wire record now carries a value of up to 32 bytes (a long4), so float4 and
wider constants reach the host; core's FunctionConstant follows, which only
this lane's decoder uses.
The bundle picked each device buffer's and heap's GPU address 256-byte
aligned, right after the one before it. The host pins those addresses, and
a pin must start a 32 KiB granule and hold the pages its bytes touch plus a
guard page, rounded up to a granule, apart from every other live pin
(metal2vulkan's address.rs). Picks that broke the rule were refused, so
every other HEAP_CREATE of a churn failed. Nothing was ever given back
either, so a long-lived process would walk off its context's 64 GiB.
Each pick now starts a granule and holds that span. A pick's range goes
back once its object's destroy is retired, into a coalesced free map per
context. Picks go forward from the last one and wrap round to the ranges
given back behind them, so a freed range is picked again only after a lap
of the slot. Buffers that picked their address (device buffers and those
over host memory, not ones placed in a heap), heaps, and device-placed and
Managed textures give theirs back.
The bundle answered neither minimumTextureBufferAlignmentForPixelFormat: nor
either sparseTileSizeWithTextureType: form, and IOGPUMetalDevice has none of
them. A call fell through to the zero catch-all, whose signature returns a
scalar where both tile queries return an MTLSize.
The blob now carries, for each pixel format of the SDK, its texture-buffer
alignment and its 2D sparse tile at 1, 2 and 4 samples on 16, 64 and 256 KiB
pages. The tile is one answer for every texture type, as Metal gives it on an
M3 Max. Metal asks the alignment only of the 56 formats it answers; on every
other one it fails an assertion, measured on the M3 Max. The Vulkan platform
answers with the runtime's linear alignment, which Metal answers alike for
every format, and with the runtime's tiles.
The guest's MTLDevice answered supportsFamily: of Apple5 to Apple10 and -1009
alone, no to Common1-3, Mac1/Mac2, Metal3 and every feature set, a 32-byte
name that cut "NVIDIA GeForce RTX 5080 Laptop GPU" short, and placeholders for
its identity (1 GiB working set, unified memory, Tier2 argument buffers). Apps
that gate on Mac2, Metal3 or a macOS feature set refused to run.
- GpuDevice::identity_caps, which only the graphics lane asks, holds
supportsFamily: of every family of the SDK, supportsFeatureSet: of every
feature set, and the identity and capability getters. The paravirt lane's
DeviceCaps are untouched. Metal answers every one with its own getter. The
Vulkan platform answers each from the runtime where it can: its properties,
supportsFamily:, and the audit of a feature row (BC formats, query LOD,
barycentrics, dynamic libraries, ray tracing, function pointers). Apple5 to
Apple10 keep the platform's DeviceCaps answers. Each claimed family claims
what Metal documents it contains. Feature sets follow their families, as
Metal on an M3 Max answers them: no to ReadWriteTextureTier2 and to tvOS.
The working set is the sum of the device-local Vulkan heaps. The runtime
has no answer of the rest, which is None.
- RgfxDeviceInfo v2 carries all of it: families and feature sets as (value,
answer) lists that the bundle looks up by value, the integer and BOOL
identity answers, the architecture name, and a name of 256 bytes. A gap
reads 0, never yes.
- device_info.rs answers with the lane's own device where it can do less
than the host GPU, in one table with a row per missing piece: Metal4,
ray tracing, motion blur, function pointers, dynamic libraries, placement
sparse, counter sampling and rate maps answer no. hasUnifiedMemory stays
yes for now, because Managed buffers are guest memory alone in the bundle.
- The bundle answers every one of these getters from the blob, with no
defaults of its own.
-commit posted with tryPost and ignored its answer, so a command buffer
committed while its queue's 32 KiB submission ring was full, or one larger
than the ring, was never posted and never completed: 400 small fills in a row
hung every time on msi. Metal never fails or drops a buffer for its size, and
throttles with maxCommandBufferCount.
- A buffer larger than half its ring goes out of line: the bundle writes its
whole COMMAND_BUFFER message into a region block of the process's own and
posts a new COMMAND_BUFFER_IN_REGION (0x301: offset, length). The queue's
service thread copies the message out of the block once, with the
reference's seqno, and refuses a span outside the processes' blocks or one
holding no COMMAND_BUFFER of that length. The block goes back as the buffer
completes. With no block to be had, the buffer fails with
MTLCommandBufferErrorOutOfMemory, off the committing thread.
- A queue keeps maxCommandBufferCount slots (64 for 0, as Metal's default):
-commandBuffer blocks while every one is held by a buffer alive and not
completed, and a buffer gives its slot back before its handlers run, or at
dealloc where it never completes.
- A commit that finds the ring full rings the doorbell and sleeps 20 us
doubling to 1 ms between looks; on the delivering thread, or where no
completion thread drives the ring, it takes the queue's completions
meanwhile, as the host may be waiting for room there.
It also closes a race in the completion work: commit expected a buffer's
completion only after posting it, and set Committed after, so the completion
thread could take a fast completion with no handler yet (lost, the buffer
hung) or have its status overwritten. The completion is now expected under the
ring's lock before producer moves, and Committed is set before the post.
Every guest Metal process's textures share the host's one device, whose
texture ids end below 16381: Metal ends the process for a texture placed at
16381 or more, and metal2vulkan imitates that. The ids were split by context
slot (1 + s * 2048), so slot 8 onward was past the limit, and a WindowServer
crash loop or a few app launches killed QEMU at the first texture create
("invalid use of new_texture: ResourceId { id: 16385, limit: 16381 }").
The kext now keeps one pool of 255 chunks of 64 ids, all below 16321, and
gives a process a chunk when it asks (user-client selector 0x106). It posts
the grant on ring 0 (RESOURCE_ID_CHUNK: context, chunk) before it returns, so
the host has it before any create naming its ids. A process keeps its chunks
until its close, and they are freed after its CONTEXT_CLOSE is answered, with
its blocks. OPEN_CONTEXT answers no resource-id base any more. A chunk is 64
ids so that the bundle keeps each chunk's free ids in one 64-bit mask.
The bundle takes the lowest free id of the first chunk it took that has one,
asks for a chunk only when all of its are in use, and gives an id back as its
texture goes. With every chunk held, newTexture answers nil, as Metal answers
a texture it cannot make.
The host refuses a texture create, from a device, a buffer or an IOSurface,
whose id lies in no chunk of its own context, 0 and the limit's included,
before any platform call, as a refused create is refused: unanswered, and a
command buffer naming the texture fails. So no guest id reaches the
platform's own limit, where the Vulkan platform ends the process.
Only textures are affected: sampler and pipeline states take no guest-picked
ids (the host numbers them), and the bundle makes no indirect command buffers.
tools/tex_probe copies a pattern through a Private texture and back, and holds
N textures at once, checking their ids are distinct and below the limit.
Every process that loads QuartzCore's shaders sent the whole library over
the region, and the host built it again. Now the bundle takes the AIR slice's
content key (SHA-256 of the .metallib without its bitcode section, whose
functions the HASH tags name) and asks the host first with LIBRARY_LOOKUP.
On a hit the new id is bound to the library the device made for any process,
and no bytes cross. On a miss the slice goes as before, now with its key.
The host keeps a library under a key only where it computed that key from
the bytes itself, checked every HASH tag against its bitcode, and found the
functions cover the bitcode section. Every AIR metallib of macOS 27's system
covers it. A lookup can then only bind content with that key, on Metal as on
the Vulkan platform. A wrong key makes the library uncached. Libraries no id
names stay in a 64 MiB least-recently-released list, so a restarted
WindowServer still hits.
Library creates are now answered with COMPLETE, and the kext waits for the
answer (for a region-streamed library, its last chunk), so a refusal is nil
and an NSError at newLibrary*, as in Metal. They are made on the compile pool,
off the control thread. A pipeline create that names a library still being
made waits for it on its compile thread, and a destroy of such a library
keeps ring order.
Each process's creates and destroys now reach the host on the control ring,
which the accelerator kext posts for it under the framebuffer's ring lock, in
place of a device queue per process and the BAR 0 mailbox. Ring 0 keeps one
producer, the kexts, and one consumer, the host's control thread, so the
lifecycle of every process is in one order with the display commands.
The bundle hands each message to the kext by a user-client call (selector
0x105, struct in). The kext checks the object is in the caller's context,
stamps the seqno and posts it; for a pipeline create it waits for the
reflection, which the work loop routes by seqno, and hands it back as struct
out. QUEUE_CREATE (selector 0x103) is posted and answered with COMPLETE once
the host has the queue's rings. At a close the kext posts each queue's
OBJECT_DESTROY, then CONTEXT_CLOSE, which the host answers once the context's
objects are dropped, then frees the blocks.
The host carries out lifecycle messages on the control thread with no ring
held, and a command buffer waits until every ring-0 message published before
its queue's thread took it is carried out. The Host trait's queue_message
becomes stage3_message, and its poster (CompletionPoster) also targets the
control completion ring.
The ObjC++ layer Apple's Metal loads as the guest's MTLDevice and that
serialises Metal calls into the reims-graphics wire, built on the existing
serialiser core. This slice lays the foundation the resource, pipeline,
command-buffer and sync slices stack on.
What it adds:
- RgfxMetalPrivate.h: minimal, author-written forward-declarations of the
Apple-private base (IOGPUMetalDevice/_MTLDevice) and the private protocols
(MTLDeviceSPI, MTLCommandQueueSPI, MTLCommandBufferSPI), each with only the
selectors the shell overrides, tagged measured. No Apple header or SPI dump
is copied into the tree.
- RgfxMetalDevice.{h,mm}: RgfxMetalDevice : IOGPUMetalDevice
<MTLDevice, MTLDeviceSPI>. init + wire-handshake stub, device identity, the
family/sample-count/feature queries and the limit getters, answered from
RgfxCaps. The resource-creation methods are left to per-slice categories;
the header documents the +Resources/+Pipelines/+CommandBuffer/+Sync split so
the slices never collide in one .mm.
- RgfxResource.{h,mm} and RgfxBuffer.{h,mm}: the wrapper convention — an
NSObject conforming to a Metal protocol, carrying the guest-picked objId, a
weak device back-pointer and a borrowed serialiser it routes mutating calls
through. RgfxBuffer is the worked example the resource slice replicates.
Being NSObject-based (not the private device base), the wrappers instantiate
and are unit-tested on the Mac.
Checks:
- make bundle compiles all shell .mm for x86_64 (the guest's arch) and
bundle-links the loadable bundle, device class included, with
-undefined dynamic_lookup (the private base/SPI resolve at load in the
guest). It only needs to compile off the guest, not run.
- make test keeps the serialiser check (387, x86_64 under Rosetta) and adds a
native-arch Metal-shell routing check (40): a wrapper's create routes an
RGFX_CMD_BUFFER_CREATE through the serialiser, read back off the ring and
asserted byte for byte — the assertion pattern the later slices copy. The
device shell is excluded from the test binary (it needs the private base at
runtime). The serialiser harness is factored into tests/rgfx_test_ring.hpp,
shared by both checks.
The generated wire header carried only the render op structs: the compute
(ops/compute.rs) and blit (ops/blit.rs) op bodies were built by a local
op_body! macro_rules macro, which cbindgen does not expand, so it never saw
them. Op struct names also collide across the groups in the flat C
namespace (render, compute and blit each define e.g. UpdateFence and
WaitForFence with different fields).
De-macro both files to explicit #[repr(C)] structs matching the render
style, and give each group's op structs a unique prefix: compute's
RgfxOp* become RgfxComputeOp*, blit's RgfxOp* become RgfxBlitOp*. The
element records (RgfxCompute*) and the render op structs (RgfxOp*) are
unchanged. The host decoders and the cbindgen include list follow the new
names; cargo xtask header now emits all 27 compute and 26 blit op structs,
and header --check is green.
Drop the guest encoder's rgfx_compute/rgfx_blit hand-mirror namespaces,
which existed only because the header lacked these types, and point the
encoder, the wire-layout asserts and the serializer tests at the header's
types directly.
RgfxEncoder builds an RGFX_CMD_COMMAND_BUFFER message for a (queue, command
buffer) pair and appends encoder passes and their ops to the op stream, then
fills op_bytes and posts it on the queue's submission ring. One method per op
across all three encoders (render, compute, blit) plus the framing ops writes an
RgfxOpHeader and the op body, 8-byte aligned, mirroring the host decoder
(graphics::decode::{cmdbuf,render,compute,blit}) byte for byte; array-tailed ops
write the head then its element records.
The render-encoder op bodies and the render-pass records are the committed wire
header. The compute-only and blit op bodies and the compute element records are
not emitted into that header (cbindgen reaches only the render-op module), so
they are mirrored here under the rgfx_compute and rgfx_blit namespaces, their
layouts pinned by RgfxWireLayout static_asserts against ops/{compute,blit}.rs.
serializer_tests gains a host-side op-stream consumer that walks a built command
buffer: it checks the begin/end framing, a representative op across each encoder
(including an array-tailed op and a no-arg render op), the fill-texture trailing
bytes, and op_bytes/alignment.
Wire: RgfxRenderPipelineCreate / RgfxComputePipelineCreate (fixed head +
tail for entry-point names, function constants, vertex descriptor and
label; colour attachments inline), their sub-records (RgfxColorAttachmentDesc,
RgfxVertexBufferLayout, RgfxVertexAttribute, RgfxFunctionConstant), and the
RgfxPipelineReflection reply (0x402). Functions are named by library obj_id +
entry-point bytes + function-constant values; size asserts and a round-trip
test guard the layout.
Host: the RENDER/COMPUTE_PIPELINE_CREATE decode arms resolve the functions'
libraries, drive the platform's new_render_pipeline_state /
new_compute_pipeline_state_for_function creators, store the handle, and emit
a reflection reply through a settable reflection sink (mirroring the
completion sink). A non-library reference is a bad reference; a nil function
or a refused descriptor emits a refused reply. Adds the require/get_library
resolver.
Guest: createRenderPipeline / createComputePipeline pack the descriptors into
the wire tail and post them; the serialiser test posts both and reads the
create bytes and the reflection reply back.
The platform's descriptor-value creators carry only the vertex/fragment
functions, colour attachment 0's format and source-over blend, and a label;
the wire carries the whole descriptor for when that value grows, and the
platform exposes no per-argument binding reflection, so the reply carries the
pipeline state's own queries. The cbindgen export and the generated header
are left for the integration pass.
The reims-graphics guest Metal-plugin bundle turns an app's Metal calls into
the device's wire stream. This is its first, validatable slice: the parts that
need no Apple Metal SPI, so they build and are checked on the Mac in user
space.
- RgfxIdSpace: the per-context object-id, resource-id and GPU-address number
lines the guest picks and the host pins (design Decided 6 and 7).
- RgfxCaps: reads the RgfxDeviceInfo caps blob and answers supportsFamily:, the
limits and the feature queries by name, in the host's field order, with a
host gap reported as unsupported, never a spurious yes (Decided 10).
- RgfxRingWriter: the guest producer's reserve-write-publish-doorbell step,
the mirror of the host consumer in reims-graphics/src/ring.rs.
- RgfxSerializer: builds and posts each object-lifecycle message whose wire
struct is fixed in wire.rs (reims_graphics_wire.h) -- queue, heap, buffer,
texture, sampler, depth/stencil, library, event, shared event, fence and
OBJECT_DESTROY -- on the control ring.
- RgfxWireLayout: asserts every wire struct's size at the guest's own compile,
the C-side wall beside wire.rs's.
The command-buffer encoder-op stream, the pipeline creates and
TEXTURE_FROM_IOSURFACE are later increments: their wire schema is not yet
fixed. The Metal device shell that drives this serialiser needs private SPI and
a guest experiment and is not built here.
make -C guest/bundle test builds and runs the serialiser check under Rosetta
(the x86-64 guest ABI); it reads every posted message back and asserts its type,
size and fields. 216 checks pass on x86-64 and arm64.