Commit Graph

98 Commits

Author SHA1 Message Date
Brian Osman
ddcb4d94f9 In pipeline stage generator, never emit declarations for opaque types
This only affects fragmentProcessors (children) - and the backend SkSL
we're emitting should not contain those. We've just been silently
ignoring those declarations when converting to GLSL, MSL, etc.

Change-Id: I241f2f4fe4614b49ebccc9c2976fd408e94656d0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/384316
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-03-13 01:46:06 +00:00
John Stiles
f3a28db703 Eliminate control-flow analysis.
We no longer derive a performance benefit from this pass in practice,
and it is a very expensive compilation step. It is also prone to fuzz-
related errors.

Doc: http://go/optimization-in-sksl

Change-Id: Ief08ffac659a8fe7fe92c92b9a5da14c9f713bc2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/381261
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-03-11 13:24:54 +00:00
John Stiles
85e1ecf4da Add #pragma settings flag to disable control-flow analysis.
This can be a useful debugging tool when working on skslc issues.

Change-Id: I838122828a704c9b959b0babda2909c182c66b55
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/376618
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-02-26 15:42:01 +00:00
John Stiles
a935c3f661 Replace Setting IRNodes with actual caps-values during IR generation.
Previously, this happened during optimization, so we couldn't disable
control-flow analysis on any code which used sk_Caps. Now this happens
as soon as the IRNode is rehydrated or instantiated. The logic has
migrated to a static helper function, Setting::Make.

Change-Id: I102557845ccd1b68cc2b12381563f06bc64c621f
Bug: skia:11365, skia:11343, skia:11319
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375298
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-02-25 19:16:29 +00:00
John Stiles
66c53b9428 Demonstrate a bug with inlined static switches.
When we detect a static switch, the optimizer finds the matching switch-
case and eliminates all the other switch-cases. It handles case
fall-through by scanning forward and looking for an unconditional break.

However, the inliner has an interesting quirk--it can replace `return`
statements inside of a switch with `continue` statements, since the body
of the inlined function has been wrapped with a for-loop to allow for
early exits. The optimizer does not recognize these continue statements
as exits from the switch (although they certainly qualify), so it
treats continues as fallen-through and keeps emitting switch-cases.

The dead-code elimination pass was actually doing us a favor here and
eliminating the excess code later. A flag was added to disable DCE in
order to reveal the problem in a test.

Change-Id: I8ff19fde5e32d0ab73d7c5411da40cb953a446f5
Bug: skia:11352
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372956
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-02-22 15:05:58 +00:00
Brian Osman
5e603c3a46 Support global variables in pipeline stage generator
Bug: skia:11295
Change-Id: Iec11f3f4d26eb5b1c07707b3cedd09096bad80d0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/371478
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-02-18 00:54:49 +00:00
Brian Osman
a5ab63a062 Tweak GlobalVariables.rte test, and adjust .stage output
Adds trivial name mangling to the .stage output, so we can verify that
it's working in all places (declarations, references, etc). Also added
another global variable whose initializer is - in turn - another global.

Bug: skia:11295
Change-Id: Ic220bfae0a6d1eeeba66ade30d3d781af15c5dea
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/371477
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-02-17 22:13:19 +00:00
John Stiles
dbd4e6f0c0 Move ProgramKind and ProgramSettings types out of SkSL::Program.
This change will allow these types to be forward-declared; C++ doesn't
allow forward declaration of types declared inside a struct. Moving
these types out of Programs resulted in a large diff.

The Settings::Value helper class has been moved inside of the
IRGenerator. In practice, it was actually just an implementation detail
of how IRGenerator looks up caps-values by name. It seems very unlikely
that this will be necessary elsewhere going forward.

Change-Id: I6119417fae608f1c492a27de746d2b550ef8ca20
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/370836
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-02-16 19:30:48 +00:00
John Stiles
d6a5f449d8 Migrate PermitInvalidStaticTests flag to Program::Settings.
This will make it accessible from the IR generator (in a future CL) and
is more in line with how we typically manage settings.

Change-Id: I478d617119cba079d1124b2b9c26d5573c7d6ae3
Bug: skia:11319
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369480
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-02-11 21:41:33 +00:00
Brian Osman
8e756f379c Support structs in runtime effects
Uses the pipeline-stage callback mechanism. It mangles the type name
(with a test to verify that this works), and then calls defineStruct
with the entire SkSL struct definition string.

