@@ -1287,6 +1287,8 @@ static void *gl1_init(const video_info_t *video,
12871287 video_driver_set_size (temp_width , temp_height );
12881288 else
12891289 video_driver_get_size (& temp_width , & temp_height );
1290+ gl1 -> vp .full_width = temp_width ;
1291+ gl1 -> vp .full_height = temp_height ;
12901292
12911293 RARCH_LOG ("[GL1] Using resolution %ux%u.\n" , temp_width , temp_height );
12921294
@@ -2008,8 +2010,11 @@ static bool gl1_alive(void *data)
20082010 bool ret = false;
20092011 gl1_t * gl1 = (gl1_t * )data ;
20102012
2011- /* Needed because some context drivers don't track their sizes */
2012- video_driver_get_size (& temp_width , & temp_height );
2013+ /* Read from local bookkeeping rather than video_st (which would
2014+ * acquire context_lock + display_lock). gl1->vp.full_* is
2015+ * written at every set_size call site in this driver. */
2016+ temp_width = gl1 -> vp .full_width ;
2017+ temp_height = gl1 -> vp .full_height ;
20132018
20142019 gl1 -> ctx_driver -> check_window (gl1 -> ctx_data ,
20152020 & quit , & resize , & temp_width , & temp_height );
@@ -2020,7 +2025,11 @@ static bool gl1_alive(void *data)
20202025 ret = !quit ;
20212026
20222027 if (temp_width != 0 && temp_height != 0 )
2028+ {
20232029 video_driver_set_size (temp_width , temp_height );
2030+ gl1 -> vp .full_width = temp_width ;
2031+ gl1 -> vp .full_height = temp_height ;
2032+ }
20242033
20252034 return ret ;
20262035}
@@ -2098,19 +2107,17 @@ static void gl1_set_rotation(void *data,
20982107
20992108static void gl1_viewport_info (void * data , struct video_viewport * vp )
21002109{
2101- unsigned width , height ;
21022110 unsigned top_y , top_dist ;
21032111 gl1_t * gl1 = (gl1_t * )data ;
21042112
2105- video_driver_get_size (& width , & height );
2106-
2113+ /* gl1->vp carries full_width/full_height (written at every
2114+ * set_size call site), so the struct copy populates them
2115+ * directly without a video_driver_get_size round-trip. */
21072116 * vp = gl1 -> vp ;
2108- vp -> full_width = width ;
2109- vp -> full_height = height ;
21102117
21112118 /* Adjust as GL viewport is bottom-up. */
21122119 top_y = vp -> y + vp -> height ;
2113- top_dist = height - top_y ;
2120+ top_dist = vp -> full_height - top_y ;
21142121 vp -> y = top_dist ;
21152122}
21162123
@@ -2135,16 +2142,13 @@ static bool gl1_read_viewport(void *data, uint8_t *buffer, bool is_idle)
21352142 /* Clamp to the region glReadPixels actually wrote.
21362143 * gl1_readback() clamps its read to
21372144 * min(vp.{w,h}, video_{width,height}), where video_{width,height}
2138- * come from video_info and ultimately video_driver_get_size() .
2145+ * come from the surface size kept in gl1->vp.full_* .
21392146 * gl1->video_{width,height} holds the core's frame size, not the
2140- * window size, so we re-query here to match. Not a hot path. */
2141- unsigned vd_w = 0 ;
2142- unsigned vd_h = 0 ;
2143- unsigned rb_w = 0 ;
2144- unsigned rb_h = 0 ;
2145- video_driver_get_size (& vd_w , & vd_h );
2146- rb_w = (gl1 -> vp .width > vd_w ) ? vd_w : gl1 -> vp .width ;
2147- rb_h = (gl1 -> vp .height > vd_h ) ? vd_h : gl1 -> vp .height ;
2147+ * window size, so we read the surface size from gl1->vp.full_*. */
2148+ unsigned vd_w = gl1 -> vp .full_width ;
2149+ unsigned vd_h = gl1 -> vp .full_height ;
2150+ unsigned rb_w = (gl1 -> vp .width > vd_w ) ? vd_w : gl1 -> vp .width ;
2151+ unsigned rb_h = (gl1 -> vp .height > vd_h ) ? vd_h : gl1 -> vp .height ;
21482152 video_frame_convert_rgba_to_bgr (
21492153 (const void * )gl1 -> readback_buffer_screenshot ,
21502154 buffer ,
0 commit comments