(D3D10/11/12) prevent some crashes on driver re-init.

This commit is contained in:
aliaspider 2018-01-25 06:24:39 +01:00
parent da3a90a025
commit 17aa49004f
3 changed files with 34 additions and 15 deletions

View File

@ -41,7 +41,11 @@ static void d3d10_gfx_set_rotation(void* data, unsigned rotation)
math_matrix_4x4* mvp;
d3d10_video_t* d3d10 = (d3d10_video_t*)data;
d3d10->frame.rotation = 3 * rotation;
if(!d3d10)
return;
d3d10->frame.rotation = rotation;
matrix_4x4_rotate_z(rot, d3d10->frame.rotation * (M_PI / 2.0f));
matrix_4x4_multiply(d3d10->mvp, rot, d3d10->mvp_no_rot);
@ -71,6 +75,8 @@ static void*
d3d10_gfx_init(const video_info_t* video, const input_driver_t** input, void** input_data)
{
WNDCLASSEX wndclass = { 0 };
MONITORINFOEX current_mon;
HMONITOR hm_to_use;
settings_t* settings = config_get_ptr();
gfx_ctx_input_t inp = { input, input_data };
d3d10_video_t* d3d10 = (d3d10_video_t*)calloc(1, sizeof(*d3d10));
@ -83,6 +89,16 @@ d3d10_gfx_init(const video_info_t* video, const input_driver_t** input, void** i
wndclass.lpfnWndProc = WndProcD3D;
win32_window_init(&wndclass, true, NULL);
win32_monitor_info(&current_mon, &hm_to_use, &d3d10->cur_mon_id);
d3d10->vp.full_width = video->width;
d3d10->vp.full_height = video->height;
if (!d3d10->vp.full_width)
d3d10->vp.full_width = current_mon.rcMonitor.right - current_mon.rcMonitor.left;
if (!d3d10->vp.full_height)
d3d10->vp.full_height = current_mon.rcMonitor.bottom - current_mon.rcMonitor.top;
if (!win32_set_video_mode(d3d10, video->width, video->height, video->fullscreen))
{
RARCH_ERR("[D3D10]: win32_set_video_mode failed.\n");
@ -133,11 +149,18 @@ d3d10_gfx_init(const video_info_t* video, const input_driver_t** input, void** i
}
D3D10SetRenderTargets(d3d10->device, 1, &d3d10->renderTargetView, NULL);
d3d10->vp.full_width = video->width;
d3d10->vp.full_height = video->height;
d3d10->viewport.Width = video->width;
d3d10->viewport.Height = video->height;
d3d10->resize_viewport = true;
d3d10->keep_aspect = video->force_aspect;
d3d10->vsync = video->vsync;
d3d10->format = video->rgb32 ? DXGI_FORMAT_B8G8R8X8_UNORM : DXGI_FORMAT_B5G6R5_UNORM;
d3d10->frame.texture.desc.Format =
d3d10_get_closest_match_texture2D(d3d10->device, d3d10->format);
d3d10->frame.texture.desc.Usage = D3D10_USAGE_DEFAULT;
d3d10->menu.texture.desc.Usage = D3D10_USAGE_DEFAULT;
matrix_4x4_ortho(d3d10->mvp_no_rot, 0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
@ -173,15 +196,6 @@ d3d10_gfx_init(const video_info_t* video, const input_driver_t** input, void** i
d3d10_set_filtering(d3d10, 0, video->smooth);
d3d10->keep_aspect = video->force_aspect;
d3d10->vsync = video->vsync;
d3d10->format = video->rgb32 ? DXGI_FORMAT_B8G8R8X8_UNORM : DXGI_FORMAT_B5G6R5_UNORM;
d3d10->frame.texture.desc.Format =
d3d10_get_closest_match_texture2D(d3d10->device, d3d10->format);
d3d10->frame.texture.desc.Usage = D3D10_USAGE_DEFAULT;
d3d10->menu.texture.desc.Usage = D3D10_USAGE_DEFAULT;
{
d3d10_vertex_t vertices[] = {
{ { 0.0f, 0.0f }, { 0.0f, 1.0f }, { 1.0f, 1.0f, 1.0f, 1.0f } },

View File

@ -46,7 +46,10 @@ static void d3d11_gfx_set_rotation(void* data, unsigned rotation)
math_matrix_4x4* mvp;
d3d11_video_t* d3d11 = (d3d11_video_t*)data;
d3d11->frame.rotation = 3 * rotation;
if(!d3d11)
return;
d3d11->frame.rotation = rotation;
matrix_4x4_rotate_z(rot, d3d11->frame.rotation * (M_PI / 2.0f));
matrix_4x4_multiply(d3d11->mvp, rot, d3d11->mvp_no_rot);
@ -210,7 +213,6 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i
d3d11_get_closest_match_texture2D(d3d11->device, d3d11->format);
d3d11->frame.texture.desc.Usage = D3D11_USAGE_DEFAULT;
d3d11->menu.texture.desc.Format = DXGI_FORMAT_B4G4R4A4_UNORM;
d3d11->menu.texture.desc.Usage = D3D11_USAGE_DEFAULT;
matrix_4x4_ortho(d3d11->mvp_no_rot, 0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);

View File

@ -42,7 +42,10 @@ static void d3d12_gfx_set_rotation(void* data, unsigned rotation)
D3D12_RANGE read_range = { 0, 0 };
d3d12_video_t* d3d12 = (d3d12_video_t*)data;
d3d12->frame.rotation = 3 * rotation;
if(!d3d12)
return;
d3d12->frame.rotation = rotation;
matrix_4x4_rotate_z(rot, d3d12->frame.rotation * (M_PI / 2.0f));
matrix_4x4_multiply(d3d12->mvp, rot, d3d12->mvp_no_rot);