mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
wgl: Add a context to framebuffer destruction
If the window is destroyed on a thread that has a currently-bound context, use that context for destroying the framebuffer. This ensures that the winsys can wait for in-flight work before destroying any resources. If the window did have a context bound beforehand but it was unbound, we should've already done a glFinish. If the window is destroyed from an unrelated thread... well, we're screwed, but that's the best we can do. Reviewed-By: Bill Kristiansen <billkris@microsoft.com> Reviewed-by: Jose Fonseca <jfonseca@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9959>
This commit is contained in:
parent
f3db2963ce
commit
51df136c8b
5 changed files with 18 additions and 10 deletions
|
|
@ -555,7 +555,7 @@ stw_make_current(HDC hDrawDC, HDC hReadDC, DHGLRC dhglrc)
|
|||
if (old_fb && old_fb != fb) {
|
||||
stw_lock_framebuffers(stw_dev);
|
||||
stw_framebuffer_lock(old_fb);
|
||||
stw_framebuffer_release_locked(old_fb);
|
||||
stw_framebuffer_release_locked(old_fb, old_ctx->st);
|
||||
stw_unlock_framebuffers(stw_dev);
|
||||
}
|
||||
|
||||
|
|
@ -584,7 +584,7 @@ fail:
|
|||
old_ctx->current_framebuffer = NULL;
|
||||
stw_lock_framebuffers(stw_dev);
|
||||
stw_framebuffer_lock(old_fb);
|
||||
stw_framebuffer_release_locked(old_fb);
|
||||
stw_framebuffer_release_locked(old_fb, old_ctx->st);
|
||||
stw_unlock_framebuffers(stw_dev);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,8 @@ stw_framebuffer_from_hwnd_locked(HWND hwnd)
|
|||
* locked. After this function completes, the fb's mutex will be unlocked.
|
||||
*/
|
||||
void
|
||||
stw_framebuffer_release_locked(struct stw_framebuffer *fb)
|
||||
stw_framebuffer_release_locked(struct stw_framebuffer *fb,
|
||||
struct st_context_iface *stctx)
|
||||
{
|
||||
struct stw_framebuffer **link;
|
||||
|
||||
|
|
@ -102,7 +103,7 @@ stw_framebuffer_release_locked(struct stw_framebuffer *fb)
|
|||
fb->shared_surface);
|
||||
|
||||
if (fb->winsys_framebuffer)
|
||||
fb->winsys_framebuffer->destroy(fb->winsys_framebuffer);
|
||||
fb->winsys_framebuffer->destroy(fb->winsys_framebuffer, stctx ? stctx->pipe : NULL);
|
||||
|
||||
stw_st_destroy_framebuffer_locked(fb->stfb);
|
||||
|
||||
|
|
@ -238,8 +239,12 @@ stw_call_window_proc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||
else if (pParams->message == WM_DESTROY) {
|
||||
stw_lock_framebuffers(stw_dev);
|
||||
fb = stw_framebuffer_from_hwnd_locked( pParams->hwnd );
|
||||
if (fb)
|
||||
stw_framebuffer_release_locked(fb);
|
||||
if (fb) {
|
||||
struct stw_context *current_context = stw_current_context();
|
||||
struct st_context_iface *ctx_iface = current_context &&
|
||||
current_context->current_framebuffer == fb ? current_context->st : NULL;
|
||||
stw_framebuffer_release_locked(fb, ctx_iface);
|
||||
}
|
||||
stw_unlock_framebuffers(stw_dev);
|
||||
}
|
||||
}
|
||||
|
|
@ -363,7 +368,7 @@ stw_framebuffer_cleanup(void)
|
|||
next = fb->next;
|
||||
|
||||
stw_framebuffer_lock(fb);
|
||||
stw_framebuffer_release_locked(fb);
|
||||
stw_framebuffer_release_locked(fb, NULL);
|
||||
|
||||
fb = next;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,7 +154,8 @@ stw_framebuffer_reference_locked(struct stw_framebuffer *fb)
|
|||
|
||||
|
||||
void
|
||||
stw_framebuffer_release_locked(struct stw_framebuffer *fb);
|
||||
stw_framebuffer_release_locked(struct stw_framebuffer *fb,
|
||||
struct st_context_iface *stctx);
|
||||
|
||||
/**
|
||||
* Search a framebuffer with a matching HWND.
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ typedef enum
|
|||
struct stw_winsys_framebuffer
|
||||
{
|
||||
void
|
||||
(*destroy)(struct stw_winsys_framebuffer *fb);
|
||||
(*destroy)(struct stw_winsys_framebuffer *fb,
|
||||
struct pipe_context *context);
|
||||
|
||||
boolean
|
||||
(*present)(struct stw_winsys_framebuffer *fb);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,8 @@ d3d12_wgl_framebuffer(struct stw_winsys_framebuffer *fb)
|
|||
}
|
||||
|
||||
static void
|
||||
d3d12_wgl_framebuffer_destroy(struct stw_winsys_framebuffer *fb)
|
||||
d3d12_wgl_framebuffer_destroy(struct stw_winsys_framebuffer *fb,
|
||||
pipe_context *ctx)
|
||||
{
|
||||
FREE(fb);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue