vulkan

package
v0.8.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package vulkan is the Vulkan backend for render.Renderer, for Linux.

It is pure Go: libvulkan is loaded at run time with purego, and the shaders ship as SPIR-V compiled from the GLSL in shaders/ (see shaders/compile.sh). The platform adapter speaks Wayland itself, without libwayland, so Vulkan's window-system integration (VK_KHR_wayland_surface) cannot be used: frames are drawn into images exported as dma-bufs, which the adapter hands to the compositor (see package dmabuf).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device is the Vulkan device and the GPU state every window shares: pipelines, samplers, the instance and staging buffers, and textures. Create one per process with NewDevice; all windows render from the UI thread, one at a time.

func NewDevice

func NewDevice() (*Device, error)

NewDevice loads Vulkan and creates the device and the pipelines every window shares. Call it once; NewRenderer adds a window to it.

func (*Device) Adapter

func (d *Device) Adapter() string

Adapter names the GPU the device runs on, for diagnostics.

func (*Device) Close

func (d *Device) Close()

Close releases the device and the instance. The windows rendering with it must be closed first.

func (*Device) NewRenderer

func (d *Device) NewRenderer(s dmabuf.Surface) (*Renderer, error)

NewRenderer creates the renderer of a window whose frames s shows. It fails when the compositor imports none of the images the device can make for it; the window is then drawn on the CPU.

func (*Device) OnDevice

func (d *Device) OnDevice(dev dmabuf.Device) bool

OnDevice reports whether the device runs on dev, the compositor's device.

func (*Device) Prefer

func (d *Device) Prefer(dev dmabuf.Device)

Prefer makes dev the device that Recover chooses when it qualifies: the GPU the compositor composites with, so frames are not copied between GPUs.

func (*Device) Recover

func (d *Device) Recover() error

Recover recreates the device and every object it owns after a loss (or after ReleaseDevice). Textures are uploaded again the next time a frame draws them; each window then calls Renderer.Recreate.

func (*Device) ReleaseDevice

func (d *Device) ReleaseDevice()

ReleaseDevice releases the device and every object it owns, as a loss leaves them. It is the simulation hook for the devicelost script step.

type Renderer

type Renderer struct {
	*Device
	// contains filtered or unexported fields
}

Renderer implements render.Renderer with Vulkan for one window. Its frames are drawn into images that the window's surface shows; the device it draws with is shared.

func (*Renderer) BeginFrame

func (r *Renderer) BeginFrame(width, height int, clear scene.Color) error

BeginFrame implements render.Renderer.

func (*Renderer) CaptureNextFrame

func (r *Renderer) CaptureNextFrame(fn func(*image.RGBA, error))

CaptureNextFrame implements render.Renderer.

func (*Renderer) Close

func (r *Renderer) Close()

Close implements render.Renderer. It releases the window's images; the device stays for the other windows.

func (*Renderer) Describe

func (r *Renderer) Describe() string

Describe summarizes how the window's frames are shown, for diagnostics.

func (*Renderer) DrawGlyphs

func (r *Renderer) DrawGlyphs(run scene.GlyphRun)

DrawGlyphs implements render.Renderer.

func (*Renderer) DrawImages

func (r *Renderer) DrawImages(ims []scene.ImageDraw)

DrawImages implements render.Renderer.

func (*Renderer) DrawQuads

func (r *Renderer) DrawQuads(qs []scene.Quad)

DrawQuads implements render.Renderer.

func (*Renderer) EndFrame

func (r *Renderer) EndFrame() error

EndFrame implements render.Renderer. It records the frame, submits it and waits for the GPU to finish, then presents the image: the compositor reads it as soon as it is attached, so it must be complete. A frame of a desktop UI takes the GPU well under a millisecond.

func (*Renderer) PopClip

func (r *Renderer) PopClip()

PopClip implements render.Renderer.

func (*Renderer) PushClip

func (r *Renderer) PushClip(c scene.Rect)

PushClip implements render.Renderer.

func (*Renderer) PushRoundedClip

func (r *Renderer) PushRoundedClip(c scene.Rect, radii scene.Corners)

PushRoundedClip implements render.Renderer.

func (*Renderer) Recreate

func (r *Renderer) Recreate() error

Recreate prepares the window to draw again on the device after Device.Recover. Its images were released with the old device. When the device still renders the kind of image the compositor imported, it is kept without probing again.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL