Commit Graph

9184 Commits

Author SHA1 Message Date
John Stiles
e4da7b672f Migrate if-statement simplifyStatement logic to IfStatement::Make.
This performs essentially the same simplifications as before, just at
a different phase of compilation.

Change-Id: Ia88df6857d4089962505cd1281798fda74fd0b02
Bug: skia:11343, skia:11319
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/376177
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-03-03 18:12:35 +00:00
John Stiles
2dda50dd50 Add return-value check to the function finalizer.
Rather than have the inliner own this responsibility, the function
finalizer now detects if a function is supposed to return a value but
never actually does. This will allow us to detect this error case even
if the inliner is disabled. The inliner should no longer encounter
functions that claim to return a value but don't, so it will now assert
if one is encountered. (The inliner still has the logic to handle this
case gracefully, just in case.)

The check is currently very simple and doesn't analyze the structure of
the function, so it won't report cases where some paths return a value
and others don't, e.g. this will pass the test:

    int func() { if (something()) return 123; }

(This is good enough to resolve the inliner issue, though, as it only
occurred in functions with no value-returns at all.)

Change-Id: I21f13daffe66c8f2e72932b320ee268ba9207bfa
Bug: oss-fuzz:31469, oss-fuzz:31525, skia:11377
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377196
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-03-03 16:29:22 +00:00
Herb Derby
9ad09829f5 encapsulate GrSDFTOptions better
The logic for picking what type of sub run to create is spread
over several locations. Gather that altogether in drawingType().

Have GrSDFT close over all the data needed to calculate the
drawing type. This reduces plumbing to the processGlyphRun
routine.

The next CL should rename GrSDFTOptions to GrSDFTControl.

Change-Id: I99e74c11af6d3b3d9919e54fe1e7286fcfbf1bfb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/378036
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2021-03-03 14:27:32 +00:00
Brian Osman
dc4f8cd7ea Add early_fragment_tests layout qualifier to SkSL
Bug: skia:11356
Change-Id: I16322e6396dc7e7c8c50ba1d39e07311cf3bd346
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/376116
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-03-02 16:45:03 +00:00
John Stiles
95d0badecf Support self-assignment elimination in the constant-folder.
Interestingly, this improves our codegen even with the optimizer fully
enabled, as apparently statement chains like:
	`x = true; x = x; x = x;`
were getting transformed by constant-propagation into:
	`x = true; x = true; x = true;`
making them no longer candidates for self-assignment elimination.

Change-Id: I6d94a809e94b01a00fd92459fcbce898b3cbbb11
Bug: skia:11343
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377100
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:46:01 +00:00
John Stiles
0c2d14a1b9 Fix fuzzer-discovered error with inlining.
In http://review.skia.org/375776, an optimization was added to the
Inliner, causing it to skip generation of unnecessary temporary
variables. The fuzzer immediately discovered a flaw in this logic: the
"unnecessary" variable was actually used in the rare case that a
function failed to actually return a value. The inliner didn't detect
this case. Of course, this isn't a valid program either, so now we
report the error and cleanly fail.

Change-Id: I1f201cfd33f45cace3be93765a4e214e43a46e69
Bug: oss-fuzz:31469, oss-fuzz:31525
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377101
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-03-01 20:06:50 +00:00
John Stiles
b0eb20f83a Convert IRGenerator::convertPrefixExpr to PrefixExpression::Make.
Surprisingly, this actually improved our error detection slightly.
The expression `- -half4(0)` can now be simplified to `half4(0)` at
IR generation time, which allows the constant-folder to detect a
constant zero (and from there, a division by constant zero).

Change-Id: I8c4f6ab522efab5bf98913f9c6a1487b7af39a99
Bug: skia:11342, skia:11343
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/376842
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-02-26 22:34:05 +00:00
Brian Osman
a654faaf7f Add permittedLayoutFlags to checkModifiers
For now, just use this to prevent *any* layout qualifiers from appearing
on functions, or their parameters.

