summaryrefslogtreecommitdiffstats
path: root/examples/sample_engine.dit.txt
blob: 4646155869edd6460d32fd84b25c7a5b1a603e57 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
diagram "Realtime Media & Compute Pipeline" routing=orthogonal

# Try opening this file directly:
#   design-it examples/sample_engine.dit.txt
# Or exporting it headlessly to SVG:
#   design-it examples/sample_engine.dit.txt --set="color scheme=nord" --export-svg=pipeline.svg

module "Ingest" id=mod_ingest tag=ingest {
  interface "PacketSource" id=src stereo="<<interface>>" tag=ingest {
    section "contract" {
      + poll(buf) : usize [non-blocking]
      + close() : void
    }
  }

  class "FileDemuxer" id=demux tag=ingest {
    section "fields" {
      - fd : s32
      - cursor : u64 [offset]
    }
    section "methods" {
      + seek(pts) : bool
    }
  }

  storage "PacketRing" id=ring stereo="lock-free SPSC" tag=hot {
    section "memory (cache-isolated)" {
      + write_idx : atomic<u64> [0x00]
      + read_idx : atomic<u64> [0x40]
      + slots[4096] : Packet [256 KB]
    }
  }
}

module "Compute" id=mod_compute tag=compute {
  system "DecodeWorker" id=worker stereo="dedicated thread" tag=hot {
    section "pipeline" {
      + decode_batch() : u32 [SIMD]
      + flush() : void
    }
  }

  enum "FrameFormat" id=fmt tag=compute {
    section "variants" {
      RGBA8 [4 Bpp]
      NV12 [planar]
      F32_STEREO [audio]
    }
  }

  struct "Frame" id=frame stereo="arena-backed" tag=compute {
    section "fields" {
      + pts_ns : u64
      + format : FrameFormat
      + data : u8* [64B align]
    }
  }
}

module "Presentation" id=mod_present tag=render {
  system "VulkanPresenter" id=presenter stereo="vk 1.3 sync2" tag=render {
    section "methods" {
      + upload(Frame*) : void [staging]
      + present() : bool [mailbox]
    }
  }

  state "Idle -> Running -> Draining" id=lifecycle tag=render {
    note "Zero CPU wakeups while Idle"
  }
}

demux ..|> src : "implements"
demux ==> ring : "enqueue packets" [1 -> 0..4096]
worker ==> ring : "consume SPSC" tag=hot
worker *-> frame : "produces"
frame -> fmt : "tagged by"
worker ==> presenter : "frame handoff" [1 -> 2] tag=hot
presenter ..> lifecycle : "tracks state" route=bezier