-
Notifications
You must be signed in to change notification settings - Fork 4
/
PerfFramework.h
84 lines (62 loc) · 2.02 KB
/
PerfFramework.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#pragma once
#include <functional>
#include <string>
#include <vector>
#include <GL/glew.h>
#include <glm/glm.hpp>
#pragma pack(push, 1)
struct PackedVec {
int x : 10;
int y : 10;
int z : 10;
int w : 2;
};
struct PackedColor {
unsigned int r : 10;
unsigned int g : 10;
unsigned int b : 10;
unsigned int a : 2;
};
#pragma pack(pop)
PackedVec PackVec3(glm::vec3 v);
PackedVec PackVec4(glm::vec4 v);
PackedColor PackColor(glm::vec3 color);
// How many frames to discard before recording starts
#define FRAMES_TO_DISCARD 32
// How many frames to record and average for a single sample
#define FRAMES_TO_RECORD 128
#define ROTATE false
//#define ROTATE true
// Record of a single performance sample
struct PerfRecord {
size_t gpuMemUsed;
size_t mainMemUsed;
double averageFrameTimeMs;
};
// Gets the amount of free VRAM for nvidia cards
size_t GetFreeMemNvidia();
// Gets the amount of main memory usage
// NOTE: Right now this includes VRAM used, so the amount of used VRAM must be subtracted off
size_t GetMainMemUsage();
// Runs a performance test with the given setup and draw functions
PerfRecord RunPerf(std::function<void()> setupFn, std::function<void()> drawFn,
std::function<void()> teardownFn);
void CheckGLErrors();
glm::vec3 CameraPosition();
// View/projection/model matrix methods
glm::mat4 MakeModelView();
glm::mat4 MakeProjection();
glm::mat4 MakeMvp();
float GetAspectRatio();
// Gets the vertical field of view in radians
float GetFovY();
// Gets the near plane where x and y store the width and height, and z stores the depth.
glm::vec3 GetNearPlane();
void PrintMatrix(glm::mat4 matrix);
// Compiles a shader program from the given list of shader files
GLuint MakeShaderProgram(std::vector<std::pair<std::string, GLenum>> shaders);
// Reads in the entire contents of the specified text file
std::string ReadTextFile(std::string filename);
// Query command line arguments
std::string GetOption(std::string optionName);
bool IsOptionSet(std::string optionName);