mirror of
https://github.com/holub/mame
synced 2025-07-05 01:48:29 +03:00
- d3dhlsl.c: Free HLSL resources on device reset. Fixes hang when alt-tabbing
away from a fullscreen window and back. [MooglyGuy]
This commit is contained in:
parent
a77655df86
commit
3d1e0d9d65
@ -777,7 +777,7 @@ void hlsl_info::init_fsfx_quad(void *vertbuf)
|
||||
// hlsl_info::create_resources
|
||||
//============================================================
|
||||
|
||||
int hlsl_info::create_resources()
|
||||
int hlsl_info::create_resources(bool reset)
|
||||
{
|
||||
if (!master_enable || !d3dintf->post_fx_available)
|
||||
return 0;
|
||||
@ -802,6 +802,8 @@ int hlsl_info::create_resources()
|
||||
|
||||
windows_options &winoptions = downcast<windows_options &>(window->machine().options());
|
||||
|
||||
if (!reset)
|
||||
{
|
||||
options = (hlsl_options*)global_alloc_clear(hlsl_options);
|
||||
|
||||
options->params_dirty = true;
|
||||
@ -981,6 +983,7 @@ int hlsl_info::create_resources()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// experimental: load a PNG to use for vector rendering; it is treated
|
||||
// as a brightness map
|
||||
@ -2055,12 +2058,12 @@ bool hlsl_info::register_texture(d3d_texture_info *texture, int width, int heigh
|
||||
// hlsl_info::delete_resources
|
||||
//============================================================
|
||||
|
||||
void hlsl_info::delete_resources()
|
||||
void hlsl_info::delete_resources(bool reset)
|
||||
{
|
||||
if (!master_enable || !d3dintf->post_fx_available)
|
||||
return;
|
||||
|
||||
if(write_ini)
|
||||
if(write_ini && !reset)
|
||||
{
|
||||
emu_file file(downcast<windows_options &>(window->machine().options()).screen_post_fx_dir(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
file_error filerr = open_next((d3d_info*)window->drawdata, file, downcast<windows_options &>(window->machine().options()).hlsl_ini_name(), "ini", 0);
|
||||
@ -2116,6 +2119,11 @@ void hlsl_info::delete_resources()
|
||||
file.printf("yiq_phase_count %d\n", options->yiq_phase_count);
|
||||
}
|
||||
|
||||
while (targethead != NULL)
|
||||
{
|
||||
remove_render_target(targethead);
|
||||
}
|
||||
|
||||
if (effect != NULL)
|
||||
{
|
||||
(*d3dintf->effect.release)(effect);
|
||||
@ -2167,10 +2175,6 @@ void hlsl_info::delete_resources()
|
||||
yiq_decode_effect = NULL;
|
||||
}
|
||||
|
||||
for (int index = 0; index < 9; index++)
|
||||
{
|
||||
}
|
||||
|
||||
if (avi_copy_texture != NULL)
|
||||
{
|
||||
(*d3dintf->texture.release)(avi_copy_texture);
|
||||
|
@ -147,8 +147,8 @@ public:
|
||||
void remove_render_target(int width, int height, UINT32 screen_index, UINT32 page_index);
|
||||
void remove_render_target(d3d_render_target *rt);
|
||||
|
||||
int create_resources();
|
||||
void delete_resources();
|
||||
int create_resources(bool reset);
|
||||
void delete_resources(bool reset);
|
||||
|
||||
// slider-related functions
|
||||
slider_state *init_slider_list();
|
||||
|
@ -803,7 +803,7 @@ try_again:
|
||||
d3d->default_texture = texture_create(d3d, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32));
|
||||
}
|
||||
|
||||
int ret = d3d->hlsl->create_resources();
|
||||
int ret = d3d->hlsl->create_resources(false);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
@ -900,7 +900,7 @@ static int device_create_resources(d3d_info *d3d)
|
||||
static void device_delete(d3d_info *d3d)
|
||||
{
|
||||
// free our effects
|
||||
d3d->hlsl->delete_resources();
|
||||
d3d->hlsl->delete_resources(false);
|
||||
|
||||
// delete the HLSL interface
|
||||
global_free(d3d->hlsl);
|
||||
@ -1144,11 +1144,15 @@ static int device_test_cooperative(d3d_info *d3d)
|
||||
|
||||
// free all existing resources and call reset on the device
|
||||
device_delete_resources(d3d);
|
||||
d3d->hlsl->delete_resources(true);
|
||||
result = (*d3dintf->device.reset)(d3d->device, &d3d->presentation);
|
||||
|
||||
// if it didn't work, punt to GDI
|
||||
if (result != D3D_OK)
|
||||
{
|
||||
printf("Unable to reset, result %08x\n", (UINT32)result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// try to create the resources again; if that didn't work, delete the whole thing
|
||||
if (device_create_resources(d3d))
|
||||
@ -1157,6 +1161,13 @@ static int device_test_cooperative(d3d_info *d3d)
|
||||
device_delete(d3d);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (d3d->hlsl->create_resources(true))
|
||||
{
|
||||
mame_printf_verbose("Direct3D: failed to recreate HLSL resources for device; failing permanently\n");
|
||||
device_delete(d3d);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user