(menu display driver) Get rid of remaining pointer grabbing

This commit is contained in:
twinaphex 2018-02-16 19:42:13 +01:00
parent 407d7e2c4e
commit 35f1c9ba33
16 changed files with 90 additions and 58 deletions

View File

@ -343,7 +343,7 @@ static void mui_draw_icon(
rotate_draw.scale_z = 1; rotate_draw.scale_z = 1;
rotate_draw.scale_enable = true; rotate_draw.scale_enable = true;
menu_display_rotate_z(&rotate_draw); menu_display_rotate_z(&rotate_draw, video_info);
coords.vertices = 4; coords.vertices = 4;
coords.vertex = NULL; coords.vertex = NULL;

View File

@ -699,7 +699,7 @@ static void xmb_draw_thumbnail(
rotate_draw.scale_z = 1; rotate_draw.scale_z = 1;
rotate_draw.scale_enable = true; rotate_draw.scale_enable = true;
menu_display_rotate_z(&rotate_draw); menu_display_rotate_z(&rotate_draw, video_info);
coords.vertices = 4; coords.vertices = 4;
coords.vertex = NULL; coords.vertex = NULL;
@ -2548,7 +2548,7 @@ static int xmb_draw_item(
rotate_draw.scale_z = 1; rotate_draw.scale_z = 1;
rotate_draw.scale_enable = true; rotate_draw.scale_enable = true;
menu_display_rotate_z(&rotate_draw); menu_display_rotate_z(&rotate_draw, video_info);
xmb_draw_icon(video_info, xmb_draw_icon(video_info,
menu_disp_info, menu_disp_info,
@ -2629,7 +2629,7 @@ static void xmb_draw_items(
rotate_draw.scale_z = 1; rotate_draw.scale_z = 1;
rotate_draw.scale_enable = true; rotate_draw.scale_enable = true;
menu_display_rotate_z(&rotate_draw); menu_display_rotate_z(&rotate_draw, video_info);
menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i); menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i);
@ -2980,7 +2980,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
rotate_draw.scale_z = 1; rotate_draw.scale_z = 1;
rotate_draw.scale_enable = true; rotate_draw.scale_enable = true;
menu_display_rotate_z(&rotate_draw); menu_display_rotate_z(&rotate_draw, video_info);
menu_display_blend_begin(video_info); menu_display_blend_begin(video_info);
if (xmb->savestate_thumbnail) if (xmb->savestate_thumbnail)
@ -3168,7 +3168,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
rotate_draw.scale_z = 1; rotate_draw.scale_z = 1;
rotate_draw.scale_enable = true; rotate_draw.scale_enable = true;
menu_display_rotate_z(&rotate_draw); menu_display_rotate_z(&rotate_draw, video_info);
xmb_draw_icon(video_info, xmb_draw_icon(video_info,
menu_disp_info, menu_disp_info,

View File

@ -25,7 +25,7 @@
#include "../menu_driver.h" #include "../menu_driver.h"
static void *menu_display_caca_get_default_mvp(void) static void *menu_display_caca_get_default_mvp(video_frame_info_t *video_info)
{ {
return NULL; return NULL;
} }
@ -48,7 +48,7 @@ static void menu_display_caca_draw_pipeline(void *data, video_frame_info_t *vide
(void)data; (void)data;
} }
static void menu_display_caca_viewport(void *data) static void menu_display_caca_viewport(void *data, video_frame_info_t *video_info)
{ {
(void)data; (void)data;
} }

View File

@ -38,7 +38,7 @@ static const float *menu_display_ctr_get_default_tex_coords(void)
return NULL; return NULL;
} }
static void *menu_display_ctr_get_default_mvp(void) static void *menu_display_ctr_get_default_mvp(video_frame_info_t *video_info)
{ {
return NULL; return NULL;
} }
@ -53,7 +53,7 @@ static void menu_display_ctr_blend_end(video_frame_info_t *video_info)
} }
static void menu_display_ctr_viewport(void *data) static void menu_display_ctr_viewport(void *data, video_frame_info_t *video_info)
{ {
} }

View File

@ -53,7 +53,7 @@ static const float *menu_display_d3d_get_default_tex_coords(void)
return &d3d_tex_coords[0]; return &d3d_tex_coords[0];
} }
static void *menu_display_d3d_get_default_mvp(void) static void *menu_display_d3d_get_default_mvp(video_frame_info_t *video_info)
{ {
static math_matrix_4x4 id; static math_matrix_4x4 id;
matrix_4x4_identity(id); matrix_4x4_identity(id);
@ -100,7 +100,7 @@ static void menu_display_d3d_blend_end(video_frame_info_t *video_info)
d3d_disable_blend_func(d3d->dev); d3d_disable_blend_func(d3d->dev);
} }
static void menu_display_d3d_viewport(void *data) static void menu_display_d3d_viewport(void *data, video_frame_info_t *video_info)
{ {
} }
@ -190,7 +190,7 @@ static void menu_display_d3d_draw(void *data, video_frame_info_t *video_info)
d3d_vertex_buffer_unlock(d3d->menu_display.buffer); d3d_vertex_buffer_unlock(d3d->menu_display.buffer);
if(!draw->matrix_data) if(!draw->matrix_data)
draw->matrix_data = menu_display_d3d_get_default_mvp(); draw->matrix_data = menu_display_d3d_get_default_mvp(video_info);
/* ugh */ /* ugh */
video_driver_get_size(&width, &height); video_driver_get_size(&width, &height);

