Fixed pick_best_mode in both d3d and ddraw cases to manually extract
refresh information from the device's inline_config, since this is done before the screen devices are start. Fixes 01491: switchres causes Exception at EIP=009413BF: ACCESS VIOLATION. Also, fixed render_target_get_minimum_size() to return nominal values if no screens are found.
This commit is contained in:
parent
75056eb1b5
commit
ec550fa07b
@ -1405,6 +1405,7 @@ void render_target_compute_visible_area(render_target *target, INT32 target_widt
|
|||||||
void render_target_get_minimum_size(render_target *target, INT32 *minwidth, INT32 *minheight)
|
void render_target_get_minimum_size(render_target *target, INT32 *minwidth, INT32 *minheight)
|
||||||
{
|
{
|
||||||
float maxxscale = 1.0f, maxyscale = 1.0f;
|
float maxxscale = 1.0f, maxyscale = 1.0f;
|
||||||
|
int screens_considered = 0;
|
||||||
int layer;
|
int layer;
|
||||||
|
|
||||||
/* scan the current view for all screens */
|
/* scan the current view for all screens */
|
||||||
@ -1450,12 +1451,18 @@ void render_target_get_minimum_size(render_target *target, INT32 *minwidth, INT3
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* pick the greater */
|
/* pick the greater */
|
||||||
if (xscale > maxxscale)
|
maxxscale = MAX(xscale, maxxscale);
|
||||||
maxxscale = xscale;
|
maxyscale = MAX(yscale, maxyscale);
|
||||||
if (yscale > maxyscale)
|
screens_considered++;
|
||||||
maxyscale = yscale;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if there were no screens considered, pick a nominal default */
|
||||||
|
if (screens_considered == 0)
|
||||||
|
{
|
||||||
|
maxxscale = 640.0f;
|
||||||
|
maxyscale = 480.0f;
|
||||||
|
}
|
||||||
|
|
||||||
/* round up */
|
/* round up */
|
||||||
if (minwidth != NULL)
|
if (minwidth != NULL)
|
||||||
|
@ -1238,7 +1238,8 @@ static int get_adapter_for_monitor(d3d_info *d3d, win_monitor_info *monitor)
|
|||||||
|
|
||||||
static void pick_best_mode(win_window_info *window)
|
static void pick_best_mode(win_window_info *window)
|
||||||
{
|
{
|
||||||
double target_refresh = ATTOSECONDS_TO_HZ(video_screen_get_frame_period(Machine->primary_screen).attoseconds);
|
const device_config *primary_screen = video_screen_first(Machine->config);
|
||||||
|
double target_refresh = 60.0;
|
||||||
INT32 target_width, target_height;
|
INT32 target_width, target_height;
|
||||||
d3d_info *d3d = window->drawdata;
|
d3d_info *d3d = window->drawdata;
|
||||||
INT32 minwidth, minheight;
|
INT32 minwidth, minheight;
|
||||||
@ -1246,6 +1247,13 @@ static void pick_best_mode(win_window_info *window)
|
|||||||
int maxmodes;
|
int maxmodes;
|
||||||
int modenum;
|
int modenum;
|
||||||
|
|
||||||
|
// determine the refresh rate of the primary screen
|
||||||
|
if (primary_screen != NULL)
|
||||||
|
{
|
||||||
|
const screen_config *config = primary_screen->inline_config;
|
||||||
|
target_refresh = ATTOSECONDS_TO_HZ(config->refresh);
|
||||||
|
}
|
||||||
|
|
||||||
// determine the minimum width/height for the selected target
|
// determine the minimum width/height for the selected target
|
||||||
// note: technically we should not be calling this from an alternate window
|
// note: technically we should not be calling this from an alternate window
|
||||||
// thread; however, it is only done during init time, and the init code on
|
// thread; however, it is only done during init time, and the init code on
|
||||||
|
@ -1291,6 +1291,7 @@ static HRESULT WINAPI enum_modes_callback(LPDDSURFACEDESC2 desc, LPVOID context)
|
|||||||
|
|
||||||
static void pick_best_mode(win_window_info *window)
|
static void pick_best_mode(win_window_info *window)
|
||||||
{
|
{
|
||||||
|
const device_config *primary_screen = video_screen_first(Machine->config);
|
||||||
dd_info *dd = window->drawdata;
|
dd_info *dd = window->drawdata;
|
||||||
mode_enum_info einfo;
|
mode_enum_info einfo;
|
||||||
HRESULT result;
|
HRESULT result;
|
||||||
@ -1304,7 +1305,15 @@ static void pick_best_mode(win_window_info *window)
|
|||||||
// use those as the target for now
|
// use those as the target for now
|
||||||
einfo.target_width = einfo.minimum_width * MAX(1, video_config.prescale);
|
einfo.target_width = einfo.minimum_width * MAX(1, video_config.prescale);
|
||||||
einfo.target_height = einfo.minimum_height * MAX(1, video_config.prescale);
|
einfo.target_height = einfo.minimum_height * MAX(1, video_config.prescale);
|
||||||
einfo.target_refresh = ATTOSECONDS_TO_HZ(video_screen_get_frame_period(Machine->primary_screen).attoseconds);
|
|
||||||
|
// determine the refresh rate of the primary screen
|
||||||
|
einfo.target_refresh = 60.0;
|
||||||
|
if (primary_screen != NULL)
|
||||||
|
{
|
||||||
|
const screen_config *config = primary_screen->inline_config;
|
||||||
|
einfo.target_refresh = ATTOSECONDS_TO_HZ(config->refresh);
|
||||||
|
}
|
||||||
|
printf("Target refresh = %f\n", einfo.target_refresh);
|
||||||
|
|
||||||
// if we're not stretching, allow some slop on the minimum since we can handle it
|
// if we're not stretching, allow some slop on the minimum since we can handle it
|
||||||
if (!video_config.hwstretch)
|
if (!video_config.hwstretch)
|
||||||
|
Loading…
Reference in New Issue
Block a user