video: set_viewport takes the size word

The video_driver_t set_viewport slot and each driver's own viewport
setter take the size as one packed word; the GL, Vulkan, GDI, RSX, GXM
and Metal setters store it as the viewport's full size directly, and
d3d8's rect helper returns the fitted viewport's word. Metal's
setViewportDims: replaces the width/height selector.

The menu drivers, widgets and screensaver hand set_viewport the frame
info's size word as they receive it.
This commit is contained in:
LibretroAdmin authored and libretroadmin committed 2026-09-22 21:40:14 +02:00
1 parent 7d5b196aa3
commit b1e88d6f62
26 files changed
+141 -156

No files matched your search

+2 -2
View File
@@ -416,8 +416,8 @@ static const video_poke_interface_t caca_poke_interface = {
static void caca_get_poke_interface(void *data,
const video_poke_interface_t **iface) { *iface = &caca_poke_interface; }
static void caca_set_viewport(void *data, unsigned vp_width,
unsigned vp_height, bool force_full, bool allow_rotate) { }
static void caca_set_viewport(void *data, unsigned dims,
bool force_full, bool allow_rotate) { }
static font_renderer_t caca_font = {
caca_font_init,
+9 -13
View File
@@ -2143,7 +2143,7 @@ static bool d3d8_init_base(void *data, const video_info_t *info)
}
static void d3d8_calculate_rect(void *data,
unsigned *width, unsigned *height,
unsigned *dims,
int *x, int *y,
bool force_full,
bool allow_rotate)
@@ -2151,20 +2151,16 @@ static void d3d8_calculate_rect(void *data,
struct video_viewport vp;
d3d8_video_t *d3d = (d3d8_video_t*)data;
*width = VIDEO_SCALE_W(d3d->vp.full_dims);
*height = VIDEO_SCALE_H(d3d->vp.full_dims);
vp.full_dims = VIDEO_SCALE_PACK(*width, *height);
vp.full_dims = d3d->vp.full_dims;
video_driver_update_viewport(&vp, force_full, d3d->keep_aspect, true);
*x = VIDEO_POS_X(vp.pos);
*y = VIDEO_POS_Y(vp.pos);
*width = VIDEO_SCALE_W(vp.dims);
*height = VIDEO_SCALE_H(vp.dims);
*dims = vp.dims;
}
static void d3d8_set_viewport(void *data,
unsigned width, unsigned height,
unsigned dims,
bool force_full,
bool allow_rotate)
{
@@ -2177,7 +2173,7 @@ static void d3d8_set_viewport(void *data,
2, 0, 0,-1, 0, 2, 0,-1, 0, 0, 1, 0, 0, 0, 0, 1
}};
d3d8_calculate_rect(data, &width, &height, &x, &y,
d3d8_calculate_rect(data, &dims, &x, &y,
force_full, allow_rotate);
/* D3D doesn't support negative X/Y viewports ... */
@@ -2188,8 +2184,8 @@ static void d3d8_set_viewport(void *data,
d3d->out_vp.X = x;
d3d->out_vp.Y = y;
d3d->out_vp.Width = width;
d3d->out_vp.Height = height;
d3d->out_vp.Width = VIDEO_SCALE_W(dims);
d3d->out_vp.Height = VIDEO_SCALE_H(dims);
d3d->out_vp.MinZ = 0.0f;
d3d->out_vp.MaxZ = 0.0f;
@@ -2265,7 +2261,7 @@ static bool d3d8_initialize(d3d8_video_t *d3d, const video_info_t *info)
/* d3d->vp.full_* was written by the caller (d3d8_init_internal
* has already called set_size at this point). */
d3d8_set_viewport(d3d,
VIDEO_SCALE_W(d3d->vp.full_dims), VIDEO_SCALE_H(d3d->vp.full_dims), false, true);
d3d->vp.full_dims, false, true);
d3d->menu_display.offset = 0;
@@ -2836,7 +2832,7 @@ static bool d3d8_frame(void *data, const void *frame,
if (d3d->should_resize)
{
d3d8_set_viewport(d3d, width, height, false, true);
d3d8_set_viewport(d3d, VIDEO_SCALE_PACK(width, height), false, true);
d3d->should_resize = false;
}
+8 -13
View File
@@ -3664,7 +3664,7 @@ static void d3d9_cg_set_osd_msg(void *data,
}
static void d3d9_cg_set_viewport(void *data,
unsigned width, unsigned height,
unsigned dims,
bool force_full,
bool allow_rotate)
{
@@ -3675,18 +3675,13 @@ static void d3d9_cg_set_viewport(void *data,
int y = 0;
struct video_viewport vp;
/* Width/height parameters are intentionally overwritten here:
* the caller's values are not used (pre-existing behaviour). */
width = VIDEO_SCALE_W(d3d->vp.full_dims);
height = VIDEO_SCALE_H(d3d->vp.full_dims);
vp.full_dims = VIDEO_SCALE_PACK(width, height);
/* The viewport is fitted to the driver's own full size; the
* caller's size word is not used. */
vp.full_dims = d3d->vp.full_dims;
video_driver_update_viewport(&vp, force_full, d3d->keep_aspect, true);
x = VIDEO_POS_X(vp.pos);
y = VIDEO_POS_Y(vp.pos);
width = VIDEO_SCALE_W(vp.dims);
height = VIDEO_SCALE_H(vp.dims);
/* D3D doesn't support negative X/Y viewports ... */
if (x < 0)
@@ -3715,8 +3710,8 @@ static void d3d9_cg_set_viewport(void *data,
d3d->out_vp.X = x;
d3d->out_vp.Y = y;
d3d->out_vp.Width = width;
d3d->out_vp.Height = height;
d3d->out_vp.Width = VIDEO_SCALE_W(vp.dims);
d3d->out_vp.Height = VIDEO_SCALE_H(vp.dims);
d3d->out_vp.MinZ = 0.0f;
d3d->out_vp.MaxZ = 1.0f;
@@ -3761,7 +3756,7 @@ static bool d3d9_cg_initialize(d3d9_video_t *d3d, const video_info_t *info)
/* d3d->vp.full_* was written by the caller (d3d9_cg_init_internal
* has already called set_size at this point). */
d3d9_cg_set_viewport(d3d,
VIDEO_SCALE_W(d3d->vp.full_dims), VIDEO_SCALE_H(d3d->vp.full_dims), false, true);
d3d->vp.full_dims, false, true);
{
@@ -4485,7 +4480,7 @@ static bool d3d9_cg_frame(void *data, const void *frame,
cg_renderchain_t *_chain = (cg_renderchain_t*)
d3d->renderchain_data;
d3d9_cg_renderchain_t *chain = (d3d9_cg_renderchain_t*)&_chain->chain;
d3d9_cg_set_viewport(d3d, width, height, false, true);
d3d9_cg_set_viewport(d3d, VIDEO_SCALE_PACK(width, height), false, true);
if (chain)
chain->out_vp = (D3DVIEWPORT9*)&d3d->out_vp;
+8 -13
View File
@@ -6986,7 +6986,7 @@ static void d3d9_set_font_rect(
}
static void d3d9_hlsl_set_viewport(void *data,
unsigned width, unsigned height,
unsigned dims,
bool force_full,
bool allow_rotate)
{
@@ -6997,18 +6997,13 @@ static void d3d9_hlsl_set_viewport(void *data,
int y = 0;
struct video_viewport vp;
/* Width/height parameters are intentionally overwritten here:
* the caller's values are not used (pre-existing behaviour). */
width = VIDEO_SCALE_W(d3d->vp.full_dims);
height = VIDEO_SCALE_H(d3d->vp.full_dims);
vp.full_dims = VIDEO_SCALE_PACK(width, height);
/* The viewport is fitted to the driver's own full size; the
* caller's size word is not used. */
vp.full_dims = d3d->vp.full_dims;
video_driver_update_viewport(&vp, force_full, d3d->keep_aspect, true);
x = VIDEO_POS_X(vp.pos);
y = VIDEO_POS_Y(vp.pos);
width = VIDEO_SCALE_W(vp.dims);
height = VIDEO_SCALE_H(vp.dims);
/* D3D doesn't support negative X/Y viewports ... */
if (x < 0)
@@ -7037,8 +7032,8 @@ static void d3d9_hlsl_set_viewport(void *data,
d3d->out_vp.X = x;
d3d->out_vp.Y = y;
d3d->out_vp.Width = width;
d3d->out_vp.Height = height;
d3d->out_vp.Width = VIDEO_SCALE_W(vp.dims);
d3d->out_vp.Height = VIDEO_SCALE_H(vp.dims);
d3d->out_vp.MinZ = 0.0f;
d3d->out_vp.MaxZ = 1.0f;
@@ -7098,7 +7093,7 @@ static bool d3d9_hlsl_initialize(
/* d3d->vp.full_* was written by the caller (d3d9_hlsl_init_internal
* has already called set_size at this point). */
d3d9_hlsl_set_viewport(d3d,
VIDEO_SCALE_W(d3d->vp.full_dims), VIDEO_SCALE_H(d3d->vp.full_dims), false, true);
d3d->vp.full_dims, false, true);
{
@@ -7794,7 +7789,7 @@ static bool d3d9_hlsl_frame(void *data, const void *frame,
hlsl_renderchain_t *_chain = (hlsl_renderchain_t*)d3d->renderchain_data;
d3d9_hlsl_renderchain_t *chain = (d3d9_hlsl_renderchain_t*)&_chain->chain;
d3d9_hlsl_set_viewport(d3d, width, height, false, true);
d3d9_hlsl_set_viewport(d3d, VIDEO_SCALE_PACK(width, height), false, true);
if (chain)
chain->out_vp = (D3DVIEWPORT9*)&d3d->out_vp;
+2 -2
View File
@@ -386,8 +386,8 @@ static void fpga_get_poke_interface(void *data,
}
/* TODO/FIXME - implement */
static void fpga_set_viewport(void *data, unsigned vp_width,
unsigned vp_height, bool force_full, bool allow_rotate) { }
static void fpga_set_viewport(void *data, unsigned dims,
bool force_full, bool allow_rotate) { }
video_driver_t video_fpga = {
fpga_init,
+4 -4
View File
@@ -117,7 +117,7 @@ static bool gdi_ensure_menu_surface(gdi_t *gdi,
static void gdi_release_menu_surface(gdi_t *gdi);
/* Defined alongside the vtable near the bottom of the file, but
* gdi_frame calls it through the should_resize path. */
static void gdi_set_viewport(void *data, unsigned vp_width, unsigned vp_height,
static void gdi_set_viewport(void *data, unsigned dims,
bool force_full, bool allow_rotate);
#ifdef HAVE_OVERLAY
/* Overlay impl lives near the bottom alongside the vtable; gdi_frame
@@ -2648,7 +2648,7 @@ static bool gdi_frame(void *data, const void *frame,
* pillarbox bars. Mirrors d3d8's should_resize pattern. */
if (gdi->should_resize)
{
gdi_set_viewport(gdi, surface_width, surface_height, false, true);
gdi_set_viewport(gdi, VIDEO_SCALE_PACK(surface_width, surface_height), false, true);
gdi->should_resize = false;
}
/* Defensive: if vp was never populated (e.g. should_resize
@@ -3459,14 +3459,14 @@ static void gdi_get_poke_interface(void *data,
* set, mirroring d3d8 / d3d9 timing. vp.full_width/full_height
* must already hold the current window size (the caller refreshes
* those via gfx_ctx_gdi_get_video_size first). */
static void gdi_set_viewport(void *data, unsigned vp_width, unsigned vp_height,
static void gdi_set_viewport(void *data, unsigned dims,
bool force_full, bool allow_rotate)
{
gdi_t *gdi = (gdi_t*)data;
if (!gdi)
return;
gdi->vp.full_dims = VIDEO_SCALE_PACK(vp_width, vp_height);
gdi->vp.full_dims = dims;
video_driver_update_viewport(&gdi->vp, force_full, gdi->keep_aspect, true);
}
+10 -10
View File
@@ -438,7 +438,7 @@ static const GLfloat gl1_white_color[16] = {
* FORWARD DECLARATIONS
*/
static void gl1_set_viewport(gl1_t *gl1,
unsigned vp_width, unsigned vp_height,
unsigned dims,
bool force_full, bool allow_rotate);
/**
@@ -963,7 +963,7 @@ static void gl1_raster_font_setup_viewport(
unsigned width, unsigned height,
gl1_raster_t *font, bool full_screen)
{
gl1_set_viewport(gl, width, height, full_screen, false);
gl1_set_viewport(gl, VIDEO_SCALE_PACK(width, height), full_screen, false);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D);
@@ -1097,7 +1097,7 @@ static void gl1_raster_font_render_msg(
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
glDisable(GL_BLEND);
gl1_set_viewport(gl, width, height, false, true);
gl1_set_viewport(gl, VIDEO_SCALE_PACK(width, height), false, true);
}
}
}
@@ -1129,7 +1129,7 @@ static void gl1_raster_font_flush_block(unsigned width, unsigned height,
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
glDisable(GL_BLEND);
gl1_set_viewport(gl, width, height, block->fullscreen, true);
gl1_set_viewport(gl, VIDEO_SCALE_PACK(width, height), block->fullscreen, true);
}
static void gl1_raster_font_bind_block(void *data, void *userdata)
@@ -1589,10 +1589,10 @@ static void gl1_set_projection(gl1_t *gl1,
}
static void gl1_set_viewport(gl1_t *gl1,
unsigned vp_width, unsigned vp_height,
unsigned dims,
bool force_full, bool allow_rotate)
{
gl1->vp.full_dims = VIDEO_SCALE_PACK(vp_width, vp_height);
gl1->vp.full_dims = dims;
video_driver_update_viewport(&gl1->vp, force_full,
(gl1->flags & GL1_FLAG_KEEP_ASPECT) ? true : false, false);
@@ -2252,7 +2252,7 @@ static bool gl1_frame(void *data, const void *frame,
gl1->ctx_driver->set_resize(gl1->ctx_data, width, height);
gl1_set_viewport(gl1,
video_width, video_height, false, true);
video_info->dims, false, true);
}
#ifndef VITA
@@ -3221,11 +3221,11 @@ static void gl1_get_poke_interface(void *data,
static bool gl1_widgets_enabled(void *data) { return true; }
#endif
static void gl1_set_viewport_wrapper(void *data, unsigned vp_width,
unsigned vp_height, bool force_full, bool allow_rotate)
static void gl1_set_viewport_wrapper(void *data, unsigned dims,
bool force_full, bool allow_rotate)
{
gl1_t *gl1 = (gl1_t*)data;
gl1_set_viewport(gl1, vp_width, vp_height, force_full, allow_rotate);
gl1_set_viewport(gl1, dims, force_full, allow_rotate);
}
#ifdef HAVE_OVERLAY
+15 -17
View File
@@ -483,7 +483,7 @@ static const GLfloat white_color[16] = {
* FORWARD DECLARATIONS
*/
static void gl2_set_viewport(gl2_t *gl,
unsigned vp_width, unsigned vp_height,
unsigned dims,
bool force_full, bool allow_rotate);
#if TARGET_OS_IPHONE
@@ -1155,7 +1155,7 @@ static void gl2_raster_font_setup_viewport(
bool full_screen,
bool video_scale_integer)
{
gl2_set_viewport(gl, width, height, full_screen, true);
gl2_set_viewport(gl, VIDEO_SCALE_PACK(width, height), full_screen, true);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -1277,7 +1277,7 @@ static void gl2_raster_font_render_msg(
/* Restore viewport */
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
glDisable(GL_BLEND);
gl2_set_viewport(gl, width, height, false, true);
gl2_set_viewport(gl, VIDEO_SCALE_PACK(width, height), false, true);
}
}
@@ -1309,7 +1309,7 @@ static void gl2_raster_font_flush_block(unsigned width, unsigned height,
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
glDisable(GL_BLEND);
gl2_set_viewport(gl, width, height, block->fullscreen, true);
gl2_set_viewport(gl, VIDEO_SCALE_PACK(width, height), block->fullscreen, true);
}
static void gl2_raster_font_bind_block(void *data, void *userdata)
@@ -1520,11 +1520,10 @@ static void gl2_set_projection(gl2_t *gl,
}
static void gl2_set_viewport(gl2_t *gl,
unsigned vp_width,
unsigned vp_height,
unsigned dims,
bool force_full, bool allow_rotate)
{
gl->vp.full_dims = VIDEO_SCALE_PACK(vp_width, vp_height);
gl->vp.full_dims = dims;
video_driver_update_viewport(&gl->vp, force_full,
(gl->flags & GL2_FLAG_KEEP_ASPECT) ? true : false, false);
@@ -1602,7 +1601,7 @@ static void gl2_renderchain_render(
/* Render to FBO with certain size. */
gl2_set_viewport(gl,
rect->img_width, rect->img_height, true, false);
VIDEO_SCALE_PACK(rect->img_width, rect->img_height), true, false);
params.vp_dims = VIDEO_SCALE_PACK(
gl->out_vp_width, gl->out_vp_height);
@@ -1677,7 +1676,7 @@ static void gl2_renderchain_render(
glGenerateMipmap(GL_TEXTURE_2D);
glClear(GL_COLOR_BUFFER_BIT);
gl2_set_viewport(gl, width, height, false, true);
gl2_set_viewport(gl, VIDEO_SCALE_PACK(width, height), false, true);
params.vp_dims = VIDEO_SCALE_PACK(gl->out_vp_width, gl->out_vp_height);
params.dims = VIDEO_SCALE_PACK(
@@ -2105,8 +2104,7 @@ static void gl2_renderchain_start_render(gl2_t *gl,
gl2_bind_fb(chain->fbo[0]);
gl2_set_viewport(gl,
gl->fbo_rect[0].img_width,
gl->fbo_rect[0].img_height, true, false);
VIDEO_SCALE_PACK(gl->fbo_rect[0].img_width, gl->fbo_rect[0].img_height), true, false);
/* Need to preserve the "flipped" state when in FBO
* as well to have consistent texture coordinates.
@@ -3083,11 +3081,11 @@ static void gl2_render_overlay(gl2_t *gl)
}
#endif
static void gl2_set_viewport_wrapper(void *data, unsigned vp_width,
unsigned vp_height, bool force_full, bool allow_rotate)
static void gl2_set_viewport_wrapper(void *data, unsigned dims,
bool force_full, bool allow_rotate)
{
gl2_t *gl = (gl2_t*)data;
gl2_set_viewport(gl, vp_width, vp_height, force_full, allow_rotate);
gl2_set_viewport(gl, dims, force_full, allow_rotate);
}
/* Shaders */
@@ -3660,7 +3658,7 @@ static INLINE void gl2_set_shader_viewports(gl2_t *gl, bool video_scale_integer)
for (i = 0; i < 2; i++)
{
gl->shader->use(gl, gl->shader_data, i, true);
gl2_set_viewport(gl, width, height, false, true);
gl2_set_viewport(gl, VIDEO_SCALE_PACK(width, height), false, true);
}
}
@@ -4448,7 +4446,7 @@ static bool gl2_frame(void *data, const void *frame,
gl2_renderchain_start_render(gl, chain, video_scale_integer);
}
else
gl2_set_viewport(gl, width, height, false, true);
gl2_set_viewport(gl, VIDEO_SCALE_PACK(width, height), false, true);
}
if (frame)
@@ -4493,7 +4491,7 @@ static bool gl2_frame(void *data, const void *frame,
gl2_bind_fb(gl2_frame_target_fbo(gl));
else
gl2_renderchain_bind_backbuffer();
gl2_set_viewport(gl, width, height, false, true);
gl2_set_viewport(gl, VIDEO_SCALE_PACK(width, height), false, true);
}
gl2_renderchain_restore_default_state(gl);
+14 -16
View File
@@ -302,7 +302,7 @@ static const float gl3_colors[16] = {
* FORWARD DECLARATIONS
*/
static void gl3_set_viewport(gl3_t *gl,
unsigned vp_width, unsigned vp_height,
unsigned dims,
bool force_full, bool allow_rotate);
/**
@@ -1500,7 +1500,7 @@ static void gl3_raster_font_setup_viewport(
unsigned width, unsigned height,
gl3_raster_t *font, bool full_screen)
{
gl3_set_viewport(gl, width, height, full_screen, false);
gl3_set_viewport(gl, VIDEO_SCALE_PACK(width, height), full_screen, false);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -1623,7 +1623,7 @@ static void gl3_raster_font_render_msg(
if (!font->block)
{
glDisable(GL_BLEND);
gl3_set_viewport(gl, width, height, false, true);
gl3_set_viewport(gl, VIDEO_SCALE_PACK(width, height), false, true);
}
}
@@ -1650,7 +1650,7 @@ static void gl3_raster_font_flush_block(unsigned width, unsigned height,
gl3_raster_font_draw_vertices(gl, font, (video_coords_t*)&block->carr.coords);
glDisable(GL_BLEND);
gl3_set_viewport(gl, width, height, block->fullscreen, true);
gl3_set_viewport(gl, VIDEO_SCALE_PACK(width, height), block->fullscreen, true);
}
static void gl3_raster_font_bind_block(void *data, void *userdata)
@@ -2381,10 +2381,10 @@ static void gl3_set_projection(gl3_t *gl,
}
static void gl3_set_viewport(gl3_t *gl,
unsigned vp_width, unsigned vp_height,
unsigned dims,
bool force_full, bool allow_rotate)
{
gl->vp.full_dims = VIDEO_SCALE_PACK(vp_width, vp_height);
gl->vp.full_dims = dims;
video_driver_update_viewport(&gl->vp, force_full,
(gl->flags & GL3_FLAG_KEEP_ASPECT) ? true : false, false);
@@ -3247,11 +3247,11 @@ static void gl3_begin_debug(gl3_t *gl)
#endif
static void gl3_set_viewport_wrapper(void *data,
unsigned vp_width, unsigned vp_height,
unsigned dims,
bool force_full, bool allow_rotate)
{
gl3_t *gl = (gl3_t*)data;
gl3_set_viewport(gl, vp_width, vp_height,
gl3_set_viewport(gl, dims,
force_full, allow_rotate);
}
@@ -3443,8 +3443,7 @@ static void *gl3_init(const video_info_t *video,
/* Set the viewport to fix recording, since it needs to know
* the viewport sizes before we start running. */
gl3_set_viewport_wrapper(gl, VIDEO_SCALE_W(temp_dims),
VIDEO_SCALE_H(temp_dims), false, true);
gl3_set_viewport_wrapper(gl, temp_dims, false, true);
if (gl->ctx_driver->input_driver)
{
@@ -4529,8 +4528,7 @@ static void gl3_renderchain_start_render(
glBindFramebuffer(GL_FRAMEBUFFER, gl->chain.fbo[0]);
gl3_set_viewport(gl,
gl->chain.fbo_rect[0].img_width,
gl->chain.fbo_rect[0].img_height, true, false);
VIDEO_SCALE_PACK(gl->chain.fbo_rect[0].img_width, gl->chain.fbo_rect[0].img_height), true, false);
/* Need to preserve the "flipped" state when in FBO
* as well to have consistent texture coordinates.
@@ -4605,7 +4603,7 @@ static void gl3_renderchain_render(
glClear(GL_COLOR_BUFFER_BIT);
/* Render to FBO with certain size. */
gl3_set_viewport(gl, rect->img_width, rect->img_height, true, false);
gl3_set_viewport(gl, VIDEO_SCALE_PACK(rect->img_width, rect->img_height), true, false);
params.vp_dims = VIDEO_SCALE_PACK(
gl->out_vp_width, gl->out_vp_height);
@@ -4674,7 +4672,7 @@ static void gl3_renderchain_render(
glGenerateMipmap(GL_TEXTURE_2D);
glClear(GL_COLOR_BUFFER_BIT);
gl3_set_viewport(gl, width, height, false, true);
gl3_set_viewport(gl, VIDEO_SCALE_PACK(width, height), false, true);
params.vp_dims = VIDEO_SCALE_PACK(gl->out_vp_width, gl->out_vp_height);
params.dims = VIDEO_SCALE_PACK(
@@ -4930,7 +4928,7 @@ static bool gl3_frame(void *data, const void *frame,
gl3_renderchain_start_render(gl);
}
else
gl3_set_viewport(gl, width, height, false, true);
gl3_set_viewport(gl, VIDEO_SCALE_PACK(width, height), false, true);
}
/* Can be NULL for frame dupe / NULL render. */
@@ -5002,7 +5000,7 @@ static bool gl3_frame(void *data, const void *frame,
{
glBindFramebuffer(GL_FRAMEBUFFER,
gl3_frame_target_fbo(gl, width, height));
gl3_set_viewport(gl, width, height, false, true);
gl3_set_viewport(gl, VIDEO_SCALE_PACK(width, height), false, true);
}
glDisable(GL_DEPTH_TEST);
+5 -5
View File
@@ -1869,13 +1869,13 @@ static void gxm_font_render_message(
}
}
static void gxm_set_viewport_wrapper(void *data, unsigned vp_width,
unsigned vp_height, bool force_full, bool allow_rotate)
static void gxm_set_viewport_wrapper(void *data, unsigned dims,
bool force_full, bool allow_rotate)
{
struct video_ortho ortho = {0, 1, 0, 1, -1, 1};
vita_video_t *vita = (vita_video_t*)data;
vita->vp.full_dims = VIDEO_SCALE_PACK(vp_width, vp_height);
vita->vp.full_dims = dims;
video_driver_update_viewport(&vita->vp, force_full,
vita->keep_aspect, true);
@@ -1946,7 +1946,7 @@ static void gxm_font_render_msg(
drop_alpha = 1.0f;
}
gxm_set_viewport_wrapper(vita, width, height, full_screen, false);
gxm_set_viewport_wrapper(vita, VIDEO_SCALE_PACK(width, height), full_screen, false);
if (drop_x || drop_y)
{
@@ -2039,7 +2039,7 @@ static void *gxm_gfx_init(const video_info_t *video,
vita->video_height = temp_height;
video_driver_set_output_dims(VIDEO_SCALE_PACK(temp_width, temp_height));
gxm_set_viewport_wrapper(vita, temp_width, temp_height, false, true);
gxm_set_viewport_wrapper(vita, VIDEO_SCALE_PACK(temp_width, temp_height), false, true);
if (input && input_data)
{
+2 -2
View File
@@ -1003,9 +1003,9 @@ static bool hub75_has_windowed(void *data) { (void)data; return false; }
static bool hub75_set_shader(void *data, enum rarch_shader_type type,
const char *path)
{ (void)data; (void)type; (void)path; return false; }
static void hub75_set_viewport(void *data, unsigned width, unsigned height,
static void hub75_set_viewport(void *data, unsigned dims,
bool force_full, bool allow_rotate)
{ (void)data; (void)width; (void)height; (void)force_full; (void)allow_rotate; }
{ (void)data; (void)dims; (void)force_full; (void)allow_rotate; }
static void hub75_set_rotation(void *data, unsigned rotation)
{
+15 -10
View File
@@ -250,7 +250,7 @@ typedef NS_ENUM(NSUInteger, ViewportResetMode) {
/* (Re)allocate HDR-mode offscreen textures (readback landing pad and
* SDR UI overlay) to match a new drawable size. Called from
* setViewportWidth:height: on window resize; cheap no-op when the
* setViewportDims: on window resize; cheap no-op when the
* current allocations already match. */
- (void)resizeHDRResourcesForWidth:(NSUInteger)w height:(NSUInteger)h;
@@ -455,7 +455,7 @@ typedef NS_ENUM(NSInteger, ViewDrawState)
/*! @brief setNeedsResize triggers a display resize */
- (void)setNeedsResize;
- (void)setViewportWidth:(unsigned)width height:(unsigned)height forceFull:(BOOL)forceFull allowRotate:(BOOL)allowRotate;
- (void)setViewportDims:(unsigned)dims forceFull:(BOOL)forceFull allowRotate:(BOOL)allowRotate;
- (void)setRotation:(unsigned)rotation;
/*! @brief applyVideoMode sizes the window, or takes it full screen, on
* the main thread; a zero axis means the view's current size. Returns
@@ -4605,11 +4605,11 @@ static void metal_pull_cached_frame_cb(void *userdata,
return YES;
}
- (void)setViewportWidth:(unsigned)width height:(unsigned)height forceFull:(BOOL)forceFull allowRotate:(BOOL)allowRotate
- (void)setViewportDims:(unsigned)dims forceFull:(BOOL)forceFull allowRotate:(BOOL)allowRotate
{
_viewport->full_dims = VIDEO_SCALE_PACK(width, height);
_viewport->full_dims = dims;
video_driver_set_output_dims(_viewport->full_dims);
_layer.drawableSize = CGSizeMake(width, height);
_layer.drawableSize = CGSizeMake(VIDEO_SCALE_W(dims), VIDEO_SCALE_H(dims));
video_driver_update_viewport(_viewport, forceFull, _keepAspect, YES);
_context.viewport = _viewport; /* Update matrix */
_viewportMVP.outputSize = simd_make_float2(VIDEO_SCALE_W(_viewport->full_dims), VIDEO_SCALE_H(_viewport->full_dims));
@@ -4618,7 +4618,8 @@ static void metal_pull_cached_frame_cb(void *userdata,
/* Keep the HDR offscreens matched to the drawable size on resize.
* Cheap no-op when already the right size. */
if (_context.hdrEnabled)
[_context resizeHDRResourcesForWidth:width height:height];
[_context resizeHDRResourcesForWidth:VIDEO_SCALE_W(dims)
height:VIDEO_SCALE_H(dims)];
#endif
}
@@ -4841,9 +4842,13 @@ static void metal_pull_cached_frame_cb(void *userdata,
{
#ifdef HAVE_COCOATOUCH
CGFloat scale = [[UIScreen mainScreen] scale];
[self setViewportWidth:(unsigned int)view.bounds.size.width*scale height:(unsigned int)view.bounds.size.height*scale forceFull:NO allowRotate:YES];
[self setViewportDims:VIDEO_SCALE_PACK(
(unsigned)((unsigned int)view.bounds.size.width * scale),
(unsigned)((unsigned int)view.bounds.size.height * scale))
forceFull:NO allowRotate:YES];
#else
[self setViewportWidth:(unsigned int)size.width height:(unsigned int)size.height forceFull:NO allowRotate:YES];
[self setViewportDims:VIDEO_SCALE_PACK((unsigned int)size.width,
(unsigned int)size.height) forceFull:NO allowRotate:YES];
#endif
}
@@ -6583,12 +6588,12 @@ static void metal_free(void *data)
}
}
static void metal_set_viewport(void *data, unsigned vp_width, unsigned vp_height,
static void metal_set_viewport(void *data, unsigned dims,
bool force_full, bool allow_rotate)
{
MetalDriver *md = (__bridge MetalDriver *)data;
if (md)
[md setViewportWidth:vp_width height:vp_height forceFull:force_full allowRotate:allow_rotate];
[md setViewportDims:dims forceFull:force_full allowRotate:allow_rotate];
}
static void metal_set_rotation(void *data, unsigned rotation)
+2 -2
View File
@@ -477,8 +477,8 @@ static void network_gfx_get_poke_interface(void *data,
*iface = &network_poke_interface;
}
static void network_gfx_set_viewport(void *data, unsigned vp_width,
unsigned vp_height, bool force_full, bool allow_rotate) { }
static void network_gfx_set_viewport(void *data, unsigned dims,
bool force_full, bool allow_rotate) { }
bool network_has_menu_frame(void)
{
+9 -9
View File
@@ -302,8 +302,8 @@ static const float rsx_tex_coords[8] = {
* FORWARD DECLARATIONS
*/
static void rsx_set_viewport(void *data, unsigned vp_width,
unsigned vp_height, bool force_full, bool allow_rotate);
static void rsx_set_viewport(void *data, unsigned dims,
bool force_full, bool allow_rotate);
/*
* DISPLAY DRIVER
@@ -909,7 +909,7 @@ static void rsx_font_setup_viewport(
unsigned width, unsigned height,
bool full_screen)
{
rsx_set_viewport(rsx, width, height, full_screen, false);
rsx_set_viewport(rsx, VIDEO_SCALE_PACK(width, height), full_screen, false);
rsxSetBlendEnable(rsx->context, GCM_TRUE);
rsxSetBlendFunc(rsx->context, GCM_SRC_ALPHA,
@@ -1021,7 +1021,7 @@ static void rsx_font_render_msg(
rsxTextureControl(rsx->context, font->tex_unit->index,
GCM_TRUE, 0 << 8, 12 << 8, GCM_TEXTURE_MAX_ANISO_1);
rsxSetBlendEnable(rsx->context, GCM_FALSE);
rsx_set_viewport(rsx, width, height, false, true);
rsx_set_viewport(rsx, VIDEO_SCALE_PACK(width, height), false, true);
}
rsx->font_vert_idx = 0;
}
@@ -1052,7 +1052,7 @@ static void rsx_font_flush_block(unsigned width, unsigned height,
rsxTextureControl(rsx->context, font->tex_unit->index,
GCM_TRUE, 0 << 8, 12 << 8, GCM_TEXTURE_MAX_ANISO_1);
rsxSetBlendEnable(rsx->context, GCM_FALSE);
rsx_set_viewport(rsx, width, height, block->fullscreen, true);
rsx_set_viewport(rsx, VIDEO_SCALE_PACK(width, height), block->fullscreen, true);
font->rsx->font_vert_idx = 0;
}
@@ -1172,7 +1172,7 @@ static void rsx_set_projection(rsx_t *rsx,
matrix_4x4_multiply(rsx->mvp, rot, rsx->mvp_no_rot);
}
static void rsx_set_viewport(void *data, unsigned vp_width, unsigned vp_height,
static void rsx_set_viewport(void *data, unsigned dims,
bool force_full, bool allow_rotate)
{
int i;
@@ -1180,7 +1180,7 @@ static void rsx_set_viewport(void *data, unsigned vp_width, unsigned vp_height,
struct video_ortho ortho = {0, 1, 0, 1, -1, 1};
rsx_t *rsx = (rsx_t*)data;
rsx->vp.full_dims = VIDEO_SCALE_PACK(vp_width, vp_height);
rsx->vp.full_dims = dims;
video_driver_update_viewport(&rsx->vp, force_full, rsx->keep_aspect, true);
vp.min = 0.0f;
@@ -1581,7 +1581,7 @@ static void* rsx_init(const video_info_t* video,
rsx->vp.full_dims = VIDEO_SCALE_PACK(rsx->width, rsx->height);
rsx->rgb32 = video->rgb32;
video_driver_set_output_dims(rsx->vp.dims);
rsx_set_viewport(rsx, VIDEO_SCALE_W(rsx->vp.dims), VIDEO_SCALE_H(rsx->vp.dims), false, true);
rsx_set_viewport(rsx, rsx->vp.dims, false, true);
if (input && input_data)
{
@@ -2226,7 +2226,7 @@ static void rsx_render_overlay(void *data)
rsx_t *rsx = (rsx_t *)data;
rsx_set_viewport(rsx, rsx->width, rsx->height, true, true);
rsx_set_viewport(rsx, VIDEO_SCALE_PACK(rsx->width, rsx->height), true, true);
for (i = 0; i < rsx->overlays; i++)
{
+2 -2
View File
@@ -618,8 +618,8 @@ static void sixel_gfx_get_poke_interface(void *data,
*iface = &sixel_poke_interface;
}
static void sixel_gfx_set_viewport(void *data, unsigned vp_width,
unsigned vp_height, bool force_full, bool allow_rotate) { }
static void sixel_gfx_set_viewport(void *data, unsigned dims,
bool force_full, bool allow_rotate) { }
bool sixel_has_menu_frame(void)
{
+2 -2
View File
@@ -479,8 +479,8 @@ static const video_poke_interface_t vga_poke_interface = {
static void vga_gfx_get_poke_interface(void *data,
const video_poke_interface_t **iface) { *iface = &vga_poke_interface; }
void vga_gfx_set_viewport(void *data, unsigned vp_width,
unsigned vp_height, bool force_full, bool allow_rotate) { }
void vga_gfx_set_viewport(void *data, unsigned dims,
bool force_full, bool allow_rotate) { }
static void vga_gfx_viewport_info(void *data, struct video_viewport *vp)
{
+12 -13
View File
@@ -2412,8 +2412,8 @@ static void vulkan_copy_staging_to_dynamic(vk_t *vk, VkCommandBuffer cmd,
/**
* FORWARD DECLARATIONS
*/
static void vulkan_set_viewport(void *data, unsigned vp_width,
unsigned vp_height, bool force_full, bool allow_rotate);
static void vulkan_set_viewport(void *data, unsigned dims,
bool force_full, bool allow_rotate);
static void vulkan_lock_queue(void *handle);
static void vulkan_unlock_queue(void *handle);
@@ -3446,7 +3446,7 @@ static void vulkan_font_render_msg(
color[3] = 1.0f;
}
vulkan_set_viewport(vk, width, height, full_screen, false);
vulkan_set_viewport(vk, VIDEO_SCALE_PACK(width, height), full_screen, false);
/* Compute max glyphs for VBO allocation.
* Line scan below discovers actual length; this uses strlen
@@ -3842,7 +3842,7 @@ static void vulkan_font_flush_block(unsigned width, unsigned height,
return;
vk = font->vk;
vulkan_set_viewport(vk, width, height, font->block->fullscreen, false);
vulkan_set_viewport(vk, VIDEO_SCALE_PACK(width, height), font->block->fullscreen, false);
vulkan_font_upload_atlas(vk, font);
if (vulkan_buffer_chain_alloc(vk->context, &vk->chain->vbo,
@@ -6266,8 +6266,7 @@ static void *vulkan_init(const video_info_t *video,
/* Set the viewport to fix recording, since it needs to know
* the viewport sizes before we start running. */
vulkan_set_viewport(vk, VIDEO_SCALE_W(temp_dims),
VIDEO_SCALE_H(temp_dims), false, true);
vulkan_set_viewport(vk, temp_dims, false, true);
#ifdef VULKAN_HDR_SWAPCHAIN
vk->hdr.ubo = vulkan_create_buffer(vk->context, sizeof(vulkan_hdr_uniform_t), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT);
@@ -6959,13 +6958,13 @@ static void vulkan_set_video_mode(void *data,
dims, fullscreen);
}
static void vulkan_set_viewport(void *data, unsigned vp_width,
unsigned vp_height, bool force_full, bool allow_rotate)
static void vulkan_set_viewport(void *data, unsigned dims,
bool force_full, bool allow_rotate)
{
struct video_ortho ortho = {0, 1, 0, 1, -1, 1};
vk_t *vk = (vk_t*)data;
vk->vp.full_dims = VIDEO_SCALE_PACK(vp_width, vp_height);
vk->vp.full_dims = dims;
video_driver_update_viewport(&vk->vp, force_full,
(vk->flags & VK_FLAG_KEEP_ASPECT) ? true : false, true);
@@ -8408,7 +8407,7 @@ static bool vulkan_frame(void *data, const void *frame,
filter_chain, &input);
}
vulkan_set_viewport(vk, width, height, false, true);
vulkan_set_viewport(vk, VIDEO_SCALE_PACK(width, height), false, true);
vulkan_filter_chain_build_offscreen_passes(
(vulkan_filter_chain_t*)filter_chain,
@@ -8598,7 +8597,7 @@ static bool vulkan_frame(void *data, const void *frame,
struct vk_texture *optimal = &vk->menu.textures_optimal[vk->menu.last_index];
bool menu_linear_filter = video_info->menu_linear_filter;
vulkan_set_viewport(vk, width, height, ((vk->flags &
vulkan_set_viewport(vk, VIDEO_SCALE_PACK(width, height), ((vk->flags &
VK_FLAG_MENU_FULLSCREEN) > 0), false);
#ifdef VULKAN_HDR_SWAPCHAIN
@@ -10131,7 +10130,7 @@ static void vulkan_viewport_info(void *data, struct video_viewport *vp)
width = vk->video_width;
height = vk->video_height;
/* Make sure we get the correct viewport. */
vulkan_set_viewport(vk, width, height, false, true);
vulkan_set_viewport(vk, VIDEO_SCALE_PACK(width, height), false, true);
*vp = vk->vp;
vp->full_dims = VIDEO_SCALE_PACK(width, height);
@@ -10823,7 +10822,7 @@ static void vulkan_render_overlay(vk_t *vk, unsigned width,
return;
vp = vk->vp;
vulkan_set_viewport(vk, width, height,
vulkan_set_viewport(vk, VIDEO_SCALE_PACK(width, height),
((vk->flags & VK_FLAG_OVERLAY_FULLSCREEN) > 0),
false);
+2 -2
View File
@@ -1957,7 +1957,7 @@ static void gfx_widgets_frame_state(void *data)
if (video_st->current_video && video_st->current_video->set_viewport)
video_st->current_video->set_viewport(
video_st->data, video_width, video_height, true, false);
video_st->data, video_info->dims, true, false);
/* Font setup */
font_driver_bind_block(p_dispwidget->gfx_widget_fonts.regular.font,
@@ -2242,7 +2242,7 @@ static void gfx_widgets_frame_state(void *data)
if (video_st->current_video && video_st->current_video->set_viewport)
video_st->current_video->set_viewport(
video_st->data, video_width, video_height, false, true);
video_st->data, video_info->dims, false, true);
}
void gfx_widgets_frame(void *data)
+1 -1
View File
@@ -113,7 +113,7 @@ static void crt_aspect_ratio_switch(
video_driver_set_output_dims(VIDEO_SCALE_PACK(width, height));
if (video_st->current_video && video_st->current_video->set_viewport)
video_st->current_video->set_viewport(
video_st->data, width, height, true, true);
video_st->data, VIDEO_SCALE_PACK(width, height), true, true);
command_event(CMD_EVENT_VIDEO_APPLY_STATE_CHANGES, NULL);
}
+1 -1
View File
@@ -1060,7 +1060,7 @@ typedef struct video_driver
/* Human-readable identifier. */
const char *ident;
void (*set_viewport)(void *data, unsigned width, unsigned height,
void (*set_viewport)(void *data, unsigned dims,
bool force_full, bool allow_rotate);
void (*set_rotation)(void *data, unsigned rotation);
+4 -5
View File
@@ -673,8 +673,7 @@ static bool video_thread_handle_packet(
case CMD_SET_VIEWPORT:
if (thr->driver_data && thr->driver && thr->driver->set_viewport)
thr->driver->set_viewport(thr->driver_data,
VIDEO_SCALE_W(pkt.data.set_viewport.dims),
VIDEO_SCALE_H(pkt.data.set_viewport.dims),
pkt.data.set_viewport.dims,
pkt.data.set_viewport.force_full,
pkt.data.set_viewport.allow_rotate);
video_thread_reply(thr, &pkt);
@@ -2875,8 +2874,8 @@ static bool video_thread_set_shader(void *data,
return pkt.data.b;
}
static void video_thread_set_viewport(void *data, unsigned width,
unsigned height, bool force_full, bool video_allow_rotate)
static void video_thread_set_viewport(void *data, unsigned dims,
bool force_full, bool video_allow_rotate)
{
thread_video_t *thr = (thread_video_t*)data;
@@ -2884,7 +2883,7 @@ static void video_thread_set_viewport(void *data, unsigned width,
{
thread_packet_t pkt;
pkt.type = CMD_SET_VIEWPORT;
pkt.data.set_viewport.dims = VIDEO_SCALE_PACK(width, height);
pkt.data.set_viewport.dims = dims;
pkt.data.set_viewport.force_full = force_full;
pkt.data.set_viewport.allow_rotate = video_allow_rotate;
video_thread_send_and_wait_user_to_thread(thr, &pkt);
+2 -2
View File
@@ -8471,7 +8471,7 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
if (video_st->current_video && video_st->current_video->set_viewport)
video_st->current_video->set_viewport(
video_st->data, video_width, video_height, true, false);
video_st->data, video_info->dims, true, false);
/* Guard: bail if context was destroyed after we started */
if (ctx_gen != mui->context_generation)
@@ -8745,7 +8745,7 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
if (video_st->current_video && video_st->current_video->set_viewport)
video_st->current_video->set_viewport(
video_st->data, video_width, video_height, false, true);
video_st->data, video_info->dims, false, true);
ctx_destroyed:
; /* no-op — reached if context was destroyed mid-frame */
+2 -2
View File
@@ -12841,7 +12841,7 @@ static void ozone_frame(void *data, video_frame_info_t *video_info)
if (video_st->current_video && video_st->current_video->set_viewport)
video_st->current_video->set_viewport(
video_st->data, video_width, video_height, true, false);
video_st->data, video_info->dims, true, false);
/* Guard: bail if context was destroyed after we started */
if (ctx_gen != ozone->context_generation)
@@ -13181,7 +13181,7 @@ static void ozone_frame(void *data, video_frame_info_t *video_info)
if (video_st->current_video && video_st->current_video->set_viewport)
video_st->current_video->set_viewport(
video_st->data, video_width, video_height, false, true);
video_st->data, video_info->dims, false, true);
ctx_destroyed:
; /* no-op — reached if context was destroyed mid-frame */
+2 -2
View File
@@ -9328,7 +9328,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
if (video_st->current_video && video_st->current_video->set_viewport)
video_st->current_video->set_viewport(
video_st->data, video_width, video_height, true, false);
video_st->data, video_info->dims, true, false);
pseudo_font_length = xmb->icon_spacing_horizontal * 4 - xmb->icon_size / 4.0f;
left_thumbnail_margin_width = floorf(xmb->icon_size * (xmb->use_ps3_layout ? 3.3f : 2.0f));
@@ -10369,7 +10369,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
if (video_st->current_video && video_st->current_video->set_viewport)
video_st->current_video->set_viewport(
video_st->data, video_width, video_height, false, true);
video_st->data, video_info->dims, false, true);
ctx_destroyed:
; /* no-op — reached if context was destroyed mid-frame */
+2 -2
View File
@@ -802,7 +802,7 @@ void menu_screensaver_frame(menu_screensaver_t *screensaver,
/* Set viewport */
if (video_st->current_video && video_st->current_video->set_viewport)
video_st->current_video->set_viewport(
video_st->data, video_width, video_height, true, false);
video_st->data, video_info->dims, true, false);
/* Draw background */
gfx_display_draw_quad(
@@ -858,5 +858,5 @@ void menu_screensaver_frame(menu_screensaver_t *screensaver,
/* Unset viewport */
if (video_st->current_video && video_st->current_video->set_viewport)
video_st->current_video->set_viewport(
video_st->data, video_width, video_height, false, true);
video_st->data, video_info->dims, false, true);
}
@@ -951,7 +951,7 @@ static void lane_every_command_replies(void)
drv->set_nonblock_state(data, false, true, 2);
drv->set_nonblock_state(data, false, false, 1);
if (drv->set_viewport)
drv->set_viewport(data, 640, 480, false, true);
drv->set_viewport(data, VIDEO_SCALE_PACK(640, 480), false, true);
if (drv->set_rotation)
drv->set_rotation(data, 1), drv->set_rotation(data, 0);
if (drv->set_shader)
@@ -1100,7 +1100,7 @@ static bool reentrant_frame(void *data, const void *frame, unsigned w,
/* As ozone/xmb do: through the frontend's current driver, which is
* the wrapper, from the video thread. */
if (cur && cur->set_viewport)
cur->set_viewport(video_st->data, w, h, false, true);
cur->set_viewport(video_st->data, VIDEO_SCALE_PACK(w, h), false, true);
if (cur && cur->set_nonblock_state)
cur->set_nonblock_state(video_st->data, false, false, 1);
if (cur && cur->poke_interface)
@@ -1148,7 +1148,7 @@ static void lane_reentrant_from_frame(void)
if (drv->set_rotation)
drv->set_rotation(video_st->data, i & 3);
if ((i % 7) == 0 && drv->set_viewport)
drv->set_viewport(video_st->data, 800, 600, false, true);
drv->set_viewport(video_st->data, VIDEO_SCALE_PACK(800, 600), false, true);
}
video_thread_wait_idle();
CHECK(reentrant_frames > before,
@@ -2412,7 +2412,7 @@ static void lane_driver_reloads(void)
* down on a real driver. */
if (video_st->current_video->set_viewport)
video_st->current_video->set_viewport(video_st->data,
320 + 64 * (i & 1), 240 + 48 * (i & 1), true, true);
VIDEO_SCALE_PACK(320 + 64 * (i & 1), 240 + 48 * (i & 1)), true, true);
run_frames(2);
}
video_thread_wait_idle();