From 665c81084f8ff39f782abefc773cdb0687ace178 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Thu, 16 Apr 2015 23:57:45 +0000 Subject: [PATCH] R_Clear: clear stencil buffer together with depth buffer if we have one. mh suggest that not doing this may cause performance issues: http://forums.inside3d.com/viewtopic.php?t=2408 It's also mentioned in a "Depth In-Depth" document from AMD. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1203 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/gl_rmain.c | 3 +++ Quake/gl_vidsdl.c | 5 +++++ Quake/glquake.h | 2 ++ 3 files changed, 10 insertions(+) diff --git a/Quake/gl_rmain.c b/Quake/gl_rmain.c index 5ac9943b..d05ad286 100644 --- a/Quake/gl_rmain.c +++ b/Quake/gl_rmain.c @@ -489,6 +489,9 @@ void R_Clear (void) unsigned int clearbits; clearbits = GL_DEPTH_BUFFER_BIT; + // from mh -- if we get a stencil buffer, we should clear it, even though we don't use it + if (gl_stencilbits) + clearbits |= GL_STENCIL_BUFFER_BIT; if (gl_clear.value) clearbits |= GL_COLOR_BUFFER_BIT; glClear (clearbits); diff --git a/Quake/gl_vidsdl.c b/Quake/gl_vidsdl.c index 5571bd15..a62efab7 100644 --- a/Quake/gl_vidsdl.c +++ b/Quake/gl_vidsdl.c @@ -104,6 +104,7 @@ qboolean gl_glsl_able = false; //ericw GLint gl_max_texture_units = 0; //ericw qboolean gl_glsl_gamma_able = false; //ericw qboolean gl_glsl_alias_able = false; //ericw +int gl_stencilbits; PFNGLMULTITEXCOORD2FARBPROC GL_MTexCoord2fFunc = NULL; //johnfitz PFNGLACTIVETEXTUREARBPROC GL_SelectTextureFunc = NULL; //johnfitz @@ -651,6 +652,10 @@ static qboolean VID_SetMode (int width, int height, int bpp, qboolean fullscreen if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &fsaa_obtained) == -1) fsaa_obtained = 0; +// read stencil bits + if (SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &gl_stencilbits) == -1) + gl_stencilbits = 0; + modestate = VID_GetFullscreen() ? MS_FULLSCREEN : MS_WINDOWED; CDAudio_Resume (); diff --git a/Quake/glquake.h b/Quake/glquake.h index fcb2d3ef..3715eb23 100644 --- a/Quake/glquake.h +++ b/Quake/glquake.h @@ -148,6 +148,8 @@ extern cvar_t gl_playermip; extern cvar_t gl_subdivide_size; extern float load_subdivide_size; //johnfitz -- remember what subdivide_size value was when this map was loaded +extern int gl_stencilbits; + // Multitexture extern qboolean mtexenabled; extern qboolean gl_mtexable;