40 lines
968 B
C++
40 lines
968 B
C++
#pragma once
|
|
|
|
#include "RuntimeShaderArtifact.h"
|
|
|
|
#include <atomic>
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <thread>
|
|
|
|
struct RuntimeSlangShaderBuild
|
|
{
|
|
bool available = false;
|
|
bool succeeded = false;
|
|
RuntimeShaderArtifact artifact;
|
|
std::string message;
|
|
};
|
|
|
|
class RuntimeSlangShaderCompiler
|
|
{
|
|
public:
|
|
RuntimeSlangShaderCompiler() = default;
|
|
RuntimeSlangShaderCompiler(const RuntimeSlangShaderCompiler&) = delete;
|
|
RuntimeSlangShaderCompiler& operator=(const RuntimeSlangShaderCompiler&) = delete;
|
|
~RuntimeSlangShaderCompiler();
|
|
|
|
void StartHappyAccidentBuild();
|
|
void StartShaderBuild(const std::string& shaderId);
|
|
void Stop();
|
|
bool TryConsume(RuntimeSlangShaderBuild& build);
|
|
bool Running() const { return mRunning.load(std::memory_order_acquire); }
|
|
|
|
private:
|
|
RuntimeSlangShaderBuild BuildShader(const std::string& shaderId) const;
|
|
|
|
std::thread mThread;
|
|
std::atomic<bool> mRunning{ false };
|
|
std::mutex mMutex;
|
|
RuntimeSlangShaderBuild mReadyBuild;
|
|
};
|