Shader ownership change
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "AppConfig.h"
|
||||
#include "../runtime/RuntimeSlangShaderCompiler.h"
|
||||
#include "../telemetry/TelemetryPrinter.h"
|
||||
#include "../video/DeckLinkOutput.h"
|
||||
#include "../video/DeckLinkOutputThread.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <type_traits>
|
||||
@@ -78,6 +80,7 @@ public:
|
||||
Stop();
|
||||
return false;
|
||||
}
|
||||
StartRuntimeShaderBuild();
|
||||
|
||||
if (!mFrameExchange.WaitForCompletedDepth(mConfig.warmupCompletedFrames, mConfig.warmupTimeout))
|
||||
{
|
||||
@@ -116,6 +119,7 @@ public:
|
||||
mTelemetry.Stop();
|
||||
mOutputThread.Stop();
|
||||
mOutput.Stop();
|
||||
StopRuntimeShaderBuild();
|
||||
mRenderThread.Stop();
|
||||
mOutput.ReleaseResources();
|
||||
mStarted = false;
|
||||
@@ -137,12 +141,47 @@ private:
|
||||
return false;
|
||||
}
|
||||
|
||||
void StartRuntimeShaderBuild()
|
||||
{
|
||||
mShaderCompiler.StartHappyAccidentBuild();
|
||||
mShaderBridgeStopping = false;
|
||||
mShaderBridgeThread = std::thread([this]() { ShaderBridgeMain(); });
|
||||
}
|
||||
|
||||
void StopRuntimeShaderBuild()
|
||||
{
|
||||
mShaderBridgeStopping = true;
|
||||
if (mShaderBridgeThread.joinable())
|
||||
mShaderBridgeThread.join();
|
||||
mShaderCompiler.Stop();
|
||||
}
|
||||
|
||||
void ShaderBridgeMain()
|
||||
{
|
||||
while (!mShaderBridgeStopping)
|
||||
{
|
||||
RuntimeSlangShaderBuild build;
|
||||
if (mShaderCompiler.TryConsume(build))
|
||||
{
|
||||
if (build.succeeded)
|
||||
mRenderThread.SubmitRuntimeShaderArtifact(build.artifact);
|
||||
else
|
||||
std::cout << "Runtime Slang build failed: " << build.message << "\n";
|
||||
return;
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||
}
|
||||
}
|
||||
|
||||
RenderThread& mRenderThread;
|
||||
SystemFrameExchange& mFrameExchange;
|
||||
AppConfig mConfig;
|
||||
DeckLinkOutput mOutput;
|
||||
DeckLinkOutputThread<SystemFrameExchange> mOutputThread;
|
||||
TelemetryPrinter mTelemetry;
|
||||
RuntimeSlangShaderCompiler mShaderCompiler;
|
||||
std::thread mShaderBridgeThread;
|
||||
std::atomic<bool> mShaderBridgeStopping{ false };
|
||||
bool mStarted = false;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user