forked from FWGS/xash3d-fwgs
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert direct stack manipulation to simple and cheap event writing. Draw rudimentary frame times graph. Related to #412
- Loading branch information
Showing
5 changed files
with
148 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Frame structure wrt calls from the engine | ||
- (eng) SCR_UpdateScreen() | ||
- (eng) V_PreRender() | ||
- **(ref) R_BeginFrame()** | ||
- (eng) V_RenderView() | ||
- **(ref) GL_BackendStartFrame()** -- ref_gl only sets speeds string to empty here | ||
- (eng) loop over ref_params_t views | ||
- **(ref) GL_RenderFrame()** | ||
- (eng) ??? SV_DrawDebugTriangles() | ||
- **(ref) GL_BackendEndFrame()** -- ref_gl only produces speeds string here | ||
- (eng) V_PostRender() | ||
- **(ref) R_AllowFog(), R_Set2DMode(true)** | ||
- **(ref) R_DrawTileClear()** x N | ||
- (vgui) Paint() -> ??? | ||
- (eng) SCR_RSpeeds() | ||
- **(ref) R_SpeedsMessage()** | ||
- (eng) CL_DrawString() ... | ||
- **(ref) GL_SetRenderMode()** | ||
- **(ref) RefGetParm()** for texture resolution | ||
- **(ref) Color4ub()** | ||
- **(ref) R_DrawStretchPic()** | ||
- (eng) SRC_DrawNetGraph() | ||
- **(ref) many TriApi calls** -- 2D usage of triapi. we were not ready for this (maybe track R_Set2DMode()?) | ||
- **(ref) R_ShowTextures()** kekw | ||
- **(ref) VID_ScreenShot()** | ||
- **(ref) R_AllowFog(true)** | ||
- **(ref) R_EndFrame()** | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include "r_slows.h" | ||
#include "vk_light.h" // For stats | ||
#include "shaders/ray_interop.h" // stats: struct LightCluster | ||
#include "vk_overlay.h" | ||
#include "vk_framectl.h" | ||
|
||
#include "profiler.h" | ||
|
||
#define MAX_FRAMES_HISTORY 256 | ||
|
||
static struct { | ||
float frame_times[MAX_FRAMES_HISTORY]; | ||
uint32_t frame_num; | ||
} g_slows; | ||
|
||
|
||
static float linearstep(float min, float max, float v) { | ||
if (v <= min) return 0; | ||
if (v >= max) return 1; | ||
return (v - min) / (max - min); | ||
} | ||
|
||
// FIXME move this to r_speeds or something like that | ||
void R_ShowExtendedProfilingData(uint32_t prev_frame_index) { | ||
{ | ||
const int dirty = g_lights.stats.dirty_cells; | ||
gEngine.Con_NPrintf(4, "Dirty light cells: %d, size = %dKiB, ranges = %d\n", dirty, (int)(dirty * sizeof(struct LightCluster) / 1024), g_lights.stats.ranges_uploaded); | ||
} | ||
|
||
const uint32_t events = g_aprof.events_last_frame - prev_frame_index; | ||
const unsigned long long delta_ns = APROF_EVENT_TIMESTAMP(g_aprof.events[g_aprof.events_last_frame]) - APROF_EVENT_TIMESTAMP(g_aprof.events[prev_frame_index]); | ||
const float frame_time = delta_ns / 1e6; | ||
|
||
gEngine.Con_NPrintf(5, "aprof events this frame: %u, wraps: %d, frame time: %.03fms (%lluns)\n", events, g_aprof.current_frame_wraparounds, frame_time, delta_ns); | ||
|
||
g_slows.frame_times[g_slows.frame_num] = frame_time; | ||
g_slows.frame_num = (g_slows.frame_num + 1) % MAX_FRAMES_HISTORY; | ||
|
||
const float width = (float)vk_frame.width / MAX_FRAMES_HISTORY; | ||
for (int i = 0; i < MAX_FRAMES_HISTORY; ++i) { | ||
const float frame_time = g_slows.frame_times[i]; | ||
CL_FillRGBA(i * width, 100, width, frame_time * 2.f, | ||
//255, 255, 255, 255); | ||
255*linearstep(16.67, 16.67*2.f, frame_time), 255, 0, 127); | ||
} | ||
|
||
/* gEngine.Con_NPrintf(5, "Perf scopes:"); */ | ||
/* for (int i = 0; i < g_aprof.num_scopes; ++i) { */ | ||
/* const aprof_scope_t *const scope = g_aprof.scopes + i; */ | ||
/* gEngine.Con_NPrintf(6 + i, "%s: c%d t%.03f(%.03f)ms s%.03f(%.03f)ms", scope->name, */ | ||
/* scope->frame.count, */ | ||
/* scope->frame.duration / 1e6, */ | ||
/* (scope->frame.duration / 1e6) / scope->frame.count, */ | ||
/* (scope->frame.duration - scope->frame.duration_children) / 1e6, */ | ||
/* (scope->frame.duration - scope->frame.duration_children) / 1e6 / scope->frame.count); */ | ||
/* } */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#pragma once | ||
#include <stdint.h> | ||
|
||
void R_ShowExtendedProfilingData(uint32_t prev_frame_event_index); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters