Commit Graph

209 Commits

Author SHA1 Message Date
John Stiles
e1182785be Create a diagonal-matrix Constructor class.
This constructor takes a single argument and splats it diagonally across
an otherwise-zero matrix. These are also sometimes referred to as a
uniform-scale matrix.

Change-Id: I1ed8140f55f5cad4029015807b220d6475401daa
Bug: skia:11032
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/390716
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-03-31 18:00:42 +00:00
Brian Salomon
5ca24f94ab Reland "Reland "Add GrRuntimeFPBuilder""
This is a reland of 7508b54af3

Original change's description:
> Reland "Add GrRuntimeFPBuilder"
>
> This is a reland of 4b39aaf2cb
>
> Original change's description:
> > Add GrRuntimeFPBuilder
> >
> > Like SkRuntimeShaderBuilder but for internal use for creating FPs.
> >
> > Currently it requires that the code be a static string so it can
> > easily make a static SkRuntimeEffect instance for each effect.
> >
> > Bug: skia:11771
> >
> > Change-Id: I18148eb33e7d28c804e4a13bcef88c89c06b2c9b
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386889
> > Commit-Queue: Brian Salomon <bsalomon@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
>
> Bug: skia:11771
> Cq-Include-Trybots: luci.skia.skia.primary:Build-Debian10-GCC-x86_64-Release-Shared_Docker,Build-Win-Clang-x86_64-Release-Shared,Build-Win-MSVC-x86_64-Release-Shared
> Change-Id: I10a7974aa209f9cd63a5dc1ef21a36822b49bda3
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388097
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>

Bug: skia:11771
Change-Id: Id20797ecf5b34847fdc22e28d3e68db88f2519c3
Cq-Include-Trybots: luci.skia.skia.primary:Canary-Android
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388458
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-03-24 16:11:42 +00:00
Brian Salomon
bb0ed8e487 Revert "Reland "Add GrRuntimeFPBuilder""
This reverts commit 7508b54af3.

Reason for revert: android roll

Original change's description:
> Reland "Add GrRuntimeFPBuilder"
>
> This is a reland of 4b39aaf2cb
>
> Original change's description:
> > Add GrRuntimeFPBuilder
> >
> > Like SkRuntimeShaderBuilder but for internal use for creating FPs.
> >
> > Currently it requires that the code be a static string so it can
> > easily make a static SkRuntimeEffect instance for each effect.
> >
> > Bug: skia:11771
> >
> > Change-Id: I18148eb33e7d28c804e4a13bcef88c89c06b2c9b
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386889
> > Commit-Queue: Brian Salomon <bsalomon@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
>
> Bug: skia:11771
> Change-Id: I10a7974aa209f9cd63a5dc1ef21a36822b49bda3
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388097
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>

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

Change-Id: I01a1567edd4162f1054137886052f5065a9e6175
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11771
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388397
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-03-23 18:11:47 +00:00
Brian Salomon
7508b54af3 Reland "Add GrRuntimeFPBuilder"
This is a reland of 4b39aaf2cb

Original change's description:
> Add GrRuntimeFPBuilder
>
> Like SkRuntimeShaderBuilder but for internal use for creating FPs.
>
> Currently it requires that the code be a static string so it can
> easily make a static SkRuntimeEffect instance for each effect.
>
> Bug: skia:11771
>
> Change-Id: I18148eb33e7d28c804e4a13bcef88c89c06b2c9b
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386889
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Bug: skia:11771
Cq-Include-Trybots: luci.skia.skia.primary:Build-Debian10-GCC-x86_64-Release-Shared_Docker,Build-Win-Clang-x86_64-Release-Shared,Build-Win-MSVC-x86_64-Release-Shared
Change-Id: I10a7974aa209f9cd63a5dc1ef21a36822b49bda3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388097
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-03-23 14:08:48 +00:00
Brian Salomon
50af8c2656 Revert "Add GrRuntimeFPBuilder"
This reverts commit 4b39aaf2cb.

Reason for revert: DLL fail

Original change's description:
> Add GrRuntimeFPBuilder
>
> Like SkRuntimeShaderBuilder but for internal use for creating FPs.
>
> Currently it requires that the code be a static string so it can
> easily make a static SkRuntimeEffect instance for each effect.
>
> Bug: skia:11771
>
> Change-Id: I18148eb33e7d28c804e4a13bcef88c89c06b2c9b
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386889
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

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

