jovian / venusian-vulkan
The 'vulkan' GPU driver for Venusian topside: one Vulkan device for the process, its textures, buffers, shaders, pipelines and passes, and the surfaces it presents into, through ext-vulkan.
Requires
- php: ~8.4.27||^8.5.12
- ext-posi: ^0.11.0
- ext-vulkan: ^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
- ext-metal: On macOS, presenting into a canvas's CAMetalLayer goes through vkCreateMetalSurfaceEXT over ext-metal's layer.
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-03 14:58:00 UTC
README
The vulkan GPU driver for Venusian topside: one Vulkan device for the process, its textures, buffers, shaders, pipelines and passes, and the surfaces it presents into, through ext-vulkan.
Requirements
- PHP 8.4 and ext-vulkan ^0.11.0, with a Vulkan loader and driver (MoltenVK on macOS).
- 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-vulkan
The provider is discovered through extra.venusian.providers and registers the vulkan driver with topside's GPU component.
Usage
With GPU_DRIVER=vulkan, topside's Gpu gives the Vulkan 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 as SPIR-V, named spirv, with its entry point, bound as SDL's GPU API lays it out:
| What a shader binds | Where it is in spirv |
|---|---|
| vertex texture slot n, with its sampler | set 0, binding n |
| vertex uniform-block slot n | set 1, binding n |
| fragment texture slot n, with its sampler | set 2, binding n |
| fragment uniform-block slot n | set 3, binding n |
| vertex buffer n | binding n of the vertex input |
Gpu::target($info) answers the target for a place lent as the create-info of a surface: on macOS a VkMetalSurfaceCreateInfoEXT, known by its layer; on Linux a VkXlibSurfaceCreateInfoKHR, known by its display and window, or a VkWaylandSurfaceCreateInfoKHR, known by its display and surface. The Linux forms exist in ext-vulkan's Linux build. The driver makes the surface on its own instance. Its images have the size the surface reports, and present() copies what fits.
Earlier code
The package's earlier engines, presenters, shaders and tests are kept in deprecated/, deprecated2/ and deprecated3/. None is autoloaded or run.
Security
See SECURITY.md.
License
MIT. See LICENSE.