@@ -409,9 +409,8 @@ static void d3d8_set_vertices(
409409 unsigned pass ,
410410 unsigned vert_width , unsigned vert_height , uint64_t frame_count )
411411{
412- unsigned width , height ;
413-
414- video_driver_get_size (& width , & height );
412+ unsigned width = d3d -> vp .full_width ;
413+ unsigned height = d3d -> vp .full_height ;
415414
416415 if (chain -> last_width != vert_width || chain -> last_height != vert_height )
417416 {
@@ -572,15 +571,14 @@ static bool d3d8_setup_init(void *data,
572571 bool rgb32
573572 )
574573{
575- unsigned width , height ;
576574 d3d8_video_t * d3d = (d3d8_video_t * )data ;
577575 settings_t * settings = config_get_ptr ();
578576 LPDIRECT3DDEVICE8 d3dr = (LPDIRECT3DDEVICE8 )d3d -> dev ;
579577 d3d8_renderchain_t * chain = (d3d8_renderchain_t * )d3d -> renderchain_data ;
580578 unsigned fmt = (rgb32 ) ? RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565 ;
581579 video_viewport_t * custom_vp = & settings -> video_vp_custom ;
582-
583- video_driver_get_size ( & width , & height ) ;
580+ unsigned width = d3d -> vp . full_width ;
581+ unsigned height = d3d -> vp . full_height ;
584582
585583 chain -> dev = dev_data ;
586584 chain -> pixel_size = (fmt == RETRO_PIXEL_FORMAT_RGB565 )
@@ -1569,7 +1567,8 @@ static void d3d8_font_render_msg(
15691567 if (!d3d )
15701568 return ;
15711569
1572- video_driver_get_size (& width , & height );
1570+ width = d3d -> vp .full_width ;
1571+ height = d3d -> vp .full_height ;
15731572 if (!width || !height )
15741573 return ;
15751574
@@ -1781,21 +1780,18 @@ gfx_display_ctx_driver_t gfx_display_ctx_d3d8 = {
17811780
17821781static void d3d8_viewport_info (void * data , struct video_viewport * vp )
17831782{
1784- unsigned width , height ;
17851783 d3d8_video_t * d3d = (d3d8_video_t * )data ;
17861784
17871785 if (!d3d || !vp )
17881786 return ;
17891787
1790- video_driver_get_size (& width , & height );
1791-
17921788 vp -> x = d3d -> out_vp .X ;
17931789 vp -> y = d3d -> out_vp .Y ;
17941790 vp -> width = d3d -> out_vp .Width ;
17951791 vp -> height = d3d -> out_vp .Height ;
17961792
1797- vp -> full_width = width ;
1798- vp -> full_height = height ;
1793+ vp -> full_width = d3d -> vp . full_width ;
1794+ vp -> full_height = d3d -> vp . full_height ;
17991795}
18001796
18011797static void d3d8_overlay_render (d3d8_video_t * d3d ,
@@ -2104,22 +2100,25 @@ static void d3d8_make_d3dpp(void *data,
21042100 if (!windowed_enable )
21052101 {
21062102#ifdef _XBOX
2107- /* Xbox: query the actual display size and publish it to
2108- * video_st. Use the same values directly for the d3dpp
2109- * back-buffer rather than reading them back via
2110- * video_driver_get_size (which would just return what we
2111- * just wrote -- nothing else writes video_st->width /
2112- * height except the video drivers themselves). */
2103+ /* Xbox: query the actual display size, publish it to video_st
2104+ * and track it in d3d->vp.full_width/full_height so subsequent
2105+ * read sites (font_render_msg, viewport_info, etc.) can pull
2106+ * from the local field instead of locking video_st. */
21132107 unsigned width = 0 ;
21142108 unsigned height = 0 ;
21152109
21162110 d3d8_get_video_size (d3d , & width , & height );
21172111 video_driver_set_size (width , height );
2112+ d3d -> vp .full_width = width ;
2113+ d3d -> vp .full_height = height ;
21182114 d3dpp -> BackBufferWidth = width ;
21192115 d3dpp -> BackBufferHeight = height ;
21202116#else
2121- video_driver_get_size (& d3dpp -> BackBufferWidth ,
2122- & d3dpp -> BackBufferHeight );
2117+ /* Non-Xbox: by the time make_d3dpp runs, d3d8_init_internal
2118+ * has already published the size and written d3d->vp.
2119+ * full_width/full_height; read from there. */
2120+ d3dpp -> BackBufferWidth = d3d -> vp .full_width ;
2121+ d3dpp -> BackBufferHeight = d3d -> vp .full_height ;
21232122#endif
21242123 }
21252124
@@ -2202,7 +2201,8 @@ static void d3d8_calculate_rect(void *data,
22022201 struct video_viewport vp ;
22032202 d3d8_video_t * d3d = (d3d8_video_t * )data ;
22042203
2205- video_driver_get_size (width , height );
2204+ * width = d3d -> vp .full_width ;
2205+ * height = d3d -> vp .full_height ;
22062206
22072207 vp .full_width = * width ;
22082208 vp .full_height = * height ;
@@ -2267,7 +2267,6 @@ static void d3d8_set_viewport(void *data,
22672267static bool d3d8_initialize (d3d8_video_t * d3d , const video_info_t * info )
22682268{
22692269 struct LinkInfo link_info ;
2270- unsigned width , height ;
22712270 unsigned i = 0 ;
22722271 bool ret = true;
22732272 settings_t * settings = config_get_ptr ();
@@ -2316,9 +2315,10 @@ static bool d3d8_initialize(d3d8_video_t *d3d, const video_info_t *info)
23162315 )
23172316 return false;
23182317
2319- video_driver_get_size (& width , & height );
2318+ /* d3d->vp.full_* was written by the caller (d3d8_init_internal
2319+ * has already called set_size at this point). */
23202320 d3d8_set_viewport (d3d ,
2321- width , height , false, true);
2321+ d3d -> vp . full_width , d3d -> vp . full_height , false, true);
23222322
23232323 font_driver_init_osd (d3d , info ,
23242324 false,
@@ -2413,6 +2413,8 @@ static void d3d8_set_resize(d3d8_video_t *d3d,
24132413 d3d -> video_info .width = new_width ;
24142414 d3d -> video_info .height = new_height ;
24152415 video_driver_set_size (new_width , new_height );
2416+ d3d -> vp .full_width = new_width ;
2417+ d3d -> vp .full_height = new_height ;
24162418}
24172419
24182420static bool d3d8_alive (void * data )
@@ -2424,8 +2426,14 @@ static bool d3d8_alive(void *data)
24242426 bool quit = false;
24252427 bool resize = false;
24262428
2427- /* Needed because some context drivers don't track their sizes */
2428- video_driver_get_size (& temp_width , & temp_height );
2429+ /* Read from local bookkeeping rather than video_st (which
2430+ * would acquire context_lock + display_lock). d3d->vp.full_*
2431+ * is written at every set_size call site in this driver, so
2432+ * it stays in sync with video_st->width/height as long as no
2433+ * other code path writes them. In practice nothing does --
2434+ * see video_driver.c audit. */
2435+ temp_width = d3d -> vp .full_width ;
2436+ temp_height = d3d -> vp .full_height ;
24292437
24302438 win32_check_window (NULL , & quit , & resize , & temp_width , & temp_height );
24312439
@@ -2442,7 +2450,11 @@ static bool d3d8_alive(void *data)
24422450 ret = !quit ;
24432451
24442452 if (temp_width != 0 && temp_height != 0 )
2453+ {
24452454 video_driver_set_size (temp_width , temp_height );
2455+ d3d -> vp .full_width = temp_width ;
2456+ d3d -> vp .full_height = temp_height ;
2457+ }
24462458
24472459 return ret ;
24482460}
@@ -2543,6 +2555,8 @@ static bool d3d8_init_internal(d3d8_video_t *d3d,
25432555 unsigned new_width = info -> fullscreen ? full_x : info -> width ;
25442556 unsigned new_height = info -> fullscreen ? full_y : info -> height ;
25452557 video_driver_set_size (new_width , new_height );
2558+ d3d -> vp .full_width = new_width ;
2559+ d3d -> vp .full_height = new_height ;
25462560
25472561#ifdef HAVE_WINDOW
25482562 /* Use new_width / new_height directly rather than reading
0 commit comments