9 Commits
Author SHA1 Message Date
geramyloveless b004eb754d radv, libdrm-mlg: windowed frames follow the window, clipped, off when it leaves
- drmMlgPlaceWindow (libdrm-mlg) places one frame: the window's content
  and the monitor's screen in global points (CoreGraphics' space), the
  output's mode and the image. A screen point is crtc/screen pixels, which
  is the backing scale and the mode in one factor. A window that fills the
  screen (or is in native full screen there) gets the primary plane;
  otherwise an overlay plane at its rectangle in CRTC pixels, clipped to
  the CRTC with the matching crop of the image on every edge. A window off
  the monitor, or with less of it there than DC's 12-pixel smallest
  viewport (which DC would grow without saying), gets nothing, with the
  reason. No window or no screen keeps the old rules.
- LX_SCANOUT HIDE: the client's frames off the screen (the desktop back,
  the overlay off) while it stays attached and keeps its overlay plane.
- The WSI (radv-macos-display-wsi.patch) reads the window at every
  present, in global points, and uses drmMlgPlaceWindow. Off the monitor
  it hides once, logs it, keeps the game running paced at the refresh
  rate, and shows the frames again when the window comes back; going full
  screen on the monitor when the window is elsewhere is gone. A place that
  changed is checked with TEST before it is presented; a refusal names the
  rectangles and the scale. A layer at another size than the images makes
  presents VK_SUBOPTIMAL_KHR, so a resized window or a full-screen toggle
  gets new images.
- Tests: test-mlg-place (1x and 2x, screens at any global position, full
  screen, clipping on each edge and a corner, a scaled window clipped, off
  the screen, the viewport minimum, modes, refusals); test-scanout (HIDE,
  a cropped present after it, a crop past the framebuffer refused);
  test-radv-scanout (suboptimal presents for a layer of another size).
