mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-23 01:21:57 -05:00
Direct3D9Ex: Also enter reduced performance mode when minimised, and showe a message in chat when that happens
This commit is contained in:
parent
05f8fe0555
commit
513d2d9a7b
5 changed files with 13 additions and 8 deletions
|
@ -52,8 +52,9 @@ static void CreateDeviceAndSwapChain(void) {
|
|||
|
||||
DXGI_SWAP_CHAIN_DESC desc = { 0 };
|
||||
desc.BufferCount = 1;
|
||||
// todo see if BGRA slightly faster
|
||||
desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
desc.BufferDesc.RefreshRate.Numerator = 60;
|
||||
desc.BufferDesc.RefreshRate.Numerator = 60; // TODO just leave at 0? check DXGI docs again
|
||||
desc.BufferDesc.RefreshRate.Denominator = 1;
|
||||
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
desc.OutputWindow = WindowInfo.Handle;
|
||||
|
|
|
@ -814,8 +814,13 @@ void Gfx_EndFrame(void) {
|
|||
IDirect3DDevice9_EndScene(device);
|
||||
cc_result res = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
|
||||
|
||||
/* Direct3D9Ex returns S_PRESENT_OCCLUDED when e.g. window is minimised */
|
||||
if (res && res != S_PRESENT_OCCLUDED) {
|
||||
/* Direct3D9Ex returns S_PRESENT_OCCLUDED when e.g.window is minimised */
|
||||
if (res == S_PRESENT_OCCLUDED) {
|
||||
TickReducedPerformance(); return;
|
||||
}
|
||||
EndReducedPerformance();
|
||||
|
||||
if (res) {
|
||||
if (res != D3DERR_DEVICELOST) Logger_Abort2(res, "D3D9_EndFrame");
|
||||
/* TODO: Make sure this actually works on all graphics cards. */
|
||||
Gfx_LoseContext(" (Direct3D9 device lost)");
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "Core.h"
|
||||
#if defined CC_BUILD_GL && !defined CC_BUILD_GLMODERN
|
||||
#include "_GraphicsBase.h"
|
||||
#include "Chat.h"
|
||||
#include "Errors.h"
|
||||
#include "Logger.h"
|
||||
#include "Window.h"
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "Core.h"
|
||||
#if defined CC_BUILD_GL && defined CC_BUILD_GLMODERN
|
||||
#include "_GraphicsBase.h"
|
||||
#include "Chat.h"
|
||||
#include "Errors.h"
|
||||
#include "Logger.h"
|
||||
#include "Window.h"
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "Block.h"
|
||||
#include "Options.h"
|
||||
#include "Bitmap.h"
|
||||
#include "Chat.h"
|
||||
|
||||
struct _GfxData Gfx;
|
||||
GfxResourceID Gfx_defaultIb;
|
||||
|
@ -96,14 +97,14 @@ static void TickReducedPerformance(void) {
|
|||
Thread_Sleep(100); /* 10 FPS */
|
||||
|
||||
if (reducedPerformance) return;
|
||||
reducedPerformance = true; /* TODO: also log a message in-game? */
|
||||
Platform_LogConst("Entering reduced performance mode");
|
||||
reducedPerformance = true;
|
||||
Chat_AddRaw("&eEntering reduced performance mode (game minimised or hidden)");
|
||||
}
|
||||
|
||||
static void EndReducedPerformance(void) {
|
||||
if (!reducedPerformance) return;
|
||||
reducedPerformance = false;
|
||||
Platform_LogConst("Exited reduced performance mode");
|
||||
Chat_AddRaw("&eExited reduced performance mode");
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue