Files
reims-vgpu/guest/bundle/src/RgfxEvent.mm
T
Anees Iqbal e9269d6c2f 🆕 Answer the resources' and shaders' SPI both x86 Macs answer
The guest's frameworks send Metal's SPI members to the objects they are given
without asking respondsToSelector: first, so each member the AMD 5300M's and
the Intel 630's objects both answer is now answered by the bundle's classes of
that kind, as Metal's own base classes answer it (read from code, macOS 27.0.1
on the M3 Max) and as a fresh object of both x86 Macs answers those that take
no argument (measured on macOS 26.7.1, tools/oracle/oracle_spi_members.m):

- textures, samplers and depth-stencil states: the handle and resource index
  Metal's base derives from gpuResourceID; a depth-stencil state's index and
  identifier raise, as Metal's base does;
- heaps, events, shared events, buffers and argument encoders: the memory
  pool, the base heap's description and its raising backing members, the
  event's barrier flag and rollback answer, the buffer's Neural Engine surface,
  and no layout object (logged);
- libraries and functions: identifiers, triples, validation, file and line
  answers from Metal's own shadow function, relocations, and functionHandle,
  at which every x86 Mac's function ends the process;
- functions of GL IR: what Metal's function of GL IR answers on the Intel 630
  (tools/gl_probe.m -s), its IR as its bitcode and a hash of it;
- compute and render pipelines: resource index, handle, telemetry IDs, no
  debug instrumentation or global constants, function tables through the
  device, and no mesh shader emulation;
- binary archives: Metal's archive's description, and none of its function
  IDs, pipeline collections or recompiles (logged).

The members the oracle's protocols lacked were asked by name
(oracle_spi_members ask), and those neither Mac answers stay absent. The
register lists each member with how it is answered.
2026-11-08 14:33:55 -08:00

86 lines
2.5 KiB
Plaintext

/*
* RgfxEvent: see RgfxEvent.h. Our own ObjC++; no Apple private SPI.
*/
#import "RgfxEvent.h"
#include <atomic>
#include "RgfxSerializer.hpp"
@implementation RgfxEvent {
std::atomic<uint64_t> _signalled; // rgfxSignalledValue; only rises
std::atomic<bool> _enableBarrier; // enableBarrier; YES from its init
}
// The host drops the event as the app lets it go, after any command buffer that names it (each
// keeps it while it runs).
- (void)dealloc
{
[self rgfxRetireThen:nullptr];
}
+ (instancetype)eventWithOptions:(NSInteger)options
device:(id<MTLDevice>)device
serializer:(RgfxSerializer *)serializer
{
(void)options;
return [self eventWithDevice:device serializer:serializer];
}
+ (instancetype)eventWithDevice:(id<MTLDevice>)device serializer:(RgfxSerializer *)serializer
{
if (serializer == nullptr) {
return nil; // an event must have a route to the host
}
RgfxCreated created = serializer->createEvent();
if (serializer->refused(created))
return nil; // the device never got it
RgfxEvent *event = [[RgfxEvent alloc] initWithObjId:created.obj_id device:device serializer:serializer];
if (event != nil) {
event->_enableBarrier.store(true, std::memory_order_relaxed);
}
return event;
}
- (uint64_t)rgfxSignalledValue
{
return _signalled.load(std::memory_order_acquire);
}
- (void)rgfxNoteSignalled:(uint64_t)value
{
uint64_t now = _signalled.load(std::memory_order_relaxed);
while (now < value &&
!_signalled.compare_exchange_weak(now, value, std::memory_order_acq_rel))
;
}
// --- MTLEventSPI ----------------------------------------------------------------------
// Whether a wait on the event is a barrier: stored and answered, YES from the event's init, as
// Metal's IOAccel event, which both x86 Macs' events are, keeps it (read from code; a fresh one
// answers YES on the AMD 5300M and the Intel 630, %spi-answers). The host's wait orders the work
// after it whatever it holds.
- (BOOL)enableBarrier
{
return _enableBarrier.load(std::memory_order_relaxed);
}
- (void)setEnableBarrier:(BOOL)enableBarrier
{
_enableBarrier.store(enableBarrier, std::memory_order_relaxed);
}
// NO: the event's value is never rolled back, as both x86 Macs' events answer (%spi-answers).
- (BOOL)supportsRollback
{
return NO;
}
// MTLEvent adds no other state or methods beyond `device` and `label`, which RgfxResource
// already carries. The event is otherwise an opaque handle named on the wire by `rgfxObjId` when
// an encoder signals or waits on it.
@end