(Gfx) Video driver cleanups

This commit is contained in:
twinaphex 2020-03-09 16:15:53 +01:00
parent 17bb6f7354
commit b7da58b40b
3 changed files with 67 additions and 63 deletions

View File

@ -141,7 +141,10 @@ static INLINE void ctr_set_screen_coords(ctr_video_t * ctr)
}
}
static void ctr_update_viewport(ctr_video_t* ctr, settings_t *settings, video_frame_info_t *video_info)
static void ctr_update_viewport(
ctr_video_t* ctr,
settings_t *settings,
video_frame_info_t *video_info)
{
int x = 0;
int y = 0;
@ -523,14 +526,19 @@ static bool ctr_frame(void* data, const void* frame,
extern u8* gfxSharedMemory;
extern u8 gfxThreadID;
uint32_t diff;
uint32_t state_tmp = 0;
settings_t *settings = config_get_ptr();
ctr_video_t *ctr = (ctr_video_t*)data;
static float fps = 0.0;
static int total_frames = 0;
static int frames = 0;
unsigned disp_mode = settings->uints.video_3ds_display_mode;
float video_refresh_rate = video_info->refresh_rate;
uint32_t state_tmp = 0;
ctr_video_t *ctr = (ctr_video_t*)data;
static float fps = 0.0;
static int total_frames = 0;
static int frames = 0;
settings_t *settings = config_get_ptr();
unsigned disp_mode = settings->uints.video_3ds_display_mode;
bool statistics_show = video_info->statistics_show;
const char *stat_text = video_info->stat_text;
float video_refresh_rate = video_info->refresh_rate;
struct font_params *osd_params = (struct font_params*)
&video_info->osd_stat_params;
if (!width || !height || !settings)
{
@ -856,15 +864,12 @@ static bool ctr_frame(void* data, const void* frame,
ctr->msg_rendering_enabled = false;
}
else if (video_info->statistics_show)
else if (statistics_show)
{
struct font_params *osd_params = (struct font_params*)
&video_info->osd_stat_params;
if (osd_params)
{
font_driver_render_msg(ctr, video_info, video_info->stat_text,
(const struct font_params*)&video_info->osd_stat_params, NULL);
font_driver_render_msg(ctr, video_info, stat_text,
(const struct font_params*)osd_params, NULL);
}
}
#endif

View File

@ -305,27 +305,27 @@ static bool d3d8_renderchain_render(
}
static bool d3d8_renderchain_init(void *data,
const void *_video_info,
const video_info_t *video_info,
void *dev_data,
const void *info_data,
const struct LinkInfo *link_info,
bool rgb32
)
{
unsigned width, height;
d3d8_video_t *d3d = (d3d8_video_t*)data;
LPDIRECT3DDEVICE8 d3dr = (LPDIRECT3DDEVICE8)d3d->dev;
const video_info_t *video_info = (const video_info_t*)_video_info;
const struct LinkInfo *link_info = (const struct LinkInfo*)info_data;
d3d8_renderchain_t *chain = (d3d8_renderchain_t*)d3d->renderchain_data;
unsigned fmt = (rgb32) ? RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565;
struct video_viewport *custom_vp = video_viewport_get_custom();
video_driver_get_size(&width, &height);
chain->dev = dev_data;
chain->pixel_size = (fmt == RETRO_PIXEL_FORMAT_RGB565) ? 2 : 4;
chain->tex_w = link_info->tex_w;
chain->tex_h = link_info->tex_h;
chain->dev = dev_data;
chain->pixel_size = (fmt == RETRO_PIXEL_FORMAT_RGB565)
? 2
: 4;
chain->tex_w = link_info->tex_w;
chain->tex_h = link_info->tex_h;
if (!d3d8_renderchain_create_first_pass(d3d, chain, video_info))
return false;
@ -421,7 +421,7 @@ static void d3d8_viewport_info(void *data, struct video_viewport *vp)
}
static void d3d8_overlay_render(d3d8_video_t *d3d,
video_frame_info_t *video_info,
unsigned width, unsigned height,
overlay_t *overlay, bool force_linear)
{
D3DVIEWPORT8 vp_full;
@ -430,8 +430,6 @@ static void d3d8_overlay_render(d3d8_video_t *d3d,
unsigned i;
Vertex vert[4];
enum D3DTEXTUREFILTERTYPE filter_type = D3DTEXF_LINEAR;
unsigned width = video_info->width;
unsigned height = video_info->height;
if (!d3d || !overlay || !overlay->tex)
return;
@ -1487,6 +1485,12 @@ static bool d3d8_frame(void *data, const void *frame,
d3d8_video_t *d3d = (d3d8_video_t*)data;
unsigned width = video_info->width;
unsigned height = video_info->height;
struct font_params *osd_params = (struct font_params*)
&video_info->osd_stat_params;
const char *stat_text = video_info->stat_text;
bool statistics_show = video_info->statistics_show;
bool black_frame_insertion = video_info->black_frame_insertion;
(void)i;
if (!frame)
@ -1527,7 +1531,7 @@ static bool d3d8_frame(void *data, const void *frame,
/* Insert black frame first, so we
* can screenshot, etc. */
if (video_info->black_frame_insertion)
if (black_frame_insertion)
{
if (!d3d8_swap(d3d, d3d->dev) || d3d->needs_restore)
return true;
@ -1547,7 +1551,7 @@ static bool d3d8_frame(void *data, const void *frame,
if (d3d->menu && d3d->menu->enabled)
{
d3d8_set_mvp(d3d->dev, &d3d->mvp);
d3d8_overlay_render(d3d, video_info, d3d->menu, false);
d3d8_overlay_render(d3d, width, height, d3d->menu, false);
d3d->menu_display.offset = 0;
d3d8_set_stream_source(d3d->dev, 0, d3d->menu_display.buffer, 0, sizeof(Vertex));
@ -1555,14 +1559,11 @@ static bool d3d8_frame(void *data, const void *frame,
d3d8_set_viewports(d3d->dev, &screen_vp);
menu_driver_frame(video_info);
}
else if (video_info->statistics_show)
else if (statistics_show)
{
struct font_params *osd_params = (struct font_params*)
&video_info->osd_stat_params;
if (osd_params)
font_driver_render_msg(d3d, video_info, video_info->stat_text,
(const struct font_params*)&video_info->osd_stat_params, NULL);
font_driver_render_msg(d3d, video_info, stat_text,
(const struct font_params*)osd_params, NULL);
}
#endif
@ -1571,7 +1572,7 @@ static bool d3d8_frame(void *data, const void *frame,
{
d3d8_set_mvp(d3d->dev, &d3d->mvp);
for (i = 0; i < d3d->overlays_size; i++)
d3d8_overlay_render(d3d, video_info, &d3d->overlays[i], true);
d3d8_overlay_render(d3d, width, height, &d3d->overlays[i], true);
}
#endif

View File

@ -195,22 +195,18 @@ static void d3d9_log_info(const struct LinkInfo *info)
info->pass->filter == RARCH_FILTER_LINEAR ? "true" : "false");
}
static bool d3d9_init_chain(d3d9_video_t *d3d, const video_info_t *video_info)
static bool d3d9_init_chain(d3d9_video_t *d3d,
unsigned input_scale,
bool rgb32)
{
unsigned i = 0;
struct LinkInfo link_info;
unsigned current_width, current_height, out_width, out_height;
unsigned i = 0;
(void)i;
(void)current_width;
(void)current_height;
(void)out_width;
(void)out_height;
/* Setup information for first pass. */
link_info.pass = NULL;
link_info.tex_w = video_info->input_scale * RARCH_SCALE_BASE;
link_info.tex_h = video_info->input_scale * RARCH_SCALE_BASE;
link_info.tex_w = input_scale * RARCH_SCALE_BASE;
link_info.tex_h = input_scale * RARCH_SCALE_BASE;
link_info.pass = &d3d->shader.pass[0];
if (!renderchain_d3d_init_first(GFX_CTX_DIRECT3D9_API,
@ -228,7 +224,7 @@ static bool d3d9_init_chain(d3d9_video_t *d3d, const video_info_t *video_info)
!d3d->renderchain_driver->init(
d3d,
d3d->dev, &d3d->final_viewport, &link_info,
d3d->video_info.rgb32)
rgb32)
)
{
RARCH_ERR("[D3D9]: Failed to init render chain.\n");
@ -255,8 +251,8 @@ static bool d3d9_init_chain(d3d9_video_t *d3d, const video_info_t *video_info)
link_info.tex_w = next_pow2(out_width);
link_info.tex_h = next_pow2(out_height);
current_width = out_width;
current_height = out_height;
current_width = out_width;
current_height = out_height;
if (!d3d->renderchain_driver->add_pass(
d3d->renderchain_data, &link_info))
@ -423,7 +419,8 @@ void d3d9_set_mvp(void *data, const void *mat_data)
#if defined(HAVE_MENU) || defined(HAVE_OVERLAY)
static void d3d9_overlay_render(d3d9_video_t *d3d,
video_frame_info_t *video_info,
unsigned width,
unsigned height,
overlay_t *overlay, bool force_linear)
{
D3DTEXTUREFILTERTYPE filter_type;
@ -442,8 +439,6 @@ static void d3d9_overlay_render(d3d9_video_t *d3d,
D3DDECLUSAGE_COLOR, 0},
D3DDECL_END()
};
unsigned width = video_info->width;
unsigned height = video_info->height;
if (!d3d || !overlay || !overlay->tex)
return;
@ -942,7 +937,7 @@ static bool d3d9_initialize(d3d9_video_t *d3d, const video_info_t *info)
if (!ret)
return ret;
if (!d3d9_init_chain(d3d, info))
if (!d3d9_init_chain(d3d, info->input_scale, info->rgb32))
{
RARCH_ERR("[D3D9]: Failed to initialize render chain.\n");
return false;
@ -1533,7 +1528,13 @@ static bool d3d9_frame(void *data, const void *frame,
d3d9_video_t *d3d = (d3d9_video_t*)data;
unsigned width = video_info->width;
unsigned height = video_info->height;
(void)i;
bool statistics_show = video_info->statistics_show;
bool widgets_inited = video_info->widgets_inited;
bool black_frame_insertion = video_info->black_frame_insertion;
struct font_params *osd_params = (struct font_params*)
&video_info->osd_stat_params;
const char *stat_text = video_info->stat_text;
if (!frame)
return true;
@ -1577,7 +1578,7 @@ static bool d3d9_frame(void *data, const void *frame,
/* Insert black frame first, so we
* can screenshot, etc. */
if (video_info->black_frame_insertion)
if (black_frame_insertion)
{
if (!d3d9_swap(d3d, d3d->dev) || d3d->needs_restore)
return true;
@ -1596,7 +1597,7 @@ static bool d3d9_frame(void *data, const void *frame,
if (d3d->menu && d3d->menu->enabled)
{
d3d9_set_mvp(d3d->dev, &d3d->mvp);
d3d9_overlay_render(d3d, video_info, d3d->menu, false);
d3d9_overlay_render(d3d, width, height, d3d->menu, false);
d3d->menu_display.offset = 0;
d3d9_set_vertex_declaration(d3d->dev, (LPDIRECT3DVERTEXDECLARATION9)d3d->menu_display.decl);
@ -1605,17 +1606,14 @@ static bool d3d9_frame(void *data, const void *frame,
d3d9_set_viewports(d3d->dev, &screen_vp);
menu_driver_frame(video_info);
}
else if (video_info->statistics_show)
else if (statistics_show)
{
struct font_params *osd_params = (struct font_params*)
&video_info->osd_stat_params;
if (osd_params)
{
d3d9_set_viewports(d3d->dev, &screen_vp);
d3d9_begin_scene(d3d->dev);
font_driver_render_msg(d3d, video_info, video_info->stat_text,
(const struct font_params*)&video_info->osd_stat_params, NULL);
font_driver_render_msg(d3d, video_info, stat_text,
(const struct font_params*)osd_params, NULL);
d3d9_end_scene(d3d->dev);
}
}
@ -1626,12 +1624,12 @@ static bool d3d9_frame(void *data, const void *frame,
{
d3d9_set_mvp(d3d->dev, &d3d->mvp);
for (i = 0; i < d3d->overlays_size; i++)
d3d9_overlay_render(d3d, video_info, &d3d->overlays[i], true);
d3d9_overlay_render(d3d, width, height, &d3d->overlays[i], true);
}
#endif
#ifdef HAVE_GFX_WIDGETS
if (video_info->widgets_inited)
if (widgets_inited)
gfx_widgets_frame(video_info);
#endif