wgl: Use winsys framebuffer interface if present

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7535>
This commit is contained in:
Jesse Natalie
2020-03-18 13:46:25 -07:00
committed by Erik Faye-Lund
parent 23bfe03567
commit d60913e392
3 changed files with 47 additions and 15 deletions
+20 -3
View File
@@ -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);
}
@@ -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;
+25 -12
View File
@@ -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;
}