skia2/tests/sksl/intrinsics/IsInf.metal

26 lines
1.1 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
half2x2 testMatrix2x2;
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)]];
};
Reland "Add ES3 intrinsics isinf/isnan to public SkSL ES3." This reverts commit 9155b338bb9c2b52533d4de6f5af0665498937a4. Reason for revert: disable test for GLSL + Adreno 6xx Original change's description: > Revert "Add ES3 intrinsics isinf/isnan to public SkSL ES3." > > This reverts commit e43714f490ecab72bd1dca73f296a37fc99ef415. > > Reason for revert: Several Pixel (Adreno) devices failing the test > > Original change's description: > > Add ES3 intrinsics isinf/isnan to public SkSL ES3. > > > > The ES3 spec doesn't mandate that `isnan` actually has to do anything, > > so the Isnan test is not enabled. (It doesn't work on my personal > > machine unless I make the NaN detectable at compile-time.) > > > > We do not support these functions in constant-expressions, as we > > currently avoid optimizing anything into a non-finite value; we leave > > expressions alone if we calculate a NaN/inf result for their value. > > > > Change-Id: Ibfdfb47b6e6134165c8780db570de04a916d2bfa > > Bug: skia:12022 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441581 > > Auto-Submit: John Stiles <johnstiles@google.com> > > Reviewed-by: Brian Osman <brianosman@google.com> > > Commit-Queue: John Stiles <johnstiles@google.com> > > TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com > > Change-Id: I89899ed391aa870350d0452bab4a0fb75bd7be38 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:12022 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441716 > Reviewed-by: Brian Osman <brianosman@google.com> > Commit-Queue: Brian Osman <brianosman@google.com> Bug: skia:12022, skia:12377 Change-Id: Ib149dbc1138feb3ee2bf6f7e31e9e8a9414560bc Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441884 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-25 17:54:34 +00:00
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 half4_from_half2x2(half2x2 x) {
return half4(x[0].xy, x[1].xy);
Reland "Add ES3 intrinsics isinf/isnan to public SkSL ES3." This reverts commit 9155b338bb9c2b52533d4de6f5af0665498937a4. Reason for revert: disable test for GLSL + Adreno 6xx Original change's description: > Revert "Add ES3 intrinsics isinf/isnan to public SkSL ES3." > > This reverts commit e43714f490ecab72bd1dca73f296a37fc99ef415. > > Reason for revert: Several Pixel (Adreno) devices failing the test > > Original change's description: > > Add ES3 intrinsics isinf/isnan to public SkSL ES3. > > > > The ES3 spec doesn't mandate that `isnan` actually has to do anything, > > so the Isnan test is not enabled. (It doesn't work on my personal > > machine unless I make the NaN detectable at compile-time.) > > > > We do not support these functions in constant-expressions, as we > > currently avoid optimizing anything into a non-finite value; we leave > > expressions alone if we calculate a NaN/inf result for their value. > > > > Change-Id: Ibfdfb47b6e6134165c8780db570de04a916d2bfa > > Bug: skia:12022 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441581 > > Auto-Submit: John Stiles <johnstiles@google.com> > > Reviewed-by: Brian Osman <brianosman@google.com> > > Commit-Queue: John Stiles <johnstiles@google.com> > > TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com > > Change-Id: I89899ed391aa870350d0452bab4a0fb75bd7be38 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:12022 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441716 > Reviewed-by: Brian Osman <brianosman@google.com> > Commit-Queue: Brian Osman <brianosman@google.com> Bug: skia:12022, skia:12377 Change-Id: Ib149dbc1138feb3ee2bf6f7e31e9e8a9414560bc Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441884 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-25 17:54:34 +00:00
}
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 infiniteValue = half4_from_half2x2(_uniforms.testMatrix2x2) / _uniforms.colorGreen.x;
half4 finiteValue = half4_from_half2x2(_uniforms.testMatrix2x2) / _uniforms.colorGreen.y;
_out.sk_FragColor = ((((((isinf(float(infiniteValue.x)) && all(isinf(float2(infiniteValue.xy)))) && all(isinf(float3(infiniteValue.xyz)))) && all(isinf(float4(infiniteValue)))) && !isinf(float(finiteValue.x))) && !any(isinf(float2(finiteValue.xy)))) && !any(isinf(float3(finiteValue.xyz)))) && !any(isinf(float4(finiteValue))) ? _uniforms.colorGreen : _uniforms.colorRed;
return _out;
}