From ef2de97077ff97fb7452d2b9d60e21cf59c81e8e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 6 Oct 2019 19:32:35 +0200 Subject: [PATCH] - the harmless changes of the failed refactoring of the shader. --- source/blood/src/credits.cpp | 4 ++-- source/build/include/palette.h | 14 +++++++++++--- source/build/include/polymost.h | 2 +- source/build/src/osd.cpp | 4 ---- source/build/src/palette.cpp | 6 ++++-- source/build/src/polymost.cpp | 18 ++---------------- source/duke3d/src/anim.cpp | 2 +- source/glbackend/gl_shader.cpp | 2 +- source/glbackend/glbackend.cpp | 2 +- source/glbackend/glbackend.h | 1 + source/rr/src/anim.cpp | 2 +- 11 files changed, 25 insertions(+), 32 deletions(-) diff --git a/source/blood/src/credits.cpp b/source/blood/src/credits.cpp index e07bedbe5..ece342d3f 100644 --- a/source/blood/src/credits.cpp +++ b/source/blood/src/credits.cpp @@ -230,7 +230,7 @@ void credPlaySmk(const char *_pzSMK, const char *_pzWAV, int nWav) int nFrames = Smacker_GetNumFrames(hSMK); Smacker_GetPalette(hSMK, palette); - paletteSetColorTable(kSMKPal, palette); + paletteSetColorTable(kSMKPal, palette, true); videoSetPalette(gBrightness>>2, kSMKPal, 8+2); int nScale; @@ -271,7 +271,7 @@ void credPlaySmk(const char *_pzSMK, const char *_pzWAV, int nWav) videoClearScreen(0); Smacker_GetPalette(hSMK, palette); - paletteSetColorTable(kSMKPal, palette); + paletteSetColorTable(kSMKPal, palette, true); videoSetPalette(gBrightness >> 2, kSMKPal, 0); tileInvalidate(kSMKTile, 0, 1 << 4); // JBF 20031228 Smacker_GetFrame(hSMK, pFrame); diff --git a/source/build/include/palette.h b/source/build/include/palette.h index 22f7422d0..26c2926ac 100644 --- a/source/build/include/palette.h +++ b/source/build/include/palette.h @@ -33,8 +33,16 @@ extern const char *(paletteGetBlendTable) (int32_t blend); #endif extern uint32_t PaletteIndexFullbrights[8]; -#define IsPaletteIndexFullbright(col) (PaletteIndexFullbrights[(col)>>5] & (1u<<((col)&31))) -#define SetPaletteIndexFullbright(col) (PaletteIndexFullbrights[(col)>>5] |= (1u<<((col)&31))) + +inline bool IsPaletteIndexFullbright(uint8_t col) +{ + return (PaletteIndexFullbrights[col >> 5] & (1u << (col & 31))); +} + +inline void SetPaletteIndexFullbright(int col) +{ + PaletteIndexFullbrights[col >> 5] |= (1u << (col & 31)); +} typedef struct { uint8_t r, g, b, f; @@ -49,7 +57,7 @@ extern void fullscreen_tint_gl(uint8_t r, uint8_t g, uint8_t b, uint8_t f); extern void fullscreen_tint_gl_blood(void); extern void videoFadeToBlack(int32_t moreopaquep); void paletteMakeLookupTable(int32_t palnum, const char *remapbuf, uint8_t r, uint8_t g, uint8_t b, char noFloorPal); -void paletteSetColorTable(int32_t id, uint8_t const *table); +void paletteSetColorTable(int32_t id, uint8_t const *table, bool transient = false); void paletteFreeColorTable(int32_t id); void paletteSetBlendTable(int32_t blend, const char *tab); void paletteFreeBlendTable(int32_t blend); diff --git a/source/build/include/polymost.h b/source/build/include/polymost.h index cd20643f5..e32c0d24e 100644 --- a/source/build/include/polymost.h +++ b/source/build/include/polymost.h @@ -34,7 +34,7 @@ void polymost_outputGLDebugMessage(uint8_t severity, const char* format, ...); //void phex(char v, char *s); void uploadtexture(FHardwareTexture *tex, int32_t doalloc, vec2_t siz, int32_t texfmt, coltype *pic, vec2_t tsiz, int32_t dameth); -void uploadbasepalette(int32_t basepalnum); +void uploadbasepalette(int32_t basepalnum, bool transient = false); void uploadpalswap(int32_t palookupnum); void polymost_drawsprite(int32_t snum); void polymost_drawmaskwall(int32_t damaskwallcnt); diff --git a/source/build/src/osd.cpp b/source/build/src/osd.cpp index ad2235c19..d5fd522b2 100644 --- a/source/build/src/osd.cpp +++ b/source/build/src/osd.cpp @@ -2165,10 +2165,6 @@ int osdcmd_cvar_set(osdcmdptr_t parm) fallthrough__; case CVAR_INVALIDATEART: gltexinvalidatetype(INVALIDATE_ART); -#ifdef POLYMER - if (videoGetRenderMode() == REND_POLYMER) - polymer_texinvalidate(); -#endif break; } } diff --git a/source/build/src/palette.cpp b/source/build/src/palette.cpp index 50ce33058..6f8e1f636 100644 --- a/source/build/src/palette.cpp +++ b/source/build/src/palette.cpp @@ -708,7 +708,7 @@ void paletteMakeLookupTable(int32_t palnum, const char *remapbuf, uint8_t r, uin // // setbasepal // -void paletteSetColorTable(int32_t id, uint8_t const * const table) +void paletteSetColorTable(int32_t id, uint8_t const * const table, bool transient) { if (basepaltable[id] == NULL) basepaltable[id] = (uint8_t *) Xmalloc(768); @@ -718,7 +718,7 @@ void paletteSetColorTable(int32_t id, uint8_t const * const table) #ifdef USE_OPENGL if (videoGetRenderMode() >= REND_POLYMOST) { - uploadbasepalette(id); + uploadbasepalette(id, transient); } #endif } @@ -811,6 +811,7 @@ void videoSetPalette(char dabrightness, uint8_t dapalid, uint8_t flags) g_lastpalettesum = lastpalettesum = newpalettesum; +#if 0 if (videoGetRenderMode() >= REND_POLYMOST) { // Only reset the textures if the corresponding preserve flags are clear and @@ -826,6 +827,7 @@ void videoSetPalette(char dabrightness, uint8_t dapalid, uint8_t flags) if (!(flags&8) && doinvalidate) gltexinvalidatetype(INVALIDATE_ART_NON_INDEXED); } +#endif if ((flags&16)==0) { diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index fee91d25f..9039dfd58 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -131,9 +131,6 @@ int32_t r_flatsky = 1; static float fogresult, fogresult2; coltypef fogcol, fogtable[MAXPALOOKUPS]; -static GLenum currentActiveTexture = 0; -static uint32_t currentTextureID = 0; - static GLuint quadVertsID = 0; @@ -142,8 +139,6 @@ int32_t r_useindexedcolortextures = -1; static int32_t lastbasepal = -1; static FHardwareTexture *paletteTextureIDs[MAXBASEPALS]; static FHardwareTexture *palswapTextureID = nullptr; -//extern char const *polymost1Frag; -//extern char const *polymost1Vert; static inline float float_trans(uint32_t maskprops, uint8_t blend) { @@ -377,10 +372,6 @@ void polymost_glinit() { globalflags |= GLOBAL_NO_GL_TILESHADES; // This re-enables the old fading logic without re-adding the r_usetileshades variable. The entire thing will have to be done on a more abstract level anyway. - currentTextureID = 0; - char allPacked = false; - - lastbasepal = -1; for (int basepalnum = 0; basepalnum < MAXBASEPALS; ++basepalnum) { @@ -696,7 +687,7 @@ void uploadtexture(FHardwareTexture *tex, int32_t doalloc, vec2_t siz, int32_t t tex->LoadTexture((uint8_t *)pic); } -void uploadbasepalette(int32_t basepalnum) +void uploadbasepalette(int32_t basepalnum, bool transient) // transient palettes are used by movies and should not affect the engine state. All other palettes only get set at game startup. { if (!basepaltable[basepalnum]) { @@ -1424,7 +1415,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32 int32_t size2; for (size2 = 1; size2 < size; size2 += size2) {} if (size == size2) - GLInterface.SetNpotEmulation(false, 1.f, 0.f); + GLInterface.SetNpotEmulation(false, 1.f, 0.f); else { float xOffset = 1.f / tilesiz[globalpicnum].x; @@ -1459,11 +1450,6 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32 float pc[4]; -#ifdef POLYMER - if (videoGetRenderMode() == REND_POLYMER && pr_artmapping && !(globalflags & GLOBAL_NO_GL_TILESHADES) && polymer_eligible_for_artmap(globalpicnum, pth)) - pc[0] = pc[1] = pc[2] = 1.0f; - else -#endif { polytint_t const & tint = hictinting[globalpal]; float shadeFactor = (pth->flags & PTH_INDEXED) && diff --git a/source/duke3d/src/anim.cpp b/source/duke3d/src/anim.cpp index 2caa7c9b6..88447a6ac 100644 --- a/source/duke3d/src/anim.cpp +++ b/source/duke3d/src/anim.cpp @@ -465,7 +465,7 @@ int32_t Anim_Play(const char *fn) goto end_anim; } - paletteSetColorTable(ANIMPAL, ANIM_GetPalette()); + paletteSetColorTable(ANIMPAL, ANIM_GetPalette(), true); // setpalette(0L,256L,tempbuf); // setbrightness(ud.brightness>>2,tempbuf,2); diff --git a/source/glbackend/gl_shader.cpp b/source/glbackend/gl_shader.cpp index 4dfc85c94..d423c620e 100644 --- a/source/glbackend/gl_shader.cpp +++ b/source/glbackend/gl_shader.cpp @@ -39,8 +39,8 @@ ** */ #include -#include "glbackend.h" #include "glad/glad.h" +#include "glbackend.h" #include "gl_shader.h" #include "zstring.h" diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 442f86cc1..208678e91 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -1,6 +1,6 @@ #include -#include "glbackend.h" #include "glad/glad.h" +#include "glbackend.h" #include "gl_samplers.h" #include "gl_shader.h" diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index 15a6765c9..6a259687a 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -7,6 +7,7 @@ #include "gl_hwtexture.h" #include "gl_renderstate.h" #include "matrix.h" +#include "palentry.h" class FSamplerManager; class FShader; diff --git a/source/rr/src/anim.cpp b/source/rr/src/anim.cpp index 2b383664d..6b6441c73 100644 --- a/source/rr/src/anim.cpp +++ b/source/rr/src/anim.cpp @@ -499,7 +499,7 @@ int32_t Anim_Play(const char *fn) goto end_anim; } - paletteSetColorTable(ANIMPAL, ANIM_GetPalette()); + paletteSetColorTable(ANIMPAL, ANIM_GetPalette(), true); // setpalette(0L,256L,tempbuf); // setbrightness(ud.brightness>>2,tempbuf,2);