Skip to content

multi-window: per-output warp, blend, photometric and colour calibration stage - #2427

Open
jcelerier wants to merge 7 commits into
split/chain-basefrom
split/multiwindow-output
Open

jcelerier wants to merge 7 commits into
split/chain-basefrom
split/multiwindow-output

Conversation

@jcelerier

@jcelerier jcelerier commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

depends on: #2415 to #2426, all the independent PRs of the series, because split/chain-base is master plus a merge of each of them. The code here uses #2420 and #2425. Through #2426 the base also carries the libossia gitlink of libossia#995.

The first PR of the immersive chain. The multi-window output gets a full per-output calibration stage, so that score can drive a multi-projector installation (on the CAVE: six 3840x2160 projectors from one 8192x4096 equirect canvas) directly from the calibration files that the later PRs produce, without an external media server.

Per output, in this order:

  • Warp: corner pin, or a dense warp map (PFM), importable from MPCDI or Bourke files, with bicubic sampling, and mipmapped and anisotropic sampling of the canvas.
  • Blend: RGB alpha (blend) and beta (black level) maps, out = content * alpha + beta. A per-output "Blend map space" setting (Auto / Linear light / Signal) chooses where they apply. Auto applies float maps (PFM, EXR, Bourke intensities: what score writes, linear as Gfx/Calibration/Blending.hpp defines them) and an MPCDI alpha (linearised by its gammaEmbedded) in linear light. It applies 8 and 16-bit images in signal space, on the gamma-encoded values, as WATCHOUT or Resolume blend their masks. Linear light and Signal force one space for every map. The edge ramps keep following the linear blend setting. The setting is saved in the output mapping (in JSON only when not Auto), shown in the settings widget, and exposed as /i/maps/blend_space.
  • Radiometric compensation: P = M c + o, with a per-pixel M from comp*.pfm. Negative components are desaturated, and an out-of-range colour is scaled down whole, keeping its hue.
  • Projector colour mixing, inverted through a 33³ table packed in the response texture. A colour out of reach takes the closest reachable one, or is scaled towards black.
  • Response and colour: the measured per-channel response (name.response.json or a 1D .cube) in place of the 2.2 curve; gain, gamma, a 3D .cube LUT, HDR transfer functions, a 16-bit float canvas, and blue-noise dither (a baked 64x64 void-and-cluster table).

