Files
NativeMetal/NativeBridgeMetalFrontend.h
bluseliu50 add14db0ef fix(metal): keep the import's own surface in the held-import table; read the virtualized gate
A surface import hit recorded the caller's IOSurface object, which the
import never retained. A completion thread then read the retain count of
a freed object in pruneHeldImports, and backboardd died on the isa
authentication (i35abaf83, twice, at 879 s and 905 s). The table now
records the surface the import itself retains.

i35abaf83 read 0x6E23 and the framebuffer stayed RGhA.
framebuffer_pixel_format also takes RGhA from the device-is-virtualized
byte; the render server now reads it back (0x6E30 bit) and notes the
key that sets it.
2026-11-01 05:21:10 +08:00

37 lines
2.6 KiB
Objective-C

// SPDX-License-Identifier: MIT
// Entry points of the native Metal frontend over the bridge (NativeBridgeMetalFrontend.mm).
#pragma once
#include <stddef.h>
#include <stdint.h>
#ifdef __OBJC__
#import <Foundation/Foundation.h>
extern "C" {
// Opens the process's one device: loader exports vkGetInstanceProcAddr (Turnip), cache is a writable shader-cache directory, registryID is the
// accelerator service's registry entry. missing (may be null) is told the class and selector of every unimplemented call.
id native_bridge_metal_open(const char *loader, const char *cache, uint64_t registryID, void (*missing)(const char *, const char *));
// Bare AIR bitcode as a library (the bridge's fixtures; Metal itself accepts only metallibs).
id native_bridge_metal_library_with_air(const void *bytes, size_t length);
// One line for the plugin's status report: command buffers committed/failed locally, pipelines made, refusals, the last refusal's text.
size_t native_bridge_metal_status(char *out, size_t size);
// The pixel formats of the textures asked for (first eight distinct) and how many texture requests the runtime refused.
size_t native_bridge_metal_formats(char *out, size_t size);
// The process's first problem (a refusal or a missing call) into out, and how many problems there were.
uint64_t native_bridge_metal_first_problem(char *out, size_t size);
// A note from the plugin for the telemetry's problem lines.
void native_bridge_metal_note(const char *what);
// Called once, on the thread that hit it, with the first problem's text (null: not called).
extern void (*native_bridge_metal_problem_hook)(const char *);
size_t native_bridge_metal_telemetry(char *out, size_t size);
// Structured cumulative artifact/driver-cache counters for offline qualification.
struct NmbShaderCacheStats;
bool native_bridge_metal_shader_cache_stats(struct NmbShaderCacheStats *out);
bool native_bridge_metal_work_stats(uint64_t out[10]);
// The same fixed CPU, memory and pipeline workload on the tablet and the host, so their times compare directly (int-145): compute, first-touch
// page faults, memset bandwidth, CommonCrypto SHA-256, then the first `pairs` vertex/fragment pairs of the given QuartzCore metallib made into
// BGRA8 render states and drawn once each (pipeline_timing_host's draw=1 order). The results become the telemetry's Y rows; also returned.
size_t native_bridge_metal_benchmark(id device, const char *metallib, unsigned pairs, char *out, size_t size);
// Lets go of every held IOSurface import whose surface only the import still retains (also done at each command buffer's completion).
void native_bridge_metal_trim_surface_imports(void);
}
#endif