Skip to content

Commit

Permalink
Consistent viewport naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Dec 24, 2024
1 parent 83a1877 commit 44238e9
Show file tree
Hide file tree
Showing 44 changed files with 534 additions and 552 deletions.
18 changes: 9 additions & 9 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -2279,11 +2279,11 @@ static struct config_float_setting *populate_settings_float(
#endif

SETTING_FLOAT("video_aspect_ratio", &settings->floats.video_aspect_ratio, true, DEFAULT_ASPECT_RATIO, false);
SETTING_FLOAT("video_viewport_bias_x", &settings->floats.video_viewport_bias_x, true, DEFAULT_VIEWPORT_BIAS_X, false);
SETTING_FLOAT("video_viewport_bias_y", &settings->floats.video_viewport_bias_y, true, DEFAULT_VIEWPORT_BIAS_Y, false);
SETTING_FLOAT("video_viewport_bias_x", &settings->floats.video_vp_bias_x, true, DEFAULT_VIEWPORT_BIAS_X, false);
SETTING_FLOAT("video_viewport_bias_y", &settings->floats.video_vp_bias_y, true, DEFAULT_VIEWPORT_BIAS_Y, false);
#if defined(RARCH_MOBILE)
SETTING_FLOAT("video_viewport_bias_portrait_x", &settings->floats.video_viewport_bias_portrait_x, true, DEFAULT_VIEWPORT_BIAS_PORTRAIT_X, false);
SETTING_FLOAT("video_viewport_bias_portrait_y", &settings->floats.video_viewport_bias_portrait_y, true, DEFAULT_VIEWPORT_BIAS_PORTRAIT_Y, false);
SETTING_FLOAT("video_viewport_bias_portrait_x", &settings->floats.video_vp_bias_portrait_x, true, DEFAULT_VIEWPORT_BIAS_PORTRAIT_X, false);
SETTING_FLOAT("video_viewport_bias_portrait_y", &settings->floats.video_vp_bias_portrait_y, true, DEFAULT_VIEWPORT_BIAS_PORTRAIT_Y, false);
#endif
SETTING_FLOAT("video_refresh_rate", &settings->floats.video_refresh_rate, true, DEFAULT_REFRESH_RATE, false);
SETTING_FLOAT("video_autoswitch_pal_threshold", &settings->floats.video_autoswitch_pal_threshold, true, DEFAULT_AUTOSWITCH_PAL_THRESHOLD, false);
Expand Down Expand Up @@ -2431,10 +2431,10 @@ static struct config_uint_setting *populate_settings_uint(

SETTING_UINT("crt_switch_resolution", &settings->uints.crt_switch_resolution, true, DEFAULT_CRT_SWITCH_RESOLUTION, false);
SETTING_UINT("crt_switch_resolution_super", &settings->uints.crt_switch_resolution_super, true, DEFAULT_CRT_SWITCH_RESOLUTION_SUPER, false);
SETTING_UINT("custom_viewport_width", &settings->video_viewport_custom.width, false, 0 /* TODO */, false);
SETTING_UINT("custom_viewport_height", &settings->video_viewport_custom.height, false, 0 /* TODO */, false);
SETTING_UINT("custom_viewport_x", (unsigned*)&settings->video_viewport_custom.x, false, 0 /* TODO */, false);
SETTING_UINT("custom_viewport_y", (unsigned*)&settings->video_viewport_custom.y, false, 0 /* TODO */, false);
SETTING_UINT("custom_viewport_width", &settings->video_vp_custom.width, false, 0 /* TODO */, false);
SETTING_UINT("custom_viewport_height", &settings->video_vp_custom.height, false, 0 /* TODO */, false);
SETTING_UINT("custom_viewport_x", (unsigned*)&settings->video_vp_custom.x, false, 0 /* TODO */, false);
SETTING_UINT("custom_viewport_y", (unsigned*)&settings->video_vp_custom.y, false, 0 /* TODO */, false);
SETTING_UINT("aspect_ratio_index", &settings->uints.video_aspect_ratio_idx, true, DEFAULT_ASPECT_RATIO_IDX, false);
SETTING_UINT("video_autoswitch_refresh_rate", &settings->uints.video_autoswitch_refresh_rate, true, DEFAULT_AUTOSWITCH_REFRESH_RATE, false);
SETTING_UINT("video_monitor_index", &settings->uints.video_monitor_index, true, DEFAULT_MONITOR_INDEX, false);
Expand Down Expand Up @@ -2735,7 +2735,7 @@ void config_set_defaults(void *data)
const char *def_record = config_get_default_record();
const char *def_midi = config_get_default_midi();
const char *def_mitm = DEFAULT_NETPLAY_MITM_SERVER;
struct video_viewport *custom_vp = &settings->video_viewport_custom;
struct video_viewport *custom_vp = &settings->video_vp_custom;
struct config_float_setting *float_settings = populate_settings_float (settings, &float_settings_size);
struct config_bool_setting *bool_settings = populate_settings_bool (settings, &bool_settings_size);
struct config_int_setting *int_settings = populate_settings_int (settings, &int_settings_size);
Expand Down
10 changes: 5 additions & 5 deletions configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ typedef struct settings
size_t rewind_buffer_size;
} sizes;

video_viewport_t video_viewport_custom; /* int alignment */
video_viewport_t video_vp_custom; /* int alignment */

struct
{
Expand Down Expand Up @@ -384,11 +384,11 @@ typedef struct settings
{
float placeholder;
float video_aspect_ratio;
float video_viewport_bias_x;
float video_viewport_bias_y;
float video_vp_bias_x;
float video_vp_bias_y;
#if defined(RARCH_MOBILE)
float video_viewport_bias_portrait_x;
float video_viewport_bias_portrait_y;
float video_vp_bias_portrait_x;
float video_vp_bias_portrait_y;
#endif
float video_refresh_rate;
float video_autoswitch_pal_threshold;
Expand Down
23 changes: 11 additions & 12 deletions gfx/common/ctr_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
#define CTR_BOTTOM_FRAMEBUFFER_HEIGHT 240
#define CTR_STATE_DATE_SIZE 11

#define CTR_SET_SCALE_VECTOR(vec, viewport_width, viewport_height, texture_width, texture_height) \
(vec)->x = -2.0f / (viewport_width); \
(vec)->y = -2.0f / (viewport_height); \
(vec)->u = 1.0f / (texture_width); \
(vec)->v = -1.0f / (texture_height)
#define CTR_SET_SCALE_VECTOR(vec, vp_width, vp_height, tex_width, tex_height) \
(vec)->x = -2.0f / (vp_width); \
(vec)->y = -2.0f / (vp_height); \
(vec)->u = 1.0f / (tex_width); \
(vec)->v = -1.0f / (tex_height)

typedef enum
{
Expand Down Expand Up @@ -79,19 +79,19 @@ typedef struct ctr_video
struct
{
uint32_t* display_list;
int display_list_size;
void* texture_linear;
void* texture_swizzled;
ctr_vertex_t* frame_coords;
int display_list_size;
int texture_width;
int texture_height;
ctr_scale_vector_t scale_vector;
ctr_vertex_t* frame_coords;
}menu;

uint32_t* display_list;
uint32_t *display_list;
void *texture_linear;
void *texture_swizzled;
int display_list_size;
void* texture_linear;
void* texture_swizzled;
int texture_width;
int texture_height;

Expand All @@ -115,7 +115,6 @@ typedef struct ctr_video
int current_buffer_top;
int current_buffer_bottom;


struct
{
ctr_vertex_t* buffer;
Expand Down Expand Up @@ -186,7 +185,7 @@ extern u8* gfxBottomFramebuffers[2];

#ifdef CONSOLE_LOG
extern PrintConsole* ctrConsole;
#endif
#endif

extern const u8 ctr_sprite_shbin[];
extern const u32 ctr_sprite_shbin_size;
Expand Down
2 changes: 1 addition & 1 deletion gfx/common/d3d8_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ typedef struct d3d8_video
WNDCLASSEX windowClass;
#endif
LPDIRECT3DDEVICE8 dev;
D3DVIEWPORT8 final_viewport;
D3DVIEWPORT8 out_vp;

char *shader_path;

Expand Down
30 changes: 15 additions & 15 deletions gfx/common/d3d9_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -829,10 +829,10 @@ void d3d9_viewport_info(void *data, struct video_viewport *vp)

video_driver_get_size(&width, &height);

vp->x = d3d->final_viewport.X;
vp->y = d3d->final_viewport.Y;
vp->width = d3d->final_viewport.Width;
vp->height = d3d->final_viewport.Height;
vp->x = d3d->out_vp.X;
vp->y = d3d->out_vp.Y;
vp->width = d3d->out_vp.Width;
vp->height = d3d->out_vp.Height;

vp->full_width = width;
vp->full_height = height;
Expand Down Expand Up @@ -906,12 +906,12 @@ void d3d9_set_viewport(void *data,
d3d->needs_restore = true;
}

d3d->final_viewport.X = x;
d3d->final_viewport.Y = y;
d3d->final_viewport.Width = width;
d3d->final_viewport.Height = height;
d3d->final_viewport.MinZ = 0.0f;
d3d->final_viewport.MaxZ = 1.0f;
d3d->out_vp.X = x;
d3d->out_vp.Y = y;
d3d->out_vp.Width = width;
d3d->out_vp.Height = height;
d3d->out_vp.MinZ = 0.0f;
d3d->out_vp.MaxZ = 1.0f;

d3d9_set_font_rect(d3d, NULL);
}
Expand Down Expand Up @@ -1038,7 +1038,7 @@ void d3d9_overlay_render(d3d9_video_t *d3d,

/* Restore previous state. */
IDirect3DDevice9_SetRenderState(dev, D3DRS_ALPHABLENDENABLE, false);
IDirect3DDevice9_SetViewport(dev, (D3DVIEWPORT9*)&d3d->final_viewport);
IDirect3DDevice9_SetViewport(dev, (D3DVIEWPORT9*)&d3d->out_vp);
}

void d3d9_free_overlay(d3d9_video_t *d3d, overlay_t *overlay)
Expand Down Expand Up @@ -1304,14 +1304,14 @@ bool d3d9_read_viewport(void *data, uint8_t *buffer, bool is_idle)

{
unsigned x, y;
unsigned vp_width = (d3d->final_viewport.Width > width) ? width : d3d->final_viewport.Width;
unsigned vp_height = (d3d->final_viewport.Height > height) ? height : d3d->final_viewport.Height;
unsigned vp_width = (d3d->out_vp.Width > width) ? width : d3d->out_vp.Width;
unsigned vp_height = (d3d->out_vp.Height > height) ? height : d3d->out_vp.Height;
unsigned pitchpix = rect.Pitch / 4;
const uint32_t *pixels = (const uint32_t*)rect.pBits;

pixels += d3d->final_viewport.X;
pixels += d3d->out_vp.X;
pixels += (vp_height - 1) * pitchpix;
pixels -= d3d->final_viewport.Y * pitchpix;
pixels -= d3d->out_vp.Y * pitchpix;

for (y = 0; y < vp_height; y++, pixels -= pitchpix)
{
Expand Down
4 changes: 2 additions & 2 deletions gfx/common/d3d9_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ typedef struct d3d9_video
WNDCLASSEX windowClass;
#endif
LPDIRECT3DDEVICE9 dev;
D3DVIEWPORT9 final_viewport;
D3DVIEWPORT9 out_vp;
float translate_x;
float translate_y;

Expand Down Expand Up @@ -258,7 +258,7 @@ void d3d9_set_osd_msg(void *data,
const char *msg,
const struct font_params *params, void *font);

void d3d9_unload_texture(void *data,
void d3d9_unload_texture(void *data,
bool threaded, uintptr_t id);

void d3d9_set_video_mode(void *data,
Expand Down
4 changes: 2 additions & 2 deletions gfx/common/gl1_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ typedef struct gl1
unsigned menu_pitch;
unsigned video_bits;
unsigned menu_bits;
unsigned vp_out_width;
unsigned vp_out_height;
unsigned out_vp_width;
unsigned out_vp_height;
unsigned tex_index; /* For use with PREV. */
unsigned textures;
unsigned rotation;
Expand Down
4 changes: 2 additions & 2 deletions gfx/common/gl2_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ struct gl2
unsigned textures;
unsigned fbo_feedback_pass;
unsigned rotation;
unsigned vp_out_width;
unsigned vp_out_height;
unsigned out_vp_width;
unsigned out_vp_height;
unsigned tex_w;
unsigned tex_h;
unsigned base_size; /* 2 or 4 */
Expand Down
4 changes: 2 additions & 2 deletions gfx/common/gl3_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ typedef struct gl3
unsigned overlays;
unsigned version_major;
unsigned version_minor;
unsigned vp_out_width;
unsigned vp_out_height;
unsigned out_vp_width;
unsigned out_vp_height;
unsigned rotation;
unsigned textures_index;
unsigned scratch_vbo_index;
Expand Down
3 changes: 2 additions & 1 deletion gfx/common/vulkan_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,8 @@ typedef struct vk
unsigned video_height;

unsigned tex_w, tex_h;
unsigned vp_out_width, vp_out_height;
unsigned out_vp_width;
unsigned out_vp_height;
unsigned rotation;
unsigned num_swapchain_images;
unsigned last_valid_index;
Expand Down
4 changes: 2 additions & 2 deletions gfx/drivers/caca_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,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 viewport_width,
unsigned viewport_height, bool force_full, bool allow_rotate) { }
static void caca_set_viewport(void *data, unsigned vp_width,
unsigned vp_height, bool force_full, bool allow_rotate) { }

video_driver_t video_caca = {
caca_init,
Expand Down
2 changes: 0 additions & 2 deletions gfx/drivers/ctr_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,9 +768,7 @@ static void ctr_update_viewport(
true);
}
else if (ctr->keep_aspect)
{
video_viewport_get_scaled_aspect(&ctr->vp, width, height, true);
}
else
{
ctr->vp.x = 0;
Expand Down
26 changes: 13 additions & 13 deletions gfx/drivers/d3d8.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ static void d3d8_render(
video_smooth ?
D3DTEXF_LINEAR : D3DTEXF_POINT);

IDirect3DDevice8_SetViewport(chain->dev, (D3DVIEWPORT8*)&d3d->final_viewport);
IDirect3DDevice8_SetViewport(chain->dev, (D3DVIEWPORT8*)&d3d->out_vp);
IDirect3DDevice8_SetVertexShader(d3dr,
D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE);
IDirect3DDevice8_SetStreamSource(d3dr,
Expand Down Expand Up @@ -477,7 +477,7 @@ static bool d3d8_setup_init(void *data,
LPDIRECT3DDEVICE8 d3dr = (LPDIRECT3DDEVICE8)d3d->dev;
d3d8_renderchain_t *chain = (d3d8_renderchain_t*)d3d->renderchain_data;
unsigned fmt = (rgb32) ? RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565;
video_viewport_t *custom_vp = &settings->video_viewport_custom;
video_viewport_t *custom_vp = &settings->video_vp_custom;

video_driver_get_size(&width, &height);

Expand Down Expand Up @@ -759,10 +759,10 @@ static void d3d8_viewport_info(void *data, struct video_viewport *vp)

video_driver_get_size(&width, &height);

vp->x = d3d->final_viewport.X;
vp->y = d3d->final_viewport.Y;
vp->width = d3d->final_viewport.Width;
vp->height = d3d->final_viewport.Height;
vp->x = d3d->out_vp.X;
vp->y = d3d->out_vp.Y;
vp->width = d3d->out_vp.Width;
vp->height = d3d->out_vp.Height;

vp->full_width = width;
vp->full_height = height;
Expand Down Expand Up @@ -871,7 +871,7 @@ static void d3d8_overlay_render(d3d8_video_t *d3d,

/* Restore previous state. */
IDirect3DDevice8_SetRenderState(d3d->dev, D3DRS_ALPHABLENDENABLE, false);
IDirect3DDevice8_SetViewport(d3d->dev, (D3DVIEWPORT8*)&d3d->final_viewport);
IDirect3DDevice8_SetViewport(d3d->dev, (D3DVIEWPORT8*)&d3d->out_vp);
}

static void d3d8_free_overlay(d3d8_video_t *d3d, overlay_t *overlay)
Expand Down Expand Up @@ -1209,12 +1209,12 @@ static void d3d8_set_viewport(void *data,
if (y < 0)
y = 0;

d3d->final_viewport.X = x;
d3d->final_viewport.Y = y;
d3d->final_viewport.Width = width;
d3d->final_viewport.Height = height;
d3d->final_viewport.MinZ = 0.0f;
d3d->final_viewport.MaxZ = 0.0f;
d3d->out_vp.X = x;
d3d->out_vp.Y = y;
d3d->out_vp.Width = width;
d3d->out_vp.Height = height;
d3d->out_vp.MinZ = 0.0f;
d3d->out_vp.MaxZ = 0.0f;

d3d_matrix_identity(&ortho);
d3d_matrix_ortho_off_center_lh(&ortho, 0, 1, 0, 1, 0.0f, 1.0f);
Expand Down
12 changes: 6 additions & 6 deletions gfx/drivers/d3d9_renderchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ typedef struct d3d9_renderchain
unsigned last_height[TEXTURES];
} prev;
LPDIRECT3DDEVICE9 dev;
D3DVIEWPORT9 *final_viewport;
D3DVIEWPORT9 *out_vp;
struct shader_pass_vector_list *passes;
struct unsigned_vector_list *bound_tex;
struct unsigned_vector_list *bound_vert;
Expand Down Expand Up @@ -285,7 +285,7 @@ static INLINE bool d3d9_renderchain_set_pass_size(
width, height, 1,
D3DUSAGE_RENDERTARGET,
(pass2->info.pass->fbo.flags & FBO_SCALE_FLAG_FP_FBO)
? D3DFMT_A32B32G32R32F
? D3DFMT_A32B32G32R32F
: D3D9_ARGB8888_FORMAT,
D3DPOOL_DEFAULT, 0, 0, 0,
NULL, NULL, false);
Expand All @@ -308,12 +308,12 @@ static INLINE void d3d9_convert_geometry(
unsigned *out_height,
unsigned width,
unsigned height,
D3DVIEWPORT9 *final_viewport)
D3DVIEWPORT9 *out_vp)
{
switch (info->pass->fbo.type_x)
{
case RARCH_SCALE_VIEWPORT:
*out_width = info->pass->fbo.scale_x * final_viewport->Width;
*out_width = info->pass->fbo.scale_x * out_vp->Width;
break;

case RARCH_SCALE_ABSOLUTE:
Expand All @@ -328,7 +328,7 @@ static INLINE void d3d9_convert_geometry(
switch (info->pass->fbo.type_y)
{
case RARCH_SCALE_VIEWPORT:
*out_height = info->pass->fbo.scale_y * final_viewport->Height;
*out_height = info->pass->fbo.scale_y * out_vp->Height;
break;

case RARCH_SCALE_ABSOLUTE:
Expand Down Expand Up @@ -374,7 +374,7 @@ static INLINE void d3d9_recompute_pass_sizes(
d3d9_convert_geometry(
&link_info,
&out_width, &out_height,
current_width, current_height, &d3d->final_viewport);
current_width, current_height, &d3d->out_vp);

link_info.tex_w = next_pow2(out_width);
link_info.tex_h = next_pow2(out_height);
Expand Down
Loading

0 comments on commit 44238e9

Please sign in to comment.