skia2/gn
Michael Ludwig e88320baec Update how sample(matrix) calls are invoked in SkSL
This removes the kMixed type of SkSL::SampleMatrix. All analysis of FP
sampling due to parent-child relationships is tracked in flags on
GrFragmentProcessor now.

The sample strategy is tracked as follows:
- An FP marks itself as using the local coordinate builtin directly (automatically done for .fp code based on reference to sk_TransformedCoords2D[0]).
- This state propagates up the parent towards the root, marking FPs as using coordinates indirectly. We stop the propagation when we hit a parent FP that explicitly samples the child because it becomes the source of the child's coordinates.
   - If that parent references its local coordinates directly, that kicks off its own upwards propagation.
- Being sampled explicitly propagates down to all children, and effectively disables vertex-shader evaluation of transforms.
   - A variable matrix automatically marks this flag as well, since it's essentially a shortcut to (matrix expression) * coords.
- The matrix type also propagates down, but right now that's only for whether or not there's perspective.
   - This doesn't affect FS coord evaluation since each FP applies its action independently.
   - But for VS-promoted transforms, the child's varying may inherit perspective (or other more general matrix types) from the parent and switch from a float2 to a float3.
- A SampleMatrix no longer tracks a base or owner, GrFragmentProcessor exposes its parent FP. An FP's sample matrix is always owned by its immediate parent.
   - This means that you can have a hierarchy from root to leaf like: [uniform, none, none, uses local coords], and that leaf will have a SampleMatrix of kNone type. However, because of parent tracking, the coordinate generation can walk up to the root and detect the proper transform expression it needs to produce, and automatically de-duplicate across children.

Currently, all FP's that are explicitly sampled have a signature of (color, float2 coord). FP's that don't use local coords, or whose coords are promoted to a varying have a signature of (color).
   - In this case, the shader builder either updates args.fLocalCoords to point to the varying directly, or adds a float2 local to the function body that includes the perspective divide.

GrFragmentProcessor automatically pretends it has an identity coord transform if the FP is marked as referencing the local coord builtin. This allows these FPs to still be processed as part of GrGLSLGeometryProcessor::collectTransforms, but removes the need for FP implementations to declare an identity GrCoordTransform.
   - To test this theory, GrTextureEffect and GrSkSLFP no longer have coord transforms explicitly.
   - Later CLs can trivially remove them from a lot of the other effects.
   - The coord generation should not change because it detects in both cases that the coord transform matrices were identity.

GrGLSLGeometryProcessor's collectTransforms and emitTransformCode has been completely overhauled to recurse up an FP's parent pointers and collect the expressions that affect the result. It de-duplicates expressions between siblings, and is able to produce a single varying for the base local coord (either when there are no intervening transforms, or the root FP needs an explicit coordinate to start off with).


This also adds the fp_sample_chaining GM from Brian, with a few more configurations to fill out the cells.

