Exemple #1
0
static void gfx_ctx_xegl_destroy(void *data)
{
   xegl_ctx_data_t *xegl = (xegl_ctx_data_t*)data;

   x11_input_ctx_destroy();
#ifdef HAVE_EGL
   egl_destroy(&xegl->egl);
#endif

   if (g_x11_win)
   {
      /* Save last used monitor for later. */
      x11_save_last_used_monitor(RootWindow(
               g_x11_dpy, DefaultScreen(g_x11_dpy)));
      x11_window_destroy(false);
   }

   x11_colormap_destroy();

   if (xegl->should_reset_mode)
   {
      x11_exit_fullscreen(g_x11_dpy, &xegl->desktop_mode);
      xegl->should_reset_mode = false;
   }

   free(data);

   /* Do not close g_x11_dpy. We'll keep one for the entire application 
    * lifecycle to work-around nVidia EGL limitations.
    */
}
Exemple #2
0
static void gfx_ctx_destroy(void)
{
   if (g_dpy && g_ctx)
   {
      glXMakeContextCurrent(g_dpy, None, None, NULL);
      glXDestroyContext(g_dpy, g_ctx);
      g_ctx = NULL;
   }

   if (g_win)
   {
      glXDestroyWindow(g_dpy, g_glx_win);
      g_glx_win = 0;

      // Save last used monitor for later.
#ifdef HAVE_XINERAMA
      XWindowAttributes target;
      Window child;

      int x = 0, y = 0;
      XGetWindowAttributes(g_dpy, g_win, &target);
      XTranslateCoordinates(g_dpy, g_win, DefaultRootWindow(g_dpy),
            target.x, target.y, &x, &y, &child);

      g_screen = x11_get_xinerama_monitor(g_dpy, x, y,
            target.width, target.height);

      RARCH_LOG("[GLX]: Saved monitor #%u.\n", g_screen);
#endif

      XUnmapWindow(g_dpy, g_win);
      XDestroyWindow(g_dpy, g_win);
      g_win = None;
   }

   if (g_cmap)
   {
      XFreeColormap(g_dpy, g_cmap);
      g_cmap = None;
   }

   if (g_should_reset_mode)
   {
      x11_exit_fullscreen(g_dpy, &g_desktop_mode);
      g_should_reset_mode = false;
   }

   if (g_dpy)
   {
      XCloseDisplay(g_dpy);
      g_dpy = NULL;
   }

   g_inited = false;
   g_pglSwapInterval = NULL;
}
Exemple #3
0
static void ctx_glx_destroy_resources(gfx_ctx_glx_data_t *glx)
{
   if (!glx)
      return;

   x11_input_ctx_destroy();

   if (g_x11_dpy && glx->g_ctx)
   {

      glFinish();
      glXMakeContextCurrent(g_x11_dpy, None, None, NULL);

      if (!video_driver_ctl(RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT, NULL))
      {
         if (glx->g_hw_ctx)
            glXDestroyContext(g_x11_dpy, glx->g_hw_ctx);
         glXDestroyContext(g_x11_dpy, glx->g_ctx);
         glx->g_ctx = NULL;
         glx->g_hw_ctx = NULL;
      }
   }

   if (g_x11_win)
   {
      glXDestroyWindow(g_x11_dpy, glx->g_glx_win);
      glx->g_glx_win = 0;

      /* Save last used monitor for later. */
      x11_save_last_used_monitor(DefaultRootWindow(g_x11_dpy));
      x11_window_destroy(false);
   }

   x11_colormap_destroy();

   if (glx->g_should_reset_mode)
   {
      x11_exit_fullscreen(g_x11_dpy, &glx->g_desktop_mode);
      glx->g_should_reset_mode = false;
   }

   if (!video_driver_ctl(RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT, NULL) && g_x11_dpy)
   {
      XCloseDisplay(g_x11_dpy);
      g_x11_dpy = NULL;
   }

   g_pglSwapInterval = NULL;
   g_pglSwapIntervalSGI = NULL;
   g_pglSwapIntervalEXT = NULL;
   g_major = g_minor = 0;
   glx->g_core_es = false;
}
static void gfx_ctx_xegl_destroy(void *data)
{
   x11_input_ctx_destroy();
   egl_destroy(data);

   if (g_x11_win)
   {
      /* Save last used monitor for later. */
#ifdef HAVE_XINERAMA
      XWindowAttributes target;
      Window child;

      int x = 0, y = 0;
      XGetWindowAttributes(g_x11_dpy, g_x11_win, &target);
      XTranslateCoordinates(g_x11_dpy, g_x11_win, RootWindow(g_x11_dpy, DefaultScreen(g_x11_dpy)),
            target.x, target.y, &x, &y, &child);

      g_screen = x11_get_xinerama_monitor(g_x11_dpy, x, y,
            target.width, target.height);

      RARCH_LOG("[X/EGL]: Saved monitor #%u.\n", g_screen);
#endif

      x11_window_destroy(false);
   }

   x11_colormap_destroy();

   if (g_should_reset_mode)
   {
      x11_exit_fullscreen(g_x11_dpy, &g_desktop_mode);
      g_should_reset_mode = false;
   }

   /* Do not close g_x11_dpy. We'll keep one for the entire application 
    * lifecycle to work-around nVidia EGL limitations.
    */
}
Exemple #5
0
static void ctx_glx_destroy_resources(gfx_ctx_glx_data_t *glx)
{
   driver_t *driver = driver_get_ptr();

   if (!glx)
      return;

   x11_destroy_input_context(&glx->g_xim, &glx->g_xic);

   if (glx->g_dpy && glx->g_ctx)
   {

      glFinish();
      glXMakeContextCurrent(glx->g_dpy, None, None, NULL);

      if (!driver->video_cache_context)
      {
         if (glx->g_hw_ctx)
            glXDestroyContext(glx->g_dpy, glx->g_hw_ctx);
         glXDestroyContext(glx->g_dpy, glx->g_ctx);
         glx->g_ctx = NULL;
         glx->g_hw_ctx = NULL;
      }
   }

   if (glx->g_win)
   {
      glXDestroyWindow(glx->g_dpy, glx->g_glx_win);
      glx->g_glx_win = 0;

      /* Save last used monitor for later. */
#ifdef HAVE_XINERAMA
      XWindowAttributes target;
      Window child;

      int x = 0, y = 0;
      XGetWindowAttributes(glx->g_dpy, glx->g_win, &target);
      XTranslateCoordinates(glx->g_dpy, glx->g_win, DefaultRootWindow(glx->g_dpy),
            target.x, target.y, &x, &y, &child);

      glx->g_screen = x11_get_xinerama_monitor(glx->g_dpy, x, y,
            target.width, target.height);

      RARCH_LOG("[GLX]: Saved monitor #%u.\n", glx->g_screen);
#endif

      XUnmapWindow(glx->g_dpy, glx->g_win);
      XDestroyWindow(glx->g_dpy, glx->g_win);
      glx->g_win = None;
   }

   if (glx->g_cmap)
   {
      XFreeColormap(glx->g_dpy, glx->g_cmap);
      glx->g_cmap = None;
   }

   if (glx->g_should_reset_mode)
   {
      x11_exit_fullscreen(glx->g_dpy, &glx->g_desktop_mode);
      glx->g_should_reset_mode = false;
   }

   if (!driver->video_cache_context && glx->g_dpy)
   {
      XCloseDisplay(glx->g_dpy);
      glx->g_dpy = NULL;
   }

   g_pglSwapInterval = NULL;
   g_pglSwapIntervalSGI = NULL;
   g_pglSwapIntervalEXT = NULL;
   g_major = g_minor = 0;
   glx->g_core_es = false;
}
Exemple #6
0
static void gfx_ctx_xegl_destroy(void *data)
{
   (void)data;

   x11_destroy_input_context(&g_xim, &g_xic);

   if (g_egl_dpy)
   {
      if (g_egl_ctx)
      {
         eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE,
               EGL_NO_SURFACE, EGL_NO_CONTEXT);
         eglDestroyContext(g_egl_dpy, g_egl_ctx);
      }

      if (g_egl_hw_ctx)
         eglDestroyContext(g_egl_dpy, g_egl_hw_ctx);

      if (g_egl_surf)
         eglDestroySurface(g_egl_dpy, g_egl_surf);
      eglTerminate(g_egl_dpy);
   }

   g_egl_ctx     = NULL;
   g_egl_hw_ctx  = NULL;
   g_egl_surf    = NULL;
   g_egl_dpy     = NULL;
   g_egl_config  = 0;

   if (g_win)
   {
      /* Save last used monitor for later. */
#ifdef HAVE_XINERAMA
      XWindowAttributes target;
      Window child;

      int x = 0, y = 0;
      XGetWindowAttributes(g_dpy, g_win, &target);
      XTranslateCoordinates(g_dpy, g_win, RootWindow(g_dpy, DefaultScreen(g_dpy)),
            target.x, target.y, &x, &y, &child);

      g_screen = x11_get_xinerama_monitor(g_dpy, x, y,
            target.width, target.height);

      RARCH_LOG("[X/EGL]: Saved monitor #%u.\n", g_screen);
#endif

      XUnmapWindow(g_dpy, g_win);
      XDestroyWindow(g_dpy, g_win);
      g_win = None;
   }

   if (g_cmap)
   {
      XFreeColormap(g_dpy, g_cmap);
      g_cmap = None;
   }

   if (g_should_reset_mode)
   {
      x11_exit_fullscreen(g_dpy, &g_desktop_mode);
      g_should_reset_mode = false;
   }

   /* Do not close g_dpy. We'll keep one for the entire application 
    * lifecycle to work-around nVidia EGL limitations.
    */
   g_inited = false;
}
Exemple #7
0
static void gfx_ctx_x_destroy_resources(gfx_ctx_x_data_t *x)
{
   x11_input_ctx_destroy();

   if (g_x11_dpy)
   {
      switch (x_api)
      {
         case GFX_CTX_OPENGL_API:
         case GFX_CTX_OPENGL_ES_API:
#ifdef HAVE_OPENGL
            if (x->g_ctx)
            {
               glFinish();
               glXMakeContextCurrent(g_x11_dpy, None, None, NULL);

               if (!video_driver_ctl(RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT, NULL))
               {
                  if (x->g_hw_ctx)
                     glXDestroyContext(g_x11_dpy, x->g_hw_ctx);
                  if (x->g_ctx)
                     glXDestroyContext(g_x11_dpy, x->g_ctx);

                  x->g_ctx    = NULL;
                  x->g_hw_ctx = NULL;
               }
            }
            
            if (g_x11_win)
            {
               if (x->g_glx_win)
                  glXDestroyWindow(g_x11_dpy, x->g_glx_win);
               x->g_glx_win = 0;
            }
#endif
            break;

         case GFX_CTX_VULKAN_API:
#ifdef HAVE_VULKAN
            vulkan_context_destroy(&x->vk, g_x11_win != 0);
#endif
            break;

         case GFX_CTX_NONE:
         default:
            break;
      }
   }

   if (g_x11_win)
   {
      /* Save last used monitor for later. */
      x11_save_last_used_monitor(DefaultRootWindow(g_x11_dpy));
      x11_window_destroy(false);
   }

   x11_colormap_destroy();

   if (x->g_should_reset_mode)
   {
      x11_exit_fullscreen(g_x11_dpy, &x->g_desktop_mode);
      x->g_should_reset_mode = false;
   }

   if (!video_driver_ctl(RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT, NULL) 
         && g_x11_dpy)
   {
      XCloseDisplay(g_x11_dpy);
      g_x11_dpy = NULL;
   }

   g_pglSwapInterval    = NULL;
   g_pglSwapIntervalSGI = NULL;
#ifdef HAVE_OPENGL
   g_pglSwapIntervalEXT = NULL;
#endif
   g_major              = 0;
   g_minor              = 0;
   x->g_core_es         = false;
}
Exemple #8
0
static void gfx_ctx_destroy(void)
{
   if (g_egl_dpy)
   {
      if (g_egl_ctx)
      {
         eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
         eglDestroyContext(g_egl_dpy, g_egl_ctx);
      }

      if (g_egl_surf)
         eglDestroySurface(g_egl_dpy, g_egl_surf);
      eglTerminate(g_egl_dpy);
   }

   g_egl_ctx  = NULL;
   g_egl_surf = NULL;
   g_egl_dpy  = NULL;
   g_config   = 0;

   if (g_win)
   {
      // Save last used monitor for later.
#ifdef HAVE_XINERAMA
      XWindowAttributes target;
      Window child;

      int x = 0, y = 0;
      XGetWindowAttributes(g_dpy, g_win, &target);
      XTranslateCoordinates(g_dpy, g_win, RootWindow(g_dpy, DefaultScreen(g_dpy)),
            target.x, target.y, &x, &y, &child);

      g_screen = x11_get_xinerama_monitor(g_dpy, x, y,
            target.width, target.height);

      RARCH_LOG("[X/EGL]: Saved monitor #%u.\n", g_screen);
#endif

      XUnmapWindow(g_dpy, g_win);
      XDestroyWindow(g_dpy, g_win);
      g_win = None;
   }

   if (g_cmap)
   {
      XFreeColormap(g_dpy, g_cmap);
      g_cmap = None;
   }

   if (g_should_reset_mode)
   {
      x11_exit_fullscreen(g_dpy, &g_desktop_mode);
      g_should_reset_mode = false;
   }

   if (g_dpy)
   {
      XCloseDisplay(g_dpy);
      g_dpy = NULL;
   }

   g_inited = false;
}
Exemple #9
0
static void gfx_ctx_x_destroy_resources(gfx_ctx_x_data_t *x)
{
   x11_input_ctx_destroy();

   if (g_x11_dpy)
   {
      switch (x_api)
      {
         case GFX_CTX_OPENGL_API:
         case GFX_CTX_OPENGL_ES_API:
#ifdef HAVE_OPENGL
            if (x->g_ctx)
            {
               if (x->swap_mode)
                  glXSwapBuffersMscOML(g_x11_dpy, x->g_glx_win, 0, x->divisor, x->remainder);
               else
                  glXSwapBuffers(g_x11_dpy, x->g_glx_win);

               glFinish();
               glXMakeContextCurrent(g_x11_dpy, None, None, NULL);

               if (!video_driver_is_video_cache_context())
               {
                  if (x->g_hw_ctx)
                     glXDestroyContext(g_x11_dpy, x->g_hw_ctx);
                  if (x->g_ctx)
                     glXDestroyContext(g_x11_dpy, x->g_ctx);

                  x->g_ctx    = NULL;
                  x->g_hw_ctx = NULL;
               }
            }

            if (g_x11_win)
            {
               if (x->g_glx_win)
                  glXDestroyWindow(g_x11_dpy, x->g_glx_win);
               x->g_glx_win = 0;
            }
#endif
            break;

         case GFX_CTX_VULKAN_API:
#ifdef HAVE_VULKAN
            vulkan_context_destroy(&x->vk, g_x11_win != 0);
#endif
            break;

         case GFX_CTX_NONE:
         default:
            break;
      }
   }

   if (g_x11_win && g_x11_dpy)
   {
#ifdef HAVE_XINERAMA
      /* Save last used monitor for later. */
      xinerama_save_last_used_monitor(DefaultRootWindow(g_x11_dpy));
#endif
      x11_window_destroy(false);
   }

   x11_colormap_destroy();

   if (g_x11_dpy)
   {
      if (x->g_should_reset_mode)
      {
         x11_exit_fullscreen(g_x11_dpy);
         x->g_should_reset_mode = false;
      }

      if (!video_driver_is_video_cache_context())
      {
         XCloseDisplay(g_x11_dpy);
         g_x11_dpy = NULL;
      }
   }

#ifdef HAVE_OPENGL
   g_pglSwapInterval    = NULL;
   g_pglSwapIntervalSGI = NULL;
   g_pglSwapIntervalEXT = NULL;
#endif
   g_major              = 0;
   g_minor              = 0;
   x->g_core_es         = false;
}