screw it, revamp the whole thing

blurgh like this theres never a condition where paletteshader shit runs even if you have shaders turned off and stuff
This commit is contained in:
alufolie91 committed 2023-11-13 22:44:23 +01:00
1 parent fde184b7a7
commit 2ffc7293af
5 files changed
+46 -53

No files matched your search

+30 -30
View File
@@ -61,15 +61,12 @@ struct hwdriver_s hwdriver;
// Commands and console variables
// ==========================================================================
// keep the state here instead of in the cv var, so it always matches the state in r_opengl.c
int gr_use_palette_shader = 0;
static void CV_filtermode_ONChange(void);
static void CV_anisotropic_ONChange(void);
static void CV_screentextures_ONChange(void);
static void CV_useCustomShaders_ONChange(void);
static void CV_grpaletteshader_OnChange(void);
static void CV_grshaders_OnChange(void);
static void CV_flashpal_OnChange(void);
static void CV_Gammaxxx_ONChange(void);
static CV_PossibleValue_t grgamma_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}};
@@ -140,12 +137,12 @@ static INT32 current_bsp_culling_distance = 0;
consvar_t cv_grscreentextures = {"gr_screentextures", "On", CV_CALL, CV_OnOff,
CV_screentextures_ONChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grshaders = {"gr_shaders", "On", CV_CALL|CV_SAVE, CV_OnOff, CV_grshaders_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grshaders = {"gr_shaders", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grusecustomshaders = {"gr_usecustomshaders", "Yes", CV_CALL|CV_SAVE, CV_OnOff, CV_useCustomShaders_ONChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grpaletteshader = {"gr_paletteshader", "Off", CV_CALL|CV_SAVE, CV_OnOff, CV_grpaletteshader_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grflashpal = {"gr_flashpal", "On", CV_CALL|CV_SAVE, CV_OnOff, CV_grshaders_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grflashpal = {"gr_flashpal", "On", CV_CALL|CV_SAVE, CV_OnOff, CV_flashpal_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grmdls = {"gr_mdls", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grfallbackplayermodel = {"gr_fallbackplayermodel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -155,6 +152,12 @@ consvar_t cv_grspritebillboarding = {"gr_spritebillboarding", "On", CV_SAVE, CV_
consvar_t cv_grfakecontrast = {"gr_fakecontrast", "Standard", CV_SAVE, grfakecontrast_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grslopecontrast = {"gr_slopecontrast", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
boolean HWR_ShouldUsePaletteRendering(void)
{
return (cv_grpaletteshader.value && cv_grshaders.value);
}
static void CV_filtermode_ONChange(void)
{
if (rendermode == render_opengl)
@@ -186,22 +189,20 @@ static void CV_grpaletteshader_OnChange(void)
{
if (rendermode == render_opengl)
{
if (cv_grshaders.value)
{
InitPalette(0, false);
HWD.pfnSetSpecialState(HWD_SET_PALETTE_SHADER_ENABLED, cv_grpaletteshader.value);
gr_use_palette_shader = cv_grpaletteshader.value;
InitPalette(0, false);
if (HWR_ShouldUsePaletteRendering())
{
V_SetPalette(0);
}
}
}
}
static void CV_grshaders_OnChange(void)
static void CV_flashpal_OnChange(void)
{
if (rendermode == render_opengl)
{
if (cv_grpaletteshader.value)
if (HWR_ShouldUsePaletteRendering())
{
InitPalette(0, false);
V_SetPalette(0);
@@ -209,8 +210,6 @@ static void CV_grshaders_OnChange(void)
}
}
// change the palette directly to see the change
static void CV_Gammaxxx_ONChange(void)
{
@@ -218,6 +217,7 @@ static void CV_Gammaxxx_ONChange(void)
V_SetPalette(0);
}
// ==========================================================================
// Globals
// ==========================================================================
@@ -533,7 +533,7 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col
Surface->LightInfo.fade_start = (colormap != NULL) ? colormap->fadestart : 0;
Surface->LightInfo.fade_end = (colormap != NULL) ? colormap->fadeend : 31;
if (gr_use_palette_shader && cv_grshaders.value)
if (HWR_ShouldUsePaletteRendering())
{
if (!colormap)
{
@@ -887,7 +887,7 @@ void HWR_RenderPlane(extrasubsector_t *xsub, boolean isceiling, fixed_t fixedhei
else if (PolyFlags & PF_Ripple)
HWD.pfnSetShader(5); // water shader
else
HWD.pfnSetShader(gr_use_palette_shader ? 9 : 1); // floor shader
HWD.pfnSetShader(HWR_ShouldUsePaletteRendering() ? 9 : 1); // floor shader
PolyFlags |= PF_ColorMapped;
}
@@ -1046,7 +1046,7 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf)
if (cv_grshaders.value && gr_shadersavailable)
{
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 2); // wall shader
HWD.pfnSetShader(HWR_ShouldUsePaletteRendering() ? 10 : 2); // wall shader
}
HWD.pfnDrawPolygon(&pSurf, wallVerts, 4, i|PF_Modulated|PF_Decal, false);
@@ -1084,7 +1084,7 @@ void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend
if (cv_grshaders.value && gr_shadersavailable)
{
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 2); // wall shader
HWD.pfnSetShader(HWR_ShouldUsePaletteRendering() ? 10 : 2); // wall shader
blendmode |= PF_ColorMapped;
}
@@ -3332,7 +3332,7 @@ void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t
if (cv_grshaders.value && gr_shadersavailable)
{
HWD.pfnSetShader(gr_use_palette_shader ? 9 : 1); // floor shader
HWD.pfnSetShader(HWR_ShouldUsePaletteRendering() ? 9 : 1); // floor shader
blendmode |= PF_ColorMapped;
}
@@ -4149,7 +4149,7 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t
if (cv_grshaders.value && gr_shadersavailable)
{
HWD.pfnSetShader(gr_use_palette_shader ? 9 : 1); // floor shader
HWD.pfnSetShader(HWR_ShouldUsePaletteRendering() ? 9 : 1); // floor shader
}
HWD.pfnDrawPolygon(&sSurf, swallVerts, 4, PF_Translucent|PF_Modulated, false);
@@ -4521,7 +4521,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
if (cv_grshaders.value && gr_shadersavailable)
{
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 3); // sprite shader
HWD.pfnSetShader(HWR_ShouldUsePaletteRendering() ? 10 : 3); // sprite shader
blend |= PF_ColorMapped;
}
@@ -4566,7 +4566,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
if (cv_grshaders.value && gr_shadersavailable)
{
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 3); // sprite shader
HWD.pfnSetShader(HWR_ShouldUsePaletteRendering() ? 10 : 3); // sprite shader
blend |= PF_ColorMapped;
}
@@ -4724,7 +4724,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
if (cv_grshaders.value && gr_shadersavailable)
{
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 3); // sprite shader
HWD.pfnSetShader(HWR_ShouldUsePaletteRendering() ? 10 : 3); // sprite shader
blend |= PF_ColorMapped;
}
@@ -4829,7 +4829,7 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr)
if (cv_grshaders.value && gr_shadersavailable)
{
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 3); // sprite shader
HWD.pfnSetShader(HWR_ShouldUsePaletteRendering() ? 10 : 3); // sprite shader
blend |= PF_ColorMapped;
}
@@ -6479,7 +6479,7 @@ void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend,
{
if (cv_grshaders.value && gr_shadersavailable)
{
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 2); // wall shader
HWD.pfnSetShader(HWR_ShouldUsePaletteRendering() ? 10 : 2); // wall shader
blendmode |= PF_ColorMapped;
}
}
@@ -6515,7 +6515,7 @@ void HWR_DoPostProcessor(player_t *player)
// Armageddon Blast Flash!
// Could this even be considered postprocessor?
if ((player->flashcount) && !(cv_grshaders.value && gr_use_palette_shader && cv_grflashpal.value))
if ((player->flashcount) && !(HWR_ShouldUsePaletteRendering() && cv_grflashpal.value))
{
FOutVector v[4];
FSurfaceInfo Surf;
@@ -6642,7 +6642,7 @@ void HWR_MakeScreenFinalTexture(void)
void HWR_DrawScreenFinalTexture(int width, int height)
{
if (gr_use_palette_shader)
if (HWR_ShouldUsePaletteRendering())
HWD.pfnSetShader(11); //post processing
HWD.pfnDrawScreenFinalTexture(width, height);
}
-2
View File
@@ -44,8 +44,6 @@ extern float gr_basewindowcenterx, gr_basewindowcentery;
extern unsigned msaa;
extern boolean a2c;
extern gr_use_palette_shader;
extern FTransform atransform;
extern float gr_viewsin, gr_viewcos;
+9 -14
View File
@@ -629,7 +629,6 @@ static boolean gl_shaderprogramchanged = true;
static boolean gl_batching = false;// are we currently collecting batches?
static GLint gl_palette[768];
static INT32 gl_use_palette_shader = 0;
boolean gl_palette_initialized = false;
static INT32 gl_enable_screen_textures = 1;
@@ -1251,7 +1250,7 @@ EXPORT boolean HWRAPI(InitCustomShaders) (void)
KillShaders();
return LoadShaders();
if (gl_use_palette_shader)
if (HWR_ShouldUsePaletteRendering())
{
InitPalette(0, false);
}
@@ -2318,7 +2317,7 @@ static int comparePolygons(const void *p1, const void *p2)
diff = poly1->texNum - poly2->texNum;
if (diff != 0) return diff;
if (gl_use_palette_shader)
if (HWR_ShouldUsePaletteRendering())
{
diff = poly1->surf.LightTableId - poly2->surf.LightTableId;
if (diff != 0) return diff;
@@ -2461,7 +2460,7 @@ EXPORT void HWRAPI(RenderBatches) (precise_t *sSortTime, precise_t *sDrawTime, i
if (gl_allowshaders)
{
Shader_Load(&currentSurfaceInfo, &firstPoly, &firstTint, &firstFade);
if (gl_use_palette_shader)
if (HWR_ShouldUsePaletteRendering())
{
pglActiveTexture(GL_TEXTURE2);// this stuff could be done better but gonna do it quick like this for now
pglBindTexture(GL_TEXTURE_2D, currentSurfaceInfo.LightTableId);
@@ -2578,7 +2577,7 @@ EXPORT void HWRAPI(RenderBatches) (precise_t *sSortTime, precise_t *sDrawTime, i
changeState = true;
changePolyFlags = true;
}
if ((gl_allowshaders) && (gl_use_palette_shader))
if ((gl_allowshaders) && (HWR_ShouldUsePaletteRendering()))
{
if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba ||
currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba ||
@@ -2592,7 +2591,7 @@ EXPORT void HWRAPI(RenderBatches) (precise_t *sSortTime, precise_t *sDrawTime, i
changeSurfaceInfo = true;
}
}
else if ((gl_allowshaders) && (!gl_use_palette_shader))
else if ((gl_allowshaders) && (!HWR_ShouldUsePaletteRendering()))
{
if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba ||
currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba ||
@@ -2723,7 +2722,7 @@ EXPORT void HWRAPI(RenderBatches) (precise_t *sSortTime, precise_t *sDrawTime, i
Shader_Load(&nextSurfaceInfo, &poly, &tint, &fade);
if (gl_use_palette_shader)
if (HWR_ShouldUsePaletteRendering())
{
pglActiveTexture(GL_TEXTURE2);// this stuff could be done better but gonna do it quick like this for now
pglBindTexture(GL_TEXTURE_2D, nextSurfaceInfo.LightTableId);
@@ -2834,7 +2833,7 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUI
fade.alpha = byte2float[pSurf->FadeColor.s.alpha];
}
if (gl_use_palette_shader && gl_allowshaders)
if (HWR_ShouldUsePaletteRendering() && gl_allowshaders)
{
pglActiveTexture(GL_TEXTURE2);
pglBindTexture(GL_TEXTURE_2D, pSurf->LightTableId);
@@ -3182,10 +3181,6 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
break;
}
break;
case HWD_SET_PALETTE_SHADER_ENABLED:
gl_use_palette_shader = Value;
break;
case HWD_SET_TEXTUREFILTERMODE:
switch (Value)
@@ -4258,7 +4253,7 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
// prepare shader, if it is enabled
Shader_SetUniforms(NULL, NULL, NULL, NULL);
if (gl_use_palette_shader && cv_grshaders.value)
if (HWR_ShouldUsePaletteRendering())
{
pglUseProgram(gl_shaderprograms[8].program); // palette shader
pglActiveTexture(GL_TEXTURE1);
@@ -4272,7 +4267,7 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
tex_downloaded = finalScreenTexture;
if (gl_use_palette_shader && cv_grshaders.value)
if (HWR_ShouldUsePaletteRendering())
{
pglUseProgram(0);
pglActiveTexture(GL_TEXTURE0);
+3 -3
View File
@@ -245,7 +245,7 @@ void ST_doPaletteStuff(void)
palette = 0;
#ifdef HWRENDER
if ((rendermode == render_opengl && !cv_grpaletteshader.value) || (rendermode == render_opengl && gr_use_palette_shader && !cv_grflashpal.value))
if ((rendermode == render_opengl && !cv_grpaletteshader.value) || (rendermode == render_opengl && HWR_ShouldUsePaletteRendering() && !cv_grflashpal.value))
palette = 0; // No flashpals here in OpenGL
#endif
@@ -254,7 +254,7 @@ void ST_doPaletteStuff(void)
st_palette = palette;
#ifdef HWRENDER
if (rendermode == render_soft || (rendermode == render_opengl && gr_use_palette_shader && cv_grflashpal.value))
if (rendermode == render_soft || (rendermode == render_opengl && HWR_ShouldUsePaletteRendering() && cv_grflashpal.value))
#else
if (rendermode != render_none)
#endif
@@ -2207,7 +2207,7 @@ void ST_Drawer(void)
//25/08/99: Hurdler: palette changes is done for all players,
// not only player1! That's why this part
// of code is moved somewhere else.
if (rendermode == render_soft || (rendermode == render_opengl && gr_use_palette_shader && cv_grflashpal.value))
if (rendermode == render_soft || (rendermode == render_opengl && HWR_ShouldUsePaletteRendering() && cv_grflashpal.value))
#endif
if (rendermode != render_none) ST_doPaletteStuff();
+4 -4
View File
@@ -203,7 +203,7 @@ void V_SetPalette(INT32 palettenum)
#ifdef HWRENDER
if (rendermode != render_soft && rendermode != render_none) {
// in palette rendering mode, we already manage our palette ourselves
if (gr_use_palette_shader)
if (HWR_ShouldUsePaletteRendering())
{
// reset our palette lookups n shit
gl_palette_initialized = false;
@@ -225,14 +225,14 @@ void V_SetPaletteLump(const char *pal)
LoadPalette(pal);
#ifdef HWRENDER
if (rendermode != render_soft && rendermode != render_none) {
if (gr_use_palette_shader)
if (HWR_ShouldUsePaletteRendering())
{
// reset our palette lookups n shit
gl_palette_initialized = false;
InitPalette(0, false);
}
else
HWR_SetPalette(pLocalPalette);
HWR_SetPalette(pLocalPalette);
}
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
else