Allow a depth/stencil canvas to be active without a color canvas.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-12-03 19:33:48 -04:00
parent 0c1c78fe29
commit cbcb1a8606
4 changed files with 65 additions and 23 deletions
+34 -5
View File
@@ -405,6 +405,7 @@ void Graphics::setCanvasInternal(const RenderTargets &rts, int w, int h, int pix
OpenGL::TempDebugGroup debuggroup("setCanvas(...)");
flushStreamDraws();
endPass();
bindCachedFBO(rts);
@@ -501,6 +502,32 @@ void Graphics::endPass()
}
}
if (depthstencil != nullptr && depthstencil->getMSAA() > 1 && depthstencil->isReadable())
{
gl.bindFramebuffer(OpenGL::FRAMEBUFFER_DRAW, ((Canvas *) depthstencil)->getFBO());
if (GLAD_APPLE_framebuffer_multisample)
glResolveMultisampleFramebufferAPPLE();
else
{
int mip = rts.depthStencil.mipmap;
int w = depthstencil->getPixelWidth(mip);
int h = depthstencil->getPixelHeight(mip);
PixelFormat format = depthstencil->getPixelFormat();
GLbitfield mask = 0;
if (isPixelFormatDepth(format))
mask |= GL_DEPTH_BUFFER_BIT;
if (isPixelFormatStencil(format))
mask |= GL_STENCIL_BUFFER_BIT;
if (mask != 0)
glBlitFramebuffer(0, 0, w, h, 0, 0, w, h, mask, GL_NEAREST);
}
}
for (const auto &rt : rts.colors)
{
if (rt.canvas->getMipmapMode() == Canvas::MIPMAPS_AUTO && rt.mipmap == 0)
@@ -709,11 +736,13 @@ void Graphics::bindCachedFBO(const RenderTargets &targets)
}
else
{
int mip = targets.colors[0].mipmap;
int w = targets.colors[0].canvas->getPixelWidth(mip);
int h = targets.colors[0].canvas->getPixelHeight(mip);
int msaa = targets.colors[0].canvas->getMSAA();
int reqmsaa = targets.colors[0].canvas->getRequestedMSAA();
RenderTarget firstRT = targets.getFirstTarget();
int mip = firstRT.mipmap;
int w = firstRT.canvas->getPixelWidth(mip);
int h = firstRT.canvas->getPixelHeight(mip);
int msaa = firstRT.canvas->getMSAA();
int reqmsaa = firstRT.canvas->getRequestedMSAA();
RenderTarget depthstencil = targets.depthStencil;