Fix a lot of small bugs/warnings
This commit is contained in:
@@ -206,21 +206,6 @@ namespace Nz::ShaderAst
|
||||
else if (IsPrimitiveType(exprType) || IsVectorType(exprType))
|
||||
{
|
||||
// Swizzle expression
|
||||
PrimitiveType baseType;
|
||||
std::size_t componentCount;
|
||||
|
||||
if (IsVectorType(exprType))
|
||||
{
|
||||
const VectorType& swizzledVec = std::get<VectorType>(exprType);
|
||||
baseType = swizzledVec.type;
|
||||
componentCount = swizzledVec.componentCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
baseType = std::get<PrimitiveType>(exprType);
|
||||
componentCount = 1;
|
||||
}
|
||||
|
||||
std::size_t swizzleComponentCount = identifier.size();
|
||||
if (swizzleComponentCount > 4)
|
||||
throw AstError{ "cannot swizzle more than four elements" };
|
||||
@@ -239,6 +224,12 @@ namespace Nz::ShaderAst
|
||||
// Use a Cast expression to replace swizzle
|
||||
indexedExpr = CacheResult(std::move(indexedExpr)); //< Since we are going to use a value multiple times, cache it if required
|
||||
|
||||
PrimitiveType baseType;
|
||||
if (IsVectorType(exprType))
|
||||
baseType = std::get<VectorType>(exprType).type;
|
||||
else
|
||||
baseType = std::get<PrimitiveType>(exprType);
|
||||
|
||||
auto cast = std::make_unique<CastExpression>();
|
||||
cast->targetType = VectorType{ swizzleComponentCount, baseType };
|
||||
for (std::size_t j = 0; j < swizzleComponentCount; ++j)
|
||||
|
||||
@@ -1023,6 +1023,7 @@ namespace Nz
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ShaderAst::UnaryType::Plus:
|
||||
|
||||
@@ -134,7 +134,9 @@ namespace Nz
|
||||
const auto& expressionType = GetExpressionType(*node.expression);
|
||||
assert(IsVectorType(expressionType));
|
||||
|
||||
SwizzledPointer swizzledPointer{ pointer };
|
||||
SwizzledPointer swizzledPointer;
|
||||
swizzledPointer.pointerId = pointer.pointerId;
|
||||
swizzledPointer.storage = pointer.storage;
|
||||
swizzledPointer.swizzledType = std::get<ShaderAst::VectorType>(expressionType);
|
||||
swizzledPointer.componentCount = node.componentCount;
|
||||
swizzledPointer.swizzleIndices = node.components;
|
||||
|
||||
Reference in New Issue
Block a user