Shader: Replace const for with [unroll] attribute
This commit is contained in:
@@ -460,10 +460,10 @@ namespace Nz::ShaderAst
|
||||
|
||||
bool Compare(const ForEachStatement& lhs, const ForEachStatement& rhs)
|
||||
{
|
||||
if (!Compare(lhs.isConst, rhs.isConst))
|
||||
if (!Compare(lhs.varName, rhs.varName))
|
||||
return false;
|
||||
|
||||
if (!Compare(lhs.varName, rhs.varName))
|
||||
if (!Compare(lhs.unroll, rhs.unroll))
|
||||
return false;
|
||||
|
||||
if (!Compare(lhs.expression, rhs.expression))
|
||||
@@ -498,6 +498,9 @@ namespace Nz::ShaderAst
|
||||
|
||||
inline bool Compare(const WhileStatement& lhs, const WhileStatement& rhs)
|
||||
{
|
||||
if (!Compare(lhs.unroll, rhs.unroll))
|
||||
return false;
|
||||
|
||||
if (!Compare(lhs.condition, rhs.condition))
|
||||
return false;
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace Nz
|
||||
Layout, //< Struct layout (struct only) - has argument style
|
||||
Location, //< Location (struct member only) - has argument index
|
||||
Set, //< Binding set (external var only) - has argument index
|
||||
Unroll, //< Unroll (for/for each only) - has argument mode
|
||||
};
|
||||
|
||||
enum class BinaryType
|
||||
@@ -106,6 +107,13 @@ namespace Nz
|
||||
SampleTexture = 2,
|
||||
};
|
||||
|
||||
enum class LoopUnroll
|
||||
{
|
||||
Always,
|
||||
Hint,
|
||||
Never
|
||||
};
|
||||
|
||||
enum class MemoryLayout
|
||||
{
|
||||
Std140
|
||||
|
||||
@@ -345,11 +345,11 @@ namespace Nz::ShaderAst
|
||||
NodeType GetType() const override;
|
||||
void Visit(AstStatementVisitor& visitor) override;
|
||||
|
||||
AttributeValue<LoopUnroll> unroll;
|
||||
std::optional<std::size_t> varIndex;
|
||||
std::string varName;
|
||||
ExpressionPtr expression;
|
||||
StatementPtr statement;
|
||||
bool isConst = false;
|
||||
};
|
||||
|
||||
struct NAZARA_SHADER_API MultiStatement : Statement
|
||||
@@ -379,6 +379,7 @@ namespace Nz::ShaderAst
|
||||
NodeType GetType() const override;
|
||||
void Visit(AstStatementVisitor& visitor) override;
|
||||
|
||||
AttributeValue<LoopUnroll> unroll;
|
||||
ExpressionPtr condition;
|
||||
StatementPtr body;
|
||||
};
|
||||
|
||||
@@ -118,6 +118,8 @@ namespace Nz::ShaderAst
|
||||
|
||||
void SanitizeIdentifier(std::string& identifier);
|
||||
|
||||
void Validate(WhileStatement& node);
|
||||
|
||||
void Validate(AccessIndexExpression& node);
|
||||
void Validate(AssignExpression& node);
|
||||
void Validate(BinaryExpression& node);
|
||||
|
||||
Reference in New Issue
Block a user