Bug: skia:10396
Change-Id: I86acc0c34c9f29d6371b34370bee9a18c2acf1c1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297868
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-06-25 14:48:34 +00:00
..
toolchain Delete .a file before writing static library. 2020-06-11 17:19:23 +00:00
__init__.py Make gn directory importable in python 2017-03-20 17:40:30 +00:00
bench.gni Reland "Add create backend texture with color upload bench." 2020-05-05 00:43:52 +00:00
BUILD.gn Revert "Enable _LIBCPP_DEBUG in Clang for non-Xcode-based debug builds." 2020-06-20 14:32:09 +00:00
BUILDCONFIG.gn decouple werror and -isystem in third_party 2020-06-19 21:59:35 +00:00
call.py [minor] mark scripts as executable 2019-11-21 17:06:27 +00:00
checkdir.py fix print functions for python3 gn scripts 2020-03-06 17:42:39 +00:00
checkpath.py Python3 tweaks 2019-12-17 17:12:03 +00:00
codesign_ios.py [minor] mark scripts as executable 2019-11-21 17:06:27 +00:00
compile_ib_files.py Reland "Add launch screen to iOS apps" 2019-09-05 14:05:08 +00:00
compile_processors.py Reland "Fetch clang-format automatically when compiling .fp files." 2020-06-12 13:21:41 +00:00
copy_git_directory.py GN tools: copy_git_directory.py better error message. 2019-11-19 17:04:18 +00:00
core.gni add simple pathbuilder 2020-06-24 01:50:30 +00:00
cp.py [minor] mark scripts as executable 2019-11-21 17:06:27 +00:00
create_sksl_enums.py [minor] mark scripts as executable 2019-11-21 17:06:27 +00:00
effects_imagefilters.gni Add new SkImageFilters factory API 2019-08-02 13:33:35 +00:00
effects.gni harmonize rewrite-includes and gn-format checks 2020-04-03 17:00:54 +00:00
find_headers.py Python3 tweaks 2019-12-17 17:12:03 +00:00
find_msvc.py Add Preview to list of possible MSVC versions. 2020-04-30 19:54:33 +00:00
find_xcode_sysroot.py fix print functions for python3 gn scripts 2020-03-06 17:42:39 +00:00
flutter_defines.gni ignore SK_DISABLE_READBUFFER 2020-06-09 16:16:57 +00:00
fuchsia_defines.gni remove legacy hinting-enum guards 2018-11-28 20:15:03 +00:00
gen_plist_ios.py [minor] mark scripts as executable 2019-11-21 17:06:27 +00:00
gm.gni Update how sample(matrix) calls are invoked in SkSL 2020-06-25 14:48:34 +00:00
gn_meta_sln.py fix print functions for python3 gn scripts 2020-03-06 17:42:39 +00:00
gn_to_bp_utils.py Android test to depend on icu and harfbuzz. 2020-06-02 21:26:25 +00:00
gn_to_bp.py Regularize selection of fontmgr. 2020-06-11 12:28:03 +00:00
gn_to_cmake.py [infra] Change CMake build to use a temporary directory 2020-01-14 11:41:55 +00:00
gpu.gni GrTextContext::Options -> GrSDFTOptions 2020-06-15 17:14:04 +00:00
highest_version_dir.py fix print functions for python3 gn scripts 2020-03-06 17:42:39 +00:00
ios.gni harmonize rewrite-includes and gn-format checks 2020-04-03 17:00:54 +00:00
is_clang.py fix print functions for python3 gn scripts 2020-03-06 17:42:39 +00:00
make_gm_gni.py GMs: re-sort gni, script to regenerate gni, file name convention 2019-05-02 20:08:37 +00:00
opts.gni add structure for normal SKX opts 2020-06-05 13:48:39 +00:00
pdf.gni Make skia_use_xps option work on Windows 2020-03-24 17:09:33 +00:00
push_to_android.py skia_android_serial = "auto" 2017-01-12 16:30:17 +00:00
rm.py Delete .a file before writing static library. 2020-06-11 17:19:23 +00:00
run_sksllex.py Reland "Fetch clang-format automatically when compiling .fp files." 2020-06-12 13:21:41 +00:00
samples.gni Add an interactive sample that fits cubics to circular arcs 2020-06-09 23:04:03 +00:00
shared_sources.gni add structure for normal SKX opts 2020-06-05 13:48:39 +00:00
skia.gni Use Mac font manager for both iOS and macOS 2020-06-17 21:50:10 +00:00
sksl.gni Remove PremulInput and GrPremulInputFragmentProcessor.fp from Skia. 2020-06-08 21:04:46 +00:00
tests.gni Add GrContext::oomed() and implement for GL and VK. 2020-06-24 16:04:06 +00:00
utils.gni Split out coretext fontmgr factory. 2020-06-06 04:06:32 +00:00
xps.gni harmonize rewrite-includes and gn-format checks 2020-04-03 17:00:54 +00:00