From 1b18dd86b8c702a7895b70a53eca9f9ffb7cbd2b Mon Sep 17 00:00:00 2001 From: divverent Date: Tue, 29 Jan 2008 12:41:02 +0000 Subject: [PATCH] added variable vid_gammatables_trivial that is true if the gamma ramp is the identity map - so glsl doesn't need to waste time on that case later git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8044 d7cf8633-e32d-0410-b094-e92efae38249 --- vid.h | 3 ++- vid_shared.c | 30 ++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/vid.h b/vid.h index 9ba33da5..29ab8785 100644 --- a/vid.h +++ b/vid.h @@ -148,7 +148,8 @@ void VID_Restart_f(void); void VID_Start(void); -extern unsigned int vid_gammaramps_serial; // so other subsystems can poll if gamma parameters have changed; this starts with 0 and gets increased by 1 each time the gamma parameters get changed and VID_BuildGammaTables should be called again +extern unsigned int vid_gammatables_serial; // so other subsystems can poll if gamma parameters have changed; this starts with 0 and gets increased by 1 each time the gamma parameters get changed and VID_BuildGammaTables should be called again +extern qboolean vid_gammatables_trivial; // this is set to true if all color control values are at default setting, and it therefore would make no sense to use the gamma table void VID_BuildGammaTables(unsigned short *ramps, int rampsize); // builds the current gamma tables into an array (needs 3*rampsize items) #endif diff --git a/vid_shared.c b/vid_shared.c index f67bb2d3..a11cfc32 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -825,7 +825,8 @@ static int gamma_forcenextframe = false; static float cachegamma, cachebrightness, cachecontrast, cacheblack[3], cachegrey[3], cachewhite[3], cachecontrastboost; static int cachecolorenable, cachehwgamma; -unsigned int vid_gammaramps_serial = 0; // so other subsystems can poll if gamma parameters have changed +unsigned int vid_gammatables_serial = 0; // so other subsystems can poll if gamma parameters have changed +qboolean vid_gammatables_trivial = true; void VID_BuildGammaTables(unsigned short *ramps, int rampsize) { if (cachecolorenable) @@ -909,6 +910,31 @@ void VID_UpdateGamma(qboolean force, int rampsize) BOUNDCVAR(v_color_white_b, 1, 5); #undef BOUNDCVAR + // set vid_gammatables_trivial to true if the current settings would generate the identity gamma table + vid_gammatables_trivial = false; + if(v_color_enable.integer) + { + if(v_contrastboost.value == 1) + if(v_color_black_r.value == 0) + if(v_color_black_g.value == 0) + if(v_color_black_b.value == 0) + if(fabs(v_color_grey_r.value - 0.5) < 1e-6) + if(fabs(v_color_grey_g.value - 0.5) < 1e-6) + if(fabs(v_color_grey_b.value - 0.5) < 1e-6) + if(v_color_white_r.value == 1) + if(v_color_white_g.value == 1) + if(v_color_white_b.value == 1) + vid_gammatables_trivial = true; + } + else + { + if(v_contrastboost.value == 1) + if(v_gamma.value == 1) + if(v_contrast.value == 1) + if(v_brightness.value == 0) + vid_gammatables_trivial = true; + } + #define GAMMACHECK(cache, value) if (cache != (value)) gamma_changed = true;cache = (value) if(v_psycho.integer) gamma_changed = true; @@ -928,7 +954,7 @@ void VID_UpdateGamma(qboolean force, int rampsize) GAMMACHECK(cachewhite[2] , v_color_white_b.value); if(gamma_changed) - ++vid_gammaramps_serial; + ++vid_gammatables_serial; GAMMACHECK(cachehwgamma , wantgamma); #undef GAMMACHECK -- 2.39.2