X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fstate_trackers%2Fwgl%2Fstw_device.c;h=ea300f27cb56ed912dbba39a2b01a64e34b4ec96;hb=182c42c8da6edfa66819eef02f4dea310c1f68d7;hp=985b8f0456a9f6f36cd631d72c3e46d665836b31;hpb=3d36d6b4cf735e93a6ae5eadf28e671252fb5303;p=mesa.git diff --git a/src/gallium/state_trackers/wgl/stw_device.c b/src/gallium/state_trackers/wgl/stw_device.c index 985b8f0456a..ea300f27cb5 100644 --- a/src/gallium/state_trackers/wgl/stw_device.c +++ b/src/gallium/state_trackers/wgl/stw_device.c @@ -33,11 +33,6 @@ #include "pipe/p_screen.h" #include "state_tracker/st_public.h" -#ifdef DEBUG -#include "trace/tr_screen.h" -#include "trace/tr_texture.h" -#endif - #include "stw_device.h" #include "stw_winsys.h" #include "stw_pixelformat.h" @@ -47,7 +42,6 @@ #ifdef WIN32_THREADS extern _glthread_Mutex OneTimeLock; -extern void FreeAllTSD(void); #endif @@ -72,19 +66,7 @@ stw_flush_frontbuffer(struct pipe_screen *screen, return; } -#if DEBUG - { - /* ensure that a random surface was not passed to us */ - struct pipe_surface *surface2; - - if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_FRONT_LEFT, &surface2 )) - assert(0); - else - assert(surface2 == surface); - } -#endif - - stw_framebuffer_present_locked(hdc, fb, ST_SURFACE_FRONT_LEFT); + stw_framebuffer_present_locked(hdc, fb, surface); } @@ -120,13 +102,10 @@ stw_init(const struct stw_winsys *stw_winsys) if(stw_winsys->get_adapter_luid) stw_winsys->get_adapter_luid(screen, &stw_dev->AdapterLuid); -#ifdef DEBUG - stw_dev->screen = trace_screen_create(screen); - stw_dev->trace_running = stw_dev->screen != screen ? TRUE : FALSE; -#else stw_dev->screen = screen; -#endif - + + /* XXX + */ stw_dev->screen->flush_frontbuffer = &stw_flush_frontbuffer; pipe_mutex_init( stw_dev->ctx_mutex ); @@ -164,24 +143,27 @@ stw_cleanup_thread(void) void stw_cleanup(void) { - unsigned i; + DHGLRC dhglrc; debug_printf("%s\n", __FUNCTION__); if (!stw_dev) return; + /* + * Abort cleanup if there are still active contexts. In some situations + * this DLL may be unloaded before the DLL that is using GL contexts is. + */ pipe_mutex_lock( stw_dev->ctx_mutex ); - { - /* Ensure all contexts are destroyed */ - i = handle_table_get_first_handle(stw_dev->ctx_table); - while (i) { - DrvDeleteContext(i); - i = handle_table_get_next_handle(stw_dev->ctx_table, i); - } - handle_table_destroy(stw_dev->ctx_table); - } + dhglrc = handle_table_get_first_handle(stw_dev->ctx_table); pipe_mutex_unlock( stw_dev->ctx_mutex ); + if (dhglrc) { + debug_printf("%s: contexts still active -- cleanup aborted\n", __FUNCTION__); + stw_dev = NULL; + return; + } + + handle_table_destroy(stw_dev->ctx_table); stw_framebuffer_cleanup(); @@ -192,7 +174,8 @@ stw_cleanup(void) #ifdef WIN32_THREADS _glthread_DESTROY_MUTEX(OneTimeLock); - FreeAllTSD(); + + _glapi_destroy_multithread(); #endif #ifdef DEBUG