]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
reworked r_viewscale_fpsscaling to use the time of SCR_DrawScreen
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 1 Apr 2011 07:04:58 +0000 (07:04 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 1 Apr 2011 07:04:58 +0000 (07:04 +0000)
wrapped in glFinish calls (REALLY should use GL_EXT_timery_query), this
means that vid_vsync now works fine with it

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10995 d7cf8633-e32d-0410-b094-e92efae38249

cl_screen.c
client.h
gl_rmain.c

index be349662ac33674fcce29b30f1bd3fa99eae5242..bedbc92f8805294de05e79fe4dcc6e976a39156a 100644 (file)
@@ -781,6 +781,8 @@ static int R_CountLeafTriangles(const dp_model_t *model, const mleaf_t *leaf)
        return triangles;
 }
 
+extern cvar_t r_viewscale;
+extern float viewscalefpsadjusted;
 void R_TimeReport_EndFrame(void)
 {
        int i, j, lines, y;
@@ -796,7 +798,7 @@ void R_TimeReport_EndFrame(void)
                loc = CL_Locs_FindNearest(cl.movement_origin);
                viewleaf = (r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.PointInLeaf) ? r_refdef.scene.worldmodel->brush.PointInLeaf(r_refdef.scene.worldmodel, r_refdef.view.origin) : NULL;
                dpsnprintf(string, sizeof(string),
-"%s%s\n"
+"%6.0fus rendertime %3.0f%% viewscale %s%s\n"
 "%3i renders org:'%+8.2f %+8.2f %+8.2f' dir:'%+2.3f %+2.3f %+2.3f'\n"
 "%5i viewleaf%5i cluster%2i area%4i brushes%4i surfaces(%7i triangles)\n"
 "%7i surfaces%7i triangles %5i entities (%7i surfaces%7i triangles)\n"
@@ -808,7 +810,7 @@ void R_TimeReport_EndFrame(void)
 "%6i draws%8i vertices%8i triangles bloompixels%8i copied%8i drawn\n"
 "updated%5i indexbuffers%8i bytes%5i vertexbuffers%8i bytes\n"
 "%s"
-, loc ? "Location: " : "", loc ? loc->name : ""
+, r_refdef.lastdrawscreentime * 1000000.0, r_viewscale.value * sqrt(viewscalefpsadjusted) * 100.0f, loc ? "Location: " : "", loc ? loc->name : ""
 , r_refdef.stats.renders, r_refdef.view.origin[0], r_refdef.view.origin[1], r_refdef.view.origin[2], r_refdef.view.forward[0], r_refdef.view.forward[1], r_refdef.view.forward[2]
 , viewleaf ? (int)(viewleaf - r_refdef.scene.worldmodel->brush.data_leafs) : -1, viewleaf ? viewleaf->clusterindex : -1, viewleaf ? viewleaf->areaindex : -1, viewleaf ? viewleaf->numleafbrushes : 0, viewleaf ? viewleaf->numleafsurfaces : 0, viewleaf ? R_CountLeafTriangles(r_refdef.scene.worldmodel, viewleaf) : 0
 , r_refdef.stats.world_surfaces, r_refdef.stats.world_triangles, r_refdef.stats.entities, r_refdef.stats.entities_surfaces, r_refdef.stats.entities_triangles
@@ -2196,6 +2198,7 @@ extern cvar_t cl_minfps_qualitymax;
 extern cvar_t cl_minfps_qualitymin;
 extern cvar_t cl_minfps_qualitypower;
 extern cvar_t cl_minfps_qualityscale;
+extern cvar_t r_viewscale_fpsscaling;
 static double cl_updatescreen_rendertime = 0;
 static double cl_updatescreen_quality = 1;
 extern void Sbar_ShowFPS_Update(void);
@@ -2203,6 +2206,7 @@ void CL_UpdateScreen(void)
 {
        vec3_t vieworigin;
        double rendertime1;
+       double drawscreenstart;
        float conwidth, conheight;
        float f;
        r_viewport_t viewport;
@@ -2331,6 +2335,9 @@ void CL_UpdateScreen(void)
                }
        }
 
+       if (r_viewscale_fpsscaling.integer && qglFinish)
+               qglFinish();
+       drawscreenstart = Sys_DoubleTime();
        if (R_Stereo_Active())
        {
                r_stereo_side = 0;
@@ -2363,6 +2370,9 @@ void CL_UpdateScreen(void)
        }
        else
                SCR_DrawScreen();
+       if (r_viewscale_fpsscaling.integer && qglFinish)
+               qglFinish();
+       r_refdef.lastdrawscreentime = Sys_DoubleTime() - drawscreenstart;
 
        SCR_CaptureVideo();
 
index 0df5daeea926cd23146d55281e333ee55858d7f1..909a5e225d6c05142d8da0764a11d60aa1c38d3c 100644 (file)
--- a/client.h
+++ b/client.h
@@ -1824,6 +1824,9 @@ typedef struct r_refdef_s
        float shadowpolygonfactor;
        float shadowpolygonoffset;
 
+       // how long R_RenderView took on the previous frame
+       double lastdrawscreentime;
+
        // rendering stats for r_speeds display
        // (these are incremented in many places)
        r_refdef_stats_t stats;
index 9d9c340fcf15156a596cecc6d99a6f43a73ad721..88ccc329d6b40ab916cf02251bf5caf167ce7809 100644 (file)
@@ -5132,7 +5132,7 @@ void R_View_Update(void)
        R_View_UpdateEntityLighting();
 }
 
-static float viewscalefpsadjusted = 1.0f;
+float viewscalefpsadjusted = 1.0f;
 
 void R_GetScaledViewSize(int width, int height, int *outwidth, int *outheight)
 {
@@ -5694,18 +5694,16 @@ void R_Bloom_StartFrame(void)
 
        if (r_viewscale_fpsscaling.integer)
        {
-               static double lastrealtime;
                double actualframetime;
                double targetframetime;
                double adjust;
-               actualframetime = realtime - lastrealtime;
+               actualframetime = r_refdef.lastdrawscreentime;
                targetframetime = (1.0 / r_viewscale_fpsscaling_target.value);
                adjust = (targetframetime - actualframetime) * r_viewscale_fpsscaling_multiply.value;
                adjust = bound(-r_viewscale_fpsscaling_stepmax.value, adjust, r_viewscale_fpsscaling_stepmax.value);
                if (r_viewscale_fpsscaling_stepsize.value > 0)
                        adjust = (int)(adjust / r_viewscale_fpsscaling_stepsize.value) * r_viewscale_fpsscaling_stepsize.value;
                viewscalefpsadjusted += adjust;
-               lastrealtime = realtime;
                viewscalefpsadjusted = bound(r_viewscale_fpsscaling_min.value, viewscalefpsadjusted, 1.0f);
        }
        else