Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
resource_counters.hpp
Go to the documentation of this file.
1#pragma once
2
3// Process-wide counts of the resource work painting does beneath the Canvas
4// API: decoding encoded images, uploading raster images to the GPU, building
5// SkParagraphs, and recording or replaying cached subtree scenes. None of it
6// is visible in a paint-command stream, and all of it is what a steady-state
7// frame should not repeat, so a benchmark reads these counters before and
8// after each frame and gates on the deltas.
9//
10// The counters only ever increase and use relaxed atomics: an increment is a
11// single uncontended add on the painting thread, and readers want totals, not
12// ordering. ImageFileCache keeps its own hit/build statistics; these count the
13// work itself, whichever path asked for it.
14
15#include <atomic>
16#include <cstdint>
17
18namespace pulp::canvas {
19
24 std::uint64_t image_decodes = 0;
26 std::uint64_t gpu_uploads = 0;
28 std::uint64_t paragraph_builds = 0;
30 std::uint64_t scene_records = 0;
32 std::uint64_t scene_replays = 0;
33};
34
35namespace detail {
36inline std::atomic<std::uint64_t> image_decodes{0};
37inline std::atomic<std::uint64_t> gpu_uploads{0};
38inline std::atomic<std::uint64_t> paragraph_builds{0};
39inline std::atomic<std::uint64_t> scene_records{0};
40inline std::atomic<std::uint64_t> scene_replays{0};
41} // namespace detail
42
44 constexpr auto relaxed = std::memory_order_relaxed;
45 return {detail::image_decodes.load(relaxed), detail::gpu_uploads.load(relaxed),
46 detail::paragraph_builds.load(relaxed), detail::scene_records.load(relaxed),
47 detail::scene_replays.load(relaxed)};
48}
49
50inline void note_image_decode() noexcept {
51 detail::image_decodes.fetch_add(1, std::memory_order_relaxed);
52}
53inline void note_gpu_upload() noexcept {
54 detail::gpu_uploads.fetch_add(1, std::memory_order_relaxed);
55}
56inline void note_paragraph_build() noexcept {
57 detail::paragraph_builds.fetch_add(1, std::memory_order_relaxed);
58}
59inline void note_scene_record() noexcept {
60 detail::scene_records.fetch_add(1, std::memory_order_relaxed);
61}
62inline void note_scene_replay() noexcept {
63 detail::scene_replays.fetch_add(1, std::memory_order_relaxed);
64}
65
66} // namespace pulp::canvas
Definition resource_counters.hpp:35
std::atomic< std::uint64_t > scene_records
Definition resource_counters.hpp:39
std::atomic< std::uint64_t > gpu_uploads
Definition resource_counters.hpp:37
std::atomic< std::uint64_t > scene_replays
Definition resource_counters.hpp:40
std::atomic< std::uint64_t > paragraph_builds
Definition resource_counters.hpp:38
std::atomic< std::uint64_t > image_decodes
Definition resource_counters.hpp:36
Definition affine_transform.hpp:24
void note_gpu_upload() noexcept
Definition resource_counters.hpp:53
void note_paragraph_build() noexcept
Definition resource_counters.hpp:56
ResourceCounters resource_counters() noexcept
Definition resource_counters.hpp:43
void note_image_decode() noexcept
Definition resource_counters.hpp:50
void note_scene_record() noexcept
Definition resource_counters.hpp:59
void note_scene_replay() noexcept
Definition resource_counters.hpp:62
Definition resource_counters.hpp:20
std::uint64_t paragraph_builds
SkParagraph builds (shaping plus line layout).
Definition resource_counters.hpp:28
std::uint64_t gpu_uploads
Raster images uploaded to a GPU texture.
Definition resource_counters.hpp:26
std::uint64_t image_decodes
Encoded image bytes handed to Skia for decoding.
Definition resource_counters.hpp:24
std::uint64_t scene_records
Subtree scenes recorded for set_subtree_cached() views.
Definition resource_counters.hpp:30
std::uint64_t scene_replays
Recorded subtree scenes replayed instead of repainting the subtree.
Definition resource_counters.hpp:32