943108b0b2
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>
18 lines
596 B
Metal
18 lines
596 B
Metal
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
using namespace metal;
|
|
struct Inputs {
|
|
};
|
|
struct Outputs {
|
|
float4 sk_FragColor [[color(0)]];
|
|
};
|
|
struct sksl_synthetic_uniforms {
|
|
float2 u_skRTFlip;
|
|
};
|
|
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant sksl_synthetic_uniforms& _anonInterface0 [[buffer(1)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
|
Outputs _out;
|
|
(void)_out;
|
|
_out.sk_FragColor.xy = float4(_fragCoord.x, _anonInterface0.u_skRTFlip.x + _anonInterface0.u_skRTFlip.y * _fragCoord.y, 0.0, _fragCoord.w).xy;
|
|
return _out;
|
|
}
|