(Gfx display) scissor_begin/scissor_end - drop video_frame_info dependency

This commit is contained in:
twinaphex 2020-03-08 21:46:52 +01:00
parent 7efe1160e1
commit 7a9684b6ea
15 changed files with 130 additions and 126 deletions

View File

@ -269,10 +269,12 @@ static bool gfx_display_d3d10_font_init_first(
return true;
}
void gfx_display_d3d10_scissor_begin(video_frame_info_t *video_info, int x, int y, unsigned width, unsigned height)
void gfx_display_d3d10_scissor_begin(void *data,
unsigned video_width, unsigned video_height,
int x, int y, unsigned width, unsigned height)
{
D3D10_RECT rect;
d3d10_video_t *d3d10 = (d3d10_video_t*)video_info->userdata;
d3d10_video_t *d3d10 = (d3d10_video_t*)data;
if (!d3d10 || !width || !height)
return;
@ -285,12 +287,11 @@ void gfx_display_d3d10_scissor_begin(video_frame_info_t *video_info, int x, int
D3D10SetScissorRects(d3d10->device, 1, &rect);
}
void gfx_display_d3d10_scissor_end(video_frame_info_t *video_info)
void gfx_display_d3d10_scissor_end(void *data,
unsigned video_width, unsigned video_height)
{
D3D10_RECT rect;
d3d10_video_t *d3d10 = (d3d10_video_t*)video_info->userdata;
unsigned video_width = video_info->width;
unsigned video_height = video_info->height;
d3d10_video_t *d3d10 = (d3d10_video_t*)data;
if (!d3d10)
return;

View File

@ -268,10 +268,13 @@ static bool gfx_display_d3d11_font_init_first(
return true;
}
void gfx_display_d3d11_scissor_begin(video_frame_info_t *video_info, int x, int y, unsigned width, unsigned height)
void gfx_display_d3d11_scissor_begin(void *data,
unsigned video_width,
unsigned video_height,
int x, int y, unsigned width, unsigned height)
{
D3D11_RECT rect;
d3d11_video_t *d3d11 = (d3d11_video_t*)video_info->userdata;
d3d11_video_t *d3d11 = (d3d11_video_t*)data;
if (!d3d11 || !width || !height)
return;
@ -284,12 +287,12 @@ void gfx_display_d3d11_scissor_begin(video_frame_info_t *video_info, int x, int
D3D11SetScissorRects(d3d11->context, 1, &rect);
}
void gfx_display_d3d11_scissor_end(video_frame_info_t *video_info)
void gfx_display_d3d11_scissor_end(void *data,
unsigned video_width,
unsigned video_height)
{
D3D11_RECT rect;
d3d11_video_t *d3d11 = (d3d11_video_t*)video_info->userdata;
unsigned video_width = video_info->width;
unsigned video_height = video_info->height;
d3d11_video_t *d3d11 = (d3d11_video_t*)data;
if (!d3d11)
return;

View File

@ -289,10 +289,12 @@ static bool gfx_display_d3d12_font_init_first(
return true;
}
void gfx_display_d3d12_scissor_begin(video_frame_info_t *video_info, int x, int y, unsigned width, unsigned height)
void gfx_display_d3d12_scissor_begin(void *data,
unsigned video_width, unsigned video_height,
int x, int y, unsigned width, unsigned height)
{
D3D12_RECT rect;
d3d12_video_t *d3d12 = (d3d12_video_t*)video_info->userdata;
d3d12_video_t *d3d12 = (d3d12_video_t*)data;
if (!d3d12 || !width || !height)
return;
@ -305,12 +307,12 @@ void gfx_display_d3d12_scissor_begin(video_frame_info_t *video_info, int x, int
D3D12RSSetScissorRects(d3d12->queue.cmd, 1, &rect);
}
void gfx_display_d3d12_scissor_end(video_frame_info_t *video_info)
void gfx_display_d3d12_scissor_end(void *data,
unsigned video_width,
unsigned video_height)
{
D3D12_RECT rect;
d3d12_video_t *d3d12 = (d3d12_video_t*)video_info->userdata;
unsigned video_width = video_info->width;
unsigned video_height = video_info->height;
d3d12_video_t *d3d12 = (d3d12_video_t*)data;
if (!d3d12)
return;

View File

@ -303,11 +303,12 @@ static bool gfx_display_d3d9_font_init_first(
}
void gfx_display_d3d9_scissor_begin(
video_frame_info_t *video_info,
void *data,
unsigned video_width, unsigned video_height,
int x, int y, unsigned width, unsigned height)
{
RECT rect;
d3d9_video_t *d3d9 = (d3d9_video_t*)video_info->userdata;
d3d9_video_t *d3d9 = (d3d9_video_t*)data;
if (!d3d9 || !width || !height)
return;
@ -320,12 +321,11 @@ void gfx_display_d3d9_scissor_begin(
d3d9_set_scissor_rect(d3d9->dev, &rect);
}
void gfx_display_d3d9_scissor_end(video_frame_info_t *video_info)
void gfx_display_d3d9_scissor_end(void *data,
unsigned video_width, unsigned video_height)
{
RECT rect;
d3d9_video_t *d3d9 = (d3d9_video_t*)video_info->userdata;
unsigned video_width = video_info->width;
unsigned video_height = video_info->height;
d3d9_video_t *d3d9 = (d3d9_video_t*)data;
if (!d3d9)
return;

View File

@ -108,15 +108,11 @@ static void gfx_display_gdi_draw(gfx_display_ctx_draw_t *draw,
}
static void gfx_display_gdi_draw_pipeline(gfx_display_ctx_draw_t *draw,
video_frame_info_t *video_info)
{
}
video_frame_info_t *video_info) { }
static void gfx_display_gdi_viewport(gfx_display_ctx_draw_t *draw, void *data) { }
static void gfx_display_gdi_restore_clear_color(void)
{
}
static void gfx_display_gdi_restore_clear_color(void) { }
static void gfx_display_gdi_clear_color(
gfx_display_ctx_clearcolor_t *clearcolor,
@ -168,6 +164,6 @@ gfx_display_ctx_driver_t gfx_display_ctx_gdi = {
GFX_VIDEO_DRIVER_GDI,
"gdi",
false,
NULL,
NULL
NULL, /* scissor_begin */
NULL /* scissor_end */
};

View File

@ -367,10 +367,12 @@ static bool gfx_display_gl_font_init_first(
}
static void gfx_display_gl_scissor_begin(
video_frame_info_t *video_info, int x, int y,
void *data,
unsigned video_width,
unsigned video_height,
int x, int y,
unsigned width, unsigned height)
{
unsigned video_height = video_info->height;
glScissor(x, video_height - y - height, width, height);
glEnable(GL_SCISSOR_TEST);
#ifdef MALI_BUG
@ -386,10 +388,11 @@ static void gfx_display_gl_scissor_begin(
#endif
}
static void gfx_display_gl_scissor_end(video_frame_info_t *video_info)
static void gfx_display_gl_scissor_end(
void *data,
unsigned video_width,
unsigned video_height)
{
unsigned video_width = video_info->width;
unsigned video_height = video_info->height;
glScissor(0, 0, video_width, video_height);
glDisable(GL_SCISSOR_TEST);
#ifdef MALI_BUG

View File

@ -201,19 +201,21 @@ static bool gfx_display_gl1_font_init_first(
return true;
}
static void gfx_display_gl1_scissor_begin(video_frame_info_t *video_info, int x, int y,
static void gfx_display_gl1_scissor_begin(void *data,
unsigned video_width,
unsigned video_height,
int x, int y,
unsigned width, unsigned height)
{
unsigned video_width = video_info->width;
unsigned video_height = video_info->height;
glScissor(x, video_height - y - height, width, height);
glEnable(GL_SCISSOR_TEST);
}
static void gfx_display_gl1_scissor_end(video_frame_info_t *video_info)
static void gfx_display_gl1_scissor_end(
void *data,
unsigned video_width,
unsigned video_height)
{
unsigned video_width = video_info->width;
unsigned video_height = video_info->height;
glScissor(0, 0, video_width, video_height);
glDisable(GL_SCISSOR_TEST);
}

View File

@ -331,15 +331,19 @@ static bool gfx_display_gl_core_font_init_first(
return false;
}
static void gfx_display_gl_core_scissor_begin(video_frame_info_t *video_info,
static void gfx_display_gl_core_scissor_begin(void *data,
unsigned video_width,
unsigned video_height,
int x, int y, unsigned width, unsigned height)
{
unsigned video_height = video_info->height;
glScissor(x, video_height - y - height, width, height);
glEnable(GL_SCISSOR_TEST);
}
static void gfx_display_gl_core_scissor_end(video_frame_info_t *video_info)
static void gfx_display_gl_core_scissor_end(
void *data,
unsigned video_width,
unsigned video_height)
{
glDisable(GL_SCISSOR_TEST);
}

View File

@ -84,9 +84,13 @@ static void gfx_display_metal_draw_pipeline(gfx_display_ctx_draw_t *draw, video_
static void gfx_display_metal_viewport(gfx_display_ctx_draw_t *draw,
void *data) } { }
static void gfx_display_metal_scissor_begin(video_frame_info_t *video_info, int x, int y, unsigned width, unsigned height)
static void gfx_display_metal_scissor_begin(
void *data,
unsigned video_width,
unsigned video_height,
int x, int y, unsigned width, unsigned height)
{
MetalDriver *md = (__bridge MetalDriver *)video_info->userdata;
MetalDriver *md = (__bridge MetalDriver *)data;
if (!md)
return;
@ -94,22 +98,23 @@ static void gfx_display_metal_scissor_begin(video_frame_info_t *video_info, int
[md.display setScissorRect:r];
}
static void gfx_display_metal_scissor_end(video_frame_info_t *video_info)
static void gfx_display_metal_scissor_end(void *data,
unsigned video_width,
unsigned video_height)
{
MetalDriver *md = (__bridge MetalDriver *)video_info->userdata;
MetalDriver *md = (__bridge MetalDriver *)data;
if (!md)
return;
[md.display clearScissorRect];
}
static void gfx_display_metal_restore_clear_color(void)
{
/* nothing to do */
}
/* Nothing to do */
static void gfx_display_metal_restore_clear_color(void) { }
static void gfx_display_metal_clear_color(gfx_display_ctx_clearcolor_t *clearcolor,
video_frame_info_t *video_info)
static void gfx_display_metal_clear_color(
gfx_display_ctx_clearcolor_t *clearcolor,
video_frame_info_t *video_info)
{
MetalDriver *md = (__bridge MetalDriver *)video_info->userdata;
if (!md)
@ -125,9 +130,9 @@ static bool gfx_display_metal_font_init_first(
{
font_data_t **handle = (font_data_t **)font_handle;
*handle = font_driver_init_first(video_data,
font_path, font_size, true,
is_threaded,
FONT_DRIVER_RENDER_METAL_API);
font_path, font_size, true,
is_threaded,
FONT_DRIVER_RENDER_METAL_API);
if (*handle)
return true;

View File

@ -22,37 +22,18 @@
#include "../gfx_display.h"
static void *gfx_display_switch_get_default_mvp(void *data)
{
return NULL;
}
static void *gfx_display_switch_get_default_mvp(void *data) { return NULL; }
static void gfx_display_switch_blend_begin(void *data) { }
static void gfx_display_switch_blend_end(void *data) { }
static void gfx_display_switch_draw(gfx_display_ctx_draw_t *draw,
video_frame_info_t *video_info)
{
}
video_frame_info_t *video_info) { }
static void gfx_display_switch_draw_pipeline(
gfx_display_ctx_draw_t *draw, video_frame_info_t *video_info)
{
}
gfx_display_ctx_draw_t *draw, video_frame_info_t *video_info) { }
static void gfx_display_switch_viewport(gfx_display_ctx_draw_t *draw,
void *data) { }
static void gfx_display_switch_restore_clear_color(void) { }
static void gfx_display_switch_restore_clear_color(void)
{
}
static void gfx_display_switch_clear_color(
gfx_display_ctx_clearcolor_t *clearcolor,
video_frame_info_t *video_info)
{
(void)clearcolor;
}
static void gfx_display_switch_clear_color(gfx_display_ctx_clearcolor_t *clearcolor, video_frame_info_t *video_info) { }
static bool gfx_display_switch_font_init_first(
void **font_handle, void *video_data,
@ -94,6 +75,6 @@ gfx_display_ctx_driver_t gfx_display_ctx_switch = {
GFX_VIDEO_DRIVER_SWITCH,
"switch",
false,
NULL,
NULL
NULL, /* scissor_begin */
NULL /* scissor_end */
};

View File

@ -180,21 +180,27 @@ static bool gfx_display_vita2d_font_init_first(
return *handle;
}
static void gfx_display_vita2d_scissor_end(video_frame_info_t *video_info)
{
unsigned video_width = video_info->width;
unsigned video_height = video_info->height;
vita2d_set_region_clip(SCE_GXM_REGION_CLIP_NONE, 0, 0, video_width, video_height);
vita2d_disable_clipping();
}
static void gfx_display_vita2d_scissor_begin(video_frame_info_t *video_info, int x, int y,
static void gfx_display_vita2d_scissor_begin(void *data,
unsigned video_width,
unsigned video_height,
int x, int y,
unsigned width, unsigned height)
{
vita2d_set_clip_rectangle(x, y, x + width, y + height);
vita2d_set_region_clip(SCE_GXM_REGION_CLIP_OUTSIDE, x, y, x + width, y + height);
}
static void gfx_display_vita2d_scissor_end(
void *data,
unsigned video_width,
unsigned video_height)
{
vita2d_set_region_clip(SCE_GXM_REGION_CLIP_NONE, 0, 0,
video_width, video_height);
vita2d_disable_clipping();
}
gfx_display_ctx_driver_t gfx_display_ctx_vita2d = {
gfx_display_vita2d_draw,
gfx_display_vita2d_draw_pipeline,

View File

@ -357,10 +357,13 @@ static bool gfx_display_vk_font_init_first(
return false;
}
static void gfx_display_vk_scissor_begin(video_frame_info_t *video_info,
static void gfx_display_vk_scissor_begin(
void *data,
unsigned video_width,
unsigned video_height,
int x, int y, unsigned width, unsigned height)
{
vk_t *vk = (vk_t*)video_info->userdata;
vk_t *vk = (vk_t*)data;
vk->tracker.use_scissor = true;
vk->tracker.scissor.offset.x = x;
@ -370,9 +373,11 @@ static void gfx_display_vk_scissor_begin(video_frame_info_t *video_info,
vk->tracker.dirty |= VULKAN_DIRTY_DYNAMIC_BIT;
}
static void gfx_display_vk_scissor_end(video_frame_info_t *video_info)
static void gfx_display_vk_scissor_end(void *data,
unsigned video_width,
unsigned video_height)
{
vk_t *vk = (vk_t*)video_info->userdata;
vk_t *vk = (vk_t*)data;
vk->tracker.use_scissor = false;
vk->tracker.dirty |= VULKAN_DIRTY_DYNAMIC_BIT;

View File

@ -28,24 +28,11 @@
#include "../../wiiu/system/memory.h"
#include "../../wiiu/wiiu_dbg.h"
static const float *gfx_display_wiiu_get_default_vertices(void)
{
return NULL;
}
static const float *gfx_display_wiiu_get_default_tex_coords(void)
{
return NULL;
}
static void *gfx_display_wiiu_get_default_mvp(void *data)
{
return NULL;
}
static const float *gfx_display_wiiu_get_default_vertices(void) { return NULL; }
static const float *gfx_display_wiiu_get_default_tex_coords(void) { return NULL; }
static void *gfx_display_wiiu_get_default_mvp(void *data) { return NULL; }
static void gfx_display_wiiu_blend_begin(void *data) { }
static void gfx_display_wiiu_blend_end(void *data) { }
static void gfx_display_wiiu_viewport(gfx_display_ctx_draw_t *draw, void *data) { }
static void gfx_display_wiiu_draw(gfx_display_ctx_draw_t *draw,
@ -307,20 +294,21 @@ static bool gfx_display_wiiu_font_init_first(
}
static void gfx_display_wiiu_scissor_begin(
video_frame_info_t *video_info, int x, int y,
void *data,
unsigned video_width,
unsigned video_height,
int x, int y,
unsigned width, unsigned height)
{
unsigned video_width = video_info->width;
unsigned video_height = video_info->height;
GX2SetScissor(MAX(x, 0), MAX(video_height - y - height, 0), MIN(width, video_width), MIN(height, video_height));
}
static void gfx_display_wiiu_scissor_end(video_frame_info_t *video_info)
static void gfx_display_wiiu_scissor_end(
void *data,
unsigned video_width,
unsigned video_height
)
{
unsigned video_width = video_info->width;
unsigned video_height = video_info->height;
GX2SetScissor(0, 0, video_width, video_height);
}

View File

@ -650,6 +650,7 @@ void gfx_display_scissor_begin(video_frame_info_t *video_info,
{
unsigned video_width = video_info->width;
unsigned video_height = video_info->height;
void *userdata = video_info->userdata;
if (dispctx && dispctx->scissor_begin)
{
@ -684,7 +685,9 @@ void gfx_display_scissor_begin(video_frame_info_t *video_info,
if ((x + width) > video_width)
width = video_width - x;
dispctx->scissor_begin(video_info, x, y, width, height);
dispctx->scissor_begin(userdata,
video_width, video_height,
x, y, width, height);
}
}
@ -692,7 +695,9 @@ void gfx_display_scissor_begin(video_frame_info_t *video_info,
void gfx_display_scissor_end(video_frame_info_t *video_info)
{
if (dispctx && dispctx->scissor_end)
dispctx->scissor_end(video_info);
dispctx->scissor_end(video_info->userdata,
video_info->width,
video_info->height);
}
font_data_t *gfx_display_font_file(

View File

@ -134,8 +134,11 @@ typedef struct gfx_display_ctx_driver
const char *ident;
bool handles_transform;
/* Enables and disables scissoring */
void (*scissor_begin)(video_frame_info_t *video_info, int x, int y, unsigned width, unsigned height);
void (*scissor_end)(video_frame_info_t *video_info);
void (*scissor_begin)(void *data, unsigned video_width,
unsigned video_height,
int x, int y, unsigned width, unsigned height);
void (*scissor_end)(void *data, unsigned video_width,
unsigned video_height);
} gfx_display_ctx_driver_t;
struct gfx_display_ctx_draw