session

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package session coordinates Wayland ownership, Vulkan submissions, DRM release points and the application frame loop behind nefergui.Run.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppHooks

type AppHooks struct {
	Wake      <-chan struct{}
	Input     func([]wayland.Input) error
	Event     func(wayland.Event) error
	Draw      func() (render.Frame, bool, error)
	Committed func(uint64) error
}

AppHooks runs entirely on the session owner loop. Draw returns dirty=false when there is no new display list; the session retries a dirty frame until committed without waiting for GPU completion on the loop.

type Pump added in v0.3.0

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

Pump drives one Session from an owner loop that multiplexes several sessions on a shared Connection. It never reads Wayland events itself: the owner applies them and forwards BufferRelease. All methods run on the owner loop.

func (*Pump) BufferReleased added in v0.3.0

func (p *Pump) BufferReleased(id uint64) error

BufferReleased returns a compositor-released wl_buffer to the pool.

func (*Pump) Close added in v0.3.0

func (p *Pump) Close()

Close stops release waiters. Call before Session.Close.

func (*Pump) Invalidate added in v0.3.0

func (p *Pump) Invalidate()

Invalidate requests a fresh draw at the next Step.

func (*Pump) Session added in v0.3.0

func (p *Pump) Session() *Session

Session returns the pumped session.

func (*Pump) Step added in v0.3.0

func (p *Pump) Step() (retry bool, err error)

Step applies queued GPU releases and submits at most one frame. retry reports that the owner must call Step again after retryInterval.

type Session

type Session struct {
	Window       *wayland.Window
	Device       *vkdevice.Device
	Node         *syncobj.Node
	Pool         *buffers.Pool
	Pipeline     *vkdevice.Pipeline
	ListPipeline *vkdevice.Pipeline
	Preparer     *render.Preparer

	Slots map[uint64]*Slot

	Acquire         uint32
	AcquireTimeline *drmsyncobj.WpLinuxDrmSyncobjTimeline
	Width, Height   int32
	Transparent     bool
	// contains filtered or unexported fields
}

func Open

func Open(name string, width, height int32, transparent bool) (*Session, error)

Open opens a default xdg-toplevel session.

func OpenWindow added in v0.3.0

func OpenWindow(w *wayland.Window, transparent bool) (_ *Session, err error)

OpenWindow builds the Vulkan/DMA-BUF/explicit-sync path for a window that is already configured and has completed dmabuf feedback (a Connection sibling). On error the window is closed. The session owns w from here on.

func OpenWithOptions added in v0.2.0

func OpenWithOptions(ctx context.Context, name string, width, height int32, transparent bool, opts wayland.SurfaceOptions) (_ *Session, err error)

OpenWithOptions opens a session whose surface role and initial input region are selected by opts; the zero value is identical to Open. Wayland startup is abandoned when ctx is cancelled; ctx is not retained after it returns.

func (*Session) Close

func (s *Session) Close() (err error)

Close detaches and destroys the explicit-sync surface, traces release points for at most 200 ms, waits for our GPU, then frees every client allocation. Compositor imports keep independent DMA-BUF kernel references. It returns errors from writing requested debug artifacts; allocations are freed regardless.

func (*Session) NewPump added in v0.3.0

func (s *Session) NewPump(ctx context.Context, wake chan<- struct{}, draw func() (render.Frame, bool, error)) (*Pump, error)

NewPump prepares s for a shared owner loop. wake is pinged (never blocked on) when a GPU release point is ready; the owner then calls Step. draw follows the AppHooks.Draw contract.

func (*Session) Run

func (s *Session) Run(ctx context.Context, frames int, draw func(int) vkdevice.Rect) (int, error)

func (*Session) RunApp

func (s *Session) RunApp(ctx context.Context, app AppHooks) error

RunApp drives a UI until close or cancellation. Wayland input is batched after Apply, and wake tokens, repeat deadlines and release points share one select.

func (*Session) RunListWithCommit

func (s *Session) RunListWithCommit(ctx context.Context, frames int, draw func(int) []vkdevice.Instance, committed func(int) error) (int, error)

RunListWithCommit drives the list renderer using the existing frame loop.

func (*Session) RunPreparedListWithCommit

func (s *Session) RunPreparedListWithCommit(ctx context.Context, frames int, draw func(int) (render.Frame, error), committed func(int) error) (int, error)

RunPreparedListWithCommit prepares uploads on every attempt. Preparer keeps them owed until a submission, so a skipped attempt is resent by the next one.

func (*Session) RunWithCommit

func (s *Session) RunWithCommit(ctx context.Context, frames int, draw func(int) vkdevice.Rect, committed func(int) error) (int, error)

RunWithCommit calls committed after each successfully committed frame. The optional hook is for the example's capture request; it never gates reuse.

func (*Session) Tick

func (s *Session) Tick(rect vkdevice.Rect) (bool, error)

Tick presents at most one frame. The caller drives the Wayland dispatch loop; a frame callback only schedules Tick, never makes an image reusable.

func (*Session) TickList

func (s *Session) TickList(instances []vkdevice.Instance, uploads []text.Upload) (bool, error)

TickList presents ordered instanced quads with the same ownership gates as Tick.

type Slot

type Slot struct {
	Buffer          *buffers.Buffer
	Image           *vkdevice.Image
	Frame           *vkdevice.Frame
	First           bool
	Wait            *vkdevice.BinaryFence
	PendingWait     *vkdevice.BinaryFence
	WaitInFlight    bool
	ReadbackFrame   uint64
	ReadbackPending bool
	ReleaseHandle   uint32
	ReleaseTimeline *drmsyncobj.WpLinuxDrmSyncobjTimeline
}

Jump to

Keyboard shortcuts

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