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