Bug: skia:10939
Change-Id: If14cf1b11faaa80ad8d4086cdacf68532bac43fc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368809
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-02-11 21:09:15 +00:00
Brian Osman
55761ae5e6 Change pipeline stage callbacks to support mangling type names
Structs, enums, and global variables are all going to require name
mangling. Move that to a separate virtual on the callback. More
importantly, the generator is going to need to do type-name substitution
inside the function declaration string, so the contract has shifted:
The generator constructs the entire function declaration line (using the
mangled name it gets from the new callback), then it calls
defineFunction with two strings, and a flag indicating if this is main
or not.

Bug: skia:10939, skia:11295, skia:11296
Change-Id: I535eee9bfbb2337013b539908fe3d658ec3b2dbd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368397
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-02-10 16:08:11 +00:00
Brian Osman
62b039b36d Add .stage output to skslc for runtime effects
This emits SkSL that is more-or-less what the compiler re-ingests when a
runtime effect is used to create a GrFragmentProcessor.

Change-Id: I0926be44fc4493e722a5edc18198e161e4192cde
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/367883
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-02-09 20:11:56 +00:00
Mike Klein
4535e61309 force portable features
I checked that this prevents diffs on my M1 Mac.
Without this we'd see FMAs.

Change-Id: I24fa2e301cde556de556332b472399b97e6a08fe
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346676
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-12-22 20:52:32 +00:00
Brian Osman
47726a1cff Add SkVM output to skslc
Change-Id: Ida9d81a8d4e530cb3055f01418a2ad2893ae86db
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345422
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-12-22 15:44:22 +00:00
Brian Osman
9194675a3e SkSL: In the front-end, rename PipelineStage to RuntimeEffect
This maps to usage better, and makes some code simpler to understand.
Note that there is still a PipelineStage *back-end*, which is specific
to the runtime-effect FP. A kRuntimeEffect_Kind program can be used to
generate a PipelineStage (for the GPU backend), or an skvm program (for
the CPU backend).

Change-Id: Id3f535db93a239726c595225aafe9467f0d19817
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344969
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-12-21 21:23:17 +00:00
Brian Osman
23f00d7800 Reland "Add ByteCode output to skslc"
Reland fixes link errors in nogpu builds

This reverts commit 5fa45548b4.

Change-Id: I45e0509d0476dde3a7088c1ed66ab0118894b31e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340037
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-12-02 15:19:46 +00:00
Brian Osman
5fa45548b4 Revert "Add ByteCode output to skslc"
This reverts commit 68da339a11.

Reason for revert: Breaking Android roll

Original change's description:
> Add ByteCode output to skslc
>
> Change-Id: I447f56a3ef464ef9a3cfc644f6ef4e4ab4e08a62
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339498
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>

TBR=brianosman@google.com,johnstiles@google.com

Change-Id: Ie02d03dacc3b5ea33538d11dbb1241b8fe31fd86
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340036
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-12-02 14:14:08 +00:00
Brian Osman
68da339a11 Add ByteCode output to skslc
Change-Id: I447f56a3ef464ef9a3cfc644f6ef4e4ab4e08a62
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339498
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-12-01 20:53:55 +00:00
John Stiles
dda1d31623 Enable SPIR-V disassembly output from skslc.
We now have SPIR-V golden outputs for `blend` and `shared` tests.
This exposes a handful of SPIR-V limitations for us to address.

Change-Id: Ie5278889b8a61432403d06231b17765885bee0ac
Bug: skia:10694
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/337182
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-11-20 22:54:26 +00:00
John Stiles
445df8d115 Factor out redundant code for compiling GLSL/Metal/SPIR-V/CPP/H files.
Change-Id: I4eb9fb50e645f503d71cd6423bfc38076a7c2119
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/336777
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-11-20 20:51:47 +00:00
Brian Osman
0006ad01ce Stop cloning builtin functions
Previously, any builtin functions would be optimized as a side-effect of
optimizing programs that used them. Now that shared elements aren't
being optimized in that way, we explicitly optimize any shared modules
when they are first created. We don't remove dead elements, but we
we do substitute settings, simplify, and inline.

Bug: skia:10905
Change-Id: I701b5e9f52fb880ef3e6f4c67694d08602f47e95
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/336440
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-11-20 15:02:54 +00:00
John Stiles
a446ca15ed Reland various cleanups to SkSLMain.
These cleanups were reverted, as they were part of the CL that added
`--` delimiters to skslc. This CL reinstates the cleanups, but does not
reinstate `--` delimited multiple-command-line support in skslc.

Change-Id: Id70ed87aa239b46d232492fc48791158b35512f3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/336677
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-11-20 14:13:43 +00:00
Brian Osman
7b239054d9 Revert "Replace skslc worklist files with -- delimited command lines."
This reverts commit 3e1b771ce4.

