mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 01:26:50 -04:00
Direct3D11: Reduce FPS instead of crashing when minimised
This commit is contained in:
parent
114aa2f666
commit
2e72ffefa2
@ -942,6 +942,13 @@ void Gfx_EndFrame(void) {
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiswapchain-present
|
||||
// gfx_vsync happens to match SyncInterval parameter
|
||||
HRESULT hr = IDXGISwapChain_Present(swapchain, gfx_vsync, 0);
|
||||
|
||||
// run at reduced FPS when minimised
|
||||
if (hr == DXGI_STATUS_OCCLUDED) {
|
||||
TickReducedPerformance(); return;
|
||||
}
|
||||
|
||||
EndReducedPerformance();
|
||||
if (hr) Logger_Abort2(hr, "Failed to swap buffers");
|
||||
}
|
||||
|
||||
|
@ -3691,7 +3691,7 @@ static const struct ScreenVTABLE TexPackOverlay_VTABLE = {
|
||||
void TexPackOverlay_Show(const cc_string* url) {
|
||||
struct TexPackOverlay* s = &TexPackOverlay;
|
||||
s->grabsInput = true;
|
||||
/* Too easy to accidentally ESC this important dialog*/
|
||||
/* Too easy to accidentally ESC this important dialog */
|
||||
/* s->closable= true; */
|
||||
s->VTABLE = &TexPackOverlay_VTABLE;
|
||||
|
||||
|
@ -91,6 +91,21 @@ void Gfx_RecreateContext(void) {
|
||||
Event_RaiseVoid(&GfxEvents.ContextRecreated);
|
||||
}
|
||||
|
||||
cc_bool reducedPerformance;
|
||||
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");
|
||||
}
|
||||
|
||||
static void EndReducedPerformance(void) {
|
||||
if (!reducedPerformance) return;
|
||||
reducedPerformance = false;
|
||||
Platform_LogConst("Exited reduced performance mode");
|
||||
}
|
||||
|
||||
|
||||
void Gfx_RecreateDynamicVb(GfxResourceID* vb, VertexFormat fmt, int maxVertices) {
|
||||
Gfx_DeleteDynamicVb(vb);
|
||||
|
Loading…
x
Reference in New Issue
Block a user