mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-10 05:57:51 +00:00
Update MSL generator to handle casts of packed types.
Currently in the MSL backend we cast int values to uint in order to get the correct WGSL behaviour for over/under flow. This fails in the case of host shareable buffers as they use `packed` types which need to get cast to the non-packed version first. Bug: tint:1677 Change-Id: I57b70abaa8ca614472a26d63f19c1aef2bd64668 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103986 Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
d1a5f93630
commit
2bcade246a
@@ -517,8 +517,18 @@ bool GeneratorImpl::EmitBinary(std::ostream& out, const ast::BinaryExpression* e
|
||||
ScopedParen sp(out);
|
||||
{
|
||||
ScopedBitCast lhs_uint_cast(this, out, lhs_type, unsigned_type_of(target_type));
|
||||
if (!EmitExpression(out, expr->lhs)) {
|
||||
return false;
|
||||
|
||||
// In case the type is packed, cast to our own type in order to remove the packing.
|
||||
// Otherwise, this just casts to itself.
|
||||
if (lhs_type->is_signed_integer_vector()) {
|
||||
ScopedBitCast lhs_self_cast(this, out, lhs_type, lhs_type);
|
||||
if (!EmitExpression(out, expr->lhs)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!EmitExpression(out, expr->lhs)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!emit_op()) {
|
||||
@@ -526,8 +536,18 @@ bool GeneratorImpl::EmitBinary(std::ostream& out, const ast::BinaryExpression* e
|
||||
}
|
||||
{
|
||||
ScopedBitCast rhs_uint_cast(this, out, rhs_type, unsigned_type_of(target_type));
|
||||
if (!EmitExpression(out, expr->rhs)) {
|
||||
return false;
|
||||
|
||||
// In case the type is packed, cast to our own type in order to remove the packing.
|
||||
// Otherwise, this just casts to itself.
|
||||
if (rhs_type->is_signed_integer_vector()) {
|
||||
ScopedBitCast rhs_self_cast(this, out, rhs_type, rhs_type);
|
||||
if (!EmitExpression(out, expr->rhs)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!EmitExpression(out, expr->rhs)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user