Change-Id: I13e22674a1bcb07b86342189bab84fc6cbb357e9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11771
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/387817
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-03-22 18:24:18 +00:00
Brian Salomon
4b39aaf2cb Add GrRuntimeFPBuilder
Like SkRuntimeShaderBuilder but for internal use for creating FPs.

Currently it requires that the code be a static string so it can
easily make a static SkRuntimeEffect instance for each effect.

Bug: skia:11771

Change-Id: I18148eb33e7d28c804e4a13bcef88c89c06b2c9b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386889
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-03-22 15:57:36 +00:00
John Stiles
e67bd1371e Migrate VarDeclaration conversion out of IRGenerator.
Change-Id: If5fb4f99d327bb429f60e8d6c526720dd02b0928
Bug: skia:11342
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386800
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-03-22 14:25:26 +00:00
John Stiles
cd7ba500b6 Migrate FunctionCall conversion out of IRGenerator.
We don't currently do FunctionCall optimization, but implementing
something along the lines of skia:10835 would probably involve doing
rewrites for optimization in FunctionCall::Make. This CL is the first
step down that road.

Change-Id: I249b02412e7ebac21bb98d6c5d61af3dcd6f1e69
Bug: skia:11342
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/387156
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-03-19 15:47:21 +00:00
John Stiles
bf16b6c5df Add Make factory function to Block.
Block::Make always makes a real Block object. This is important because
many callers rely on Blocks specifically; e.g. a function body must be a
scoped Block, nothing else will do.

However, unscoped Blocks are just a collection of Statements and usually
have more flexibility. So, Block::MakeUnscoped is a factory function
that will return the Statement as-is for a single-statement unscoped
Block. For an entirely empty Block, MakeUnscoped returns Nop.

Change-Id: Ied65d505bde4ea7f6157a039944018546e4b7333
Bug: skia:11342
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/384180
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-03-13 13:28:17 +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
Ethan Nicholas
24c1772ea4 Fixed an issue with DSL includes
It turned out that everywhere we were using or testing DSL code either
directly or indirectly imported big chunks of the SkSL library. These
imports turned out to be necessary; code written using just DSL.h would
fail with various template instantiation errors.

Change-Id: Iae72d15b0d6ef14614ac1a4ff08c36bc1876cd4d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/381638
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-03-09 20:07:00 +00:00
John Stiles
06d600fb9d Add Convert/Make factory functions to FieldAccess.
Change-Id: Ib1f5296c017374b833654f988ff89d11d8f78b4d
Bug: skia:11342
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/380458
Reviewed-by: Brian Osman <brianosman@google.com>
2021-03-08 17:44:17 +00:00
John Stiles
51d33982ad Add Convert/Make factory functions to IndexExpression.
Change-Id: I7a7874e58bf53978afce8a41b26092406b6490ed
Bug: skia:11342
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/380360
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-03-08 15:55:59 +00:00
Ethan Nicholas
daed2592bb Made SkSL DSL into public API
In addition to the unsurprising changes to eliminate references to
src/, we also had to tighten up some C++17-isms as they are not
permitted in public headers.

Change-Id: Ie5005a33d7a135e69fb66beca5e7a5f960dbd453
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/378496
Reviewed-by: Brian Osman <brianosman@google.com>
2021-03-04 21:03:58 +00:00
John Stiles
e2aec43cfc Convert IRGenerator::convertBinaryExpr to BinaryExpr::Make.
Interestingly, this reduces the size of our dehydated data
significantly, because we were storing the result type of the binary
expression explicitly. Now the result type is deduced automatically from
the left and right types by the Make call.

Change-Id: Ic6187a5c36774f5a4ed2ec579e9cd13b331832b5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377099
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-03-01 22:01:21 +00:00
John Stiles
90518f72b9 Convert IRGenerator::convertTernaryExpr to TernaryExpr::Make.
Change-Id: I3a9e8b278709485de51dca18b19f6fc7768dde51
Bug: skia:11342
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377098
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-03-01 14:20:30 +00:00
John Stiles
52d3b01da8 Convert IRGenerator::convertPostfixExpr to PostfixExpr::Make.
We have no optimizations on postfix-expressions at all so this is a very
straightforward cut-and-paste.

Change-Id: I73b3bc73ad833e668306301e6d6859e44230393a
Bug: skia:11342
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/376846
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-02-26 22:34:34 +00:00
John Stiles
ea5822ea27 Convert IRGenerator::convertDo to DoStatement::Make.
We currently don't have any optimizations for do-statements so the
primary benefit is moving code out of IRGenerator.

