From fc2a2e05ee7637551aa5a1d86d1c7cd3ee8ae306 Mon Sep 17 00:00:00 2001 From: havoc Date: Wed, 10 Aug 2005 07:08:57 +0000 Subject: [PATCH] renamed r_shadow_geforcefxlowquality to r_shadow_usehalffloat and added gl_support_half_float extension checking, (half float is now considered a feature rather than a low quality option, as it is an even bigger speed gain on GF6 than on GFFX and no quality reduction has been observed) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5565 d7cf8633-e32d-0410-b094-e92efae38249 --- glquake.h | 4 ++++ r_shadow.c | 14 +++++++------- vid_shared.c | 9 +++++++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/glquake.h b/glquake.h index 12cc1165..20f2b6d0 100644 --- a/glquake.h +++ b/glquake.h @@ -676,6 +676,10 @@ extern int gl_support_shading_language_100; // GL_EXT_bgra #define GL_BGRA 0x80E1 +// GL_NV_half_float +extern int gl_support_half_float; +// note: this extension has GL_HALF stuff for feeding half floats but I don't use that + #define DEBUGGL #ifdef DEBUGGL diff --git a/r_shadow.c b/r_shadow.c index 3e8cab55..20836366 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -223,7 +223,7 @@ cvar_t r_shadow_glsl = {0, "r_shadow_glsl", "1"}; cvar_t r_shadow_glsl_offsetmapping = {0, "r_shadow_glsl_offsetmapping", "0"}; cvar_t r_shadow_glsl_offsetmapping_scale = {0, "r_shadow_glsl_offsetmapping_scale", "-0.04"}; cvar_t r_shadow_glsl_offsetmapping_bias = {0, "r_shadow_glsl_offsetmapping_bias", "0.04"}; -cvar_t r_shadow_glsl_geforcefxlowquality = {0, "r_shadow_glsl_geforcefxlowquality", "1"}; +cvar_t r_shadow_glsl_usehalffloat = {0, "r_shadow_glsl_usehalffloat", "0"}; cvar_t r_shadow_glsl_surfacenormalize = {0, "r_shadow_glsl_surfacenormalize", "1"}; cvar_t gl_ext_stenciltwoside = {0, "gl_ext_stenciltwoside", "1"}; cvar_t r_editlights = {0, "r_editlights", "0"}; @@ -427,9 +427,9 @@ const char *builtinshader_light_frag = void r_shadow_start(void) { int i; - // if not a GeForce FX, turn off the lowquality cvar - if (strncmp(gl_renderer, "GeForce FX ", strlen("GeForce FX "))) - Cvar_SetValue("r_shadow_glsl_geforcefxlowquality", 0); + // use half float math where available (speed gain on NVIDIA GFFX and GF6) + if (gl_support_half_float) + Cvar_SetValue("r_shadow_glsl_usehalffloat", 1); // allocate vertex processing arrays numcubemaps = 0; r_shadow_attenuation2dtexture = NULL; @@ -620,7 +620,7 @@ void R_Shadow_Help_f(void) "r_shadow_glsl_offsetmapping : enables Offset Mapping bumpmap enhancement\n" "r_shadow_glsl_offsetmapping_scale : controls depth of Offset Mapping\n" "r_shadow_glsl_offsetmapping_bias : should be negative half of scale\n" -"r_shadow_glsl_geforcefxlowquality : use lower quality lighting\n" +"r_shadow_glsl_usehalffloat : use lower quality lighting\n" "r_shadow_glsl_surfacenormalize : makes bumpmapping slightly higher quality\n" "r_shadow_scissor : use scissor optimization\n" "r_shadow_shadow_polygonfactor : nudge shadow volumes closer/further\n" @@ -668,7 +668,7 @@ void R_Shadow_Init(void) Cvar_RegisterVariable(&r_shadow_glsl_offsetmapping); Cvar_RegisterVariable(&r_shadow_glsl_offsetmapping_scale); Cvar_RegisterVariable(&r_shadow_glsl_offsetmapping_bias); - Cvar_RegisterVariable(&r_shadow_glsl_geforcefxlowquality); + Cvar_RegisterVariable(&r_shadow_glsl_usehalffloat); Cvar_RegisterVariable(&r_shadow_glsl_surfacenormalize); Cvar_RegisterVariable(&gl_ext_stenciltwoside); if (gamemode == GAME_TENEBRAE) @@ -1224,7 +1224,7 @@ void R_Shadow_Stage_Lighting(int stenciltest) r_shadow_lightpermutation |= SHADERPERMUTATION_OFFSETMAPPING; if (r_shadow_glsl_surfacenormalize.integer && r_shadow_program_light[r_shadow_lightpermutation | SHADERPERMUTATION_SURFACENORMALIZE]) r_shadow_lightpermutation |= SHADERPERMUTATION_SURFACENORMALIZE; - if (r_shadow_glsl_geforcefxlowquality.integer && r_shadow_program_light[r_shadow_lightpermutation | SHADERPERMUTATION_GEFORCEFX]) + if (r_shadow_glsl_usehalffloat.integer && r_shadow_program_light[r_shadow_lightpermutation | SHADERPERMUTATION_GEFORCEFX]) r_shadow_lightpermutation |= SHADERPERMUTATION_GEFORCEFX; r_shadow_lightprog = r_shadow_program_light[r_shadow_lightpermutation]; qglUseProgramObjectARB(r_shadow_lightprog);CHECKGLERROR diff --git a/vid_shared.c b/vid_shared.c index d253881c..30bb057b 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -48,6 +48,8 @@ int gl_support_shading_language_100 = false; int gl_support_vertex_shader = false; // GL_ARB_fragment_shader int gl_support_fragment_shader = false; +// GL_NV_half_float +int gl_support_half_float = false; // LordHavoc: if window is hidden, don't update screen qboolean vid_hidden = true; @@ -673,12 +675,15 @@ void VID_CheckExtensions(void) // COMMANDLINEOPTION: GL: -noshaderobjects disables GL_ARB_shader_objects (required for vertex shader and fragment shader) // COMMANDLINEOPTION: GL: -noshadinglanguage100 disables GL_ARB_shading_language_100 (required for vertex shader and fragment shader) -// COMMANDLINEOPTION: GL: -novertexshader disables GL_ARB_vertex_shader (currently unused, allows vertex shader effects) -// COMMANDLINEOPTION: GL: -nofragmentshader disables GL_ARB_fragment_shader (currently unused, allows pixel shader effects) +// COMMANDLINEOPTION: GL: -novertexshader disables GL_ARB_vertex_shader (allows vertex shader effects) +// COMMANDLINEOPTION: GL: -nofragmentshader disables GL_ARB_fragment_shader (allows pixel shader effects, can improve per pixel lighting performance and capabilities) if ((gl_support_shader_objects = GL_CheckExtension("GL_ARB_shader_objects", shaderobjectsfuncs, "-noshaderobjects", false))) if ((gl_support_shading_language_100 = GL_CheckExtension("GL_ARB_shading_language_100", NULL, "-noshadinglanguage100", false))) if ((gl_support_vertex_shader = GL_CheckExtension("GL_ARB_vertex_shader", vertexshaderfuncs, "-novertexshader", false))) gl_support_fragment_shader = GL_CheckExtension("GL_ARB_fragment_shader", NULL, "-nofragmentshader", false); + +// COMMANDLINEOPTION: GL: -nohalffloat disables GL_NV_half_float extension + gl_support_half_float = GL_CheckExtension("GL_NV_half_float", NULL, "-nohalffloat", false); } qboolean vid_vertexarrays_are_var = false; -- 2.39.2