tint/resolver: Materialize argument to bitcast

Bug: tint:1504
Change-Id: I4eb4f041e69154dccd9719746a30dd6963dcd252
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91846
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ben Clayton 2022-05-28 07:09:17 +00:00 committed by Dawn LUCI CQ
parent 3a236c6c51
commit 8c7ffbd9d5
2 changed files with 22 additions and 1 deletions

View File

@ -544,6 +544,12 @@ enum class Method {
// min(abstract_expr, abstract_expr);
kBuiltinArg,
// bitcast<f32>(abstract_expr);
kBitcastF32Arg,
// bitcast<vec3<f32>>(abstract_expr);
kBitcastVec3F32Arg,
// array<i32, abstract_expr>();
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<f32>(abstract_expr()));
break;
case Method::kBitcastVec3F32Arg:
WrapInFunction(Bitcast(ty.vec3<f32>(), 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

View File

@ -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;