v0.7.0 438604c

slot.go RawHistoryFolder

1//go:build linux
2
3// Package session is the Wayland-free presentation core: Vulkan rendering into
4// DMA-BUF buffers, DRM syncobj timelines and buffer ownership.
5package session
6
7import (
8	"fmt"
9
10	"github.com/bnema/nefergui/internal/presentation/buffers"
11	"github.com/bnema/nefergui/internal/presentation/vkdevice"
12)
13
14// Slot is the GPU side of one pool buffer. Descriptors are -1 when unset.
15type Slot struct {
16	Buffer        *buffers.Buffer
17	Image         *vkdevice.Image
18	Frame         *vkdevice.Frame
19	First         bool
20	Wait          *vkdevice.BinaryFence
21	PendingWait   *vkdevice.BinaryFence
22	WaitInFlight  bool
23	spare         *vkdevice.BinaryFence // consumed, unsignaled wait semaphore kept for reuse
24	ReleaseHandle uint32
25	ReleaseFD     int  // eventfd armed on each commit's release point
26	ReleaseExport int  // exported syncobj fd of the release timeline
27	Presented     bool // the caller has been told to import this buffer
28}
29
30// beginReady does not change Pool ownership until the previous GPU submission
31// has completed. An unready available buffer is retried on a bounded wakeup.
32func beginReady(pool *buffers.Pool, slots map[uint64]*Slot, ready func(*Slot) (bool, error)) (*buffers.Buffer, *Slot, bool, error) {
33	waiting := false
34	for _, b := range pool.Buffers {
35		if b.Generation != pool.Generation || b.State != buffers.Available {
36			continue
37		}
38		slot := slots[b.ID]
39		if slot == nil {
40			return nil, nil, false, fmt.Errorf("missing slot %d", b.ID)
41		}
42		ok, err := ready(slot)
43		if err != nil {
44			return nil, nil, false, err
45		}
46		if !ok {
47			waiting = true
48			continue
49		}
50		b.State = buffers.Rendering
51		b.WlReleased, b.PointSignaled = false, false
52		return b, slot, false, nil
53	}
54	return nil, nil, waiting, nil
55}
56
57// installReleaseWait holds the new semaphore until the old submission is done.
58// Only the state owner calls it. On an unready fence it leaves Pool Released.
59func installReleaseWait(slot *Slot, next *vkdevice.BinaryFence, ready func() (bool, error)) (bool, error) {
60	if slot.Wait != nil && slot.WaitInFlight {
61		ok, err := ready()
62		if err != nil {
63			return false, err
64		}
65		if !ok {
66			slot.PendingWait = next
67			return false, nil
68		}
69	}
70	if slot.Wait != nil {
71		if slot.WaitInFlight {
72			slot.recycle(slot.Wait) // submission done: the wait was consumed
73		} else {
74			slot.Wait.Close() // never waited on: its imported payload is still signaled
75		}
76	}
77	slot.Wait, slot.PendingWait, slot.WaitInFlight = next, nil, false
78	return true, nil
79}
80
81// recycle keeps a release-wait semaphore for reuse. The caller guarantees the
82// submission that waited on it has completed: a wait operation consumes the
83// temporarily imported payload and leaves the semaphore unsignaled and idle.
84func (s *Slot) recycle(w *vkdevice.BinaryFence) {
85	if s.spare != nil {
86		w.Close()
87		return
88	}
89	s.spare = w
90}
91
92type retiredPipelines struct {
93	generation uint64
94	list       *vkdevice.Pipeline
95}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 12

↑↓ moveenter openesc close