Compare commits

..

1 Commits

Author SHA1 Message Date
Morph
762b8ad448 general: Replace high_resolution_clock with steady_clock
On some OSes, high_resolution_clock is an alias to system_clock and is not monotonic in nature. Replace this with steady_clock.
2021-12-02 14:20:43 -05:00
10 changed files with 15 additions and 28 deletions

View File

@@ -19,16 +19,16 @@ u64 EstimateRDTSCFrequency() {
// get current time
_mm_mfence();
const u64 tscStart = __rdtsc();
const auto startTime = std::chrono::high_resolution_clock::now();
const auto startTime = std::chrono::steady_clock::now();
// wait roughly 3 seconds
while (true) {
auto milli = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::high_resolution_clock::now() - startTime);
std::chrono::steady_clock::now() - startTime);
if (milli.count() >= 3000)
break;
std::this_thread::sleep_for(milli_10);
}
const auto endTime = std::chrono::high_resolution_clock::now();
const auto endTime = std::chrono::steady_clock::now();
_mm_mfence();
const u64 tscEnd = __rdtsc();
// calculate difference

View File

@@ -30,7 +30,6 @@
#include "core/hle/service/apm/apm_controller.h"
#include "core/hle/service/apm/apm_interface.h"
#include "core/hle/service/bcat/backend/backend.h"
#include "core/hle/service/caps/caps.h"
#include "core/hle/service/filesystem/filesystem.h"
#include "core/hle/service/ns/ns.h"
#include "core/hle/service/nvflinger/nvflinger.h"
@@ -299,7 +298,7 @@ ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nv
{91, &ISelfController::GetAccumulatedSuspendedTickChangedEvent, "GetAccumulatedSuspendedTickChangedEvent"},
{100, &ISelfController::SetAlbumImageTakenNotificationEnabled, "SetAlbumImageTakenNotificationEnabled"},
{110, nullptr, "SetApplicationAlbumUserData"},
{120, &ISelfController::SaveCurrentScreenshot, "SaveCurrentScreenshot"},
{120, nullptr, "SaveCurrentScreenshot"},
{130, nullptr, "SetRecordVolumeMuted"},
{1000, nullptr, "GetDebugStorageChannel"},
};
@@ -580,17 +579,6 @@ void ISelfController::SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestCo
rb.Push(ResultSuccess);
}
void ISelfController::SaveCurrentScreenshot(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto album_report_option = rp.PopEnum<Capture::AlbumReportOption>();
LOG_WARNING(Service_AM, "(STUBBED) called. album_report_option={}", album_report_option);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
AppletMessageQueue::AppletMessageQueue(Core::System& system)
: service_context{system, "AppletMessageQueue"} {
on_new_message = service_context.CreateEvent("AMMessageQueue:OnMessageReceived");

View File

@@ -151,7 +151,6 @@ private:
void GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx);
void GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequestContext& ctx);
void SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestContext& ctx);
void SaveCurrentScreenshot(Kernel::HLERequestContext& ctx);
enum class ScreenshotPermission : u32 {
Inherit = 0,

View File

@@ -96,7 +96,7 @@ private:
bool DecodeOpusData(u32& consumed, u32& sample_count, const std::vector<u8>& input,
std::vector<opus_int16>& output, u64* out_performance_time) const {
const auto start_time = std::chrono::high_resolution_clock::now();
const auto start_time = std::chrono::steady_clock::now();
const std::size_t raw_output_sz = output.size() * sizeof(opus_int16);
if (sizeof(OpusPacketHeader) > input.size()) {
LOG_ERROR(Audio, "Input is smaller than the header size, header_sz={}, input_sz={}",
@@ -135,7 +135,7 @@ private:
return false;
}
const auto end_time = std::chrono::high_resolution_clock::now() - start_time;
const auto end_time = std::chrono::steady_clock::now() - start_time;
sample_count = out_sample_count;
consumed = static_cast<u32>(sizeof(OpusPacketHeader) + hdr.size);
if (out_performance_time != nullptr) {

View File

@@ -24,7 +24,7 @@ enum class AlbumImageOrientation {
Orientation3 = 3,
};
enum class AlbumReportOption : s32 {
enum class AlbumReportOption {
Disable = 0,
Enable = 1,
};

View File

@@ -33,7 +33,7 @@ public:
explicit PerfStats(u64 title_id_);
~PerfStats();
using Clock = std::chrono::high_resolution_clock;
using Clock = std::chrono::steady_clock;
void BeginSystemFrame();
void EndSystemFrame();
@@ -87,7 +87,7 @@ private:
class SpeedLimiter {
public:
using Clock = std::chrono::high_resolution_clock;
using Clock = std::chrono::steady_clock;
void DoSpeedLimiting(std::chrono::microseconds current_system_time_us);

View File

@@ -18,7 +18,7 @@ int ShaderNotify::ShadersBuilding() noexcept {
const int now_complete = num_complete.load(std::memory_order::relaxed);
const int now_building = num_building.load(std::memory_order::relaxed);
if (now_complete == now_building) {
const auto now = std::chrono::high_resolution_clock::now();
const auto now = std::chrono::steady_clock::now();
if (completed && num_complete == num_when_completed) {
if (now - complete_time > TIME_TO_STOP_REPORTING) {
report_base = now_complete;

View File

@@ -28,6 +28,6 @@ private:
bool completed{};
int num_when_completed{};
std::chrono::high_resolution_clock::time_point complete_time;
std::chrono::steady_clock::time_point complete_time;
};
} // namespace VideoCore

View File

@@ -136,7 +136,7 @@ void LoadingScreen::OnLoadComplete() {
void LoadingScreen::OnLoadProgress(VideoCore::LoadCallbackStage stage, std::size_t value,
std::size_t total) {
using namespace std::chrono;
const auto now = high_resolution_clock::now();
const auto now = steady_clock::now();
// reset the timer if the stage changes
if (stage != previous_stage) {
ui->progress_bar->setStyleSheet(QString::fromUtf8(progressbar_style[stage]));
@@ -160,7 +160,7 @@ void LoadingScreen::OnLoadProgress(VideoCore::LoadCallbackStage stage, std::size
// If theres a drastic slowdown in the rate, then display an estimate
if (now - previous_time > milliseconds{50} || slow_shader_compile_start) {
if (!slow_shader_compile_start) {
slow_shader_start = high_resolution_clock::now();
slow_shader_start = steady_clock::now();
slow_shader_compile_start = true;
slow_shader_first_value = value;
}

View File

@@ -84,8 +84,8 @@ private:
// shaders, it will start quickly but end slow if new shaders were added since previous launch.
// These variables are used to detect the change in speed so we can generate an ETA
bool slow_shader_compile_start = false;
std::chrono::high_resolution_clock::time_point slow_shader_start;
std::chrono::high_resolution_clock::time_point previous_time;
std::chrono::steady_clock::time_point slow_shader_start;
std::chrono::steady_clock::time_point previous_time;
std::size_t slow_shader_first_value = 0;
};