dawn-cmake/test/tint/expressions/swizzle/read/packed_vec3/i32.wgsl.expected.msl

150 lines
6.0 KiB
Plaintext
Raw Normal View History

#include <metal_stdlib>
using namespace metal;
template<typename T, size_t N>
struct tint_array {
const constant T& operator[](size_t i) const constant { return elements[i]; }
device T& operator[](size_t i) device { return elements[i]; }
const device T& operator[](size_t i) const device { return elements[i]; }
thread T& operator[](size_t i) thread { return elements[i]; }
const thread T& operator[](size_t i) const thread { return elements[i]; }
threadgroup T& operator[](size_t i) threadgroup { return elements[i]; }
const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; }
T elements[N];
};
tint/msl: Preserve trailing vec3 padding In order to preserve padding properly for MSL, we need to use its packed_vec type for all vec3 types in storage buffers, not just struct members. This commit includes a complete rewrite of the PackedVec3 transform to achieve this. The key details are: * An internal `__packed_vec3<>` type was added, which corresponds to a `type::Vector` with an additional flag to indicate that it will be emitted as packed vector. * The `PackedVec3` transform replaces all vec3 types used in host-shareable address spaces with the internal `__packed_vec3` type. This includes vec3 types that appear as the store type of a pointer. * When used as an array element, these `__packed_vec3` types are wrapped in a struct that contains a single `__packed_vec3` member. This allows us to add an `@align()` attribute that ensures that `array<vec3<T>>` still has the correct array element stride. * When the `vec3<T>` appears as a struct member in the input program, we apply the `@align()` to that member to ensure that we do not change its offset. * Matrix types with three rows that are used in memory are replaced with an array of columns, where each column uses a `__packed_vec3` inside an aligned wrapper structure as above. * Accesses to host-shareable memory that involve any of these types invoke a "pack" or "unpack" helper function to convert them to the equivalent type that uses `__packed_vec3` or a regular `vec3` as required. * The `chromium_internal_relaxed_uniform_layout` extension is used to avoid issues where modifying a type in the uniform address space triggers stricter layout validation rules. Bug: tint:1571 Fixed: tint:1837 Change-Id: Idaf2da2f5bcb2be00c85ec657edfb614186476bb Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121200 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-27 20:21:03 +00:00
struct S_tint_packed_vec3 {
/* 0x0000 */ packed_int3 v;
/* 0x000c */ tint_array<int8_t, 4> tint_pad;
};
tint/msl: Preserve trailing vec3 padding In order to preserve padding properly for MSL, we need to use its packed_vec type for all vec3 types in storage buffers, not just struct members. This commit includes a complete rewrite of the PackedVec3 transform to achieve this. The key details are: * An internal `__packed_vec3<>` type was added, which corresponds to a `type::Vector` with an additional flag to indicate that it will be emitted as packed vector. * The `PackedVec3` transform replaces all vec3 types used in host-shareable address spaces with the internal `__packed_vec3` type. This includes vec3 types that appear as the store type of a pointer. * When used as an array element, these `__packed_vec3` types are wrapped in a struct that contains a single `__packed_vec3` member. This allows us to add an `@align()` attribute that ensures that `array<vec3<T>>` still has the correct array element stride. * When the `vec3<T>` appears as a struct member in the input program, we apply the `@align()` to that member to ensure that we do not change its offset. * Matrix types with three rows that are used in memory are replaced with an array of columns, where each column uses a `__packed_vec3` inside an aligned wrapper structure as above. * Accesses to host-shareable memory that involve any of these types invoke a "pack" or "unpack" helper function to convert them to the equivalent type that uses `__packed_vec3` or a regular `vec3` as required. * The `chromium_internal_relaxed_uniform_layout` extension is used to avoid issues where modifying a type in the uniform address space triggers stricter layout validation rules. Bug: tint:1571 Fixed: tint:1837 Change-Id: Idaf2da2f5bcb2be00c85ec657edfb614186476bb Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121200 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
2023-02-27 20:21:03 +00:00
struct S {
int3 v;
};
void f(const constant S_tint_packed_vec3* const tint_symbol) {
int3 v = int3((*(tint_symbol)).v);
int x = (*(tint_symbol)).v[0];
int y = (*(tint_symbol)).v[1];
int z = (*(tint_symbol)).v[2];
int2 xx = int3((*(tint_symbol)).v).xx;
int2 xy = int3((*(tint_symbol)).v).xy;
int2 xz = int3((*(tint_symbol)).v).xz;
int2 yx = int3((*(tint_symbol)).v).yx;
int2 yy = int3((*(tint_symbol)).v).yy;
int2 yz = int3((*(tint_symbol)).v).yz;
int2 zx = int3((*(tint_symbol)).v).zx;
int2 zy = int3((*(tint_symbol)).v).zy;
int2 zz = int3((*(tint_symbol)).v).zz;
int3 xxx = int3((*(tint_symbol)).v).xxx;
int3 xxy = int3((*(tint_symbol)).v).xxy;
int3 xxz = int3((*(tint_symbol)).v).xxz;
int3 xyx = int3((*(tint_symbol)).v).xyx;
int3 xyy = int3((*(tint_symbol)).v).xyy;
int3 xyz = int3((*(tint_symbol)).v).xyz;
int3 xzx = int3((*(tint_symbol)).v).xzx;
int3 xzy = int3((*(tint_symbol)).v).xzy;
int3 xzz = int3((*(tint_symbol)).v).xzz;
int3 yxx = int3((*(tint_symbol)).v).yxx;
int3 yxy = int3((*(tint_symbol)).v).yxy;
int3 yxz = int3((*(tint_symbol)).v).yxz;
int3 yyx = int3((*(tint_symbol)).v).yyx;
int3 yyy = int3((*(tint_symbol)).v).yyy;
int3 yyz = int3((*(tint_symbol)).v).yyz;
int3 yzx = int3((*(tint_symbol)).v).yzx;
int3 yzy = int3((*(tint_symbol)).v).yzy;
int3 yzz = int3((*(tint_symbol)).v).yzz;
int3 zxx = int3((*(tint_symbol)).v).zxx;
int3 zxy = int3((*(tint_symbol)).v).zxy;
int3 zxz = int3((*(tint_symbol)).v).zxz;
int3 zyx = int3((*(tint_symbol)).v).zyx;
int3 zyy = int3((*(tint_symbol)).v).zyy;
int3 zyz = int3((*(tint_symbol)).v).zyz;
int3 zzx = int3((*(tint_symbol)).v).zzx;
int3 zzy = int3((*(tint_symbol)).v).zzy;
int3 zzz = int3((*(tint_symbol)).v).zzz;
int4 xxxx = int3((*(tint_symbol)).v).xxxx;
int4 xxxy = int3((*(tint_symbol)).v).xxxy;
int4 xxxz = int3((*(tint_symbol)).v).xxxz;
int4 xxyx = int3((*(tint_symbol)).v).xxyx;
int4 xxyy = int3((*(tint_symbol)).v).xxyy;
int4 xxyz = int3((*(tint_symbol)).v).xxyz;
int4 xxzx = int3((*(tint_symbol)).v).xxzx;
int4 xxzy = int3((*(tint_symbol)).v).xxzy;
int4 xxzz = int3((*(tint_symbol)).v).xxzz;
int4 xyxx = int3((*(tint_symbol)).v).xyxx;
int4 xyxy = int3((*(tint_symbol)).v).xyxy;
int4 xyxz = int3((*(tint_symbol)).v).xyxz;
int4 xyyx = int3((*(tint_symbol)).v).xyyx;
int4 xyyy = int3((*(tint_symbol)).v).xyyy;
int4 xyyz = int3((*(tint_symbol)).v).xyyz;
int4 xyzx = int3((*(tint_symbol)).v).xyzx;
int4 xyzy = int3((*(tint_symbol)).v).xyzy;
int4 xyzz = int3((*(tint_symbol)).v).xyzz;
int4 xzxx = int3((*(tint_symbol)).v).xzxx;
int4 xzxy = int3((*(tint_symbol)).v).xzxy;
int4 xzxz = int3((*(tint_symbol)).v).xzxz;
int4 xzyx = int3((*(tint_symbol)).v).xzyx;
int4 xzyy = int3((*(tint_symbol)).v).xzyy;
int4 xzyz = int3((*(tint_symbol)).v).xzyz;
int4 xzzx = int3((*(tint_symbol)).v).xzzx;
int4 xzzy = int3((*(tint_symbol)).v).xzzy;
int4 xzzz = int3((*(tint_symbol)).v).xzzz;
int4 yxxx = int3((*(tint_symbol)).v).yxxx;
int4 yxxy = int3((*(tint_symbol)).v).yxxy;
int4 yxxz = int3((*(tint_symbol)).v).yxxz;
int4 yxyx = int3((*(tint_symbol)).v).yxyx;
int4 yxyy = int3((*(tint_symbol)).v).yxyy;
int4 yxyz = int3((*(tint_symbol)).v).yxyz;
int4 yxzx = int3((*(tint_symbol)).v).yxzx;
int4 yxzy = int3((*(tint_symbol)).v).yxzy;
int4 yxzz = int3((*(tint_symbol)).v).yxzz;
int4 yyxx = int3((*(tint_symbol)).v).yyxx;
int4 yyxy = int3((*(tint_symbol)).v).yyxy;
int4 yyxz = int3((*(tint_symbol)).v).yyxz;
int4 yyyx = int3((*(tint_symbol)).v).yyyx;
int4 yyyy = int3((*(tint_symbol)).v).yyyy;
int4 yyyz = int3((*(tint_symbol)).v).yyyz;
int4 yyzx = int3((*(tint_symbol)).v).yyzx;
int4 yyzy = int3((*(tint_symbol)).v).yyzy;
int4 yyzz = int3((*(tint_symbol)).v).yyzz;
int4 yzxx = int3((*(tint_symbol)).v).yzxx;
int4 yzxy = int3((*(tint_symbol)).v).yzxy;
int4 yzxz = int3((*(tint_symbol)).v).yzxz;
int4 yzyx = int3((*(tint_symbol)).v).yzyx;
int4 yzyy = int3((*(tint_symbol)).v).yzyy;
int4 yzyz = int3((*(tint_symbol)).v).yzyz;
int4 yzzx = int3((*(tint_symbol)).v).yzzx;
int4 yzzy = int3((*(tint_symbol)).v).yzzy;
int4 yzzz = int3((*(tint_symbol)).v).yzzz;
int4 zxxx = int3((*(tint_symbol)).v).zxxx;
int4 zxxy = int3((*(tint_symbol)).v).zxxy;
int4 zxxz = int3((*(tint_symbol)).v).zxxz;
int4 zxyx = int3((*(tint_symbol)).v).zxyx;
int4 zxyy = int3((*(tint_symbol)).v).zxyy;
int4 zxyz = int3((*(tint_symbol)).v).zxyz;
int4 zxzx = int3((*(tint_symbol)).v).zxzx;
int4 zxzy = int3((*(tint_symbol)).v).zxzy;
int4 zxzz = int3((*(tint_symbol)).v).zxzz;
int4 zyxx = int3((*(tint_symbol)).v).zyxx;
int4 zyxy = int3((*(tint_symbol)).v).zyxy;
int4 zyxz = int3((*(tint_symbol)).v).zyxz;
int4 zyyx = int3((*(tint_symbol)).v).zyyx;
int4 zyyy = int3((*(tint_symbol)).v).zyyy;
int4 zyyz = int3((*(tint_symbol)).v).zyyz;
int4 zyzx = int3((*(tint_symbol)).v).zyzx;
int4 zyzy = int3((*(tint_symbol)).v).zyzy;
int4 zyzz = int3((*(tint_symbol)).v).zyzz;
int4 zzxx = int3((*(tint_symbol)).v).zzxx;
int4 zzxy = int3((*(tint_symbol)).v).zzxy;
int4 zzxz = int3((*(tint_symbol)).v).zzxz;
int4 zzyx = int3((*(tint_symbol)).v).zzyx;
int4 zzyy = int3((*(tint_symbol)).v).zzyy;
int4 zzyz = int3((*(tint_symbol)).v).zzyz;
int4 zzzx = int3((*(tint_symbol)).v).zzzx;
int4 zzzy = int3((*(tint_symbol)).v).zzzy;
int4 zzzz = int3((*(tint_symbol)).v).zzzz;
}