Bug: skia:11301
Change-Id: I05d8118c7121048c6ef49695a54e3714a8f8687e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/376796
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-02-26 18:38:31 +00:00
Brian Osman
7b361499c9 Align SkSL const rules more closely with GLSL
This adds Analysis::IsConstantExpression, to determine if an expression
is a constant-expression. It now expands to cover 'const' local and
global variables, because we also enforce that the initializer on those
variables is - in turn - a constant expression.

This fixes 10837 - previously you could initialize a const variable with
a non-constant expression, and we'd emit GLSL that contained that same
pattern, which would fail to compile at the driver level. That should
not be possible any longer.

Bug: skia:10679
Bug: skia:10837
Change-Id: I517820ef4da57fff45768c0b04c55aebc18d3272
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375856
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-02-26 17:44:11 +00:00
John Stiles
bb8542f086 Fix fuzzer-discovered error with ~ prefix on literals.
The expression `~123` was making a PrefixExpression of type $intLiteral.
It should be converted to type `int` when the ~ prefix is applied.

This change also changes the output from oss-fuzz:27614. Both programs
are essentially nonsense expressions with no real behavior, so this is
fine.

Change-Id: I586be149ce95136fabee72fdd3473814d54948cf
Bug: oss-fuzz:31410
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/376620
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:30:26 +00:00
Mike Klein
1f77cd802c always work from fBitmap in table CF
No point holding two copies of our data, an SkBitmap and fStorage array.
The GPU backend wants a bitmap, so make the CPU backend work from that.

Updating the flattened format removed the last use of SkPackBits.

Change-Id: I97f75ebe9324ec5eed37dfe6282e10d0fe08711f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/376599
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Adlai Holler <adlai@google.com>
2021-02-26 14:48:19 +00:00
Ethan Nicholas
34c7e11492 Revert "Revert "SkSL DSL now reports the C++ line numbers of errors""
This reverts commit 3a4e19da8e.

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

Change-Id: I5ae97aba2df5b9c3b3dcca8e30da4e5ce9009109
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/376117
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-02-26 12:19:45 +00:00
Brian Salomon
76d13bbdf8 Remove texture idle proc mechanism
Bug: skia:11369
Change-Id: I0d1a74cc64dd74486acbb69df529ccc0f8b63ef3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375202
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-02-25 22:23:20 +00:00
Ethan Nicholas
b956304bc7 Revert "Revert "Add DSL PossibleExpression & PossibleStatement""
This reverts commit 4903482a2a.

Change-Id: Ie56583344897fcb2c072bcac4d97d582edeadf07
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375660
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-02-25 19:50:20 +00:00
John Stiles
511c500ad4 Avoid generating unused variables in the Inliner.
These variables were later being eliminated by the dead-code-elimination
pass, so you can't see them directly in the final output, but removing
them affects the name mangling off all future symbols, so it causes an
enormous ripple effect in the diff. And of course, it's a waste of time
and memory to synthesize IRNodes just to destroy them later.

If we disable control-flow analysis, we lose the dead-code-elimination
pass entirely; this change is also beneficial for emitting better code
when optimizations are turned off.

Change-Id: I882b3be4f3fd99b77d99b6abe128f26bb9252c89
Bug: skia:11319
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375776
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-02-25 19:18:19 +00:00
Adlai Holler
38b9a4bc3e Revert "Support sharing promise images between DDLs"
This reverts commit 07e11d48cb.

Reason for revert: Broke DDL3_ASAN and DDL3_TSAN

Original change's description:
> Support sharing promise images between DDLs
>
> - Migrate our code to SkImage::MakePromiseTexture
> - Have DDLTileHelper share one SKP and one set of promise images across all tiles.
> - Disallow on-the-fly allocation of mips for promise textures.
>
> Bug: skia:10286
> Change-Id: Ie35976958454fc520f3c9d860e6285441260c9f7
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291938
> Commit-Queue: Adlai Holler <adlai@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>

TBR=robertphillips@google.com,adlai@google.com

Change-Id: I939b14875d1a20e4a92eab94680adcfe9596ad81
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10286
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375738
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Adlai Holler <adlai@google.com>
2021-02-25 17:55:00 +00:00
Adlai Holler
07e11d48cb Support sharing promise images between DDLs
- Migrate our code to SkImage::MakePromiseTexture
- Have DDLTileHelper share one SKP and one set of promise images across all tiles.
- Disallow on-the-fly allocation of mips for promise textures.

