From: divverent Date: Tue, 13 Dec 2011 20:20:03 +0000 (+0000) Subject: get rid of 3 permutation bits X-Git-Tag: xonotic-v0.6.0~102^2~5 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=16f6300b58c0e4b6566a4219b8d72a2dc3871212;p=xonotic%2Fdarkplaces.git get rid of 3 permutation bits git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11614 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/dpsoftrast.h b/dpsoftrast.h index 9bd1d010..c30f69a6 100644 --- a/dpsoftrast.h +++ b/dpsoftrast.h @@ -185,20 +185,17 @@ typedef enum shaderpermutation_e SHADERPERMUTATION_OFFSETMAPPING = 1<<16, ///< adjust texcoords to roughly simulate a displacement mapped surface SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING = 1<<17, ///< adjust texcoords to accurately simulate a displacement mapped surface (requires OFFSETMAPPING to also be set!) SHADERPERMUTATION_SHADOWMAP2D = 1<<18, ///< (lightsource) use shadowmap texture as light filter - SHADERPERMUTATION_SHADOWMAPPCF = 1<<19, ///< (lightsource) use percentage closer filtering on shadowmap test results - SHADERPERMUTATION_SHADOWMAPPCF2 = 1<<20, ///< (lightsource) use higher quality percentage closer filtering on shadowmap test results - SHADERPERMUTATION_SHADOWSAMPLER = 1<<21, ///< (lightsource) use hardware shadowmap test - SHADERPERMUTATION_SHADOWMAPVSDCT = 1<<22, ///< (lightsource) use virtual shadow depth cube texture for shadowmap indexing - SHADERPERMUTATION_SHADOWMAPORTHO = 1<<23, ///< (lightsource) use orthographic shadowmap projection - SHADERPERMUTATION_DEFERREDLIGHTMAP = 1<<24, ///< (lightmap) read Texture_ScreenDiffuse/Specular textures and add them on top of lightmapping - SHADERPERMUTATION_ALPHAKILL = 1<<25, ///< (deferredgeometry) discard pixel if diffuse texture alpha below 0.5 - SHADERPERMUTATION_REFLECTCUBE = 1<<26, ///< fake reflections using global cubemap (not HDRI light probe) - SHADERPERMUTATION_NORMALMAPSCROLLBLEND = 1<<27, ///< (water) counter-direction normalmaps scrolling - SHADERPERMUTATION_BOUNCEGRID = 1<<28, ///< (lightmap) use Texture_BounceGrid as an additional source of ambient light - SHADERPERMUTATION_BOUNCEGRIDDIRECTIONAL = 1<<29, ///< (lightmap) use 16-component pixels in bouncegrid texture for directional lighting rather than standard 4-component - SHADERPERMUTATION_TRIPPY = 1<<30, ///< use trippy vertex shader effect - SHADERPERMUTATION_DEPTHRGB = 1<<31, ///< read/write depth values in RGB color coded format for older hardware without depth samplers - SHADERPERMUTATION_COUNT = 32 ///< size of shaderpermutationinfo array + SHADERPERMUTATION_SHADOWMAPVSDCT = 1<<19, ///< (lightsource) use virtual shadow depth cube texture for shadowmap indexing + SHADERPERMUTATION_SHADOWMAPORTHO = 1<<20, ///< (lightsource) use orthographic shadowmap projection + SHADERPERMUTATION_DEFERREDLIGHTMAP = 1<<21, ///< (lightmap) read Texture_ScreenDiffuse/Specular textures and add them on top of lightmapping + SHADERPERMUTATION_ALPHAKILL = 1<<22, ///< (deferredgeometry) discard pixel if diffuse texture alpha below 0.5 + SHADERPERMUTATION_REFLECTCUBE = 1<<23, ///< fake reflections using global cubemap (not HDRI light probe) + SHADERPERMUTATION_NORMALMAPSCROLLBLEND = 1<<24, ///< (water) counter-direction normalmaps scrolling + SHADERPERMUTATION_BOUNCEGRID = 1<<25, ///< (lightmap) use Texture_BounceGrid as an additional source of ambient light + SHADERPERMUTATION_BOUNCEGRIDDIRECTIONAL = 1<<26, ///< (lightmap) use 16-component pixels in bouncegrid texture for directional lighting rather than standard 4-component + SHADERPERMUTATION_TRIPPY = 1<<27, ///< use trippy vertex shader effect + SHADERPERMUTATION_DEPTHRGB = 1<<28, ///< read/write depth values in RGB color coded format for older hardware without depth samplers + SHADERPERMUTATION_COUNT = 29 ///< size of shaderpermutationinfo array } shaderpermutation_t; diff --git a/gl_rmain.c b/gl_rmain.c index 5da1769f..3f1123fb 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -645,9 +645,6 @@ shaderpermutationinfo_t shaderpermutationinfo[SHADERPERMUTATION_COUNT] = {"#define USEOFFSETMAPPING\n", " offsetmapping"}, {"#define USEOFFSETMAPPING_RELIEFMAPPING\n", " reliefmapping"}, {"#define USESHADOWMAP2D\n", " shadowmap2d"}, - {"#define USESHADOWMAPPCF 1\n", " shadowmappcf"}, // TODO make this a static parm - {"#define USESHADOWMAPPCF 2\n", " shadowmappcf2"}, // TODO make this a static parm - {"#define USESHADOWSAMPLER\n", " shadowsampler"}, // TODO make this a static parm {"#define USESHADOWMAPVSDCT\n", " shadowmapvsdct"}, // TODO make this a static parm {"#define USESHADOWMAPORTHO\n", " shadowmaportho"}, {"#define USEDEFERREDLIGHTMAP\n", " deferredlightmap"}, @@ -852,15 +849,21 @@ enum SHADERSTATICPARM_POSTPROCESS_USERVEC4 = 5, ///< postprocess uservec4 is enabled SHADERSTATICPARM_VERTEXTEXTUREBLEND_USEBOTHALPHAS = 6, // use both alpha layers while blending materials, allows more advanced microblending SHADERSTATICPARM_OFFSETMAPPING_USELOD = 7, ///< LOD for offsetmapping + SHADERSTATICPARM_SHADOWMAPPCF_1 = 8, ///< PCF 1 + SHADERSTATICPARM_SHADOWMAPPCF_2 = 9, ///< PCF 2 + SHADERSTATICPARM_SHADOWSAMPLER = 10, ///< sampler }; -#define SHADERSTATICPARMS_COUNT 8 +#define SHADERSTATICPARMS_COUNT 11 static const char *shaderstaticparmstrings_list[SHADERSTATICPARMS_COUNT]; static int shaderstaticparms_count = 0; static unsigned int r_compileshader_staticparms[(SHADERSTATICPARMS_COUNT + 0x1F) >> 5] = {0}; #define R_COMPILESHADER_STATICPARM_ENABLE(p) r_compileshader_staticparms[(p) >> 5] |= (1 << ((p) & 0x1F)) -static qboolean R_CompileShader_CheckStaticParms(void) + +extern qboolean r_shadow_shadowmapsampler; +extern int r_shadow_shadowmappcf; +qboolean R_CompileShader_CheckStaticParms(void) { static int r_compileshader_staticparms_save[1]; memcpy(r_compileshader_staticparms_save, r_compileshader_staticparms, sizeof(r_compileshader_staticparms)); @@ -886,6 +889,14 @@ static qboolean R_CompileShader_CheckStaticParms(void) } if (r_glsl_offsetmapping_lod.integer && r_glsl_offsetmapping_lod_distance.integer > 0) R_COMPILESHADER_STATICPARM_ENABLE(SHADERSTATICPARM_OFFSETMAPPING_USELOD); + + if (r_shadow_shadowmapsampler) + R_COMPILESHADER_STATICPARM_ENABLE(SHADERSTATICPARM_SHADOWSAMPLER); + if (r_shadow_shadowmappcf > 1) + R_COMPILESHADER_STATICPARM_ENABLE(SHADERSTATICPARM_SHADOWMAPPCF_2); + else if (r_shadow_shadowmappcf) + R_COMPILESHADER_STATICPARM_ENABLE(SHADERSTATICPARM_SHADOWMAPPCF_1); + return memcmp(r_compileshader_staticparms, r_compileshader_staticparms_save, sizeof(r_compileshader_staticparms)) != 0; } @@ -907,6 +918,9 @@ static void R_CompileShader_AddStaticParms(unsigned int mode, unsigned int permu R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_POSTPROCESS_USERVEC4, "USERVEC4"); R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_VERTEXTEXTUREBLEND_USEBOTHALPHAS, "USEBOTHALPHAS"); R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_OFFSETMAPPING_USELOD, "USEOFFSETMAPPING_LOD"); + R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_SHADOWMAPPCF_1, "USESHADOWMAPPCF 1"); + R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_SHADOWMAPPCF_2, "USESHADOWMAPPCF 2"); + R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_SHADOWSAMPLER, "USESHADOWSAMPLER"); } /// information about each possible shader permutation @@ -1786,7 +1800,7 @@ static void R_SetupShader_SetPermutationSoft(unsigned int mode, unsigned int per DPSOFTRAST_Uniform1f(DPSOFTRAST_UNIFORM_ClientTime, cl.time); } -static void R_GLSL_Restart_f(void) +void R_GLSL_Restart_f(void) { unsigned int i, limit; if (glslshaderstring && glslshaderstring != builtinshaderstring) @@ -2047,8 +2061,6 @@ extern qboolean r_shadow_usingshadowmaportho; extern float r_shadow_shadowmap_texturescale[2]; extern float r_shadow_shadowmap_parameters[4]; extern qboolean r_shadow_shadowmapvsdct; -extern qboolean r_shadow_shadowmapsampler; -extern int r_shadow_shadowmappcf; extern rtexture_t *r_shadow_shadowmap2ddepthbuffer; extern rtexture_t *r_shadow_shadowmap2ddepthtexture; extern rtexture_t *r_shadow_shadowmapvsdcttexture; @@ -2215,12 +2227,6 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, if(r_shadow_shadowmapvsdct) permutation |= SHADERPERMUTATION_SHADOWMAPVSDCT; - if (r_shadow_shadowmapsampler) - permutation |= SHADERPERMUTATION_SHADOWSAMPLER; - if (r_shadow_shadowmappcf > 1) - permutation |= SHADERPERMUTATION_SHADOWMAPPCF2; - else if (r_shadow_shadowmappcf) - permutation |= SHADERPERMUTATION_SHADOWMAPPCF; if (r_shadow_shadowmap2ddepthbuffer) permutation |= SHADERPERMUTATION_DEPTHRGB; } @@ -2259,12 +2265,6 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, permutation |= SHADERPERMUTATION_SHADOWMAPORTHO; permutation |= SHADERPERMUTATION_SHADOWMAP2D; - if (r_shadow_shadowmapsampler) - permutation |= SHADERPERMUTATION_SHADOWSAMPLER; - if (r_shadow_shadowmappcf > 1) - permutation |= SHADERPERMUTATION_SHADOWMAPPCF2; - else if (r_shadow_shadowmappcf) - permutation |= SHADERPERMUTATION_SHADOWMAPPCF; if (r_shadow_shadowmap2ddepthbuffer) permutation |= SHADERPERMUTATION_DEPTHRGB; } @@ -2316,12 +2316,6 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, permutation |= SHADERPERMUTATION_SHADOWMAPORTHO; permutation |= SHADERPERMUTATION_SHADOWMAP2D; - if (r_shadow_shadowmapsampler) - permutation |= SHADERPERMUTATION_SHADOWSAMPLER; - if (r_shadow_shadowmappcf > 1) - permutation |= SHADERPERMUTATION_SHADOWMAPPCF2; - else if (r_shadow_shadowmappcf) - permutation |= SHADERPERMUTATION_SHADOWMAPPCF; if (r_shadow_shadowmap2ddepthbuffer) permutation |= SHADERPERMUTATION_DEPTHRGB; } @@ -2378,12 +2372,6 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, permutation |= SHADERPERMUTATION_SHADOWMAPORTHO; permutation |= SHADERPERMUTATION_SHADOWMAP2D; - if (r_shadow_shadowmapsampler) - permutation |= SHADERPERMUTATION_SHADOWSAMPLER; - if (r_shadow_shadowmappcf > 1) - permutation |= SHADERPERMUTATION_SHADOWMAPPCF2; - else if (r_shadow_shadowmappcf) - permutation |= SHADERPERMUTATION_SHADOWMAPPCF; if (r_shadow_shadowmap2ddepthbuffer) permutation |= SHADERPERMUTATION_DEPTHRGB; } @@ -2439,12 +2427,6 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, permutation |= SHADERPERMUTATION_SHADOWMAPORTHO; permutation |= SHADERPERMUTATION_SHADOWMAP2D; - if (r_shadow_shadowmapsampler) - permutation |= SHADERPERMUTATION_SHADOWSAMPLER; - if (r_shadow_shadowmappcf > 1) - permutation |= SHADERPERMUTATION_SHADOWMAPPCF2; - else if (r_shadow_shadowmappcf) - permutation |= SHADERPERMUTATION_SHADOWMAPPCF; if (r_shadow_shadowmap2ddepthbuffer) permutation |= SHADERPERMUTATION_DEPTHRGB; } @@ -3008,12 +2990,6 @@ void R_SetupShader_DeferredLight(const rtlight_t *rtlight) if (r_shadow_shadowmapvsdct) permutation |= SHADERPERMUTATION_SHADOWMAPVSDCT; - if (r_shadow_shadowmapsampler) - permutation |= SHADERPERMUTATION_SHADOWSAMPLER; - if (r_shadow_shadowmappcf > 1) - permutation |= SHADERPERMUTATION_SHADOWMAPPCF2; - else if (r_shadow_shadowmappcf) - permutation |= SHADERPERMUTATION_SHADOWMAPPCF; if (r_shadow_shadowmap2ddepthbuffer) permutation |= SHADERPERMUTATION_DEPTHRGB; } diff --git a/r_shadow.c b/r_shadow.c index 19ae463e..320667df 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -496,6 +496,9 @@ static void R_Shadow_SetShadowMode(void) break; } } + + if(R_CompileShader_CheckStaticParms()) + R_GLSL_Restart_f(); } qboolean R_Shadow_ShadowMappingEnabled(void) diff --git a/render.h b/render.h index c869615a..60fc6afe 100644 --- a/render.h +++ b/render.h @@ -578,5 +578,7 @@ void R_LightningBeams_Init(void); void Mod_RenderInit(void); void Font_Init(void); -#endif +qboolean R_CompileShader_CheckStaticParms(void); +void R_GLSL_Restart_f(void); +#endif