jovian / venusian-metal
The 'metal' GPU driver for Venusian topside: one Metal device for the process, its textures, buffers, shaders, pipelines and passes, and the CAMetalLayers it presents into, through ext-metal.
Package info
github.com/jovian-packages/venusian-metal
Language:Metal
pkg:composer/jovian/venusian-metal
Requires
- php: ~8.4.27||^8.5.12
- ext-appkit: ^0.11.0
- ext-fb: ^0.11.1
- ext-metal: ^0.11.0
- venusian-surface/contracts: ^0.11.0
- venusian-surface/drawing: ^0.11.0
- venusian-surface/framebuffers: ^0.11.0
- venusian-voyager/nuts-and-bolts: ^0.11.0
Requires (Dev)
- pestphp/pest: ^4
- venusian-surface/fonts: ^0.11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-03 06:18:44 UTC
README
The metal GPU driver for Venusian topside: one Metal device for the process, its textures, buffers, shaders, pipelines and passes, and the CAMetalLayers it presents into, through ext-metal.
Requirements
- macOS, PHP 8.4 and ext-metal ^0.11.0.
- The test suite also needs ext-posi, and the package does not. ext-posi writes the memory a test hands over as an address and reads the pixels
read()answers; it is inrequire-devandsuggest, neverrequire. A test that needs it is skipped where it is not loaded.
Install
composer require jovian/venusian-metal
The provider is discovered through extra.venusian.providers and registers the metal driver with topside's GPU component.
Usage
With GPU_DRIVER=metal, topside's Gpu gives the Mac's Metal device:
use Surface\Gpu\Gpu; use Surface\Gpu\PassSpec; use Surface\Gpu\TextureSpec; use Surface\NutsAndBolts\Color; use Surface\NutsAndBolts\FormatSpec; use Surface\Contracts\Gpu\TextureUse; use Surface\Contracts\Gpu\TextureFormat; $device = Gpu::device(); $texture = $device->texture(new TextureSpec(320, 240, TextureFormat::RGBA8, [TextureUse::TARGET])); $commands = $device->commands(); $commands->render(new PassSpec($texture, clear: new Color(1.0, 0.5, 0.0, 1.0)))->end(); $commands->submit(); $memory = $device->read($texture, FormatSpec::rgba8Premultiplied()); // a PixelMemory, top row first
A shader is handed over in Metal's shading language, named msl, as text with its entry point; Metal compiles it when the shader is made.
| What a shader binds | Where it is in msl |
|---|---|
| texture slot n, with its sampler | [[texture(n)]] and [[sampler(n)]] |
| uniform-block slot n | [[buffer(n)]] |
| vertex buffer n | [[buffer(14 + n)]] |
Gpu::target($layer) answers the target for a CAMetalLayer, the same one for the same layer while it lives. The driver sets its device and BGRA8 pixel format on the layer. present() leaves the layer's size to its owner and copies what fits.
Earlier code
The package's earlier engines and their shaders and tests are kept in deprecated/, deprecated2/ and deprecated3/. None is autoloaded or run.
Security
See SECURITY.md.
License
MIT. See LICENSE.