Commit 018ee72b authored by Hans-Kristian Arntzen's avatar Hans-Kristian Arntzen
Browse files

git subrepo pull mupen64plus-video-paraLLEl/parallel-rdp

subrepo:
  subdir:   "mupen64plus-video-paraLLEl/parallel-rdp"
  merged:   "0dcebe1"
upstream:
  origin:   "https://github.com/Themaister/parallel-rdp-standalone.git"
  branch:   "master"
  commit:   "0dcebe1"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"
parent d28b4c52
Pipeline #77525 passed with stages
in 14 minutes
......@@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/Themaister/parallel-rdp-standalone.git
branch = master
commit = e79d0cb775faa3953457bf29eb1ca27f540cf370
parent = aec5348830ebe206ea72292091a040ab622585c4
commit = 0dcebe11ee79288441e40e145c8f340d81f52316
parent = d28b4c52c7bbfe4458c2c99734b61a5fde0bc601
method = rebase
cmdver = 0.4.3
b3eeb49e708a215ee990415f303ce9936e55bd66
e5efa5836cd43a597c706e07f04e79083d5ffb4f
......@@ -23,16 +23,12 @@
#include "timer.hpp"
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#else
#include <time.h>
#endif
#ifdef __linux__
#include <sys/timerfd.h>
#include <unistd.h>
#endif
namespace Util
{
FrameTimer::FrameTimer()
......@@ -102,11 +98,6 @@ struct QPCFreq
} static static_qpc_freq;
#endif
#if !defined(_WIN32) && !defined(CLOCK_MONOTONIC_RAW)
#warning "CLOCK_MONOTONIC_RAW is not defined?"
#define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
#endif
int64_t get_current_time_nsecs()
{
#ifdef _WIN32
......@@ -132,123 +123,4 @@ double Timer::end()
auto nt = get_current_time_nsecs();
return double(nt - t) * 1e-9;
}
struct FrameLimiter::Impl
{
#ifdef _WIN32
HANDLE timer_handle = nullptr;
#else
int timer_fd = -1;
#endif
bool begin_interval_ns(uint64_t ns)
{
#ifdef _WIN32
if (!timer_handle)
{
timer_handle = CreateWaitableTimerA(nullptr, FALSE, nullptr);
if (timer_handle)
timeBeginPeriod(1);
}
if (!timer_handle)
return false;
LARGE_INTEGER due_time;
due_time.QuadPart = -int64_t(ns) / 100;
if (!SetWaitableTimer(timer_handle, &due_time, ns / 1000000,
nullptr, nullptr, FALSE))
{
CloseHandle(timer_handle);
timer_handle = nullptr;
return false;
}
return true;
#elif defined(__linux__)
if (timer_fd < 0)
timer_fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
if (timer_fd >= 0)
{
itimerspec timerspec = {};
timerspec.it_value.tv_nsec = ns % (1000 * 1000 * 1000);
timerspec.it_value.tv_sec = ns / (1000 * 1000 * 1000);
timerspec.it_interval = timerspec.it_value;
if (timerfd_settime(timer_fd, TFD_TIMER_CANCEL_ON_SET, &timerspec, nullptr) < 0)
{
close(timer_fd);
timer_fd = -1;
}
}
return timer_fd >= 0;
#else
return false;
#endif
}
bool wait_interval()
{
#ifdef _WIN32
if (!timer_handle)
return false;
return WaitForSingleObject(timer_handle, INFINITE) == WAIT_OBJECT_0;
#elif defined(__linux__)
if (timer_fd < 0)
return false;
uint64_t expirations = 0;
return ::read(timer_fd, &expirations, sizeof(expirations)) > 0;
#else
return false;
#endif
}
bool is_active() const
{
#if defined(_WIN32)
return timer_handle != nullptr;
#else
return timer_fd >= 0;
#endif
}
~Impl()
{
#ifdef _WIN32
if (timer_handle)
{
CloseHandle(timer_handle);
timeEndPeriod(1);
}
#else
if (timer_fd >= 0)
::close(timer_fd);
#endif
}
};
FrameLimiter::FrameLimiter()
{
impl.reset(new Impl);
}
FrameLimiter::~FrameLimiter()
{
}
bool FrameLimiter::is_active() const
{
return impl->is_active();
}
bool FrameLimiter::begin_interval_ns(uint64_t ns)
{
return impl->begin_interval_ns(ns);
}
bool FrameLimiter::wait_interval()
{
return impl->wait_interval();
}
}
\ No newline at end of file
......@@ -23,7 +23,6 @@
#pragma once
#include <stdint.h>
#include <memory>
namespace Util
{
......@@ -50,20 +49,6 @@ private:
int64_t get_time();
};
class FrameLimiter
{
public:
FrameLimiter();
~FrameLimiter();
bool begin_interval_ns(uint64_t ns);
bool wait_interval();
bool is_active() const;
private:
struct Impl;
std::unique_ptr<Impl> impl;
};
class Timer
{
public:
......
......@@ -30,15 +30,6 @@ namespace Vulkan
{
WSI::WSI()
{
const char *frame_time_ms = getenv("GRANITE_FRAME_TIME_MS");
if (frame_time_ms)
{
auto period_ms = atol(frame_time_ms);
LOGI("Limiting frame time to %ld ms.\n", period_ms);
if (!frame_limiter.begin_interval_ns(1000000ull * period_ms))
LOGE("Failed to begin timer.\n");
}
// With frame latency of 1, we get the ideal latency where
// we present, and then wait for the previous present to complete.
// Once this unblocks, it means that the present we just queued up is scheduled to complete next vblank,
......@@ -436,9 +427,6 @@ bool WSI::end_frame()
{
device->end_frame_context();
if (frame_limiter.is_active())
frame_limiter.wait_interval();
// Take ownership of the release semaphore so that the external user can use it.
if (frame_is_external)
{
......
......@@ -239,7 +239,6 @@ private:
unsigned present_frame_latency = 0;
WSITiming timing;
Util::FrameLimiter frame_limiter;
void tear_down_swapchain();
void drain_swapchain();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment