Reduce amount of times video_driver_get_size is called

This commit is contained in:
twinaphex 2017-01-18 23:02:24 +01:00
parent f4adbd04ae
commit c5445d2980
4 changed files with 20 additions and 25 deletions

View File

@ -285,10 +285,10 @@ static void vg_free(void *data)
free(vg);
}
static void vg_calculate_quad(vg_t *vg)
static void vg_calculate_quad(vg_t *vg, video_frame_info_t *video_info)
{
unsigned width, height;
video_driver_get_size(&width, &height);
unsigned width = video_info->width;
unsigned heigh = video_info->height;
/* set viewport for aspect ratio, taken from the OpenGL driver. */
if (vg->keep_aspect)
@ -384,23 +384,22 @@ static bool vg_frame(void *data, const void *frame,
uint64_t frame_count, unsigned pitch, const char *msg,
video_frame_info_t *video_info)
{
unsigned width, height;
vg_t *vg = (vg_t*)data;
static struct retro_perf_counter vg_fr = {0};
static struct retro_perf_counter vg_image = {0};
unsigned width = video_info->width;
unsigned height = video_info->height;
performance_counter_init(&vg_fr, "vg_fr");
performance_counter_start(&vg_fr);
video_driver_get_size(&width, &height);
if ( frame_width != vg->mRenderWidth
|| frame_height != vg->mRenderHeight
|| vg->should_resize)
{
vg->mRenderWidth = frame_width;
vg->mRenderHeight = frame_height;
vg_calculate_quad(vg);
vg_calculate_quad(vg, video_info);
matrix_3x3_quad_to_quad(
vg->x1, vg->y1, vg->x2, vg->y1, vg->x2, vg->y2, vg->x1, vg->y2,
/* needs to be flipped, Khronos loves their bottom-left origin */

View File

@ -54,7 +54,7 @@ static void vulkan_set_viewport(void *data, unsigned viewport_width,
#ifdef HAVE_OVERLAY
static void vulkan_overlay_free(vk_t *vk);
static void vulkan_render_overlay(vk_t *vk);
static void vulkan_render_overlay(vk_t *vk, video_frame_info_t *video_info);
#endif
static void vulkan_viewport_info(void *data, struct video_viewport *vp);
@ -1523,7 +1523,7 @@ static bool vulkan_frame(void *data, const void *frame,
unsigned pitch, const char *msg, video_frame_info_t *video_info)
{
struct vk_per_frame *chain;
unsigned width, height;
VkSemaphore signal_semaphores[2];
VkClearValue clear_value;
vk_t *vk = (vk_t*)data;
static struct retro_perf_counter frame_run = {0};
@ -1534,7 +1534,8 @@ static bool vulkan_frame(void *data, const void *frame,
static struct retro_perf_counter swapbuffers = {0};
static struct retro_perf_counter queue_submit = {0};
bool waits_for_semaphores = false;
VkSemaphore signal_semaphores[2];
unsigned width = video_info->width;
unsigned height = video_info->height;
VkCommandBufferBeginInfo begin_info = {
VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO };
@ -1554,8 +1555,6 @@ static bool vulkan_frame(void *data, const void *frame,
performance_counter_init(&end_cmd, "end_command");
performance_counter_start(&frame_run);
video_driver_get_size(&width, &height);
/* Bookkeeping on start of frame. */
chain = &vk->swapchain[frame_index];
vk->chain = chain;
@ -1779,7 +1778,7 @@ static bool vulkan_frame(void *data, const void *frame,
#ifdef HAVE_OVERLAY
if (vk->overlay.enable)
vulkan_render_overlay(vk);
vulkan_render_overlay(vk, video_info);
#endif
performance_counter_stop(&build_cmd);
@ -2394,16 +2393,16 @@ static void vulkan_overlay_set_alpha(void *data,
}
}
static void vulkan_render_overlay(vk_t *vk)
static void vulkan_render_overlay(vk_t *vk, video_frame_info_t *video_info)
{
unsigned width, height;
unsigned i;
struct video_viewport vp;
unsigned width = video_info->width;
unsigned height = video_info->height;
if (!vk)
return;
video_driver_get_size(&width, &height);
vp = vk->vp;
vulkan_set_viewport(vk, width, height, vk->overlay.full_screen, false);

View File

@ -1029,8 +1029,8 @@ static void mui_frame(void *data, video_frame_info_t *video_info)
float header_bg_color_real[16] = {0};
file_list_t *list = NULL;
mui_node_t *node = NULL;
unsigned width = 0;
unsigned height = 0;
unsigned width = video_info->width;
unsigned height = video_info->height;
unsigned ticker_limit = 0;
unsigned i = 0;
unsigned header_height = 0;
@ -1211,8 +1211,6 @@ static void mui_frame(void *data, video_frame_info_t *video_info)
menu_display_set_alpha(header_bg_color_real, settings->menu.header.opacity);
menu_display_set_alpha(footer_bg_color_real, settings->menu.footer.opacity);
video_driver_get_size(&width, &height);
menu_display_set_viewport();
header_height = menu_display_get_header_height();
@ -1663,7 +1661,6 @@ static void mui_context_reset(void *data)
if (!mui || !settings)
return;
mui_layout(mui);
mui_context_bg_destroy(mui);
menu_display_allocate_white_texture();

View File

@ -2558,13 +2558,15 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
size_t selection;
size_t percent_width = 0;
math_matrix_4x4 mymat;
unsigned i, width, height;
unsigned i;
float item_color[16], coord_black[16], coord_white[16];
menu_display_ctx_rotate_draw_t rotate_draw;
char msg[1024];
char title_msg[255];
char title_truncated[255];
menu_display_frame_info_t menu_disp_info;
unsigned width = video_info->width;
unsigned height = video_info->height;
bool render_background = false;
file_list_t *selection_buf = NULL;
file_list_t *menu_stack = NULL;
@ -2580,8 +2582,6 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
title_msg[0] = '\0';
title_truncated[0] = '\0';
video_driver_get_size(&width, &height);
menu_display_font_bind_block(xmb->font, &xmb->raster_block);
menu_display_font_bind_block(xmb->font2, &xmb->raster_block2);