Bug: skia:10286
Change-Id: Ie35976958454fc520f3c9d860e6285441260c9f7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291938
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-02-25 17:00:19 +00:00
Florin Malita
4903482a2a Revert "Add DSL PossibleExpression & PossibleStatement"
This reverts commit d42932a1b5.

Reason for revert: Breaking CMake and SKQP builds.

Original change's description:
> Add DSL PossibleExpression & PossibleStatement
>
> These are currently unused, but in future CLs they will be used to
> capture line number information in DSL error handling.
>
> Change-Id: Ieee730e0ad8323043437972fedb5bec471c367e4
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375069
> Reviewed-by: John Stiles <johnstiles@google.com>

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

Change-Id: I2062c9964569c9129a2145f9e45f849310129687
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375658
Reviewed-by: Florin Malita <fmalita@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
2021-02-25 13:19:19 +00:00
Florin Malita
3a4e19da8e Revert "SkSL DSL now reports the C++ line numbers of errors"
This reverts commit 8a43a2889e.

Reason for revert: Prereq revert for https://skia-review.googlesource.com/c/skia/+/375069

Original change's description:
> SkSL DSL now reports the C++ line numbers of errors
>
> This is done a best-effort basis. Positions will only be reported in
> Clang and GCC, and may not be reported in every possible situation.
>
> Change-Id: I7efb15781546b95e667fee34e488366174bb5f36
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/374600
> Reviewed-by: John Stiles <johnstiles@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>

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

Change-Id: I173cb355533d6f99c9561177b68f56924fe8a98f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375657
Reviewed-by: Florin Malita <fmalita@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
2021-02-25 13:17:59 +00:00
Chris Dalton
bb33be21cf Use SIMD to update hw tessellation tolerances
Bug: chromium:1172543
Change-Id: I223566197d1f2fd5fea07302f48ab89f50a36187
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/374840
Reviewed-by: John Stiles <johnstiles@google.com>
2021-02-25 00:33:48 +00:00
Ethan Nicholas
8a43a2889e SkSL DSL now reports the C++ line numbers of errors
This is done a best-effort basis. Positions will only be reported in
Clang and GCC, and may not be reported in every possible situation.

Change-Id: I7efb15781546b95e667fee34e488366174bb5f36
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/374600
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-02-24 22:20:31 +00:00
Brian Osman
029851d951 Remove fragmentProcessor field access
Change-Id: Iafeb13812851271a5262730e9c0642d4469c273f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375020
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-02-24 21:33:36 +00:00
Ethan Nicholas
d42932a1b5 Add DSL PossibleExpression & PossibleStatement
These are currently unused, but in future CLs they will be used to
capture line number information in DSL error handling.

Change-Id: Ieee730e0ad8323043437972fedb5bec471c367e4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375069
Reviewed-by: John Stiles <johnstiles@google.com>
2021-02-24 21:04:18 +00:00
John Stiles
c1a98b8736 Move shader caps into SkSL context.
Previously these existed in each Program, but they are unchanging for
the lifetime of the Compiler. Also, their presence in the Context will
allow the SkSL::Setting class to access them outside of the IRGenerator.

Also, removed some code which allowed the IRGenerator to support null
shader-caps; this never actually happens. (The Compiler asserts that
they are non-null; the GLSL code generator uses the caps bits without a
null check, etc.)

Change-Id: Id58743a0c2ac068cb60ec35648b4f758bf28bbe3
Bug: skia:11365, skia:11319
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375067
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-02-24 20:00:54 +00:00
Ben Wagner
5d9c20ecc9 Make TextBlob 'Text' allocators public.
This will allow users to create PDFs with the actual text embedded. This
will allow for correct search and copy operations on the generated PDF.

Since these are now public, SkTextBlobBuilderPriv is no longer needed
and is removed. For consistency, the allocRunRSXform overload is renamed
to allocRunTextRSXform.

Change-Id: I44be82d9038a433e1221d5cbfd8ed113ecb6d4fa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375017
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2021-02-24 18:48:44 +00:00
Herb Derby
72917e4529 return void* instead of char* from alignedBytes
Not as many casts needed to use this.

