From 4e6f26d2e43a59cac98c67e4af362ae3962b5524 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Mar 2020 16:24:20 +0100 Subject: [PATCH] (Video drivers) Cleanups --- gfx/drivers/d3d11.c | 24 +++++++++++++----------- gfx/drivers/d3d12.c | 25 ++++++++++++++----------- gfx/drivers/dispmanx_gfx.c | 5 +++-- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index f61767a0ee..771c5b1e25 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -1282,11 +1282,15 @@ static bool d3d11_gfx_frame( video_frame_info_t* video_info) { unsigned i; - d3d11_texture_t* texture = NULL; - d3d11_video_t* d3d11 = (d3d11_video_t*)data; - D3D11DeviceContext context = d3d11->context; - unsigned video_width = video_info->width; - unsigned video_height = video_info->height; + d3d11_texture_t* texture = NULL; + d3d11_video_t* d3d11 = (d3d11_video_t*)data; + D3D11DeviceContext context = d3d11->context; + bool widgets_inited = video_info->widgets_inited; + const char *stat_text = video_info->stat_text; + unsigned video_width = video_info->width; + unsigned video_height = video_info->height; + bool statistics_show = video_info->statistics_show; + struct font_params* osd_params = (struct font_params*)&video_info->osd_stat_params; if (d3d11->resize_chain) { @@ -1544,18 +1548,16 @@ static bool d3d11_gfx_frame( menu_driver_frame(video_info); else #endif - if (video_info->statistics_show) + if (statistics_show) { - struct font_params* osd_params = (struct font_params*)&video_info->osd_stat_params; - if (osd_params) { D3D11SetViewports(context, 1, &d3d11->viewport); D3D11SetBlendState(d3d11->context, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK); D3D11SetVertexBuffer(context, 0, d3d11->sprites.vbo, sizeof(d3d11_sprite_t), 0); font_driver_render_msg(d3d11, - video_info, video_info->stat_text, - (const struct font_params*)&video_info->osd_stat_params, NULL); + video_info, stat_text, + (const struct font_params*)osd_params, NULL); } } @@ -1581,7 +1583,7 @@ static bool d3d11_gfx_frame( #endif #ifdef HAVE_GFX_WIDGETS - if (video_info->widgets_inited) + if (widgets_inited) gfx_widgets_frame(video_info); #endif diff --git a/gfx/drivers/d3d12.c b/gfx/drivers/d3d12.c index 75e01ec5fa..35c9ceec60 100644 --- a/gfx/drivers/d3d12.c +++ b/gfx/drivers/d3d12.c @@ -1166,10 +1166,16 @@ static bool d3d12_gfx_frame( video_frame_info_t* video_info) { unsigned i; - d3d12_texture_t* texture = NULL; - d3d12_video_t* d3d12 = (d3d12_video_t*)data; - unsigned video_width = video_info->width; - unsigned video_height = video_info->height; + d3d12_texture_t* texture = NULL; + d3d12_video_t* d3d12 = (d3d12_video_t*)data; + const char *stat_text = video_info->stat_text; + bool statistics_show = video_info->statistics_show; + bool widgets_inited = video_info->widgets_inited; + unsigned video_width = video_info->width; + unsigned video_height = video_info->height; + struct font_params *osd_params = (struct font_params*) + &video_info->osd_stat_params; + d3d12_gfx_sync(d3d12); @@ -1511,19 +1517,16 @@ static bool d3d12_gfx_frame( menu_driver_frame(video_info); else #endif - if (video_info->statistics_show) + if (statistics_show) { - struct font_params *osd_params = (struct font_params*) - &video_info->osd_stat_params; - if (osd_params) { D3D12SetPipelineState(d3d12->queue.cmd, d3d12->sprites.pipe_blend); D3D12RSSetViewports(d3d12->queue.cmd, 1, &d3d12->chain.viewport); D3D12RSSetScissorRects(d3d12->queue.cmd, 1, &d3d12->chain.scissorRect); D3D12IASetVertexBuffers(d3d12->queue.cmd, 0, 1, &d3d12->sprites.vbo_view); - font_driver_render_msg(d3d12, video_info, video_info->stat_text, - (const struct font_params*)&video_info->osd_stat_params, NULL); + font_driver_render_msg(d3d12, video_info, stat_text, + (const struct font_params*)osd_params, NULL); } } #ifdef HAVE_OVERLAY @@ -1563,7 +1566,7 @@ static bool d3d12_gfx_frame( #endif #ifdef HAVE_GFX_WIDGETS - if (video_info->widgets_inited) + if (widgets_inited) gfx_widgets_frame(video_info); #endif diff --git a/gfx/drivers/dispmanx_gfx.c b/gfx/drivers/dispmanx_gfx.c index 97193360f6..0466dfc952 100644 --- a/gfx/drivers/dispmanx_gfx.c +++ b/gfx/drivers/dispmanx_gfx.c @@ -437,7 +437,8 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width, video_frame_info_t *video_info) { struct dispmanx_video *_dispvars = data; - float aspect = video_driver_get_aspect_ratio(); + float aspect = video_driver_get_aspect_ratio(); + unsigned max_swapchain_images = video_info->max_swapchain_images; if (!frame) return true; @@ -468,7 +469,7 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width, _dispvars->rgb32 ? VC_IMAGE_XRGB8888 : VC_IMAGE_RGB565, 255, _dispvars->aspect_ratio, - video_info->max_swapchain_images, + max_swapchain_images, 0, &_dispvars->main_surface);