Shader: Many fixes
This commit is contained in:
@@ -20,8 +20,13 @@ namespace Nz::ShaderAst
|
||||
|
||||
struct Module
|
||||
{
|
||||
struct Metadata
|
||||
{
|
||||
UInt32 shaderLangVersion;
|
||||
};
|
||||
|
||||
std::shared_ptr<const Metadata> metadata;
|
||||
MultiStatementPtr rootNode;
|
||||
UInt32 shaderLangVersion;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ namespace Nz
|
||||
struct EntryAttribute;
|
||||
struct LayoutAttribute;
|
||||
struct LocationAttribute;
|
||||
struct NzslAttribute;
|
||||
struct SetAttribute;
|
||||
struct UnrollAttribute;
|
||||
|
||||
@@ -76,7 +75,6 @@ namespace Nz
|
||||
void AppendAttribute(EntryAttribute entry);
|
||||
void AppendAttribute(LayoutAttribute layout);
|
||||
void AppendAttribute(LocationAttribute location);
|
||||
void AppendAttribute(NzslAttribute nzslVersion);
|
||||
void AppendAttribute(SetAttribute set);
|
||||
void AppendAttribute(UnrollAttribute unroll);
|
||||
void AppendCommentSection(const std::string& section);
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Nz::ShaderBuilder
|
||||
|
||||
struct DeclareStruct
|
||||
{
|
||||
inline std::unique_ptr<ShaderAst::DeclareStructStatement> operator()(ShaderAst::StructDescription description) const;
|
||||
inline std::unique_ptr<ShaderAst::DeclareStructStatement> operator()(ShaderAst::StructDescription description, ShaderAst::ExpressionValue<bool> isExported) const;
|
||||
};
|
||||
|
||||
struct DeclareVariable
|
||||
|
||||
@@ -189,6 +189,7 @@ namespace Nz::ShaderBuilder
|
||||
case ShaderAst::PrimitiveType::Float32: return ShaderBuilder::Constant(SafeCast<float>(value));
|
||||
case ShaderAst::PrimitiveType::Int32: return ShaderBuilder::Constant(SafeCast<Int32>(value));
|
||||
case ShaderAst::PrimitiveType::UInt32: return ShaderBuilder::Constant(SafeCast<UInt32>(value));
|
||||
case ShaderAst::PrimitiveType::String: return ShaderBuilder::Constant(value);
|
||||
}
|
||||
|
||||
throw std::runtime_error("unexpected primitive type");
|
||||
@@ -269,10 +270,11 @@ namespace Nz::ShaderBuilder
|
||||
return declareOptionNode;
|
||||
}
|
||||
|
||||
inline std::unique_ptr<ShaderAst::DeclareStructStatement> Impl::DeclareStruct::operator()(ShaderAst::StructDescription description) const
|
||||
inline std::unique_ptr<ShaderAst::DeclareStructStatement> Impl::DeclareStruct::operator()(ShaderAst::StructDescription description, ShaderAst::ExpressionValue<bool> isExported) const
|
||||
{
|
||||
auto declareStructNode = std::make_unique<ShaderAst::DeclareStructStatement>();
|
||||
declareStructNode->description = std::move(description);
|
||||
declareStructNode->isExported = std::move(isExported);
|
||||
|
||||
return declareStructNode;
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ namespace Nz::ShaderLang
|
||||
const Token& Peek(std::size_t advance = 0);
|
||||
|
||||
std::vector<ShaderAst::ExprValue> ParseAttributes();
|
||||
void ParseModuleStatement(std::vector<ShaderAst::ExprValue> attributes);
|
||||
void ParseVariableDeclaration(std::string& name, ShaderAst::ExpressionValue<ShaderAst::ExpressionType>& type, ShaderAst::ExpressionPtr& initialValue);
|
||||
|
||||
// Statements
|
||||
@@ -93,7 +94,6 @@ namespace Nz::ShaderLang
|
||||
std::vector<ShaderAst::StatementPtr> ParseFunctionBody();
|
||||
ShaderAst::StatementPtr ParseFunctionDeclaration(std::vector<ShaderAst::ExprValue> attributes = {});
|
||||
ShaderAst::DeclareFunctionStatement::Parameter ParseFunctionParameter();
|
||||
void ParseModuleStatement(std::vector<ShaderAst::ExprValue> attributes);
|
||||
ShaderAst::StatementPtr ParseOptionDeclaration();
|
||||
ShaderAst::StatementPtr ParseReturnStatement();
|
||||
ShaderAst::StatementPtr ParseRootStatement(std::vector<ShaderAst::ExprValue> attributes = {});
|
||||
|
||||
Reference in New Issue
Block a user