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,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <plot/core/types.hpp>
|
||||
#include <plot/math/vec2.hpp>
|
||||
|
||||
namespace plot::qt {
|
||||
|
||||
/// The cached pointer position a move event's movement is measured from, in
|
||||
/// **logical** widget pixels.
|
||||
///
|
||||
/// Logical, not device, pixels on purpose. Qt reports every widget position in
|
||||
/// logical pixels, and the device-pixel ratio can change between two move events
|
||||
/// -- the window being dragged onto a monitor with another scale factor is the
|
||||
/// case -- so an anchor cached in device pixels would compare a position computed
|
||||
/// at the old ratio with one computed at the new one. At 1.0 -> 1.25 a logical
|
||||
/// position of 500 would then look like a jump of 125 device pixels, and
|
||||
/// `Controller::pan` applies a delta as a fraction of the range span (and clears
|
||||
/// auto scale), so a scale change mid-drag would pan the plot by 125 pixels' worth
|
||||
/// of data. Keeping the anchor logical and scaling the *difference* by the ratio
|
||||
/// in effect now makes the same gesture map to the same device distance whatever
|
||||
/// the window's scale is.
|
||||
///
|
||||
/// A plain value with no toolkit dependency: the widget owns one, and this is the
|
||||
/// part of the adapter's translation a test can drive directly (see
|
||||
/// tests/test_qt_pointer.cpp).
|
||||
struct PointerAnchor {
|
||||
bool have = false; ///< false until the first sample, which has no movement
|
||||
f32 x = 0.0f; ///< last logical position, widget pixels
|
||||
f32 y = 0.0f;
|
||||
|
||||
/// Movement from the cached position to `logical`, in device pixels at `dpr`.
|
||||
/// Zero before the first sample, so the first motion of a drag never includes
|
||||
/// the jump to where the drag began.
|
||||
Vec2 device_delta(Vec2 logical, f64 dpr) const noexcept {
|
||||
if (!have) return Vec2{0.0f, 0.0f};
|
||||
return Vec2{static_cast<f32>((static_cast<f64>(logical.x) - static_cast<f64>(x)) * dpr),
|
||||
static_cast<f32>((static_cast<f64>(logical.y) - static_cast<f64>(y)) * dpr)};
|
||||
}
|
||||
|
||||
/// Caches `logical` as the position the next movement is measured from. Always
|
||||
/// logical pixels, whatever the ratio is: see the type's comment.
|
||||
void set(Vec2 logical) noexcept {
|
||||
x = logical.x;
|
||||
y = logical.y;
|
||||
have = true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace plot::qt
|
||||
Reference in new issue
Block a user