From 147d7fb772a7e6b5207c70d02d133af324b0ccf2 Mon Sep 17 00:00:00 2001 From: Charmaine Lee Date: Mon, 10 Jul 2017 23:06:11 -0700 Subject: st/mesa: add a winsys buffers list in st_context Commit a5e733c6b52e93de3000647d075f5ca2f55fcb71 fixes the dangling framebuffer object by unreferencing the window system draw/read buffers when context is released. However this can prematurely destroy the resources associated with these window system buffers. The problem is reproducible with Turbine Demo running with VMware driver. In this case, the depth buffer content was lost when the context is rebound to a drawable. To prevent premature destroy of the resources associated with window system buffers, this patch maintains a list of these buffers in the context, making sure the reference counts of these buffers will not reach zero until the associated framebuffer interface objects no longer exist. This also helps to avoid unnecessary destruction and re-construction of the resources associated with the framebuffer. Fixes VMware bug 1909807. Reviewed-by: Brian Paul --- src/gallium/state_trackers/wgl/stw_st.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gallium/state_trackers/wgl') diff --git a/src/gallium/state_trackers/wgl/stw_st.c b/src/gallium/state_trackers/wgl/stw_st.c index 7806a2a10e3..c2844b04c4e 100644 --- a/src/gallium/state_trackers/wgl/stw_st.c +++ b/src/gallium/state_trackers/wgl/stw_st.c @@ -46,7 +46,7 @@ struct stw_st_framebuffer { unsigned texture_mask; }; - +static uint32_t stwfb_ID = 0; /** * Is the given mutex held by the calling thread? @@ -234,6 +234,7 @@ stw_st_create_framebuffer(struct stw_framebuffer *fb) stwfb->fb = fb; stwfb->stvis = fb->pfi->stvis; + stwfb->base.ID = p_atomic_inc_return(&stwfb_ID); stwfb->base.visual = &stwfb->stvis; p_atomic_set(&stwfb->base.stamp, 1); @@ -255,6 +256,7 @@ stw_st_destroy_framebuffer_locked(struct st_framebuffer_iface *stfb) for (i = 0; i < ST_ATTACHMENT_COUNT; i++) pipe_resource_reference(&stwfb->textures[i], NULL); + stwfb->base.ID = 0; FREE(stwfb); } -- cgit v1.2.3