tint/writer/msl: Move packed_vector hacks to transform

Attempting to paper over all the MSL standard library holes for packed_vector in the MSL writer added complexity to the writer, produced messy output, and didn't actually catch all the cases where casts were needed.

Add a new PackedVec3 transform that applies the packed_vector -> vec casts in a smarter, more precise way.

Fixed: tint:1534
Change-Id: I73ce7e5a62fbc9cb04e1093133070f5fb8965dce
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107340
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
This commit is contained in:
Ben Clayton
2022-10-27 14:36:49 +00:00
committed by Dawn LUCI CQ
parent 59c0982426
commit a92f4259d5
53 changed files with 1070 additions and 379 deletions

View File

@@ -2,16 +2,6 @@
using namespace metal;
template<typename T, int N, int M>
inline vec<T, M> operator*(matrix<T, N, M> lhs, packed_vec<T, N> rhs) {
return lhs * vec<T, N>(rhs);
}
template<typename T, int N, int M>
inline vec<T, N> operator*(packed_vec<T, M> lhs, matrix<T, N, M> rhs) {
return vec<T, M>(lhs) * rhs;
}
template<typename T, size_t N>
struct tint_array {
const constant T& operator[](size_t i) const constant { return elements[i]; }
@@ -44,11 +34,11 @@ struct S {
};
void tint_symbol_inner(uint idx, const constant S* const tint_symbol_1) {
int3 const a = (*(tint_symbol_1)).arr[idx].a;
int3 const a = int3((*(tint_symbol_1)).arr[idx].a);
int const b = (*(tint_symbol_1)).arr[idx].b;
uint3 const c = (*(tint_symbol_1)).arr[idx].c;
uint3 const c = uint3((*(tint_symbol_1)).arr[idx].c);
uint const d = (*(tint_symbol_1)).arr[idx].d;
float3 const e = (*(tint_symbol_1)).arr[idx].e;
float3 const e = float3((*(tint_symbol_1)).arr[idx].e);
float const f = (*(tint_symbol_1)).arr[idx].f;
int2 const g = (*(tint_symbol_1)).arr[idx].g;
int2 const h = (*(tint_symbol_1)).arr[idx].h;