RetroArch/xbox1/xdk_d3d8.cpp

546 lines
16 KiB
C++
Raw Normal View History

2012-04-21 23:13:50 +02:00
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
* Copyright (C) 2011-2012 - Daniel De Matteis
*
2012-04-21 23:13:50 +02: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.
*
2012-04-21 23:13:50 +02:00
* 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.
*
2012-04-21 23:31:57 +02:00
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
2012-05-28 02:29:51 +02:00
#ifdef _XBOX
#include <xtl.h>
#include <xgraphics.h>
2012-05-28 02:29:51 +02:00
#endif
#include "../driver.h"
#include "xdk_d3d8.h"
2012-05-28 02:29:51 +02:00
2012-07-31 01:23:42 +02:00
#include "../../gfx/fonts/xdk1_xfonts.h"
2012-05-28 02:29:51 +02:00
#include "./../gfx/gfx_context.h"
#include "../general.h"
#include "../message.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
2012-07-15 19:12:58 +02:00
wchar_t strw_buffer[128];
unsigned font_x, font_y;
2012-07-15 19:12:58 +02:00
2012-07-07 20:15:06 +03:00
static void check_window(xdk_d3d_video_t *d3d)
2012-05-28 02:29:51 +02:00
{
bool quit, resize;
gfx_ctx_check_window(&quit,
&resize, NULL, NULL,
2012-07-07 14:41:58 +02:00
d3d->frame_count);
2012-05-28 02:29:51 +02:00
if (quit)
2012-07-07 14:41:58 +02:00
d3d->quitting = true;
2012-05-28 02:29:51 +02:00
else if (resize)
2012-07-07 14:41:58 +02:00
d3d->should_resize = true;
2012-05-28 02:29:51 +02:00
}
2012-07-07 20:15:06 +03:00
static void xdk_d3d_free(void * data)
{
2012-05-28 00:56:58 +02:00
#ifdef RARCH_CONSOLE
if (driver.video_data)
return;
2012-05-28 00:56:58 +02:00
#endif
2012-07-07 20:15:06 +03:00
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)data;
2012-07-07 14:41:58 +02:00
if (!d3d)
return;
2012-07-07 14:41:58 +02:00
d3d->d3d_render_device->Release();
d3d->d3d_device->Release();
2012-07-07 14:41:58 +02:00
free(d3d);
}
2012-07-07 20:15:06 +03:00
static void xdk_d3d_set_viewport(bool force_full)
{
2012-07-07 20:15:06 +03:00
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data;
2012-05-28 00:56:58 +02:00
d3d->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET, 0xff000000, 1.0f, 0);
// Get the "video mode"
d3d->video_mode = XGetVideoFlags();
// Set the viewport based on the current resolution
int width, height;
width = d3d->d3dpp.BackBufferWidth;
height = d3d->d3dpp.BackBufferHeight;
int m_viewport_x_temp, m_viewport_y_temp, m_viewport_width_temp, m_viewport_height_temp;
float m_zNear, m_zFar;
m_viewport_x_temp = 0;
m_viewport_y_temp = 0;
m_viewport_width_temp = width;
m_viewport_height_temp = height;
m_zNear = 0.0f;
m_zFar = 1.0f;
if (!force_full)
{
float desired_aspect = g_settings.video.aspect_ratio;
float device_aspect = (float)width / height;
float delta;
// If the aspect ratios of screen and desired aspect ratio are sufficiently equal (floating point stuff),
2012-05-22 02:19:40 +02:00
if(g_console.aspect_ratio_index == ASPECT_RATIO_CUSTOM)
{
2012-05-29 15:25:39 +02:00
delta = (desired_aspect / device_aspect - 1.0) / 2.0 + 0.5;
m_viewport_x_temp = g_console.viewports.custom_vp.x;
m_viewport_y_temp = g_console.viewports.custom_vp.y;
m_viewport_width_temp = g_console.viewports.custom_vp.width;
m_viewport_height_temp = g_console.viewports.custom_vp.height;
2012-05-22 02:19:40 +02:00
}
else if (device_aspect > desired_aspect)
{
delta = (desired_aspect / device_aspect - 1.0) / 2.0 + 0.5;
m_viewport_x_temp = (int)(width * (0.5 - delta));
m_viewport_width_temp = (int)(2.0 * width * delta);
width = (unsigned)(2.0 * width * delta);
}
else
{
delta = (device_aspect / desired_aspect - 1.0) / 2.0 + 0.5;
m_viewport_y_temp = (int)(height * (0.5 - delta));
m_viewport_height_temp = (int)(2.0 * height * delta);
height = (unsigned)(2.0 * height * delta);
}
}
D3DVIEWPORT vp = {0};
vp.Width = m_viewport_width_temp;
vp.Height = m_viewport_height_temp;
vp.X = m_viewport_x_temp;
vp.Y = m_viewport_y_temp;
vp.MinZ = m_zNear;
vp.MaxZ = m_zFar;
2012-07-07 14:41:58 +02:00
d3d->d3d_render_device->SetViewport(&vp);
font_x = vp.X;
font_y = vp.Y;
//if(gl->overscan_enable && !force_full)
//{
// m_left = -gl->overscan_amount/2;
// m_right = 1 + gl->overscan_amount/2;
// m_bottom = -gl->overscan_amount/2;
//}
}
2012-07-07 20:15:06 +03:00
static void xdk_d3d_set_rotation(void * data, unsigned orientation)
{
(void)data;
2012-07-07 20:15:06 +03:00
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)data;
FLOAT angle;
switch(orientation)
{
case ORIENTATION_NORMAL:
angle = M_PI * 0 / 180;
2012-05-29 15:25:39 +02:00
break;
case ORIENTATION_VERTICAL:
angle = M_PI * 270 / 180;
break;
case ORIENTATION_FLIPPED:
angle = M_PI * 180 / 180;
break;
case ORIENTATION_FLIPPED_ROTATED:
angle = M_PI * 90 / 180;
break;
}
/*
2012-07-09 01:07:36 +02:00
D3DXMATRIX p_out;
D3DXMatrixIdentity(&p_out);
d3d->d3d_render_device->SetTransform(D3DTS_PROJECTION, &p_out);
2012-07-07 14:41:58 +02:00
d3d->should_resize = TRUE;
*/
}
2012-07-07 20:15:06 +03:00
static void *xdk_d3d_init(const video_info_t *video, const input_driver_t **input, void **input_data)
{
if (driver.video_data)
return driver.video_data;
2012-07-07 20:15:06 +03:00
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)calloc(1, sizeof(xdk_d3d_video_t));
2012-07-07 14:41:58 +02:00
if (!d3d)
return NULL;
d3d->d3d_device = direct3d_create_ctx(D3D_SDK_VERSION);
2012-07-07 14:41:58 +02:00
if (!d3d->d3d_device)
{
2012-07-07 14:41:58 +02:00
free(d3d);
RARCH_ERR("Failed to create a D3D8 object.\n");
return NULL;
}
2012-07-07 14:41:58 +02:00
memset(&d3d->d3dpp, 0, sizeof(d3d->d3dpp));
// Get the "video mode"
d3d->video_mode = XGetVideoFlags();
// Check if we are able to use progressive mode
if(d3d->video_mode & XC_VIDEO_FLAGS_HDTV_480p)
2012-07-15 18:11:24 +02:00
d3d->d3dpp.Flags = D3DPRESENTFLAG_PROGRESSIVE;
else
d3d->d3dpp.Flags = D3DPRESENTFLAG_INTERLACED;
// Safe mode
2012-07-15 18:11:24 +02:00
d3d->d3dpp.BackBufferWidth = 640;
2012-07-15 17:40:12 +02:00
d3d->d3dpp.BackBufferHeight = 480;
g_console.menus_hd_enable = false;
// Only valid in PAL mode, not valid for HDTV modes!
if(XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I)
{
2012-07-15 17:40:12 +02:00
if(d3d->video_mode & XC_VIDEO_FLAGS_PAL_60Hz)
d3d->d3dpp.FullScreen_RefreshRateInHz = 60;
else
d3d->d3dpp.FullScreen_RefreshRateInHz = 50;
// Check for 16:9 mode (PAL REGION)
if(d3d->video_mode & XC_VIDEO_FLAGS_WIDESCREEN)
{
if(d3d->video_mode & XC_VIDEO_FLAGS_PAL_60Hz)
2012-07-15 18:11:24 +02:00
{ //60 Hz, 720x480i
2012-07-15 17:40:12 +02:00
d3d->d3dpp.BackBufferWidth = 720;
2012-07-15 18:11:24 +02:00
d3d->d3dpp.BackBufferHeight = 480;
}
else
{ //50 Hz, 720x576i
d3d->d3dpp.BackBufferWidth = 720;
d3d->d3dpp.BackBufferHeight = 576;
}
2012-07-15 17:40:12 +02:00
}
}
else
{
// Check for 16:9 mode (NTSC REGIONS)
if(d3d->video_mode & XC_VIDEO_FLAGS_WIDESCREEN)
{
d3d->d3dpp.BackBufferWidth = 720;
2012-07-15 18:11:24 +02:00
d3d->d3dpp.BackBufferHeight = 480;
2012-07-15 17:40:12 +02:00
}
}
2012-07-15 17:40:12 +02:00
if(XGetAVPack() == XC_AV_PACK_HDTV)
{
2012-07-15 18:04:54 +02:00
if(d3d->video_mode & XC_VIDEO_FLAGS_HDTV_480p)
{
g_console.menus_hd_enable = false;
d3d->d3dpp.BackBufferWidth = 640;
d3d->d3dpp.BackBufferHeight = 480;
d3d->d3dpp.Flags = D3DPRESENTFLAG_PROGRESSIVE;
}
2012-07-15 17:40:12 +02:00
else if(d3d->video_mode & XC_VIDEO_FLAGS_HDTV_720p)
{
2012-07-15 18:04:54 +02:00
g_console.menus_hd_enable = true;
d3d->d3dpp.BackBufferWidth = 1280;
d3d->d3dpp.BackBufferHeight = 720;
d3d->d3dpp.Flags = D3DPRESENTFLAG_PROGRESSIVE;
2012-07-15 17:40:12 +02:00
}
else if(d3d->video_mode & XC_VIDEO_FLAGS_HDTV_1080i)
{
2012-07-15 18:04:54 +02:00
g_console.menus_hd_enable = true;
d3d->d3dpp.BackBufferWidth = 1920;
d3d->d3dpp.BackBufferHeight = 1080;
d3d->d3dpp.Flags = D3DPRESENTFLAG_INTERLACED;
2012-07-15 17:40:12 +02:00
}
}
2012-08-03 18:27:38 +02:00
d3d->win_width = d3d->d3dpp.BackBufferWidth;
d3d->win_height = d3d->d3dpp.BackBufferHeight;
2012-07-15 17:40:12 +02:00
if(d3d->d3dpp.BackBufferWidth > 640 && ((float)d3d->d3dpp.BackBufferHeight / (float)d3d->d3dpp.BackBufferWidth != 0.75) ||
((d3d->d3dpp.BackBufferWidth == 720) && (d3d->d3dpp.BackBufferHeight == 576))) // 16:9
d3d->d3dpp.Flags |= D3DPRESENTFLAG_WIDESCREEN;
// no letterboxing in 4:3 mode (if widescreen is unsupported
2012-07-15 18:04:54 +02:00
d3d->d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
2012-07-14 12:56:18 +02:00
d3d->d3dpp.FullScreen_PresentationInterval = video->vsync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
2012-07-15 18:04:54 +02:00
d3d->d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3d->d3dpp.BackBufferCount = 2;
d3d->d3dpp.EnableAutoDepthStencil = FALSE;
d3d->d3dpp.SwapEffect = D3DSWAPEFFECT_COPY;
2012-07-14 12:56:18 +02:00
d3d->d3d_device->CreateDevice(0, D3DDEVTYPE_HAL, NULL, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3d->d3dpp, &d3d->d3d_render_device);
d3d->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET, 0xff000000, 1.0f, 0);
// use an orthogonal matrix for the projection matrix
D3DXMATRIX mat;
D3DXMatrixOrthoOffCenterLH(&mat, 0, d3d->d3dpp.BackBufferWidth , d3d->d3dpp.BackBufferHeight , 0, 0.0f, 1.0f);
d3d->d3d_render_device->SetTransform(D3DTS_PROJECTION, &mat);
// use an identity matrix for the world and view matrices
D3DXMatrixIdentity(&mat);
d3d->d3d_render_device->SetTransform(D3DTS_WORLD, &mat);
d3d->d3d_render_device->SetTransform(D3DTS_VIEW, &mat);
d3d->d3d_render_device->CreateTexture(512, 512, 1, 0, D3DFMT_LIN_X1R5G5B5, 0, &d3d->lpTexture);
2012-01-07 15:21:23 +01:00
D3DLOCKED_RECT d3dlr;
2012-07-09 00:27:37 +02:00
d3d->lpTexture->LockRect(0, &d3dlr, NULL, 0);
2012-03-08 16:14:09 +01:00
memset(d3dlr.pBits, 0, 512 * d3dlr.Pitch);
2012-07-07 14:41:58 +02:00
d3d->lpTexture->UnlockRect(0);
2012-01-07 15:21:23 +01:00
2012-07-07 14:41:58 +02:00
d3d->last_width = 512;
d3d->last_height = 512;
2012-01-07 15:21:23 +01:00
2012-07-07 14:41:58 +02:00
d3d->d3d_render_device->CreateVertexBuffer(4 * sizeof(DrawVerticeFormats),
2012-07-07 23:02:01 +03:00
D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, &d3d->vertex_buf);
static const DrawVerticeFormats init_verts[] = {
2012-07-09 00:27:37 +02:00
{ -1.0f, -1.0f, 1.0f, 0.0f, 1.0f },
{ 1.0f, -1.0f, 1.0f, 1.0f, 1.0f },
{ -1.0f, 1.0f, 1.0f, 0.0f, 0.0f },
{ 1.0f, 1.0f, 1.0f, 1.0f, 0.0f },
};
BYTE *verts_ptr;
2012-07-07 14:41:58 +02:00
d3d->vertex_buf->Lock(0, 0, &verts_ptr, 0);
memcpy(verts_ptr, init_verts, sizeof(init_verts));
2012-07-07 14:41:58 +02:00
d3d->vertex_buf->Unlock();
2012-07-07 23:02:01 +03:00
d3d->d3d_render_device->SetVertexShader(D3DFVF_XYZ | D3DFVF_TEX1);
// disable lighting
d3d->d3d_render_device->SetRenderState(D3DRS_LIGHTING, FALSE);
// disable culling
2012-07-07 14:41:58 +02:00
d3d->d3d_render_device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
// disable z-buffer
2012-07-07 14:41:58 +02:00
d3d->d3d_render_device->SetRenderState(D3DRS_ZENABLE, FALSE);
2012-01-07 15:11:57 +01:00
D3DVIEWPORT vp = {0};
vp.Width = d3d->d3dpp.BackBufferWidth;
vp.Height = d3d->d3dpp.BackBufferHeight;
2012-01-07 15:11:57 +01:00
vp.MinZ = 0.0f;
vp.MaxZ = 1.0f;
2012-07-07 14:41:58 +02:00
d3d->d3d_render_device->SetViewport(&vp);
2012-01-07 15:11:57 +01:00
if(g_console.viewports.custom_vp.width == 0)
g_console.viewports.custom_vp.width = vp.Width;
2012-05-22 02:19:40 +02:00
if(g_console.viewports.custom_vp.height == 0)
g_console.viewports.custom_vp.height = vp.Height;
2012-05-22 02:19:40 +02:00
2012-07-07 20:15:06 +03:00
xdk_d3d_set_rotation(d3d, g_console.screen_orientation);
2012-07-07 14:41:58 +02:00
d3d->vsync = video->vsync;
2012-05-06 18:53:43 +02:00
2012-07-15 18:04:54 +02:00
// load debug font (toggle option in later revisions ?)
2012-07-15 17:40:12 +02:00
XFONT_OpenDefaultFont(&d3d->debug_font);
d3d->debug_font->SetBkMode(XFONT_TRANSPARENT);
d3d->debug_font->SetBkColor(D3DCOLOR_ARGB(100,0,0,0));
d3d->debug_font->SetTextHeight(14);
d3d->debug_font->SetTextAntialiasLevel(d3d->debug_font->GetTextAntialiasLevel());
font_x = 0;
font_y = 0;
2012-07-07 14:41:58 +02:00
return d3d;
}
2012-07-07 20:15:06 +03:00
static bool xdk_d3d_frame(void *data, const void *frame,
unsigned width, unsigned height, unsigned pitch, const char *msg)
{
if (!frame)
return true;
2012-07-07 20:15:06 +03:00
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)data;
bool menu_enabled = g_console.menu_enable;
bool fps_enable = g_console.fps_info_enable;
if (d3d->last_width != width || d3d->last_height != height) //240*160
2012-01-07 15:21:23 +01:00
{
2012-01-07 15:21:23 +01:00
D3DLOCKED_RECT d3dlr;
2012-03-08 16:14:09 +01:00
2012-07-09 00:27:37 +02:00
d3d->lpTexture->LockRect(0, &d3dlr, NULL, 0);
memset(d3dlr.pBits, 0, 512 * d3dlr.Pitch);
2012-07-07 14:41:58 +02:00
d3d->lpTexture->UnlockRect(0);
2012-01-07 15:21:23 +01:00
float tex_w = width; // / 512.0f;
float tex_h = height; // / 512.0f;
2012-05-06 22:02:54 +02:00
2012-05-06 22:11:06 +02:00
DrawVerticeFormats verts[] = {
2012-07-09 00:27:37 +02:00
{ -1.0f, -1.0f, 1.0f, 0.0f, tex_h },
{ 1.0f, -1.0f, 1.0f, tex_w, tex_h },
{ -1.0f, 1.0f, 1.0f, 0.0f, 0.0f },
{ 1.0f, 1.0f, 1.0f, tex_w, 0.0f },
};
2012-05-06 22:02:54 +02:00
// Align texels and vertices (D3D9 quirk).
for (unsigned i = 0; i < 4; i++)
{
verts[i].x -= 0.5f / 512.0f;
verts[i].y += 0.5f / 512.0f;
}
2012-07-07 23:02:01 +03:00
BYTE *verts_ptr;
2012-07-07 14:41:58 +02:00
d3d->vertex_buf->Lock(0, 0, &verts_ptr, 0);
memcpy(verts_ptr, verts, sizeof(verts));
2012-07-07 14:41:58 +02:00
d3d->vertex_buf->Unlock();
2012-07-07 14:41:58 +02:00
d3d->last_width = width;
d3d->last_height = height;
2012-01-07 15:21:23 +01:00
}
2012-07-07 14:41:58 +02:00
if (d3d->should_resize)
2012-07-07 20:15:06 +03:00
xdk_d3d_set_viewport(false);
2012-05-28 02:29:51 +02:00
2012-07-07 14:41:58 +02:00
d3d->frame_count++;
2012-05-06 18:53:43 +02:00
2012-07-07 14:41:58 +02:00
d3d->d3d_render_device->SetTexture(0, d3d->lpTexture);
2012-05-06 18:53:43 +02:00
D3DLOCKED_RECT d3dlr;
2012-07-09 00:27:37 +02:00
d3d->lpTexture->LockRect(0, &d3dlr, NULL, 0);
for (unsigned y = 0; y < height; y++)
{
const uint8_t *in = (const uint8_t*)frame + y * pitch;
uint8_t *out = (uint8_t*)d3dlr.pBits + y * d3dlr.Pitch;
memcpy(out, in, width * sizeof(uint16_t));
}
2012-07-07 14:41:58 +02:00
d3d->lpTexture->UnlockRect(0);
2012-07-07 14:41:58 +02:00
d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_MINFILTER, g_settings.video.smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT);
d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_MAGFILTER, g_settings.video.smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT);
d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);
d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER);
2012-07-09 01:07:36 +02:00
D3DXMATRIX p_out;
D3DXMatrixIdentity(&p_out);
d3d->d3d_render_device->SetTransform(D3DTS_WORLD, &p_out);
d3d->d3d_render_device->SetTransform(D3DTS_VIEW, &p_out);
d3d->d3d_render_device->SetTransform(D3DTS_PROJECTION, &p_out);
2012-07-07 23:02:01 +03:00
d3d->d3d_render_device->SetVertexShader(D3DFVF_XYZ | D3DFVF_TEX1);
d3d->d3d_render_device->SetStreamSource(0, d3d->vertex_buf, sizeof(DrawVerticeFormats));
d3d->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET, 0xff000000, 1.0f, 0);
2012-07-09 05:35:37 +02:00
d3d->d3d_render_device->BeginScene();
2012-07-07 14:41:58 +02:00
d3d->d3d_render_device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
2012-07-09 05:35:37 +02:00
d3d->d3d_render_device->EndScene();
if(fps_enable)
{
static MEMORYSTATUS stat;
GlobalMemoryStatus(&stat);
//Output memory usage
2012-07-15 19:12:58 +02:00
char buf[128], buf2[128], buf_fps_last[128];
bool ret = false;
2012-07-29 18:46:52 +02:00
snprintf(buf, sizeof(buf), "%.2f MB free / %.2f MB total", stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f));
2012-08-03 00:23:09 +02:00
xfonts_render_msg_place(d3d, font_x + 30, font_y + 50, 0 /* scale */, buf);
2012-07-15 19:12:58 +02:00
if(ret = gfx_window_title(buf2, sizeof(buf2)) || sizeof(buf_fps_last))
{
if(ret)
{
2012-07-29 18:46:52 +02:00
snprintf(buf_fps_last, sizeof(buf_fps_last), buf2);
2012-08-03 00:23:09 +02:00
xfonts_render_msg_place(d3d, font_x + 30, font_y + 70, 0 /* scale */, buf_fps_last);
convert_char_to_wchar(strw_buffer, buf2, sizeof(strw_buffer));
}
else if(buf_fps_last)
2012-08-03 00:23:09 +02:00
xfonts_render_msg_place(d3d, font_x + 30, font_y + 70, 0 /* scale */, buf2);
}
2012-07-15 19:12:58 +02:00
}
if (msg)
xfonts_render_msg_place(d3d, 60, 365, 0, msg); //TODO: dehardcode x/y here for HD (720p) mode
2012-07-07 14:41:58 +02:00
if(!d3d->block_swap)
2012-05-28 02:51:34 +02:00
gfx_ctx_swap_buffers();
return true;
}
2012-07-07 20:15:06 +03:00
static void xdk_d3d_set_nonblock_state(void *data, bool state)
{
2012-07-07 20:15:06 +03:00
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)data;
2012-07-07 14:41:58 +02:00
if(d3d->vsync)
{
RARCH_LOG("D3D Vsync => %s\n", state ? "off" : "on");
gfx_ctx_set_swap_interval(state ? 0 : 1, TRUE);
}
}
2012-07-07 20:15:06 +03:00
static bool xdk_d3d_alive(void *data)
{
2012-07-07 20:15:06 +03:00
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)data;
2012-07-07 14:41:58 +02:00
check_window(d3d);
return !d3d->quitting;
}
2012-07-07 20:15:06 +03:00
static bool xdk_d3d_focus(void *data)
{
2012-05-28 02:29:51 +02:00
(void)data;
return gfx_ctx_window_has_focus();
}
2012-07-07 20:15:06 +03:00
static void xdk_d3d_start(void)
{
video_info_t video_info = {0};
video_info.vsync = g_settings.video.vsync;
video_info.force_aspect = false;
2012-05-28 00:56:58 +02:00
video_info.fullscreen = true;
video_info.smooth = g_settings.video.smooth;
video_info.input_scale = 2;
2012-07-07 20:15:06 +03:00
driver.video_data = xdk_d3d_init(&video_info, NULL, NULL);
2012-07-07 20:15:06 +03:00
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data;
2012-05-28 02:51:34 +02:00
2012-07-07 14:41:58 +02:00
gfx_ctx_set_swap_interval(d3d->vsync ? 1 : 0, false);
}
2012-07-07 20:15:06 +03:00
static void xdk_d3d_restart(void)
2012-05-28 00:37:54 +02:00
{
}
2012-07-07 20:15:06 +03:00
static void xdk_d3d_stop(void)
{
2012-05-28 00:56:58 +02:00
void *data = driver.video_data;
driver.video_data = NULL;
2012-07-07 20:15:06 +03:00
xdk_d3d_free(data);
}
2012-07-07 20:15:06 +03:00
const video_driver_t video_xdk_d3d = {
xdk_d3d_init,
xdk_d3d_frame,
xdk_d3d_set_nonblock_state,
xdk_d3d_alive,
xdk_d3d_focus,
NULL,
2012-07-07 20:15:06 +03:00
xdk_d3d_free,
"xdk_d3d",
2012-07-07 20:15:06 +03:00
xdk_d3d_start,
xdk_d3d_stop,
xdk_d3d_restart,
xdk_d3d_set_rotation,
};