Change-Id: Ibc4d1ecd87ebef572e742dfdb15821cf4ac0f047
Bug: skia:11342
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/376179
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-02-26 17:08:01 +00:00
John Stiles
3e5871c498 Convert make_unique<ExpressionStatement> to ExpressionStatement::Make.
This allows for elimination expression-statements with no side effects
when they are first created, rather than later on in the control-flow
optimization pass.

Change-Id: I09ec8421a3af7fa37f98b0405657198c0a24f2ac
Bug: skia:11342, skia:11319
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/376136
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-02-26 14:58:31 +00:00
John Stiles
b321a07f16 Convert IRGenerator::convertFor to ForStatement::Make.
Since while statements are implemented in terms of a for loop, also
added ForStatement::MakeWhile() which assumes null for the init-stmt and
the next-expr.

We currently don't have any optimizations for for-statements so the
primary benefit is moving code out of IRGenerator.

Change-Id: I4b3fc3482e28b7d28065e85670a6037b511847ff
Bug: skia:11342
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375203
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-02-25 22:25:50 +00:00
John Stiles
cf3059e719 Convert IRGenerator::convertIf to IfStatement::Make.
This lets the Rehydrator and Inliner benefit from static optimization
opportunities, like converting `if (false) {...}` to a Nop.

Change-Id: I70b4fceab84c50ea270dc894b0d6fe0e7e2369eb
Bug: skia:11342
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375777
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-02-25 19:28:59 +00:00
John Stiles
e1d1b08203 Migrate convertSwitch to SwitchStatement::Make.
This splits switch() construction into two stages.

- One version of Make takes an array of case-values and case-statement
lists, and is responsible for reporting errors if the case-values are
not unique or are improperly typed. This is what the IR generator or DSL
will start with on its first encounter with the switch statement.