Change-Id: I871b5f3f9658d349d08d396f2cb8ec5498c3b50b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375061
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2021-02-24 17:23:54 +00:00
Ben Wagner
0baacb50bc Remove lang parameter from TextBlob alloc methods.
The 'lang' was never stored or used, so this makes no current practical
difference. The original intent was to be able to specify a language so
that it could be emitted as a 'Lang' override in the 'ActualText' when
generating a PDF. However, due to the way 'ActualText' is generally used
this would be impractical. If there is ever a desire to mark up sections
of the PDF with a specific language it would be better handled in a
different way.

Change-Id: Id63596190235fc45ce17249b9b578b6f9b838b2b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375060
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2021-02-24 17:08:04 +00:00
Brian Osman
a77ed8b382 Add flags for all layout qualifiers, check for duplicates
Now, even if a qualifier has a default value, we will know that it
appeared in the text. We can use that to check for redundant qualifiers
(as is being done here), and in the IR generator to prevent any use of
certain qualifiers, depending on context. (eg, runtime effects, wrong
shader stage, on a parameter declaration, etc.)

Bug: skia:11301
Change-Id: I2cd6ad35c2b4c4d6f87ade97e80aea84dc16ee4b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/374616
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-02-24 16:22:26 +00:00
Chris Dalton
7c0200a8e2 Move cubic cusp existence test into GrStrokeHardwareTessellator.cpp
GrStrokeHardwareTessellator is the only user that needs to simply
check if a cusp exists at all. Making the check local speeds up the
microbench from 502us -> 392.

Bug: chromium:1172543
Change-Id: I52adf9ef0a66e1267435e6ce41f01ee1eda17d7a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/373744
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-02-24 08:24:53 +00:00
John Stiles
642cde289d Optimize @switch statements in SwitchStatement::Make.
At IR generation time, this CL limits our optimizations to only
@switch statements. A regular switch statement will only be optimized
during the optimization phase even if the switch-value is a known
compile-time constant. This is done to avoid upsetting our reachability
analysis.

Most of this CL is moving existing logic from SkSLCompiler into
SkSLAnalysis and SkSLSwitchStatement. Although the diffs look large, the
actual changes are very small.

Change-Id: I90920f41bc386dfa7a980ae7510f6681231a5120
Bug: skia:11340, skia:11342, skia:11319
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372679
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-02-23 21:36:04 +00:00
Brian Osman
4a015c5092 Require initializers on const variable declarations
Bug: skia:10837
Change-Id: I33da2eb1e723ed04ab62d65c21e54306dd362bed
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372677
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-02-23 20:55:01 +00:00
Mike Klein
4d68c244a7 refactor high-contrast filter
Rewrite as one cacheable runtime effect with uniforms paralleling
SkHighContrastConfig.  This is mostly for style, in the sense of
readability but also how I'd recommend writing these effects generally:
one program body controlled by uniforms.  Callers needing specialization
can write their own effect (or use our TBD uniform->constant facility).

Test isAlphaUnchanged(), and make it so by not saturating c.a.

MaliT880 was producing seriously bad results until I switched to mix().

Change-Id: Ia4cfef25fe26643f6832a5fa0843b28dafc5b284
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372295
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2021-02-23 20:22:07 +00:00
Ethan Nicholas
63f75fc1b6 SkSL DSL function objects are now callable
Change-Id: I10d561eec456a7917681d7bdf0b1bd2f5ee5ad5f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/374217
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-02-23 20:06:18 +00:00
Brian Salomon
e666254f0f Remove SkImage_Base::peekProxy.
This is the only place we provide a proxy from a SkImage other than
asView() and is only used in one place in the library. Add a utility
function to replace uses in tests based on asView().

Bug: skia:11208
Change-Id: Ica6eae6e5f153f208523331566acc0360925a20e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/373617
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-02-23 19:59:31 +00:00
Brian Salomon
18ab2030e3 Make GrGLSLFragmentProcessors be created as std::unique_ptr.
Rename factory function from createGLSLInstance() to makeProgramImpl()

