Mesa (main): wgl, d3d12: Handle front buffer writes for double-buffered MSAA surfaces backed by swapchains
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jun 1 23:31:53 UTC 2022
Module: Mesa
Branch: main
Commit: 1ef329b825c27871cec86b17bf49d9e4d0eb1637
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1ef329b825c27871cec86b17bf49d9e4d0eb1637
Author: Jesse Natalie <jenatali at microsoft.com>
Date: Thu Apr 28 13:53:58 2022 -0700
wgl, d3d12: Handle front buffer writes for double-buffered MSAA surfaces backed by swapchains
We don't need to go as far as the fake front thing when MSAA is being used, because the
swapchain (single-sampled) is already decoupled from the app render buffers. But we do
need to direct the frontbuffer flush to the single-sampled back buffer, and then present
the back buffer. We also need to swap the buffers when we do this, so the next blit
targets the former front buffer.
Reviewed-by: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16227>
---
src/gallium/frontends/wgl/stw_st.c | 34 +++++++++++++++++++++++-----------
1 file changed, 23 insertions(+), 11 deletions(-)
diff --git a/src/gallium/frontends/wgl/stw_st.c b/src/gallium/frontends/wgl/stw_st.c
index 3ff97338eb3..7050a4e24b9 100644
--- a/src/gallium/frontends/wgl/stw_st.c
+++ b/src/gallium/frontends/wgl/stw_st.c
@@ -160,11 +160,15 @@ stw_st_framebuffer_validate_locked(struct st_context_iface *stctx,
/* As of now, the only stw_winsys_framebuffer implementation is
* d3d12_wgl_framebuffer and it doesn't support front buffer
- * drawing. A fake front texture is needed to handle that scenario */
+ * drawing. A fake front texture is needed to handle that scenario.
+ * For MSAA, we just need to make sure that the back buffer also
+ * exists, so we can blt to it during flush_frontbuffer. */
if (mask & ST_ATTACHMENT_FRONT_LEFT_MASK &&
- stwfb->fb->winsys_framebuffer &&
- stwfb->stvis.samples <= 1) {
- stwfb->needs_fake_front = true;
+ stwfb->fb->winsys_framebuffer) {
+ if (stwfb->stvis.samples <= 1)
+ stwfb->needs_fake_front = true;
+ else
+ mask |= ST_ATTACHMENT_BACK_LEFT_MASK;
}
/* remove outdated textures */
@@ -440,6 +444,7 @@ stw_st_framebuffer_flush_front(struct st_context_iface *stctx,
struct pipe_context *pipe = stctx->pipe;
bool ret;
HDC hDC;
+ bool need_swap_textures = false;
if (statt != ST_ATTACHMENT_FRONT_LEFT)
return false;
@@ -448,17 +453,24 @@ stw_st_framebuffer_flush_front(struct st_context_iface *stctx,
/* Resolve the front buffer. */
if (stwfb->stvis.samples > 1) {
- stw_pipe_blit(pipe, stwfb->textures[statt], stwfb->msaa_textures[statt]);
+ enum st_attachment_type blit_target = statt;
+ if (stwfb->fb->winsys_framebuffer) {
+ blit_target = ST_ATTACHMENT_BACK_LEFT;
+ need_swap_textures = true;
+ }
+
+ stw_pipe_blit(pipe, stwfb->textures[blit_target],
+ stwfb->msaa_textures[statt]);
} else if (stwfb->needs_fake_front) {
- struct pipe_resource *ptex;
+ /* fake front texture is now invalid */
+ p_atomic_inc(&stwfb->base.stamp);
+ need_swap_textures = true;
+ }
- /* swap the textures */
- ptex = stwfb->textures[ST_ATTACHMENT_FRONT_LEFT];
+ if (need_swap_textures) {
+ struct pipe_resource *ptex = stwfb->textures[ST_ATTACHMENT_FRONT_LEFT];
stwfb->textures[ST_ATTACHMENT_FRONT_LEFT] = stwfb->textures[ST_ATTACHMENT_BACK_LEFT];
stwfb->textures[ST_ATTACHMENT_BACK_LEFT] = ptex;
-
- /* fake front texture is now invalid */
- p_atomic_inc(&stwfb->base.stamp);
}
if (stwfb->textures[statt])
More information about the mesa-commit
mailing list