]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fix callprofile by making some CSQC builtins that call the renderer (or QC) exempt...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 17 Sep 2009 10:14:17 +0000 (10:14 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 17 Sep 2009 10:14:17 +0000 (10:14 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9206 d7cf8633-e32d-0410-b094-e92efae38249

clvm_cmds.c
prvm_exec.c

index 045f84ef014fce94cc7916fea1515986aa398aab..8ed5cdfc57734be4a2538beb44326c66575bb84d 100644 (file)
@@ -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)
index b6c8a0acf70081cc23a61fec4d8899ebcaf5e936..c2864168c6e18bb5abdd5be478d73b2265561e5d 100644 (file)
@@ -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();
 }