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 ¶
- type Device
- type Renderer
- func (r *Renderer) BeginFrame(width, height int, clear scene.Color) error
- func (r *Renderer) CaptureNextFrame(fn func(*image.RGBA, error))
- func (r *Renderer) Close()
- func (r *Renderer) Describe() string
- func (r *Renderer) DrawGlyphs(run scene.GlyphRun)
- func (r *Renderer) DrawImages(ims []scene.ImageDraw)
- func (r *Renderer) DrawQuads(qs []scene.Quad)
- func (r *Renderer) EndFrame() error
- func (r *Renderer) PopClip()
- func (r *Renderer) PushClip(c scene.Rect)
- func (r *Renderer) PushRoundedClip(c scene.Rect, radii scene.Corners)
- func (r *Renderer) Recreate() error
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 ¶
NewDevice loads Vulkan and creates the device and the pipelines every window shares. Call it once; NewRenderer adds a window to it.
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 ¶
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) Prefer ¶
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 ¶
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 ¶
BeginFrame implements render.Renderer.
func (*Renderer) CaptureNextFrame ¶
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) DrawGlyphs ¶
DrawGlyphs implements render.Renderer.
func (*Renderer) DrawImages ¶
DrawImages implements render.Renderer.
func (*Renderer) EndFrame ¶
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) PushRoundedClip ¶
PushRoundedClip implements render.Renderer.