9b9805959d
This reverts commit9d24b02c2f
. Reason for revert: needs premul/unpremul conversion fix (http://review.skia.org/465798) Original change's description: > Revert "Add support for half-precision types in Metal." > > This reverts commitd90e09b1ae
. > > Reason for revert: MacMini failing CompressedBackendAllocationTest > > Original change's description: > > Add support for half-precision types in Metal. > > > > This will hopefully improve performance on lower-end GPUs. > > > > Change-Id: I9c2ee6dc31acd08bec0bfb5f59edc3cf90163f9e > > Bug: skia:12339 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/465078 > > Auto-Submit: John Stiles <johnstiles@google.com> > > Reviewed-by: Brian Osman <brianosman@google.com> > > Commit-Queue: John Stiles <johnstiles@google.com> > > Bug: skia:12339 > Change-Id: Ic5aa4bef454ca67f5ce26c600444d9565e0158cb > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/465796 > Auto-Submit: Brian Osman <brianosman@google.com> > Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Bug: skia:12339 Change-Id: I53a8a6fef299da15d206d884ba7029820ffcff43 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/465799 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: John Stiles <johnstiles@google.com>
97 lines
3.3 KiB
Metal
97 lines
3.3 KiB
Metal
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
using namespace metal;
|
|
struct Uniforms {
|
|
half4 colorRed;
|
|
half4 colorGreen;
|
|
half unknownInput;
|
|
};
|
|
struct Inputs {
|
|
};
|
|
struct Outputs {
|
|
half4 sk_FragColor [[color(0)]];
|
|
};
|
|
bool test_int_b(Uniforms _uniforms) {
|
|
bool ok = true;
|
|
int4 inputRed = int4(_uniforms.colorRed);
|
|
int4 inputGreen = int4(_uniforms.colorGreen);
|
|
int4 x = inputRed + 2;
|
|
ok = ok && all(x == int4(3, 2, 2, 3));
|
|
x = inputGreen.ywxz - 2;
|
|
ok = ok && all(x == int4(-1, -1, -2, -2));
|
|
x = inputRed + inputGreen.y;
|
|
ok = ok && all(x == int4(2, 1, 1, 2));
|
|
x.xyz = inputGreen.wyw * 9;
|
|
ok = ok && all(x == int4(9, 9, 9, 2));
|
|
x.xy = x.zw / 3;
|
|
ok = ok && all(x == int4(3, 0, 9, 2));
|
|
x = (inputRed * 5).yxwz;
|
|
ok = ok && all(x == int4(0, 5, 5, 0));
|
|
x = 2 + inputRed;
|
|
ok = ok && all(x == int4(3, 2, 2, 3));
|
|
x = 10 - inputGreen.ywxz;
|
|
ok = ok && all(x == int4(9, 9, 10, 10));
|
|
x = inputRed.x + inputGreen;
|
|
ok = ok && all(x == int4(1, 2, 1, 2));
|
|
x.xyz = 9 * inputGreen.wyw;
|
|
ok = ok && all(x == int4(9, 9, 9, 2));
|
|
x.xy = 36 / x.zw;
|
|
ok = ok && all(x == int4(4, 18, 9, 2));
|
|
x = (36 / x).yxwz;
|
|
ok = ok && all(x == int4(2, 9, 18, 4));
|
|
x += 2;
|
|
x *= 2;
|
|
x -= 4;
|
|
x /= 2;
|
|
ok = ok && all(x == int4(2, 9, 18, 4));
|
|
x = x + 2;
|
|
x = x * 2;
|
|
x = x - 4;
|
|
x = x / 2;
|
|
ok = ok && all(x == int4(2, 9, 18, 4));
|
|
return ok;
|
|
}
|
|
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
|
Outputs _out;
|
|
(void)_out;
|
|
bool _0_ok = true;
|
|
half4 _1_inputRed = _uniforms.colorRed;
|
|
half4 _2_inputGreen = _uniforms.colorGreen;
|
|
half4 _3_x = _1_inputRed + 2.0h;
|
|
_0_ok = _0_ok && all(_3_x == half4(3.0h, 2.0h, 2.0h, 3.0h));
|
|
_3_x = _2_inputGreen.ywxz - 2.0h;
|
|
_0_ok = _0_ok && all(_3_x == half4(-1.0h, -1.0h, -2.0h, -2.0h));
|
|
_3_x = _1_inputRed + _2_inputGreen.y;
|
|
_0_ok = _0_ok && all(_3_x == half4(2.0h, 1.0h, 1.0h, 2.0h));
|
|
_3_x.xyz = _2_inputGreen.wyw * 9.0h;
|
|
_0_ok = _0_ok && all(_3_x == half4(9.0h, 9.0h, 9.0h, 2.0h));
|
|
_3_x.xy = _3_x.zw / 0.5h;
|
|
_0_ok = _0_ok && all(_3_x == half4(18.0h, 4.0h, 9.0h, 2.0h));
|
|
_3_x = (_1_inputRed * 5.0h).yxwz;
|
|
_0_ok = _0_ok && all(_3_x == half4(0.0h, 5.0h, 5.0h, 0.0h));
|
|
_3_x = 2.0h + _1_inputRed;
|
|
_0_ok = _0_ok && all(_3_x == half4(3.0h, 2.0h, 2.0h, 3.0h));
|
|
_3_x = 10.0h - _2_inputGreen.ywxz;
|
|
_0_ok = _0_ok && all(_3_x == half4(9.0h, 9.0h, 10.0h, 10.0h));
|
|
_3_x = _1_inputRed.x + _2_inputGreen;
|
|
_0_ok = _0_ok && all(_3_x == half4(1.0h, 2.0h, 1.0h, 2.0h));
|
|
_3_x.xyz = 9.0h * _2_inputGreen.wyw;
|
|
_0_ok = _0_ok && all(_3_x == half4(9.0h, 9.0h, 9.0h, 2.0h));
|
|
_3_x.xy = 36.0h / _3_x.zw;
|
|
_0_ok = _0_ok && all(_3_x == half4(4.0h, 18.0h, 9.0h, 2.0h));
|
|
_3_x = (36.0h / _3_x).yxwz;
|
|
_0_ok = _0_ok && all(_3_x == half4(2.0h, 9.0h, 18.0h, 4.0h));
|
|
_3_x += 2.0h;
|
|
_3_x *= 2.0h;
|
|
_3_x -= 4.0h;
|
|
_3_x /= 2.0h;
|
|
_0_ok = _0_ok && all(_3_x == half4(2.0h, 9.0h, 18.0h, 4.0h));
|
|
_3_x = _3_x + 2.0h;
|
|
_3_x = _3_x * 2.0h;
|
|
_3_x = _3_x - 4.0h;
|
|
_3_x = _3_x / 2.0h;
|
|
_0_ok = _0_ok && all(_3_x == half4(2.0h, 9.0h, 18.0h, 4.0h));
|
|
_out.sk_FragColor = _0_ok && test_int_b(_uniforms) ? _uniforms.colorGreen : _uniforms.colorRed;
|
|
return _out;
|
|
}
|