Reason for revert: Not working on Windows.

Original change's description:
> Replace skslc worklist files with -- delimited command lines.
>
> Command lines with delimiters are a simpler approach; they don't require
> a scratch file to be created and parsed. (I didn't consider this
> approach until after implementing worklists.)
>
> This also fixes a minor issue with result codes when processing multiple
> files at once; in particular, unit tests can ignore compile errors, but
> regular fragment processor compilation should treat compile errors as
> fatal and stop the build.
>
> Change-Id: I3f153e7670d757c6b021bf60a260a2cd3f2090aa
> Bug: skia:10919
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334428
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>

TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: skia:10919
Change-Id: I0e4bae8a8e09c61eac4e79453fd38e5e81b29e89
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335858
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-11-18 18:02:25 +00:00
John Stiles
031a76756e Stop the inliner after it has inlined 2500 statements in a program.
This prevents OOMing when given a pathological input, but is large
enough that almost all inputs should continue to compile as-is.

Change-Id: If5c46711b886ee08495bfd09af537e9dc7ea5649
Bug: skia:10945, oss-fuzz:27442
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334838
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-11-13 23:02:11 +00:00
John Stiles
3e1b771ce4 Replace skslc worklist files with -- delimited command lines.
Command lines with delimiters are a simpler approach; they don't require
a scratch file to be created and parsed. (I didn't consider this
approach until after implementing worklists.)

This also fixes a minor issue with result codes when processing multiple
files at once; in particular, unit tests can ignore compile errors, but
regular fragment processor compilation should treat compile errors as
fatal and stop the build.

Change-Id: I3f153e7670d757c6b021bf60a260a2cd3f2090aa
Bug: skia:10919
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334428
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-11-13 21:27:20 +00:00
John Stiles
a1e8fe3a2b Update skslc to compile multiple files during one invocation.
skslc can now take a `.worklist` file as an input, containing multiple
"command lines" to run in sequence. compile_sksl_tests.py now assembles
a worklist file and runs skslc one time, rather than running skslc
once per each target. This improves compile times on Windows
significantly (where spawning skslc hundreds of times is much more
expensive than on Linux/Mac).

One subtle behavioral difference with .worklist files: if an error is
encountered, it is written to the output file instead of to stdout.
Previously, compile_sksl_tests was in charge of for capturing stdout
and overwriting the compiler output with the error message, but this
doesn't work when many files are being compiled (which errors are
associated with which files?)

This refactor exposed a minor latent bug--when encountering an error,
skslc would previously exit() immediately without closing its
FileOutputStream. This led to an assertion when exit() was replaced with
normal returns. Since FileOutputStream is only used by skslc, and in
every case the desired behavior is just to close the stream cleanly,
FileOutputStream now closes the file in its destructor instead of
asserting that we haven't done so.

Change-Id: Ia55baff0c11fe466923bde2e0c944df9f2ccd092
Bug: skia:10919
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334099
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-11-12 15:05:27 +00:00
Brian Osman
d7e7659cad Move GrShaderCaps from Program::Settings to Compiler
This ties the caps to the compiler instance, paving the way for
pre-optimizing the shared code. Most of the time, the compiler is
created and owned the GPU instance, so this is fine. For runtime
effects, we now use the shared (device-agnostic) compiler instance
for the first compile, even on GPU. It's configured with caps that
apply no workarounds. We pass the user's SkSL to the backend as
cleanly as possible, and then apply any workarounds once it's part
of the full program.

Bug: skia:10905
Bug: skia:10868
Change-Id: Ifcf8d7ebda5d43ad8e180f06700a261811da83de
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331493
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-11-04 19:38:33 +00:00
John Stiles
f972313fa1 Add test for disabling the inliner.
This golden verifies that when the inline threshold is zero, inlining is
not performed.

Change-Id: Icad6e1faed569dd1b2469874be3b9e635ad0b9ad
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/325656
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2020-10-12 17:14:07 +00:00
Brian Osman
3d87e9f660 Reorganize how SkSL includes are parsed and stored
This binds together the IntrinsicMap and SymbolTable for each include to
a single entity, with helper functions that create and return them. Used
a little bit of macro trickery to move all of the standalone/runtime
logic into loadIncludeFile, which drastically reduces boilerplate.