View File

@ -28,11 +28,20 @@
#include "../../gfx/video_driver.h" #include "../../gfx/video_driver.h"
#include "../../gfx/common/d3d11_common.h" #include "../../gfx/common/d3d11_common.h"
static const float* menu_display_d3d11_get_default_vertices(void) { return NULL; } static const float* menu_display_d3d11_get_default_vertices(void)
{
return NULL;
}
static const float* menu_display_d3d11_get_default_tex_coords(void) { return NULL; } static const float* menu_display_d3d11_get_default_tex_coords(void)
{
return NULL;
}
static void* menu_display_d3d11_get_default_mvp(void) { return NULL; } static void* menu_display_d3d11_get_default_mvp(video_frame_info_t *video_info)
{
return NULL;
}
static void menu_display_d3d11_blend_begin(video_frame_info_t *video_info) static void menu_display_d3d11_blend_begin(video_frame_info_t *video_info)
{ {
@ -48,7 +57,9 @@ static void menu_display_d3d11_blend_end(video_frame_info_t *video_info)
d3d11->blend_disable, NULL, D3D11_DEFAULT_SAMPLE_MASK); d3d11->blend_disable, NULL, D3D11_DEFAULT_SAMPLE_MASK);
} }
static void menu_display_d3d11_viewport(void* data) {} static void menu_display_d3d11_viewport(void* data, video_frame_info_t *video_info)
{
}
static void menu_display_d3d11_draw(void* data, video_frame_info_t *video_info) static void menu_display_d3d11_draw(void* data, video_frame_info_t *video_info)
{ {

View File

@ -28,11 +28,20 @@
#include "../../gfx/video_driver.h" #include "../../gfx/video_driver.h"
#include "../../gfx/common/d3d12_common.h" #include "../../gfx/common/d3d12_common.h"
static const float* menu_display_d3d12_get_default_vertices(void) { return NULL; } static const float* menu_display_d3d12_get_default_vertices(void)
{
return NULL;
}
static const float* menu_display_d3d12_get_default_tex_coords(void) { return NULL; } static const float* menu_display_d3d12_get_default_tex_coords(void)
{
return NULL;
}
static void* menu_display_d3d12_get_default_mvp(void) { return NULL; } static void* menu_display_d3d12_get_default_mvp(video_frame_info_t *video_info)
{
return NULL;
}
static void menu_display_d3d12_blend_begin(video_frame_info_t *video_info) static void menu_display_d3d12_blend_begin(video_frame_info_t *video_info)
{ {
@ -50,7 +59,9 @@ static void menu_display_d3d12_blend_end(video_frame_info_t *video_info)
D3D12SetPipelineState(d3d12->queue.cmd, d3d12->sprites.pipe); D3D12SetPipelineState(d3d12->queue.cmd, d3d12->sprites.pipe);
} }
static void menu_display_d3d12_viewport(void* data) {} static void menu_display_d3d12_viewport(void* data, video_frame_info_t *video_info)
{
}
static void menu_display_d3d12_draw(void* data, video_frame_info_t *video_info) static void menu_display_d3d12_draw(void* data, video_frame_info_t *video_info)
{ {

View File

@ -29,7 +29,7 @@
#include "../../gfx/common/win32_common.h" #include "../../gfx/common/win32_common.h"
#endif #endif
static void *menu_display_gdi_get_default_mvp(void) static void *menu_display_gdi_get_default_mvp(video_frame_info_t *video_info)
{ {
return NULL; return NULL;
} }
@ -52,7 +52,7 @@ static void menu_display_gdi_draw_pipeline(void *data, video_frame_info_t *video
(void)data; (void)data;
} }
static void menu_display_gdi_viewport(void *data) static void menu_display_gdi_viewport(void *data, video_frame_info_t *video_info)
{ {
(void)data; (void)data;
} }

View File

@ -50,9 +50,9 @@ static const float *menu_display_gl_get_default_tex_coords(void)
return &gl_tex_coords[0]; return &gl_tex_coords[0];
} }
static void *menu_display_gl_get_default_mvp(void) static void *menu_display_gl_get_default_mvp(video_frame_info_t *video_info)
{ {
gl_t *gl = (gl_t*)video_driver_get_ptr(false); gl_t *gl = video_info ? (gl_t*)video_info->userdata : NULL;
if (!gl) if (!gl)
return NULL; return NULL;
@ -96,13 +96,12 @@ static void menu_display_gl_blend_end(video_frame_info_t *video_info)
glDisable(GL_BLEND); glDisable(GL_BLEND);
} }
static void menu_display_gl_viewport(void *data) static void menu_display_gl_viewport(void *data, video_frame_info_t *video_info)
{ {
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data; menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
if (!draw) if (draw)
return; glViewport(draw->x, draw->y, draw->width, draw->height);
glViewport(draw->x, draw->y, draw->width, draw->height);
} }
static void menu_display_gl_bind_texture(void *data) static void menu_display_gl_bind_texture(void *data)
@ -132,7 +131,7 @@ static void menu_display_gl_draw(void *data, video_frame_info_t *video_info)
if (!draw->coords->lut_tex_coord) if (!draw->coords->lut_tex_coord)
draw->coords->lut_tex_coord = menu_display_gl_get_default_tex_coords(); draw->coords->lut_tex_coord = menu_display_gl_get_default_tex_coords();
menu_display_gl_viewport(draw); menu_display_gl_viewport(draw, video_info);
menu_display_gl_bind_texture(draw); menu_display_gl_bind_texture(draw);
coords.handle_data = gl; coords.handle_data = gl;
@ -142,7 +141,7 @@ static void menu_display_gl_draw(void *data, video_frame_info_t *video_info)
mvp.data = gl; mvp.data = gl;
mvp.matrix = draw->matrix_data ? (math_matrix_4x4*)draw->matrix_data mvp.matrix = draw->matrix_data ? (math_matrix_4x4*)draw->matrix_data
: (math_matrix_4x4*)menu_display_gl_get_default_mvp(); : (math_matrix_4x4*)menu_display_gl_get_default_mvp(video_info);
video_driver_set_mvp(&mvp); video_driver_set_mvp(&mvp);

View File

@ -23,7 +23,7 @@
#include "../menu_driver.h" #include "../menu_driver.h"
static void *menu_display_null_get_default_mvp(void) static void *menu_display_null_get_default_mvp(video_frame_info_t *video_info)
{ {
return NULL; return NULL;
} }
@ -47,7 +47,7 @@ static void menu_display_null_draw_pipeline(
(void)data; (void)data;
} }
static void menu_display_null_viewport(void *data) static void menu_display_null_viewport(void *data, video_frame_info_t *video_info)
{ {
(void)data; (void)data;
} }

