(D3D) Cleanups
This commit is contained in:
parent
3f118245a6
commit
162ffd9586
331
gfx/d3d/d3d.cpp
331
gfx/d3d/d3d.cpp
|
@ -127,7 +127,7 @@ static bool d3d_init_shader(void *data)
|
||||||
#if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL)
|
#if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL)
|
||||||
const shader_backend_t *backend = NULL;
|
const shader_backend_t *backend = NULL;
|
||||||
#endif
|
#endif
|
||||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
(void)d3d;
|
(void)d3d;
|
||||||
|
@ -238,7 +238,7 @@ static bool d3d_init_base(void *data, const video_info_t *info)
|
||||||
|
|
||||||
static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info)
|
static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info)
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
global_t *global = global_get_ptr();
|
global_t *global = global_get_ptr();
|
||||||
|
|
||||||
|
@ -335,12 +335,12 @@ static void d3d_set_viewport(d3d_video_t *d3d, int x, int y,
|
||||||
if (y < 0)
|
if (y < 0)
|
||||||
y = 0;
|
y = 0;
|
||||||
|
|
||||||
viewport.X = x;
|
viewport.X = x;
|
||||||
viewport.Y = y;
|
viewport.Y = y;
|
||||||
viewport.Width = width;
|
viewport.Width = width;
|
||||||
viewport.Height = height;
|
viewport.Height = height;
|
||||||
viewport.MinZ = 0.0f;
|
viewport.MinZ = 0.0f;
|
||||||
viewport.MaxZ = 1.0f;
|
viewport.MaxZ = 1.0f;
|
||||||
|
|
||||||
d3d->final_viewport = viewport;
|
d3d->final_viewport = viewport;
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ static void d3d_calculate_rect(d3d_video_t *d3d,
|
||||||
|
|
||||||
static void d3d_set_nonblock_state(void *data, bool state)
|
static void d3d_set_nonblock_state(void *data, bool state)
|
||||||
{
|
{
|
||||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||||
|
|
||||||
if (!d3d)
|
if (!d3d)
|
||||||
return;
|
return;
|
||||||
|
@ -507,7 +507,7 @@ static void d3d_apply_state_changes(void *data)
|
||||||
static void d3d_set_osd_msg(void *data, const char *msg,
|
static void d3d_set_osd_msg(void *data, const char *msg,
|
||||||
const struct font_params *params, void *font)
|
const struct font_params *params, void *font)
|
||||||
{
|
{
|
||||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||||
font_renderer_t *font_ctx = d3d ? (font_renderer_t*)d3d->font_driver : NULL;
|
font_renderer_t *font_ctx = d3d ? (font_renderer_t*)d3d->font_driver : NULL;
|
||||||
|
|
||||||
#ifndef _XBOX
|
#ifndef _XBOX
|
||||||
|
@ -526,8 +526,8 @@ static bool d3d_construct(d3d_video_t *d3d,
|
||||||
void **input_data)
|
void **input_data)
|
||||||
{
|
{
|
||||||
unsigned full_x, full_y;
|
unsigned full_x, full_y;
|
||||||
driver_t *driver = driver_get_ptr();
|
driver_t *driver = driver_get_ptr();
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
d3d->should_resize = false;
|
d3d->should_resize = false;
|
||||||
#ifndef _XBOX
|
#ifndef _XBOX
|
||||||
|
@ -538,15 +538,15 @@ static bool d3d_construct(d3d_video_t *d3d,
|
||||||
if (d3d->menu)
|
if (d3d->menu)
|
||||||
free(d3d->menu);
|
free(d3d->menu);
|
||||||
|
|
||||||
d3d->menu = (overlay_t*)calloc(1, sizeof(overlay_t));
|
d3d->menu = (overlay_t*)calloc(1, sizeof(overlay_t));
|
||||||
|
|
||||||
if (!d3d->menu)
|
if (!d3d->menu)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
d3d->menu->tex_coords.x = 0;
|
d3d->menu->tex_coords.x = 0;
|
||||||
d3d->menu->tex_coords.y = 0;
|
d3d->menu->tex_coords.y = 0;
|
||||||
d3d->menu->tex_coords.w = 1;
|
d3d->menu->tex_coords.w = 1;
|
||||||
d3d->menu->tex_coords.h = 1;
|
d3d->menu->tex_coords.h = 1;
|
||||||
d3d->menu->vert_coords.x = 0;
|
d3d->menu->vert_coords.x = 0;
|
||||||
d3d->menu->vert_coords.y = 1;
|
d3d->menu->vert_coords.y = 1;
|
||||||
d3d->menu->vert_coords.w = 1;
|
d3d->menu->vert_coords.w = 1;
|
||||||
|
@ -562,9 +562,9 @@ static bool d3d_construct(d3d_video_t *d3d,
|
||||||
d3d->windowClass.hInstance = NULL;
|
d3d->windowClass.hInstance = NULL;
|
||||||
d3d->windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
d3d->windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
d3d->windowClass.lpszClassName = "RetroArch";
|
d3d->windowClass.lpszClassName = "RetroArch";
|
||||||
d3d->windowClass.hIcon = LoadIcon(GetModuleHandle(NULL),
|
d3d->windowClass.hIcon = LoadIcon(GetModuleHandle(NULL),
|
||||||
MAKEINTRESOURCE(IDI_ICON));
|
MAKEINTRESOURCE(IDI_ICON));
|
||||||
d3d->windowClass.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL),
|
d3d->windowClass.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL),
|
||||||
MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0);
|
MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0);
|
||||||
if (!info->fullscreen)
|
if (!info->fullscreen)
|
||||||
d3d->windowClass.hbrBackground = (HBRUSH)COLOR_WINDOW;
|
d3d->windowClass.hbrBackground = (HBRUSH)COLOR_WINDOW;
|
||||||
|
@ -588,8 +588,8 @@ static bool d3d_construct(d3d_video_t *d3d,
|
||||||
if (d3d->ctx_driver && d3d->ctx_driver->get_video_size)
|
if (d3d->ctx_driver && d3d->ctx_driver->get_video_size)
|
||||||
d3d->ctx_driver->get_video_size(d3d, &full_x, &full_y);
|
d3d->ctx_driver->get_video_size(d3d, &full_x, &full_y);
|
||||||
#endif
|
#endif
|
||||||
d3d->screen_width = info->fullscreen ? full_x : info->width;
|
d3d->screen_width = info->fullscreen ? full_x : info->width;
|
||||||
d3d->screen_height = info->fullscreen ? full_y : info->height;
|
d3d->screen_height = info->fullscreen ? full_y : info->height;
|
||||||
|
|
||||||
#if defined(HAVE_WINDOW) && !defined(_XBOX)
|
#if defined(HAVE_WINDOW) && !defined(_XBOX)
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
|
@ -602,8 +602,8 @@ static bool d3d_construct(d3d_video_t *d3d,
|
||||||
rect.right = d3d->screen_width;
|
rect.right = d3d->screen_width;
|
||||||
rect.bottom = d3d->screen_height;
|
rect.bottom = d3d->screen_height;
|
||||||
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
|
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
|
||||||
win_width = rect.right - rect.left;
|
win_width = rect.right - rect.left;
|
||||||
win_height = rect.bottom - rect.top;
|
win_height = rect.bottom - rect.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
video_monitor_get_fps(buffer, sizeof(buffer), NULL, 0);
|
video_monitor_get_fps(buffer, sizeof(buffer), NULL, 0);
|
||||||
|
@ -681,13 +681,13 @@ static void d3d_viewport_info(void *data, struct video_viewport *vp)
|
||||||
if (!d3d || !vp)
|
if (!d3d || !vp)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vp->x = d3d->final_viewport.X;
|
vp->x = d3d->final_viewport.X;
|
||||||
vp->y = d3d->final_viewport.Y;
|
vp->y = d3d->final_viewport.Y;
|
||||||
vp->width = d3d->final_viewport.Width;
|
vp->width = d3d->final_viewport.Width;
|
||||||
vp->height = d3d->final_viewport.Height;
|
vp->height = d3d->final_viewport.Height;
|
||||||
|
|
||||||
vp->full_width = d3d->screen_width;
|
vp->full_width = d3d->screen_width;
|
||||||
vp->full_height = d3d->screen_height;
|
vp->full_height = d3d->screen_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void d3d_set_rotation(void *data, unsigned rot)
|
static void d3d_set_rotation(void *data, unsigned rot)
|
||||||
|
@ -710,13 +710,14 @@ static const gfx_ctx_driver_t *d3d_get_context(void *data)
|
||||||
/* Default to Direct3D9 for now.
|
/* Default to Direct3D9 for now.
|
||||||
TODO: GL core contexts through ANGLE? */
|
TODO: GL core contexts through ANGLE? */
|
||||||
enum gfx_ctx_api api = GFX_CTX_DIRECT3D9_API;
|
enum gfx_ctx_api api = GFX_CTX_DIRECT3D9_API;
|
||||||
unsigned major = 9, minor = 0;
|
unsigned major = 9;
|
||||||
|
unsigned minor = 0;
|
||||||
driver_t *driver = driver_get_ptr();
|
driver_t *driver = driver_get_ptr();
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
#if defined(_XBOX1)
|
#if defined(HAVE_D3D8)
|
||||||
api = GFX_CTX_DIRECT3D8_API;
|
api = GFX_CTX_DIRECT3D8_API;
|
||||||
major = 8;
|
major = 8;
|
||||||
#endif
|
#endif
|
||||||
return gfx_ctx_init_first(driver->video_data,
|
return gfx_ctx_init_first(driver->video_data,
|
||||||
settings->video.context_driver,
|
settings->video.context_driver,
|
||||||
|
@ -851,17 +852,17 @@ static RECT d3d_monitor_rect(d3d_video_t *d3d)
|
||||||
unsigned fs_monitor, i;
|
unsigned fs_monitor, i;
|
||||||
MONITORINFOEX current_mon;
|
MONITORINFOEX current_mon;
|
||||||
HMONITOR hm_to_use;
|
HMONITOR hm_to_use;
|
||||||
monitor_count = 0;
|
monitor_count = 0;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
EnumDisplayMonitors(NULL, NULL, d3d_monitor_enum_proc, 0);
|
EnumDisplayMonitors(NULL, NULL, d3d_monitor_enum_proc, 0);
|
||||||
|
|
||||||
if (!monitor_last)
|
if (!monitor_last)
|
||||||
monitor_last = MonitorFromWindow(
|
monitor_last = MonitorFromWindow(
|
||||||
GetDesktopWindow(), MONITOR_DEFAULTTONEAREST);
|
GetDesktopWindow(), MONITOR_DEFAULTTONEAREST);
|
||||||
|
|
||||||
hm_to_use = monitor_last;
|
hm_to_use = monitor_last;
|
||||||
fs_monitor = settings->video.monitor_index;
|
fs_monitor = settings->video.monitor_index;
|
||||||
|
|
||||||
if (fs_monitor && fs_monitor <= monitor_count
|
if (fs_monitor && fs_monitor <= monitor_count
|
||||||
&& monitor_all[fs_monitor - 1])
|
&& monitor_all[fs_monitor - 1])
|
||||||
|
@ -893,15 +894,15 @@ static RECT d3d_monitor_rect(d3d_video_t *d3d)
|
||||||
static void d3d_recompute_pass_sizes(d3d_video_t *d3d)
|
static void d3d_recompute_pass_sizes(d3d_video_t *d3d)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
LinkInfo link_info = {0};
|
LinkInfo link_info = {0};
|
||||||
link_info.pass = &d3d->shader.pass[0];
|
link_info.pass = &d3d->shader.pass[0];
|
||||||
link_info.tex_w = link_info.tex_h =
|
link_info.tex_w = link_info.tex_h =
|
||||||
d3d->video_info.input_scale * RARCH_SCALE_BASE;
|
d3d->video_info.input_scale * RARCH_SCALE_BASE;
|
||||||
|
|
||||||
unsigned current_width = link_info.tex_w;
|
unsigned current_width = link_info.tex_w;
|
||||||
unsigned current_height = link_info.tex_h;
|
unsigned current_height = link_info.tex_h;
|
||||||
unsigned out_width = 0;
|
unsigned out_width = 0;
|
||||||
unsigned out_height = 0;
|
unsigned out_height = 0;
|
||||||
|
|
||||||
if (!renderchain_set_pass_size(d3d->chain, 0,
|
if (!renderchain_set_pass_size(d3d->chain, 0,
|
||||||
current_width, current_height))
|
current_width, current_height))
|
||||||
|
@ -944,9 +945,9 @@ static bool d3d_init_imports(d3d_video_t *d3d)
|
||||||
if (!d3d->shader.variables)
|
if (!d3d->shader.variables)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
tracker_info.wram = (uint8_t*)
|
tracker_info.wram = (uint8_t*)
|
||||||
pretro_get_memory_data(RETRO_MEMORY_SYSTEM_RAM);
|
pretro_get_memory_data(RETRO_MEMORY_SYSTEM_RAM);
|
||||||
tracker_info.info = d3d->shader.variable;
|
tracker_info.info = d3d->shader.variable;
|
||||||
tracker_info.info_elem = d3d->shader.variables;
|
tracker_info.info_elem = d3d->shader.variables;
|
||||||
|
|
||||||
#ifdef HAVE_PYTHON
|
#ifdef HAVE_PYTHON
|
||||||
|
@ -992,12 +993,12 @@ static bool d3d_init_chain(d3d_video_t *d3d, const video_info_t *video_info)
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
/* TODO - properly implement this. */
|
/* TODO - properly implement this. */
|
||||||
d3d_video_t *link_info = (d3d_video_t*)d3d;
|
d3d_video_t *link_info = (d3d_video_t*)d3d;
|
||||||
link_info->tex_w = link_info->tex_h =
|
link_info->tex_w = link_info->tex_h =
|
||||||
RARCH_SCALE_BASE * video_info->input_scale;
|
RARCH_SCALE_BASE * video_info->input_scale;
|
||||||
|
|
||||||
//d3d_deinit_chain(d3d);
|
//d3d_deinit_chain(d3d);
|
||||||
#else
|
#else
|
||||||
link_info.pass = &d3d->shader.pass[0];
|
link_info.pass = &d3d->shader.pass[0];
|
||||||
link_info.tex_w = link_info.tex_h =
|
link_info.tex_w = link_info.tex_h =
|
||||||
video_info->input_scale * RARCH_SCALE_BASE;
|
video_info->input_scale * RARCH_SCALE_BASE;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1038,7 +1039,7 @@ static bool d3d_init_chain(d3d_video_t *d3d, const video_info_t *video_info)
|
||||||
&out_width, &out_height,
|
&out_width, &out_height,
|
||||||
current_width, current_height, &d3d->final_viewport);
|
current_width, current_height, &d3d->final_viewport);
|
||||||
|
|
||||||
link_info.pass = &d3d->shader.pass[i];
|
link_info.pass = &d3d->shader.pass[i];
|
||||||
link_info.tex_w = next_pow2(out_width);
|
link_info.tex_w = next_pow2(out_width);
|
||||||
link_info.tex_h = next_pow2(out_height);
|
link_info.tex_h = next_pow2(out_height);
|
||||||
|
|
||||||
|
@ -1076,16 +1077,13 @@ static bool d3d_init_chain(d3d_video_t *d3d, const video_info_t *video_info)
|
||||||
static void d3d_reinit_renderchain(void *data,
|
static void d3d_reinit_renderchain(void *data,
|
||||||
const video_info_t *video)
|
const video_info_t *video)
|
||||||
{
|
{
|
||||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||||
|
|
||||||
if (!d3d)
|
if (!d3d)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
d3d->pixel_size = video->rgb32 ?
|
d3d->pixel_size = video->rgb32 ? sizeof(uint32_t) : sizeof(uint16_t);
|
||||||
sizeof(uint32_t) : sizeof(uint16_t);
|
d3d->tex_w = d3d->tex_h = RARCH_SCALE_BASE * video->input_scale;
|
||||||
d3d->tex_w = d3d->tex_h =
|
|
||||||
RARCH_SCALE_BASE * video->input_scale;
|
|
||||||
|
|
||||||
RARCH_LOG(
|
RARCH_LOG(
|
||||||
"Reinitializing renderchain - and textures (%u x %u @ %u bpp)\n",
|
"Reinitializing renderchain - and textures (%u x %u @ %u bpp)\n",
|
||||||
d3d->tex_w, d3d->tex_h, d3d->pixel_size * CHAR_BIT);
|
d3d->tex_w, d3d->tex_h, d3d->pixel_size * CHAR_BIT);
|
||||||
|
@ -1105,19 +1103,17 @@ static bool texture_image_render(d3d_video_t *d3d,
|
||||||
struct texture_image *out_img,
|
struct texture_image *out_img,
|
||||||
int x, int y, int w, int h, bool force_fullscreen)
|
int x, int y, int w, int h, bool force_fullscreen)
|
||||||
{
|
{
|
||||||
float fX, fY;
|
void *verts = NULL;
|
||||||
void *verts = NULL;
|
|
||||||
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
||||||
|
float fX = (float)(x);
|
||||||
|
float fY = (float)(y);
|
||||||
|
|
||||||
if (!d3d)
|
if (!d3d)
|
||||||
return false;
|
return false;
|
||||||
if (!out_img->pixels || !out_img->vertex_buf)
|
if (!out_img->pixels || !out_img->vertex_buf)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
fX = (float)(x);
|
/* Create the new vertices. */
|
||||||
fY = (float)(y);
|
|
||||||
|
|
||||||
// create the new vertices
|
|
||||||
Vertex newVerts[] =
|
Vertex newVerts[] =
|
||||||
{
|
{
|
||||||
// x, y, z, color, u ,v
|
// x, y, z, color, u ,v
|
||||||
|
@ -1155,12 +1151,12 @@ static bool texture_image_render(d3d_video_t *d3d,
|
||||||
if (force_fullscreen)
|
if (force_fullscreen)
|
||||||
{
|
{
|
||||||
D3DVIEWPORT vp = {0};
|
D3DVIEWPORT vp = {0};
|
||||||
vp.Width = w;
|
vp.Width = w;
|
||||||
vp.Height = h;
|
vp.Height = h;
|
||||||
vp.X = 0;
|
vp.X = 0;
|
||||||
vp.Y = 0;
|
vp.Y = 0;
|
||||||
vp.MinZ = 0.0f;
|
vp.MinZ = 0.0f;
|
||||||
vp.MaxZ = 1.0f;
|
vp.MaxZ = 1.0f;
|
||||||
d3d_set_viewport(d3dr, &vp);
|
d3d_set_viewport(d3dr, &vp);
|
||||||
}
|
}
|
||||||
d3d_draw_primitive(d3dr, D3DPT_QUADLIST, 0, 1);
|
d3d_draw_primitive(d3dr, D3DPT_QUADLIST, 0, 1);
|
||||||
|
@ -1200,7 +1196,7 @@ static bool d3d_init_multipass(d3d_video_t *d3d)
|
||||||
unsigned i;
|
unsigned i;
|
||||||
bool use_extra_pass;
|
bool use_extra_pass;
|
||||||
video_shader_pass *pass = NULL;
|
video_shader_pass *pass = NULL;
|
||||||
config_file_t *conf = config_file_new(d3d->cg_shader.c_str());
|
config_file_t *conf = config_file_new(d3d->cg_shader.c_str());
|
||||||
|
|
||||||
if (!conf)
|
if (!conf)
|
||||||
{
|
{
|
||||||
|
@ -1228,19 +1224,19 @@ static bool d3d_init_multipass(d3d_video_t *d3d)
|
||||||
if (d3d->shader.pass[i].fbo.valid)
|
if (d3d->shader.pass[i].fbo.valid)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
d3d->shader.pass[i].fbo.scale_x =
|
d3d->shader.pass[i].fbo.scale_y = 1.0f;
|
||||||
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 =
|
d3d->shader.pass[i].fbo.type_x = RARCH_SCALE_INPUT;
|
||||||
d3d->shader.pass[i].fbo.type_y = RARCH_SCALE_INPUT;
|
d3d->shader.pass[i].fbo.type_y = RARCH_SCALE_INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
use_extra_pass = d3d->shader.passes < GFX_MAX_SHADERS &&
|
use_extra_pass = d3d->shader.passes < GFX_MAX_SHADERS &&
|
||||||
d3d->shader.pass[d3d->shader.passes - 1].fbo.valid;
|
d3d->shader.pass[d3d->shader.passes - 1].fbo.valid;
|
||||||
|
|
||||||
if (use_extra_pass)
|
if (use_extra_pass)
|
||||||
{
|
{
|
||||||
d3d->shader.passes++;
|
d3d->shader.passes++;
|
||||||
pass = (video_shader_pass*)
|
pass = (video_shader_pass*)
|
||||||
&d3d->shader.pass[d3d->shader.passes - 1];
|
&d3d->shader.pass[d3d->shader.passes - 1];
|
||||||
|
|
||||||
pass->fbo.scale_x = pass->fbo.scale_y = 1.0f;
|
pass->fbo.scale_x = pass->fbo.scale_y = 1.0f;
|
||||||
|
@ -1249,7 +1245,7 @@ static bool d3d_init_multipass(d3d_video_t *d3d)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pass = (video_shader_pass*)
|
pass = (video_shader_pass*)
|
||||||
&d3d->shader.pass[d3d->shader.passes - 1];
|
&d3d->shader.pass[d3d->shader.passes - 1];
|
||||||
|
|
||||||
pass->fbo.scale_x = pass->fbo.scale_y = 1.0f;
|
pass->fbo.scale_x = pass->fbo.scale_y = 1.0f;
|
||||||
|
@ -1264,33 +1260,33 @@ static void d3d_set_font_rect(d3d_video_t *d3d,
|
||||||
const struct font_params *params)
|
const struct font_params *params)
|
||||||
{
|
{
|
||||||
#ifndef _XBOX
|
#ifndef _XBOX
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
float pos_x = settings->video.msg_pos_x;
|
float pos_x = settings->video.msg_pos_x;
|
||||||
float pos_y = settings->video.msg_pos_y;
|
float pos_y = settings->video.msg_pos_y;
|
||||||
float font_size = settings->video.font_size;
|
float font_size = settings->video.font_size;
|
||||||
|
|
||||||
if (params)
|
if (params)
|
||||||
{
|
{
|
||||||
pos_x = params->x;
|
pos_x = params->x;
|
||||||
pos_y = params->y;
|
pos_y = params->y;
|
||||||
font_size *= params->scale;
|
font_size *= params->scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!d3d)
|
if (!d3d)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
d3d->font_rect.left = d3d->final_viewport.X +
|
d3d->font_rect.left = d3d->final_viewport.X +
|
||||||
d3d->final_viewport.Width * pos_x;
|
d3d->final_viewport.Width * pos_x;
|
||||||
d3d->font_rect.right = d3d->final_viewport.X +
|
d3d->font_rect.right = d3d->final_viewport.X +
|
||||||
d3d->final_viewport.Width;
|
d3d->final_viewport.Width;
|
||||||
d3d->font_rect.top = d3d->final_viewport.Y +
|
d3d->font_rect.top = d3d->final_viewport.Y +
|
||||||
(1.0f - pos_y) * d3d->final_viewport.Height - font_size;
|
(1.0f - pos_y) * d3d->final_viewport.Height - font_size;
|
||||||
d3d->font_rect.bottom = d3d->final_viewport.Height;
|
d3d->font_rect.bottom = d3d->final_viewport.Height;
|
||||||
|
|
||||||
d3d->font_rect_shifted = d3d->font_rect;
|
d3d->font_rect_shifted = d3d->font_rect;
|
||||||
d3d->font_rect_shifted.left -= 2;
|
d3d->font_rect_shifted.left -= 2;
|
||||||
d3d->font_rect_shifted.right -= 2;
|
d3d->font_rect_shifted.right -= 2;
|
||||||
d3d->font_rect_shifted.top += 2;
|
d3d->font_rect_shifted.top += 2;
|
||||||
d3d->font_rect_shifted.bottom += 2;
|
d3d->font_rect_shifted.bottom += 2;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1304,12 +1300,15 @@ static bool d3d_init_singlepass(d3d_video_t *d3d)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
memset(&d3d->shader, 0, sizeof(d3d->shader));
|
memset(&d3d->shader, 0, sizeof(d3d->shader));
|
||||||
d3d->shader.passes = 1;
|
d3d->shader.passes = 1;
|
||||||
pass = (video_shader_pass*)&d3d->shader.pass[0];
|
|
||||||
|
|
||||||
pass->fbo.valid = true;
|
pass = (video_shader_pass*)&d3d->shader.pass[0];
|
||||||
pass->fbo.scale_x = pass->fbo.scale_y = 1.0;
|
|
||||||
pass->fbo.type_x = pass->fbo.type_y = RARCH_SCALE_VIEWPORT;
|
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;
|
||||||
strlcpy(pass->source.path, d3d->cg_shader.c_str(),
|
strlcpy(pass->source.path, d3d->cg_shader.c_str(),
|
||||||
sizeof(pass->source.path));
|
sizeof(pass->source.path));
|
||||||
#endif
|
#endif
|
||||||
|
@ -1393,41 +1392,41 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay)
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
vert[i].z = 0.5f;
|
vert[i].z = 0.5f;
|
||||||
vert[i].r = vert[i].g = vert[i].b = 1.0f;
|
vert[i].r = vert[i].g = vert[i].b = 1.0f;
|
||||||
vert[i].a = overlay->alpha_mod;
|
vert[i].a = overlay->alpha_mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
overlay_width = d3d->final_viewport.Width;
|
overlay_width = d3d->final_viewport.Width;
|
||||||
overlay_height = d3d->final_viewport.Height;
|
overlay_height = d3d->final_viewport.Height;
|
||||||
|
|
||||||
vert[0].x = overlay->vert_coords.x * overlay_width;
|
vert[0].x = overlay->vert_coords.x * overlay_width;
|
||||||
vert[1].x = (overlay->vert_coords.x + overlay->vert_coords.w)
|
vert[1].x = (overlay->vert_coords.x + overlay->vert_coords.w)
|
||||||
* overlay_width;
|
* overlay_width;
|
||||||
vert[2].x = overlay->vert_coords.x * overlay_width;
|
vert[2].x = overlay->vert_coords.x * overlay_width;
|
||||||
vert[3].x = (overlay->vert_coords.x + overlay->vert_coords.w)
|
vert[3].x = (overlay->vert_coords.x + overlay->vert_coords.w)
|
||||||
* overlay_width;
|
* overlay_width;
|
||||||
vert[0].y = overlay->vert_coords.y * overlay_height;
|
vert[0].y = overlay->vert_coords.y * overlay_height;
|
||||||
vert[1].y = overlay->vert_coords.y * overlay_height;
|
vert[1].y = overlay->vert_coords.y * overlay_height;
|
||||||
vert[2].y = (overlay->vert_coords.y + overlay->vert_coords.h)
|
vert[2].y = (overlay->vert_coords.y + overlay->vert_coords.h)
|
||||||
* overlay_height;
|
* overlay_height;
|
||||||
vert[3].y = (overlay->vert_coords.y + overlay->vert_coords.h)
|
vert[3].y = (overlay->vert_coords.y + overlay->vert_coords.h)
|
||||||
* overlay_height;
|
* overlay_height;
|
||||||
|
|
||||||
vert[0].u = overlay->tex_coords.x;
|
vert[0].u = overlay->tex_coords.x;
|
||||||
vert[1].u = overlay->tex_coords.x + overlay->tex_coords.w;
|
vert[1].u = overlay->tex_coords.x + overlay->tex_coords.w;
|
||||||
vert[2].u = overlay->tex_coords.x;
|
vert[2].u = overlay->tex_coords.x;
|
||||||
vert[3].u = overlay->tex_coords.x + overlay->tex_coords.w;
|
vert[3].u = overlay->tex_coords.x + overlay->tex_coords.w;
|
||||||
vert[0].v = overlay->tex_coords.y;
|
vert[0].v = overlay->tex_coords.y;
|
||||||
vert[1].v = overlay->tex_coords.y;
|
vert[1].v = overlay->tex_coords.y;
|
||||||
vert[2].v = overlay->tex_coords.y + overlay->tex_coords.h;
|
vert[2].v = overlay->tex_coords.y + overlay->tex_coords.h;
|
||||||
vert[3].v = overlay->tex_coords.y + overlay->tex_coords.h;
|
vert[3].v = overlay->tex_coords.y + overlay->tex_coords.h;
|
||||||
|
|
||||||
/* Align texels and vertices. */
|
/* Align texels and vertices. */
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
vert[i].x -= 0.5f;
|
vert[i].x -= 0.5f;
|
||||||
vert[i].y += 0.5f;
|
vert[i].y += 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
overlay->vert_buf->Lock(0, sizeof(vert), &verts, 0);
|
overlay->vert_buf->Lock(0, sizeof(vert), &verts, 0);
|
||||||
|
@ -1453,12 +1452,12 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay)
|
||||||
/* Set viewport to full window. */
|
/* Set viewport to full window. */
|
||||||
D3DVIEWPORT vp_full = {0};
|
D3DVIEWPORT vp_full = {0};
|
||||||
|
|
||||||
vp_full.X = 0;
|
vp_full.X = 0;
|
||||||
vp_full.Y = 0;
|
vp_full.Y = 0;
|
||||||
vp_full.Width = d3d->screen_width;
|
vp_full.Width = d3d->screen_width;
|
||||||
vp_full.Height = d3d->screen_height;
|
vp_full.Height = d3d->screen_height;
|
||||||
vp_full.MinZ = 0.0f;
|
vp_full.MinZ = 0.0f;
|
||||||
vp_full.MaxZ = 1.0f;
|
vp_full.MaxZ = 1.0f;
|
||||||
d3d_set_viewport(d3d->dev, &vp_full);
|
d3d_set_viewport(d3d->dev, &vp_full);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1522,8 +1521,8 @@ static void d3d_overlay_vertex_geom(void *data,
|
||||||
if (!d3d)
|
if (!d3d)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
y = 1.0f - y;
|
y = 1.0f - y;
|
||||||
h = -h;
|
h = -h;
|
||||||
d3d->overlays[index].vert_coords.x = x;
|
d3d->overlays[index].vert_coords.x = x;
|
||||||
d3d->overlays[index].vert_coords.y = y;
|
d3d->overlays[index].vert_coords.y = y;
|
||||||
d3d->overlays[index].vert_coords.w = w;
|
d3d->overlays[index].vert_coords.w = w;
|
||||||
|
@ -1545,11 +1544,11 @@ static bool d3d_overlay_load(void *data,
|
||||||
for (i = 0; i < num_images; i++)
|
for (i = 0; i < num_images; i++)
|
||||||
{
|
{
|
||||||
D3DLOCKED_RECT d3dlr;
|
D3DLOCKED_RECT d3dlr;
|
||||||
unsigned width = images[i].width;
|
unsigned width = images[i].width;
|
||||||
unsigned height = images[i].height;
|
unsigned height = images[i].height;
|
||||||
overlay_t *overlay = (overlay_t*)&d3d->overlays[i];
|
overlay_t *overlay = (overlay_t*)&d3d->overlays[i];
|
||||||
|
|
||||||
overlay->tex = (LPDIRECT3DTEXTURE)
|
overlay->tex = (LPDIRECT3DTEXTURE)
|
||||||
d3d_texture_new(d3d->dev, NULL,
|
d3d_texture_new(d3d->dev, NULL,
|
||||||
width, height, 1,
|
width, height, 1,
|
||||||
0,
|
0,
|
||||||
|
@ -1575,8 +1574,8 @@ static bool d3d_overlay_load(void *data,
|
||||||
overlay->tex->UnlockRect(0);
|
overlay->tex->UnlockRect(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
overlay->tex_w = width;
|
overlay->tex_w = width;
|
||||||
overlay->tex_h = height;
|
overlay->tex_h = height;
|
||||||
|
|
||||||
/* Default. Stretch to whole screen. */
|
/* Default. Stretch to whole screen. */
|
||||||
d3d_overlay_tex_geom(d3d, i, 0, 0, 1, 1);
|
d3d_overlay_tex_geom(d3d, i, 0, 0, 1, 1);
|
||||||
|
@ -1639,13 +1638,13 @@ static bool d3d_frame(void *data, const void *frame,
|
||||||
const char *msg)
|
const char *msg)
|
||||||
{
|
{
|
||||||
D3DVIEWPORT screen_vp;
|
D3DVIEWPORT screen_vp;
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||||
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
||||||
runloop_t *runloop = rarch_main_get_ptr();
|
runloop_t *runloop = rarch_main_get_ptr();
|
||||||
driver_t *driver = driver_get_ptr();
|
driver_t *driver = driver_get_ptr();
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
global_t *global = global_get_ptr();
|
global_t *global = global_get_ptr();
|
||||||
const font_renderer_t *font_ctx = d3d ? (const font_renderer_t*)d3d->font_driver : NULL;
|
const font_renderer_t *font_ctx = d3d ? (const font_renderer_t*)d3d->font_driver : NULL;
|
||||||
|
|
||||||
(void)i;
|
(void)i;
|
||||||
|
@ -1683,12 +1682,12 @@ static bool d3d_frame(void *data, const void *frame,
|
||||||
|
|
||||||
/* render_chain() only clears out viewport,
|
/* render_chain() only clears out viewport,
|
||||||
* clear out everything. */
|
* clear out everything. */
|
||||||
screen_vp.X = 0;
|
screen_vp.X = 0;
|
||||||
screen_vp.Y = 0;
|
screen_vp.Y = 0;
|
||||||
screen_vp.MinZ = 0;
|
screen_vp.MinZ = 0;
|
||||||
screen_vp.MaxZ = 1;
|
screen_vp.MaxZ = 1;
|
||||||
screen_vp.Width = d3d->screen_width;
|
screen_vp.Width = d3d->screen_width;
|
||||||
screen_vp.Height = d3d->screen_height;
|
screen_vp.Height = d3d->screen_height;
|
||||||
d3d_set_viewport(d3dr, &screen_vp);
|
d3d_set_viewport(d3dr, &screen_vp);
|
||||||
d3d_clear(d3dr, 0, 0, D3DCLEAR_TARGET, 0, 1, 0);
|
d3d_clear(d3dr, 0, 0, D3DCLEAR_TARGET, 0, 1, 0);
|
||||||
|
|
||||||
|
@ -1719,15 +1718,15 @@ static bool d3d_frame(void *data, const void *frame,
|
||||||
struct font_params font_parms = {0};
|
struct font_params font_parms = {0};
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
#if defined(_XBOX1)
|
#if defined(_XBOX1)
|
||||||
float msg_width = 60;
|
float msg_width = 60;
|
||||||
float msg_height = 365;
|
float msg_height = 365;
|
||||||
#elif defined(_XBOX360)
|
#elif defined(_XBOX360)
|
||||||
float msg_width = d3d->resolution_hd_enable ? 160 : 100;
|
float msg_width = d3d->resolution_hd_enable ? 160 : 100;
|
||||||
float msg_height = 120;
|
float msg_height = 120;
|
||||||
#endif
|
#endif
|
||||||
font_parms.x = msg_width;
|
font_parms.x = msg_width;
|
||||||
font_parms.y = msg_height;
|
font_parms.y = msg_height;
|
||||||
font_parms.scale = 21;
|
font_parms.scale = 21;
|
||||||
#endif
|
#endif
|
||||||
font_ctx->render_msg(d3d->font_handle, msg, &font_parms);
|
font_ctx->render_msg(d3d->font_handle, msg, &font_parms);
|
||||||
}
|
}
|
||||||
|
@ -1776,9 +1775,9 @@ static bool d3d_read_viewport(void *data, uint8_t *buffer)
|
||||||
LPDIRECT3DSURFACE target = NULL;
|
LPDIRECT3DSURFACE target = NULL;
|
||||||
LPDIRECT3DSURFACE dest = NULL;
|
LPDIRECT3DSURFACE dest = NULL;
|
||||||
#endif
|
#endif
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||||
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
||||||
|
|
||||||
RARCH_PERFORMANCE_INIT(d3d_read_viewport);
|
RARCH_PERFORMANCE_INIT(d3d_read_viewport);
|
||||||
RARCH_PERFORMANCE_START(d3d_read_viewport);
|
RARCH_PERFORMANCE_START(d3d_read_viewport);
|
||||||
|
@ -1814,12 +1813,12 @@ static bool d3d_read_viewport(void *data, uint8_t *buffer)
|
||||||
if (SUCCEEDED(dest->LockRect(&rect, NULL, D3DLOCK_READONLY)))
|
if (SUCCEEDED(dest->LockRect(&rect, NULL, D3DLOCK_READONLY)))
|
||||||
{
|
{
|
||||||
unsigned x, y;
|
unsigned x, y;
|
||||||
unsigned pitchpix = rect.Pitch / 4;
|
unsigned pitchpix = rect.Pitch / 4;
|
||||||
const uint32_t *pixels = (const uint32_t*)rect.pBits;
|
const uint32_t *pixels = (const uint32_t*)rect.pBits;
|
||||||
|
|
||||||
pixels += d3d->final_viewport.X;
|
pixels += d3d->final_viewport.X;
|
||||||
pixels += (d3d->final_viewport.Height - 1) * pitchpix;
|
pixels += (d3d->final_viewport.Height - 1) * pitchpix;
|
||||||
pixels -= d3d->final_viewport.Y * pitchpix;
|
pixels -= d3d->final_viewport.Y * pitchpix;
|
||||||
|
|
||||||
for (y = 0; y < d3d->final_viewport.Height; y++, pixels -= pitchpix)
|
for (y = 0; y < d3d->final_viewport.Height; y++, pixels -= pitchpix)
|
||||||
{
|
{
|
||||||
|
@ -1857,7 +1856,7 @@ static bool d3d_set_shader(void *data,
|
||||||
{
|
{
|
||||||
case RARCH_SHADER_CG:
|
case RARCH_SHADER_CG:
|
||||||
if (path)
|
if (path)
|
||||||
shader = path;
|
shader = path;
|
||||||
#ifdef HAVE_HLSL
|
#ifdef HAVE_HLSL
|
||||||
d3d->shader = &hlsl_backend;
|
d3d->shader = &hlsl_backend;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1868,7 +1867,7 @@ static bool d3d_set_shader(void *data,
|
||||||
|
|
||||||
std::string old_shader = d3d->cg_shader;
|
std::string old_shader = d3d->cg_shader;
|
||||||
#ifdef HAVE_CG
|
#ifdef HAVE_CG
|
||||||
d3d->cg_shader = shader;
|
d3d->cg_shader = shader;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!d3d_process_shader(d3d) || !d3d_restore(d3d))
|
if (!d3d_process_shader(d3d) || !d3d_restore(d3d))
|
||||||
|
@ -1964,11 +1963,11 @@ static void d3d_set_menu_texture_frame(void *data,
|
||||||
uint32_t g = (c >> 8) & 0xf;
|
uint32_t g = (c >> 8) & 0xf;
|
||||||
uint32_t b = (c >> 4) & 0xf;
|
uint32_t b = (c >> 4) & 0xf;
|
||||||
uint32_t a = (c >> 0) & 0xf;
|
uint32_t a = (c >> 0) & 0xf;
|
||||||
r = ((r << 4) | r) << 16;
|
r = ((r << 4) | r) << 16;
|
||||||
g = ((g << 4) | g) << 8;
|
g = ((g << 4) | g) << 8;
|
||||||
b = ((b << 4) | b) << 0;
|
b = ((b << 4) | b) << 0;
|
||||||
a = ((a << 4) | a) << 24;
|
a = ((a << 4) | a) << 24;
|
||||||
dst[w] = r | g | b | a;
|
dst[w] = r | g | b | a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1988,14 +1987,14 @@ static void d3d_set_menu_texture_enable(void *data,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
d3d->menu_texture_enable = state;
|
d3d->menu_texture_enable = state;
|
||||||
d3d->menu_texture_full_screen = full_screen;
|
d3d->menu_texture_full_screen = full_screen;
|
||||||
#else
|
#else
|
||||||
if (!d3d->menu)
|
if (!d3d->menu)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
d3d->menu->enabled = state;
|
d3d->menu->enabled = state;
|
||||||
d3d->menu->fullscreen = full_screen;
|
d3d->menu->fullscreen = full_screen;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue