skia2/tests/sksl/shared/SwizzleByConstantIndex.metal

37 lines
1.2 KiB
Metal
Raw Normal View History

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Uniforms {
Reland "Add support for half-precision types in Metal." This reverts commit 9d24b02c2fdb5eede1054b16b9c03b5ed26dc618. 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 commit d90e09b1ae0939b463f59f81c2958b8c08f5027b. > > 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>
2021-10-30 02:34:51 +00:00
half4 testInputs;
half4 colorGreen;
half4 colorRed;
};
struct Inputs {
};
struct Outputs {
Reland "Add support for half-precision types in Metal." This reverts commit 9d24b02c2fdb5eede1054b16b9c03b5ed26dc618. 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 commit d90e09b1ae0939b463f59f81c2958b8c08f5027b. > > 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>
2021-10-30 02:34:51 +00:00
half4 sk_FragColor [[color(0)]];
};
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Outputs _out;
(void)_out;
Reland "Add support for half-precision types in Metal." This reverts commit 9d24b02c2fdb5eede1054b16b9c03b5ed26dc618. 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 commit d90e09b1ae0939b463f59f81c2958b8c08f5027b. > > 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>
2021-10-30 02:34:51 +00:00
half4 _0_v = _uniforms.testInputs;
half _1_x = _0_v.x;
half _2_y = _0_v.y;
half _3_z = _0_v.z;
half _4_w = _0_v.w;
half4 a = half4(_1_x, _2_y, _3_z, _4_w);
half _9_x = _uniforms.testInputs.x;
half _10_y = _uniforms.testInputs.y;
half _11_z = _uniforms.testInputs.z;
half _12_w = _uniforms.testInputs.w;
half4 b = half4(_9_x, _10_y, _11_z, _12_w);
half4 _13_v = half4(0.0h, 1.0h, 2.0h, 3.0h);
half _14_x = _13_v.x;
half _15_y = _13_v.y;
half _16_z = _13_v.z;
half _17_w = _13_v.w;
half4 c = half4(_14_x, _15_y, _16_z, _17_w);
_out.sk_FragColor = (all(a == half4(-1.25h, 0.0h, 0.75h, 2.25h)) && all(b == half4(-1.25h, 0.0h, 0.75h, 2.25h))) && all(c == half4(0.0h, 1.0h, 2.0h, 3.0h)) ? _uniforms.colorGreen : _uniforms.colorRed;
return _out;
}