- The other version of Make takes an array of already-processed
SwitchCases and can assume the invariant that they're all correctly-
typed with unique values. This is what we will have when a statement
is inlined or otherwise cloned. (We still assert this invariant, for
correctness' sake, but in release mode we assume it.)

This CL doesn't perform any optimizations at Make time yet; it does work
equivalent to how `switch` works in the IR generator today. It does
improve duplicate case-label checking slightly; duplicate case labels
are now reported, and duplicate `default:` labels are detected.
(Multiple `default` labels won't pass the parser, but they can be
constructed in DSL.)

Change-Id: I537ce2c8236152d58641fb1793619d66a62c01a8
Bug: skia:11342
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372616
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-02-23 19:16:40 +00:00
John Stiles
6e88e041d9 Migrate convertSwizzle to Swizzle::Make.
There are two forms. Swizzle::Make supports components XYZW only;
Swizzle::MakeWith01 also supports the 01 components, and restructures
the zeros and ones into a constructor (as IRGenerator::convertSwizzle
has historically done). This means that once we are past the initial
IR generation stage, and we know that the 01 components have been
eliminated, we can avoid the extra 01-handling logic and just call
Swizzle::Make directly. This isn't a huge deal but it means that call
sites like the inliner can avoid some extra work that will never happen.

Change-Id: I46690c3d6b07feb6327ee72e8f66f15592a35554
Bug: skia:11342
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/371398
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-19 21:26:58 +00:00
Mike Klein
af8db303f7 promote the runtime mixer CF to the only mixer CF
Cq-Include-Trybots: luci.chromium.try:linux-blink-rel
Change-Id: I898fc64d8df625d22750cfe1145ba4b02acdfbb9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372078
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2021-02-19 11:43:47 +00:00
Mike Klein
7a2ff98ce6 clean up SK_SUPPORT_LEGACY_RUNTIME_EFFECTS
Cq-Include-Trybots: luci.chromium.try:linux-blink-rel
Change-Id: I4475982f0a5b17bcc4bae4b3f75557969cc70fd2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369856
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2021-02-13 22:01:14 +00:00
John Stiles
e8a2492b68 Migrate DefinitionMap logic to its own class.
This doesn't change any functionality. It just compartmentalizes a large
chunk of logic that was previously intertwined in the Compiler class.
This logic stands alone and doesn't need anything from the Compiler at
all except the generic "Defined" expression from the Context.

In followup CLs I intend to experiment with changes to the API and
logic, but factoring the code out seemed like a big enough change that
it deserved its own CL.

Change-Id: I3e1a7c62812c6f284167c967086ef4dd828a0b2e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/367879
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-02-09 02:27:26 +00:00
Brian Osman
001850105e Create SkSLOperators, centralize functionality
Change-Id: I3593e7ab0caac2fd572346038cbc8ff63e6fe970
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/366406
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-02-06 16:24:12 +00:00
Ethan Nicholas
c3bb9e3bbd add Start/EndFragmentProcessor to DSLWriter
Change-Id: I6f9d414d55b3ba64c3f67f3a590f6b7b5642062a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/364599
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-02-02 20:56:13 +00:00
John Stiles
ecdfc03f3b Add DSL headers to GN files.
Change-Id: I712b34874f36dc83812389d24bc0e4997ead1b12
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/363780
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-01 16:45:28 +00:00
Greg Daniel
29e521c533 Revert "Initial support for DSL FPs"
This reverts commit c48a23d774.

Reason for revert: Possibly breaking some builds on android roll

Original change's description:
> Initial support for DSL FPs
>
> Change-Id: I1abbe881f925ac6db4f7d672a391aadd349a33b5
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/361556
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>

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

Change-Id: Ia76b24293ab676fbf9e43f470cf3c3d6b96b2d34
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362696
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-01-30 02:51:51 +00:00
Ethan Nicholas
c48a23d774 Initial support for DSL FPs
Change-Id: I1abbe881f925ac6db4f7d672a391aadd349a33b5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/361556
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-01-29 21:07:18 +00:00
Ethan Nicholas
1ff760981d Added SkSL DSLFunction
Change-Id: Ibc995e908e5b4f8d1516e13d56854a4fcf5cc809
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/360556
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-01-28 16:13:19 +00:00
Ethan Nicholas
d6b6f3ec84 Added basic SkSL DSL statements
(and Ternary for good measure)

Change-Id: I4afa121d54ab9ba8d0814693ce53da7cb73ef340
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/353626
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-01-22 22:25:18 +00:00
Ethan Nicholas
5b9b0db5b8 SkSL vars now track their declaration instead of their initial value
This should not cause any functional changes, and is just a prerequisite
for upcoming DSL work.

Change-Id: Iea165d3b7ede39ccc9cf5f5d78f623bc883b391e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/356816
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-01-22 15:16:32 +00:00
Brian Osman
ce75036b3e SkSL: Remove ByteCode interpreter, generator, etc.
Change-Id: Ib150e6d6d3de34a85ce8051eea843ab3b2d7ab75
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/356921
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2021-01-22 14:38:41 +00:00
John Stiles
ac01aca0fe Migrate BuiltinTypes to a separate file from Context.
No code or functionality changes.

Change-Id: I24317767570ae9ebbfea56f873d98709fb22d8b9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/354876
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-01-15 17:23:16 +00:00
Ethan Nicholas
bffe80a29d Add SkSL DSLVar
Change-Id: I1093aa6bbdb481c98ea3dab10c06bfcf323b2a75
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/352058
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-01-12 14:36:26 +00:00
John Stiles
54e7c056d9 Separate out built-in SkSL types into their own struct.
Previously, these were in SkSL::Context directly. This change doesn't
remove them from the context entirely, but it gives them a dedicated
subclass and firewalls them off from the rest of the context.

Change-Id: I0c344bf7436a11b8494a5fe7542d0a4ef1ece964
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/352502
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-01-11 20:02:24 +00:00
Ethan Nicholas
6f4eee21ca Break SkSLInliner mangling out into a separate class
Change-Id: If0300761153d37b026fdc7756018c239ea6ca7ee
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/352505
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-01-11 19:55:04 +00:00
John Stiles
dc8ec31ce5 Move constant folding to a separate file.
This doesn't change any logic, just makes the IR generator a few
hundred lines shorter.

Change-Id: I92010191ee9283c33499c819d65fc85913f25824
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/352121
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-01-11 17:33:47 +00:00
Ethan Nicholas
b3d4e74d34 Add SkSL DSLType
Change-Id: I0bbda6a41391fc2a11dc812be5e9c0c0d14c4d75
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/351921
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-01-08 17:25:54 +00:00
Ethan Nicholas
950461497d Beginnings of the SkSL DSL framework
The code at this point doesn't do anything useful, but establishes some
of the basic types and patterns.

Change-Id: I580a9e75ffa3162879893450fb7d1f0905a10687
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350697
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
2021-01-07 21:53:01 +00:00
Brian Osman
be0b3b7363 Strip down SkSL::ExternalValues, limit them to functions
Previously ExternalValues were flexible, and could be used as raw values
(with the ability to chain access via dot notation), or they could be
callable. The only non-test use-case has been for functions (in
particles) for a long time. With the push towards SkVM, limiting
ourselves to this interface simplifies things: external functions are
basically custom intrinsics (and with the SkVM backend, they'll just get
access to the builder, and be able to do any math, as well as
loads/stores, etc).

By narrowing the feature set, we can rename everything to reflect that,
and it's overall clearer (the SkSL types now mirror FunctionReference
and FunctionCall directly, particularly in how they're handled by the
CFG and inliner).