Calibration sets (name.json plus its .alpha/.beta/.cube/.response/.comp files) are assigned per output in the settings widget, through JSON, and through /i/maps/* OSC parameters. They are reloaded live when the files change, with a 300 ms debounce. Paths are stored as <PROJECT>: / <LIBRARY>: when they live under a root, and missing files are listed. setMaps() reads and checks the files on a worker thread and hands the result to the output on the GUI thread; only the texture upload stays on the render thread.

An output that only uses the settings that existed before is unchanged. Edge ramps alone neither make the canvas 16-bit float nor turn Auto dither on, and Auto sampling stays linear under a corner warp.

Commits

  • 270b90377f gfx: multi-window output stage with per-output calibration. This is the bulk of the PR, described above. The first load, in createOutput, is synchronous, before any frame. An MPCDI archive decodes only the region an output uses. A map whose size differs from its output is reported once per load. The PFM, Bourke, MPCDI, .cube and response.json readers bound every size they read, accept CRLF headers and refuse non-finite values. The output mapping stream is delimited, so a truncated project fails cleanly.
  • bd49445543 gfx: a multi-window device renders its content at its input size. The device's Input width / height only reached the forced-offscreen path, so every process feeding the device rendered at 1280x720 whatever the canvas size.
  • bdbf376952 profiler: frame rate, and the multi-window output stage. The profiler reports the frame rate of the fastest output, and an "Output stage" entry for the windows' own passes, kept apart from frame totals. It also fixes a master bug: QRhiCommandBuffer::lastCompletedGpuTime() is in seconds, but was recorded as milliseconds.
  • 9126360463 multi-window: bake the warp map lookup once per window. The 16-tap Catmull-Rom read is baked into an RGBA32F texture at the window's size, redone only when the map, the filter or the size changes. On the CAVE (RTX A4000, Vulkan): window passes take 6.4-7.1 ms instead of 12.7-13.2 ms, and 54-59 fps instead of 43-44. It costs about 133 MB per 4K window with a warp map. SCORE_MW_NO_WARP_BAKE=1 forces the old path.
  • a68cea3b63 multi-window: one QRhi frame slot per tick when Qt supports it. See the notes.
  • 234e345f81 multi-window: Auto sampling uses mips only where the warp minifies. The footprint is measured from the warp map when it loads (99.5th percentile, sampled on at most 2^18 texels). Auto picks anisotropic only above 1.5 canvas texels per output pixel. On the CAVE this avoids about 2.6 ms of GPU per frame on Vulkan and a blocking generateMips on D3D12 (16-18 fps before, 62 fps after).
  • 660c6e9859 tests: device pixels on a HiDPI desktop. The test fixture turns Qt's high-DPI scaling off unless the environment chooses otherwise, so readback sizes match the window sizes on a scaled desktop.

Tests

  • New: test_gfx_multi_window_calibration (warp, alpha / beta, colour, blending in linear light, live corner warp, blend map space, Auto sampling and mips, live map swaps and reloads), test_gfx_multi_window_photometric (RGB maps, measured response, compensation, colour mixing inverse), test_gfx_multi_window_quality (3D LUT, dither, Catmull-Rom warp, mip / anisotropic sampling), test_gfx_float_map_files (PFM layout, 16-bit images, Bourke meshes, MPCDI), test_gfx_calibration_file_hardening (crafted PFM, Bourke, MPCDI, .cube and response.json files), and test_gfx_profiler_gpu_time.
  • Extended: test_gfx_multi_window (renders at the canvas size it is given), test_gfx_window_device_tree (warp, colour and map parameters, calibration file matching and watching), test_gfx_window_settings_ui (calibration maps and sets, relative paths, colour values), and test_unit_profiler (frame rate, stale outputs, output stage report).
  • The whole series was built and tested with ctest on Linux (Xvfb, lavapipe Vulkan and Mesa OpenGL). Nothing failed beyond master's own known failures (test_gfx_shader_corpus_targets, test_gfx_window_layout, test_threedim_ply_fingerprint, test_unit_miniaudio_alsa and the few others master's run lists).
  • The multi-window tests were also run on a real desktop GPU (Intel, Mesa OpenGL and Vulkan under XWayland).

Notes for review

  • The frame-slot-group path (a68cea3b63) compiles only against a patched Qt that defines QRHI_HAS_FRAME_SLOT_GROUPS (the ossia SDK patch). CI never builds it, and on stock Qt behaviour is unchanged. With the flags, the scene frame keeps its slot, the windows continue it, and the last live window advances it. A tick that opens the group and does not close it (no output renderer, or the last window failing beginFrame) closes it with an empty offscreen frame. SCORE_MW_NO_SLOT_GROUP=1 disables it at run time.
  • "Blend map space" Auto deliberately treats 8/16-bit images as signal-space masks and float maps as linear light. That matches what media servers and score's own writers produce, but mixed sets behave differently per map.
  • The warp bake uses RGBA32F because stock Qt has no RG32F render target. If the target cannot be created, the old path is used.
  • MultiWindowNode.cpp grows by about 1600 lines. Most of it is the window pass and its resources.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KdPgujQFUTMVZBdH6Hv7Vj

jcelerier and others added 7 commits November 25, 2026 10:45
Multi-window output, per output, in this order:
- warp: corner pin, or a dense warp map (PFM), imported from MPCDI or Bourke
  files; bicubic sampling; mipmapped and anisotropic sampling of the canvas;
- RGB alpha (blend) and beta (black level) maps, out = content * alpha +
  beta, in the space a per-output "Blend map space" gives: Auto applies
  float maps (PFM, EXR, Bourke intensities: what score writes, linear as
  Gfx/Calibration/Blending.hpp defines them) and an MPCDI alpha (which its
  gammaEmbedded linearises) in linear light, and 8 and 16-bit images in
  signal space, on the gamma-encoded values, as media servers such as
  WATCHOUT or Resolume blend their masks; Linear light and Signal force one
  space for every map. The edge ramps keep following the linear blend
  setting. The setting is saved in the output mapping (JSON only when not
  Auto), shown in the settings widget and exposed as /i/maps/blend_space;
- radiometric compensation, P = M c + o with per-pixel M from comp*.pfm.
  Negative components are desaturated and an out-of-range colour is scaled
  down whole, keeping its hue;
- the projector's own colour mixing, inverted through a 33^3 table packed in
  the response texture. A colour out of reach takes the closest reachable
  one, or is scaled towards black;
- the measured per-channel response (name.response.json or a 1D .cube) in
  place of the 2.2 curve; gain, gamma, a 3D .cube LUT, HDR transfer
  functions, a 16-bit float canvas, and blue-noise dither (a baked 64x64
  void-and-cluster table).

What an output that only uses the earlier settings gets is unchanged: the
edge ramps alone do not make the canvas 16-bit float nor turn Auto dither
on (maps, LUTs, responses, compensation and the colour stage do), and Auto
sampling stays linear under a corner warp; a warp map selects anisotropic
sampling. The canvas format and mips are decided again once a window has a
swap chain and when it is resized, and a rebuild can drop the mips.

Calibration files: a calibration set (name.json + its .alpha/.beta/.cube/
.response/.comp files) assigned per output in the settings widget, through
JSON and through /i/maps/* OSC parameters, and reloaded live when the files
change (300 ms debounce). The settings store them as <PROJECT>: / <LIBRARY>:
paths when they live under a root and list the files that cannot be found;
the device resolves them against the project roots. setMaps() reads and
checks the files on a worker thread and hands the result to the output on
the GUI thread, a later request superseding an earlier one; only the
texture upload stays on the render thread (the first load, in
createOutput, before any frame, is synchronous). An MPCDI archive decodes
only the region an output uses. A map whose size differs from its output's
is reported once per load, and so is a compensation offset that does not
match its rows. A compensation JSON saved under another name reads the
file names it lists. The PFM, Bourke mesh, MPCDI, .cube and response.json
readers bound every size read from the file, accept CRLF headers and
refuse non-finite values; the 3D LUT and the 1D response share one .cube
parser. OSC callbacks run on the GUI thread; the output mapping stream is
delimited so a truncated project fails cleanly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KdPgujQFUTMVZBdH6Hv7Vj
The device's Input width / height reached only the forced-offscreen
path: the multi-window device was created without them, so its render
state kept the 1280x720 that createRenderState was given, and every
process feeding it rendered at that size whatever the canvas. Found on
the CAVE with an 8192x4096 equirect canvas: a grid shader's parallels
vanished on the projectors, sharp offscreen.

The node now takes the canvas size at construction, and setRenderSize
keeps the size it is given before the output exists instead of dropping
it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KdPgujQFUTMVZBdH6Hv7Vj
Found profiling the CAVE: Score.benchmark() had no frame rate, and a
multi-window device's own work (the warp, blend and colour pass into
each window) was attributed nowhere, since each window is drawn in its
own swap-chain frame after the render list's.

- Frames carry the time they started; the profiler reports the frame rate
  of the fastest output over its last 64 frames (render.fps, and in the
  panel's summary). An output that has not rendered for a second no longer
  counts, and is forgotten when newer frames arrive, so a closed output or
  a rebuilt render list does not keep its last rate forever.
- The multi-window node reports an "Output stage" entry: the CPU time of
  recording the windows' passes (not the waits in beginFrame / endFrame)
  and the sum of their command buffers' GPU time. It is kept apart from
  the frame totals, which it would otherwise count twice.
- QRhiCommandBuffer::lastCompletedGpuTime() is in seconds: the render
  list's frame GPU timing recorded it as milliseconds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KdPgujQFUTMVZBdH6Hv7Vj
The window pass reconstructed the warp with a 16-tap Catmull-Rom read of
the RGBA32F warp map for every output pixel, every frame. On the CAVE
(six 3840x2160 outputs, RTX A4000, Vulkan Sponza) that was about 1 ms of
GPU per window: the six window passes cost 12.7-13.2 ms and the outputs
ran at 43-44 fps.

The interpolated lookup now goes into an RGBA32F texture at the window's
pixel size, written by a small pass that runs only when the warp map,
the bicubic/bilinear choice or the window size changes. The window pass
reads it with a single texelFetch at gl_FragCoord. Both passes share the
same sampleWarp() code, so the result is unchanged. Canvas sampling,
blending, colour and the corner warp still run per frame.

Measured on the CAVE, alternating baked and unbaked runs: window passes
6.4-7.1 ms instead of 12.7-13.2 ms, 54-59 fps instead of 43-44; 59.7 fps
with linear canvas sampling. Camera grabs of baked and unbaked output
differ no more than two baked grabs do.

Costs one RGBA32F texture per window with a warp map (about 133 MB at
4K): the target, its render pass and its pipeline are made when a warp
map is first drawn, and released, the texture back to 1x1, when the map
is removed. RGBA32F because stock Qt has no RG32F render target. If it
cannot be created the old path is used. SCORE_MW_NO_WARP_BAKE=1, read
once, forces the old path for comparisons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KdPgujQFUTMVZBdH6Hv7Vj
QRhi Vulkan keeps two frames in flight shared by every swapchain and
offscreen frame, and advances the slot after each of them. With the
scene's offscreen frame followed by six window frames per tick, the
second window's beginFrame waited for this tick's scene render to finish
on the GPU, and each later window for the window two places before it:
CPU and GPU never overlapped. On the CAVE the index-1 wait tracked the
scene's GPU cost (1.5 ms at FACE=256, 9.1 at 1024, 23.9 at 2048).

With a Qt that has the frame-slot group flags (QRHI_HAS_FRAME_SLOT_GROUPS,
from the ossia SDK patch), the scene frame keeps its slot, the windows
continue it, and the last live window advances it, so the only wait each
tick is for the frame two ticks back. Measured on the CAVE: all window
beginFrame calls drop to microseconds and the wait moves to
beginOffscreenFrame, at the same total, because the pipeline is
GPU-bound there; the change pays off once GPU time is below the frame
period. Without those flags the code is compiled out.
SCORE_MW_NO_SLOT_GROUP=1, read once, disables it at run time.

A tick that keeps the slot open and then does not end it, because the
render list has no output renderer or the last live window fails to begin
its frame, closes it with an empty offscreen frame, so the
next tick starts from a closed group.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KdPgujQFUTMVZBdH6Hv7Vj
Auto picked anisotropic sampling, and so a mipmapped canvas regenerated
every frame, for any output with a warp map. On the CAVE every output
magnifies the canvas instead: about 0.3 canvas texels per output pixel
(an 8192x4096 canvas, outputs covering 13-15 % of it in u on 3840
pixels). The mips and the anisotropic taps bought nothing there, and
cost about 2.6 ms of GPU per frame on Vulkan and 50-55 ms on D3D12,
whose generateMips on the RGBA16F 8192x4096 canvas blocks
endOffscreenFrame (D3D12 Sponza 6 outputs: 16-18 fps default, 62 fps
with Sampling=Linear).

When a warp map loads, record the 99.5th percentile of the change in
source u and v between neighbouring valid texels, per screen direction
(sampled on at most 2^18 texels, so a large map costs little to load).
The footprint is the longer of the row and column derivatives, as
texture LOD selection takes it, each scaled by the source rectangle, the
canvas size and the map-to-output ratio along its own axis; Auto chooses
anisotropic only above 1.5 canvas texels per output pixel, and linear
otherwise. Below that a bilinear tap already covers the footprint well
enough that mipmapping changes nothing visible. Pairing the largest u
change along a row with the largest v change along a column with hypot
flagged the CAVE's left wall (1.19e-4 and 1.44e-4 per texel, 0.98 and
0.59 canvas texels, hypot 1.14) as minifying.

The output size is the window's swap chain once it exists, the map's
before; the canvas is decided again when the swap chain appears and on
resize. A corner warp alone stays linear, and the explicit modes are
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KdPgujQFUTMVZBdH6Hv7Vj
The multi-window and capture tests compare readbacks against the window
sizes they set, in pixels. On a desktop scaled by 2 (KWin at scale 2,
under XWayland too), Qt made every output window twice that size and
those tests failed for no fault of the code. The test fixture now turns
Qt's high-DPI scaling off unless the environment chooses otherwise, as
it already was under Xvfb.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KdPgujQFUTMVZBdH6Hv7Vj

This branch is waiting to be deployed

1 waiting deployment
full-ci — 660c6e98 Waiting Nov 25, 2026 by jcelerier via Approve full PR suite #16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant