further phase 1
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "RuntimeSnapshotProvider.h"
|
||||
|
||||
#include "RuntimeClock.h"
|
||||
#include "ShaderCompiler.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <mutex>
|
||||
@@ -13,7 +14,57 @@ RuntimeSnapshotProvider::RuntimeSnapshotProvider(RuntimeHost& runtimeHost) :
|
||||
|
||||
bool RuntimeSnapshotProvider::BuildLayerPassFragmentShaderSources(const std::string& layerId, std::vector<ShaderPassBuildSource>& passSources, std::string& error) const
|
||||
{
|
||||
return mRuntimeHost.BuildLayerPassFragmentShaderSources(layerId, passSources, error);
|
||||
try
|
||||
{
|
||||
ShaderPackage shaderPackage;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mRuntimeHost.mMutex);
|
||||
const RuntimeHost::LayerPersistentState* layer = mRuntimeHost.FindLayerById(layerId);
|
||||
if (!layer)
|
||||
{
|
||||
error = "Unknown layer id: " + layerId;
|
||||
return false;
|
||||
}
|
||||
|
||||
auto it = mRuntimeHost.mPackagesById.find(layer->shaderId);
|
||||
if (it == mRuntimeHost.mPackagesById.end())
|
||||
{
|
||||
error = "Unknown shader id: " + layer->shaderId;
|
||||
return false;
|
||||
}
|
||||
shaderPackage = it->second;
|
||||
}
|
||||
|
||||
ShaderCompiler compiler(
|
||||
mRuntimeHost.mRepoRoot,
|
||||
mRuntimeHost.mWrapperPath,
|
||||
mRuntimeHost.mGeneratedGlslPath,
|
||||
mRuntimeHost.mPatchedGlslPath,
|
||||
mRuntimeHost.mConfig.maxTemporalHistoryFrames);
|
||||
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("RuntimeSnapshotProvider::BuildLayerPassFragmentShaderSources exception: ") + exception.what();
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
error = "RuntimeSnapshotProvider::BuildLayerPassFragmentShaderSources threw a non-standard exception.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned RuntimeSnapshotProvider::GetMaxTemporalHistoryFrames() const
|
||||
@@ -24,8 +75,8 @@ unsigned RuntimeSnapshotProvider::GetMaxTemporalHistoryFrames() const
|
||||
RuntimeSnapshotVersions RuntimeSnapshotProvider::GetVersions() const
|
||||
{
|
||||
RuntimeSnapshotVersions versions;
|
||||
versions.renderStateVersion = mRuntimeHost.GetRenderStateVersion();
|
||||
versions.parameterStateVersion = mRuntimeHost.GetParameterStateVersion();
|
||||
versions.renderStateVersion = mRuntimeHost.mRenderStateVersion.load(std::memory_order_relaxed);
|
||||
versions.parameterStateVersion = mRuntimeHost.mParameterStateVersion.load(std::memory_order_relaxed);
|
||||
return versions;
|
||||
}
|
||||
|
||||
@@ -46,12 +97,13 @@ RuntimeRenderFrameContext RuntimeSnapshotProvider::GetFrameContext() const
|
||||
|
||||
void RuntimeSnapshotProvider::AdvanceFrame()
|
||||
{
|
||||
mRuntimeHost.AdvanceFrame();
|
||||
++mRuntimeHost.mFrameCounter;
|
||||
}
|
||||
|
||||
bool RuntimeSnapshotProvider::TryAdvanceFrame()
|
||||
{
|
||||
return mRuntimeHost.TryAdvanceFrame();
|
||||
++mRuntimeHost.mFrameCounter;
|
||||
return true;
|
||||
}
|
||||
|
||||
RuntimeRenderStateSnapshot RuntimeSnapshotProvider::GetRenderStateSnapshot(unsigned outputWidth, unsigned outputHeight) const
|
||||
|
||||
Reference in New Issue
Block a user