Example #1
0
void
stw_cleanup(void)
{
   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.
    */
   stw_lock_contexts(stw_dev);
   dhglrc = handle_table_get_first_handle(stw_dev->ctx_table);
   stw_unlock_contexts(stw_dev);
   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();

   DeleteCriticalSection(&stw_dev->fb_mutex);
   DeleteCriticalSection(&stw_dev->ctx_mutex);

   if (stw_dev->smapi->destroy)
      stw_dev->smapi->destroy(stw_dev->smapi);

   FREE(stw_dev->smapi);
   stw_dev->stapi->destroy(stw_dev->stapi);

   stw_dev->screen->destroy(stw_dev->screen);

   /* glapi is statically linked: we can call the local destroy function. */
#ifdef _GLAPI_NO_EXPORTS
   _glapi_destroy_multithread();
#endif

#ifdef DEBUG
   debug_memory_end(stw_dev->memdbg_no);
#endif

   stw_tls_cleanup();

   stw_dev = NULL;
}
Example #2
0
void
stw_cleanup(void)
{
   unsigned i;

   debug_printf("%s\n", __FUNCTION__);

   if (!stw_dev)
      return;
   
   pipe_mutex_lock( stw_dev->ctx_mutex );
   {
      /* Ensure all contexts are destroyed */
      i = handle_table_get_first_handle(stw_dev->ctx_table);
      while (i) {
         stw_delete_context(i);
         i = handle_table_get_next_handle(stw_dev->ctx_table, i);
      }
      handle_table_destroy(stw_dev->ctx_table);
   }
   pipe_mutex_unlock( stw_dev->ctx_mutex );

   stw_framebuffer_cleanup();
   
   pipe_mutex_destroy( stw_dev->fb_mutex );
   pipe_mutex_destroy( stw_dev->ctx_mutex );
   
   stw_dev->screen->destroy(stw_dev->screen);

#ifdef WIN32_THREADS
   _glthread_DESTROY_MUTEX(OneTimeLock);
   FreeAllTSD();
#endif

#ifdef DEBUG
   debug_memory_end(stw_dev->memdbg_no);
#endif

   stw_tls_cleanup();

   stw_dev = NULL;
}