- got rid of the software rendering blend tables.

This commit is contained in:
Christoph Oelckers 2020-03-29 17:23:57 +02:00
parent 41545b644a
commit 5af0217db7
8 changed files with 2 additions and 143 deletions

View file

@ -165,7 +165,6 @@ void scrLoadPalette(void)
DICTNODE *pTrans = gSysRes.Lookup("TRANS", "TLU");
if (!pTrans)
ThrowError("TRANS.TLU not found");
blendtable[0] = (char*)gSysRes.Lock(pTrans);
paletteloaded |= PALETTE_TRANSLUC;
palettePostLoadTables();
@ -241,7 +240,6 @@ void scrInit(void)
void scrUnInit(void)
{
memset(palookup, 0, sizeof(palookup));
memset(blendtable, 0, sizeof(blendtable));
}

View file

@ -541,7 +541,6 @@ EXTERN int16_t numshades;
EXTERN char *palookup[MAXPALOOKUPS];
extern uint8_t *basepaltable[MAXBASEPALS];
EXTERN uint8_t paletteloaded;
EXTERN char *blendtable[MAXBLENDTABS];
EXTERN uint8_t whitecol, redcol, blackcol;
EXTERN int32_t maxspritesonscreen;

View file

@ -27,8 +27,6 @@
extern uint8_t curbasepal;
#define paletteGetBlendTable(blend) (blendtable[blend])
extern uint8_t PaletteIndexFullbrights[32];
@ -56,8 +54,6 @@ void paletteMakeLookupTable(int32_t palnum, const char *remapbuf, uint8_t r, uin
void paletteSetColorTable(int32_t id, uint8_t const *table, bool transient = false);
void paletteFreeColorTable(int32_t id);
void paletteFreeColorTables();
void paletteSetBlendTable(int32_t blend, const char *tab);
void paletteFreeBlendTable(int32_t blend);
int32_t paletteSetLookupTable(int32_t palnum, const uint8_t *shtab);
void paletteFreeLookupTable(int32_t palnum);

View file

@ -3116,7 +3116,6 @@ static int32_t defsparser(scriptfile *script)
break;
}
paletteSetBlendTable(id, (char*)blendbuf.Data());
didLoadTransluc = 1;
break;
}
@ -3132,15 +3131,6 @@ static int32_t defsparser(scriptfile *script)
break;
}
char const * const sourcetable = blendtable[source];
if (EDUKE32_PREDICT_FALSE(sourcetable == NULL))
{
initprintf("Error: blendtable: Source blendtable does not exist on line %s:%d\n",
script->filename, scriptfile_getlinum(script,cmdtokptr));
break;
}
paletteSetBlendTable(id, sourcetable);
didLoadTransluc = 1;
#ifdef USE_OPENGL
@ -3150,8 +3140,6 @@ static int32_t defsparser(scriptfile *script)
}
case T_UNDEF:
{
paletteFreeBlendTable(id);
didLoadTransluc = 0;
if (id == 0)
paletteloaded &= ~PALETTE_TRANSLUC;
@ -3382,9 +3370,6 @@ static int32_t defsparser(scriptfile *script)
break;
}
for (bssize_t i = id0; i <= id1; i++)
paletteFreeBlendTable(i);
if (id0 == 0)
paletteloaded &= ~PALETTE_TRANSLUC;
}

View file

@ -2211,10 +2211,6 @@ void engineUnInit(void)
}
Bmemset(palookup, 0, sizeof(palookup));
for (bssize_t i=0; i<MAXBLENDTABS; i++)
Xfree(blendtable[i]);
Bmemset(blendtable, 0, sizeof(blendtable));
for (bssize_t i=1; i<MAXBASEPALS; i++)
Xfree(basepaltable[i]);
Bmemset(basepaltable, 0, sizeof(basepaltable));

View file

