Big code changes
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <sophia/types.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace sophia {
|
||||
|
||||
enum class ShaderStage { VERTEX, FRAGMENT, COMPUTE };
|
||||
|
||||
class Shader {
|
||||
public:
|
||||
class Builder;
|
||||
|
||||
Shader(const Shader&) = delete;
|
||||
Shader& operator=(const Shader&) = delete;
|
||||
|
||||
~Shader() = default;
|
||||
|
||||
const std::vector<u32>& getSpirv() const { return this->spirv; }
|
||||
ShaderStage getStage() const { return this->stage; }
|
||||
|
||||
private:
|
||||
Shader() = default;
|
||||
|
||||
void compile(const std::string& path, ShaderStage shaderStage);
|
||||
void load(const std::string& path, ShaderStage shaderStage);
|
||||
|
||||
ShaderStage stage;
|
||||
std::vector<u32> spirv;
|
||||
};
|
||||
|
||||
class Shader::Builder {
|
||||
public:
|
||||
Builder() = default;
|
||||
|
||||
Builder& fromGLSL(const std::string& path);
|
||||
Builder& fromSPIRV(const std::string& path);
|
||||
Builder& setStage(ShaderStage shaderStage);
|
||||
|
||||
std::unique_ptr<Shader> build();
|
||||
|
||||
private:
|
||||
std::string path;
|
||||
ShaderStage stage;
|
||||
bool stageSet = false;
|
||||
bool precompiled = false;
|
||||
};
|
||||
|
||||
} // namespace sophia
|
||||
Reference in New Issue
Block a user