mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-08 14:15:58 +00:00
Metal 1.x does not support swizzling on packed_vec types. Use array-index for single element selection (permitted on LHS and RHS of assignment) Cast the packed_vec to a vec for multiple element swizzles (not permitted as the LHS of an assignment). Fixed: tint:1249 Change-Id: I70cbb0c22a935b06b3905d24484bdc2edfb95fc2 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/67060 Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Ben Clayton <bclayton@google.com> Reviewed-by: James Price <jrprice@google.com>
27 lines
513 B
Plaintext
27 lines
513 B
Plaintext
#include <metal_stdlib>
|
|
|
|
using namespace metal;
|
|
|
|
template<typename T, int N, int M>
|
|
inline auto 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 auto operator*(packed_vec<T, M> lhs, matrix<T, N, M> rhs) {
|
|
return vec<T, M>(lhs) * rhs;
|
|
}
|
|
|
|
struct S {
|
|
/* 0x0000 */ packed_float3 v;
|
|
/* 0x000c */ int8_t tint_pad[4];
|
|
};
|
|
|
|
void f(device S& U) {
|
|
U.v = float3(1.0f, 2.0f, 3.0f);
|
|
U.v[0] = 1.0f;
|
|
U.v[1] = 2.0f;
|
|
U.v[2] = 3.0f;
|
|
}
|
|
|