From 17273493ef71d446b7d5cd3413ac0412e25622c2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 19 Apr 2016 08:50:35 +0200 Subject: [PATCH] (Menu) Create viewport function callback --- menu/drivers/xmb.c | 2 +- menu/drivers_display/menu_display_d3d.cpp | 30 +++++++++++++++------- menu/drivers_display/menu_display_gl.c | 15 +++++++++-- menu/drivers_display/menu_display_null.c | 6 +++++ menu/drivers_display/menu_display_vulkan.c | 24 ++++++++++++----- menu/menu_display.h | 1 + 6 files changed, 60 insertions(+), 18 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 39eebcf97e..31416f69ad 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -49,7 +49,7 @@ #include "../../tasks/tasks_internal.h" -#if 0 +#if 1 #define XMB_RIBBON_ENABLE #define XMB_RIBBON_ROWS 16 #define XMB_RIBBON_COLS 32 diff --git a/menu/drivers_display/menu_display_d3d.cpp b/menu/drivers_display/menu_display_d3d.cpp index 87f2c86fae..bc22eccdca 100644 --- a/menu/drivers_display/menu_display_d3d.cpp +++ b/menu/drivers_display/menu_display_d3d.cpp @@ -110,9 +110,27 @@ static void menu_display_d3d_blend_end(void) d3d_disable_blend_func(d3d->dev); } -static void menu_display_d3d_draw(void *data) +static void menu_display_d3d_viewport(void *data) { D3DVIEWPORT vp = {0}; + d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(false); + menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data; + + if (!d3d || !draw) + return; + + vp.X = draw->x; + vp.Y = draw->y; + vp.Width = draw->width; + vp.Height = draw->height; + vp.MinZ = 0.0f; + vp.MaxZ = 1.0f; + + d3d_set_viewports(d3d->dev, &vp); +} + +static void menu_display_d3d_draw(void *data) +{ math_matrix_4x4 *mat = NULL; d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(false); menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data; @@ -136,14 +154,7 @@ static void menu_display_d3d_draw(void *data) if (!draw->coords->lut_tex_coord) draw->coords->lut_tex_coord = menu_display_d3d_get_default_tex_coords(); - vp.X = draw->x; - vp.Y = draw->y; - vp.Width = draw->width; - vp.Height = draw->height; - vp.MinZ = 0.0f; - vp.MaxZ = 1.0f; - - d3d_set_viewports(d3d->dev, &vp); + menu_display_d3d_viewport(draw); d3d_set_texture(d3d->dev, 0, (LPDIRECT3DTEXTURE)draw->texture); #if 0 @@ -192,6 +203,7 @@ static bool menu_display_d3d_font_init_first( menu_display_ctx_driver_t menu_display_ctx_d3d = { menu_display_d3d_draw, + menu_display_d3d_viewport, menu_display_d3d_blend_begin, menu_display_d3d_blend_end, menu_display_d3d_restore_clear_color, diff --git a/menu/drivers_display/menu_display_gl.c b/menu/drivers_display/menu_display_gl.c index f09cb104c0..c0bf8a379d 100644 --- a/menu/drivers_display/menu_display_gl.c +++ b/menu/drivers_display/menu_display_gl.c @@ -94,12 +94,22 @@ static void menu_display_gl_blend_end(void) glDisable(GL_BLEND); } +static void menu_display_gl_viewport(void *data) +{ + gl_t *gl = (gl_t*)video_driver_get_ptr(false); + menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data; + + if (!gl || !draw) + return; + glViewport(draw->x, draw->y, draw->width, draw->height); +} + static void menu_display_gl_draw(void *data) { video_shader_ctx_mvp_t mvp; video_shader_ctx_coords_t coords; - gl_t *gl = (gl_t*)video_driver_get_ptr(false); math_matrix_4x4 *mat = NULL; + gl_t *gl = (gl_t*)video_driver_get_ptr(false); menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data; if (!gl || !draw) @@ -120,7 +130,7 @@ static void menu_display_gl_draw(void *data) if (!draw->coords->lut_tex_coord) draw->coords->lut_tex_coord = menu_display_gl_get_default_tex_coords(); - glViewport(draw->x, draw->y, draw->width, draw->height); + menu_display_gl_viewport(draw); glBindTexture(GL_TEXTURE_2D, (GLuint)draw->texture); coords.handle_data = gl; @@ -164,6 +174,7 @@ static bool menu_display_gl_font_init_first( menu_display_ctx_driver_t menu_display_ctx_gl = { menu_display_gl_draw, + menu_display_gl_viewport, menu_display_gl_blend_begin, menu_display_gl_blend_end, menu_display_gl_restore_clear_color, diff --git a/menu/drivers_display/menu_display_null.c b/menu/drivers_display/menu_display_null.c index 8f3105ddf8..b0df865259 100644 --- a/menu/drivers_display/menu_display_null.c +++ b/menu/drivers_display/menu_display_null.c @@ -42,6 +42,11 @@ static void menu_display_null_draw(void *data) (void)data; } +static void menu_display_null_viewport(void *data) +{ + (void)data; +} + static void menu_display_null_restore_clear_color(void) { } @@ -72,6 +77,7 @@ static const float *menu_display_null_get_default_tex_coords(void) menu_display_ctx_driver_t menu_display_ctx_null = { menu_display_null_draw, + menu_display_null_viewport, menu_display_null_blend_begin, menu_display_null_blend_end, menu_display_null_restore_clear_color, diff --git a/menu/drivers_display/menu_display_vulkan.c b/menu/drivers_display/menu_display_vulkan.c index d87fe65d76..99579242a6 100644 --- a/menu/drivers_display/menu_display_vulkan.c +++ b/menu/drivers_display/menu_display_vulkan.c @@ -61,6 +61,22 @@ static unsigned to_display_pipeline( return ((type == MENU_DISPLAY_PRIM_TRIANGLESTRIP) << 1) | (blend << 0); } +static void menu_display_vk_viewport(void *data) +{ + menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data; + vk_t *vk = (vk_t*)video_driver_get_ptr(false); + + if (!vk || !draw) + return; + + vk->vk_vp.x = draw->x; + vk->vk_vp.y = vk->context->swapchain_height - draw->y - draw->height; + vk->vk_vp.width = draw->width; + vk->vk_vp.height = draw->height; + vk->vk_vp.minDepth = 0.0f; + vk->vk_vp.maxDepth = 1.0f; +} + static void menu_display_vk_draw(void *data) { unsigned i; @@ -99,12 +115,7 @@ static void menu_display_vk_draw(void *data) if (!texture) texture = &vk->display.blank_texture; - vk->vk_vp.x = draw->x; - vk->vk_vp.y = vk->context->swapchain_height - draw->y - draw->height; - vk->vk_vp.width = draw->width; - vk->vk_vp.height = draw->height; - vk->vk_vp.minDepth = 0.0f; - vk->vk_vp.maxDepth = 1.0f; + menu_display_vk_viewport(draw); vk->tracker.dirty |= VULKAN_DIRTY_DYNAMIC_BIT; /* Bake interleaved VBO. Kinda ugly, we should probably try to move to @@ -190,6 +201,7 @@ static bool menu_display_vk_font_init_first( menu_display_ctx_driver_t menu_display_ctx_vulkan = { menu_display_vk_draw, + menu_display_vk_viewport, menu_display_vk_blend_begin, menu_display_vk_blend_end, menu_display_vk_restore_clear_color, diff --git a/menu/menu_display.h b/menu/menu_display.h index a88d3e0264..71f16a5107 100644 --- a/menu/menu_display.h +++ b/menu/menu_display.h @@ -150,6 +150,7 @@ typedef struct menu_display_ctx_datetime typedef struct menu_display_ctx_driver { void (*draw)(void *data); + void (*viewport)(void *data); void (*blend_begin)(void); void (*blend_end)(void); void (*restore_clear_color)(void);