void D3DVideo::init_base(const video_info_t &info) { D3DPRESENT_PARAMETERS d3dpp; make_d3dpp(info, d3dpp); g_pD3D = Direct3DCreate9(D3D_SDK_VERSION); if (!g_pD3D) throw std::runtime_error("Failed to create D3D9 interface!"); if (FAILED(Callback::d3d_err = g_pD3D->CreateDevice( Monitor::cur_mon_id, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &dev))) { RARCH_WARN("[D3D9]: Failed to init device with hardware vertex processing (code: 0x%x). Trying to fall back to software vertex processing.\n", (unsigned)Callback::d3d_err); if (FAILED(Callback::d3d_err = g_pD3D->CreateDevice( Monitor::cur_mon_id, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &dev))) { throw std::runtime_error("Failed to init device"); } } }
void D3DVideo::init(const video_info_t &info) { if (!g_pD3D) init_base(info); else if (needs_restore) { D3DPRESENT_PARAMETERS d3dpp; make_d3dpp(info, d3dpp); if (dev->Reset(&d3dpp) != D3D_OK) { HRESULT res = dev->TestCooperativeLevel(); const char *err; switch (res) { case D3DERR_DEVICELOST: err = "DEVICELOST"; break; case D3DERR_DEVICENOTRESET: err = "DEVICENOTRESET"; break; case D3DERR_DRIVERINTERNALERROR: err = "DRIVERINTERNALERROR"; break; default: err = "Unknown"; } // Try to recreate the device completely ... RARCH_WARN("[D3D9]: Attempting to recover from dead state (%s).\n", err); deinit(); g_pD3D->Release(); g_pD3D = nullptr; init_base(info); RARCH_LOG("[D3D9]: Recovered from dead state.\n"); } } calculate_rect(screen_width, screen_height, info.force_aspect, g_settings.video.aspect_ratio); #ifdef HAVE_CG if (!init_cg()) throw std::runtime_error("Failed to init Cg"); #endif if (!init_chain(info)) throw std::runtime_error("Failed to init render chain"); if (!init_font()) throw std::runtime_error("Failed to init Font"); }
void D3DVideo::init_base(const video_info_t &info) { D3DPRESENT_PARAMETERS d3dpp; make_d3dpp(info, d3dpp); g_pD3D = Direct3DCreate9(D3D_SDK_VERSION); if (!g_pD3D) throw std::runtime_error("Failed to create D3D9 interface!"); if (FAILED(g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &dev))) { throw std::runtime_error("Failed to init device"); } }
void D3DVideo::init(const video_info_t &info) { if (!g_pD3D) init_base(info); else if (needs_restore) { D3DPRESENT_PARAMETERS d3dpp; make_d3dpp(info, d3dpp); if (dev->Reset(&d3dpp) != D3D_OK) throw std::runtime_error("Failed to reset device ..."); } calculate_rect(screen_width, screen_height, info.force_aspect, g_settings.video.aspect_ratio); if (!init_cg()) throw std::runtime_error("Failed to init Cg"); if (!init_chain(info)) throw std::runtime_error("Failed to init render chain"); if (!init_font()) throw std::runtime_error("Failed to init Font"); }