- remove old vid_maxfps implementations as they were garbage anyway and the new one works on all the platforms

This commit is contained in:
Magnus Norddahl 2019-03-26 11:10:17 +01:00
commit 9f0f659db0
14 changed files with 44 additions and 281 deletions

View file

@ -59,14 +59,9 @@
#include "vulkan/system/vk_swapchain.h"
#include "doomerrors.h"
#include <chrono>
#include <thread>
void Draw2D(F2DDrawer *drawer, FRenderState &state);
void DoWriteSavePic(FileWriter *file, ESSType ssformat, uint8_t *scr, int width, int height, sector_t *viewsector, bool upsidedown);
EXTERN_CVAR(Bool, vid_vsync)
EXTERN_CVAR(Int, vid_maxfps)
EXTERN_CVAR(Bool, r_drawvoxels)
EXTERN_CVAR(Int, gl_tonemap)
EXTERN_CVAR(Int, screenblocks)
@ -223,40 +218,6 @@ void VulkanFrameBuffer::Update()
Super::Update();
}
void VulkanFrameBuffer::FPSLimit()
{
using namespace std::chrono;
using namespace std::this_thread;
if (vid_maxfps <= 0 || vid_vsync)
return;
uint64_t targetWakeTime = fpsLimitTime + 1'000'000 / vid_maxfps;
while (true)
{
fpsLimitTime = duration_cast<microseconds>(steady_clock::now().time_since_epoch()).count();
int64_t timeToWait = targetWakeTime - fpsLimitTime;
if (timeToWait > 1'000'000 || timeToWait <= 0)
{
break;
}
if (timeToWait <= 2'000'000)
{
// We are too close to the deadline. OS sleep is not precise enough to wake us before it elapses.
// Yield execution and check time again.
sleep_for(nanoseconds(0));
}
else
{
// Sleep, but try to wake before deadline.
sleep_for(microseconds(timeToWait - 1'000'000));
}
}
}
void VulkanFrameBuffer::DeleteFrameObjects()
{
FrameDeleteList.Images.clear();