Skip to content

Commit

Permalink
ShaderAST: Implemented constant resolution for some intrinsics.
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonJoker committed Oct 19, 2023
1 parent e858a0f commit 77c1fb8
Show file tree
Hide file tree
Showing 8 changed files with 5,585 additions and 317 deletions.
2 changes: 1 addition & 1 deletion include/ShaderAST/Expr/ExprLiteral.inl
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ namespace ast::expr
, LhsTypeT const & lhs
, expr::Literal const & rhs )
{
return binCompOp< std::less_equal<> >( exprCache, typesCache, lhs, rhs );
return binCompOp< std::less<> >( exprCache, typesCache, lhs, rhs );
}
};

Expand Down
10 changes: 5 additions & 5 deletions source/ShaderAST/Expr/ExprCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ namespace ast::expr
, ExprPtr lhs
, ExprPtr rhs )
{
return makeExpr< Greater >( typesCache.getBool()
return makeExpr< Greater >( typesCache.getVector( type::Kind::eBoolean, type::getComponentCount( lhs->getType() ) )
, std::move( lhs )
, std::move( rhs ) );
}
Expand All @@ -298,7 +298,7 @@ namespace ast::expr
, ExprPtr lhs
, ExprPtr rhs )
{
return makeExpr< GreaterEqual >( typesCache.getBool()
return makeExpr< GreaterEqual >( typesCache.getVector( type::Kind::eBoolean, type::getComponentCount( lhs->getType() ) )
, std::move( lhs )
, std::move( rhs ) );
}
Expand Down Expand Up @@ -330,7 +330,7 @@ namespace ast::expr
, ExprPtr lhs
, ExprPtr rhs )
{
return makeExpr< Less >( typesCache.getBool()
return makeExpr< Less >( typesCache.getVector( type::Kind::eBoolean, type::getComponentCount( lhs->getType() ) )
, std::move( lhs )
, std::move( rhs ) );
}
Expand All @@ -339,7 +339,7 @@ namespace ast::expr
, ExprPtr lhs
, ExprPtr rhs )
{
return makeExpr< LessEqual >( typesCache.getBool()
return makeExpr< LessEqual >( typesCache.getVector( type::Kind::eBoolean, type::getComponentCount( lhs->getType() ) )
, std::move( lhs )
, std::move( rhs ) );
}
Expand Down Expand Up @@ -502,7 +502,7 @@ namespace ast::expr
, ExprPtr lhs
, ExprPtr rhs )
{
return makeExpr< NotEqual >( typesCache.getBool()
return makeExpr< NotEqual >( typesCache.getVector( type::Kind::eBoolean, type::getComponentCount( lhs->getType() ) )
, std::move( lhs )
, std::move( rhs ) );
}
Expand Down
28 changes: 24 additions & 4 deletions source/ShaderAST/ShaderAST.natvis
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@
<Item Name="rhs">m_rhs</Item>
</Expand>
</Type>
<Type Name="ast::expr::AggrInit">
<DisplayString Condition="m_identifier!=nullptr">{*m_identifier}({m_initialisers})</DisplayString>
<DisplayString Condition="m_identifier==nullptr">({m_initialisers})</DisplayString>
<Expand>
<Item Name="type">m_type</Item>
<Item Name="identifier">m_identifier</Item>
<Item Name="initialisers">m_initialisers</Item>
<Item Name="flags">m_flags</Item>
</Expand>
</Type>
<Type Name="ast::expr::BitAnd">
<DisplayString>{*m_lhs} &amp; {*m_rhs}</DisplayString>
<Expand>
Expand Down Expand Up @@ -539,8 +549,13 @@
</Type>
<Type Name="ast::expr::Literal">
<DisplayString Condition="m_valueType==ast::expr::LiteralType::eBool">{m_value.boolv}</DisplayString>
<DisplayString Condition="m_valueType==ast::expr::LiteralType::eInt">{m_value.intv}s</DisplayString>
<DisplayString Condition="m_valueType==ast::expr::LiteralType::eUInt">{m_value.uint32v}u</DisplayString>
<DisplayString Condition="m_valueType==ast::expr::LiteralType::eInt8">{m_value.int8v}s</DisplayString>
<DisplayString Condition="m_valueType==ast::expr::LiteralType::eInt16">{m_value.int16v}s</DisplayString>
<DisplayString Condition="m_valueType==ast::expr::LiteralType::eInt32">{m_value.int32v}s</DisplayString>
<DisplayString Condition="m_valueType==ast::expr::LiteralType::eInt64">{m_value.int64v}s</DisplayString>
<DisplayString Condition="m_valueType==ast::expr::LiteralType::eUInt8">{m_value.uint8v}ull</DisplayString>
<DisplayString Condition="m_valueType==ast::expr::LiteralType::eUInt16">{m_value.uint16v}ull</DisplayString>
<DisplayString Condition="m_valueType==ast::expr::LiteralType::eUInt32">{m_value.uint32v}ull</DisplayString>
<DisplayString Condition="m_valueType==ast::expr::LiteralType::eUInt64">{m_value.uint64v}ull</DisplayString>
<DisplayString Condition="m_valueType==ast::expr::LiteralType::eFloat">{m_value.floatv}f</DisplayString>
<DisplayString Condition="m_valueType==ast::expr::LiteralType::eDouble">{m_value.doublev}d</DisplayString>
Expand All @@ -551,8 +566,13 @@
<Item Name="valueType">m_valueType</Item>
<Item Name="value">m_value</Item>
<Item Name="value" Condition="m_valueType==ast::expr::LiteralType::eBool">m_value.boolv</Item>
<Item Name="value" Condition="m_valueType==ast::expr::LiteralType::eInt">m_value.intv</Item>
<Item Name="value" Condition="m_valueType==ast::expr::LiteralType::eUInt">m_value.uint32v</Item>
<Item Name="value" Condition="m_valueType==ast::expr::LiteralType::eInt8">m_value.int8v</Item>
<Item Name="value" Condition="m_valueType==ast::expr::LiteralType::eInt16">m_value.int16v</Item>
<Item Name="value" Condition="m_valueType==ast::expr::LiteralType::eInt32">m_value.int32v</Item>
<Item Name="value" Condition="m_valueType==ast::expr::LiteralType::eInt64">m_value.int64v</Item>
<Item Name="value" Condition="m_valueType==ast::expr::LiteralType::eUInt8">m_value.uint8v</Item>
<Item Name="value" Condition="m_valueType==ast::expr::LiteralType::eUInt16">m_value.uint16v</Item>
<Item Name="value" Condition="m_valueType==ast::expr::LiteralType::eUInt32">m_value.uint32v</Item>
<Item Name="value" Condition="m_valueType==ast::expr::LiteralType::eUInt64">m_value.uint64v</Item>
<Item Name="value" Condition="m_valueType==ast::expr::LiteralType::eFloat">m_value.floatv</Item>
<Item Name="value" Condition="m_valueType==ast::expr::LiteralType::eDouble">m_value.doublev</Item>
Expand Down
Loading

0 comments on commit 77c1fb8

Please sign in to comment.