From 975cdf18574022456bb8a035cd44588d0d54b7ee Mon Sep 17 00:00:00 2001 From: divverent Date: Thu, 17 Sep 2009 10:14:17 +0000 Subject: [PATCH] fix callprofile by making some CSQC builtins that call the renderer (or QC) exempt from prvm_callprofile git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9206 d7cf8633-e32d-0410-b094-e92efae38249 --- clvm_cmds.c | 13 +++++++++++++ prvm_exec.c | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/clvm_cmds.c b/clvm_cmds.c index 045f84ef..8ed5cdfc 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -726,6 +726,7 @@ extern void CSQC_Predraw (prvm_edict_t *ed);//csprogs.c extern void CSQC_Think (prvm_edict_t *ed);//csprogs.c void VM_CL_R_AddEntities (void) { + double t = Sys_DoubleTime(); int i, drawmask; prvm_edict_t *ed; VM_SAFEPARMCOUNT(1, VM_CL_R_AddEntities); @@ -750,13 +751,18 @@ void VM_CL_R_AddEntities (void) continue; CSQC_AddRenderEdict(ed); } + + // callprofile fixing hack: do not include this time in what is counted for CSQC_UpdateView + prog->functions[prog->funcoffsets.CSQC_UpdateView].totaltime -= Sys_DoubleTime() - t; } //#302 void(entity ent) addentity (EXT_CSQC) void VM_CL_R_AddEntity (void) { + double t = Sys_DoubleTime(); VM_SAFEPARMCOUNT(1, VM_CL_R_AddEntity); CSQC_AddRenderEdict(PRVM_G_EDICT(OFS_PARM0)); + prog->functions[prog->funcoffsets.CSQC_UpdateView].totaltime -= Sys_DoubleTime() - t; } //#303 float(float property, ...) setproperty (EXT_CSQC) @@ -881,6 +887,7 @@ void VM_CL_R_SetView (void) //#305 void(vector org, float radius, vector lightcolours[, float style, string cubemapname, float pflags]) adddynamiclight (EXT_CSQC) void VM_CL_R_AddDynamicLight (void) { + double t = Sys_DoubleTime(); vec_t *org; float radius = 300; vec_t *col; @@ -927,6 +934,7 @@ void VM_CL_R_AddDynamicLight (void) R_RTLight_Update(&r_refdef.scene.templights[r_refdef.scene.numlights], false, &matrix, col, style, cubemapname, castshadow, coronaintensity, coronasizescale, ambientscale, diffusescale, specularscale, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE); r_refdef.scene.lights[r_refdef.scene.numlights] = &r_refdef.scene.templights[r_refdef.scene.numlights++]; + prog->functions[prog->funcoffsets.CSQC_UpdateView].totaltime -= Sys_DoubleTime() - t; } //============================================================================ @@ -2490,8 +2498,10 @@ vmpolygons_t vmpolygons[PRVM_MAXPROGS]; // --blub void VM_CL_R_RenderScene (void) { + double t = Sys_DoubleTime(); vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr(); VM_SAFEPARMCOUNT(0, VM_CL_R_RenderScene); + // we need to update any RENDER_VIEWMODEL entities at this point because // csqc supplies its own view matrix CL_UpdateViewEntities(); @@ -2500,6 +2510,9 @@ void VM_CL_R_RenderScene (void) polys->num_vertices = polys->num_triangles = 0; polys->progstarttime = prog->starttime; + + // callprofile fixing hack: do not include this time in what is counted for CSQC_UpdateView + prog->functions[prog->funcoffsets.CSQC_UpdateView].totaltime -= Sys_DoubleTime() - t; } static void VM_ResizePolygons(vmpolygons_t *polys) diff --git a/prvm_exec.c b/prvm_exec.c index b6c8a0ac..c2864168 100644 --- a/prvm_exec.c +++ b/prvm_exec.c @@ -840,7 +840,7 @@ cleanup: // delete tempstrings created by this function vm_tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize; - prog->functions[fnum].totaltime += (Sys_DoubleTime() - calltime); + f->totaltime += (Sys_DoubleTime() - calltime); SV_FlushBroadcastMessages(); } -- 2.39.2