TachyonUI 1.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
gui_primitive_renderer.h
Go to the documentation of this file.
1#pragma once
2
3// API-neutral GUI primitive renderer: per-window targets accumulate per-kind
4// primitive streams, then Render() uploads each stream and replays the pass
5// list through the RHI. No graphics-API types appear here - a backend
6// supplies a RenderCommandList with a fence-protected transient upload arena
7// and the pipeline set built from kPrimitiveSpecs.
8
9#include <gui_core/gui_id.h>
13
14#include <algorithm>
15#include <array>
16#include <cassert>
17#include <cmath>
18#include <cstddef>
19#include <cstdint>
20#include <cstring>
21#include <span>
22#include <type_traits>
23#include <unordered_map>
24#include <vector>
25
26namespace tachyon
27{
30
31 using PipelineSet = std::array<RHI::GpuPipeline, kPrimitiveKindCount>;
32
36 {
40 int replay = -1;
41
42 bool operator==(const PrimitiveRenderPass&) const = default;
43 };
44
46 {
47 public:
50 struct Stream
51 {
52 std::vector<std::byte> cpu;
53 int passStart = 0;
54 };
55 std::array<Stream, kPrimitiveKindCount> streams;
56
57 std::vector<PrimitiveRenderPass> renderPasses;
58 int currentKind = -1;
60 float currentOpacity = 1.0f;
61
65 {
68 uint32_t baseOrder = 0;
69 bool operator==(const ScopeReplay&) const = default;
70 };
71 std::vector<ScopeReplay> replays;
74 bool recaptured = false;
75
76 public:
79
86 void AddReplay(tachyon::ID scope, tachyon::int2 delta, const PrimitiveRenderTarget& captured);
87
88 public:
91 size_t Render(RHI::RenderCommandList& cmdList, const PipelineSet& pipelines,
92 GPUDrawPushConstants& push_constants);
93 void Reset();
94
96 void SetOpacity(float opacity) { currentOpacity = opacity; }
98 void RenderBox(tachyon::IntRect rect, tachyon::IntRect clipRect, uint32_t fromStyleIndex, uint32_t toStyleIndex, float blendT, tachyon::VisualColorStyleIndex colorStyleIndex = {}, tachyon::ImageIndex textureIndex = tachyon::ImageIndex::Invalid, tachyon::IntRect snappedPx = {})
99 {
100 RenderBox(rect, clipRect, tachyon::StyleBlend::Between(fromStyleIndex, toStyleIndex, blendT), colorStyleIndex, textureIndex, snappedPx);
101 }
102 void RenderGlyph(tachyon::float2 pos, tachyon::float2 size, tachyon::float2 uvMin, tachyon::float2 uvMax, float scale, int bpp, int mode, tachyon::VisualColorStyleIndex textColorIndex, tachyon::IntRect clipRect, tachyon::ImageIndex textureIndex = tachyon::ImageIndex::Invalid, float shadowBlur = -1.0f);
105 void RenderGlyphs(std::span<const GUIRenderer::GlyphInstance> glyphs, tachyon::float2 offset, tachyon::IntRect clipRect);
107 void RenderCircle(tachyon::float2 center, float radius, tachyon::IntRect clipRect, const tachyon::LineStyle& lineStyle);
108 void RenderDot(tachyon::float2 pos, tachyon::IntRect clipRect, float size, tachyon::color4f color);
110 void RenderDots(std::span<const tachyon::float2> positions, tachyon::IntRect clipRect, float size, tachyon::color4f color);
112 void RenderQuad(tachyon::IntRect rect, tachyon::IntRect clipRect, tachyon::VisualColorStyleIndex colorStyleIndex, float cornerRadius = 0.0f, tachyon::ImageIndex textureIndex = tachyon::ImageIndex::Invalid, const tachyon::UVRect& uv = {}, const tachyon::ImageDisplay& display = {});
113 void RenderShadow(tachyon::IntRect rect, tachyon::IntRect clipRect, tachyon::VisualColorStyleIndex colorStyleIndex, float cornerRadius, int blur);
115
117 uint32_t nextOrder = 0;
118
119 private:
121 struct ScreenBox
122 {
123 int32_t x0 = 0, y0 = 0, x1 = 0, y1 = 0;
124
125 bool Empty() const { return x1 <= x0 || y1 <= y0; }
126 bool Overlaps(const ScreenBox& o) const
127 {
128 return !Empty() && !o.Empty() && x0 < o.x1 && o.x0 < x1 && y0 < o.y1 && o.y0 < y1;
129 }
131 ScreenBox Cover(const ScreenBox& o) const
132 {
133 if (Empty()) return o;
134 if (o.Empty()) return *this;
135 return { std::min(x0, o.x0), std::min(y0, o.y0), std::max(x1, o.x1), std::max(y1, o.y1) };
136 }
137 ScreenBox Within(tachyon::IntRect clip) const
138 {
139 return { std::max(x0, clip.x), std::max(y0, clip.y), std::min(x1, clip.x + clip.w), std::min(y1, clip.y + clip.h) };
140 }
142 ScreenBox Moved(tachyon::int2 delta, int32_t limit) const
143 {
144 auto move = [limit](int32_t v, int32_t d)
145 {
146 return v <= -limit || v >= limit ? v : int32_t(std::clamp<int64_t>(int64_t(v) + d, -limit, limit));
147 };
148 return { move(x0, delta.x), move(y0, delta.y), move(x1, delta.x), move(y1, delta.y) };
149 }
150 };
152 ScreenBox Covered() const;
153
156 std::vector<ScreenBox> passBounds;
157 ScreenBox openBounds {};
159 std::array<int, kPrimitiveKindCount> lastPass = MakeNoPasses();
160 static constexpr std::array<int, kPrimitiveKindCount> MakeNoPasses()
161 {
162 std::array<int, kPrimitiveKindCount> none {};
163 none.fill(-1);
164 return none;
165 }
166
171 void PlaceInPass(PrimitiveKind kind, ScreenBox bounds, int count = 1);
174 ScreenBox Bounds(tachyon::float2 min, tachyon::float2 max, float margin, tachyon::IntRect clipRect) const
175 {
176 const tachyon::float3x2& t = currentTransform;
177 float x0, x1, y0, y1;
178 if (t.r0.y == 0.0f && t.r1.x == 0.0f)
179 {
180 // No rotation or shear (nearly always): each axis on its own.
181 const float ax = t.r0.x * min.x + t.r0.z, bx = t.r0.x * max.x + t.r0.z;
182 const float ay = t.r1.y * min.y + t.r1.z, by = t.r1.y * max.y + t.r1.z;
183 x0 = std::min(ax, bx); x1 = std::max(ax, bx);
184 y0 = std::min(ay, by); y1 = std::max(ay, by);
185 }
186 else
187 {
188 const float cx[4] = { min.x, max.x, min.x, max.x }, cy[4] = { min.y, min.y, max.y, max.y };
189 x0 = y0 = INFINITY;
190 x1 = y1 = -INFINITY;
191 for (int i = 0; i < 4; ++i)
192 {
193 const float x = t.r0.x * cx[i] + t.r0.y * cy[i] + t.r0.z, y = t.r1.x * cx[i] + t.r1.y * cy[i] + t.r1.z;
194 x0 = std::min(x0, x); x1 = std::max(x1, x);
195 y0 = std::min(y0, y); y1 = std::max(y1, y);
196 }
197 }
198 // Far past the screen counts as the screen's edge, so the ints don't overflow; a
199 // NaN lands on the edge too, by the clamp's comparisons.
200 static constexpr float kFar = float(1 << 28);
201 auto px = [](float v) { return int32_t(std::clamp(v, -kFar, kFar)); };
202 const ScreenBox box{ px(std::floor(x0 - margin)), px(std::floor(y0 - margin)),
203 px(std::ceil(x1 + margin)), px(std::ceil(y1 + margin)) };
204 return box.Within(clipRect);
205 }
206
209 template <typename T>
210 void Append(PrimitiveKind kind, const T& primitive, ScreenBox bounds)
211 {
212 static_assert(std::is_trivially_copyable_v<T>);
213 assert(sizeof(T) == kPrimitiveSpecs[size_t(kind)].stride);
214 PlaceInPass(kind, bounds);
215 auto& cpu = streams[size_t(kind)].cpu;
216 T ordered = primitive;
217 ordered.transform0.w = float(nextOrder++);
218 ordered.transform1.w = 1.0f - currentOpacity; // transparency: 0 is opaque
219 const size_t at = cpu.size();
220 cpu.resize(at + sizeof(T));
221 std::memcpy(cpu.data() + at, &ordered, sizeof(T));
222 }
223 };
224
226 {
227 public:
228 std::unordered_map<tachyon::ID, PrimitiveRenderTarget> idTargets;
231
232 public:
233 void Reset() override;
234 void SetTransform(tachyon::float3x2 transform) override;
235 void SetOpacity(float opacity) override;
237 void RenderBox(tachyon::IntRect rect, tachyon::IntRect clipRect, const tachyon::StyleBlend& styles, tachyon::VisualColorStyleIndex colorStyleIndex = {}, tachyon::ImageIndex textureIndex = tachyon::ImageIndex::Invalid, tachyon::IntRect snappedPx = {}) override;
238 void RenderGlyph(tachyon::float2 pos, tachyon::float2 size, tachyon::float2 uvMin, tachyon::float2 uvMax, float scale, int bpp, int mode, tachyon::VisualColorStyleIndex textColorIndex, tachyon::IntRect clipRect, tachyon::ImageIndex textureIndex = tachyon::ImageIndex::Invalid, float shadowBlur = -1.0f) override;
239 void RenderGlyphs(std::span<const GlyphInstance> glyphs, tachyon::float2 offset, tachyon::IntRect clipRect) override;
241 void RenderCircle(tachyon::float2 center, float radius, tachyon::IntRect clipRect, const tachyon::LineStyle& lineStyle) override;
242 void RenderDot(tachyon::float2 pos, tachyon::IntRect clipRect, float size, tachyon::color4f color) override;
243 void RenderDots(std::span<const tachyon::float2> positions, tachyon::IntRect clipRect, float size, tachyon::color4f color) override;
245 void RenderQuad(tachyon::IntRect rect, tachyon::IntRect clipRect, tachyon::VisualColorStyleIndex colorStyleIndex, float cornerRadius = 0.0f, tachyon::ImageIndex textureIndex = tachyon::ImageIndex::Invalid, const tachyon::UVRect& uv = {}, const tachyon::ImageDisplay& display = {}) override;
246 void RenderShadow(tachyon::IntRect rect, tachyon::IntRect clipRect, tachyon::VisualColorStyleIndex colorStyleIndex, float cornerRadius, int blur) override;
247 void RenderOccluder(tachyon::IntRect rect, tachyon::IntRect clipRect) override;
248
249 public:
251 {
252 auto target = idTargets.find(id);
253 if (target == idTargets.end())
254 {
256 return idTargets[id];
257 }
258 return target->second;
259 }
260
265
266 bool StartResizing(tachyon::ID id) override
267 {
268 assert(resizingTarget == nullptr);
269 auto target = idTargets.find(id);
270 if (target == idTargets.end())
271 {
272 resizingTarget = nullptr;
273 } else
274 resizingTarget = &target->second;
275 return resizingTarget != nullptr;
276 }
277
278 // The target may be gone already: the frame a live resize runs can close its window,
279 // and ReleaseTarget lets go of it then.
280 void StopResizing() override
281 {
282 resizingTarget = nullptr;
283 }
284
285 bool BeginWindow(tachyon::ID id) override;
286 void EndWindow() override;
287 bool DrawsChanged(tachyon::ID window) const override;
288
289 // Draw caching. A capture's primitives go to the GPU once and are drawn from there,
290 // moved by the world matrix, each time it is replayed; until their copy is on the GPU
291 // they are uploaded with the frame.
292 void BeginScopeCapture(tachyon::ID scopeId) override;
293 void EndScopeCapture(tachyon::ID scopeId) override;
294 bool ReplayScopeCapture(tachyon::ID scopeId, tachyon::int2 delta) override;
295 bool HasScopeCapture(tachyon::ID scopeId) const override;
296 void InvalidateScopeCapture(tachyon::ID scopeId) override;
297 void ClearScopeCaptures() override;
298
299 void Render(tachyon::ID id, RHI::RenderCommandList& cmdList, const PipelineSet& pipelines,
300 GPUDrawPushConstants& push_constants);
301
304 size_t LastFrameUploadBytes() const { return m_lastUploadBytes; }
306 size_t ResidentScopeCount() const;
307
310 static constexpr uint64_t kEvictAfterFrames = 240;
311
312 private:
314 struct ScopeCapture
315 {
317 PrimitiveRenderTarget previous;
318 RHI::ResidentBufferId resident = 0;
319 std::array<DeviceAddress, kPrimitiveKindCount> addresses{};
320 uint64_t lastUsedFrame = 0;
321 };
322
325 std::array<DeviceAddress, kPrimitiveKindCount> CaptureAddresses(ScopeCapture& capture, RHI::RenderCommandList& cmdList);
327 void ReleaseResident(ScopeCapture& capture);
328
330 std::unordered_map<tachyon::ID, ScopeCapture> scopeCaptures;
332 std::vector<RHI::ResidentBufferId> m_releasedResidents;
335 struct ResolvedReplay
336 {
337 const PrimitiveRenderTarget* passes = nullptr;
338 std::array<DeviceAddress, kPrimitiveKindCount> addresses{};
339 GPUDrawPushConstants push{};
340 };
341 std::vector<ResolvedReplay> m_resolvedReplays;
343 PrimitiveRenderTarget* m_captureSaved = nullptr;
344 uint64_t m_frame = 0;
345 size_t m_lastUploadBytes = 0;
346
348 struct DrawSnapshot
349 {
350 PrimitiveRenderTarget draws;
351 bool seen = false;
352 bool changed = true;
353 };
354 std::unordered_map<tachyon::ID, DrawSnapshot> m_lastDraws;
355 tachyon::ID m_currentWindow = tachyon::ID::Invalid();
357 void NoteDraws(tachyon::ID window, const PrimitiveRenderTarget& target);
358 };
359
360}
Definition gui_renderer.h:78
virtual void RenderBox(tachyon::IntRect rect, tachyon::IntRect clipRect, const StyleBlend &styles, tachyon::VisualColorStyleIndex colorStyleIndex={}, tachyon::ImageIndex textureIndex=tachyon::ImageIndex::Invalid, tachyon::IntRect snappedPx={})=0
Draws a styled box, styles mixed.
Definition gui_primitive_renderer.h:226
void RenderCircle(tachyon::float2 center, float radius, tachyon::IntRect clipRect, const tachyon::LineStyle &lineStyle) override
A circle outline lineStyle.lineWidth wide, exactly round.
size_t LastFrameUploadBytes() const
Primitive bytes the last Render uploaded with the frame; cached scopes drawn from their GPU copy add ...
Definition gui_primitive_renderer.h:304
void RenderOccluder(tachyon::IntRect rect, tachyon::IntRect clipRect) override
Draws nothing: marks rect as covered by opaque content drawn after this call, so what was drawn befor...
void EndWindow() override
bool ReplayScopeCapture(tachyon::ID scopeId, tachyon::int2 delta) override
Draws the capture of scopeId again, moved by delta pixels; false if there is none.
PrimitiveRenderTarget & GetTarget(tachyon::ID id)
Definition gui_primitive_renderer.h:250
void InvalidateScopeCapture(tachyon::ID scopeId) override
Drops the capture of scopeId.
void ClearScopeCaptures() override
Drops every capture.
std::unordered_map< tachyon::ID, PrimitiveRenderTarget > idTargets
Definition gui_primitive_renderer.h:228
void RenderBox(tachyon::IntRect rect, tachyon::IntRect clipRect, const tachyon::StyleBlend &styles, tachyon::VisualColorStyleIndex colorStyleIndex={}, tachyon::ImageIndex textureIndex=tachyon::ImageIndex::Invalid, tachyon::IntRect snappedPx={}) override
Draws a styled box, styles mixed.
bool HasScopeCapture(tachyon::ID scopeId) const override
True when scopeId has a non-empty capture.
void RenderLine(tachyon::int2 p0, tachyon::int2 p1, tachyon::int2 p2, tachyon::int2 p3, tachyon::IntRect clipRect, const tachyon::LineStyle &lineStyle) override
void RenderGlyphs(std::span< const GlyphInstance > glyphs, tachyon::float2 offset, tachyon::IntRect clipRect) override
RenderGlyph for each of glyphs, moved by offset, in order: a text's glyphs at once.
bool DrawsChanged(tachyon::ID window) const override
Whether the window's draws this frame differ from its last frame's (as of its EndWindow); true when t...
void RenderGlyph(tachyon::float2 pos, tachyon::float2 size, tachyon::float2 uvMin, tachyon::float2 uvMax, float scale, int bpp, int mode, tachyon::VisualColorStyleIndex textColorIndex, tachyon::IntRect clipRect, tachyon::ImageIndex textureIndex=tachyon::ImageIndex::Invalid, float shadowBlur=-1.0f) override
A glyph from the text atlas.
PrimitiveRenderTarget * currentTarget
Definition gui_primitive_renderer.h:229
bool StartResizing(tachyon::ID id) override
Definition gui_primitive_renderer.h:266
void RenderTriangle(tachyon::float2 p0, tachyon::float2 p1, tachyon::float2 p2, tachyon::IntRect clipRect, tachyon::VisualColorStyleIndex colorStyleIndex, tachyon::ImageIndex textureIndex=tachyon::ImageIndex::Invalid, TriangleEdges hardEdges=TriangleEdges::None) override
A filled triangle.
void RenderShadow(tachyon::IntRect rect, tachyon::IntRect clipRect, tachyon::VisualColorStyleIndex colorStyleIndex, float cornerRadius, int blur) override
A box shadow: rect is the shadow's shape, which fades out over blur pixels on either side of its edge...
void RenderQuad(tachyon::IntRect rect, tachyon::IntRect clipRect, tachyon::VisualColorStyleIndex colorStyleIndex, float cornerRadius=0.0f, tachyon::ImageIndex textureIndex=tachyon::ImageIndex::Invalid, const tachyon::UVRect &uv={}, const tachyon::ImageDisplay &display={}) override
Draws a filled, optionally rounded and textured rect: a box without borders, style blending or elemen...
void RenderDots(std::span< const tachyon::float2 > positions, tachyon::IntRect clipRect, float size, tachyon::color4f color) override
RenderDot at each of positions, in order, all alike.
size_t ResidentScopeCount() const
Captured scopes with a GPU copy (made or on its way).
void ReleaseTarget(tachyon::ID id)
Drops the CPU-side target of window id, when the window is destroyed.
PrimitiveRenderTarget * resizingTarget
Definition gui_primitive_renderer.h:230
static constexpr uint64_t kEvictAfterFrames
A capture neither recorded nor replayed for this many frames is dropped, its GPU copy freed (as UICac...
Definition gui_primitive_renderer.h:310
void RenderDot(tachyon::float2 pos, tachyon::IntRect clipRect, float size, tachyon::color4f color) override
void Render(tachyon::ID id, RHI::RenderCommandList &cmdList, const PipelineSet &pipelines, GPUDrawPushConstants &push_constants)
bool BeginWindow(tachyon::ID id) override
void StopResizing() override
Definition gui_primitive_renderer.h:280
void SetOpacity(float opacity) override
How opaque what is drawn from now on is, 0 to 1 (1 until set).
void SetTransform(tachyon::float3x2 transform) override
void BeginScopeCapture(tachyon::ID scopeId) override
Starts recording primitives under scopeId, replacing its previous capture.
void EndScopeCapture(tachyon::ID scopeId) override
Ends the capture of scopeId and draws it into the current window.
One frame's recording surface for one window.
Definition gui_rhi.h:62
uint64_t ResidentBufferId
GPU storage kept across frames (UploadResidentBuffers); 0 is none.
Definition gui_rhi.h:36
TriangleEdges
A triangle's edges, for the ones drawn without a soft edge: where it meets another triangle of the sa...
Definition gui_renderer.h:24
ImageIndex
Index of an image in the graphics context's image set, as the shaders sample it.
Definition gui_image.h:99
std::array< RHI::GpuPipeline, kPrimitiveKindCount > PipelineSet
Definition gui_primitive_renderer.h:31
PrimitiveKind
Definition gui_render_primitives.h:209
constexpr PrimitiveSpec kPrimitiveSpecs[kPrimitiveKindCount]
Push-constant slot order matches the shaders' (all_common.slang: box, glyph, dot, line,...
Definition gui_render_primitives.h:245
@ None
Definition gui_renderer.h:25
@ Invalid
Definition gui_image.h:99
VisualColorStyleIndex
Index into StyleManager's color style pool; Invalid (0) draws nothing (transparent).
Definition gui_style.h:33
Definition gui_logging.h:24
Definition gui_render_primitives.h:257
A 64-bit element ID whose bit layout depends on its IDMode.
Definition gui_id.h:23
static constexpr ID Invalid()
The "no element" ID (all bits zero); also the default for optional ID parameters.
Definition gui_id.h:66
How an image is shown, in this order:
Definition gui_image.h:42
Definition gui_base_types.h:406
Definition gui_renderer.h:33
One contiguous same-kind run of primitives, drawn with one call; or, with replay set,...
Definition gui_primitive_renderer.h:36
int replay
index into PrimitiveRenderTarget::replays
Definition gui_primitive_renderer.h:40
PrimitiveKind kind
Definition gui_primitive_renderer.h:39
int firstPrimitive
Definition gui_primitive_renderer.h:37
bool operator==(const PrimitiveRenderPass &) const =default
int primitiveCount
Definition gui_primitive_renderer.h:38
A cached scope drawn here, moved delta window pixels from where it was captured; its primitives' draw...
Definition gui_primitive_renderer.h:65
uint32_t baseOrder
Definition gui_primitive_renderer.h:68
bool operator==(const ScopeReplay &) const =default
tachyon::int2 delta
Definition gui_primitive_renderer.h:67
tachyon::ID scope
Definition gui_primitive_renderer.h:66
Per-kind primitive stream: CPU bytes appended by the emit methods and packed together into the curren...
Definition gui_primitive_renderer.h:51
int passStart
index of the open pass's first primitive
Definition gui_primitive_renderer.h:53
std::vector< std::byte > cpu
Definition gui_primitive_renderer.h:52
Definition gui_primitive_renderer.h:46
void RenderQuad(tachyon::IntRect rect, tachyon::IntRect clipRect, tachyon::VisualColorStyleIndex colorStyleIndex, float cornerRadius=0.0f, tachyon::ImageIndex textureIndex=tachyon::ImageIndex::Invalid, const tachyon::UVRect &uv={}, const tachyon::ImageDisplay &display={})
tachyon::float3x2 currentTransform
Definition gui_primitive_renderer.h:59
std::vector< ScopeReplay > replays
Definition gui_primitive_renderer.h:71
float currentOpacity
0 to 1, stamped into each primitive
Definition gui_primitive_renderer.h:60
void StartRenderPass(PrimitiveKind kind)
void RenderGlyph(tachyon::float2 pos, tachyon::float2 size, tachyon::float2 uvMin, tachyon::float2 uvMax, float scale, int bpp, int mode, tachyon::VisualColorStyleIndex textColorIndex, tachyon::IntRect clipRect, tachyon::ImageIndex textureIndex=tachyon::ImageIndex::Invalid, float shadowBlur=-1.0f)
void AddReplay(tachyon::ID scope, tachyon::int2 delta, const PrimitiveRenderTarget &captured)
Closes the open pass and adds a pass that draws cached scope scope, moved by delta; captured is what ...
void RenderCircle(tachyon::float2 center, float radius, tachyon::IntRect clipRect, const tachyon::LineStyle &lineStyle)
void RenderShadow(tachyon::IntRect rect, tachyon::IntRect clipRect, tachyon::VisualColorStyleIndex colorStyleIndex, float cornerRadius, int blur)
void RenderBox(tachyon::IntRect rect, tachyon::IntRect clipRect, const tachyon::StyleBlend &styles, tachyon::VisualColorStyleIndex colorStyleIndex={}, tachyon::ImageIndex textureIndex=tachyon::ImageIndex::Invalid, tachyon::IntRect snappedPx={})
std::vector< PrimitiveRenderPass > renderPasses
Definition gui_primitive_renderer.h:57
void RenderGlyphs(std::span< const GUIRenderer::GlyphInstance > glyphs, tachyon::float2 offset, tachyon::IntRect clipRect)
RenderGlyph for each of glyphs, moved by offset: one pass placement for them all, over the box they c...
void AppendCaptured(const PrimitiveRenderTarget &src, tachyon::int2 delta)
Appends another target's passes, translated by delta pixels.
void RenderOccluder(tachyon::IntRect rect, tachyon::IntRect clipRect)
int currentKind
kind of the open pass; -1 when none
Definition gui_primitive_renderer.h:58
void RenderLine(tachyon::int2 p0, tachyon::int2 p1, tachyon::int2 p2, tachyon::int2 p3, tachyon::IntRect clipRect, const tachyon::LineStyle &lineStyle)
bool recaptured
A cached scope captured again into this target this frame drew something else than before: what it re...
Definition gui_primitive_renderer.h:74
void SetTransform(tachyon::float3x2 transform)
uint32_t nextOrder
The draw order the next primitive gets; also counts a replay's primitives.
Definition gui_primitive_renderer.h:117
void RenderDots(std::span< const tachyon::float2 > positions, tachyon::IntRect clipRect, float size, tachyon::color4f color)
RenderDot at each of positions: one pass placement for them all.
std::array< Stream, kPrimitiveKindCount > streams
Definition gui_primitive_renderer.h:55
void SetOpacity(float opacity)
Definition gui_primitive_renderer.h:96
void RenderTriangle(tachyon::float2 p0, tachyon::float2 p1, tachyon::float2 p2, tachyon::IntRect clipRect, tachyon::VisualColorStyleIndex colorStyleIndex, tachyon::ImageIndex textureIndex=tachyon::ImageIndex::Invalid, TriangleEdges hardEdges=TriangleEdges::None)
void RenderDot(tachyon::float2 pos, tachyon::IntRect clipRect, float size, tachyon::color4f color)
size_t Render(RHI::RenderCommandList &cmdList, const PipelineSet &pipelines, GPUDrawPushConstants &push_constants)
Uploads the streams and draws the passes; replay passes are left to the caller (PrimitiveRenderer).
void RenderBox(tachyon::IntRect rect, tachyon::IntRect clipRect, uint32_t fromStyleIndex, uint32_t toStyleIndex, float blendT, tachyon::VisualColorStyleIndex colorStyleIndex={}, tachyon::ImageIndex textureIndex=tachyon::ImageIndex::Invalid, tachyon::IntRect snappedPx={})
Definition gui_primitive_renderer.h:98
A box's look as a mix of up to four of its state styles (flat GPU style indices, as GUIRenderer::Styl...
Definition gui_renderer.h:47
static StyleBlend Between(uint32_t from, uint32_t to, float t)
from mixed with to, t (0 to 1) of the way to to.
Definition gui_renderer.h:55
The part of an image to draw, in UV: 0,0 is its top-left corner and 1,1 its bottom-right.
Definition gui_image.h:15
Definition gui_base_types.h:394
Definition gui_base_types.h:120
float y
Definition gui_base_types.h:121
float x
Definition gui_base_types.h:121
float y
Definition gui_base_types.h:150
float x
Definition gui_base_types.h:150
float z
Definition gui_base_types.h:150
2D affine transform matrix (2 rows x 3 columns): x' = r0.x*x + r0.y*y + r0.z y' = r1....
Definition gui_base_types.h:218
float3 r1
Definition gui_base_types.h:219
float3 r0
Definition gui_base_types.h:219
Integer 2D vector.
Definition gui_base_types.h:18
int32_t x
Definition gui_base_types.h:19
int32_t y
Definition gui_base_types.h:19