KiCad PCB EDA Suite
Loading...
Searching...
No Matches
render_thread_window_state.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef RHI_RENDER_THREAD_WINDOW_STATE_H
21#define RHI_RENDER_THREAD_WINDOW_STATE_H
22
24#include <rhi/rhi_handle.h>
25#include <rhi/rhi_surface.h>
26#include <rhi/frame_mailbox.h>
27#include <rhi/frame_packet.h>
30
31#include <chrono>
32#include <cstdint>
33#include <optional>
34
35
36namespace KIGFX
37{
38
44{
47
50
51 uint32_t width = 0;
52 uint32_t height = 0;
53 float dpiScale = 1.0f;
54
55 uint32_t backingWidth = 0;
56 uint32_t backingHeight = 0;
57
62 uint32_t supersampleFactor = 1;
63
64 uint32_t RenderWidth() const { return backingWidth * supersampleFactor; }
65 uint32_t RenderHeight() const { return backingHeight * supersampleFactor; }
66
69
74 uint32_t staticMargin = 0;
75
78
84 bool staticInMargin = true;
85
90
92 int32_t ShownStaticX() const
93 {
94 return staticInMargin ? ( static_cast<int32_t>( staticMargin ) - staticShift.x )
95 * static_cast<int32_t>( supersampleFactor )
96 : 0;
97 }
98
99 int32_t ShownStaticY() const
100 {
101 return staticInMargin ? ( static_cast<int32_t>( staticMargin ) - staticShift.y )
102 * static_cast<int32_t>( supersampleFactor )
103 : 0;
104 }
105
108
111
112 uint32_t StaticWidth() const { return RenderWidth() + 2 * staticMargin * supersampleFactor; }
113 uint32_t StaticHeight() const { return RenderHeight() + 2 * staticMargin * supersampleFactor; }
115
122
129
135 bool overlayInMargin = false;
136
139
142
154
164
169 static constexpr size_t UNIFORM_GENERATIONS = 3;
170
173
175
177
184 bool staticChanged = true;
185 bool dynamicChanged = true;
186
187 uint64_t staticEpoch = 0;
188 uint64_t dynamicEpoch = 0;
189
195 {
196 bool valid = false;
197 uint64_t epoch = 0;
198 bool drawGrid = false;
201 uint32_t margin = 0;
202 };
203
207
208 uint64_t staticPasses = 0;
209 uint64_t geometryRenderPasses = 0;
210 uint64_t dynamicPasses = 0;
211
214
216 bool active = false;
217 bool frameResultPending = false;
218
219 uint64_t framesProcessed = 0;
220
221 using Clock = std::chrono::steady_clock;
222 Clock::time_point lastActivityTime;
223 Clock::time_point lastFrameRequestTime;
224 Clock::time_point lastRenderStartTime;
225 Clock::time_point lastRenderCompleteTime;
226 Clock::time_point lastPresentAttemptTime;
227 Clock::time_point lastPresentSuccessTime;
228 Clock::time_point lastPresentFailureTime;
229 Clock::time_point nextPresentRetryAt;
231 Clock::time_point lastLagLogTime;
232
237 float refreshHz = 0.0f;
238 Clock::time_point nextFrameAt;
239 uint64_t drawnInputSerial = 0;
240
246
249};
250
251
252} // namespace KIGFX
253
254
255#endif // RHI_RENDER_THREAD_WINDOW_STATE_H
Lock-free single-slot mailbox carrying frame state from the main thread to the render thread.
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30
uint32_t RHI_WINDOW_ID
Routes control commands to a swapchain.
RHI_HANDLE< RHI_TAG_FRAMEBUFFER > RHI_FramebufferHandle
Definition rhi_handle.h:93
RHI_HANDLE< RHI_TAG_BUFFER > RHI_BufferHandle
Definition rhi_handle.h:83
RHI_HANDLE< RHI_TAG_BIND_GROUP > RHI_BindGroupHandle
Definition rhi_handle.h:90
RHI_HANDLE< RHI_TAG_SURFACE > RHI_SurfaceHandle
Definition rhi_handle.h:91
RHI_HANDLE< RHI_TAG_SWAPCHAIN > RHI_SwapchainHandle
Definition rhi_handle.h:92
GPU geometry of one frame, built by GAL_MODERN after EndDrawing() and passed through the FRAME_MAILBO...
Per-frame uniform block matching FrameUBO in frame_ubo.glsl (std140).
Grid uniform block matching the GridUBO layout in grid.frag (std140).
How far the view has moved since the static target was drawn, in whole frame pixels.
One window's uniforms for one frame.
Uniform buffers owned by one geometry target.
What a geometry target holds, so a frame asking for the same content at the same camera can reuse it.
uint32_t margin
how much of the static target's margin was drawn
Per-window state owned by the render thread.
RHI_VIEW_SHIFT staticShift
How far the view has moved since the static target was drawn.
RHI_FramebufferHandle diffBelowFBO
Copies of what lies under a difference layer, for the view sized targets and the static one.
RHI_FramebufferHandle staticDiffBelowFBO
RHI_FramebufferHandle dynamicFBO
Clock::time_point lastRenderStartTime
RHI_FramebufferHandle overlayGeometryFBO
Overlay content, drawn from a transparent start and composited over the dynamic target (see RHI_GAL_P...
FRAME_UNIFORMS uniformSets[UNIFORM_GENERATIONS]
Clock::time_point lastFrameRequestTime
static constexpr size_t UNIFORM_GENERATIONS
A frame's passes are still queued when the next frame is built, so frames rotate through several unif...
Clock::time_point lastSwapchainCreateAttemptTime
uint32_t supersampleFactor
Supersampling factor.
RHI_FramebufferHandle ShownStaticFBO() const
float refreshHz
A swapchain that presents immediately is drawn at most once per refresh unless the frame answers inpu...
bool staticInMargin
the content shown is in staticFBO
RHI_FramebufferHandle staticTempFBO
The static target's temp target, made when a static layer first needs one.
Clock::time_point lastPresentAttemptTime
RHI_NATIVE_WINDOW_HANDLE nativeHandle
Clock::time_point nextFrameAt
earliest time such a window may be drawn again
int32_t ShownStaticX() const
Where the view starts in the shown static target, in texels.
Clock::time_point lastPresentFailureTime
RHI_FramebufferHandle accumulationFBO
Color only, without depth or stencil.
FRAME_DRAW_DESC staticDrawDesc
Static and dynamic pool descriptions, each drawn into its own target.
RHI_FramebufferHandle staticViewFBO
Static content drawn without the margin, as during a zoom, goes into this view sized target so the zo...
RHI_FramebufferHandle overlayMarginFBO
Overlay content that stayed the same through a pan, drawn with the static target's margin.
RHI_VIEW_SHIFT overlayShift
How far the view has moved since overlayMarginFBO was drawn.
uint64_t geometryRenderPasses
render passes begun while drawing geometry
uint32_t staticMargin
Frame pixels the static target holds beyond each view edge so a pan within them is only a shift.
uint64_t drawnInputSerial
FRAME_PACKET::inputSerial of the last packet loaded.
uint64_t dynamicPasses
times dynamicFBO was re-rendered
std::chrono::steady_clock Clock
Clock::time_point lastPresentSuccessTime
FRAME_MAILBOX * mailbox
Owned by the panel.
bool dynamicGeometryDrawn
An empty dynamicFBO is neither drawn nor composited.
RHI_FramebufferHandle staticFBO
RHI_FramebufferHandle tempFBO
uint64_t staticPasses
times staticFBO was re-rendered
RENDERED_CONTENT renderedOverlay
the overlay target keeps the static target's margin
Clock::time_point lastRenderCompleteTime
Platform-agnostic wrapper for a native window handle.
Definition rhi_surface.h:45