Shader ownership change
All checks were successful
CI / React UI Build (push) Successful in 11s
CI / Native Windows Build And Tests (push) Successful in 2m52s
CI / Windows Release Package (push) Successful in 2m59s

This commit is contained in:
Aiden
2026-05-12 02:15:03 +10:00
parent 4ea829af85
commit c0d7e84495
12 changed files with 370 additions and 36 deletions

View File

@@ -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;
};
}