Remove emscripten-only vsync fps limit type

This was ill-designed: "vsync" should be a draw cap limit, if anything. We can't currently think of a way to allow both vsync and a different arbitrary fps limit without banishing the simulation to another thread, so this gets shelved now.
This commit is contained in:
Tamás Bálint Misius
2025-01-22 16:02:03 +01:00
parent 99f3aabbf6
commit 6576872074
5 changed files with 14 additions and 28 deletions

View File

@@ -1,9 +1,6 @@
#pragma once
#include <variant>
struct FpsLimitVsync
{
};
struct FpsLimitNone
{
};
@@ -11,7 +8,7 @@ struct FpsLimitExplicit
{
float value;
};
using FpsLimit = std::variant<FpsLimitVsync, FpsLimitNone, FpsLimitExplicit>;
using FpsLimit = std::variant<FpsLimitNone, FpsLimitExplicit>;
struct DrawLimitDisplay
{
@@ -23,4 +20,5 @@ struct DrawLimitExplicit
{
int value;
};
// TODO: DrawLimitVsync
using DrawLimit = std::variant<DrawLimitDisplay, DrawLimitNone, DrawLimitExplicit>;

View File

@@ -204,7 +204,7 @@ void SDLClose()
void SDLSetScreen()
{
auto newFrameOps = ui::Engine::Ref().windowFrameOps;
auto newVsyncHint = std::holds_alternative<FpsLimitVsync>(ui::Engine::Ref().GetFpsLimit());
auto newVsyncHint = false; // TODO: DrawLimitVsync
if (FORCE_WINDOW_FRAME_OPS == forceWindowFrameOpsEmbedded)
{
newFrameOps.resizable = false;

View File

@@ -22,13 +22,13 @@ void SetFpsLimit(FpsLimit newFpsLimit)
emscripten_set_main_loop(MainLoopBody, 0, 0);
mainLoopSet = true;
}
if (std::get_if<FpsLimitVsync>(&newFpsLimit))
{
emscripten_set_main_loop_timing(EM_TIMING_RAF, 1);
std::cerr << "implicit fps limit via vsync" << std::endl;
}
else
{
// if (std::get_if<FpsLimitVsync>(&newFpsLimit)) // TODO: DrawLimitVsync
// {
// emscripten_set_main_loop_timing(EM_TIMING_RAF, 1);
// std::cerr << "implicit fps limit via vsync" << std::endl;
// }
// else
// {
auto delay = 0;
if (auto *fpsLimitExplicit = std::get_if<FpsLimitExplicit>(&newFpsLimit))
{
@@ -36,7 +36,7 @@ void SetFpsLimit(FpsLimit newFpsLimit)
}
emscripten_set_main_loop_timing(EM_TIMING_SETTIMEOUT, delay);
std::cerr << "explicit fps limit: " << delay << "ms delays" << std::endl;
}
// }
}
void UpdateFpsLimit()

View File

@@ -2564,11 +2564,7 @@ void GameView::OnDraw()
fpsInfo << "\nSimulation";
fpsInfo << "\n FPS cap: ";
auto fpsLimit = ui::Engine::Ref().GetFpsLimit();
if (std::holds_alternative<FpsLimitVsync>(fpsLimit))
{
fpsInfo << "vsync";
}
else if (std::holds_alternative<FpsLimitNone>(fpsLimit))
if (std::holds_alternative<FpsLimitNone>(fpsLimit))
{
fpsInfo << "none";
}

View File

@@ -201,11 +201,7 @@ static int fpsCap(lua_State *L)
if (acount == 0)
{
auto fpsLimit = ui::Engine::Ref().GetFpsLimit();
if (std::holds_alternative<FpsLimitVsync>(fpsLimit))
{
lua_pushliteral(L, "vsync");
}
else if (std::holds_alternative<FpsLimitNone>(fpsLimit))
if (std::holds_alternative<FpsLimitNone>(fpsLimit))
{
lua_pushnumber(L, 2);
}
@@ -215,11 +211,6 @@ static int fpsCap(lua_State *L)
}
return 1;
}
if (lua_isstring(L, 1) && byteStringEqualsLiteral(tpt_lua_toByteString(L, 1), "vsync"))
{
ui::Engine::Ref().SetFpsLimit(FpsLimitVsync{});
return 0;
}
float fpscap = luaL_checknumber(L, 1);
if (fpscap < 2)
{
@@ -254,6 +245,7 @@ static int drawCap(lua_State *L)
}
return 1;
}
// if (lua_isstring(L, 1) && byteStringEqualsLiteral(tpt_lua_toByteString(L, 1), "vsync")) // TODO: DrawLimitVsync
if (lua_isstring(L, 1) && byteStringEqualsLiteral(tpt_lua_toByteString(L, 1), "display"))
{
ui::Engine::Ref().SetDrawingFrequencyLimit(DrawLimitDisplay{});