Phase 3 refactor in progress
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "RuntimeCoordinator.h"
|
||||
#include "RuntimeEventDispatcher.h"
|
||||
#include "RuntimeParameterUtils.h"
|
||||
#include "RuntimeServiceLiveBridge.h"
|
||||
#include "RuntimeServices.h"
|
||||
#include "RuntimeSnapshotProvider.h"
|
||||
#include "RuntimeStore.h"
|
||||
@@ -302,61 +303,30 @@ void OpenGLComposite::renderEffect()
|
||||
{
|
||||
if (mRuntimeUpdateController)
|
||||
mRuntimeUpdateController->ProcessRuntimeWork();
|
||||
std::vector<RuntimeServices::AppliedOscUpdate> appliedOscUpdates;
|
||||
std::vector<RuntimeServices::CompletedOscCommit> completedOscCommits;
|
||||
if (mRuntimeServices)
|
||||
{
|
||||
std::string oscError;
|
||||
if (!mRuntimeServices->ApplyPendingOscUpdates(appliedOscUpdates, oscError) && !oscError.empty())
|
||||
OutputDebugStringA(("OSC apply failed: " + oscError + "\n").c_str());
|
||||
mRuntimeServices->ConsumeCompletedOscCommits(completedOscCommits);
|
||||
}
|
||||
|
||||
std::vector<RenderEngine::OscOverlayUpdate> overlayUpdates;
|
||||
overlayUpdates.reserve(appliedOscUpdates.size());
|
||||
for (const RuntimeServices::AppliedOscUpdate& update : appliedOscUpdates)
|
||||
{
|
||||
overlayUpdates.push_back({ update.routeKey, update.layerKey, update.parameterKey, update.targetValue });
|
||||
}
|
||||
|
||||
std::vector<RenderEngine::OscOverlayCommitCompletion> overlayCommitCompletions;
|
||||
overlayCommitCompletions.reserve(completedOscCommits.size());
|
||||
for (const RuntimeServices::CompletedOscCommit& completedCommit : completedOscCommits)
|
||||
{
|
||||
overlayCommitCompletions.push_back({ completedCommit.routeKey, completedCommit.generation });
|
||||
}
|
||||
|
||||
if (mRenderEngine)
|
||||
mRenderEngine->UpdateOscOverlayState(overlayUpdates, overlayCommitCompletions);
|
||||
|
||||
const bool hasInputSource = mVideoBackend->HasInputSource();
|
||||
std::vector<RuntimeRenderState> layerStates;
|
||||
std::vector<RenderEngine::OscOverlayCommitRequest> overlayCommitRequests;
|
||||
const double smoothing = mRuntimeStore ? mRuntimeStore->GetConfiguredOscSmoothing() : 0.0;
|
||||
mRenderEngine->ResolveRenderLayerStates(
|
||||
mRuntimeCoordinator && mRuntimeCoordinator->UseCommittedLayerStates(),
|
||||
mVideoBackend->InputFrameWidth(),
|
||||
mVideoBackend->InputFrameHeight(),
|
||||
smoothing,
|
||||
&overlayCommitRequests,
|
||||
layerStates);
|
||||
if (mRuntimeServices)
|
||||
{
|
||||
for (const RenderEngine::OscOverlayCommitRequest& commitRequest : overlayCommitRequests)
|
||||
{
|
||||
std::string commitError;
|
||||
if (!mRuntimeServices->QueueOscCommit(
|
||||
commitRequest.routeKey,
|
||||
commitRequest.layerKey,
|
||||
commitRequest.parameterKey,
|
||||
commitRequest.value,
|
||||
commitRequest.generation,
|
||||
commitError) &&
|
||||
!commitError.empty())
|
||||
{
|
||||
OutputDebugStringA(("OSC commit queue failed: " + commitError + "\n").c_str());
|
||||
}
|
||||
}
|
||||
RuntimeServiceLiveBridge::PrepareLiveRenderLayerStates(
|
||||
*mRuntimeServices,
|
||||
*mRenderEngine,
|
||||
mRuntimeCoordinator && mRuntimeCoordinator->UseCommittedLayerStates(),
|
||||
mVideoBackend->InputFrameWidth(),
|
||||
mVideoBackend->InputFrameHeight(),
|
||||
smoothing,
|
||||
layerStates);
|
||||
}
|
||||
else
|
||||
{
|
||||
mRenderEngine->ResolveRenderLayerStates(
|
||||
mRuntimeCoordinator && mRuntimeCoordinator->UseCommittedLayerStates(),
|
||||
mVideoBackend->InputFrameWidth(),
|
||||
mVideoBackend->InputFrameHeight(),
|
||||
smoothing,
|
||||
nullptr,
|
||||
layerStates);
|
||||
}
|
||||
const unsigned historyCap = mRuntimeStore ? mRuntimeStore->GetConfiguredMaxTemporalHistoryFrames() : 0;
|
||||
mRenderEngine->RenderLayerStack(
|
||||
|
||||
@@ -259,8 +259,7 @@ bool RenderEngine::ResolveRenderLayerStates(
|
||||
layerStates.clear();
|
||||
if (useCommittedLayerStates)
|
||||
{
|
||||
layerStates = mShaderPrograms.CommittedLayerStates();
|
||||
ApplyOscOverlays(layerStates, false, oscSmoothing, commitRequests);
|
||||
layerStates = ComposeRenderLayerStates(mShaderPrograms.CommittedLayerStates(), false, oscSmoothing, commitRequests);
|
||||
mRuntimeSnapshotProvider.RefreshDynamicRenderStateFields(layerStates);
|
||||
return true;
|
||||
}
|
||||
@@ -281,12 +280,12 @@ bool RenderEngine::ResolveRenderLayerStates(
|
||||
renderSnapshot.versions.parameterStateVersion = mCachedParameterStateVersion;
|
||||
renderSnapshot.states = mCachedLayerRenderStates;
|
||||
|
||||
ApplyOscOverlays(renderSnapshot.states, true, oscSmoothing, commitRequests);
|
||||
renderSnapshot.states = ComposeRenderLayerStates(renderSnapshot.states, true, oscSmoothing, commitRequests);
|
||||
if (mCachedParameterStateVersion != versions.parameterStateVersion &&
|
||||
mRuntimeSnapshotProvider.TryRefreshPublishedSnapshotParameters(renderSnapshot))
|
||||
{
|
||||
mCachedParameterStateVersion = renderSnapshot.versions.parameterStateVersion;
|
||||
ApplyOscOverlays(renderSnapshot.states, true, oscSmoothing, commitRequests);
|
||||
renderSnapshot.states = ComposeRenderLayerStates(renderSnapshot.states, true, oscSmoothing, commitRequests);
|
||||
}
|
||||
|
||||
mCachedLayerRenderStates = renderSnapshot.states;
|
||||
@@ -303,36 +302,38 @@ bool RenderEngine::ResolveRenderLayerStates(
|
||||
mCachedParameterStateVersion = renderSnapshot.versions.parameterStateVersion;
|
||||
mCachedRenderStateWidth = renderSnapshot.outputWidth;
|
||||
mCachedRenderStateHeight = renderSnapshot.outputHeight;
|
||||
ApplyOscOverlays(mCachedLayerRenderStates, true, oscSmoothing, commitRequests);
|
||||
mCachedLayerRenderStates = ComposeRenderLayerStates(mCachedLayerRenderStates, true, oscSmoothing, commitRequests);
|
||||
layerStates = mCachedLayerRenderStates;
|
||||
return true;
|
||||
}
|
||||
|
||||
ApplyOscOverlays(mCachedLayerRenderStates, true, oscSmoothing, commitRequests);
|
||||
layerStates = mCachedLayerRenderStates;
|
||||
layerStates = ComposeRenderLayerStates(mCachedLayerRenderStates, true, oscSmoothing, commitRequests);
|
||||
mRuntimeSnapshotProvider.RefreshDynamicRenderStateFields(layerStates);
|
||||
return !layerStates.empty();
|
||||
}
|
||||
|
||||
void RenderEngine::ApplyOscOverlays(
|
||||
std::vector<RuntimeRenderState>& states,
|
||||
std::vector<RuntimeRenderState> RenderEngine::ComposeRenderLayerStates(
|
||||
const std::vector<RuntimeRenderState>& baseStates,
|
||||
bool allowCommit,
|
||||
double smoothing,
|
||||
std::vector<OscOverlayCommitRequest>* commitRequests)
|
||||
{
|
||||
std::vector<RuntimeLiveOscCommitRequest> liveCommitRequests;
|
||||
RuntimeLiveStateApplyOptions options;
|
||||
options.allowCommit = allowCommit;
|
||||
options.smoothing = smoothing;
|
||||
options.commitDelay = kOscOverlayCommitDelay;
|
||||
options.now = std::chrono::steady_clock::now();
|
||||
mRuntimeLiveState.ApplyToLayerStates(states, options, commitRequests ? &liveCommitRequests : nullptr);
|
||||
RenderStateCompositionInput input;
|
||||
input.baseLayerStates = &baseStates;
|
||||
input.liveState = &mRuntimeLiveState;
|
||||
input.allowLiveCommits = allowCommit;
|
||||
input.collectLiveCommitRequests = commitRequests != nullptr;
|
||||
input.liveSmoothing = smoothing;
|
||||
input.liveCommitDelay = kOscOverlayCommitDelay;
|
||||
input.now = std::chrono::steady_clock::now();
|
||||
const RenderStateCompositionResult result = mRenderStateComposer.BuildFrameState(input);
|
||||
|
||||
if (!commitRequests)
|
||||
return;
|
||||
return result.layerStates;
|
||||
|
||||
for (const RuntimeLiveOscCommitRequest& request : liveCommitRequests)
|
||||
for (const RuntimeLiveOscCommitRequest& request : result.commitRequests)
|
||||
commitRequests->push_back({ request.routeKey, request.layerKey, request.parameterKey, request.value, request.generation });
|
||||
return result.layerStates;
|
||||
}
|
||||
|
||||
void RenderEngine::RenderLayerStack(
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
#include "OpenGLRenderPipeline.h"
|
||||
#include "OpenGLRenderer.h"
|
||||
#include "OpenGLShaderPrograms.h"
|
||||
#include "RenderStateComposer.h"
|
||||
#include "HealthTelemetry.h"
|
||||
#include "RuntimeCoordinator.h"
|
||||
#include "RuntimeLiveState.h"
|
||||
#include "RuntimeSnapshotProvider.h"
|
||||
|
||||
#include <windows.h>
|
||||
@@ -133,8 +133,8 @@ private:
|
||||
HDC mHdc;
|
||||
HGLRC mHglrc;
|
||||
|
||||
void ApplyOscOverlays(
|
||||
std::vector<RuntimeRenderState>& states,
|
||||
std::vector<RuntimeRenderState> ComposeRenderLayerStates(
|
||||
const std::vector<RuntimeRenderState>& baseStates,
|
||||
bool allowCommit,
|
||||
double smoothing,
|
||||
std::vector<OscOverlayCommitRequest>* commitRequests);
|
||||
@@ -145,5 +145,6 @@ private:
|
||||
unsigned mCachedRenderStateWidth = 0;
|
||||
unsigned mCachedRenderStateHeight = 0;
|
||||
std::chrono::steady_clock::time_point mLastPreviewPresentTime;
|
||||
RenderStateComposer mRenderStateComposer;
|
||||
RuntimeLiveState mRuntimeLiveState;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user