6e88e041d9
There are two forms. Swizzle::Make supports components XYZW only; Swizzle::MakeWith01 also supports the 01 components, and restructures the zeros and ones into a constructor (as IRGenerator::convertSwizzle has historically done). This means that once we are past the initial IR generation stage, and we know that the 01 components have been eliminated, we can avoid the extra 01-handling logic and just call Swizzle::Make directly. This isn't a huge deal but it means that call sites like the inliner can avoid some extra work that will never happen. Change-Id: I46690c3d6b07feb6327ee72e8f66f15592a35554 Bug: skia:11342 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/371398 Commit-Queue: John Stiles <johnstiles@google.com> Commit-Queue: Brian Osman <brianosman@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
47 lines
1.3 KiB
Metal
47 lines
1.3 KiB
Metal
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
using namespace metal;
|
|
struct Uniforms {
|
|
float4 colorRed;
|
|
float4 colorGreen;
|
|
float4 testInputs;
|
|
};
|
|
struct Inputs {
|
|
};
|
|
struct Outputs {
|
|
float4 sk_FragColor [[color(0)]];
|
|
};
|
|
|
|
|
|
|
|
float fn(float4 v) {
|
|
for (int x = 1;x <= 2; ++x) {
|
|
return v.x;
|
|
}
|
|
}
|
|
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
|
Outputs _out;
|
|
(void)_out;
|
|
float4 v = _uniforms.testInputs;
|
|
v = float4(0.0, v.zyx);
|
|
v = float4(0.0, 0.0, v.xw);
|
|
v = float4(1.0, 1.0, v.wx);
|
|
v = float4(v.zy, 1.0, 1.0);
|
|
v = float4(v.xx, 1.0, 1.0);
|
|
v = v.wzwz;
|
|
v = float3(fn(v), 123.0, 456.0).yyzz;
|
|
v = float3(fn(v), 123.0, 456.0).yyzz;
|
|
v = float4(123.0, 456.0, 456.0, fn(v));
|
|
v = float4(123.0, 456.0, 456.0, fn(v));
|
|
v = float3(fn(v), 123.0, 456.0).yxxz;
|
|
v = float3(fn(v), 123.0, 456.0).yxxz;
|
|
v = float4(1.0, 1.0, 2.0, 3.0);
|
|
v = float4(_uniforms.colorRed.xyz, 1.0);
|
|
v = float4(_uniforms.colorRed.x, 1.0, _uniforms.colorRed.yz);
|
|
v.wzyx = v;
|
|
v.xw = v.yz;
|
|
v.wzyx.yzw = float3(v.ww, 1.0);
|
|
_out.sk_FragColor = all(v == float4(1.0)) ? _uniforms.colorGreen : _uniforms.colorRed;
|
|
return _out;
|
|
}
|