@ -174,37 +174,6 @@ void paletteLoadFromDisk(void)
return;
paletteloaded |= PALETTE_SHADE;
// PALETTE_TRANSLUC
char * const transluc = blendtable[0] = (char *) Xcalloc(256, 256);
// Read translucency (blending) table.
if (lamedukep)
{
for (bssize_t i=0; i<255; i++)
{
// NOTE: LameDuke's table doesn't have the last row or column (i==255).
// Read the entries above and on the diagonal, if the table is
// thought as being row-major.
if (read_and_test(fil, &transluc[256*i + i + 1], 255-i))
return;
// Duplicate the entries below the diagonal.
for (bssize_t j=i+1; j<256; j++)
transluc[256*j + i] = transluc[256*i + j];
}
for (bssize_t i=0; i<256; i++)
transluc[256*i + i] = i;
}
else
{
if (read_and_test(fil, transluc, 65536))
return;
}
paletteloaded |= PALETTE_TRANSLUC;
@ -231,9 +200,6 @@ void paletteLoadFromDisk(void)
return;
}
if (paletteGetBlendTable(blendnum) != NULL)
initprintf("Warning: duplicate blending table index %3d encountered\n", blendnum);
if (read_and_test(fil, tab, 256*256))
{
initprintf("Warning: failed reading additional blending table\n");
@ -241,7 +207,6 @@ void paletteLoadFromDisk(void)
return;
}
paletteSetBlendTable(blendnum, tab);
setBlendFactor(blendnum, DetermineTranslucency((const uint8_t*)tab));
}
@ -266,9 +231,6 @@ void palettePostLoadTables(void)
globalpal = 0;
globalpalwritten = palookup[0];
// Do we still need these?
//setpalookupaddress(globalpalwritten);
//fixtransluscence(FP_OFF(blendtable[0]));
char const * const palookup0 = palookup[0];
@ -332,21 +294,6 @@ void paletteFixTranslucencyMask(void)
for (bssize_t j=0; j<numshades; j++)
thispalookup[(j<<8) + 255] = 255;
}
// fix up translucency table so that transluc(255,x)
// and transluc(x,255) is black instead of purple.
for (auto transluc : blendtable)
{
if (transluc == NULL)
continue;
for (bssize_t j=0; j<255; j++)
{
transluc[(255<<8) + j] = transluc[(blackcol<<8) + j];
transluc[255 + (j<<8)] = transluc[blackcol + (j<<8)];
}
transluc[(255<<8) + 255] = transluc[(blackcol<<8) + blackcol];
}
}
// Load LOOKUP.DAT, which contains lookup tables and additional base palettes.
@ -432,26 +379,6 @@ static void maybe_alloc_palookup(int32_t palnum)
}
}
void paletteSetBlendTable(int32_t blend, const char *tab)
{
if (blendtable[blend] == NULL)
blendtable[blend] = (char *) Xmalloc(256*256);
Bmemcpy(blendtable[blend], tab, 256*256);
}
void paletteFreeBlendTable(int32_t const blend)
{
DO_FREE_AND_NULL(blendtable[blend]);
}
#ifdef LUNATIC
const char *(paletteGetBlendTable) (int32_t blend)
{
return blendtable[blend];
}
#endif
#ifdef USE_OPENGL
glblend_t const nullglblend =
{
@ -687,21 +614,14 @@ void paletteFreeColorTables()
// 32: apply brightness to scene in OpenGL
void videoSetPalette(int dabrightness, int dapalid, ESetPalFlags flags)
{
int32_t i, j;
const uint8_t* dapal;
int32_t paldidchange;
// uint32_t lastbright = curbrightness;
// Bassert((flags&4)==0); // What is so bad about this flag?
int32_t i;
if (/*(unsigned)dapalid >= MAXBASEPALS ||*/ basepaltable[dapalid] == NULL)
dapalid = 0;
paldidchange = (curbasepal != dapalid || basepalreset);
curbasepal = dapalid;
basepalreset = 0;
dapal = basepaltable[curbasepal];
auto dapal = basepaltable[curbasepal];
// In-scene brightness mode for RR's thunderstorm. This shouldn't affect the global gamma ramp.
if ((videoGetRenderMode() >= REND_POLYMOST) && (flags & Pal_SceneBrightness))
@ -712,7 +632,6 @@ void videoSetPalette(int dabrightness, int dapalid, ESetPalFlags flags)
{
r_scenebrightness = 0;
}
j = 0; // Assume that the backend can do it.
for (i = 0; i < 256; i++)
{

View file

@ -1,21 +0,0 @@
#version 330
//s_texture points to an indexed color texture
uniform sampler2D s_texture;
//s_palette is the palette texture
uniform sampler2D s_palette;
in vec2 v_texCoord;
out vec4 FragColor;
const float c_paletteScale = 255.0/256.0;
const float c_paletteOffset = 0.5/256.0;
void main()
{
vec4 color = texture(s_texture, v_texCoord.xy);
color.r = c_paletteOffset + c_paletteScale*color.r;
color.rgb = texture(s_palette, color.rg).rgb;
FragColor = color;
}

View file

@ -1,13 +0,0 @@
#version 330
in vec4 i_vertPos;
in vec4 i_texCoord;
out vec2 v_texCoord;
void main()
{
gl_Position = i_vertPos;
v_texCoord = i_texCoord.st;
}