further phase 1
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "RuntimeClock.h"
|
||||
#include "RuntimeParameterUtils.h"
|
||||
#include "ShaderCompiler.h"
|
||||
#include "ShaderPackageRegistry.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -212,42 +211,6 @@ bool ParseShaderParameterType(const std::string& typeName, ShaderParameterType&
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TextureAssetsEqual(const std::vector<ShaderTextureAsset>& left, const std::vector<ShaderTextureAsset>& right)
|
||||
{
|
||||
if (left.size() != right.size())
|
||||
return false;
|
||||
|
||||
for (std::size_t index = 0; index < left.size(); ++index)
|
||||
{
|
||||
if (left[index].id != right[index].id ||
|
||||
left[index].path != right[index].path ||
|
||||
left[index].writeTime != right[index].writeTime)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FontAssetsEqual(const std::vector<ShaderFontAsset>& left, const std::vector<ShaderFontAsset>& right)
|
||||
{
|
||||
if (left.size() != right.size())
|
||||
return false;
|
||||
|
||||
for (std::size_t index = 0; index < left.size(); ++index)
|
||||
{
|
||||
if (left[index].id != right[index].id ||
|
||||
left[index].path != right[index].path ||
|
||||
left[index].writeTime != right[index].writeTime)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string ManifestPathMessage(const std::filesystem::path& manifestPath)
|
||||
{
|
||||
return manifestPath.string();
|
||||
@@ -712,126 +675,6 @@ RuntimeHost::RuntimeHost()
|
||||
{
|
||||
}
|
||||
|
||||
bool RuntimeHost::PollFileChanges(bool& registryChanged, bool& reloadRequested, std::string& error)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
registryChanged = false;
|
||||
reloadRequested = false;
|
||||
|
||||
if (!mAutoReloadEnabled)
|
||||
{
|
||||
reloadRequested = mReloadRequested;
|
||||
return true;
|
||||
}
|
||||
|
||||
const auto now = std::chrono::steady_clock::now();
|
||||
if (mLastScanTime != std::chrono::steady_clock::time_point::min() &&
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(now - mLastScanTime).count() < 250)
|
||||
{
|
||||
reloadRequested = mReloadRequested;
|
||||
return true;
|
||||
}
|
||||
|
||||
mLastScanTime = now;
|
||||
|
||||
std::string scanError;
|
||||
std::map<std::string, ShaderPackage> previousPackages = mPackagesById;
|
||||
std::vector<std::string> previousOrder = mPackageOrder;
|
||||
std::map<std::string, std::pair<std::filesystem::file_time_type, std::filesystem::file_time_type>> previousLayerShaderTimes;
|
||||
for (const LayerPersistentState& layer : mPersistentState.layers)
|
||||
{
|
||||
auto previous = previousPackages.find(layer.shaderId);
|
||||
if (previous != previousPackages.end())
|
||||
previousLayerShaderTimes[layer.id] = std::make_pair(previous->second.shaderWriteTime, previous->second.manifestWriteTime);
|
||||
}
|
||||
|
||||
if (!ScanShaderPackages(scanError))
|
||||
{
|
||||
error = scanError;
|
||||
return false;
|
||||
}
|
||||
|
||||
registryChanged = previousOrder != mPackageOrder;
|
||||
if (!registryChanged && previousPackages.size() == mPackagesById.size())
|
||||
{
|
||||
for (const auto& item : mPackagesById)
|
||||
{
|
||||
auto previous = previousPackages.find(item.first);
|
||||
if (previous == previousPackages.end())
|
||||
{
|
||||
registryChanged = true;
|
||||
break;
|
||||
}
|
||||
if (previous->second.shaderWriteTime != item.second.shaderWriteTime ||
|
||||
previous->second.manifestWriteTime != item.second.manifestWriteTime ||
|
||||
!TextureAssetsEqual(previous->second.textureAssets, item.second.textureAssets) ||
|
||||
!FontAssetsEqual(previous->second.fontAssets, item.second.fontAssets))
|
||||
{
|
||||
registryChanged = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (LayerPersistentState& layer : mPersistentState.layers)
|
||||
{
|
||||
auto active = mPackagesById.find(layer.shaderId);
|
||||
auto previous = previousLayerShaderTimes.find(layer.id);
|
||||
if (active == mPackagesById.end())
|
||||
continue;
|
||||
EnsureLayerDefaultsLocked(layer, active->second);
|
||||
if (previous != previousLayerShaderTimes.end())
|
||||
{
|
||||
auto previousPackage = previousPackages.find(layer.shaderId);
|
||||
if (previous->second.first != active->second.shaderWriteTime ||
|
||||
previous->second.second != active->second.manifestWriteTime ||
|
||||
(previousPackage != previousPackages.end() &&
|
||||
(!TextureAssetsEqual(previousPackage->second.textureAssets, active->second.textureAssets) ||
|
||||
!FontAssetsEqual(previousPackage->second.fontAssets, active->second.fontAssets))))
|
||||
{
|
||||
mReloadRequested = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reloadRequested = mReloadRequested;
|
||||
if (registryChanged || reloadRequested)
|
||||
MarkRenderStateDirtyLocked();
|
||||
return true;
|
||||
}
|
||||
catch (const std::exception& exception)
|
||||
{
|
||||
error = std::string("RuntimeHost::PollFileChanges exception: ") + exception.what();
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
error = "RuntimeHost::PollFileChanges threw a non-standard exception.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool RuntimeHost::ManualReloadRequested()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
return mReloadRequested;
|
||||
}
|
||||
|
||||
void RuntimeHost::ClearReloadRequest()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
mReloadRequested = false;
|
||||
}
|
||||
|
||||
void RuntimeHost::SetCompileStatus(bool succeeded, const std::string& message)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
mCompileSucceeded = succeeded;
|
||||
mCompileMessage = message;
|
||||
}
|
||||
|
||||
void RuntimeHost::SetSignalStatus(bool hasSignal, unsigned width, unsigned height, const std::string& modeName)
|
||||
{
|
||||
const HealthTelemetry::SignalStatusSnapshot previousStatus = mHealthTelemetry.GetSignalStatusSnapshot();
|
||||
@@ -921,69 +764,6 @@ bool RuntimeHost::TrySetFramePacingStats(double completionIntervalMilliseconds,
|
||||
maxCompletionIntervalMilliseconds, lateFrameCount, droppedFrameCount, flushedFrameCount);
|
||||
}
|
||||
|
||||
void RuntimeHost::AdvanceFrame()
|
||||
{
|
||||
++mFrameCounter;
|
||||
}
|
||||
|
||||
bool RuntimeHost::TryAdvanceFrame()
|
||||
{
|
||||
++mFrameCounter;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RuntimeHost::BuildLayerPassFragmentShaderSources(const std::string& layerId, std::vector<ShaderPassBuildSource>& passSources, std::string& error)
|
||||
{
|
||||
try
|
||||
{
|
||||
ShaderPackage shaderPackage;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
const LayerPersistentState* layer = FindLayerById(layerId);
|
||||
if (!layer)
|
||||
{
|
||||
error = "Unknown layer id: " + layerId;
|
||||
return false;
|
||||
}
|
||||
|
||||
auto it = mPackagesById.find(layer->shaderId);
|
||||
if (it == mPackagesById.end())
|
||||
{
|
||||
error = "Unknown shader id: " + layer->shaderId;
|
||||
return false;
|
||||
}
|
||||
shaderPackage = it->second;
|
||||
}
|
||||
|
||||
ShaderCompiler compiler(mRepoRoot, mWrapperPath, mGeneratedGlslPath, mPatchedGlslPath, mConfig.maxTemporalHistoryFrames);
|
||||
// Compile every declared pass while the caller remains backend-neutral.
|
||||
// The GL layer decides how the resulting pass sources are routed.
|
||||
passSources.clear();
|
||||
passSources.reserve(shaderPackage.passes.size());
|
||||
for (const ShaderPassDefinition& pass : shaderPackage.passes)
|
||||
{
|
||||
ShaderPassBuildSource passSource;
|
||||
passSource.passId = pass.id;
|
||||
passSource.inputNames = pass.inputNames;
|
||||
passSource.outputName = pass.outputName;
|
||||
if (!compiler.BuildPassFragmentShaderSource(shaderPackage, pass, passSource.fragmentShaderSource, error))
|
||||
return false;
|
||||
passSources.push_back(std::move(passSource));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (const std::exception& exception)
|
||||
{
|
||||
error = std::string("RuntimeHost::BuildLayerPassFragmentShaderSources exception: ") + exception.what();
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
error = "RuntimeHost::BuildLayerPassFragmentShaderSources threw a non-standard exception.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void RuntimeHost::SetServerPort(unsigned short port)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
|
||||
Reference in New Issue
Block a user