Change-Id: Ic70c0d67967cc614daeab5c50412ab69dcdf2fea
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/324124
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-10-09 14:49:43 +00:00
John Stiles
eaaa71b705 Add test for sk_Caps.mustGuardDivisionEvenAfterExplicitZeroCheck.
Change-Id: Ib1374e1dce1a654a83813dbe341774bd91729796
Bug: skia:10694, skia:10819
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/324356
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-10-09 13:48:13 +00:00
John Stiles
8f84cee9ab Add test for sk_Caps.inBlendModesFailRandomlyForAllZeroVec.
This CL also alphabetizes the various factories in ShaderCapsFactory.

Change-Id: I0378ceb821678173e72690d5563d2a9a92d90201
Bug: skia:10694, skia:10819
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/324257
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-10-09 13:44:43 +00:00
John Stiles
e1589a1e19 Add line breaks to make dehydrated files more merge-friendly.
Change-Id: Ica329608e5ee7f873a55dc27e6c14bb8734665a3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/324118
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2020-10-08 18:55:02 +00:00
Brian Osman
41d906752d Allow use of SkTHash* in skslc
hash_fn was the only missing piece. I tried to avoid the duplicated code
(eg, by compiling SkOpts.cpp in skslc), but that triggers a chain of
dependencies that was hard to break. (SkColor, SkImageInfo, ...).

Change-Id: Iddf4291b4038c95930ef512328a0e9e67efe3944
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/322493
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-10-05 21:34:26 +00:00
Brian Osman
a6ca9757d3 Let skslc use more of Skia's core
With these changes, SkTArray/SkSTArray can be used.

Change-Id: Ibf9a720086ac4342157a665786afac713d56c300
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/321786
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-10-02 20:58:54 +00:00
Brian Osman
e498b3c75b Various cleanup related to symbol tables
- Remove a spurious symbol table inserted by convertProgram. start()
  already pushes a symbol table, and this was pushing a second one,
  which didn't seem necessary. (The Parser can inject symbols for types
  it discovers, but I can't justify those needing to be in a different
  table than the rest of the program elements?)
- The convertProgram one had a comment indicating that it was popped by
  the Compiler. That wasn't true, so this gets us one step closer to
  balance.
- The one in start() is meant to be balanced by a pop in finish(), but
  no one ever called finish(). Add that call in, and also rearrange
  things so that the base symbol table is a parameter to start(), rather
  than just setting it on the IR generator. (There's more of this
  pattern around, but I wanted to limit the scope of this CL).
- When dehydrating the include files, we had logic to work around the
  extra symbol table (absorbing the symbols) - that's not needed now.
- Simplify some other logic in processIncludeFile (no need to make so
  many string copies). Always just put the incoming include file strings
  into the root table, also. It's largely irrelevant where they go.

Change-Id: I18d897af3d5fa6506e11024beb9bb70e6cc5b538
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319038
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-09-23 19:55:08 +00:00
John Stiles
881a10c6e8 Revert "Add program-settings flag to disable the inliner."
This reverts commit 910845fac1.

Reason for revert: IRGenerator inline change reverted

Original change's description:
> Add program-settings flag to disable the inliner.
>
> Change-Id: I6c4e7f6a2aab6710221029022a3a5f3ec323c5e2
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317856
> Commit-Queue: John Stiles <johnstiles@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>

TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com

Change-Id: Ie38a29495ea8497f9db26d2603df179e696ac5ff
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317977
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2020-09-19 14:13:54 +00:00
John Stiles
910845fac1 Add program-settings flag to disable the inliner.
Change-Id: I6c4e7f6a2aab6710221029022a3a5f3ec323c5e2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317856
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-09-18 20:30:22 +00:00
John Stiles
be0a9ca63d Migrate remaining SkSL GLSL tests to golden outputs.
Change-Id: I72fd3083f75ca5bf74fb2c3b032465864a13aed5
Bug: skia:10694
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317771
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-09-18 19:22:19 +00:00
John Stiles
87e6ccde21 Migrate geometry SkSL tests to golden outputs.
Change-Id: I01c150d6bfcdd1500033521a87c058c7428c3521
Bug: skia:10694
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317769
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2020-09-18 17:34:22 +00:00
John Stiles
c884631f99 Migrate Derivatives tests to golden outputs.
Change-Id: I35ff25c4cc394c1a4a964207ece87095a9ba84cf
Bug: skia:10694
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317767
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-09-18 17:30:07 +00:00
John Stiles
0ed9f31f6a Migrate several GLSL workaround unit tests to golden files.
We now support building an SkSL golden output twice, once honoring the
custom #pragma settings, and once more ignoring the settings. This
allows us to see the output of the workaround technique, alongside the
"default-settings" output which should not contain a workaround.