Change-Id: Ib5dd34158ff85aae6c297408a92ace5485a08190
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350704
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-01-07 14:28:41 +00:00
Brian Osman
33c64a4473 SkSL: Remove "null" as a type and literal value.
Nullable fragment processors still exist, but they're handled
transparently by sample() within C++, so there's no need for .fp files
to ever do these tests manually.

Change-Id: Idf2bc58505207560553066c0126a2a036c5d970b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347039
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-12-23 16:21:57 +00:00
Ethan Nicholas
dcd2f869d3 Reland "Reland "Reland "Reland "Revert "Initial land of SkSL DSL."""""
This reverts commit 4129b6b65f.

Reason for revert: WASM breakage: https://task-driver.skia.org/td/UBRwnWYfbc5IwUWqtFMv

Original change's description:
> Revert "Reland "Reland "Reland "Revert "Initial land of SkSL DSL."""""
>
> This reverts commit 346dd53ac0.
>
> Change-Id: I93bb18438cc6c2ad43d058d6c3f95bcc65d0cea9
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/343916
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>

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

# Not skipping CQ checks because this is a reland.

Change-Id: If05145cf9d9c51f4c76fe523f6050a670b5da669
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345169
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2020-12-18 01:05:48 +00:00
Ethan Nicholas
4129b6b65f Revert "Reland "Reland "Reland "Revert "Initial land of SkSL DSL."""""
This reverts commit 346dd53ac0.

Change-Id: I93bb18438cc6c2ad43d058d6c3f95bcc65d0cea9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/343916
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-12-17 21:47:16 +00:00
Brian Osman
0a442b71b0 New SkSL code generator that emits directly to skvm
Still TODO:
- Function calls. Can do these by inlining everything (recursively).
- Additional flow control: ES2 for loops can be supported (via
  unrolling), and switch() can be implemented. (Was never done in
  ByteCode).
- Uniforms and params have been set up to work very generically (caller
  just supplies IDs, the generator collates everything into a master
  working list). Builtins should work the same way (caller supplies a
  map of builtin ID -> skvm::Val[]?), so that we don't need a special
  case for device coord.
- Figure out integer type policy. Today, it's a mix of only supporting
  signed integers, and just treating all integers as signed, even if
  they're not.
- Now that defining intrinsics is *much* simpler, stop defining so many
  of them in sksl_public.sksl, and just implement them here.

Change-Id: Id9771444ce54ccf8e6e408c44ebb3780c1170435
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/341980
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-12-17 19:16:25 +00:00
Brian Osman
d6f2338ab1 SkSL IR normalization: Convert while loops to for loops
Bug: skia:11095
Change-Id: Icd69df40675e5ecde5004e04a7dcd78eedf8343c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344765
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-12-16 23:03:23 +00:00
Ethan Nicholas
346dd53ac0 Reland "Reland "Reland "Revert "Initial land of SkSL DSL.""""
This reverts commit b37a693254.

Reason for revert: Breaking Flutter roll

Original change's description:
> Revert "Reland "Reland "Revert "Initial land of SkSL DSL.""""
>
> This reverts commit 6b07e0eb49.
>
> Change-Id: Ic01f31edf55b2d1a7533e0e8ed33b39b4846d937
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/343106
> Reviewed-by: John Stiles <johnstiles@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Auto-Submit: Ethan Nicholas <ethannicholas@google.com>

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

# Not skipping CQ checks because this is a reland.

Change-Id: I3373f186f4d0531bc8ab1e4392c512608389734f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/343518
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2020-12-11 20:45:13 +00:00
Ethan Nicholas
b37a693254 Revert "Reland "Reland "Revert "Initial land of SkSL DSL.""""
This reverts commit 6b07e0eb49.

Change-Id: Ic01f31edf55b2d1a7533e0e8ed33b39b4846d937
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/343106
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
2020-12-11 16:53:50 +00:00