-
Notifications
You must be signed in to change notification settings - Fork 63
tr_sky: clear color buffer when fastsky is enabled, do not clear screen by default #473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
It only clears color buffer and does not clear other buffers if r_fastsky is enabled for performance and r_clear is disabled to workaround Nvidia issue described in #472
How about combining this with the Also it seems the default value for |
2605037
to
d8949e2
Compare
Done. An alternative way would be to do
Done. We would also have to edit Unvanquished presets as well. This code was successfully tested with Nvidia Quadro K1100M GPU using Nvidia 390.143 driver on Linux 5.8.0-53-generic on Ubuntu 20.04.2. |
Hmm, doing this would probably just bring back the bug. |
Yes, that's what I was trying to say. Do all the clearing in one place, the place where it is now.
Well if you have both the affected hardware+drivers, and use |
The thing is that, when I clear color buffer in Basically the clearing code in int clearBits = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
// clear relevant buffers
if ( r_clear->integer ) {
clearBits |= GL_COLOR_BUFFER_BIT;
}
glClear( clearBits ); If we do: int clearBits = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
// clear relevant buffers
if ( r_clear->integer || r_fastsky->integer ) {
clearBits |= GL_COLOR_BUFFER_BIT;
}
glClear( clearBits ); I expect the bug to be back, because it would run with
For my K1100M GPU, yes |
I confirm, doing this in int clearBits = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
// clear relevant buffers
if ( r_clear->integer || r_fastsky->integer ) {
clearBits |= GL_COLOR_BUFFER_BIT;
}
glClear( clearBits ); While doing both this in int clearBits = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
// clear relevant buffers
if ( r_clear->integer ) {
clearBits |= GL_COLOR_BUFFER_BIT;
}
glClear( clearBits ); and that in if ( r_fastsky->integer )
{
if ( ! r_clear->integer )
{
glClear( GL_COLOR_BUFFER_BIT );
}
// …
} |
I confirm the Geforce 8400 GS rev.2 (from 2007) is affected as well, I own a PCI version of it (which is then even slower than freem's one) Using fast sky on that particularly slow GPU brings ~7 fps more when there is a sky to draw. Fast sky, complete clearing (color, stencil, depth clearing): I noticed not clearing saved 2 fps on that particularly slow GPU, it's the first time I see a difference between with or without clearing: No clearing: Complete clearing: Because this GPU is super slow (while being featureful: OpenGL 3, 512M of VRAM), I used the I was not able to test the performance of “only clear color buffer on fast sky” because of #474, the tests were done with 0.52 release build. On my laptop running Ubuntu 20.04, Nvidia 390 driver and 5.8 kernel, I can test properly the PR, but the hardware is too much performant to get significant numbers on clearing performance. At least we know it fixes the bug. |
I just thought about something, maybe that patch workarounds the bug on that plat23 scene only because there is no sky on that alien base, so the color buffer clearing called by fastsky code does not run. I still believe this patch is good to have because fastsky code explicitely requires color buffer clearing to work, and with that code, color buffer clearing would be only done when fastsky code runs (if |
d8949e2
to
ffba73e
Compare
ffba73e
to
d47e63d
Compare
Some comments from here:
|
Or maybe @VReaperV being a sky masterwizard knows how to make an alternative sky code that just paints to black the sky area without clearing (and as fast as clearing) when |
We can probably put it as a uniform or define in the skybox shader and just set output color to black. I doubt it would be faster than doing a glClear() though. |
Yes, the idea is to skip entirely the skybox shader. |
I'm not sure there's really any way to do that other than by just clearing the framebuffer (well, any sane way that is). |
Another implementation can be: diff --git a/src/engine/renderer/tr_backend.cpp b/src/engine/renderer/tr_backend.cpp
index 39665b4ef..775e5b7ec 100644
--- a/src/engine/renderer/tr_backend.cpp
+++ b/src/engine/renderer/tr_backend.cpp
@@ -5623,7 +5623,7 @@ const RenderCommand *ClearBufferCommand::ExecuteSelf( ) const
GL_State( GLS_DEFAULT );
// clear relevant buffers
- if ( r_clear->integer ) {
+ if ( r_clear->integer || r_fastsky->integer ) {
clearBits |= GL_COLOR_BUFFER_BIT;
} There would be no question about the clearing being done at the right place or not. |
d47e63d
to
0995da1
Compare
I removed the archive flag on |
0995da1
to
0a8caf8
Compare
This works fine on my end with all 4 combinations of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
0a8caf8
to
de4e6e9
Compare
Clear color buffer but nothing else, even if
r_clear
is disabled, there can be issues when enabling complete clearing by defaultwith Nvidia proprietary drivers. So clearing the color buffer there prevents void effect in skipped sky without needing to enable
r_clear
.Anyway, we may want to do it (and even force a color) on purpose, this would mean clearing is the explicit way to draw the fast sky.
This makes possible to workaround #472 by keeping
r_clear
disabled while clearing the color buffer whenr_fastsky
is enabled but not clearing other buffers (because disabledr_clear
).This DOES NOT fix #472. We still have to figure out why we get what looks like precision loss on Nvidia proprietary driver.