v0.3.0 API Reference
OGLDrawTimer.h
1//
2// OpenGLDrawTimer.h
3// avara3d
4//
5// Created by Morgan Davis on 12/24/25.
6// Copyright © 2026 Morgan K Davis. All rights reserved.
7//
8
9#ifndef AVARA3D_PROFILING_OPENGLDRAWTIMER_H
10#define AVARA3D_PROFILING_OPENGLDRAWTIMER_H
11
12#include <chrono>
13#include <cstdint>
14#include <vector>
15
16#include "a3d/render/backend/opengl/GLTypes.h"
17
18namespace a3d {
19
20class OGLDrawTimer {
21
22public:
23 // [Internal Lifecycle Functions]
24
25 explicit OGLDrawTimer(unsigned bufferedFrames);
26
27 OGLDrawTimer(const OGLDrawTimer&) = delete;
28 OGLDrawTimer& operator=(const OGLDrawTimer&) = delete;
29
30 OGLDrawTimer(OGLDrawTimer&& other) = delete;
31 OGLDrawTimer& operator=(OGLDrawTimer&& other) = delete;
32
33 ~OGLDrawTimer();
34
35 // [Internal Member Functions]
36
37 bool initialize();
38 void begin();
39 std::chrono::nanoseconds end();
40
41private:
42 // [Private Types]
43
44 enum class Mode {
45 Disabled,
46 DesktopTimeElapsed,
47 WebDisjointTimerQuery,
48 WebDisjointTimerQueryExt
49 };
50
51 // [Private Member Functions]
52
53 bool resolveQuery(size_t index);
54
55 // [Private Member Variables]
56
57 Mode _mode;
58 gl::enum_t _queryTarget;
59 unsigned _bufferSize;
60 std::vector<unsigned> _glQueries;
61 size_t _frame;
62 std::chrono::nanoseconds _lastTime;
63 std::vector<uint8_t> _issued;
64 bool _active = false;
65 bool _initialized = false;
66};
67
68} // namespace a3d
69
70#endif // AVARA3D_PROFILING_OPENGLDRAWTIMER_H