You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a607e20
Browse filesBrowse the repository at this point in the historyBrowse files
feat(compositor): the Linux pass of shader effects
The wgpu compositor now draws agent-written effects, as the Windows one does:
same targets (image, text layer, both), same lanes, same blocking rule
(the export waits for the pipeline, the live view skips it until it lands).
- The WGSL goes to wgpu as it is. A background thread builds the module and
the pipeline against an explicit layout of the prelude's four bindings.
- wgpu panics on a validation error: `analyze` now also refuses any binding
the prelude does not declare, so nothing invalid reaches it.
- `check_for_agent` translates the effect to SPIR-V on Linux.
- live.rs turns the preview's non-blocking mode on for Linux too.
Tested on lavapipe under WSL: the six GPU tests of the Windows pass, ported,
and the full compositor suite. Tier calibration on lavapipe goes to
rendering-performance.md and the spec (C.7, H.2).
-**Mesuré sur lavapipe** (le repli CPU de Linux, 16 threads) : environ 1,4 ms par lecture en
344
+
1080p, 350 fois la RTX. Un effet léger y ajoute jusqu'à 11 ms à une frame qui en coûte 7,5 ;
345
+
un lourd, 234 ms. L'ordre des paliers tient, mais sans GPU même un effet léger double le
346
+
temps d'export.
341
347
-**Le GPU intégré de référence** (le Radeon 610M des mesures Linux) reste à mesurer : on y attend
342
348
plusieurs fois ces coûts. La description de l'outil donnera les paliers en ms sur les deux
343
349
machines, pour que l'agent raisonne en temps et non en lectures.
@@ -424,10 +430,10 @@ Une seule source WGSL, traduite par naga au moment de compiler.
424
430
|---|---|---|---|
425
431
| Traduction | naga vers HLSL SM 5.0 | naga vers MSL | aucune : WGSL tel quel |
426
432
| Compilation |`D3DCompile` (FXC) vers DXBC, puis `CreateVertexShader`/`CreatePixelShader`|`new_library_with_source`, puis `make_pipeline(…, Blend::Replace)`|`create_shader_module`, puis `create_render_pipeline`|
427
-
| Thread de fond | naga et FXC (fait) | bibliothèque et pipeline, sous `autoreleasepool`| module et pipeline |
428
-
| Copie du RT |`CopySubresourceRegion` vers `ann_copy` (fait) |`snapshot_rt(cmd_buf, false)`|`copy_texture_to_texture` vers `ann_copy` (comme le verre) |
429
-
| Insertion | fin de `compose_frame` (fait) | entre `draw_annotations(…, false)` et `submit`| entre l'ann-passet `submit`|
430
-
| Uniforms |`Map(WRITE_DISCARD)` (fait) |`set_fragment_bytes`|`create_buffer_init(UNIFORM)` par draw|
433
+
| Thread de fond | naga et FXC (fait) | bibliothèque et pipeline, sous `autoreleasepool`| module et pipeline (fait) |
434
+
| Copie du RT |`CopySubresourceRegion` vers `ann_copy` (fait) |`snapshot_rt(cmd_buf, false)`|`copy_texture_to_texture` vers le niveau 0 d'`ann_copy` (fait) |
435
+
| Insertion | fin de `compose_frame` (fait) | entre `draw_annotations(…, false)` et `submit`|`image`entre la passe caméra et l'ann-pass, `text`et `both` après (fait)|
436
+
| Uniforms |`Map(WRITE_DISCARD)` (fait) |`set_fragment_bytes`|`create_buffer_init(UNIFORM)` par passe (fait)|
431
437
432
438
**macOS en détail**
433
439
-**Activer `msl-out`.** Le dépôt l'obtient aujourd'hui par unification des features de wgpu ; le
@@ -447,7 +453,14 @@ Une seule source WGSL, traduite par naga au moment de compiler.
447
453
-**Le thread de fond.**`wgpu::Device` est `Send`, `Sync` et `Clone` : le pipeline peut se
448
454
construire hors du thread de rendu.
449
455
-**Valider avant wgpu.** Aucun `on_uncaptured_error` n'est posé, donc une erreur de validation
450
-
wgpu fait paniquer. La pré-validation par naga (`shader_fx::validate`) en protège.
456
+
wgpu fait paniquer. La pré-validation (`shader_fx::analyze`) en protège : naga 24, celui de
457
+
wgpu 24, et le refus de tout binding que le prélude ne déclare pas. Si wgpu panique malgré tout,
458
+
seul le thread de compilation meurt, et l'effet ne se dessine pas (D.6).
459
+
-**« Accepté » sous Linux.**`check_for_agent` traduit l'effet en SPIR-V par naga, comme wgpu le
460
+
fera. La compilation par le pilote Vulkan n'a lieu qu'à `set_scene`, faute de device dans
461
+
l'outil.
462
+
-**Le calque des textes** est une texture RGBA8 transparente, posée sur le RT par la passe qui
463
+
recopie déjà `accum` (`pipeline_copy`, « over » prémultiplié).
451
464
452
465
**naga reste en 24.** À partir de la 25, sa sortie HLSL déclare les samplers dans un tas D3D12
453
466
(`register(s0, space0)`), que FXC refuse en `ps_5_0` (erreur X3721). Le test
@@ -692,10 +705,12 @@ qu'on n'a pas écrit.
692
705
| Export de 180 frames en 1752×1080 : sans effet, avec effet, avec effet lourd | 520, 523 et 521 ms |
693
706
| Preview en lecture, source à 30 i/s | 30 i/s avec et sans effet |
694
707
708
+
Mesuré à la passe Linux (lavapipe sous WSL, 16 threads) : effet prêt en 18 ms après `set_scene`,
709
+
module et pipeline compris ; les paliers en C.7.
710
+
695
711
À mesurer à l'implémentation :
696
712
- un GPU intégré (le Radeon 610M des mesures Linux) ;
|[`crates/compositor/src/compositor.rs`](../../crates/compositor/src/compositor_windows.rs)| HLSL compositor — every per-frame pass (`compose_frame`, background, screen, webcam, cursor, annotations, shadows, blur) |
31
31
|[`crates/compositor/src/scene.rs`](../../crates/compositor/src/scene.rs)| the `Scene` struct parsed from the app's `SceneDescription` JSON |
32
-
|[`crates/compositor/src/shader_fx.rs`](../../crates/compositor/src/shader_fx.rs)| agent-written shader effects: the WGSL contract, validation and loop rule, cost tiers, parameter packing, background compilation (FXC on Windows) |
32
+
|[`crates/compositor/src/shader_fx.rs`](../../crates/compositor/src/shader_fx.rs)| agent-written shader effects: the WGSL contract, validation and loop rule, cost tiers, parameter packing, background compilation (FXC on Windows; on Linux, `compositor_linux.rs` builds wgpu pipelines) |
33
33
|[`crates/compositor/src/regions.rs`](../../crates/compositor/src/regions.rs)| zoom / speed / Full Camera regions — envelope shapes and per-frame state sampling |
34
34
|[`crates/compositor/src/pipeline.rs`](../../crates/compositor/src/pipeline_windows.rs)| demux + `D3D11VA` decode + composite + AMF encode + mux (`run_c0` for decode/encode only, `run_composited` for the full path) |
Copy file name to clipboardExpand all lines: technical-documentation/engineering/rendering-performance.md
+13-1Lines changed: 13 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -448,7 +448,19 @@ An agent-written effect (`crates/compositor/src/shader_fx.rs`, [docs/shader-effe
448
448
449
449
-**The cost is linear in the reads,** about 4 µs per read at 1080p and 17 µs at 4K, over a fixed 0.03 ms (1080p) for the copy and the pass. It is the texture bandwidth that pays, which is why the tiers count reads.
450
450
-**The export does not notice a light effect:** 180 frames at 1752×1080 took 520 ms without, 523 ms with the spike's effect, and 521 ms with a heavier one. The preview held the source's 30 fps either way.
451
-
-**Not measured yet:** an integrated GPU, where the same reads cost several times more, and the Metal and wgpu passes.
451
+
-**On lavapipe, the Linux CPU fallback,** the same bench (`compositor_linux::tests::shader_fx_tier_calibration`, release, best of three runs of 5 frames, WSL on 16 threads) gives about 1.4 ms per read at 1080p, 350 times the RTX:
452
+
453
+
|`frame()` reads | Tier | 1080p | 4K |
454
+
|---:|---|---:|---:|
455
+
| none (the frame alone) || 7.5 ms | 29.5 ms |
456
+
| 1 | light | +3.2 ms | +13.4 ms |
457
+
| 8 | light | +11.2 ms | +44.4 ms |
458
+
| 32 | medium | +42.1 ms | +159 ms |
459
+
| 128 | heavy | +234 ms | +958 ms |
460
+
| 512 | very heavy | +1 035 ms | +5 068 ms |
461
+
462
+
-**The tiers keep their order on lavapipe,** but without a GPU a light effect already doubles the frame. The pipeline is ready 18 ms after `set_scene` there, module and driver compile included.
463
+
-**Not measured yet:** an integrated GPU, where the same reads cost several times more, and the Metal pass.
0 commit comments