diff --git a/src/tint/resolver/materialize_test.cc b/src/tint/resolver/materialize_test.cc index 2bd74cc7b7..bcb1671856 100644 --- a/src/tint/resolver/materialize_test.cc +++ b/src/tint/resolver/materialize_test.cc @@ -544,6 +544,12 @@ enum class Method { // min(abstract_expr, abstract_expr); kBuiltinArg, + // bitcast(abstract_expr); + kBitcastF32Arg, + + // bitcast>(abstract_expr); + kBitcastVec3F32Arg, + // array(); kArrayLength, @@ -562,6 +568,10 @@ static std::ostream& operator<<(std::ostream& o, Method m) { return o << "let"; case Method::kBuiltinArg: return o << "builtin-arg"; + case Method::kBitcastF32Arg: + return o << "bitcast-f32-arg"; + case Method::kBitcastVec3F32Arg: + return o << "bitcast-vec3-f32-arg"; case Method::kArrayLength: return o << "array-length"; case Method::kSwitch: @@ -632,6 +642,12 @@ TEST_P(MaterializeAbstractNumericToDefaultType, Test) { case Method::kBuiltinArg: WrapInFunction(CallStmt(Call("min", abstract_expr(), abstract_expr()))); break; + case Method::kBitcastF32Arg: + WrapInFunction(Bitcast(abstract_expr())); + break; + case Method::kBitcastVec3F32Arg: + WrapInFunction(Bitcast(ty.vec3(), abstract_expr())); + break; case Method::kArrayLength: WrapInFunction(Construct(ty.array(ty.i32(), abstract_expr()))); break; @@ -701,6 +717,7 @@ constexpr Method kScalarMethods[] = { Method::kLet, Method::kVar, Method::kBuiltinArg, + Method::kBitcastF32Arg, }; /// Methods that support vector materialization @@ -708,6 +725,7 @@ constexpr Method kVectorMethods[] = { Method::kLet, Method::kVar, Method::kBuiltinArg, + Method::kBitcastVec3F32Arg, }; /// Methods that support matrix materialization diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc index 9fdb576c90..807dc62370 100644 --- a/src/tint/resolver/resolver.cc +++ b/src/tint/resolver/resolver.cc @@ -1239,7 +1239,10 @@ sem::Expression* Resolver::IndexAccessor(const ast::IndexAccessorExpression* exp } sem::Expression* Resolver::Bitcast(const ast::BitcastExpression* expr) { - auto* inner = sem_.Get(expr->expr); + auto* inner = Materialize(sem_.Get(expr->expr)); + if (!inner) { + return nullptr; + } auto* ty = Type(expr->type); if (!ty) { return nullptr;