Bug: b/180759848
Bug: skia:11358
Change-Id: I095bdf1f26db5a8192fa8ab59000db4a1d561d96
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/373738
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-02-23 19:31:01 +00:00
John Stiles
56566c68aa Remove obsolete test outputs.
The test inputs were removed at http://review.skia.org/360778

Change-Id: Ib2918f3f984cd80463bacb822ef510ee9feb1e77
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/373916
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-02-23 19:17:51 +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
Brian Osman
4882e9a43d Remove specific blend mode layout qualifiers
These were unused - we always enable the advanced blend equation
extension using "blend_support_all_equations" (if enabling the
extension is required at all).

Change-Id: I95fd6483ec54dfaf983290de95629fe0e86c22e8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/373877
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
2021-02-23 15:45:55 +00:00
John Stiles
2b3d1f2086 Remove constant propagation from static-switch test.
Constant propagation might be going away, but static-switches are likely
here to stay. Avoid conflating the two in this test.

Change-Id: If4b6c99c85f124d3bbc20da858693f09f5e4fd59
Bug: skia:11319
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/374117
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-23 15:39:05 +00:00
John Stiles
04ca41acf3 Fix switch optimization pass.
The optimizer now properly recognizes all types of exits from a switch
statement. Break, continue and return are all potential exits and need
to be considered when determining the exit path from the switch.

Previously, dead code elimination was hiding the effects of this bug
from us, but it meant that an optimized switch had the potential to
generate lots of worthless IR nodes which then needed to be detected and
eliminated by the CFG. In particular, this affected the enum form of
blend, causing a catastrophic amount of extra work to be done.

Change-Id: If857e38cadfc016884624ea4db25a273ad3dce5b
Bug: skia:11352
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372958
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-02-23 15:38:24 +00:00
Ethan Nicholas
bd97400744 Split IRGenerator's VarDeclaration processing into two parts
This allows things to align better between the IR and DSL sides
and gives us equivalent error handling on both sides.

Change-Id: I6d5569e29df51a4d1a6cb0ad1e6611d419dfe30c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/373737
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-02-22 22:02:45 +00:00
Brian Osman
ffee4766fa SkSL: Allow 'const' on function parameters
Change-Id: I672345116e3b5538c0f7e8c5f2f74aa56bb81e6d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372676
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-02-22 21:40:26 +00:00
Chris Dalton
ed82686819 Delete GrSTArenaList
The intent of this class was to abstract the internal linked list used
by GrStrokeTessellateOp, but it seems to just make things more
complicated. We have a need now to iterate the list with more freedom
than is offered by GrSTArenaList, so it seems best to just use a plain
C-style linked list instead.

Bug: chromium:1172543
Change-Id: Ia76be83c523bd3c285200099a529ccd3818490b6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372656
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-02-22 20:56:27 +00:00
Ben Wagner
a3e5e555d5 Reland "Reland "Test mac system font variations.""
This reverts commit 759f2613b5.

Reason for revert: Fix bzl build.