2026-10-04 09:32:48 -07:00
geramyloveless d197adc7e7 radv: VK_MVK_macos_surface for SDL2 before 2.26
T2 on 239: Quake3e's bundled SDL2 2.24.1 refused RADV as its Vulkan
library ("Installed Vulkan Portability library doesn't implement the
VK_MVK_macos_surface extension"); its Cocoa backend requires that
extension at load, and every window creation failed ("Couldn't get a
visual"). RADV now also advertises VK_MVK_macos_surface on the macOS
platform; vkCreateMacOSSurfaceMVK takes an NSView backed by a
CAMetalLayer, or the layer, and makes the same Metal surface (a view
without one is refused). test-radv-scanout checks the extension, both
kinds of pView and the refusal.
2026-10-04 08:08:16 -07:00
geramyloveless c4ef3c0f23 Merge display-c (7150b0c, build 238) into feature/quake3-direct-scanout 2026-10-03 22:36:36 -07:00
geramyloveless 2ea6aeea12 radv: present Metal surfaces with the GPU's display engine
patches/mesa/radv-macos-display-wsi.patch: RADV advertises
VK_EXT_metal_surface and swapchains on the macOS platform, and presents
them through libdrm-mlg's drmMlgScanout on the driver's display output.
The images stay in VRAM as framebuffers of the primary node, with
modifiers the output's planes scan out; a present goes on the primary
plane in place of the desktop (the window fills its screen, or is not on
the monitor's screen) or on an overlay plane at the window's rectangle,
or where MLG_WSI_MODE says. MLG_WSI_OUTPUT names the output; without it
the surface reports no presentation support and nothing is presented
another way. FIFO, a syncobj per image signalled at its vblank; the
window is moved to the monitor's screen at swapchain creation; the last
swapchain gives the screen back to the desktop. Failures print the step
and errno and lose the surface.

scripts/build-radv.sh builds the macOS platform. test-radv-scanout runs
RADV on the fixture's display output: no support without MLG_WSI_OUTPUT,
a refused connector, capabilities, FIFO frames of tiled images on the
primary plane, the desktop given back, a windowed overlay.
2026-10-03 22:27:26 -07:00
geramyloveless bffa8423bc radv offline test waits for the shader upload; stats split syncobj polls
vkCreateComputePipelines returns once the shader's SDMA copy is
submitted; the fixture engine runs it after. The test read the engine
counters once and passed only while the driver was slow enough. It now
waits up to 10 s for the copy.

LIBDRM_MLG_STATS counts zero-timeout SYNCOBJ_WAIT and
SYNCOBJ_TIMELINE_WAIT (polls; a failure is "not yet") apart from the
waits that may sleep.
2026-10-03 21:56:53 -07:00
geramyloveless a91b51d6c2 radv: upload shaders to VRAM by SDMA when no VRAM is CPU-visible
With no CPU-visible VRAM (Apple silicon), the winsys moved shader arenas
to GTT along with every other CPU-mapped buffer. Each instruction fetch
that missed the GPU's caches then crossed the PCIe link. On the R9700,
RADV_PERFTEST=dmashaders, which keeps shader code in NO_CPU_ACCESS VRAM
and uploads it by SDMA, raised llama.cpp decode from 12.96 to 17.97
tokens/s.

The Apple-silicon Mesa patch now selects that path whenever the device
has dedicated VRAM and none of it is CPU-visible, so no flag is needed.

The CS fixture runs a userspace driver's SDMA packets (copy linear,
write, constant fill, fence) in client IBs when driver streams are
modeled; the kernel's IBs keep the fixture's own packets.
test-radv-offline checks that a compiled pipeline reaches VRAM through
an SDMA copy.
2026-10-03 21:24:49 -07:00
geramyloveless f498511cca radv: keep buffers the CPU maps out of VRAM on Apple silicon
First run on the R9700: vkCreateDevice died with SIGBUS
(EXC_ARM_DA_ALIGN) in memmove, writing RADV's graphics preamble into a
command buffer. RADV places command buffers in CPU-visible VRAM, and
resizable BAR makes all of it visible. Apple silicon gives the CPU only
Device memory attributes for PCIe BARs, even for a write-combined mapping,
so unaligned stores fault. A probe of each mapping on the R9700: GTT,
cached or USWC, takes aligned and unaligned stores, unaligned memcpy and
memset; VRAM through BAR0 takes aligned stores but faults on unaligned
stores and unaligned memcpy.

No mapping option makes BAR space normal memory, so the third Mesa patch
(radv-apple-silicon-vram.patch) keeps the CPU out of VRAM on Apple
silicon. RADV's winsys reports no CPU-visible VRAM (no host-visible
device-local memory type; all VRAM is one device-local heap), and places
every buffer that is not NO_CPU_ACCESS in GTT: command buffers,
descriptor pools, shader arenas and upload buffers. Buffers only the GPU
touches, such as images, device-local memory and model weights, stay in
VRAM.

On the R9700, vulkaninfo now completes, and llama.cpp's test-backend-ops
passes on the GPU: ADD 103/103 and MUL_MAT 1132/1132. test-radv-offline
now checks that no memory type is both host-visible and device-local on
Apple silicon.
2026-10-03 18:00:23 -07:00
geramyloveless cdb75b6ff4 Pin llama.cpp b11379 and build its Vulkan backend for RADV
llama.cpp is the first application of the Vulkan path. third_party/llama.cpp
pins b11379 as an optional, unpatched upstream (sparse, update = none);
scripts/bootstrap.sh --llama-only fetches it and verify-upstream.py checks
it once checked out.

scripts/build-llama-vulkan.sh (make llama-vulkan) builds it with
GGML_VULKAN against the Vulkan loader (Homebrew's or the LunarG SDK's),
Metal, BLAS and libcurl off, into build/llama.cpp/bin: llama-bench,
llama-completion and test-backend-ops. Its shaders need shaderc's glslc.
scripts/llama-radv.sh runs any program with the loader pointed at the RADV
ICD alone, so a MoltenVK installation is not used.

test-llama-offline brings the CS fixture device up inside llama.cpp's own
test-backend-ops (vulkan/tests/fixture_preload.c, inserted through
MLG_PRELOAD) so its Vulkan backend runs on RADV on the software GPU:
llama.cpp lists the R9700, and in performance mode ADD and the Q4_0/Q4_K
matrix multiplications of a feed-forward layer (matrix-vector and
matrix-matrix pipelines) are compiled by ACO, allocated, submitted and
fenced. It skips unless RADV and llama.cpp are built.
2026-10-03 11:19:41 -07:00
geramyloveless 8c105a22ef radv: build Mesa's Vulkan driver for macOS, and test it offline
scripts/build-radv.sh (make radv) builds RADV from third_party/mesa on
libdrm-mlg: Meson with the ACO compiler and no LLVM, no window-system
platform (headless WSI), no GL, video, zstd or SPIRV-Tools, so the driver
links only the system and libdrm-mlg. It installs a relocatable ICD into
build/radv/install (libvulkan_radeon.dylib, libdrm_mlg.dylib,
libmlg_drm.dylib, share/vulkan/icd.d/radeon_icd.json with a relative
library path) and fails if any symbol other than the weak layer
entrypoints is left unresolved. Mesa's Python generators get a virtualenv
when python3 lacks mako, PyYAML or packaging.

test-radv-offline (vulkan/tests/test_radv_offline.c) loads the ICD as the
loader does and runs it on the CS fixture device through libdrm-mlg and
the loopback transport, against unmodified upstream DRM/amdgpu: instance
and enumeration ("AMD Radeon AI Pro R9700 (RADV GFX1201)", Vulkan 1.4, PCI
bus info), device creation, host-visible memory, an empty submit with a
fence, vkCmdFillBuffer and vkCmdUpdateBuffer executed by the software GPU
and checked through the mapping, a compute pipeline compiled by ACO, and a
dispatch submitted with a timeline semaphore and a fence (the software GPU
runs no shaders, so its result is not checked). It skips when RADV has not
been built.
2026-10-03 11:19:30 -07:00