skia2/tests/sksl/shared/Clockwise.metal

15 lines
390 B
Metal
Raw Normal View History

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Inputs {
};
struct Outputs {
float4 sk_FragColor [[color(0)]];
};
Revert "Don't key progams/pipelines on origin." This reverts commit 943108b0b25d0e13e615dbbdcf712640548d2d0f. Reason for revert: clockwise GM bad on android. Original change's description: > Don't key progams/pipelines on origin. > > SkSL language features that are origin sensitive now use a uniform > to conditionally flip their result rather than generating different > code. > > Previously we would insert a "rt height" uniform if sk_FragCoord needed > to be flipped. sk_FragCoord,y was implemented as "realFragCoord.y" or > "rtHeight - realFragCoord.y" depending on SkSL::ProgramSettings::fFlipY. > > Now we instead use a two component vector rtFlip and sk_FragCoord.y is > always "rtFlip.x + rtFlip.y*realFragCoord.y". We configure rtFlip as > either (0, 1) or (rtHeight, -1). sk_Clockwise and dFdy simiarly use > rtFlip.y to emit code that always works with either origin. > > Bug: skia:12037 > > Change-Id: I7a09d0caac60a58d72b76645ff31bcabde4086b6 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414796 > Commit-Queue: Brian Salomon <bsalomon@google.com> > Reviewed-by: Greg Daniel <egdaniel@google.com> > Reviewed-by: Ethan Nicholas <ethannicholas@google.com> TBR=egdaniel@google.com,bsalomon@google.com,ethannicholas@google.com Change-Id: I91cc0d86be216f6c32e453a231de088c991be4b2 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:12037 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425056 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-07-06 19:04:18 +00:00
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Outputs _out;
(void)_out;
Revert "Don't key progams/pipelines on origin." This reverts commit 943108b0b25d0e13e615dbbdcf712640548d2d0f. Reason for revert: clockwise GM bad on android. Original change's description: > Don't key progams/pipelines on origin. > > SkSL language features that are origin sensitive now use a uniform > to conditionally flip their result rather than generating different > code. > > Previously we would insert a "rt height" uniform if sk_FragCoord needed > to be flipped. sk_FragCoord,y was implemented as "realFragCoord.y" or > "rtHeight - realFragCoord.y" depending on SkSL::ProgramSettings::fFlipY. > > Now we instead use a two component vector rtFlip and sk_FragCoord.y is > always "rtFlip.x + rtFlip.y*realFragCoord.y". We configure rtFlip as > either (0, 1) or (rtHeight, -1). sk_Clockwise and dFdy simiarly use > rtFlip.y to emit code that always works with either origin. > > Bug: skia:12037 > > Change-Id: I7a09d0caac60a58d72b76645ff31bcabde4086b6 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414796 > Commit-Queue: Brian Salomon <bsalomon@google.com> > Reviewed-by: Greg Daniel <egdaniel@google.com> > Reviewed-by: Ethan Nicholas <ethannicholas@google.com> TBR=egdaniel@google.com,bsalomon@google.com,ethannicholas@google.com Change-Id: I91cc0d86be216f6c32e453a231de088c991be4b2 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:12037 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425056 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-07-06 19:04:18 +00:00
_out.sk_FragColor = float4(float((!_frontFacing) ? 1 : -1));
return _out;
}