Added clock time
Some checks failed
CI / React UI Build (push) Successful in 11s
CI / Native Windows Build And Tests (push) Successful in 1m32s
CI / Windows Release Package (push) Failing after 2m7s

This commit is contained in:
2026-05-06 12:38:23 +10:00
parent d2cf852eb2
commit 414ef62479
17 changed files with 335 additions and 18 deletions

View File

@@ -0,0 +1,45 @@
#include "RuntimeClock.h"
#include <chrono>
namespace
{
bool ToUtcTime(std::time_t time, std::tm& utcTime)
{
return gmtime_s(&utcTime, &time) == 0;
}
bool ToLocalTime(std::time_t time, std::tm& localTime)
{
return localtime_s(&localTime, &time) == 0;
}
}
RuntimeClockSnapshot GetRuntimeClockSnapshot()
{
return MakeRuntimeClockSnapshot(std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()));
}
RuntimeClockSnapshot MakeRuntimeClockSnapshot(std::time_t now)
{
RuntimeClockSnapshot snapshot;
std::tm utcTime = {};
if (!ToUtcTime(now, utcTime))
return snapshot;
snapshot.utcTimeSeconds =
static_cast<double>(utcTime.tm_hour * 3600 + utcTime.tm_min * 60 + utcTime.tm_sec);
std::tm localTime = {};
if (!ToLocalTime(now, localTime))
return snapshot;
utcTime.tm_isdst = localTime.tm_isdst;
const std::time_t localAsTime = std::mktime(&localTime);
const std::time_t utcAsLocalTime = std::mktime(&utcTime);
if (localAsTime != static_cast<std::time_t>(-1) && utcAsLocalTime != static_cast<std::time_t>(-1))
snapshot.utcOffsetSeconds = std::difftime(localAsTime, utcAsLocalTime);
return snapshot;
}

View File

@@ -0,0 +1,12 @@
#pragma once
#include <ctime>
struct RuntimeClockSnapshot
{
double utcTimeSeconds = 0.0;
double utcOffsetSeconds = 0.0;
};
RuntimeClockSnapshot GetRuntimeClockSnapshot();
RuntimeClockSnapshot MakeRuntimeClockSnapshot(std::time_t now);

View File

@@ -1,5 +1,7 @@
#include "stdafx.h"
#include "RuntimeHost.h"
#include "RuntimeClock.h"
#include "RuntimeParameterUtils.h"
#include "ShaderCompiler.h"
#include "ShaderPackageRegistry.h"
@@ -1321,6 +1323,7 @@ bool RuntimeHost::TryGetLayerRenderStates(unsigned outputWidth, unsigned outputH
void RuntimeHost::BuildLayerRenderStatesLocked(unsigned outputWidth, unsigned outputHeight, std::vector<RuntimeRenderState>& states) const
{
const RuntimeClockSnapshot clock = GetRuntimeClockSnapshot();
for (const LayerPersistentState& layer : mPersistentState.layers)
{
auto shaderIt = mPackagesById.find(layer.shaderId);
@@ -1331,6 +1334,8 @@ void RuntimeHost::BuildLayerRenderStatesLocked(unsigned outputWidth, unsigned ou
state.layerId = layer.id;
state.shaderId = layer.shaderId;
state.timeSeconds = std::chrono::duration_cast<std::chrono::duration<double>>(std::chrono::steady_clock::now() - mStartTime).count();
state.utcTimeSeconds = clock.utcTimeSeconds;
state.utcOffsetSeconds = clock.utcOffsetSeconds;
state.frameCount = static_cast<double>(mFrameCounter);
state.mixAmount = 1.0;
state.bypass = layer.bypass ? 1.0 : 0.0;