fix(render): one fence per frame for the vertex ring; two qt6 adapter fixes
The persistent-mapped instance ring had three slots and recorded a fence per upload, so a frame recycled a slot whose fence was recorded a few draws earlier *in that same frame*: from the fourth of the demos' nine uploads on, each one waited on the frame's own work. It is free on a driver that retires draws promptly (the GLFW host, 1.07 ms/frame) and ~4 ms of the Qt widget's 7.11 ms under llvmpipe, and it grows with the trace and cursor counts this library exists for. * The ring grows to cover a frame's upload count, the frame's write cursor is the ring index (so a frame writes 0, 1, 2, ... and never a slot twice), one fence is recorded after the frame's last draw, and the only wait is at the start of the next frame. A wait that times out, or a slot written with no fence ever recorded behind it, drops the store to the orphan path -- the treatment a refused fence already had -- so nothing is ever written into storage the GPU may still be reading. * New test-only counters (PLOT_RING_STATS, the PLOT_PYRAMID_COUNT_* pattern: free functions, no member, so no consumer's layout changes) pin a frame's upload and wait counts. The new tests assert the frame's slot offsets are distinct, that the ring grew past its floor to cover the frame, and that a frame waits at most once per store -- read from the counters and from glClientWaitSync itself. * qt6: print the unresolved entry-point names before the load-failure branch, which used to return first and leave the one failure this widget can have reporting nothing but a generic message. * qt6: the cached pointer anchor is now in logical pixels and a move's delta is the logical difference scaled by the DPR in effect, so a scale change between two move events (the window dragged onto another monitor mid-drag) is no longer a cross-scale jump applied as a pan. The anchor moved into a toolkit-free unit (adapters/qt6/qt_pointer.hpp) with its own test. GLFW demo headless: 1.07 -> 0.73 ms/frame. Qt widget under xvfb/llvmpipe: 7.1 -> 3.8 ms at dpr 1.0, 6.7 -> 3.6 ms at 1.25, with both upload paths still rendering and the demo's scripted pan/box-zoom checks passing at both scales.
This commit is contained in:
1 parent
1ee2dd9c3d
commit
3c0e7763ab
13 files changed
+626
-113
No files matched your search
@@ -0,0 +1,56 @@
|
||||
// The Qt adapter's pointer translation, driven directly. The widget's cached
|
||||
// pointer anchor is a plain value with no toolkit dependency (see
|
||||
// adapters/qt6/qt_pointer.hpp) precisely so the one thing a screenshot cannot show
|
||||
// -- which pixel space a drag delta is in -- is testable without a QApplication, a
|
||||
// window or a display.
|
||||
#include "harness.hpp"
|
||||
|
||||
#include <qt6/qt_pointer.hpp>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
// The defect this pins: the anchor used to be cached in *device* pixels while the
|
||||
// next event's delta was a raw difference of device positions, so a DPR change
|
||||
// between two move events -- the window dragged onto a monitor with a different
|
||||
// scale factor mid-drag -- mixed two pixel spaces. At 1.0 -> 1.25 a logical
|
||||
// position of 500 produced a spurious 125 device-pixel delta, which
|
||||
// `Controller::pan` applies as a fraction of the range span and which also clears
|
||||
// auto scale: a scale change mid-drag would move the plot by 125 pixels' worth of
|
||||
// data and silently disarm a live axis.
|
||||
PLOT_TEST(pointer_anchor_survives_a_dpr_change_between_move_events) {
|
||||
plot::qt::PointerAnchor anchor;
|
||||
|
||||
// The press caches a logical position while the window is on the 1.0 display.
|
||||
anchor.set({500.0f, 300.0f});
|
||||
|
||||
// The next move arrives after the window moved to the 1.25 display, at the same
|
||||
// logical position: the pointer has not moved, so the delta must be zero -- not
|
||||
// 500 * 1.25 - 500 * 1.0 = 125 device pixels, which is what comparing two device
|
||||
// positions across the scale change reported.
|
||||
const plot::Vec2 still = anchor.device_delta({500.0f, 300.0f}, 1.25);
|
||||
PLOT_CHECK_NEAR(still.x, 0.0, 1e-6);
|
||||
PLOT_CHECK_NEAR(still.y, 0.0, 1e-6);
|
||||
|
||||
// A real movement is the logical delta scaled by the ratio in effect now, in both
|
||||
// directions.
|
||||
const plot::Vec2 moved = anchor.device_delta({503.0f, 295.0f}, 1.25);
|
||||
PLOT_CHECK_NEAR(moved.x, 3.0 * 1.25, 1e-6);
|
||||
PLOT_CHECK_NEAR(moved.y, -5.0 * 1.25, 1e-6);
|
||||
|
||||
// And the anchor follows the sample it just reported: the following move is
|
||||
// measured from there, at whatever ratio that event carries.
|
||||
anchor.set({503.0f, 295.0f});
|
||||
const plot::Vec2 unchanged = anchor.device_delta({503.0f, 295.0f}, 1.0);
|
||||
PLOT_CHECK_NEAR(unchanged.x, 0.0, 1e-6);
|
||||
PLOT_CHECK_NEAR(unchanged.y, 0.0, 1e-6);
|
||||
}
|
||||
|
||||
// The first sample of a gesture has no anchor to measure from, so its delta is
|
||||
// zero however far the position is from the origin: the first motion of a drag
|
||||
// must never include the jump to where the drag began.
|
||||
PLOT_TEST(pointer_anchor_reports_no_movement_before_its_first_sample) {
|
||||
plot::qt::PointerAnchor anchor;
|
||||
const plot::Vec2 delta = anchor.device_delta({500.0f, 300.0f}, 1.25);
|
||||
PLOT_CHECK_NEAR(delta.x, 0.0, 1e-9);
|
||||
PLOT_CHECK_NEAR(delta.y, 0.0, 1e-9);
|
||||
}
|
||||
Reference in new issue
Block a user