8#include "spdlog/fmt/fmt.h"
33 if (!std::filesystem::exists(path))
38 std::ifstream file(path);
44 std::stringstream buffer;
45 buffer << file.rdbuf();
127 std::vector<Utils::ValidationError>
validate(
void)
const override
129 std::vector<Utils::ValidationError> errors;
132 errors.emplace_back(
"Shader source is not set",
"ShaderDescriptor",
135 if (!this->
_name.has_value())
137 errors.emplace_back(
"Shader name is not set ('Unnamed' will be used)",
"ShaderDescriptor",
142 errors.emplace_back(
"No vertex buffer layouts added",
"ShaderDescriptor",
147 errors.emplace_back(
"Vertex entry point is not set ('vs_main' will be used)",
"ShaderDescriptor",
152 errors.emplace_back(
"Fragment entry point is not set ('fs_main' will be used)",
"ShaderDescriptor",
158 for (
const auto &error : layoutErrors)
160 errors.emplace_back(error.message, fmt::format(
"ShaderDescriptor::({}){}", i, error.location),
167 for (
const auto &error : layoutErrors)
169 errors.emplace_back(error.message, fmt::format(
"ShaderDescriptor::({}){}", i, error.location),
176 for (
const auto &error : stateErrors)
178 errors.emplace_back(error.message, fmt::format(
"ShaderDescriptor::({}){}", i, error.location),
185 for (
const auto &error : stateErrors)
187 errors.emplace_back(error.message, fmt::format(
"ShaderDescriptor::DepthStencil{}", error.location),
const std::optional< std::string > & getShaderSource() const
Definition ShaderDescriptor.hpp:200
const std::string & getVertexEntryPoint() const
Definition ShaderDescriptor.hpp:206
const std::list< Utils::ColorTargetState > & getOutputColorFormats() const
Definition ShaderDescriptor.hpp:198
std::optional< std::string > _vertexEntryPoint
Definition ShaderDescriptor.hpp:224
const std::string & getName() const
Definition ShaderDescriptor.hpp:195
std::optional< std::string > _fragmentEntryPoint
Definition ShaderDescriptor.hpp:223
const std::list< Utils::BindGroupLayout > & getBindGroupLayouts() const
Definition ShaderDescriptor.hpp:196
ShaderDescriptor & setPrimitiveTopology(wgpu::PrimitiveTopology topology)
Definition ShaderDescriptor.hpp:102
wgpu::CullMode _cullMode
Definition ShaderDescriptor.hpp:227
ShaderDescriptor & setVertexEntryPoint(std::string_view entryPoint)
Definition ShaderDescriptor.hpp:50
ShaderDescriptor & setShaderFromFile(const std::filesystem::path &path)
Definition ShaderDescriptor.hpp:31
ShaderDescriptor & setName(std::string_view name)
Definition ShaderDescriptor.hpp:108
ShaderDescriptor & setCullMode(wgpu::CullMode mode)
Definition ShaderDescriptor.hpp:96
std::optional< Utils::DepthStencilState > _outputDepthFormat
Definition ShaderDescriptor.hpp:225
ShaderDescriptor & setFragmentEntryPoint(std::string_view entryPoint)
Definition ShaderDescriptor.hpp:56
Utils::VertexBufferLayout & getVertexBufferLayout(size_t index)
Definition ShaderDescriptor.hpp:68
static const std::string _DEFAULT_NAME
Definition ShaderDescriptor.hpp:216
static const std::string _DEFAULT_VERTEX_ENTRY_POINT
Definition ShaderDescriptor.hpp:215
static const std::string _DEFAULT_FRAGMENT_ENTRY_POINT
Definition ShaderDescriptor.hpp:214
ShaderDescriptor & addBindGroupLayout(const Utils::BindGroupLayout &layout)
Definition ShaderDescriptor.hpp:73
std::list< Utils::ColorTargetState > _outputColorFormats
Definition ShaderDescriptor.hpp:221
~ShaderDescriptor() override=default
ShaderDescriptor & addOutputColorFormat(const Utils::ColorTargetState &state)
Definition ShaderDescriptor.hpp:84
wgpu::PrimitiveTopology _primitiveTopology
Definition ShaderDescriptor.hpp:226
std::optional< std::string > _shaderSource
Definition ShaderDescriptor.hpp:222
std::list< Utils::VertexBufferLayout > _vertexBufferLayouts
Definition ShaderDescriptor.hpp:220
Utils::BindGroupLayout & getBindGroupLayout(size_t index)
Definition ShaderDescriptor.hpp:79
wgpu::CullMode getCullMode() const
Definition ShaderDescriptor.hpp:211
ShaderDescriptor()=default
wgpu::PrimitiveTopology getPrimitiveTopology() const
Definition ShaderDescriptor.hpp:210
std::vector< Utils::ValidationError > validate(void) const override
Validate the ShaderDescriptor and all contained layouts/states.
Definition ShaderDescriptor.hpp:127
const std::string & getFragmentEntryPoint() const
Definition ShaderDescriptor.hpp:201
const std::list< Utils::VertexBufferLayout > & getVertexBufferLayouts() const
Definition ShaderDescriptor.hpp:197
std::optional< std::string > _name
Definition ShaderDescriptor.hpp:218
ShaderDescriptor & addVertexBufferLayout(const Utils::VertexBufferLayout &layout)
Definition ShaderDescriptor.hpp:62
std::list< Utils::BindGroupLayout > _bindGroupLayouts
Definition ShaderDescriptor.hpp:219
ShaderDescriptor & setShader(std::string_view source)
Definition ShaderDescriptor.hpp:26
ShaderDescriptor & setOutputDepthFormat(const Utils::DepthStencilState &state)
Definition ShaderDescriptor.hpp:90
const std::optional< Utils::DepthStencilState > & getOutputDepthFormat() const
Definition ShaderDescriptor.hpp:199
Definition BindGroupLayout.hpp:13
Definition ColorTargetState.hpp:8
Definition DepthStencilState.hpp:8
Definition IValidable.hpp:26
Definition VertexBufferLayout.hpp:11
Definition AGPUBuffer.hpp:6
void Error(const T &msg) noexcept
Definition Logger.hpp:51
@ Warning
Definition IValidable.hpp:13
@ Error
Definition IValidable.hpp:14