@@ -1140,35 +1140,14 @@ static void rsx_set_projection(rsx_t *rsx,
11401140static void rsx_set_viewport (void * data , unsigned vp_width , unsigned vp_height ,
11411141 bool force_full , bool allow_rotate )
11421142{
1143- int i ;
1143+ int i ;
11441144 rsx_viewport_t vp ;
11451145 struct video_ortho ortho = {0 , 1 , 0 , 1 , -1 , 1 };
1146- settings_t * settings = config_get_ptr ();
11471146 rsx_t * rsx = (rsx_t * )data ;
1148- bool video_scale_integer = settings -> bools .video_scale_integer ;
11491147
1150- if (video_scale_integer && !force_full )
1151- {
1152- video_viewport_get_scaled_integer (& rsx -> vp ,
1153- vp_width , vp_height ,
1154- video_driver_get_aspect_ratio (), rsx -> keep_aspect ,
1155- true);
1156- vp_width = rsx -> vp .width ;
1157- vp_height = rsx -> vp .height ;
1158- }
1159- else if (rsx -> keep_aspect && !force_full )
1160- {
1161- video_viewport_get_scaled_aspect (& rsx -> vp , vp_width , vp_height , true);
1162- vp_width = rsx -> vp .width ;
1163- vp_height = rsx -> vp .height ;
1164- }
1165- else
1166- {
1167- rsx -> vp .x = 0 ;
1168- rsx -> vp .y = 0 ;
1169- rsx -> vp .width = vp_width ;
1170- rsx -> vp .height = vp_height ;
1171- }
1148+ rsx -> vp .full_width = vp_width ;
1149+ rsx -> vp .full_height = vp_height ;
1150+ video_driver_update_viewport (& rsx -> vp , force_full , rsx -> keep_aspect , true);
11721151
11731152 vp .min = 0.0f ;
11741153 vp .max = 1.0f ;
@@ -1191,13 +1170,6 @@ static void rsx_set_viewport(void *data, unsigned vp_width, unsigned vp_height,
11911170 rsxSetScissor (rsx -> context , vp .x , vp .y , vp .w , vp .h );
11921171
11931172 rsx_set_projection (rsx , & ortho , allow_rotate );
1194-
1195- /* Set last backbuffer viewport. */
1196- if (!force_full )
1197- {
1198- rsx -> vp .width = vp_width ;
1199- rsx -> vp .height = vp_height ;
1200- }
12011173}
12021174
12031175static const gfx_ctx_driver_t * rsx_get_context (rsx_t * rsx )
@@ -1597,81 +1569,11 @@ static void* rsx_init(const video_info_t* video,
15971569
15981570static void rsx_update_viewport (rsx_t * rsx )
15991571{
1600- int x = 0 ;
1601- int y = 0 ;
1602- unsigned vp_width = rsx -> width ;
1603- unsigned vp_height = rsx -> height ;
1604- float device_aspect = ((float )vp_width ) / vp_height ;
1605- settings_t * settings = config_get_ptr ();
1606- bool video_scale_integer = settings -> bools .video_scale_integer ;
1607- unsigned aspect_ratio_idx = settings -> uints .video_aspect_ratio_idx ;
1608-
1609- if (video_scale_integer )
1610- {
1611- video_viewport_get_scaled_integer (& rsx -> vp , vp_width , vp_height ,
1612- video_driver_get_aspect_ratio (), rsx -> keep_aspect ,
1613- true);
1614- vp_width = rsx -> vp .width ;
1615- vp_height = rsx -> vp .height ;
1616- }
1617- else if (rsx -> keep_aspect )
1618- {
1619- float desired_aspect = video_driver_get_aspect_ratio ();
1620-
1621- #if defined(HAVE_MENU )
1622- if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM )
1623- {
1624- video_viewport_t * custom_vp = & settings -> video_vp_custom ;
1625- /* RSX/libgcm has top-left origin viewport. */
1626- x = custom_vp -> x ;
1627- y = custom_vp -> y ;
1628- vp_width = custom_vp -> width ;
1629- vp_height = custom_vp -> height ;
1630- }
1631- else
1632- #endif
1633- {
1634- float delta ;
1635-
1636- if ((fabsf (device_aspect - desired_aspect ) < 0.0001f ))
1637- {
1638- /* If the aspect ratios of screen and desired aspect
1639- * ratio are sufficiently equal (floating point stuff),
1640- * assume they are actually equal.
1641- */
1642- }
1643- else if (device_aspect > desired_aspect )
1644- {
1645- float viewport_bias = settings -> floats .video_vp_bias_x ;
1646- delta = (desired_aspect / device_aspect - 1.0f )
1647- / 2.0f + 0.5f ;
1648- x = (int )roundf (vp_width * ((0.5f - delta ) * (viewport_bias * 2.0f )));
1649- vp_width = (unsigned )roundf (2.0f * vp_width * delta );
1650- }
1651- else
1652- {
1653- float viewport_bias = 1.0 - settings -> floats .video_vp_bias_y ;
1654- delta = (device_aspect / desired_aspect - 1.0f )
1655- / 2.0f + 0.5f ;
1656- y = (int )roundf (vp_height * ((0.5f - delta ) * (viewport_bias * 2.0f )));
1657- vp_height = (unsigned )roundf (2.0f * vp_height * delta );
1658- }
1659- }
1660-
1661- rsx -> vp .x = x ;
1662- rsx -> vp .y = y ;
1663- rsx -> vp .width = vp_width ;
1664- rsx -> vp .height = vp_height ;
1665- }
1666- else
1667- {
1668- rsx -> vp .x = 0 ;
1669- rsx -> vp .y = 0 ;
1670- rsx -> vp .width = vp_width ;
1671- rsx -> vp .height = vp_height ;
1672- }
1572+ rsx -> vp .full_width = rsx -> width ;
1573+ rsx -> vp .full_height = rsx -> height ;
1574+ video_driver_update_viewport (& rsx -> vp , false, rsx -> keep_aspect , true);
16731575
1674- rsx -> should_resize = false;
1576+ rsx -> should_resize = false;
16751577}
16761578
16771579static unsigned rsx_wrap_type_to_enum (enum gfx_wrap_type type )
0 commit comments