d8d85b9b89
Reland works around Adreno issue with this formulation of sk_Clockwise: (sk_RTFlip.y < 0.0 ? !gl_FrontFacing : gl_FrontFacing) and instead adds this to the top of the function: bool sk_Clockwise = gl_FrontFacing; if (sk_RTFlip.y < 0.0) { sk_Clockwise = !sk_Clockwise; } Original description: 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: I3a2ad6f5667eb4dcd823b939abd5698f89b58929 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425178 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Brian Salomon <bsalomon@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;
|
|
}
|