Cogs.Core
Source
Services
QualityService.h
1
#pragma once
2
3
#include "Base.h"
4
5
#include "Foundation/Platform/Timer.h"
6
7
namespace
Cogs::Core
8
{
9
enum struct
QualityRequest
10
{
11
AtTarget,
12
HasSlack,
13
ThrottleDown,
14
RapidBackoff,
15
};
16
17
enum class
MetricType :
unsigned
int
18
{
19
Idle,
20
Frame,
21
PreRender,
22
Present,
23
MetricTypeCount,
24
};
25
26
class
COGSCORE_DLL_API
QualityService
27
{
28
friend
class
InspectorGuiRenderer
;
29
friend
void
renderingStatsInspector(
class
Context
*,
bool
*);
30
public
:
31
33
struct
FrameTimings
{
34
float
frameTime
;
35
float
cogsTime
;
36
float
cpuTime
;
37
float
presentTime
;
38
float
idleTime
;
39
};
40
41
QualityService
(
class
Context
* context);
42
43
void
beginFrame();
44
void
endFrame();
45
46
void
begin(MetricType metric);
47
void
end(MetricType metric);
48
49
void
updateTimes();
50
51
// in [0,2]
52
float
getCurrentQuality()
const
{
return
currentQuality; }
53
54
void
requestQualityChange(QualityRequest request);
55
57
FrameTimings getFrameTimings()
const
;
58
59
float
getMetric(MetricType metric);
60
61
float
assetSystemToleranceScale = 1.f;
62
63
float
potreeSystemToleranceScale = 1.f;
64
float
potreeSystemChunkCountScale = 1.f;
65
66
// Used as control-value/status for the cache system in the OGC3DTilesSystem.
67
float
ogc3DTilesSystemToleranceScale = 1.0f;
68
float
ogc3DTilesSystemCacheControl = 1.0f;
69
70
private
:
71
Context
* context =
nullptr
;
72
bool
rapidBackoff =
false
;
73
bool
throttleDown =
false
;
74
bool
hasSlack =
false
;
75
bool
resetFrameTime =
false
;
76
bool
hasOneFrame =
false
;
77
78
float
frameTimeTarget = 0.f;
79
uint32_t gpuMemTargetMB = 0;
80
float
avgFrameTime = 0.f;
// Exponential moving average of frame time in ms.
81
float
qualitySetting = 100.f;
82
float
currentQuality = 1.f;
83
84
size_t
stack_idx = 0;
85
86
static
constexpr
size_t
TIMES_COUNT = 256;
87
size_t
times_idx = 0;
88
TimePerf time[(size_t)MetricType::MetricTypeCount];
89
float
times[TIMES_COUNT][(size_t)MetricType::MetricTypeCount];
90
91
size_t
bufferUploadSize[TIMES_COUNT];
92
size_t
textureUploadSize[TIMES_COUNT];
93
};
94
}
Cogs::Core::Context
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition:
Context.h:83
Cogs::Core::InspectorGuiRenderer
Definition:
InspectorGuiRenderer.h:14
Cogs::Core::QualityService
Definition:
QualityService.h:27
Cogs::Core
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
Definition:
ComponentFunctions.h:10
Cogs::Core::QualityService::FrameTimings
Definition:
QualityService.h:33
Cogs::Core::QualityService::FrameTimings::frameTime
float frameTime
Time from finishing the previous frame to finishing this frame. Sum of cogsTime plus idleTime.
Definition:
QualityService.h:34
Cogs::Core::QualityService::FrameTimings::presentTime
float presentTime
Time spent in cogs waiting for present to return.
Definition:
QualityService.h:37
Cogs::Core::QualityService::FrameTimings::idleTime
float idleTime
Time spent outside of cogs between frames.
Definition:
QualityService.h:38
Cogs::Core::QualityService::FrameTimings::cpuTime
float cpuTime
Time spent in cogs before presenting.
Definition:
QualityService.h:36
Cogs::Core::QualityService::FrameTimings::cogsTime
float cogsTime
Time spent in cogs this frame. Sum of cpuTime plus presentTime.
Definition:
QualityService.h:35
Generated by
1.9.6