Original change's description:
> Revert "Reland "Test mac system font variations.""
>
> This reverts commit ba55be671d.
>
> Reason for revert: G3 roll
>
> (08:59:24) ERROR: third_party/skia/HEAD/BUILD:926:10: Compiling third_party/skia/HEAD/tests/TypefaceMacTest.cpp failed: (Exit 1) driver_is_not_gcc failed: error executing command third_party/crosstool/v18/stable/toolchain/bin/driver_is_not_gcc '-frandom-seed=blaze-out/k8-fastbuild/bin/third_party/skia/HEAD/_objs/dm/TypefaceMacTest.pic.o' -DSK_USE_FREETYPE_EMBOLDEN ... (remaining 383 argument(s) skipped).  [forge_remote_host=ixog19]
> third_party/skia/HEAD/tests/TypefaceMacTest.cpp:31:45: error: unknown type name 'CTFontRef'
>     auto makeSystemFont = [](float size) -> CTFontRef {
>                                             ^
> third_party/skia/HEAD/tests/TypefaceMacTest.cpp:33:46: error: use of undeclared identifier 'kCTFontUIFontSystem'
>         return CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, size, nullptr);
>                                              ^
> 2 errors generated.
>
> Original change's description:
> > Reland "Test mac system font variations."
> >
> > This reverts commit 4c0b9b90d6.
> >
> > Reason for revert: Work around broken -Wrange-loop-analysis
> >
> > Original change's description:
> > > Revert "Test mac system font variations."
> > >
> > > This reverts commit a612dc77d7.
> > >
> > > Reason for revert: Breaking iOS builds.
> > >
> > > Original change's description:
> > > > Test mac system font variations.
> > > >
> > > > On macOS system fonts are special and sometimes have different behavior
> > > > from fonts generated from data. Add a test which exercises several
> > > > expectations about changing the variation on the system ui font.
> > > >
> > > > Bug: skia:10968
> > > > Change-Id: Ia10dfbf7f4f0ff099f9bfebf95481c95c7d3715f
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372218
> > > > Commit-Queue: Ben Wagner <bungeman@google.com>
> > > > Reviewed-by: Herb Derby <herb@google.com>
> > >
> > > TBR=bungeman@google.com,herb@google.com,drott@google.com
> > >
> > > Change-Id: Iccc05f25d827ab85c507b5f3bde936561349e2b8
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: skia:10968
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372678
> > > Reviewed-by: Jim Van Verth <jvanverth@google.com>
> > > Commit-Queue: Jim Van Verth <jvanverth@google.com>
> >
> > # Not skipping CQ checks because this is a reland.
> >
> > Bug: skia:10968
> > Change-Id: Ifddc6c5ada335d97f7796df7f6ea10577f6bc252
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372776
> > Commit-Queue: Ben Wagner <bungeman@google.com>
> > Reviewed-by: Ben Wagner <bungeman@google.com>
>
> # Not skipping CQ checks because original CL landed > 1 day ago.
>
> Bug: skia:10968
> Change-Id: Ia5ff4ff827e3f79ff17b4d99458ffb45b7c36c58
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/373277
> Reviewed-by: Mike Klein <mtklein@google.com>
> Commit-Queue: Mike Klein <mtklein@google.com>

Bug: skia:10968
Change-Id: Ieb79128745dc934a7469d84b27a9e9f3306704df
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/373620
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Dominik Röttsches <drott@chromium.org>
Commit-Queue: Ben Wagner <bungeman@google.com>
2021-02-22 18:48:49 +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
Mike Klein
759f2613b5 Revert "Reland "Test mac system font variations.""
This reverts commit ba55be671d.

Reason for revert: G3 roll

(08:59:24) ERROR: third_party/skia/HEAD/BUILD:926:10: Compiling third_party/skia/HEAD/tests/TypefaceMacTest.cpp failed: (Exit 1) driver_is_not_gcc failed: error executing command third_party/crosstool/v18/stable/toolchain/bin/driver_is_not_gcc '-frandom-seed=blaze-out/k8-fastbuild/bin/third_party/skia/HEAD/_objs/dm/TypefaceMacTest.pic.o' -DSK_USE_FREETYPE_EMBOLDEN ... (remaining 383 argument(s) skipped).  [forge_remote_host=ixog19]
third_party/skia/HEAD/tests/TypefaceMacTest.cpp:31:45: error: unknown type name 'CTFontRef'
    auto makeSystemFont = [](float size) -> CTFontRef {
                                            ^
third_party/skia/HEAD/tests/TypefaceMacTest.cpp:33:46: error: use of undeclared identifier 'kCTFontUIFontSystem'
        return CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, size, nullptr);
                                             ^
2 errors generated.

