From d1430451182d6b00a08ad3681657f9be7328781b Mon Sep 17 00:00:00 2001 From: Spoike Date: Sun, 8 Jun 2014 09:36:15 +0000 Subject: [PATCH] fix !!ver so it actually works, allowing later glsl version (for stuff like 'flat') git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4683 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/common/net_wins.c | 2 +- engine/d3d/d3d11_shader.c | 2 +- engine/d3d/d3d_shader.c | 2 +- engine/gl/gl_shader.c | 18 ++++++++++-------- engine/gl/gl_vidcommon.c | 11 +++++++---- engine/gl/shader.h | 2 +- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/engine/common/net_wins.c b/engine/common/net_wins.c index 23745e031..f3a75490b 100644 --- a/engine/common/net_wins.c +++ b/engine/common/net_wins.c @@ -5310,7 +5310,6 @@ void NET_GetLocalAddress (int socket, netadr_t *out) { #if defined(_WIN32) && defined(HAVE_PACKET) char buff[512]; - char adrbuf[MAX_ADR_SIZE]; struct sockaddr_qstorage address; int namelen; netadr_t adr = {0}; @@ -5362,6 +5361,7 @@ void NET_GetLocalAddress (int socket, netadr_t *out) if (!notvalid) { +// char adrbuf[MAX_ADR_SIZE]; // Con_TPrintf("Client IP address %s\n", NET_AdrToString (adrbuf, sizeof(adrbuf), out) ); return; } diff --git a/engine/d3d/d3d11_shader.c b/engine/d3d/d3d11_shader.c index 9dba71889..092e102fa 100644 --- a/engine/d3d/d3d11_shader.c +++ b/engine/d3d/d3d11_shader.c @@ -325,7 +325,7 @@ static qboolean D3D11Shader_LoadBlob(program_t *prog, const char *name, unsigned return success; } -qboolean D3D11Shader_CreateProgram (program_t *prog, const char *name, unsigned int permu, const char **precompilerconstants, const char *vert, const char *hull, const char *domain, const char *frag, qboolean silenterrors, vfsfile_t *blobfile) +qboolean D3D11Shader_CreateProgram (program_t *prog, const char *name, unsigned int permu, int ver, const char **precompilerconstants, const char *vert, const char *hull, const char *domain, const char *frag, qboolean silenterrors, vfsfile_t *blobfile) { char *vsformat; char *hsformat = NULL; diff --git a/engine/d3d/d3d_shader.c b/engine/d3d/d3d_shader.c index 44351097e..6978ef555 100644 --- a/engine/d3d/d3d_shader.c +++ b/engine/d3d/d3d_shader.c @@ -141,7 +141,7 @@ static dllhandle_t *shaderlib; (This)->lpVtbl -> Release(This) #endif -static qboolean D3D9Shader_CreateProgram (program_t *prog, const char *sname, unsigned int permu, const char **precompilerconstants, const char *vert, const char *tcs, const char *tes, const char *frag, qboolean silent, vfsfile_t *blobfile) +static qboolean D3D9Shader_CreateProgram (program_t *prog, const char *sname, unsigned int permu, int ver, const char **precompilerconstants, const char *vert, const char *tcs, const char *tes, const char *frag, qboolean silent, vfsfile_t *blobfile) { D3DXMACRO defines[64]; LPD3DXBUFFER code = NULL, errors = NULL; diff --git a/engine/gl/gl_shader.c b/engine/gl/gl_shader.c index 4bee1432f..c6d4372ba 100644 --- a/engine/gl/gl_shader.c +++ b/engine/gl/gl_shader.c @@ -893,6 +893,8 @@ static qboolean Shader_LoadPermutations(char *name, program_t *prog, char *scrip qboolean onefailed = false; extern cvar_t gl_specular; + ver = 0; + if (qrenderer != qrtype) { return false; @@ -1031,14 +1033,14 @@ static qboolean Shader_LoadPermutations(char *name, program_t *prog, char *scrip { unsigned int magic; unsigned int corrupt = false; - char ver[MAX_QPATH]; - char *thisver = version_string(); + char ever[MAX_QPATH]; + char *thisever = version_string(); corrupt |= VFS_READ(blobfile, &magic, sizeof(magic)) != sizeof(magic); corrupt |= magic != *(unsigned int*)"FBLB"; corrupt |= VFS_READ(blobfile, &blobheaderoffset, sizeof(blobheaderoffset)) != sizeof(blobheaderoffset); - corrupt |= VFS_READ(blobfile, ver, sizeof(ver)) != sizeof(ver); + corrupt |= VFS_READ(blobfile, ever, sizeof(ever)) != sizeof(ever); - corrupt |= strcmp(ver, thisver); + corrupt |= strcmp(ever, thisever); //if the magic or header didn't read properly then the file is corrupt if (corrupt) { @@ -1051,9 +1053,9 @@ static qboolean Shader_LoadPermutations(char *name, program_t *prog, char *scrip VFS_SEEK(blobfile, 0); magic = *(unsigned int*)"FBLB"; //magic VFS_WRITE(blobfile, &magic, sizeof(magic)); - memset(ver, 0, sizeof(ver)); //make sure we don't leak stuff. - Q_strncpyz(ver, thisver, sizeof(ver)); - VFS_WRITE(blobfile, ver, sizeof(ver)); + memset(ever, 0, sizeof(ever)); //make sure we don't leak stuff. + Q_strncpyz(ever, thisever, sizeof(ever)); + VFS_WRITE(blobfile, ever, sizeof(ever)); blobheaderoffset = 0; } } @@ -1200,7 +1202,7 @@ static qboolean Shader_LoadPermutations(char *name, program_t *prog, char *scrip initoffset = VFS_GETLEN(blobfile); VFS_SEEK(blobfile, initoffset); } - if (!sh_config.pCreateProgram(prog, name, p, permutationdefines, script, tess?script:NULL, tess?script:NULL, script, (p & PERMUTATION_SKELETAL)?true:onefailed, blobfile)) + if (!sh_config.pCreateProgram(prog, name, p, ver, permutationdefines, script, tess?script:NULL, tess?script:NULL, script, (p & PERMUTATION_SKELETAL)?true:onefailed, blobfile)) { if (!(p & PERMUTATION_SKELETAL)) onefailed = true; //don't flag it if skeletal failed. diff --git a/engine/gl/gl_vidcommon.c b/engine/gl/gl_vidcommon.c index bb5d462b7..d6fe92043 100644 --- a/engine/gl/gl_vidcommon.c +++ b/engine/gl/gl_vidcommon.c @@ -1686,11 +1686,14 @@ GLhandleARB GLSlang_CreateProgram(const char *name, int ver, const char **precom return handle; } -qboolean GLSlang_CreateProgramPermu(program_t *prog, const char *name, unsigned int permu, const char **precompilerconstants, const char *vert, const char *tcs, const char *tes, const char *frag, qboolean noerrors, vfsfile_t *blobfile) +qboolean GLSlang_CreateProgramPermu(program_t *prog, const char *name, unsigned int permu, int ver, const char **precompilerconstants, const char *vert, const char *tcs, const char *tes, const char *frag, qboolean noerrors, vfsfile_t *blobfile) { - int ver = gl_config.gles?100:110; - if (permu & PERMUTATION_SKELETAL) - ver = 120; + if (!ver) + { + ver = gl_config.gles?100:110; + if (permu & PERMUTATION_SKELETAL) + ver = 120; + } prog->permu[permu].handle.glsl = GLSlang_CreateProgram(name, ver, precompilerconstants, vert, frag, noerrors, blobfile); if (prog->permu[permu].handle.glsl) return true; diff --git a/engine/gl/shader.h b/engine/gl/shader.h index 7f5ba21db..a2636cdd8 100644 --- a/engine/gl/shader.h +++ b/engine/gl/shader.h @@ -633,7 +633,7 @@ typedef struct void (*pDeleteProg) (program_t *prog, unsigned int permu); qboolean (*pLoadBlob) (program_t *prog, const char *name, unsigned int permu, vfsfile_t *blobfile); - qboolean (*pCreateProgram) (program_t *prog, const char *name, unsigned int permu, const char **precompilerconstants, const char *vert, const char *tcs, const char *tes, const char *frag, qboolean noerrors, vfsfile_t *blobfile); + qboolean (*pCreateProgram) (program_t *prog, const char *name, unsigned int permu, int ver, const char **precompilerconstants, const char *vert, const char *tcs, const char *tes, const char *frag, qboolean noerrors, vfsfile_t *blobfile); void (*pProgAutoFields) (program_t *prog, char **cvarnames, int *cvartypes); } sh_config_t; extern sh_config_t sh_config;