ensure consistent shader state

This commit is contained in:
Alug committed 2024-01-18 17:03:00 +01:00
1 parent d7fe3272e2
commit 241108abc2
4 files changed
+23 -7

No files matched your search

+17 -1
View File
@@ -182,6 +182,9 @@ static void CV_screentextures_ONChange(void)
static void CV_grshaders_OnChange(void)
{
if (rendermode == render_opengl)
HWR_SetShaderState();
if ((rendermode == render_opengl) && (cv_grpaletterendering.value))
{
// can't do palette rendering without shaders, so update the state if needed
@@ -212,6 +215,17 @@ static void CV_grpalettedepth_OnChange(void)
HWR_SetPalette(pLocalPalette);
}
//
// Sets the shader state.
//
void HWR_SetShaderState(void)
{
INT32 state = cv_grshaders.value;
HWD.pfnSetSpecialState(HWD_SET_SHADERS, (INT32)state);
HWD.pfnSetShader(0);
}
// ==========================================================================
// Globals
// ==========================================================================
@@ -6440,7 +6454,9 @@ void HWR_Startup(void)
HWD.pfnKillShaders();
if (!HWD.pfnLoadShaders())
gr_shadersavailable = false;
HWR_SetShaderState();
HWR_TogglePaletteRendering();
if (msaa)
+2
View File
@@ -167,6 +167,8 @@ RGBA_t *HWR_GetTexturePalette(void);
// hw_trick.c
void HWR_CorrectSWTricks(void);
void HWR_SetShaderState(void);
// Console variables
extern consvar_t cv_grshaders;
extern consvar_t cv_grfofcut;
+4 -4
View File
@@ -3407,10 +3407,9 @@ EXPORT void HWRAPI(DrawScreenTexture)(int tex, FSurfaceInfo *surf, FBITFIELD pol
pglBindTexture(GL_TEXTURE_2D, screenTextures[tex]);
if (surf)
PreparePolygon(surf, NULL, polyflags);
else
Shader_SetUniforms(NULL, NULL, NULL, NULL); // prepare shader, if it is enabled
PreparePolygon(surf, NULL, surf ? polyflags : (PF_NoDepthTest));
if (!surf)
pglColor4ubv(white);
pglColor4ubv(white);
@@ -3705,6 +3704,7 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int tex, int width, int height)
clearColour.red = clearColour.green = clearColour.blue = 0;
clearColour.alpha = 1;
ClearBuffer(true, false, false, &clearColour);
SetBlend(PF_NoDepthTest);
pglBindTexture(GL_TEXTURE_2D, screenTextures[tex]);
-2
View File
@@ -1487,11 +1487,9 @@ void I_FinishUpdate(void)
if (HWR_ShouldUsePaletteRendering())
{
HWD.pfnMakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2);
HWD.pfnSetSpecialState(HWD_SET_SHADERS, 1);
HWD.pfnSetShader(8);
HWD.pfnDrawScreenTexture(HWD_SCREENTEXTURE_GENERIC2, NULL, 0);
HWD.pfnUnSetShader();
HWD.pfnSetSpecialState(HWD_SET_SHADERS, 0);
}
OglSdlFinishUpdate(cv_vidwait.value);
}