diff --git a/UI/PauseScreen.cpp b/UI/PauseScreen.cpp index 6298d8288e..113a7617e2 100644 --- a/UI/PauseScreen.cpp +++ b/UI/PauseScreen.cpp @@ -43,6 +43,13 @@ #include "UI/OnScreenDisplay.h" #include "UI/GameInfoCache.h" +AsyncImageFileView::AsyncImageFileView(const std::string &filename, UI::ImageSizeMode sizeMode, PrioritizedWorkQueue *wq, UI::LayoutParams *layoutParams) + : UI::Clickable(layoutParams), canFocus_(true), filename_(filename), color_(0xFFFFFFFF), sizeMode_(sizeMode), texture_(nullptr), textureFailed_(false), fixedSizeW_(0.0f), fixedSizeH_(0.0f) {} + +AsyncImageFileView::~AsyncImageFileView() { + delete texture_; +} + void AsyncImageFileView::GetContentDimensions(const UIContext &dc, float &w, float &h) const { if (texture_) { float texw = (float)texture_->Width(); diff --git a/UI/PauseScreen.h b/UI/PauseScreen.h index 13790c3a5d..b30aecce65 100644 --- a/UI/PauseScreen.h +++ b/UI/PauseScreen.h @@ -69,11 +69,8 @@ class PrioritizedWorkQueue; // of the view. TODO: Actually make async using the task. class AsyncImageFileView : public UI::Clickable { public: - AsyncImageFileView(const std::string &filename, UI::ImageSizeMode sizeMode, PrioritizedWorkQueue *wq, UI::LayoutParams *layoutParams = 0) - : UI::Clickable(layoutParams), canFocus_(true), filename_(filename), color_(0xFFFFFFFF), sizeMode_(sizeMode), texture_(nullptr), textureFailed_(false), fixedSizeW_(0.0f), fixedSizeH_(0.0f) {} - ~AsyncImageFileView() { - delete texture_; - } + AsyncImageFileView(const std::string &filename, UI::ImageSizeMode sizeMode, PrioritizedWorkQueue *wq, UI::LayoutParams *layoutParams = 0); + ~AsyncImageFileView(); void GetContentDimensions(const UIContext &dc, float &w, float &h) const override; void Draw(UIContext &dc) override; diff --git a/Windows/GPU/D3D11Context.cpp b/Windows/GPU/D3D11Context.cpp index ce679c7e41..015ad07e37 100644 --- a/Windows/GPU/D3D11Context.cpp +++ b/Windows/GPU/D3D11Context.cpp @@ -34,7 +34,6 @@ void D3D11Context::SwapInterval(int interval) { bool D3D11Context::Init(HINSTANCE hInst, HWND wnd, std::string *error_message) { bool windowed = true; hWnd_ = wnd; - HRESULT hr = S_OK; UINT createDeviceFlags = 0; #ifdef _DEBUG @@ -56,6 +55,7 @@ bool D3D11Context::Init(HINSTANCE hInst, HWND wnd, std::string *error_message) { }; UINT numFeatureLevels = ARRAYSIZE(featureLevels); + HRESULT hr = S_OK; // Temporarily commenting out until we can dynamically load D3D11CreateDevice. for (UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++) { driverType_ = driverTypes[driverTypeIndex]; @@ -70,8 +70,23 @@ bool D3D11Context::Init(HINSTANCE hInst, HWND wnd, std::string *error_message) { if (SUCCEEDED(hr)) break; } - if (FAILED(hr)) + + if (FAILED(hr)) { + const char *defaultError = "Your GPU does not appear to support Direct3D 11.\n\nWould you like to try again using Direct3D 9 instead?"; + I18NCategory *err = GetI18NCategory("Error"); + + std::wstring error = ConvertUTF8ToWString(err->T("D3D11NotSupported", defaultError)); + std::wstring title = ConvertUTF8ToWString(err->T("D3D11InitializationError", "Direct3D 11 initialization error")); + bool yes = IDYES == MessageBox(hWnd_, error.c_str(), title.c_str(), MB_ICONERROR | MB_YESNO); + if (yes) { + // Change the config to D3D and restart. + g_Config.iGPUBackend = GPU_BACKEND_DIRECT3D9; + g_Config.Save(); + + W32Util::ExitAndRestart(); + } return false; + } #ifdef _DEBUG if (SUCCEEDED(device_->QueryInterface(__uuidof(ID3D11Debug), (void**)&d3dDebug_))) { diff --git a/ext/native/thin3d/thin3d_d3d11.cpp b/ext/native/thin3d/thin3d_d3d11.cpp index b4c7f83e63..e2a51dccd3 100644 --- a/ext/native/thin3d/thin3d_d3d11.cpp +++ b/ext/native/thin3d/thin3d_d3d11.cpp @@ -211,7 +211,11 @@ D3D11DrawContext::D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *co } D3D11DrawContext::~D3D11DrawContext() { - + // Release references. + ID3D11RenderTargetView *view = nullptr; + context_->OMSetRenderTargets(1, &view, nullptr); + ID3D11ShaderResourceView *srv[2]{}; + context_->PSSetShaderResources(0, 2, srv); } void D3D11DrawContext::HandleEvent(Event ev) {