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