Module: Mesa Branch: master Commit: d60913e39259c867b9dbff93efbd9005b00b33ad URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d60913e39259c867b9dbff93efbd9005b00b33ad
Author: Jesse Natalie <[email protected]> Date: Wed Mar 18 13:46:25 2020 -0700 wgl: Use winsys framebuffer interface if present Reviewed-by: Charmaine Lee <[email protected]> Reviewed-by: Erik Faye-Lund <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7535> --- src/gallium/frontends/wgl/stw_framebuffer.c | 23 +++++++++++++++--- src/gallium/frontends/wgl/stw_framebuffer.h | 2 ++ src/gallium/frontends/wgl/stw_st.c | 37 +++++++++++++++++++---------- 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/src/gallium/frontends/wgl/stw_framebuffer.c b/src/gallium/frontends/wgl/stw_framebuffer.c index 49911a6d48d..8a213f6de35 100644 --- a/src/gallium/frontends/wgl/stw_framebuffer.c +++ b/src/gallium/frontends/wgl/stw_framebuffer.c @@ -28,6 +28,7 @@ #include <windows.h> #include "pipe/p_screen.h" +#include "pipe/p_state.h" #include "util/u_memory.h" #include "hud/hud_context.h" #include "util/os_time.h" @@ -100,6 +101,9 @@ stw_framebuffer_release_locked(struct stw_framebuffer *fb) stw_dev->stw_winsys->shared_surface_close(stw_dev->screen, fb->shared_surface); + if (fb->winsys_framebuffer) + fb->winsys_framebuffer->destroy(fb->winsys_framebuffer); + stw_st_destroy_framebuffer_locked(fb->stfb); stw_framebuffer_unlock(fb); @@ -268,6 +272,10 @@ stw_framebuffer_create(HDC hdc, int iPixelFormat) fb->hWnd = hWnd; fb->iPixelFormat = iPixelFormat; + if (stw_dev->stw_winsys->create_framebuffer) + fb->winsys_framebuffer = + stw_dev->stw_winsys->create_framebuffer(stw_dev->screen, hdc, iPixelFormat); + /* * We often need a displayable pixel format to make GDI happy. Set it * here (always 1, i.e., out first pixel format) where appropriate. @@ -552,8 +560,17 @@ stw_framebuffer_present_locked(HDC hdc, struct stw_framebuffer *fb, struct pipe_resource *res) { - if (stw_dev->callbacks.pfnPresentBuffers && - stw_dev->stw_winsys->compose) { + if (fb->winsys_framebuffer) { + BOOL result = fb->winsys_framebuffer->present(fb->winsys_framebuffer); + + stw_framebuffer_update(fb); + stw_notify_current_locked(fb); + stw_framebuffer_unlock(fb); + + return result; + } + else if (stw_dev->callbacks.pfnPresentBuffers && + stw_dev->stw_winsys->compose) { PRESENTBUFFERSCB data; memset(&data, 0, sizeof data); @@ -652,7 +669,7 @@ DrvSwapBuffers(HDC hdc) } } - if (stw_dev->swap_interval != 0) { + if (stw_dev->swap_interval != 0 && !fb->winsys_framebuffer) { wait_swap_interval(fb); } diff --git a/src/gallium/frontends/wgl/stw_framebuffer.h b/src/gallium/frontends/wgl/stw_framebuffer.h index d44c3a6634a..45d41544957 100644 --- a/src/gallium/frontends/wgl/stw_framebuffer.h +++ b/src/gallium/frontends/wgl/stw_framebuffer.h @@ -108,6 +108,8 @@ struct stw_framebuffer HANDLE hSharedSurface; struct stw_shared_surface *shared_surface; + struct stw_winsys_framebuffer *winsys_framebuffer; + /* For WGL_EXT_swap_control */ int64_t prev_swap_time; diff --git a/src/gallium/frontends/wgl/stw_st.c b/src/gallium/frontends/wgl/stw_st.c index 44bc60c45eb..ca885d182fc 100644 --- a/src/gallium/frontends/wgl/stw_st.c +++ b/src/gallium/frontends/wgl/stw_st.c @@ -29,11 +29,13 @@ #include "util/u_inlines.h" #include "util/u_atomic.h" #include "state_tracker/st_gl_api.h" /* for st_gl_api_create */ +#include "pipe/p_state.h" #include "stw_st.h" #include "stw_device.h" #include "stw_framebuffer.h" #include "stw_pixelformat.h" +#include "stw_winsys.h" struct stw_st_framebuffer { struct st_framebuffer_iface base; @@ -74,7 +76,8 @@ stw_own_mutex(const CRITICAL_SECTION *cs) * Remove outdated textures and create the requested ones. */ static void -stw_st_framebuffer_validate_locked(struct st_framebuffer_iface *stfb, +stw_st_framebuffer_validate_locked(struct st_context_iface *stctx, + struct st_framebuffer_iface *stfb, unsigned width, unsigned height, unsigned mask) { @@ -82,14 +85,6 @@ stw_st_framebuffer_validate_locked(struct st_framebuffer_iface *stfb, struct pipe_resource templ; unsigned i; - /* remove outdated textures */ - if (stwfb->texture_width != width || stwfb->texture_height != height) { - for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { - pipe_resource_reference(&stwfb->msaa_textures[i], NULL); - pipe_resource_reference(&stwfb->textures[i], NULL); - } - } - memset(&templ, 0, sizeof(templ)); templ.target = PIPE_TEXTURE_2D; templ.width0 = width; @@ -98,6 +93,20 @@ stw_st_framebuffer_validate_locked(struct st_framebuffer_iface *stfb, templ.array_size = 1; templ.last_level = 0; + /* remove outdated textures */ + if (stwfb->texture_width != width || stwfb->texture_height != height) { + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { + pipe_resource_reference(&stwfb->msaa_textures[i], NULL); + pipe_resource_reference(&stwfb->textures[i], NULL); + } + + if (stwfb->fb->winsys_framebuffer) { + templ.nr_samples = templ.nr_storage_samples = 1; + templ.format = stwfb->stvis.color_format; + stwfb->fb->winsys_framebuffer->resize(stwfb->fb->winsys_framebuffer, stctx->pipe, &templ); + } + } + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { enum pipe_format format; unsigned bind; @@ -141,8 +150,12 @@ stw_st_framebuffer_validate_locked(struct st_framebuffer_iface *stfb, templ.bind = bind; templ.nr_samples = templ.nr_storage_samples = 1; - stwfb->textures[i] = - stw_dev->screen->resource_create(stw_dev->screen, &templ); + if (stwfb->fb->winsys_framebuffer) + stwfb->textures[i] = stwfb->fb->winsys_framebuffer->get_resource( + stwfb->fb->winsys_framebuffer, i); + else + stwfb->textures[i] = + stw_dev->screen->resource_create(stw_dev->screen, &templ); } } @@ -168,7 +181,7 @@ stw_st_framebuffer_validate(struct st_context_iface *stctx, stw_framebuffer_lock(stwfb->fb); if (stwfb->fb->must_resize || (statt_mask & ~stwfb->texture_mask)) { - stw_st_framebuffer_validate_locked(&stwfb->base, + stw_st_framebuffer_validate_locked(stctx, &stwfb->base, stwfb->fb->width, stwfb->fb->height, statt_mask); stwfb->fb->must_resize = FALSE; } _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