Original change's description:
> Reland "Test mac system font variations."
>
> This reverts commit 4c0b9b90d6.
>
> Reason for revert: Work around broken -Wrange-loop-analysis
>
> Original change's description:
> > Revert "Test mac system font variations."
> >
> > This reverts commit a612dc77d7.
> >
> > Reason for revert: Breaking iOS builds.
> >
> > Original change's description:
> > > Test mac system font variations.
> > >
> > > On macOS system fonts are special and sometimes have different behavior
> > > from fonts generated from data. Add a test which exercises several
> > > expectations about changing the variation on the system ui font.
> > >
> > > Bug: skia:10968
> > > Change-Id: Ia10dfbf7f4f0ff099f9bfebf95481c95c7d3715f
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372218
> > > Commit-Queue: Ben Wagner <bungeman@google.com>
> > > Reviewed-by: Herb Derby <herb@google.com>
> >
> > TBR=bungeman@google.com,herb@google.com,drott@google.com
> >
> > Change-Id: Iccc05f25d827ab85c507b5f3bde936561349e2b8
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:10968
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372678
> > Reviewed-by: Jim Van Verth <jvanverth@google.com>
> > Commit-Queue: Jim Van Verth <jvanverth@google.com>
>
> # Not skipping CQ checks because this is a reland.
>
> Bug: skia:10968
> Change-Id: Ifddc6c5ada335d97f7796df7f6ea10577f6bc252
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372776
> Commit-Queue: Ben Wagner <bungeman@google.com>
> Reviewed-by: Ben Wagner <bungeman@google.com>

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

Bug: skia:10968
Change-Id: Ia5ff4ff827e3f79ff17b4d99458ffb45b7c36c58
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/373277
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2021-02-21 18:34:24 +00:00
Ben Wagner
ba55be671d Reland "Test mac system font variations."
This reverts commit 4c0b9b90d6.

Reason for revert: Work around broken -Wrange-loop-analysis

Original change's description:
> Revert "Test mac system font variations."
>
> This reverts commit a612dc77d7.
>
> Reason for revert: Breaking iOS builds.
>
> Original change's description:
> > Test mac system font variations.
> >
> > On macOS system fonts are special and sometimes have different behavior
> > from fonts generated from data. Add a test which exercises several
> > expectations about changing the variation on the system ui font.
> >
> > Bug: skia:10968
> > Change-Id: Ia10dfbf7f4f0ff099f9bfebf95481c95c7d3715f
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372218
> > Commit-Queue: Ben Wagner <bungeman@google.com>
> > Reviewed-by: Herb Derby <herb@google.com>
>
> TBR=bungeman@google.com,herb@google.com,drott@google.com
>
> Change-Id: Iccc05f25d827ab85c507b5f3bde936561349e2b8
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:10968
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372678
> Reviewed-by: Jim Van Verth <jvanverth@google.com>
> Commit-Queue: Jim Van Verth <jvanverth@google.com>

# Not skipping CQ checks because this is a reland.

Bug: skia:10968
Change-Id: Ifddc6c5ada335d97f7796df7f6ea10577f6bc252
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372776
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2021-02-20 15:46:13 +00:00
Jim Van Verth
4c0b9b90d6 Revert "Test mac system font variations."
This reverts commit a612dc77d7.

Reason for revert: Breaking iOS builds.

Original change's description:
> Test mac system font variations.
>
> On macOS system fonts are special and sometimes have different behavior
> from fonts generated from data. Add a test which exercises several
> expectations about changing the variation on the system ui font.
>
> Bug: skia:10968
> Change-Id: Ia10dfbf7f4f0ff099f9bfebf95481c95c7d3715f
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372218
> Commit-Queue: Ben Wagner <bungeman@google.com>
> Reviewed-by: Herb Derby <herb@google.com>

TBR=bungeman@google.com,herb@google.com,drott@google.com

Change-Id: Iccc05f25d827ab85c507b5f3bde936561349e2b8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10968
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372678
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2021-02-19 23:26:31 +00:00
Ben Wagner
a612dc77d7 Test mac system font variations.
On macOS system fonts are special and sometimes have different behavior
from fonts generated from data. Add a test which exercises several
expectations about changing the variation on the system ui font.

Bug: skia:10968
Change-Id: Ia10dfbf7f4f0ff099f9bfebf95481c95c7d3715f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372218
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2021-02-19 22:16:40 +00:00
Adlai Holler
dced31f62b Change PromiseImage API to take GrContextThreadSafeProxy
This detaches PromiseImages from any specific context, just to
a certain family.

Next up is to remove the tileSpecificSKP code from the DDLTileHelper.

Currently we have this janky PromiseImageDummy GrImageContext that
we make for each promise image. It's not ideal but it'll tide us over.

Bug: skia:10286
Change-Id: I12ab0bb7df9360a08af594da80de9df14cc2a44f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372516
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-02-19 21:52:59 +00:00