mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Add an escape route to D3D9 in case D3D11 fails to initialize. Cleanups.
This commit is contained in:
parent
b807442641
commit
522ac5c739
4 changed files with 31 additions and 8 deletions
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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_))) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue