@@ -1489,7 +1489,8 @@ static void d3d9_cg_font_render_msg(
14891489 if (!d3d || !font || !msg || !* msg )
14901490 return ;
14911491
1492- video_driver_get_size (& width , & height );
1492+ width = d3d -> vp .full_width ;
1493+ height = d3d -> vp .full_height ;
14931494 if (!width || !height )
14941495 return ;
14951496
@@ -1657,8 +1658,8 @@ static void d3d9_cg_font_render_msg(
16571658 float _inv_vp_w , _inv_vp_h ;
16581659 float _inv_tex_w , _inv_tex_h ;
16591660 const struct font_glyph * _glyph_q = NULL ;
1660- unsigned _rl_width = 0 ;
1661- unsigned _rl_height = 0 ;
1661+ unsigned _rl_width = d3d -> vp . full_width ;
1662+ unsigned _rl_height = d3d -> vp . full_height ;
16621663 int _rx , _ry ;
16631664 unsigned _vert_count = 0 ;
16641665 Vertex * _verts = NULL ;
@@ -1668,7 +1669,6 @@ static void d3d9_cg_font_render_msg(
16681669 float _rl_pos_y = drop_pos_y ;
16691670 D3DCOLOR _rl_color = color_dark ;
16701671
1671- video_driver_get_size (& _rl_width , & _rl_height );
16721672 if (_rl_width && _rl_height )
16731673 {
16741674 _verts = d3d9_cg_font_get_scratch (font , _rl_msg_len * 6 );
@@ -1771,8 +1771,8 @@ static void d3d9_cg_font_render_msg(
17711771 float _inv_vp_w , _inv_vp_h ;
17721772 float _inv_tex_w , _inv_tex_h ;
17731773 const struct font_glyph * _glyph_q = NULL ;
1774- unsigned _rl_width = 0 ;
1775- unsigned _rl_height = 0 ;
1774+ unsigned _rl_width = d3d -> vp . full_width ;
1775+ unsigned _rl_height = d3d -> vp . full_height ;
17761776 int _rx , _ry ;
17771777 unsigned _vert_count = 0 ;
17781778 Vertex * _verts = NULL ;
@@ -1782,7 +1782,6 @@ static void d3d9_cg_font_render_msg(
17821782 float _rl_pos_y = line_y ;
17831783 D3DCOLOR _rl_color = color ;
17841784
1785- video_driver_get_size (& _rl_width , & _rl_height );
17861785 if (_rl_width && _rl_height )
17871786 {
17881787 _verts = d3d9_cg_font_get_scratch (font , _rl_msg_len * 6 );
@@ -3664,7 +3663,10 @@ static void d3d9_cg_set_viewport(void *data,
36643663 int y = 0 ;
36653664 struct video_viewport vp ;
36663665
3667- video_driver_get_size (& width , & height );
3666+ /* Width/height parameters are intentionally overwritten here:
3667+ * the caller's values are not used (pre-existing behaviour). */
3668+ width = d3d -> vp .full_width ;
3669+ height = d3d -> vp .full_height ;
36683670
36693671 vp .full_width = width ;
36703672 vp .full_height = height ;
@@ -3712,7 +3714,6 @@ static void d3d9_cg_set_viewport(void *data,
37123714
37133715static bool d3d9_cg_initialize (d3d9_video_t * d3d , const video_info_t * info )
37143716{
3715- unsigned width , height ;
37163717 bool ret = true;
37173718 settings_t * settings = config_get_ptr ();
37183719
@@ -3747,9 +3748,10 @@ static bool d3d9_cg_initialize(d3d9_video_t *d3d, const video_info_t *info)
37473748 return false;
37483749 }
37493750
3750- video_driver_get_size (& width , & height );
3751+ /* d3d->vp.full_* was written by the caller (d3d9_cg_init_internal
3752+ * has already called set_size at this point). */
37513753 d3d9_cg_set_viewport (d3d ,
3752- width , height , false, true);
3754+ d3d -> vp . full_width , d3d -> vp . full_height , false, true);
37533755
37543756 font_driver_init_osd (d3d , info ,
37553757 false,
@@ -3974,6 +3976,8 @@ static bool d3d9_cg_init_internal(d3d9_video_t *d3d,
39743976 unsigned new_width = info -> fullscreen ? full_x : info -> width ;
39753977 unsigned new_height = info -> fullscreen ? full_y : info -> height ;
39763978 video_driver_set_size (new_width , new_height );
3979+ d3d -> vp .full_width = new_width ;
3980+ d3d -> vp .full_height = new_height ;
39773981
39783982#ifdef HAVE_WINDOW
39793983 /* Use new_width / new_height directly rather than reading
@@ -4832,6 +4836,8 @@ static void d3d9_cg_set_resize(d3d9_video_t *d3d,
48324836 d3d -> video_info .width = new_width ;
48334837 d3d -> video_info .height = new_height ;
48344838 video_driver_set_size (new_width , new_height );
4839+ d3d -> vp .full_width = new_width ;
4840+ d3d -> vp .full_height = new_height ;
48354841}
48364842
48374843static bool d3d9_cg_alive (void * data )
@@ -4843,8 +4849,11 @@ static bool d3d9_cg_alive(void *data)
48434849 bool resize = false;
48444850 d3d9_video_t * d3d = (d3d9_video_t * )data ;
48454851
4846- /* Needed because some context drivers don't track their sizes */
4847- video_driver_get_size (& temp_width , & temp_height );
4852+ /* Read from local bookkeeping rather than video_st (which would
4853+ * acquire context_lock + display_lock). d3d->vp.full_* is
4854+ * written at every set_size call site in this driver. */
4855+ temp_width = d3d -> vp .full_width ;
4856+ temp_height = d3d -> vp .full_height ;
48484857
48494858 win32_check_window (NULL , & quit , & resize , & temp_width , & temp_height );
48504859
@@ -4862,7 +4871,11 @@ static bool d3d9_cg_alive(void *data)
48624871
48634872 if ( temp_width != 0 &&
48644873 temp_height != 0 )
4874+ {
48654875 video_driver_set_size (temp_width , temp_height );
4876+ d3d -> vp .full_width = temp_width ;
4877+ d3d -> vp .full_height = temp_height ;
4878+ }
48664879
48674880 return ret ;
48684881}
@@ -4890,18 +4903,15 @@ void d3d9_cg_set_rotation(void *data, unsigned rot)
48904903
48914904void d3d9_cg_viewport_info (void * data , struct video_viewport * vp )
48924905{
4893- unsigned width , height ;
48944906 d3d9_video_t * d3d = (d3d9_video_t * )data ;
48954907
4896- video_driver_get_size (& width , & height );
4897-
48984908 vp -> x = d3d -> out_vp .X ;
48994909 vp -> y = d3d -> out_vp .Y ;
49004910 vp -> width = d3d -> out_vp .Width ;
49014911 vp -> height = d3d -> out_vp .Height ;
49024912
4903- vp -> full_width = width ;
4904- vp -> full_height = height ;
4913+ vp -> full_width = d3d -> vp . full_width ;
4914+ vp -> full_height = d3d -> vp . full_height ;
49054915}
49064916
49074917static INLINE bool d3d9_cg_device_get_render_target_data (
@@ -4915,15 +4925,14 @@ static INLINE bool d3d9_cg_device_get_render_target_data(
49154925
49164926bool d3d9_cg_read_viewport (void * data , uint8_t * buffer , bool is_idle )
49174927{
4918- unsigned width , height ;
49194928 D3DLOCKED_RECT rect ;
49204929 LPDIRECT3DSURFACE9 target = NULL ;
49214930 LPDIRECT3DSURFACE9 dest = NULL ;
49224931 bool ret = true;
49234932 d3d9_video_t * d3d = (d3d9_video_t * )data ;
49244933 LPDIRECT3DDEVICE9 d3dr = d3d -> dev ;
4925-
4926- video_driver_get_size ( & width , & height ) ;
4934+ unsigned width = d3d -> vp . full_width ;
4935+ unsigned height = d3d -> vp . full_height ;
49274936
49284937 if (
49294938 !SUCCEEDED (IDirect3DDevice9_GetRenderTarget (d3dr , 0 , (LPDIRECT3DSURFACE9 * )& target ))
0 commit comments