]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Move depth invalidation before swap
authoruis <uis9936@gmail.com>
Sat, 27 Jan 2024 22:17:00 +0000 (01:17 +0300)
committeruis <uis9936@gmail.com>
Sat, 27 Jan 2024 22:17:00 +0000 (01:17 +0300)
Still has to figure out how to invalidate on maps without sky even when
sky is disabled.

cl_screen.c
vid_sdl.c

index 32ea147bdceab9367b03539a3939a16c94d3864d..a0e8bb3566430caabc980dea04523f15e6048b42 100644 (file)
@@ -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);
 }
 
index 151a73c5920bd8a66756dc7d8cfbafe82f89075d..03b72aa6cebf33226461728d73db68424da201ab 100644 (file)
--- 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
 {