From 1d56c1443e6b78a3cb1d473ab5caf51627951e18 Mon Sep 17 00:00:00 2001 From: Spoike Date: Mon, 7 Oct 2019 04:51:17 +0000 Subject: [PATCH] Optimise env_cubemap. Fix some compile warnings. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5564 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- build_setup.sh | 4 ++-- engine/client/image.c | 1 + engine/client/m_download.c | 2 ++ engine/client/renderer.c | 2 ++ engine/common/fs.c | 5 ----- engine/common/plugin.c | 2 +- engine/common/q1bsp.c | 5 +++++ engine/gl/gl_model.c | 33 ++++++++++++++++++++++++++++----- engine/gl/gl_shader.c | 3 ++- engine/gl/shader.h | 1 + 10 files changed, 44 insertions(+), 14 deletions(-) diff --git a/build_setup.sh b/build_setup.sh index 039a3eded..b60187b22 100755 --- a/build_setup.sh +++ b/build_setup.sh @@ -230,11 +230,11 @@ function otherpackages { #Note: only the native linux-sdl target can be compiled, as libSDL[2]-dev doesn't support multiarch properly, and we depend upon it instead of building from source (thus ensuring it has whatever distro stuff needed... though frankly that should be inside the .so instead of the headers). -if [ $UID -eq 0 ] && [ ! -z `which apt-get` ]; then +#if [ $UID -eq 0 ] && [ ! -z `which apt-get` ]; then #because multiarch requires separate packages for some things, we'll need to set that up now (in case noone did that yet) # dpkg --add-architecture i386 # apt-get update -fi +#fi #generic crap. much of this is needed to set up and decompress dependancies and stuff. debianpackages subversion make automake libtool p7zip-full zip ca-certificates || otherpackages z7 make svn || exit diff --git a/engine/client/image.c b/engine/client/image.c index 95d60e2fc..b7f8d3468 100644 --- a/engine/client/image.c +++ b/engine/client/image.c @@ -4024,6 +4024,7 @@ static qboolean XCF_CombineLayer(struct xcf_s *f) case 3: Vector4Set(px, in[0], in[1], in[2], 0xff); break; case 2: Vector4Set(px, in[0], in[0], in[0], in[1]); break; case 1: Vector4Set(px, in[0], in[0], in[0], 0xff); break; + default: case 0: Vector4Set(px, 0xff, 0xff, 0xff, 0xff); break; } if (applylayermask) diff --git a/engine/client/m_download.c b/engine/client/m_download.c index 9a8d7d0b8..b5f1f1133 100644 --- a/engine/client/m_download.c +++ b/engine/client/m_download.c @@ -664,6 +664,7 @@ static void PM_AddSubList(const char *url, const char *prefix, qboolean save, qb numdownloadablelists++; } } +#ifdef WEBCLIENT static void PM_RemSubList(const char *url) { int i; @@ -675,6 +676,7 @@ static void PM_RemSubList(const char *url) } } } +#endif static qboolean PM_ParsePackageList(vfsfile_t *f, int parseflags, const char *url, const char *prefix) { diff --git a/engine/client/renderer.c b/engine/client/renderer.c index 12bb66d74..30fe440d5 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -359,6 +359,7 @@ cvar_t gl_blend2d = CVAR ("gl_blend2d", "1"); cvar_t gl_blendsprites = CVARD ("gl_blendsprites", "0", "Blend sprites instead of alpha testing them"); cvar_t r_deluxemapping_cvar = CVARAFD ("r_deluxemapping", "1", "r_glsl_deluxemapping", CVAR_ARCHIVE|CVAR_RENDERERLATCH, "Enables bumpmapping based upon precomputed light directions.\n0=off\n1=use if available\n2=auto-generate (if possible)"); +cvar_t mod_loadsurfenvmaps = CVARD ("r_loadsurfenvmaps", "1", "Load local reflection environment-maps, where available. These are normally defined via env_cubemap entities dotted around the place."); qboolean r_deluxemapping; cvar_t r_shaderblobs = CVARD ("r_shaderblobs", "0", "If enabled, can massively accelerate vid restarts / loading (especially with the d3d renderer). Can cause issues when upgrading engine versions, so this is disabled by default."); cvar_t gl_compress = CVARFD ("gl_compress", "0", CVAR_ARCHIVE, "Enable automatic texture compression even for textures which are not pre-compressed."); @@ -599,6 +600,7 @@ void GLRenderer_Init(void) Cvar_Register (&r_lightmap_nearest, GLRENDEREROPTIONS); Cvar_Register (&r_lightmap_average, GLRENDEREROPTIONS); + Cvar_Register (&mod_loadsurfenvmaps, GLRENDEREROPTIONS); } #endif diff --git a/engine/common/fs.c b/engine/common/fs.c index 03cfffff4..99e8a031b 100644 --- a/engine/common/fs.c +++ b/engine/common/fs.c @@ -4548,11 +4548,6 @@ static qboolean Sys_SteamHasFile(char *basepath, int basepathlen, char *steamdir } return false; } -#else -static qboolean Sys_SteamHasFile(char *basepath, int basepathlen, char *steamdir, char *fname) -{ //this system probably has no steam installs... - return false; -} #endif qboolean Sys_DoDirectoryPrompt(char *basepath, size_t basepathsize, const char *poshname, const char *savedname) diff --git a/engine/common/plugin.c b/engine/common/plugin.c index 3a2b812ef..de10c704d 100644 --- a/engine/common/plugin.c +++ b/engine/common/plugin.c @@ -584,7 +584,7 @@ void Plug_Command_f(void) if (!plugincommandarray[i].plugin) continue; //don't check commands who's owners died. - if (stricmp(plugincommandarray[i].command, cmd)) //not the right command + if (Q_strcasecmp(plugincommandarray[i].command, cmd)) //not the right command continue; currentplug = plugincommandarray[i].plugin; diff --git a/engine/common/q1bsp.c b/engine/common/q1bsp.c index 81d25e6e7..55a089cce 100644 --- a/engine/common/q1bsp.c +++ b/engine/common/q1bsp.c @@ -5,6 +5,7 @@ #include "shader.h" extern cvar_t r_decal_noperpendicular; +extern cvar_t mod_loadsurfenvmaps; /* Decal functions @@ -2428,6 +2429,10 @@ void BSPX_LoadEnvmaps(model_t *mod, bspx_header_t *bspx, void *mod_base) menvmap_t *out; int count; denvmap_t *in = BSPX_FindLump(bspx, mod_base, "ENVMAP", &count); + mod->envmaps = NULL; + mod->numenvmaps = 0; + if (!mod_loadsurfenvmaps.ival) + return; if (count%sizeof(*in)) return; //erk count /= sizeof(*in); diff --git a/engine/gl/gl_model.c b/engine/gl/gl_model.c index 9cce149a7..8df9dae1c 100644 --- a/engine/gl/gl_model.c +++ b/engine/gl/gl_model.c @@ -190,6 +190,11 @@ static void Mod_TextureList_f(void) char *body; char editname[MAX_OSPATH]; int preview = (Cmd_Argc()==1)?8:atoi(Cmd_Argv(1)); + + int s; + batch_t *batch; + unsigned int batchcount; + for (m=0 , mod=mod_known ; mbatches[s]; batch; batch = batch->next) + { + if (batch->texture == tx) + batchcount++; + } + } + // if (!batchcount) +// continue; //not actually used... + if (!shownmodelname) { shownmodelname = true; @@ -232,9 +249,9 @@ static void Mod_TextureList_f(void) Con_Printf("^[\\img\\%s\\imgtype\\%i\\s\\%i\\tip\\{%s^]", tx->shader->name, tx->shader->usageflags, preview, body); } if (*editname) - Con_Printf(" ^[%s\\edit\\%s\\tipimg\\%s\\tipimgtype\\%i\\tip\\{%s^]\n", tx->name, editname, tx->name, tx->shader->usageflags, body); + Con_Printf(" ^[%s\\edit\\%s\\tipimg\\%s\\tipimgtype\\%i\\tip\\{%s^] (%u batches)\n", tx->name, editname, tx->name, tx->shader->usageflags, body, batchcount); else - Con_Printf(" ^[%s\\tipimg\\%s\\tipimgtype\\%i\\tip\\{%s^]\n", tx->name, tx->shader->name, tx->shader->usageflags, body); + Con_Printf(" ^[%s\\tipimg\\%s\\tipimgtype\\%i\\tip\\{%s^] (%u batches)\n", tx->name, tx->shader->name, tx->shader->usageflags, body, batchcount); count++; } } @@ -2861,6 +2878,7 @@ static int Mod_Batches_Generate(model_t *mod) int sortid; batch_t *batch, *lbatch = NULL; vec4_t plane; + image_t *envmap; int merge = mod->lightmaps.merge; if (!merge) @@ -2877,6 +2895,7 @@ static int Mod_Batches_Generate(model_t *mod) { surf = mod->surfaces + mod->firstmodelsurface + i; shader = surf->texinfo->texture->shader; + envmap = surf->envmap; if (surf->flags & SURF_NODRAW) { @@ -2884,6 +2903,7 @@ static int Mod_Batches_Generate(model_t *mod) sortid = shader->sort; VectorClear(plane); plane[3] = 0; + envmap = NULL; } else if (shader) { @@ -2908,6 +2928,9 @@ static int Mod_Batches_Generate(model_t *mod) VectorClear(plane); plane[3] = 0; } + + if (!(shader->flags & SHADER_HASREFLECTCUBE)) + envmap = NULL; } else { @@ -2928,7 +2951,7 @@ static int Mod_Batches_Generate(model_t *mod) lbatch->lightmap[3] == lmmerge(surf->lightmaptexturenums[3]) && #endif lbatch->fog == surf->fog && - lbatch->envmap == surf->envmap)) + lbatch->envmap == envmap)) batch = lbatch; else { @@ -2946,7 +2969,7 @@ static int Mod_Batches_Generate(model_t *mod) batch->lightmap[3] == lmmerge(surf->lightmaptexturenums[3]) && #endif batch->fog == surf->fog && - batch->envmap == surf->envmap) + batch->envmap == envmap) break; } } @@ -2983,7 +3006,7 @@ static int Mod_Batches_Generate(model_t *mod) batch->next = mod->batches[sortid]; batch->ent = &r_worldentity; batch->fog = surf->fog; - batch->envmap = surf->envmap; + batch->envmap = envmap; Vector4Copy(plane, batch->plane); mod->batches[sortid] = batch; diff --git a/engine/gl/gl_shader.c b/engine/gl/gl_shader.c index 99aad42a4..177eb59c4 100644 --- a/engine/gl/gl_shader.c +++ b/engine/gl/gl_shader.c @@ -2805,6 +2805,7 @@ static qboolean Shaderpass_MapGen (parsestate_t *ps, shaderpass_t *pass, char *t } else if (!Q_stricmp (tname, "$reflectcube")) { + shader->flags |= SHADER_HASREFLECTCUBE; pass->texgen = T_GEN_REFLECTCUBE; } else if (!Q_stricmp (tname, "$reflectmask")) @@ -4348,7 +4349,7 @@ void Shader_FixupProgPasses(parsestate_t *ps, shaderpass_t *pass) {T_GEN_LOWEROVERLAY, SHADER_HASTOPBOTTOM}, //6 {T_GEN_FULLBRIGHT, SHADER_HASFULLBRIGHT}, //7 {T_GEN_PALETTED, SHADER_HASPALETTED}, //8 - {T_GEN_REFLECTCUBE, 0}, //9 + {T_GEN_REFLECTCUBE, SHADER_HASREFLECTCUBE}, //9 {T_GEN_REFLECTMASK, 0}, //10 {T_GEN_DISPLACEMENT, SHADER_HASDISPLACEMENT},//11 {T_GEN_OCCLUSION, 0}, //12 diff --git a/engine/gl/shader.h b/engine/gl/shader.h index 2d4e2c785..86c2630bb 100644 --- a/engine/gl/shader.h +++ b/engine/gl/shader.h @@ -641,6 +641,7 @@ struct shader_s SHADER_NODLIGHT = 1 << 15, //from surfaceflags SHADER_HASLIGHTMAP = 1 << 16, SHADER_HASTOPBOTTOM = 1 << 17, + SHADER_HASREFLECTCUBE = 1 << 18, //shader has a T_GEN_REFLECTCUBE pass (otherwise we can skip surf envmaps for better batching) // SHADER_STATICDATA = 1 << 18, //set if true: no deforms, no tcgen, rgbgen=identitylighting, alphagen=identity, tmu0=st + tmu1=lm(if available) for every pass, no norms SHADER_HASREFLECT = 1 << 19, //says that we need to generate a reflection image first SHADER_HASREFRACT = 1 << 20, //says that we need to generate a refraction image first