RetroArch/gfx/d3d/d3d.cpp

1882 lines
48 KiB
C++
Raw Normal View History

2012-10-26 19:09:30 +00:00
/* RetroArch - A frontend for libretro.
2014-01-01 00:50:59 +00:00
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
2015-01-07 17:06:50 +00:00
* Copyright (C) 2011-2015 - Daniel De Matteis
2014-01-01 00:50:59 +00:00
* Copyright (C) 2012-2014 - OV2
2015-05-20 22:28:12 +00:00
*
2012-10-26 19:09:30 +00:00
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef _XBOX
#include <xtl.h>
#include <xgraphics.h>
#endif
2015-07-11 17:47:20 +00:00
#include <formats/image.h>
2015-09-05 12:10:16 +00:00
#include <compat/strl.h>
#include <compat/posix_string.h>
#include <file/file_path.h>
2015-07-11 17:47:20 +00:00
2015-01-07 21:23:45 +00:00
#include "d3d.h"
2015-01-18 22:59:57 +00:00
#include "../video_viewport.h"
#include "../video_monitor.h"
2015-11-10 00:50:15 +00:00
#include "../video_common.h"
2015-04-11 19:57:03 +00:00
#include "../../dynamic.h"
#include "render_chain_driver.h"
2015-04-09 03:16:02 +00:00
#include "../common/win32_common.h"
2014-09-11 18:59:52 +00:00
2015-09-05 12:10:16 +00:00
#ifndef _XBOX
#define HAVE_MONITOR
#define HAVE_WINDOW
2014-09-11 18:59:52 +00:00
#endif
2014-01-09 17:44:25 +00:00
2012-11-03 23:14:43 +00:00
#include "../../performance.h"
2012-10-26 19:09:30 +00:00
2015-04-05 23:10:39 +00:00
#include "d3d_defines.h"
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_HLSL)
2014-03-08 03:56:27 +00:00
#if defined(HAVE_CG)
#define HAVE_SHADERS
#endif
#ifdef HAVE_HLSL
#include "../drivers_shader/shader_hlsl.h"
#endif
#endif
/* forward declarations */
2015-11-10 21:46:45 +00:00
static bool d3d_init_luts(d3d_video_t *d3d)
{
unsigned i;
settings_t *settings = config_get_ptr();
if (!d3d->renderchain_driver->add_lut)
return true;
for (i = 0; i < d3d->shader.luts; i++)
{
bool ret = d3d->renderchain_driver->add_lut(
d3d->renderchain_data,
d3d->shader.lut[i].id, d3d->shader.lut[i].path,
d3d->shader.lut[i].filter == RARCH_FILTER_UNSPEC ?
settings->video.smooth :
(d3d->shader.lut[i].filter == RARCH_FILTER_LINEAR));
if (!ret)
return ret;
}
return true;
}
static bool d3d_process_shader(d3d_video_t *d3d);
static bool d3d_init_chain(d3d_video_t *d3d,
const video_info_t *video_info);
#ifdef HAVE_OVERLAY
2015-03-15 16:51:27 +00:00
static void d3d_free_overlays(d3d_video_t *d3d);
static void d3d_free_overlay(d3d_video_t *d3d, overlay_t *overlay);
#endif
#ifdef HAVE_WINDOW
2015-04-05 23:10:39 +00:00
#define IDI_ICON 1
2015-04-05 23:10:39 +00:00
2015-05-09 16:07:59 +00:00
#ifndef MAX_MONITORS
#define MAX_MONITORS 9
2015-05-09 16:07:59 +00:00
#endif
extern LRESULT CALLBACK WindowProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam);
static void d3d_monitor_rect(MONITORINFOEX *mon, HMONITOR *hm_to_use, unsigned *mon_id);
#endif
#ifdef HAVE_MONITOR
2015-11-11 04:32:00 +00:00
static HMONITOR monitor_d3d_last;
static HMONITOR monitor_d3d_all[MAX_MONITORS];
static unsigned monitor_d3d_count;
#endif
static void d3d_deinit_chain(d3d_video_t *d3d)
{
2015-11-09 18:08:57 +00:00
d3d->renderchain_driver->chain_free(d3d->renderchain_data);
d3d->renderchain_driver = NULL;
d3d->renderchain_data = NULL;
}
2015-03-15 16:51:27 +00:00
static void d3d_deinitialize(d3d_video_t *d3d)
{
driver_t *driver = driver_get_ptr();
const font_renderer_t *font_ctx = NULL;
2015-03-15 16:51:27 +00:00
if (!d3d)
return;
font_ctx = (const font_renderer_t*)driver->font_osd_driver;
2015-03-29 21:58:00 +00:00
if (font_ctx->free)
font_ctx->free(driver->font_osd_data);
2015-03-29 21:58:00 +00:00
font_ctx = NULL;
d3d_deinit_chain(d3d);
#ifndef _XBOX
d3d->needs_restore = false;
#endif
}
2015-04-11 19:56:38 +00:00
void d3d_make_d3dpp(void *data,
2015-04-11 19:54:52 +00:00
const video_info_t *info, D3DPRESENT_PARAMETERS *d3dpp)
{
d3d_video_t *d3d = (d3d_video_t*)data;
settings_t *settings = config_get_ptr();
/* TODO/FIXME - get rid of global state dependencies. */
global_t *global = global_get_ptr();
2015-04-11 19:54:52 +00:00
memset(d3dpp, 0, sizeof(*d3dpp));
d3dpp->Windowed = false;
#ifndef _XBOX
d3dpp->Windowed = settings->video.windowed_fullscreen || !info->fullscreen;
#endif
d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
if (info->vsync)
{
switch (settings->video.swap_interval)
{
default:
case 1:
d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_ONE;
break;
case 2:
d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_TWO;
break;
case 3:
d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_THREE;
break;
case 4:
d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_FOUR;
break;
}
}
d3dpp->SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp->BackBufferCount = 2;
#ifdef _XBOX
d3dpp->BackBufferFormat =
#ifdef _XBOX360
global->console.screen.gamma_correction ?
(D3DFORMAT)MAKESRGBFMT(info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5) :
#endif
info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5;
#else
d3dpp->hDeviceWindow = d3d->hWnd;
d3dpp->BackBufferFormat = !d3dpp->Windowed ? D3DFMT_X8R8G8B8 : D3DFMT_UNKNOWN;
#endif
if (!d3dpp->Windowed)
{
#ifdef _XBOX
unsigned width = 0;
unsigned height = 0;
gfx_ctx_get_video_size(d3d, &width, &height);
video_driver_set_size_width(width);
video_driver_set_size_height(height);
#endif
video_driver_get_size(&d3dpp->BackBufferWidth, &d3dpp->BackBufferHeight);
}
#ifdef _XBOX
d3dpp->MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp->EnableAutoDepthStencil = FALSE;
#if defined(_XBOX1)
/* Get the "video mode" */
DWORD video_mode = XGetVideoFlags();
/* Check if we are able to use progressive mode. */
if (video_mode & XC_VIDEO_FLAGS_HDTV_480p)
d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE;
else
d3dpp->Flags = D3DPRESENTFLAG_INTERLACED;
/* Only valid in PAL mode, not valid for HDTV modes. */
if (XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I)
2015-04-11 19:54:52 +00:00
{
if (video_mode & XC_VIDEO_FLAGS_PAL_60Hz)
d3dpp->FullScreen_RefreshRateInHz = 60;
else
d3dpp->FullScreen_RefreshRateInHz = 50;
2015-04-11 19:54:52 +00:00
}
if (XGetAVPack() == XC_AV_PACK_HDTV)
{
if (video_mode & XC_VIDEO_FLAGS_HDTV_480p)
d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE;
else if (video_mode & XC_VIDEO_FLAGS_HDTV_720p)
d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE;
else if (video_mode & XC_VIDEO_FLAGS_HDTV_1080i)
d3dpp->Flags = D3DPRESENTFLAG_INTERLACED;
}
if (widescreen_mode)
d3dpp->Flags |= D3DPRESENTFLAG_WIDESCREEN;
#elif defined(_XBOX360)
if (!widescreen_mode)
d3dpp->Flags |= D3DPRESENTFLAG_NO_LETTERBOX;
if (global->console.screen.gamma_correction)
d3dpp->FrontBufferFormat = (D3DFORMAT)MAKESRGBFMT(D3DFMT_LE_X8R8G8B8);
else
d3dpp->FrontBufferFormat = D3DFMT_LE_X8R8G8B8;
d3dpp->MultiSampleQuality = 0;
#endif
#endif
2015-04-11 19:54:52 +00:00
}
static bool d3d_init_base(void *data, const video_info_t *info)
{
D3DPRESENT_PARAMETERS d3dpp;
2015-03-16 17:33:47 +00:00
d3d_video_t *d3d = (d3d_video_t*)data;
d3d_make_d3dpp(d3d, info, &d3dpp);
d3d->g_pD3D = D3DCREATE_CTX(D3D_SDK_VERSION);
if (!d3d->g_pD3D)
{
RARCH_ERR("Failed to create D3D interface.\n");
return false;
}
#ifdef _XBOX360
2015-03-16 17:33:47 +00:00
d3d->cur_mon_id = 0;
#endif
if (FAILED(d3d->d3d_err = d3d->g_pD3D->CreateDevice(
d3d->cur_mon_id,
D3DDEVTYPE_HAL,
d3d->hWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&d3dpp,
&d3d->dev)))
{
RARCH_WARN("[D3D]: Failed to init device with hardware vertex processing (code: 0x%x). Trying to fall back to software vertex processing.\n",
(unsigned)d3d->d3d_err);
if (FAILED(d3d->d3d_err = d3d->g_pD3D->CreateDevice(
d3d->cur_mon_id,
D3DDEVTYPE_HAL,
d3d->hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&d3d->dev)))
{
RARCH_ERR("Failed to initialize device.\n");
return false;
}
}
return true;
}
static void d3d_set_viewport(void *data,
2015-11-10 21:18:08 +00:00
unsigned width, unsigned height,
bool force_full,
2015-11-10 21:18:08 +00:00
bool allow_rotate)
{
D3DVIEWPORT viewport;
2015-11-10 21:18:08 +00:00
d3d_video_t *d3d = (d3d_video_t*)data;
int x = 0;
int y = 0;
float device_aspect = (float)width / height;
settings_t *settings = config_get_ptr();
float desired_aspect = video_driver_get_aspect_ratio();
video_driver_get_size(&width, &height);
gfx_ctx_translate_aspect(d3d, &device_aspect, width, height);
if (settings->video.scale_integer && !force_full)
{
struct video_viewport vp = {0};
video_viewport_get_scaled_integer(&vp, width, height, desired_aspect, d3d->keep_aspect);
x = vp.x;
y = vp.y;
2015-11-10 21:36:05 +00:00
width = vp.width;
height = vp.height;
}
else if (d3d->keep_aspect && !force_full)
{
if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{
video_viewport_t *custom = video_viewport_get_custom();
2015-11-10 21:18:08 +00:00
if (custom)
{
x = custom->x;
y = custom->y;
2015-11-10 21:36:05 +00:00
width = custom->width;
height = custom->height;
}
}
else
{
float delta;
if (fabsf(device_aspect - desired_aspect) < 0.0001f) { }
else if (device_aspect > desired_aspect)
{
delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f;
x = int(roundf(width * (0.5f - delta)));
y = 0;
2015-11-10 21:36:05 +00:00
width = unsigned(roundf(2.0f * width * delta));
}
else
{
delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f;
x = 0;
y = int(roundf(height * (0.5f - delta)));
2015-11-10 21:36:05 +00:00
height = unsigned(roundf(2.0f * height * delta));
}
}
}
/* D3D doesn't support negative X/Y viewports ... */
if (x < 0)
x = 0;
if (y < 0)
y = 0;
viewport.X = x;
viewport.Y = y;
viewport.Width = width;
viewport.Height = height;
viewport.MinZ = 0.0f;
viewport.MaxZ = 1.0f;
d3d->final_viewport = viewport;
if (d3d->renderchain_driver && d3d->renderchain_data)
{
if (d3d->renderchain_driver->set_font_rect)
d3d->renderchain_driver->set_font_rect(d3d, NULL);
}
2015-11-10 21:18:08 +00:00
}
2015-03-15 16:51:27 +00:00
static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info)
{
unsigned width, height;
2015-04-05 14:34:31 +00:00
bool ret = true;
2015-03-20 21:08:36 +00:00
settings_t *settings = config_get_ptr();
driver_t *driver = driver_get_ptr();
2015-01-17 05:30:39 +00:00
2015-03-15 16:51:27 +00:00
if (!d3d)
return false;
if (!d3d->g_pD3D)
ret = d3d_init_base(d3d, info);
else if (d3d->needs_restore)
{
D3DPRESENT_PARAMETERS d3dpp;
2015-03-16 17:33:47 +00:00
d3d_make_d3dpp(d3d, info, &d3dpp);
2015-03-16 17:33:47 +00:00
if (d3d->dev->Reset(&d3dpp) != D3D_OK)
{
2015-01-17 05:30:39 +00:00
/* Try to recreate the device completely. */
#ifndef _XBOX
2015-06-13 00:10:06 +00:00
HRESULT res = d3d->dev->TestCooperativeLevel();
const char *err = NULL;
switch (res)
{
case D3DERR_DEVICELOST:
err = "DEVICELOST";
break;
case D3DERR_DEVICENOTRESET:
err = "DEVICENOTRESET";
break;
case D3DERR_DRIVERINTERNALERROR:
err = "DRIVERINTERNALERROR";
break;
default:
err = "Unknown";
}
RARCH_WARN(
"[D3D]: Attempting to recover from dead state (%s).\n", err);
#else
RARCH_WARN("[D3D]: Attempting to recover from dead state.\n");
#endif
2015-05-20 22:28:12 +00:00
d3d_deinitialize(d3d);
d3d->g_pD3D->Release();
d3d->g_pD3D = NULL;
ret = d3d_init_base(d3d, info);
if (ret)
RARCH_LOG("[D3D]: Recovered from dead state.\n");
}
}
if (!ret)
return ret;
if (!d3d_init_chain(d3d, info))
{
RARCH_ERR("Failed to initialize render chain.\n");
return false;
}
video_driver_get_size(&width, &height);
d3d_set_viewport(d3d,
width, height, false, true);
#if defined(_XBOX360)
2015-03-20 21:08:36 +00:00
strlcpy(settings->video.font_path, "game:\\media\\Arial_12.xpr",
sizeof(settings->video.font_path));
#endif
if (!font_init_first((const void**)&driver->font_osd_driver, &driver->font_osd_data,
2015-04-21 15:53:11 +00:00
d3d, settings->video.font_path, 0, FONT_DRIVER_RENDER_DIRECT3D_API))
{
RARCH_ERR("[D3D]: Failed to initialize font renderer.\n");
return false;
}
return true;
}
bool d3d_restore(d3d_video_t *d3d)
{
d3d_deinitialize(d3d);
d3d->needs_restore = !d3d_initialize(d3d, &d3d->video_info);
if (d3d->needs_restore)
RARCH_ERR("[D3D]: Restore error.\n");
return !d3d->needs_restore;
}
static void d3d_set_nonblock_state(void *data, bool state)
{
2015-04-09 16:38:24 +00:00
d3d_video_t *d3d = (d3d_video_t*)data;
2015-03-16 17:33:47 +00:00
if (!d3d)
return;
d3d->video_info.vsync = !state;
2015-04-10 06:34:28 +00:00
gfx_ctx_swap_interval(d3d, state ? 0 : 1);
}
static bool d3d_alive(void *data)
{
unsigned temp_width = 0, temp_height = 0;
2015-05-20 00:40:44 +00:00
bool ret = false;
d3d_video_t *d3d = (d3d_video_t*)data;
bool quit = false;
bool resize = false;
2015-04-09 16:38:24 +00:00
if (gfx_ctx_check_window(d3d, &quit, &resize,
&temp_width, &temp_height))
{
if (quit)
d3d->quitting = quit;
else if (resize)
d3d->should_resize = true;
ret = !quit;
}
if (temp_width != 0 && temp_height != 0)
{
video_driver_set_size_width(temp_width);
video_driver_set_size_height(temp_height);
}
return ret;
}
static bool d3d_focus(void *data)
{
return gfx_ctx_focus(data);
}
2015-01-18 21:43:07 +00:00
static bool d3d_suppress_screensaver(void *data, bool enable)
{
return gfx_ctx_suppress_screensaver(data, enable);
2015-01-18 21:43:07 +00:00
}
static bool d3d_has_windowed(void *data)
{
return gfx_ctx_has_windowed(data);
}
static void d3d_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
{
d3d_video_t *d3d = (d3d_video_t*)data;
2015-05-20 22:28:12 +00:00
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
switch (aspect_ratio_idx)
{
case ASPECT_RATIO_SQUARE:
2015-01-18 22:59:57 +00:00
video_viewport_set_square_pixel(
av_info->geometry.base_width,
av_info->geometry.base_height);
break;
case ASPECT_RATIO_CORE:
2015-01-18 22:59:57 +00:00
video_viewport_set_core();
break;
case ASPECT_RATIO_CONFIG:
2015-01-18 22:59:57 +00:00
video_viewport_set_config();
break;
default:
break;
}
video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value);
2015-03-16 17:33:47 +00:00
2015-03-21 04:42:49 +00:00
if (!d3d)
return;
2015-11-10 04:30:25 +00:00
d3d->keep_aspect = true;
2015-03-21 04:42:49 +00:00
d3d->should_resize = true;
}
static void d3d_apply_state_changes(void *data)
{
d3d_video_t *d3d = (d3d_video_t*)data;
2015-01-17 05:30:39 +00:00
if (d3d)
d3d->should_resize = true;
}
static void d3d_set_osd_msg(void *data, const char *msg,
2014-11-09 19:27:51 +00:00
const struct font_params *params, void *font)
{
2015-04-05 14:34:31 +00:00
d3d_video_t *d3d = (d3d_video_t*)data;
driver_t *driver = driver_get_ptr();
const font_renderer_t *font_ctx = driver->font_osd_driver;
if (d3d->renderchain_driver->set_font_rect && params)
d3d->renderchain_driver->set_font_rect(d3d, params);
2015-03-29 21:58:00 +00:00
if (font_ctx->render_msg)
font_ctx->render_msg(driver->font_osd_data, msg, params);
}
/* Delay constructor due to lack of exceptions. */
static bool d3d_construct(d3d_video_t *d3d,
const video_info_t *info, const input_driver_t **input,
void **input_data)
{
2015-01-17 05:30:39 +00:00
unsigned full_x, full_y;
2015-04-09 16:38:24 +00:00
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
2015-01-17 05:30:39 +00:00
d3d->should_resize = false;
2015-04-06 18:47:29 +00:00
#if defined(HAVE_MENU)
if (d3d->menu)
free(d3d->menu);
d3d->menu = (overlay_t*)calloc(1, sizeof(overlay_t));
if (!d3d->menu)
return false;
2015-11-11 02:48:05 +00:00
d3d->menu->tex_coords[0] = 0;
d3d->menu->tex_coords[1] = 0;
d3d->menu->tex_coords[2] = 1;
d3d->menu->tex_coords[3] = 1;
d3d->menu->vert_coords[0] = 0;
d3d->menu->vert_coords[1] = 1;
d3d->menu->vert_coords[2] = 1;
d3d->menu->vert_coords[3] = -1;
#endif
#if defined(HAVE_WINDOW) && !defined(_XBOX)
memset(&d3d->windowClass, 0, sizeof(d3d->windowClass));
2015-03-16 17:33:47 +00:00
d3d->windowClass.cbSize = sizeof(d3d->windowClass);
d3d->windowClass.style = CS_HREDRAW | CS_VREDRAW;
d3d->windowClass.lpfnWndProc = WindowProc;
d3d->windowClass.hInstance = NULL;
d3d->windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
d3d->windowClass.lpszClassName = "RetroArch";
d3d->windowClass.hIcon = LoadIcon(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDI_ICON));
d3d->windowClass.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0);
if (!info->fullscreen)
d3d->windowClass.hbrBackground = (HBRUSH)COLOR_WINDOW;
RegisterClassEx(&d3d->windowClass);
#endif
#ifdef HAVE_MONITOR
2015-11-11 04:32:00 +00:00
bool windowed_full;
RECT mon_rect;
2015-11-11 04:35:32 +00:00
MONITORINFOEX current_mon;
2015-11-11 04:32:55 +00:00
HMONITOR hm_to_use;
d3d_monitor_rect(&current_mon, &hm_to_use, &d3d->cur_mon_id);
2015-11-11 04:34:21 +00:00
mon_rect = current_mon.rcMonitor;
2015-11-11 04:32:00 +00:00
windowed_full = settings->video.windowed_fullscreen;
2015-05-20 22:28:12 +00:00
full_x = (windowed_full || info->width == 0) ?
(mon_rect.right - mon_rect.left) : info->width;
2015-05-20 22:28:12 +00:00
full_y = (windowed_full || info->height == 0) ?
(mon_rect.bottom - mon_rect.top) : info->height;
2015-05-20 22:28:12 +00:00
RARCH_LOG("[D3D]: Monitor size: %dx%d.\n",
(int)(mon_rect.right - mon_rect.left),
(int)(mon_rect.bottom - mon_rect.top));
#else
2015-04-10 05:12:15 +00:00
gfx_ctx_get_video_size(d3d, &full_x, &full_y);
#endif
video_driver_set_size_width(info->fullscreen ? full_x : info->width);
video_driver_set_size_height(info->fullscreen ? full_y : info->height);
2015-04-05 23:43:47 +00:00
#ifndef _XBOX
#ifdef HAVE_WINDOW
unsigned win_width, win_height;
2015-06-13 00:10:06 +00:00
char buffer[128] = {0};
RECT rect = {0};
video_driver_get_size(&win_width, &win_height);
if (!info->fullscreen)
{
2015-05-20 00:45:32 +00:00
video_driver_get_size((unsigned*)&rect.right, (unsigned*)&rect.bottom);
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
2015-04-05 14:34:31 +00:00
win_width = rect.right - rect.left;
win_height = rect.bottom - rect.top;
}
video_monitor_get_fps(buffer, sizeof(buffer), NULL, 0);
2015-09-28 14:57:07 +00:00
strlcat(buffer, " || Direct3D", sizeof(buffer));
2015-04-10 05:41:37 +00:00
d3d->hWnd = CreateWindowEx(0, "RetroArch", buffer,
info->fullscreen ?
(WS_EX_TOPMOST | WS_POPUP) : WS_OVERLAPPEDWINDOW,
info->fullscreen ? mon_rect.left : CW_USEDEFAULT,
info->fullscreen ? mon_rect.top : CW_USEDEFAULT,
win_width, win_height,
NULL, NULL, NULL, d3d);
driver->display_type = RARCH_DISPLAY_WIN32;
driver->video_display = 0;
driver->video_window = (uintptr_t)d3d->hWnd;
2015-04-05 23:43:47 +00:00
#endif
#endif
2015-04-10 06:49:01 +00:00
gfx_ctx_show_mouse(d3d, !info->fullscreen
#ifdef HAVE_OVERLAY
2015-04-10 06:49:01 +00:00
|| d3d->overlays_enabled
#endif
2015-04-10 06:49:01 +00:00
);
2015-04-05 23:43:47 +00:00
#ifndef _XBOX
#ifdef HAVE_WINDOW
2015-03-20 21:08:36 +00:00
if (!info->fullscreen && settings->ui.menubar_enable)
{
2015-04-10 05:25:45 +00:00
RECT rc_temp = {0, 0, (LONG)win_height, 0x7FFF};
2015-03-16 17:33:47 +00:00
SetMenu(d3d->hWnd, LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_MENU)));
SendMessage(d3d->hWnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rc_temp);
win_height += rc_temp.top + rect.top;
SetWindowPos(d3d->hWnd, NULL, 0, 0, win_width, win_height, SWP_NOMOVE);
}
ShowWindow(d3d->hWnd, SW_RESTORE);
UpdateWindow(d3d->hWnd);
SetForegroundWindow(d3d->hWnd);
SetFocus(d3d->hWnd);
#endif
#ifdef HAVE_SHADERS
/* This should only be done once here
* to avoid set_shader() to be overridden
* later. */
2015-05-20 22:28:12 +00:00
enum rarch_shader_type type =
2015-03-20 21:08:36 +00:00
video_shader_parse_type(settings->video.shader_path, RARCH_SHADER_NONE);
if (settings->video.shader_enable && type == RARCH_SHADER_CG)
2015-04-05 16:20:45 +00:00
d3d->shader_path = settings->video.shader_path;
if (!d3d_process_shader(d3d))
return false;
#endif
2015-04-05 23:43:47 +00:00
#endif
d3d->video_info = *info;
if (!d3d_initialize(d3d, &d3d->video_info))
return false;
2015-04-10 06:53:45 +00:00
gfx_ctx_input_driver(d3d, input, input_data);
RARCH_LOG("[D3D]: Init complete.\n");
return true;
}
2015-02-14 04:52:05 +00:00
static void d3d_viewport_info(void *data, struct video_viewport *vp)
{
d3d_video_t *d3d = (d3d_video_t*)data;
if (!d3d || !d3d->renderchain_driver || !d3d->renderchain_driver->viewport_info)
2015-11-11 00:45:43 +00:00
return;
d3d->renderchain_driver->viewport_info(d3d, vp);
}
static void d3d_set_rotation(void *data, unsigned rot)
{
d3d_video_t *d3d = (d3d_video_t*)data;
2015-11-09 23:13:17 +00:00
struct gfx_ortho ortho = {0, 1, 0, 1, -1, 1};
if (!d3d)
return;
d3d->dev_rotation = rot;
}
static void d3d_show_mouse(void *data, bool state)
{
2015-04-10 04:46:25 +00:00
gfx_ctx_show_mouse(data, state);
}
static const gfx_ctx_driver_t *d3d_get_context(void *data)
{
/* Default to Direct3D9 for now.
TODO: GL core contexts through ANGLE? */
2015-04-05 14:34:31 +00:00
unsigned minor = 0;
2015-03-20 21:08:36 +00:00
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
2015-04-05 14:34:31 +00:00
#if defined(HAVE_D3D8)
2015-09-29 16:08:33 +00:00
unsigned major = 8;
enum gfx_ctx_api api = GFX_CTX_DIRECT3D8_API;
#else
unsigned major = 9;
enum gfx_ctx_api api = GFX_CTX_DIRECT3D9_API;
#endif
return gfx_ctx_init_first(driver->video_data,
2015-03-20 21:08:36 +00:00
settings->video.context_driver,
2014-10-24 00:15:30 +00:00
api, major, minor, false);
}
static void *d3d_init(const video_info_t *info,
const input_driver_t **input, void **input_data)
{
2015-04-09 16:38:24 +00:00
d3d_video_t *vid = NULL;
driver_t *driver = driver_get_ptr();
const gfx_ctx_driver_t *ctx = NULL;
2015-01-17 05:30:39 +00:00
#ifdef _XBOX
if (driver->video_data)
{
d3d_video_t *vid = (d3d_video_t*)driver->video_data;
2015-05-20 22:28:12 +00:00
/* Reinitialize renderchain as we
* might have changed pixel formats.*/
2015-04-06 21:38:02 +00:00
if (vid->renderchain_driver->reinit(vid, (const void*)info))
{
2015-04-06 21:38:02 +00:00
d3d_deinit_chain(vid);
d3d_init_chain(vid, info);
2015-04-06 21:26:14 +00:00
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
2015-04-19 16:58:27 +00:00
vid = new d3d_video_t();
if (!vid)
2015-04-05 23:12:42 +00:00
goto error;
2015-04-09 16:38:24 +00:00
ctx = d3d_get_context(vid);
if (!ctx)
2015-04-05 23:12:42 +00:00
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
2015-04-11 20:05:54 +00:00
#ifdef HAVE_MENU
vid->menu = NULL;
2015-04-11 20:05:54 +00:00
#endif
#endif
2015-04-09 16:38:24 +00:00
driver->video_context = ctx;
if (!d3d_construct(vid, info, input, input_data))
{
RARCH_ERR("[D3D]: Failed to init D3D.\n");
2015-04-05 23:12:42 +00:00
goto error;
}
2015-11-10 04:30:25 +00:00
vid->keep_aspect = info->force_aspect;
#ifdef _XBOX
driver->video_data_own = true;
driver->input_data_own = true;
#endif
return vid;
2015-04-05 23:12:42 +00:00
error:
if (vid)
2015-04-19 16:58:27 +00:00
delete vid;
2015-04-09 16:38:24 +00:00
if (driver)
driver->video_context = NULL;
2015-04-05 23:12:42 +00:00
return NULL;
}
static void d3d_free(void *data)
{
2015-04-09 16:38:24 +00:00
d3d_video_t *d3d = (d3d_video_t*)data;
if (!d3d)
return;
d3d_deinitialize(d3d);
#ifdef HAVE_OVERLAY
d3d_free_overlays(d3d);
#endif
2015-04-05 23:43:47 +00:00
#ifdef _XBOX
gfx_ctx_free(d3d);
#else
2015-04-05 23:43:47 +00:00
#ifdef HAVE_MENU
d3d_free_overlay(d3d, d3d->menu);
#endif
#endif
if (d3d->dev)
d3d->dev->Release();
if (d3d->g_pD3D)
d3d->g_pD3D->Release();
#ifdef HAVE_MONITOR
2015-11-11 04:32:00 +00:00
monitor_d3d_last = MonitorFromWindow(d3d->hWnd,
MONITOR_DEFAULTTONEAREST);
DestroyWindow(d3d->hWnd);
#endif
if (d3d)
2015-04-19 16:58:27 +00:00
delete d3d;
#ifndef _XBOX
UnregisterClass("RetroArch", GetModuleHandle(NULL));
#endif
}
#ifdef HAVE_MONITOR
static BOOL CALLBACK d3d_monitor_enum_proc(HMONITOR hMonitor,
HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
{
monitor_d3d_all[monitor_d3d_count++] = hMonitor;
return TRUE;
}
/* Multi-monitor support. */
static void d3d_monitor_rect(MONITORINFOEX *mon, HMONITOR *hm_to_use, unsigned *mon_id)
{
unsigned i, fs_monitor;
monitor_d3d_count = 0;
settings_t *settings = config_get_ptr();
EnumDisplayMonitors(NULL, NULL, d3d_monitor_enum_proc, 0);
if (!monitor_d3d_last)
monitor_d3d_last = MonitorFromWindow(
GetDesktopWindow(), MONITOR_DEFAULTTONEAREST);
*hm_to_use = monitor_d3d_last;
fs_monitor = settings->video.monitor_index;
if (fs_monitor && fs_monitor <= monitor_d3d_count
&& monitor_d3d_all[fs_monitor - 1])
{
*hm_to_use = monitor_d3d_all[fs_monitor - 1];
*mon_id = fs_monitor - 1;
}
else
{
for (i = 0; i < monitor_d3d_count; i++)
{
if (monitor_d3d_all[i] != *hm_to_use)
continue;
*mon_id = i;
break;
}
}
memset(mon, 0, sizeof(*mon));
mon->cbSize = sizeof(MONITORINFOEX);
GetMonitorInfo(*hm_to_use, (MONITORINFO*)mon);
}
#endif
2014-01-09 17:44:25 +00:00
2014-03-08 03:56:27 +00:00
#ifndef DONT_HAVE_STATE_TRACKER
2014-06-17 19:33:04 +00:00
static bool d3d_init_imports(d3d_video_t *d3d)
2014-03-08 03:03:12 +00:00
{
2015-03-16 17:18:01 +00:00
state_tracker_t *state_tracker = NULL;
2015-01-17 05:30:39 +00:00
state_tracker_info tracker_info = {0};
2014-03-08 03:03:12 +00:00
if (!d3d->shader.variables)
return true;
2015-11-10 21:46:45 +00:00
if (!d3d->renderchain_driver->add_state_tracker)
return true;
2014-03-08 03:03:12 +00:00
2015-04-05 14:34:31 +00:00
tracker_info.wram = (uint8_t*)
2015-10-07 01:52:35 +00:00
core.retro_get_memory_data(RETRO_MEMORY_SYSTEM_RAM);
2015-04-05 14:34:31 +00:00
tracker_info.info = d3d->shader.variable;
2014-03-08 03:03:12 +00:00
tracker_info.info_elem = d3d->shader.variables;
#ifdef HAVE_PYTHON
if (*d3d->shader.script_path)
{
tracker_info.script = d3d->shader.script_path;
tracker_info.script_is_file = true;
}
2015-05-20 22:28:12 +00:00
tracker_info.script_class =
2014-09-08 17:28:10 +00:00
*d3d->shader.script_class ? d3d->shader.script_class : NULL;
2014-03-08 03:03:12 +00:00
#endif
2015-03-16 17:18:01 +00:00
state_tracker = state_tracker_init(&tracker_info);
2014-03-08 03:03:12 +00:00
if (!state_tracker)
{
RARCH_ERR("Failed to initialize state tracker.\n");
return false;
}
d3d->renderchain_driver->add_state_tracker(d3d->renderchain_data, state_tracker);
2015-11-10 21:46:45 +00:00
2014-03-08 03:03:12 +00:00
return true;
}
2014-03-08 03:56:27 +00:00
#endif
2014-03-08 03:03:12 +00:00
2014-06-17 19:33:04 +00:00
static bool d3d_init_chain(d3d_video_t *d3d, const video_info_t *video_info)
2014-03-08 03:03:12 +00:00
{
2015-03-15 16:51:27 +00:00
unsigned current_width, current_height, out_width, out_height;
2015-04-05 23:14:52 +00:00
unsigned i = 0;
2014-03-08 03:03:12 +00:00
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
2015-04-05 23:14:52 +00:00
LinkInfo link_info = {0};
2015-01-17 05:47:00 +00:00
(void)i;
2015-03-21 21:48:27 +00:00
(void)current_width;
(void)current_height;
(void)out_width;
(void)out_height;
2014-09-08 17:28:10 +00:00
/* Setup information for first pass. */
2015-04-06 21:51:39 +00:00
#ifndef _XBOX
2015-04-05 14:34:31 +00:00
link_info.pass = &d3d->shader.pass[0];
2015-04-06 21:51:39 +00:00
#endif
2015-05-20 22:28:12 +00:00
link_info.tex_w = link_info.tex_h =
2014-09-08 17:28:10 +00:00
video_info->input_scale * RARCH_SCALE_BASE;
2014-03-08 03:03:12 +00:00
2015-04-06 15:07:39 +00:00
if (!renderchain_init_first(&d3d->renderchain_driver,
&d3d->renderchain_data))
{
RARCH_ERR("Renderchain could not be initialized.\n");
return false;
}
if (!d3d->renderchain_driver || !d3d->renderchain_data)
return false;
2015-04-06 15:07:39 +00:00
RARCH_LOG("Renderchain driver: %s\n", d3d->renderchain_driver->ident);
2015-04-05 23:36:27 +00:00
if (!d3d->renderchain_driver->init_shader(d3d, d3d->renderchain_data))
{
RARCH_ERR("Failed to initialize shader subsystem.\n");
return false;
}
2015-11-10 04:09:31 +00:00
if (
!d3d->renderchain_driver->init(
d3d,
&d3d->video_info,
2015-04-05 23:36:27 +00:00
d3dr, &d3d->final_viewport, &link_info,
2015-11-11 01:42:15 +00:00
d3d->video_info.rgb32)
2015-11-10 04:09:31 +00:00
)
{
2015-04-05 23:36:27 +00:00
RARCH_ERR("[D3D]: Failed to init render chain.\n");
return false;
}
2014-03-08 03:03:12 +00:00
2015-04-05 23:36:27 +00:00
#ifndef _XBOX
2015-03-15 16:51:27 +00:00
current_width = link_info.tex_w;
current_height = link_info.tex_h;
out_width = 0;
out_height = 0;
2014-03-08 03:03:12 +00:00
2015-01-17 05:30:39 +00:00
for (i = 1; i < d3d->shader.passes; i++)
2014-03-08 03:03:12 +00:00
{
d3d->renderchain_driver->convert_geometry(d3d->renderchain_data,
2015-04-06 14:15:29 +00:00
&link_info,
2015-04-04 22:44:54 +00:00
&out_width, &out_height,
2014-03-08 03:03:12 +00:00
current_width, current_height, &d3d->final_viewport);
2015-04-05 14:34:31 +00:00
link_info.pass = &d3d->shader.pass[i];
2014-03-08 03:03:12 +00:00
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 (!d3d->renderchain_driver->add_pass(d3d->renderchain_data, &link_info))
2014-03-08 03:03:12 +00:00
{
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;
}
2014-03-08 03:56:27 +00:00
#ifndef DONT_HAVE_STATE_TRACKER
2014-03-08 03:03:12 +00:00
if (!d3d_init_imports(d3d))
{
RARCH_ERR("[D3D9]: Failed to init imports.\n");
return false;
}
2014-03-08 03:56:27 +00:00
#endif
2015-04-05 23:36:27 +00:00
#endif
return true;
}
#ifdef _XBOX
#ifdef HAVE_RMENU
extern struct texture_image *menu_texture;
#endif
#ifdef _XBOX1
2015-04-12 20:29:30 +00:00
#include <formats/image.h>
2015-03-15 16:51:27 +00:00
static bool texture_image_render(d3d_video_t *d3d,
struct texture_image *out_img,
int x, int y, int w, int h, bool force_fullscreen)
{
2015-04-12 20:29:30 +00:00
LPDIRECT3DTEXTURE d3dt;
LPDIRECT3DVERTEXBUFFER d3dv;
2015-04-05 14:34:31 +00:00
void *verts = NULL;
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
2015-04-05 14:34:31 +00:00
float fX = (float)(x);
float fY = (float)(y);
2015-03-15 16:51:27 +00:00
if (!d3d)
return false;
2015-04-12 20:29:30 +00:00
d3dt = (LPDIRECT3DTEXTURE)out_img->texture_buf;
d3dv = (LPDIRECT3DVERTEXBUFFER)out_img->vertex_buf;
if (!d3dt || !d3dv)
return false;
2015-04-05 14:34:31 +00:00
/* Create the new vertices. */
Vertex newVerts[] =
{
// x, y, z, color, u ,v
{fX, fY, 0.0f, 0, 0, 0},
{fX + w, fY, 0.0f, 0, 1, 0},
{fX + w, fY + h, 0.0f, 0, 1, 1},
{fX, fY + h, 0.0f, 0, 0, 1}
};
2015-01-17 05:30:39 +00:00
/* Load the existing vertices */
2015-04-12 20:29:30 +00:00
verts = d3d_vertex_buffer_lock(d3dv);
if (!verts)
return false;
2015-01-17 05:30:39 +00:00
/* Copy the new verts over the old verts */
memcpy(verts, newVerts, sizeof(newVerts));
2015-04-12 20:29:30 +00:00
d3d_vertex_buffer_unlock(d3dv);
d3d_enable_blend_func(d3d->dev);
d3d_enable_alpha_blend_texture_func(d3d->dev);
/* Draw the quad. */
2015-04-12 20:29:30 +00:00
d3d_set_texture(d3dr, 0, d3dt);
d3d_set_stream_source(d3dr, 0,
2015-04-12 20:29:30 +00:00
d3dv, 0, sizeof(Vertex));
d3d_set_vertex_shader(d3dr, D3DFVF_CUSTOMVERTEX, NULL);
if (force_fullscreen)
d3d_set_viewport(d3d, w, h, force_fullscreen, false);
d3d_draw_primitive(d3dr, D3DPT_QUADLIST, 0, 1);
2014-03-08 03:03:12 +00:00
return true;
}
#endif
#ifdef HAVE_MENU
2015-03-15 16:51:27 +00:00
static void d3d_draw_texture(d3d_video_t *d3d)
{
2015-03-15 16:51:27 +00:00
if (!d3d)
return;
2015-01-17 05:30:39 +00:00
#if defined(HAVE_RMENU)
menu_texture->x = 0;
menu_texture->y = 0;
2015-04-06 18:51:24 +00:00
if (d3d->menu->enabled)
{
d3d_enable_blend_func(d3d->dev);
texture_image_render(d3d, menu_texture,
menu_texture->x, menu_texture->y,
d3d->screen_width, d3d->screen_height, true);
d3d_disable_blend_func(d3d->dev);
}
#endif
}
#endif
2015-04-05 23:43:47 +00:00
#endif
2014-03-08 03:03:12 +00:00
2014-03-08 03:08:18 +00:00
#ifdef HAVE_FBO
2014-06-17 19:33:04 +00:00
static bool d3d_init_multipass(d3d_video_t *d3d)
2014-03-08 03:08:18 +00:00
{
2015-01-17 05:30:39 +00:00
unsigned i;
2015-03-16 17:18:01 +00:00
bool use_extra_pass;
video_shader_pass *pass = NULL;
2015-04-05 16:20:45 +00:00
config_file_t *conf = config_file_new(d3d->shader_path.c_str());
2015-01-17 05:30:39 +00:00
2014-03-08 03:08:18 +00:00
if (!conf)
{
RARCH_ERR("Failed to load preset.\n");
return false;
}
memset(&d3d->shader, 0, sizeof(d3d->shader));
if (!video_shader_read_conf_cgp(conf, &d3d->shader))
2014-03-08 03:08:18 +00:00
{
config_file_free(conf);
RARCH_ERR("Failed to parse CGP file.\n");
return false;
}
config_file_free(conf);
2015-04-05 16:20:45 +00:00
video_shader_resolve_relative(&d3d->shader, d3d->shader_path.c_str());
2014-03-08 03:08:18 +00:00
RARCH_LOG("[D3D9 Meta-Cg] Found %u shaders.\n", d3d->shader.passes);
2014-03-08 03:08:18 +00:00
2015-01-17 05:30:39 +00:00
for (i = 0; i < d3d->shader.passes; i++)
2014-03-08 03:08:18 +00:00
{
2015-01-17 05:30:39 +00:00
if (d3d->shader.pass[i].fbo.valid)
continue;
2015-04-05 14:34:31 +00:00
d3d->shader.pass[i].fbo.scale_y = 1.0f;
d3d->shader.pass[i].fbo.scale_x = 1.0f;
d3d->shader.pass[i].fbo.type_x = RARCH_SCALE_INPUT;
d3d->shader.pass[i].fbo.type_y = RARCH_SCALE_INPUT;
2014-03-08 03:08:18 +00:00
}
2015-05-20 22:28:12 +00:00
use_extra_pass = d3d->shader.passes < GFX_MAX_SHADERS &&
2014-09-08 17:28:10 +00:00
d3d->shader.pass[d3d->shader.passes - 1].fbo.valid;
2014-03-08 03:08:18 +00:00
if (use_extra_pass)
{
d3d->shader.passes++;
2015-04-05 14:34:31 +00:00
pass = (video_shader_pass*)
2014-09-13 20:25:30 +00:00
&d3d->shader.pass[d3d->shader.passes - 1];
2015-03-16 17:18:01 +00:00
pass->fbo.scale_x = pass->fbo.scale_y = 1.0f;
pass->fbo.type_x = pass->fbo.type_y = RARCH_SCALE_VIEWPORT;
pass->filter = RARCH_FILTER_UNSPEC;
2014-03-08 03:08:18 +00:00
}
else
{
2015-04-05 14:34:31 +00:00
pass = (video_shader_pass*)
2014-09-13 20:25:30 +00:00
&d3d->shader.pass[d3d->shader.passes - 1];
pass->fbo.scale_x = pass->fbo.scale_y = 1.0f;
pass->fbo.type_x = pass->fbo.type_y = RARCH_SCALE_VIEWPORT;
2014-03-08 03:08:18 +00:00
}
return true;
}
#endif
2014-06-17 19:33:04 +00:00
static bool d3d_init_singlepass(d3d_video_t *d3d)
2014-03-08 03:08:18 +00:00
{
2014-09-11 18:59:52 +00:00
#ifndef _XBOX
2015-01-19 20:24:08 +00:00
video_shader_pass *pass = NULL;
2015-01-17 05:30:39 +00:00
2015-03-16 17:33:47 +00:00
if (!d3d)
return false;
2014-03-08 03:08:18 +00:00
memset(&d3d->shader, 0, sizeof(d3d->shader));
2015-04-05 14:34:31 +00:00
d3d->shader.passes = 1;
2014-09-13 20:25:30 +00:00
2015-04-05 14:34:31 +00:00
pass = (video_shader_pass*)&d3d->shader.pass[0];
pass->fbo.valid = true;
pass->fbo.scale_y = 1.0;
pass->fbo.type_y = RARCH_SCALE_VIEWPORT;
pass->fbo.scale_x = pass->fbo.scale_y;
pass->fbo.type_x = pass->fbo.type_y;
2015-04-05 16:20:45 +00:00
strlcpy(pass->source.path, d3d->shader_path.c_str(),
2014-09-13 20:25:30 +00:00
sizeof(pass->source.path));
2014-09-11 18:59:52 +00:00
#endif
2014-03-08 03:08:18 +00:00
return true;
}
2014-06-17 19:33:04 +00:00
static bool d3d_process_shader(d3d_video_t *d3d)
2014-03-08 03:08:18 +00:00
{
#ifdef HAVE_FBO
2014-09-08 17:28:10 +00:00
if (strcmp(path_get_extension(
2015-04-05 16:20:45 +00:00
d3d->shader_path.c_str()), "cgp") == 0)
2014-03-08 03:08:18 +00:00
return d3d_init_multipass(d3d);
#endif
return d3d_init_singlepass(d3d);
}
2014-03-08 03:03:12 +00:00
2014-01-09 17:44:25 +00:00
#ifdef HAVE_OVERLAY
2015-03-15 16:51:27 +00:00
static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay)
{
struct video_viewport vp;
unsigned width, height;
void *verts;
unsigned i;
2015-11-11 03:12:33 +00:00
float vert[4][9];
2015-01-17 05:30:39 +00:00
float overlay_width, overlay_height;
2015-03-16 17:33:47 +00:00
#ifndef _XBOX1
LPDIRECT3DVERTEXDECLARATION vertex_decl;
/* set vertex declaration for overlay. */
D3DVERTEXELEMENT vElems[4] = {
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT,
D3DDECLUSAGE_POSITION, 0},
{0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,
D3DDECLUSAGE_TEXCOORD, 0},
{0, 20, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT,
D3DDECLUSAGE_COLOR, 0},
D3DDECL_END()
};
#endif
2015-01-17 05:30:39 +00:00
2015-03-15 16:51:27 +00:00
if (!d3d)
return;
2015-01-17 05:30:39 +00:00
if (!overlay || !overlay->tex)
return;
if (!overlay->vert_buf)
{
overlay->vert_buf = d3d_vertex_buffer_new(
d3d->dev, sizeof(vert), 0, 0, D3DPOOL_MANAGED, NULL);
if (!overlay->vert_buf)
return;
}
for (i = 0; i < 4; i++)
{
2015-11-11 03:12:33 +00:00
vert[i][2] = 0.5f;
vert[i][5] = 1.0f;
vert[i][6] = 1.0f;
vert[i][7] = 1.0f;
vert[i][8] = overlay->alpha_mod;
}
d3d_viewport_info(d3d, &vp);
2015-11-11 00:46:59 +00:00
overlay_width = vp.width;
overlay_height = vp.height;
2015-11-11 03:12:33 +00:00
vert[0][0] = overlay->vert_coords[0] * overlay_width;
vert[1][0] = (overlay->vert_coords[0] + overlay->vert_coords[2])
* overlay_width;
2015-11-11 03:12:33 +00:00
vert[2][0] = overlay->vert_coords[0] * overlay_width;
vert[3][0] = (overlay->vert_coords[0] + overlay->vert_coords[2])
* overlay_width;
2015-11-11 03:12:33 +00:00
vert[0][1] = overlay->vert_coords[1] * overlay_height;
vert[1][1] = overlay->vert_coords[1] * overlay_height;
vert[2][1] = (overlay->vert_coords[1] + overlay->vert_coords[3])
* overlay_height;
2015-11-11 03:12:33 +00:00
vert[3][1] = (overlay->vert_coords[1] + overlay->vert_coords[3])
* overlay_height;
2015-11-11 03:12:33 +00:00
vert[0][3] = overlay->tex_coords[0];
vert[1][3] = overlay->tex_coords[0] + overlay->tex_coords[2];
vert[2][3] = overlay->tex_coords[0];
vert[3][3] = overlay->tex_coords[0] + overlay->tex_coords[2];
vert[0][4] = overlay->tex_coords[1];
vert[1][4] = overlay->tex_coords[1];
vert[2][4] = overlay->tex_coords[1] + overlay->tex_coords[3];
vert[3][4] = overlay->tex_coords[1] + overlay->tex_coords[3];
/* Align texels and vertices. */
for (i = 0; i < 4; i++)
{
2015-11-11 03:12:33 +00:00
vert[i][0] -= 0.5f;
vert[i][1] += 0.5f;
}
overlay->vert_buf->Lock(0, sizeof(vert), &verts, 0);
memcpy(verts, vert, sizeof(vert));
2014-09-13 17:56:52 +00:00
d3d_vertex_buffer_unlock(overlay->vert_buf);
d3d_enable_blend_func(d3d->dev);
#ifndef _XBOX1
d3d->dev->CreateVertexDeclaration(vElems, &vertex_decl);
d3d->dev->SetVertexDeclaration(vertex_decl);
vertex_decl->Release();
#endif
d3d_set_stream_source(d3d->dev, 0, overlay->vert_buf,
2015-11-11 03:12:33 +00:00
0, sizeof(*vert));
video_driver_get_size(&width, &height);
if (overlay->fullscreen)
d3d_set_viewport(d3d, width, height, true, false);
/* Render overlay. */
d3d_set_texture(d3d->dev, 0, overlay->tex);
d3d_set_sampler_address_u(d3d->dev, 0, D3DTADDRESS_BORDER);
d3d_set_sampler_address_v(d3d->dev, 0, D3DTADDRESS_BORDER);
d3d_set_sampler_minfilter(d3d->dev, 0, D3DTEXF_LINEAR);
d3d_set_sampler_magfilter(d3d->dev, 0, D3DTEXF_LINEAR);
d3d_draw_primitive(d3d->dev, D3DPT_TRIANGLESTRIP, 0, 2);
/* Restore previous state. */
d3d_disable_blend_func(d3d->dev);
d3d_set_viewport(d3d->dev, width, height, false, false);
}
2015-03-15 16:51:27 +00:00
static void d3d_free_overlay(d3d_video_t *d3d, overlay_t *overlay)
{
if (!d3d)
return;
d3d_texture_free(overlay->tex);
2015-04-05 15:08:22 +00:00
d3d_vertex_buffer_free(overlay->vert_buf, NULL);
}
2015-03-15 16:51:27 +00:00
static void d3d_free_overlays(d3d_video_t *d3d)
{
unsigned i;
if (!d3d)
return;
for (i = 0; i < d3d->overlays.size(); i++)
d3d_free_overlay(d3d, &d3d->overlays[i]);
d3d->overlays.clear();
}
2015-11-10 04:09:31 +00:00
static void d3d_overlay_tex_geom(
2015-11-10 04:11:49 +00:00
void *data,
unsigned index,
float x, float y,
float w, float h)
{
2015-11-10 04:11:49 +00:00
d3d_video_t *d3d = (d3d_video_t*)data;
2015-03-16 17:33:47 +00:00
if (!d3d)
return;
2015-11-11 02:48:05 +00:00
d3d->overlays[index].tex_coords[0] = x;
d3d->overlays[index].tex_coords[1] = y;
d3d->overlays[index].tex_coords[2] = w;
d3d->overlays[index].tex_coords[3] = h;
}
2015-11-10 04:09:31 +00:00
static void d3d_overlay_vertex_geom(
2015-11-10 04:11:49 +00:00
void *data,
unsigned index,
float x, float y,
float w, float h)
{
2015-11-10 04:11:49 +00:00
d3d_video_t *d3d = (d3d_video_t*)data;
2015-03-16 17:33:47 +00:00
if (!d3d)
return;
2015-11-11 02:48:05 +00:00
y = 1.0f - y;
h = -h;
d3d->overlays[index].vert_coords[0] = x;
d3d->overlays[index].vert_coords[1] = y;
d3d->overlays[index].vert_coords[2] = w;
d3d->overlays[index].vert_coords[3] = h;
}
static bool d3d_overlay_load(void *data,
const void *image_data, unsigned num_images)
{
unsigned i, y;
d3d_video_t *d3d = (d3d_video_t*)data;
2015-07-11 17:47:20 +00:00
const struct texture_image *images = (const struct texture_image*)
image_data;
2015-01-17 05:30:39 +00:00
2015-03-15 16:54:53 +00:00
if (!d3d)
return false;
d3d_free_overlays(d3d);
d3d->overlays.resize(num_images);
for (i = 0; i < num_images; i++)
{
2015-01-17 05:30:39 +00:00
D3DLOCKED_RECT d3dlr;
2015-04-05 14:34:31 +00:00
unsigned width = images[i].width;
unsigned height = images[i].height;
2014-09-13 20:25:30 +00:00
overlay_t *overlay = (overlay_t*)&d3d->overlays[i];
2015-11-11 03:16:18 +00:00
overlay->tex = d3d_texture_new(d3d->dev, NULL,
2014-09-13 16:42:13 +00:00
width, height, 1,
0,
D3DFMT_A8R8G8B8,
2015-05-20 22:28:12 +00:00
D3DPOOL_MANAGED, 0, 0, 0,
2014-09-13 16:42:13 +00:00
NULL, NULL);
2014-09-13 20:25:30 +00:00
if (!overlay->tex)
{
RARCH_ERR("[D3D]: Failed to create overlay texture\n");
return false;
}
2015-11-09 14:43:46 +00:00
if (d3d_lock_rectangle(overlay->tex, 0, &d3dlr,
2015-11-09 14:39:47 +00:00
NULL, 0, D3DLOCK_NOSYSLOCK))
{
2015-01-17 05:30:39 +00:00
uint32_t *dst = (uint32_t*)(d3dlr.pBits);
const uint32_t *src = images[i].pixels;
2015-01-17 05:30:39 +00:00
unsigned pitch = d3dlr.Pitch >> 2;
for (y = 0; y < height; y++, dst += pitch, src += width)
memcpy(dst, src, width << 2);
2015-11-09 14:39:47 +00:00
d3d_unlock_rectangle(overlay->tex);
}
2015-04-05 14:34:31 +00:00
overlay->tex_w = width;
overlay->tex_h = height;
/* Default. Stretch to whole screen. */
d3d_overlay_tex_geom(d3d, i, 0, 0, 1, 1);
d3d_overlay_vertex_geom(d3d, i, 0, 0, 1, 1);
}
return true;
}
static void d3d_overlay_enable(void *data, bool state)
{
unsigned i;
2015-04-09 16:38:24 +00:00
d3d_video_t *d3d = (d3d_video_t*)data;
2014-11-15 04:06:34 +00:00
if (!d3d)
return;
for (i = 0; i < d3d->overlays.size(); i++)
d3d->overlays_enabled = state;
2015-04-10 06:49:01 +00:00
gfx_ctx_show_mouse(d3d, state);
}
static void d3d_overlay_full_screen(void *data, bool enable)
{
unsigned i;
d3d_video_t *d3d = (d3d_video_t*)data;
for (i = 0; i < d3d->overlays.size(); i++)
d3d->overlays[i].fullscreen = enable;
}
static void d3d_overlay_set_alpha(void *data, unsigned index, float mod)
{
d3d_video_t *d3d = (d3d_video_t*)data;
2015-01-17 05:30:39 +00:00
if (d3d)
d3d->overlays[index].alpha_mod = mod;
}
static const video_overlay_interface_t d3d_overlay_interface = {
d3d_overlay_enable,
d3d_overlay_load,
d3d_overlay_tex_geom,
d3d_overlay_vertex_geom,
d3d_overlay_full_screen,
d3d_overlay_set_alpha,
};
static void d3d_get_overlay_interface(void *data,
const video_overlay_interface_t **iface)
{
(void)data;
*iface = &d3d_overlay_interface;
}
2014-01-09 17:44:25 +00:00
#endif
2014-01-01 00:09:31 +00:00
static bool d3d_frame(void *data, const void *frame,
unsigned frame_width, unsigned frame_height,
2015-08-03 21:01:07 +00:00
uint64_t frame_count, unsigned pitch,
2012-10-26 19:09:30 +00:00
const char *msg)
{
unsigned width, height;
2015-09-20 08:02:47 +00:00
static struct retro_perf_counter d3d_frame = {0};
unsigned i = 0;
d3d_video_t *d3d = (d3d_video_t*)data;
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
const font_renderer_t *font_ctx = driver->font_osd_driver;
2014-01-09 17:44:25 +00:00
2015-01-17 05:47:00 +00:00
(void)i;
if (!frame)
2014-01-09 17:44:25 +00:00
return true;
video_driver_get_size(&width, &height);
2015-09-20 08:02:47 +00:00
rarch_perf_init(&d3d_frame, "d3d_frame");
retro_perf_start(&d3d_frame);
2014-05-29 15:35:24 +00:00
#ifndef _XBOX
2014-09-08 17:28:10 +00:00
/* We cannot recover in fullscreen. */
2014-01-09 17:44:25 +00:00
if (d3d->needs_restore && IsIconic(d3d->hWnd))
return true;
#endif
2014-01-09 17:44:25 +00:00
if (d3d->needs_restore && !d3d_restore(d3d))
{
RARCH_ERR("[D3D]: Failed to restore.\n");
return false;
}
if (d3d->should_resize)
{
d3d_set_viewport(d3d, width, height, false, true);
if (d3d->renderchain_driver->set_final_viewport)
d3d->renderchain_driver->set_final_viewport(d3d,
d3d->renderchain_data, &d3d->final_viewport);
d3d->should_resize = false;
2014-01-09 17:44:25 +00:00
}
2015-05-20 22:28:12 +00:00
/* 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 = width;
screen_vp.Height = height;
2015-11-10 22:09:58 +00:00
d3d_set_viewport(d3dr, &screen_vp);
2014-09-13 18:09:55 +00:00
d3d_clear(d3dr, 0, 0, D3DCLEAR_TARGET, 0, 1, 0);
2014-01-09 17:44:25 +00:00
2015-05-20 22:28:12 +00:00
/* Insert black frame first, so we
* can screenshot, etc. */
2015-03-20 21:08:36 +00:00
if (settings->video.black_frame_insertion)
2014-01-09 17:44:25 +00:00
{
2015-11-09 00:59:24 +00:00
if (!d3d_swap(d3d, d3dr) || d3d->needs_restore)
2014-01-09 17:44:25 +00:00
return true;
2014-09-13 18:09:55 +00:00
d3d_clear(d3dr, 0, 0, D3DCLEAR_TARGET, 0, 1, 0);
2014-01-09 17:44:25 +00:00
}
2015-04-06 04:46:35 +00:00
if (
2015-04-06 15:16:22 +00:00
!d3d->renderchain_driver->render(
2015-04-06 04:46:35 +00:00
d3d,
frame, frame_width, frame_height,
2015-04-06 04:46:35 +00:00
pitch, d3d->dev_rotation))
2014-01-09 17:44:25 +00:00
{
RARCH_ERR("[D3D]: Failed to render scene.\n");
return false;
}
2015-03-29 21:58:00 +00:00
if (font_ctx->render_msg && msg)
{
2014-06-09 11:13:18 +00:00
struct font_params font_parms = {0};
#ifdef _XBOX
#if defined(_XBOX1)
2015-04-05 14:34:31 +00:00
float msg_width = 60;
float msg_height = 365;
#elif defined(_XBOX360)
2015-04-05 14:34:31 +00:00
float msg_width = d3d->resolution_hd_enable ? 160 : 100;
float msg_height = 120;
#endif
2015-04-05 14:34:31 +00:00
font_parms.x = msg_width;
font_parms.y = msg_height;
font_parms.scale = 21;
#endif
font_ctx->render_msg(driver->font_osd_data, msg, &font_parms);
}
2014-01-09 17:44:25 +00:00
#ifdef HAVE_MENU
2014-06-10 00:21:49 +00:00
if (d3d->menu && d3d->menu->enabled)
d3d_overlay_render(d3d, d3d->menu);
2014-01-09 17:44:25 +00:00
#endif
#ifdef HAVE_OVERLAY
2014-07-26 00:58:45 +00:00
if (d3d->overlays_enabled)
2014-01-09 17:44:25 +00:00
{
2015-01-17 05:30:39 +00:00
for (i = 0; i < d3d->overlays.size(); i++)
d3d_overlay_render(d3d, &d3d->overlays[i]);
2014-01-09 17:44:25 +00:00
}
#endif
#ifdef HAVE_MENU
if (menu_driver_alive())
2015-03-22 04:27:19 +00:00
menu_driver_frame();
#ifdef _XBOX
/* TODO - should be refactored. */
2015-04-06 18:51:24 +00:00
if (d3d && d3d->menu->enabled)
d3d_draw_texture(d3d);
#endif
#endif
2015-09-20 08:02:47 +00:00
retro_perf_stop(&d3d_frame);
2014-06-07 04:11:36 +00:00
gfx_ctx_update_window_title(d3d);
gfx_ctx_swap_buffers(d3d);
2014-01-09 17:44:25 +00:00
d3d->frame_count++;
2014-01-09 17:44:25 +00:00
return true;
2012-10-26 19:09:30 +00:00
}
2014-01-01 00:09:31 +00:00
static bool d3d_read_viewport(void *data, uint8_t *buffer)
2012-10-26 19:09:30 +00:00
{
d3d_video_t *d3d = (d3d_video_t*)data;
2014-01-09 17:44:25 +00:00
if (!d3d || !d3d->renderchain_driver || !d3d->renderchain_driver->read_viewport)
return false;
2014-01-09 17:44:25 +00:00
return d3d->renderchain_driver->read_viewport(d3d, buffer);
2012-10-26 19:09:30 +00:00
}
2014-09-08 17:28:10 +00:00
static bool d3d_set_shader(void *data,
enum rarch_shader_type type, const char *path)
2012-10-31 15:28:09 +00:00
{
2015-01-17 05:30:39 +00:00
bool restore_old = false;
d3d_video_t *d3d = (d3d_video_t*)data;
std::string shader = "";
switch (type)
{
case RARCH_SHADER_CG:
if (path)
2015-04-05 14:34:31 +00:00
shader = path;
#ifdef HAVE_HLSL
d3d->shader = &hlsl_backend;
#endif
break;
default:
break;
}
2015-04-05 16:20:45 +00:00
std::string old_shader = d3d->shader_path;
2015-04-05 16:21:25 +00:00
d3d->shader_path = shader;
2014-01-09 17:44:25 +00:00
if (!d3d_process_shader(d3d) || !d3d_restore(d3d))
2014-01-09 17:44:25 +00:00
{
RARCH_ERR("[D3D]: Setting shader failed.\n");
2014-01-09 17:44:25 +00:00
restore_old = true;
}
if (restore_old)
{
2015-04-05 16:20:45 +00:00
d3d->shader_path = old_shader;
d3d_process_shader(d3d);
2014-01-09 17:44:25 +00:00
d3d_restore(d3d);
}
return !restore_old;
2012-10-31 15:28:09 +00:00
}
#ifdef HAVE_MENU
static void d3d_set_menu_texture_frame(void *data,
const void *frame, bool rgb32, unsigned width, unsigned height,
float alpha)
{
2015-03-16 17:33:47 +00:00
D3DLOCKED_RECT d3dlr;
d3d_video_t *d3d = (d3d_video_t*)data;
2014-01-09 17:44:25 +00:00
2015-04-05 23:51:58 +00:00
(void)d3dlr;
(void)frame;
(void)rgb32;
(void)width;
(void)height;
(void)alpha;
2015-05-20 22:28:12 +00:00
if (!d3d->menu->tex || d3d->menu->tex_w != width
2014-09-08 17:28:10 +00:00
|| d3d->menu->tex_h != height)
2014-01-09 17:44:25 +00:00
{
if (d3d->menu)
2015-05-20 22:28:12 +00:00
d3d_texture_free(d3d->menu->tex);
2015-11-11 03:16:18 +00:00
d3d->menu->tex = d3d_texture_new(d3d->dev, NULL,
2014-09-13 16:42:13 +00:00
width, height, 1,
0, D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED, 0, 0, 0, NULL, NULL);
2014-09-13 16:44:04 +00:00
if (!d3d->menu->tex)
2014-01-09 17:44:25 +00:00
{
2014-06-10 00:21:49 +00:00
RARCH_ERR("[D3D]: Failed to create menu texture.\n");
2014-01-09 17:44:25 +00:00
return;
}
2014-09-13 16:42:13 +00:00
2014-06-10 00:21:49 +00:00
d3d->menu->tex_w = width;
d3d->menu->tex_h = height;
2014-01-09 17:44:25 +00:00
}
2014-06-10 00:21:49 +00:00
d3d->menu->alpha_mod = alpha;
2014-01-09 17:44:25 +00:00
2015-11-09 14:39:47 +00:00
if (d3d_lock_rectangle(d3d->menu->tex, 0, &d3dlr,
NULL, 0, D3DLOCK_NOSYSLOCK))
2014-01-09 17:44:25 +00:00
{
2015-01-17 05:30:39 +00:00
unsigned h, w;
2014-01-09 17:44:25 +00:00
if (rgb32)
{
2015-01-17 05:30:39 +00:00
uint8_t *dst = (uint8_t*)d3dlr.pBits;
2014-01-09 17:44:25 +00:00
const uint32_t *src = (const uint32_t*)frame;
2015-01-17 05:30:39 +00:00
for (h = 0; h < height; h++, dst += d3dlr.Pitch, src += width)
2014-01-09 17:44:25 +00:00
{
memcpy(dst, src, width * sizeof(uint32_t));
2014-09-08 17:28:10 +00:00
memset(dst + width * sizeof(uint32_t), 0,
d3dlr.Pitch - width * sizeof(uint32_t));
2014-01-09 17:44:25 +00:00
}
}
else
{
2015-01-17 05:30:39 +00:00
uint32_t *dst = (uint32_t*)d3dlr.pBits;
2014-01-09 17:44:25 +00:00
const uint16_t *src = (const uint16_t*)frame;
2015-01-17 05:30:39 +00:00
for (h = 0; h < height; h++, dst += d3dlr.Pitch >> 2, src += width)
2014-01-09 17:44:25 +00:00
{
2015-01-17 05:30:39 +00:00
for (w = 0; w < width; w++)
2014-01-09 17:44:25 +00:00
{
uint16_t c = src[w];
uint32_t r = (c >> 12) & 0xf;
uint32_t g = (c >> 8) & 0xf;
uint32_t b = (c >> 4) & 0xf;
uint32_t a = (c >> 0) & 0xf;
2015-04-05 14:34:31 +00:00
r = ((r << 4) | r) << 16;
g = ((g << 4) | g) << 8;
b = ((b << 4) | b) << 0;
a = ((a << 4) | a) << 24;
dst[w] = r | g | b | a;
2014-01-09 17:44:25 +00:00
}
}
}
2015-11-09 14:39:47 +00:00
2014-06-10 00:21:49 +00:00
if (d3d->menu)
2015-11-09 14:39:47 +00:00
d3d_unlock_rectangle(d3d->menu->tex);
2014-01-09 17:44:25 +00:00
}
}
2014-09-08 17:28:10 +00:00
static void d3d_set_menu_texture_enable(void *data,
bool state, bool full_screen)
{
d3d_video_t *d3d = (d3d_video_t*)data;
if (!d3d || !d3d->menu)
return;
2015-04-05 14:34:31 +00:00
d3d->menu->enabled = state;
d3d->menu->fullscreen = full_screen;
}
#endif
2014-01-01 00:09:31 +00:00
static const video_poke_interface_t d3d_poke_interface = {
NULL,
NULL,
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
2015-04-25 00:35:06 +00:00
NULL, /* get_current_framebuffer */
NULL, /* get_proc_address */
2014-01-01 00:09:31 +00:00
d3d_set_aspect_ratio,
d3d_apply_state_changes,
#ifdef HAVE_MENU
d3d_set_menu_texture_frame,
d3d_set_menu_texture_enable,
2015-04-06 22:27:47 +00:00
#else
NULL,
NULL,
#endif
2014-01-01 00:09:31 +00:00
d3d_set_osd_msg,
2014-01-01 00:09:31 +00:00
d3d_show_mouse,
};
2014-09-08 17:28:10 +00:00
static void d3d_get_poke_interface(void *data,
const video_poke_interface_t **iface)
{
(void)data;
2014-01-01 00:09:31 +00:00
*iface = &d3d_poke_interface;
}
2014-09-11 05:06:20 +00:00
video_driver_t video_d3d = {
2014-01-01 00:09:31 +00:00
d3d_init,
d3d_frame,
d3d_set_nonblock_state,
d3d_alive,
d3d_focus,
2015-01-18 21:43:07 +00:00
d3d_suppress_screensaver,
d3d_has_windowed,
2014-01-01 00:09:31 +00:00
d3d_set_shader,
d3d_free,
2014-03-07 20:14:56 +00:00
"d3d",
d3d_set_viewport,
2014-01-01 00:09:31 +00:00
d3d_set_rotation,
d3d_viewport_info,
d3d_read_viewport,
NULL, /* read_frame_raw */
2013-03-27 14:55:59 +00:00
#ifdef HAVE_OVERLAY
2014-01-01 00:09:31 +00:00
d3d_get_overlay_interface,
2013-03-27 14:55:59 +00:00
#endif
2014-01-01 00:09:31 +00:00
d3d_get_poke_interface
2014-01-22 15:38:42 +00:00
};