mirror of https://github.com/bjornbytes/lovr.git
GpuStats;
This commit is contained in:
parent
7c7714214e
commit
322c0bdef7
|
@ -368,7 +368,7 @@ int l_lovrGraphicsGetStats(lua_State* L) {
|
||||||
lua_createtable(L, 0, 2);
|
lua_createtable(L, 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsStats stats = lovrGraphicsGetStats();
|
GpuStats stats = lovrGraphicsGetStats();
|
||||||
|
|
||||||
lua_pushinteger(L, stats.drawCalls);
|
lua_pushinteger(L, stats.drawCalls);
|
||||||
lua_setfield(L, 1, "drawcalls");
|
lua_setfield(L, 1, "drawcalls");
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t shaderSwitches;
|
int shaderSwitches;
|
||||||
|
int drawCalls;
|
||||||
} GpuStats;
|
} GpuStats;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -49,6 +50,9 @@ void gpuInit(bool srgb, gpuProc (*getProcAddress)(const char*));
|
||||||
void gpuDestroy();
|
void gpuDestroy();
|
||||||
void gpuDraw(GpuDrawCommand* command);
|
void gpuDraw(GpuDrawCommand* command);
|
||||||
void gpuPresent();
|
void gpuPresent();
|
||||||
|
GpuStats gpuGetStats();
|
||||||
|
|
||||||
|
// Ephemeral
|
||||||
void gpuBindFramebuffer(uint32_t framebuffer);
|
void gpuBindFramebuffer(uint32_t framebuffer);
|
||||||
void gpuBindIndexBuffer(uint32_t indexBuffer);
|
void gpuBindIndexBuffer(uint32_t indexBuffer);
|
||||||
void gpuBindTexture(Texture* texture, int slot);
|
void gpuBindTexture(Texture* texture, int slot);
|
||||||
|
|
|
@ -116,8 +116,6 @@ void lovrGraphicsClear(bool clearColor, bool clearDepth, bool clearStencil, Colo
|
||||||
|
|
||||||
void lovrGraphicsPresent() {
|
void lovrGraphicsPresent() {
|
||||||
glfwSwapBuffers(state.window);
|
glfwSwapBuffers(state.window);
|
||||||
state.stats.drawCalls = 0;
|
|
||||||
state.stats.shaderSwitches = 0;
|
|
||||||
gpuPresent();
|
gpuPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,8 +191,8 @@ int lovrGraphicsGetHeight() {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsStats lovrGraphicsGetStats() {
|
GpuStats lovrGraphicsGetStats() {
|
||||||
return state.stats;
|
return gpuGetStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
// State
|
// State
|
||||||
|
@ -1109,8 +1107,6 @@ void lovrGraphicsDraw(Mesh* mesh, mat4 transform, DefaultShader defaultShader, i
|
||||||
if (transform) {
|
if (transform) {
|
||||||
lovrGraphicsPop();
|
lovrGraphicsPop();
|
||||||
}
|
}
|
||||||
|
|
||||||
state.stats.drawCalls++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lovrGraphicsPushLayer(Canvas* canvas) {
|
void lovrGraphicsPushLayer(Canvas* canvas) {
|
||||||
|
|
|
@ -87,11 +87,6 @@ typedef struct {
|
||||||
float textureAnisotropy;
|
float textureAnisotropy;
|
||||||
} GraphicsLimits;
|
} GraphicsLimits;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int drawCalls;
|
|
||||||
int shaderSwitches;
|
|
||||||
} GraphicsStats;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool initialized;
|
bool initialized;
|
||||||
GLFWwindow* window;
|
GLFWwindow* window;
|
||||||
|
@ -125,7 +120,6 @@ typedef struct {
|
||||||
Mesh* mesh;
|
Mesh* mesh;
|
||||||
bool stencilEnabled;
|
bool stencilEnabled;
|
||||||
bool stencilWriting;
|
bool stencilWriting;
|
||||||
GraphicsStats stats;
|
|
||||||
} GraphicsState;
|
} GraphicsState;
|
||||||
|
|
||||||
// Base
|
// Base
|
||||||
|
@ -137,7 +131,7 @@ void lovrGraphicsPresent();
|
||||||
void lovrGraphicsCreateWindow(int w, int h, bool fullscreen, int msaa, const char* title, const char* icon);
|
void lovrGraphicsCreateWindow(int w, int h, bool fullscreen, int msaa, const char* title, const char* icon);
|
||||||
int lovrGraphicsGetWidth();
|
int lovrGraphicsGetWidth();
|
||||||
int lovrGraphicsGetHeight();
|
int lovrGraphicsGetHeight();
|
||||||
GraphicsStats lovrGraphicsGetStats();
|
GpuStats lovrGraphicsGetStats();
|
||||||
|
|
||||||
// State
|
// State
|
||||||
Color lovrGraphicsGetBackgroundColor();
|
Color lovrGraphicsGetBackgroundColor();
|
||||||
|
|
|
@ -73,12 +73,20 @@ void gpuDraw(GpuDrawCommand* command) {
|
||||||
glDrawArrays(glDrawMode, rangeStart, count);
|
glDrawArrays(glDrawMode, rangeStart, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state.stats.drawCalls++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpuPresent() {
|
void gpuPresent() {
|
||||||
memset(&state.stats, 0, sizeof(state.stats));
|
memset(&state.stats, 0, sizeof(state.stats));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GpuStats gpuGetStats() {
|
||||||
|
return state.stats;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ephemeral
|
||||||
|
|
||||||
void gpuBindFramebuffer(uint32_t framebuffer) {
|
void gpuBindFramebuffer(uint32_t framebuffer) {
|
||||||
if (state.framebuffer != framebuffer) {
|
if (state.framebuffer != framebuffer) {
|
||||||
state.framebuffer = framebuffer;
|
state.framebuffer = framebuffer;
|
||||||
|
|
Loading…
Reference in New Issue