mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-30 01:54:31 +01:00
Do not emit an `Expression::As` conversion for WGSL like `vec3(v)` where `v` is already a `vec3`, or `mat2x3(m)` where `m` is already a 2x3 matrix. This doesn't fix any bugs, but it makes it clearer to the reader of `Lowerer::construct` that no conversion can actually take place in this case. Some snapshots are affected because `As` expressions whose `width` is `None` are bitcast expressions, which the constant evaluator does not yet support. When this commit removes those `As` expressions, the constant evaluator can reduce the expression to a `Literal` or `ZeroValue`, which is then concealed by #2539.
46 lines
1.5 KiB
Plaintext
46 lines
1.5 KiB
Plaintext
// language: metal1.0
|
|
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
|
|
using metal::uint;
|
|
|
|
struct Foo {
|
|
metal::float4 a;
|
|
int b;
|
|
};
|
|
struct type_5 {
|
|
metal::float2x2 inner[1];
|
|
};
|
|
struct type_10 {
|
|
Foo inner[3];
|
|
};
|
|
struct type_11 {
|
|
int inner[4];
|
|
};
|
|
constant metal::float3 const2_ = metal::float3(0.0, 1.0, 2.0);
|
|
constant metal::float2x2 const3_ = metal::float2x2(metal::float2(0.0, 1.0), metal::float2(2.0, 3.0));
|
|
constant type_5 const4_ = type_5 {metal::float2x2(metal::float2(0.0, 1.0), metal::float2(2.0, 3.0))};
|
|
constant bool cz0_ = bool {};
|
|
constant int cz1_ = int {};
|
|
constant uint cz2_ = uint {};
|
|
constant float cz3_ = float {};
|
|
constant metal::uint2 cz4_ = metal::uint2 {};
|
|
constant metal::float2x2 cz5_ = metal::float2x2 {};
|
|
constant type_10 cz6_ = type_10 {};
|
|
constant Foo cz7_ = Foo {};
|
|
constant type_11 cp3_ = type_11 {0, 1, 2, 3};
|
|
|
|
kernel void main_(
|
|
) {
|
|
Foo foo = {};
|
|
foo = Foo {metal::float4(1.0), 1};
|
|
metal::float2x2 m0_ = metal::float2x2(metal::float2(1.0, 0.0), metal::float2(0.0, 1.0));
|
|
metal::float4x4 m1_ = metal::float4x4(metal::float4(1.0, 0.0, 0.0, 0.0), metal::float4(0.0, 1.0, 0.0, 0.0), metal::float4(0.0, 0.0, 1.0, 0.0), metal::float4(0.0, 0.0, 0.0, 1.0));
|
|
metal::uint2 cit0_ = metal::uint2(0u);
|
|
metal::float2x2 cit1_ = metal::float2x2(metal::float2(0.0), metal::float2(0.0));
|
|
type_11 cit2_ = type_11 {0, 1, 2, 3};
|
|
bool ic0_ = static_cast<bool>(bool {});
|
|
metal::uint2 ic4_ = metal::uint2(0u, 0u);
|
|
metal::float2x3 ic5_ = metal::float2x3(metal::float3(0.0, 0.0, 0.0), metal::float3(0.0, 0.0, 0.0));
|
|
}
|