Example #1
0
static void d3d_deinitialize(d3d_video_t *d3d)
{
   if (!d3d)
      return;

   font_driver_free(NULL);
   d3d_deinit_chain(d3d);
}
Example #2
0
static void d3d_reinit_renderchain(void *data, const video_info_t *video)
{
   d3d_video_t *d3d = (d3d_video_t*)data;

   d3d->pixel_size   = video->rgb32 ? sizeof(uint32_t) : sizeof(uint16_t);
   d3d->tex_w = d3d->tex_h = RARCH_SCALE_BASE * video->input_scale;

   RARCH_LOG("Reinitializing renderchain - and textures (%u x %u @ %u bpp)\n", d3d->tex_w,
            d3d->tex_h, d3d->pixel_size * CHAR_BIT);
   d3d_deinit_chain(d3d);
   d3d_init_chain(d3d, video);
}
Example #3
0
static void d3d_deinitialize(void *data)
{
   d3d_video_t *d3d = (d3d_video_t*)data;

   if (d3d->font_ctx && d3d->font_ctx->deinit)
      d3d->font_ctx->deinit(d3d);
   d3d_deinit_chain(d3d);
#ifdef HAVE_SHADERS
   d3d_deinit_shader(d3d);
#endif

   d3d->needs_restore = false;
}
Example #4
0
static void d3d_deinitialize(d3d_video_t *d3d)
{
   const font_renderer_t *font_ctx = NULL;
   if (!d3d)
      return;

   font_ctx = (const font_renderer_t*)d3d->font_driver;

   if (font_ctx->free)
      font_ctx->free(d3d->font_handle);
   font_ctx = NULL;
   d3d_deinit_chain(d3d);

#ifndef _XBOX
   d3d->needs_restore = false;
#endif
}
Example #5
0
static void *d3d_init(const video_info_t *info,
      const input_driver_t **input, void **input_data)
{
   d3d_video_t            *d3d        = NULL;
   const gfx_ctx_driver_t *ctx_driver = NULL;

#ifdef _XBOX
   if (video_driver_get_ptr(false))
   {
      d3d = (d3d_video_t*)video_driver_get_ptr(false);

      /* Reinitialize renderchain as we
       * might have changed pixel formats.*/
      if (d3d->renderchain_driver->reinit(d3d, (const void*)info))
      {
         d3d_deinit_chain(d3d);
         d3d_init_chain(d3d, info);

         input_driver_set(input, input_data);

         video_driver_ctl(RARCH_DISPLAY_CTL_SET_OWN_DRIVER, NULL);
         return d3d;
      }
   }
#endif

   d3d = new d3d_video_t();
   if (!d3d)
      goto error;

   ctx_driver = d3d_get_context(d3d);
   if (!ctx_driver)
      goto error;

   /* Default values */
   d3d->dev                  = NULL;
   d3d->dev_rotation         = 0;
   d3d->needs_restore        = false;
#ifdef HAVE_OVERLAY
   d3d->overlays_enabled     = false;
#endif
#ifdef _XBOX
   d3d->should_resize        = false;
#else
#ifdef HAVE_MENU
   d3d->menu                 = NULL;
#endif
#endif

   gfx_ctx_set(ctx_driver);

   if (!d3d_construct(d3d, info, input, input_data))
   {
      RARCH_ERR("[D3D]: Failed to init D3D.\n");
      goto error;
   }

   d3d->keep_aspect       = info->force_aspect;
#ifdef _XBOX
   video_driver_ctl(RARCH_DISPLAY_CTL_SET_OWN_DRIVER, NULL);
   video_driver_ctl(RARCH_INPUT_CTL_SET_OWN_DRIVER, NULL);
#endif

   return d3d;

error:
   gfx_ctx_destroy(ctx_driver);
   if (d3d)
      delete d3d;
   return NULL;
}
Example #6
0
bool d3d_init_chain(void *data, const video_info_t *video_info)
{
   d3d_video_t *d3d = (d3d_video_t*)data;
   LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
   // Setup information for first pass.
   LinkInfo link_info = {0};

   link_info.pass = &d3d->shader.pass[0];
   link_info.tex_w = link_info.tex_h = video_info->input_scale * RARCH_SCALE_BASE;

   d3d_deinit_chain(d3d);
   d3d->chain = new renderchain_t();
   if (!d3d->chain)
      return false;

   if (!renderchain_init(d3d->chain, &d3d->video_info, d3dr, d3d->cgCtx, &d3d->final_viewport, &link_info,
            d3d->video_info.rgb32 ? ARGB : RGB565))
   {
      RARCH_ERR("[D3D9]: Failed to init render chain.\n");
      return false;
   }

   unsigned current_width = link_info.tex_w;
   unsigned current_height = link_info.tex_h;
   unsigned out_width = 0;
   unsigned out_height = 0;

   for (unsigned i = 1; i < d3d->shader.passes; i++)
   {
      renderchain_convert_geometry(d3d->chain, &link_info,
            out_width, out_height,
            current_width, current_height, &d3d->final_viewport);

      link_info.pass = &d3d->shader.pass[i];
      link_info.tex_w = next_pow2(out_width);
      link_info.tex_h = next_pow2(out_height);

      current_width = out_width;
      current_height = out_height;

      if (!renderchain_add_pass(d3d->chain, &link_info))
      {
         RARCH_ERR("[D3D9]: Failed to add pass.\n");
         return false;
      }
   }

   if (!d3d_init_luts(d3d))
   {
      RARCH_ERR("[D3D9]: Failed to init LUTs.\n");
      return false;
   }

#ifndef DONT_HAVE_STATE_TRACKER
   if (!d3d_init_imports(d3d))
   {
      RARCH_ERR("[D3D9]: Failed to init imports.\n");
      return false;
   }
#endif

   return true;
}
Example #7
0
static void *d3d_init(const video_info_t *info,
      const input_driver_t **input, void **input_data)
{
   d3d_video_t *vid = NULL;
   driver_t *driver = driver_get_ptr();

#ifdef _XBOX
   if (driver->video_data)
   {
      d3d_video_t *vid = (d3d_video_t*)driver->video_data;

      /* Reinitialize renderchain as we 
       * might have changed pixel formats.*/
      if (vid->renderchain_driver->reinit(vid, (const void*)info))
      {
         d3d_deinit_chain(vid);
         d3d_init_chain(vid, info);

         if (input && input_data)
         {
            *input = driver->input;
            *input_data = driver->input_data;
         }

         driver->video_data_own = true;
         driver->input_data_own = true;
         return driver->video_data;
      }
   }
#endif

   vid = (d3d_video_t*)calloc(1, sizeof(*vid));
   if (!vid)
      goto error;

   vid->ctx_driver = d3d_get_context(vid);
   if (!vid->ctx_driver)
      goto error;

   /* Default values */
   vid->g_pD3D               = NULL;
   vid->dev                  = NULL;
   vid->dev_rotation         = 0;
   vid->needs_restore        = false;
#ifdef HAVE_OVERLAY
   vid->overlays_enabled     = false;
#endif
#ifdef _XBOX
   vid->should_resize        = false;
#else
   vid->menu                 = NULL;
#endif

   if (!d3d_construct(vid, info, input, input_data))
   {
      RARCH_ERR("[D3D]: Failed to init D3D.\n");
      goto error;
   }

#ifdef _XBOX
   driver->video_data_own = true;
   driver->input_data_own = true;
#endif

   return vid;

error:
   if (vid)
      free(vid);
   return NULL;
}