From 0fee12c29a36d3f36f731545098053b602bdc2cc Mon Sep 17 00:00:00 2001 From: uis Date: Sun, 28 Jan 2024 01:17:00 +0300 Subject: [PATCH] Move depth invalidation before swap Still has to figure out how to invalidate on maps without sky even when sky is disabled. --- cl_screen.c | 10 +++++++--- vid_sdl.c | 7 +++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cl_screen.c b/cl_screen.c index 32ea147b..a0e8bb35 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -2081,7 +2081,9 @@ static void SCR_DrawTouchscreenOverlay(void) } } -static const GLuint drawbuffers[6] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3, GL_STENCIL_ATTACHMENT, GL_DEPTH_ATTACHMENT}; +#ifndef USE_GLES2 +static const GLuint drawbuffers[4] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3}; +#endif void R_ClearScreen(qboolean fogcolor) { float clearcolor[4]; @@ -2102,10 +2104,12 @@ void R_ClearScreen(qboolean fogcolor) // to avoid clamping interfering with strange shadow volume // drawing orders // clear the screen - if(r_sky.integer && !r_refdef.view.isoverlay && r_fbdiscard.integer && qglInvalidateFramebuffer) { + #ifndef USE_GLES2 + if(r_sky.integer && !r_refdef.view.isoverlay && r_fbdiscard.integer > 1 && qglInvalidateFramebuffer) { invalidated = true; - qglInvalidateFramebuffer(GL_FRAMEBUFFER, 6, drawbuffers); + qglInvalidateFramebuffer(GL_FRAMEBUFFER, 4, drawbuffers); } + #endif GL_Clear((invalidated ? 0 : GL_COLOR_BUFFER_BIT) | GL_DEPTH_BUFFER_BIT | (vid.stencil ? GL_STENCIL_BUFFER_BIT : 0), clearcolor, 1.0f, 128); } diff --git a/vid_sdl.c b/vid_sdl.c index 151a73c5..03b72aa6 100644 --- a/vid_sdl.c +++ b/vid_sdl.c @@ -2894,6 +2894,9 @@ void VID_Shutdown (void) gl_platformextensions = ""; } +#ifndef USE_GLES2 +static const GLuint drawbuffers[] = {GL_DEPTH_STENCIL_ATTACHMENT/*GL_STENCIL_ATTACHMENT, GL_DEPTH_ATTACHMENT*/}; +#endif void VID_Finish (void) { #if SDL_MAJOR_VERSION == 1 @@ -2921,6 +2924,10 @@ void VID_Finish (void) CHECKGLERROR if (r_speeds.integer == 2 || gl_finish.integer) GL_Finish(); + #ifndef USE_GLES2 + if(r_fbdiscard.integer && qglInvalidateFramebuffer) + qglInvalidateFramebuffer(GL_FRAMEBUFFER, sizeof(drawbuffers)/sizeof(*drawbuffers), drawbuffers); + #endif #if SDL_MAJOR_VERSION != 1 { -- 2.39.2