pass 2
This commit is contained in:
@@ -4,8 +4,12 @@
|
||||
#include "GlRenderConstants.h"
|
||||
#include "PngScreenshotWriter.h"
|
||||
#include "RenderEngine.h"
|
||||
#include "RuntimeCoordinator.h"
|
||||
#include "RuntimeParameterUtils.h"
|
||||
#include "RuntimeServices.h"
|
||||
#include "RuntimeSnapshotProvider.h"
|
||||
#include "RuntimeStore.h"
|
||||
#include "RuntimeUpdateController.h"
|
||||
#include "ShaderBuildQueue.h"
|
||||
#include "VideoBackend.h"
|
||||
|
||||
@@ -46,6 +50,13 @@ OpenGLComposite::OpenGLComposite(HWND hWnd, HDC hDC, HGLRC hRC) :
|
||||
mVideoBackend = std::make_unique<VideoBackend>(*mRenderEngine, mRuntimeStore->GetHealthTelemetry());
|
||||
mShaderBuildQueue = std::make_unique<ShaderBuildQueue>(*mRuntimeSnapshotProvider);
|
||||
mRuntimeServices = std::make_unique<RuntimeServices>();
|
||||
mRuntimeUpdateController = std::make_unique<RuntimeUpdateController>(
|
||||
*mRuntimeStore,
|
||||
*mRuntimeCoordinator,
|
||||
*mRuntimeServices,
|
||||
*mRenderEngine,
|
||||
*mShaderBuildQueue,
|
||||
*mVideoBackend);
|
||||
}
|
||||
|
||||
OpenGLComposite::~OpenGLComposite()
|
||||
@@ -245,7 +256,7 @@ bool OpenGLComposite::InitOpenGLState()
|
||||
mRenderEngine->ResetTemporalHistoryState();
|
||||
mRenderEngine->ResetShaderFeedbackState();
|
||||
|
||||
broadcastRuntimeState();
|
||||
mRuntimeUpdateController->BroadcastRuntimeState();
|
||||
mRuntimeServices->BeginPolling(*mRuntimeCoordinator);
|
||||
return true;
|
||||
}
|
||||
@@ -273,7 +284,8 @@ bool OpenGLComposite::Stop()
|
||||
bool OpenGLComposite::ReloadShader(bool preserveFeedbackState)
|
||||
{
|
||||
return mRuntimeCoordinator &&
|
||||
ApplyRuntimeCoordinatorResult(mRuntimeCoordinator->RequestShaderReload(preserveFeedbackState));
|
||||
mRuntimeUpdateController &&
|
||||
mRuntimeUpdateController->ApplyRuntimeCoordinatorResult(mRuntimeCoordinator->RequestShaderReload(preserveFeedbackState));
|
||||
}
|
||||
|
||||
bool OpenGLComposite::RequestScreenshot(std::string& error)
|
||||
@@ -285,7 +297,8 @@ bool OpenGLComposite::RequestScreenshot(std::string& error)
|
||||
|
||||
void OpenGLComposite::renderEffect()
|
||||
{
|
||||
ProcessRuntimePollResults();
|
||||
if (mRuntimeUpdateController)
|
||||
mRuntimeUpdateController->ProcessRuntimeWork();
|
||||
std::vector<RuntimeServices::AppliedOscUpdate> appliedOscUpdates;
|
||||
std::vector<RuntimeServices::CompletedOscCommit> completedOscCommits;
|
||||
if (mRuntimeServices)
|
||||
@@ -400,105 +413,7 @@ std::filesystem::path OpenGLComposite::BuildScreenshotPath() const
|
||||
return root / "screenshots" / filename.str();
|
||||
}
|
||||
|
||||
bool OpenGLComposite::ProcessRuntimePollResults()
|
||||
{
|
||||
if (!mRuntimeServices)
|
||||
return true;
|
||||
|
||||
bool shaderBuildRequested = false;
|
||||
std::vector<RuntimeCoordinatorServiceResult> serviceResults;
|
||||
mRuntimeServices->ConsumeRuntimeCoordinatorResults(serviceResults);
|
||||
for (const RuntimeCoordinatorServiceResult& serviceResult : serviceResults)
|
||||
{
|
||||
shaderBuildRequested = shaderBuildRequested || serviceResult.result.shaderBuildRequested;
|
||||
ApplyRuntimeCoordinatorResult(serviceResult.result);
|
||||
if (serviceResult.failed)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!shaderBuildRequested)
|
||||
{
|
||||
if (!mShaderBuildQueue || !mRenderEngine)
|
||||
return true;
|
||||
|
||||
const RenderEngine::PreparedShaderBuildApplyResult buildResult = mRenderEngine->TryApplyReadyShaderBuild(
|
||||
*mShaderBuildQueue,
|
||||
mVideoBackend->InputFrameWidth(),
|
||||
mVideoBackend->InputFrameHeight(),
|
||||
mRuntimeCoordinator && mRuntimeCoordinator->PreserveFeedbackOnNextShaderBuild());
|
||||
if (!buildResult.hadReadyBuild)
|
||||
return true;
|
||||
|
||||
if (!buildResult.applied)
|
||||
{
|
||||
ApplyRuntimeCoordinatorResult(mRuntimeCoordinator->HandlePreparedShaderBuildFailure(buildResult.errorMessage));
|
||||
return false;
|
||||
}
|
||||
|
||||
ApplyRuntimeCoordinatorResult(mRuntimeCoordinator->HandlePreparedShaderBuildSuccess());
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenGLComposite::RequestShaderBuild()
|
||||
{
|
||||
if (!mShaderBuildQueue || !mVideoBackend)
|
||||
return;
|
||||
|
||||
mShaderBuildQueue->RequestBuild(mVideoBackend->InputFrameWidth(), mVideoBackend->InputFrameHeight());
|
||||
}
|
||||
|
||||
bool OpenGLComposite::ApplyRuntimeCoordinatorResult(const RuntimeCoordinatorResult& result, std::string* error)
|
||||
{
|
||||
if (!result.accepted)
|
||||
{
|
||||
if (error)
|
||||
*error = result.errorMessage;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (result.compileStatusChanged && mRuntimeStore)
|
||||
mRuntimeStore->SetCompileStatus(result.compileStatusSucceeded, result.compileStatusMessage);
|
||||
|
||||
if (result.clearReloadRequest && mRuntimeStore)
|
||||
mRuntimeStore->ClearReloadRequest();
|
||||
|
||||
if (mRuntimeCoordinator)
|
||||
mRuntimeCoordinator->ApplyCommittedStateMode(result.committedStateMode);
|
||||
|
||||
if (result.clearTransientOscState)
|
||||
{
|
||||
if (mRenderEngine)
|
||||
mRenderEngine->ClearOscOverlayState();
|
||||
if (mRuntimeServices)
|
||||
mRuntimeServices->ClearOscState();
|
||||
}
|
||||
|
||||
if (mRenderEngine)
|
||||
mRenderEngine->ApplyRuntimeCoordinatorRenderReset(result.renderResetScope);
|
||||
|
||||
if (result.shaderBuildRequested)
|
||||
RequestShaderBuild();
|
||||
|
||||
if (result.runtimeStateBroadcastRequired)
|
||||
broadcastRuntimeState();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenGLComposite::broadcastRuntimeState()
|
||||
{
|
||||
if (mRuntimeServices)
|
||||
mRuntimeServices->BroadcastState();
|
||||
}
|
||||
|
||||
bool OpenGLComposite::CheckOpenGLExtensions()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user