Exemplo n.º 1
0
static bool d3d_alive(void *data)
{
   unsigned temp_width = 0, temp_height = 0;
   bool ret = false;
   d3d_video_t *d3d   = (d3d_video_t*)data;
   bool        quit   = false;
   bool        resize = false;

   if (gfx_ctx_check_window(&quit, &resize,
            &temp_width, &temp_height))
   {
      if (quit)
         d3d->quitting = quit;

      if (resize)
      {
         d3d->should_resize = true;
         gfx_ctx_set_resize(temp_width, temp_height);
         d3d_restore(d3d);
      }

      ret = !quit;
   }

   if (temp_width != 0 && temp_height != 0)
      video_driver_set_size(&temp_width, &temp_height);

   return ret;
}
Exemplo n.º 2
0
static void d3d_set_nonblock_state(void *data, bool state)
{
   d3d_video_t *d3d = (d3d_video_t*)data;
   d3d->video_info.vsync = !state;

   if (d3d->ctx_driver && d3d->ctx_driver->swap_interval)
      d3d->ctx_driver->swap_interval(d3d, state ? 0 : 1);
#ifndef _XBOX
   d3d_restore(d3d);
#endif
}
Exemplo n.º 3
0
static void gfx_ctx_d3d_swap_interval(void *data, unsigned interval)
{
   d3d_video_t      *d3d = (d3d_video_t*)data;
#ifdef _XBOX
   unsigned d3d_interval = interval ? 
      D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;

   d3d_render_state(d3d->dev, XBOX_PRESENTATIONINTERVAL, d3d_interval);
#else
   d3d_restore(d3d);
#endif
}
Exemplo n.º 4
0
static void gfx_ctx_d3d_swap_interval(void *data, unsigned interval)
{
   d3d_video_t      *d3d = (d3d_video_t*)data;
#ifdef _XBOX
   LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
   unsigned d3d_interval = interval ? 
      D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;

   d3dr->SetRenderState(XBOX_PRESENTATIONINTERVAL, d3d_interval);
#else
   d3d_restore(d3d);
#endif
}
Exemplo n.º 5
0
static void d3d_set_nonblock_state(void *data, bool state)
{
   d3d_video_t            *d3d = (d3d_video_t*)data;

   if (!d3d)
      return;

   d3d->video_info.vsync = !state;

   gfx_ctx_swap_interval(state ? 0 : 1);
#ifndef _XBOX
   d3d->needs_restore = true;
   d3d_restore(d3d);
#endif
}
Exemplo n.º 6
0
static void d3d_set_nonblock_state(void *data, bool state)
{
   unsigned interval            = state ? 0 : 1;
   d3d_video_t            *d3d = (d3d_video_t*)data;

   if (!d3d)
      return;

   d3d->video_info.vsync = !state;

   video_context_driver_swap_interval(&interval);
#ifndef _XBOX
   d3d->needs_restore = true;
   d3d_restore(d3d);
#endif
}
Exemplo n.º 7
0
static void d3d_resize(void *data, unsigned new_width, unsigned new_height)
{
   d3d_video_t *d3d      = (d3d_video_t*)curD3D;
   LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;

   if (!d3dr)
      return;

   (void)data;

   if (new_width != d3d->video_info.width || new_height != d3d->video_info.height)
   {
      RARCH_LOG("[D3D]: Resize %ux%u.\n", new_width, new_height);
      d3d->video_info.width  = d3d->screen_width = new_width;
      d3d->video_info.height = d3d->screen_height = new_height;
      d3d_restore(d3d);
   }
}
Exemplo n.º 8
0
static void d3d_resize(unsigned new_width, unsigned new_height)
{
#ifdef _XBOX
   D3DVideo *d3d = reinterpret_cast<D3DVideo*>(driver.video_data);
#else
   D3DVideo *d3d = reinterpret_cast<D3DVideo*>(curD3D);
#endif
   if (!d3d->dev)
      return;

   RARCH_LOG("[D3D]: Resize %ux%u.\n", new_width, new_height);

   if (new_width != d3d->video_info.width || new_height != d3d->video_info.height)
   {
      d3d->video_info.width = d3d->screen_width = new_width;
      d3d->video_info.height = d3d->screen_height = new_height;
      d3d_restore(d3d);
   }
}
Exemplo n.º 9
0
static bool d3d_alive(void *data)
{
   gfx_ctx_size_t size_data;
   unsigned temp_width  = 0;
   unsigned temp_height = 0;
   bool ret             = false;
   d3d_video_t *d3d     = (d3d_video_t*)data;
   bool        quit     = false;
   bool        resize   = false;

   size_data.quit       = &quit;
   size_data.resize     = &resize;
   size_data.width      = &temp_width;
   size_data.height     = &temp_height;

   if (video_context_driver_check_window(&size_data))
   {
      if (quit)
         d3d->quitting = quit;

      if (resize)
      {
         gfx_ctx_mode_t mode;

         d3d->should_resize = true;

         mode.width  = temp_width;
         mode.height = temp_height;

         video_context_driver_set_resize(&mode);
         d3d_restore(d3d);
      }

      ret = !quit;
   }

   if (temp_width != 0 && temp_height != 0)
      video_driver_set_size(&temp_width, &temp_height);

   return ret;
}
Exemplo n.º 10
0
static bool d3d_frame(void *data, const void *frame,
      unsigned width, unsigned height, unsigned pitch,
      const char *msg)
{
   d3d_video_t *d3d = (d3d_video_t*)data;

  if (!frame)
      return true;

   RARCH_PERFORMANCE_INIT(d3d_frame);
   RARCH_PERFORMANCE_START(d3d_frame);
   // We cannot recover in fullscreen.
   if (d3d->needs_restore && IsIconic(d3d->hWnd))
      return true;

   if (d3d->needs_restore && !d3d_restore(d3d))
   {
      RARCH_ERR("[D3D]: Failed to restore.\n");
      return false;
   }

   if (d3d->should_resize)
   {
      d3d_calculate_rect(d3d, d3d->screen_width, d3d->screen_height, d3d->video_info.force_aspect, g_extern.system.aspect_ratio);
      renderchain_set_final_viewport(d3d->chain, &d3d->final_viewport);
      d3d_recompute_pass_sizes(d3d);

      d3d->should_resize = false;
   }

   // render_chain() only clears out viewport, clear out everything.
   D3DVIEWPORT screen_vp;
   screen_vp.X = 0;
   screen_vp.Y = 0;
   screen_vp.MinZ = 0;
   screen_vp.MaxZ = 1;
   screen_vp.Width = d3d->screen_width;
   screen_vp.Height = d3d->screen_height;
   d3d->dev->SetViewport(&screen_vp);
   d3d->dev->Clear(0, 0, D3DCLEAR_TARGET, 0, 1, 0);

   // Insert black frame first, so we can screenshot, etc.
   if (g_settings.video.black_frame_insertion)
   {
      if (d3d->dev->Present(NULL, NULL, NULL, NULL) != D3D_OK)
      {
         RARCH_ERR("[D3D]: Present() failed.\n");
         d3d->needs_restore = true;
         return true;
      }
      d3d->dev->Clear(0, 0, D3DCLEAR_TARGET, 0, 1, 0);
   }

   if (!renderchain_render(d3d->chain, frame, width, height, pitch, d3d->dev_rotation))
   {
      RARCH_ERR("[D3D]: Failed to render scene.\n");
      return false;
   }

   if (d3d->font_ctx && d3d->font_ctx->render_msg)
   {
      font_params_t font_parms = {0};
#ifdef _XBOX
#if defined(_XBOX1)
      float msg_width  = 60;
      float msg_height = 365;
#elif defined(_XBOX360)
      float msg_width  = (g_extern.lifecycle_state & (1ULL << MODE_MENU_HD)) ? 160 : 100;
      float msg_height = 120;
#endif
      font_parms.x = msg_width;
      font_parms.y = msg_height;
      font_parms.scale = 21;
#endif
      d3d->font_ctx->render_msg(d3d, msg, &font_parms);
   }

#ifdef HAVE_MENU
   if (d3d->rgui && d3d->rgui->enabled)
      d3d_overlay_render(d3d, d3d->rgui);
#endif

#ifdef HAVE_OVERLAY
   if (d3d->overlays_enabled)
   {
      for (unsigned i = 0; i < d3d->overlays.size(); i++)
         d3d_overlay_render(d3d, &d3d->overlays[i]);
   }
#endif

   RARCH_PERFORMANCE_STOP(d3d_frame);

#ifdef HAVE_MENU
   if (g_extern.lifecycle_state & (1ULL << MODE_MENU) && driver.menu_ctx && driver.menu_ctx->frame)
      driver.menu_ctx->frame(d3d);
#endif

   if (d3d && d3d->ctx_driver && d3d->ctx_driver->update_window_title)
      d3d->ctx_driver->update_window_title(d3d);

   if (d3d && d3d->ctx_driver && d3d->ctx_driver->swap_buffers)
      d3d->ctx_driver->swap_buffers(d3d);

   return true;
}