To implement this, skslc now supports a flag: --[no]settings.
When it's set, /*#pragma settings*/ comments are honored. When it's not
set, skslc ignores the comments. compile_sksl_tests.py passes this flag
along to skslc.

This approach is not strictly limited to workarounds; the
"TypePrecision" GLSL test was also updated to use this technique.

Change-Id: I79204df047b024533ed6bc1f4c088e0e878d5bb1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317246
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-09-17 16:41:18 +00:00
John Stiles
72664bede4 Add support for #pragma settings comments in SkSL.
This will allow us to write skslc-based golden tests that deviate from
the standalone skslc settings.

This CL provides six options; more will be added as necessary.
- Default (caps)
- UsesPrecisionModifiers (caps)
- Version110 (caps)
- Version450Core (caps)
- ForceHighPrecision (settings flag bit)
- Sharpen (settings flag bit)

Change-Id: I9b779e039b2f0c0ccf43dca226fb4844aff3526b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317237
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-09-16 22:19:58 +00:00
John Stiles
194b9b9334 Add support for ShaderCapsFactory to skslc.
In a followup CL, this will allow SkSL golden tests to control their
caps settings.

Change-Id: I2aace30e5567de8a52690c89b27bbab0c2d766e3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317177
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-09-16 15:11:07 +00:00
John Stiles
f621e234fc Fix cases of variable shadowing in SkSL.
Change-Id: I83aec4a2f65fe34b79ecc292131feb4027ce4bd4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/313139
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-08-25 18:23:52 +00:00
Brian Osman
a4b9169fb6 Remove 'in' variables from SkRuntimeEffect
Runtime effects previously allowed two kinds of global input variables:
'in' variables could be bool, int, or float. 'uniform' could be float,
vector, or matrix. Uniform variables worked like you'd expect, but 'in'
variables were baked into the program statically. There was a large
amount of machinery to make this work, and it meant that 'in' variables
needed to have values before we could make decisions about program
caching, and before we could catch some errors. It was also essentially
syntactic sugar over the client just inserting the value into their SkSL
as a string. Finally: No one was using the feature.

To simplify the mental model, and make the API much more predictable,
this CL removes 'in' variables entirely. We no longer need to
"specialize" runtime effect programs, which means we can catch more
errors up front (those not detected until optimization). All of the API
that referred to "inputs" (the previous term that unified 'in' and
'uniform') now just refers to "uniforms".

Bug: skia:10593
Change-Id: I971f620d868b259e652b3114f0b497c2620f4b0c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309050
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-08-10 22:00:44 +00:00
Ethan Nicholas
b33fa3f7d2 simplified SkSL REHYDRATE=0
Change-Id: I653716df5e93dc5c520309729712a78e750a2790
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/307696
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2020-08-06 19:14:21 +00:00
Ethan Nicholas
c18bb51735 SkSL include files are now stored in a binary format
This speeds up compiler construction, because we no longer have to parse
and process a bunch of SkSL source code during startup.

Change-Id: I6d6bd9b5ce78b1661be691708ab84bf399c6df8b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305717
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2020-07-31 13:48:25 +00:00
Brian Osman
e3f57a4e62 Revert "Add SkSLCompiler::toHLSL, using SPIRV-Cross"
This reverts commit cf7c7e38e8.

Reason for revert: Breaking our Flutter build.

Original change's description:
> Add SkSLCompiler::toHLSL, using SPIRV-Cross
> 
> Change-Id: Ia7a11a726cac006f6acc36efe8fc2ff27f30af72
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270837
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>

TBR=jvanverth@google.com,bsalomon@google.com,brianosman@google.com,ethannicholas@google.com

Change-Id: I2a1353864e2225578271573a8f7157d95fb0c969
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/271744
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-02-19 19:53:30 +00:00
Brian Osman
cf7c7e38e8 Add SkSLCompiler::toHLSL, using SPIRV-Cross
Change-Id: Ia7a11a726cac006f6acc36efe8fc2ff27f30af72
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270837
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-02-19 19:15:21 +00:00
Mike Klein
c0bd9f9fe5 rewrite includes to not need so much -Ifoo
Current strategy: everything from the top

Things to look at first are the manual changes:

   - added tools/rewrite_includes.py
   - removed -Idirectives from BUILD.gn
   - various compile.sh simplifications
   - tweak tools/embed_resources.py
   - update gn/find_headers.py to write paths from the top
   - update gn/gn_to_bp.py SkUserConfig.h layout
     so that #include "include/config/SkUserConfig.h" always
     gets the header we want.

No-Presubmit: true
Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-04-24 16:27:11 +00:00