View File

@ -25,7 +25,7 @@
#include "../menu_driver.h" #include "../menu_driver.h"
static void *menu_display_vga_get_default_mvp(void) static void *menu_display_vga_get_default_mvp(video_frame_info_t *video_info)
{ {
return NULL; return NULL;
} }
@ -48,7 +48,7 @@ static void menu_display_vga_draw_pipeline(void *data, video_frame_info_t *video
(void)data; (void)data;
} }
static void menu_display_vga_viewport(void *data) static void menu_display_vga_viewport(void *data, video_frame_info_t *video_info)
{ {
(void)data; (void)data;
} }

View File

@ -53,9 +53,11 @@ static const float *menu_display_vita2d_get_default_tex_coords(void)
return &vita2d_tex_coords[0]; return &vita2d_tex_coords[0];
} }
static void *menu_display_vita2d_get_default_mvp(void) static void *menu_display_vita2d_get_default_mvp(
video_frame_info_t *video_info)
{ {
vita_video_t *vita2d = (vita_video_t*)video_driver_get_ptr(false); vita_video_t *vita2d = video_info ?
(vita_video_t*)video_info->userdata : NULL;
if (!vita2d) if (!vita2d)
return NULL; return NULL;
@ -92,10 +94,10 @@ static void menu_display_vita2d_blend_end(video_frame_info_t *video_info)
} }
static void menu_display_vita2d_viewport(void *data) static void menu_display_vita2d_viewport(void *data, video_frame_info_t *video_info)
{ {
vita_video_t *vita2d = (vita_video_t*)video_driver_get_ptr(false); vita_video_t *vita2d = video_info ? (vita_video_t*)video_info->userdata : NULL;
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data; menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
if (!vita2d || !draw) if (!vita2d || !draw)
return; return;

View File

@ -48,9 +48,9 @@ static const float vk_colors[] = {
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
}; };
static void *menu_display_vk_get_default_mvp(void) static void *menu_display_vk_get_default_mvp(video_frame_info_t *video_info)
{ {
vk_t *vk = (vk_t*)video_driver_get_ptr(false); vk_t *vk = video_info ? (vk_t*)video_info->userdata : NULL;
if (!vk) if (!vk)
return NULL; return NULL;
return &vk->mvp_no_rot; return &vk->mvp_no_rot;
@ -99,10 +99,12 @@ static unsigned to_menu_pipeline(
} }
#endif #endif
static void menu_display_vk_viewport(void *data) static void menu_display_vk_viewport(void *data,
video_frame_info_t *video_info)
{ {
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data; menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
vk_t *vk = (vk_t*)video_driver_get_ptr(false); vk_t *vk = video_info ? (vk_t*)video_info->userdata
: NULL;
if (!vk || !draw) if (!vk || !draw)
return; return;
@ -160,8 +162,12 @@ static void menu_display_vk_draw_pipeline(void *data, video_frame_info_t *video_
draw->pipeline.backend_data_size = sizeof(math_matrix_4x4) + 3 * sizeof(float); draw->pipeline.backend_data_size = sizeof(math_matrix_4x4) + 3 * sizeof(float);
/* Match UBO layout in shader. */ /* Match UBO layout in shader. */
memcpy(ubo_scratch_data, menu_display_vk_get_default_mvp(), sizeof(math_matrix_4x4)); memcpy(ubo_scratch_data,
memcpy(ubo_scratch_data + sizeof(math_matrix_4x4), output_size, sizeof(output_size)); menu_display_vk_get_default_mvp(video_info),
sizeof(math_matrix_4x4));
memcpy(ubo_scratch_data + sizeof(math_matrix_4x4),
output_size,
sizeof(output_size));
memcpy(ubo_scratch_data + sizeof(math_matrix_4x4) + 2 * sizeof(float), &t, sizeof(t)); memcpy(ubo_scratch_data + sizeof(math_matrix_4x4) + 2 * sizeof(float), &t, sizeof(t));
draw->coords = &blank_coords; draw->coords = &blank_coords;
blank_coords.vertices = 4; blank_coords.vertices = 4;
@ -204,7 +210,8 @@ static void menu_display_vk_draw(void *data, video_frame_info_t *video_info)
if (!color) if (!color)
color = menu_display_vk_get_default_color(); color = menu_display_vk_get_default_color();
menu_display_vk_viewport(draw); menu_display_vk_viewport(draw, video_info);
vk->tracker.dirty |= VULKAN_DIRTY_DYNAMIC_BIT; vk->tracker.dirty |= VULKAN_DIRTY_DYNAMIC_BIT;
/* Bake interleaved VBO. Kinda ugly, we should probably try to move to /* Bake interleaved VBO. Kinda ugly, we should probably try to move to
@ -266,7 +273,7 @@ static void menu_display_vk_draw(void *data, video_frame_info_t *video_info)
(texture->default_smooth ? vk->samplers.linear (texture->default_smooth ? vk->samplers.linear
: vk->samplers.nearest); : vk->samplers.nearest);
call.uniform = draw->matrix_data call.uniform = draw->matrix_data
? draw->matrix_data : menu_display_vk_get_default_mvp(); ? draw->matrix_data : menu_display_vk_get_default_mvp(video_info);
call.uniform_size = sizeof(math_matrix_4x4); call.uniform_size = sizeof(math_matrix_4x4);
call.vbo = ⦥ call.vbo = ⦥
call.vertices = draw->coords->vertices; call.vertices = draw->coords->vertices;

View File

@ -39,7 +39,7 @@ static const float *menu_display_wiiu_get_default_tex_coords(void)
return NULL; return NULL;
} }
static void *menu_display_wiiu_get_default_mvp(void) static void *menu_display_wiiu_get_default_mvp(video_frame_info_t *video_info)
{ {
return NULL; return NULL;
} }
@ -54,7 +54,7 @@ static void menu_display_wiiu_blend_end(video_frame_info_t *video_info)
} }
static void menu_display_wiiu_viewport(void *data) static void menu_display_wiiu_viewport(void *data, video_frame_info_t *video_info)
{ {
} }

View File

@ -640,7 +640,7 @@ void menu_display_draw_bg(menu_display_ctx_draw_t *draw,
if (!draw->texture) if (!draw->texture)
draw->texture = menu_display_white_texture; draw->texture = menu_display_white_texture;
draw->matrix_data = (math_matrix_4x4*)menu_disp->get_default_mvp(); draw->matrix_data = (math_matrix_4x4*)menu_disp->get_default_mvp(video_info);
} }
void menu_display_draw_gradient(menu_display_ctx_draw_t *draw, void menu_display_draw_gradient(menu_display_ctx_draw_t *draw,
@ -719,7 +719,7 @@ void menu_display_draw_texture(
draw.pipeline.id = 0; draw.pipeline.id = 0;
coords.color = (const float*)color; coords.color = (const float*)color;
menu_display_rotate_z(&rotate_draw); menu_display_rotate_z(&rotate_draw, video_info);
draw.texture = texture; draw.texture = texture;
draw.x = x; draw.x = x;
@ -806,7 +806,7 @@ void menu_display_draw_texture_slice(
draw.pipeline.id = 0; draw.pipeline.id = 0;
coords.color = (const float*)colors; coords.color = (const float*)colors;
menu_display_rotate_z(&rotate_draw); menu_display_rotate_z(&rotate_draw, video_info);
draw.texture = texture; draw.texture = texture;
draw.x = 0; draw.x = 0;
@ -1012,7 +1012,8 @@ void menu_display_draw_texture_slice(
free(tex_coord); free(tex_coord);
} }
void menu_display_rotate_z(menu_display_ctx_rotate_draw_t *draw) void menu_display_rotate_z(menu_display_ctx_rotate_draw_t *draw,
video_frame_info_t *video_info)
{ {
#if !defined(VITA) && !defined(_3DS) && !defined(WIIU) #if !defined(VITA) && !defined(_3DS) && !defined(WIIU)
math_matrix_4x4 matrix_rotated, matrix_scaled; math_matrix_4x4 matrix_rotated, matrix_scaled;
@ -1021,7 +1022,7 @@ void menu_display_rotate_z(menu_display_ctx_rotate_draw_t *draw)
if (!draw || !menu_disp || !menu_disp->get_default_mvp) if (!draw || !menu_disp || !menu_disp->get_default_mvp)
return; return;
b = (math_matrix_4x4*)menu_disp->get_default_mvp(); b = (math_matrix_4x4*)menu_disp->get_default_mvp(video_info);
if (!b) if (!b)
return; return;

View File

@ -323,7 +323,7 @@ typedef struct menu_display_ctx_driver
void (*draw)(void *data, video_frame_info_t *video_info); void (*draw)(void *data, video_frame_info_t *video_info);
/* Draw one of the menu pipeline shaders. */ /* Draw one of the menu pipeline shaders. */
void (*draw_pipeline)(void *data, video_frame_info_t *video_info); void (*draw_pipeline)(void *data, video_frame_info_t *video_info);
void (*viewport)(void *data); void (*viewport)(void *data, video_frame_info_t *video_info);
/* Start blending operation. */ /* Start blending operation. */
void (*blend_begin)(video_frame_info_t *video_info); void (*blend_begin)(video_frame_info_t *video_info);
/* Finish blending operation. */ /* Finish blending operation. */
@ -334,7 +334,7 @@ typedef struct menu_display_ctx_driver
void (*clear_color)(menu_display_ctx_clearcolor_t *clearcolor, void (*clear_color)(menu_display_ctx_clearcolor_t *clearcolor,
video_frame_info_t *video_info); video_frame_info_t *video_info);
/* Get the default Model-View-Projection matrix */ /* Get the default Model-View-Projection matrix */
void *(*get_default_mvp)(void); void *(*get_default_mvp)(video_frame_info_t *video_info);
/* Get the default vertices matrix */ /* Get the default vertices matrix */
const float *(*get_default_vertices)(void); const float *(*get_default_vertices)(void);
/* Get the default texture coordinates matrix */ /* Get the default texture coordinates matrix */
@ -704,7 +704,8 @@ void menu_display_draw_texture_slice(
int x, int y, unsigned w, unsigned h, int x, int y, unsigned w, unsigned h,
unsigned new_w, unsigned new_h, unsigned width, unsigned height, unsigned new_w, unsigned new_h, unsigned width, unsigned height,
float *color, unsigned offset, float scale_factor, uintptr_t texture); float *color, unsigned offset, float scale_factor, uintptr_t texture);
void menu_display_rotate_z(menu_display_ctx_rotate_draw_t *draw); void menu_display_rotate_z(menu_display_ctx_rotate_draw_t *draw,
video_frame_info_t *video_info);
bool menu_display_get_tex_coords(menu_display_ctx_coord_draw_t *draw); bool menu_display_get_tex_coords(menu_display_ctx_coord_draw_t *draw);
void menu_display_timedate(menu_display_ctx_datetime_t *datetime); void menu_display_timedate(menu_display_ctx_datetime_t *datetime);