Improve backbuffer depth buffer.

- Setting the depth buffer for the backbuffer is now done as a boolean instead of a bit depth integer, in love.conf or love.window.setMode.
- Error if depth writes are enabled when the active canvas setup or backbuffer does not have a depth buffer (now it matches stencil behaviour).
- Don't allocate a backbuffer depth-stencil buffer if they're not requested. Metal also determines the format for that buffer based on which combination of depth and stencil is requested. OpenGL still has to allocate the depth-stencil buffer for the backbuffer all the time, because changing it requires the context to be recreated.
This commit is contained in:
Sasha Szpakowski
2024-01-06 15:21:06 -04:00
parent 621a7547d2
commit aaab9791d5
11 changed files with 183 additions and 110 deletions
+5 -6
View File
@@ -127,8 +127,7 @@ void Window::setGLFramebufferAttributes(bool sRGB)
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 0);
// Always use 24/8 depth/stencil (make sure any Graphics implementations
// that have their own backbuffer match this, too).
// Always use 24/8 depth/stencil.
// Changing this after initial window creation would need the context to be
// destroyed and recreated, which we really don't want.
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
@@ -639,12 +638,12 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
context = (void *) SDL_Metal_GetLayer(metalView);
#endif
graphics->setMode(context, (int) scaledw, (int) scaledh, pixelWidth, pixelHeight, f.stencil, f.msaa);
graphics->setMode(context, (int) scaledw, (int) scaledh, pixelWidth, pixelHeight, f.stencil, f.depth, f.msaa);
this->settings.msaa = graphics->getBackbufferMSAA();
}
else
{
graphics->setViewportSize((int) scaledw, (int) scaledh, pixelWidth, pixelHeight);
graphics->backbufferChanged((int) scaledw, (int) scaledh, pixelWidth, pixelHeight, f.stencil, f.depth, f.msaa);
}
}
@@ -687,7 +686,7 @@ bool Window::onSizeChanged(int width, int height)
{
double scaledw, scaledh;
fromPixels((double) pixelWidth, (double) pixelHeight, scaledw, scaledh);
graphics->setViewportSize((int) scaledw, (int) scaledh, pixelWidth, pixelHeight);
graphics->backbufferChanged((int) scaledw, (int) scaledh, pixelWidth, pixelHeight);
}
return true;
@@ -771,7 +770,7 @@ void Window::updateSettings(const WindowSettings &newsettings, bool updateGraphi
{
double scaledw, scaledh;
fromPixels((double) pixelWidth, (double) pixelHeight, scaledw, scaledh);
graphics->setViewportSize((int) scaledw, (int) scaledh, pixelWidth, pixelHeight);
graphics->backbufferChanged((int) scaledw, (int) scaledh, pixelWidth, pixelHeight);
}
}