dx9: Avoid triggering reset when size unchanged.

This commit is contained in:
Unknown W. Brackets 2014-12-28 13:19:19 -08:00
parent cb62468fb9
commit 1a0f537967
4 changed files with 33 additions and 21 deletions

View file

@ -111,27 +111,34 @@ void Core_WaitInactive(int milliseconds) {
}
}
void UpdateScreenScale(int width, int height) {
dp_xres = width;
dp_yres = height;
pixel_xres = width;
pixel_yres = height;
bool UpdateScreenScale(int width, int height) {
g_dpi = 72;
g_dpi_scale = 1.0f;
#ifdef __SYMBIAN32__
dp_xres *= 1.4f;
dp_yres *= 1.4f;
#if defined(__SYMBIAN32__)
g_dpi_scale = 1.4f;
#endif
#ifdef _WIN32
#elif defined(_WIN32)
if (pixel_xres < 480 + 80) {
dp_xres *= 2;
dp_yres *= 2;
g_dpi_scale = 2.0f;
}
#endif
pixel_in_dps = (float)pixel_xres / dp_xres;
NativeResized();
pixel_in_dps = 1.0f / g_dpi_scale;
int new_dp_xres = width * g_dpi_scale;
int new_dp_yres = height * g_dpi_scale;
bool dp_changed = new_dp_xres != dp_xres || new_dp_yres != dp_yres;
bool px_changed = pixel_xres != width || pixel_yres != height;
if (dp_changed || px_changed) {
dp_xres = new_dp_xres;
dp_yres = new_dp_yres;
pixel_xres = width;
pixel_yres = height;
NativeResized();
return true;
}
return false;
}
void UpdateRunLoop() {

View file

@ -42,7 +42,7 @@ bool Core_IsInactive();
void Core_WaitInactive();
void Core_WaitInactive(int milliseconds);
void UpdateScreenScale(int width, int height);
bool UpdateScreenScale(int width, int height);
// Don't run the core when minimized etc.
void Core_NotifyWindowHidden(bool hidden);

View file

@ -192,12 +192,16 @@ bool D3D9_Init(HWND wnd, bool windowed, std::string *error_message) {
}
void D3D9_Resize(HWND window) {
// Allow call from only EMU thread.
if (device) {
// This should only be called from the emu thread.
int xres, yres;
GetRes(xres, yres);
bool w_changed = pp.BackBufferWidth != xres;
bool h_changed = pp.BackBufferHeight != yres;
if (device && (w_changed || h_changed)) {
DX9::fbo_shutdown();
int xres, yres;
GetRes(xres, yres);
pp.BackBufferWidth = xres;
pp.BackBufferHeight = yres;
HRESULT hr = device->Reset(&pp);

View file

@ -262,8 +262,9 @@ namespace MainWindow
UpdateRenderResolution();
if (!noWindowMovement) {
UpdateScreenScale(width, height);
NativeMessageReceived("gpu resized", "");
if (UpdateScreenScale(width, height)) {
NativeMessageReceived("gpu resized", "");
}
}
}