Commit Graph

10634 Commits

Author SHA1 Message Date
Aditya Kushwah
a696f8a925 Plumb label from GrGpu's createTexture function.
In this CL, GrResourceProvider's functions, like createTexture etc,
get label string passed to it which are called from GrGpu which then
passes the label to setLabel method of GrGpuResource.

Bug: chromium:1164111
Change-Id: Icfd88279c0729e36c105c62c05f382aab0a89310
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/534778
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2022-05-03 21:39:19 +00:00
James Godfrey-Kittle
2622e03327 [graphite] Unit tests for UploadBufferManager
This also fixes a bug that the tests revealed -- it wasn't resetting the
reused-buffer offset after transferToCommandBuffer.

Change-Id: I75850ab1cb1e63dc88f95783248f70816611cefc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/536103
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: James Godfrey-Kittle <jamesgk@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2022-05-03 18:48:40 +00:00
Arman Uguray
c908c3a898 [ganesh][dawn] Better handle buffer mapAsync failures
GrDawnGpu tries to guarantee the CPU mapping invariants of GrDawnBuffer
objects that are managed by a GrStagingBufferManager by issuing and
tracking mapAsync requests following command buffer submission. However,
this logic suffered from some issues where:

1. The code always assumed mapAsync succeeds. If a mapAsync request
   failed during shutdown due to a lost GPU connection, the GrDawnGpu
   destructor would spin forever waiting for pending mapAsync requests
   to complete.
2. If a client unmapped and then re-mapped a buffer that isn't managed
   by the async staging buffer logic in GrDawnGpu, the buffer would
   never get mapped and likely hit an assertion for a non-staging
   buffer.

These are now fixed:

* GrDawnBuffer now has more explicit error handling to make it more
  tolerant to mapAsync failures.
* GrGpuBuffer now relies on mapAsync completion callbacks instead of
  spinning on `GrGpuBuffer::isMapped` as a buffer may never get mapped
  in the case of an error. This also has the benefit of tracking the
  mapAsync procedure state on a per-request basis intead of relying on
  state stored in GrDawnBuffer. The existing `fBusyStagingBuffers` has
  been replaced by a single reference counted `GrDawnAsyncWait` object.
* A synchronous/blocking map function has been provided to satisfy the
  `GrGpuBuffer::onMap` contract. This method is not used in the existing
  staging buffer use cases in practice but it solves part of problem #2
  above.
* GrDawnGpu::onReadPixels now uses a GrDawnBuffer's blocking map
  functionality using the public GrGpuBuffer API. This has the same
  behavior as the existing blocking map that created and mapped a
  wgpu::Buffer directly.
* The invariants around GrDawnBuffer lifetime and CPU mapping are
  documented in class level comments.

Bug: skia:12512

Change-Id: I8bb92137fbd60c31066e4071bd696018b3563bb8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/533758
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Arman Uguray <armansito@google.com>
2022-05-02 17:20:55 +00:00
Kevin Lubick
c3a448ec61 [bazel] Put licenses() after legacy_exports
G3 prefers license() first.

This was done mechanically with a big find/replace

Change-Id: I8c33c7bc10a6bec42e966cad81c259954e841811
Bug: skia:13211
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/535898
Reviewed-by: Ben Wagner <bungeman@google.com>
2022-05-02 15:04:33 +00:00
Kevin Lubick
fe01e985a7 Reland "Reland "[includes] Remove SkColorSpace include from SkImageInfo""
This is a reland of commit 00de8cc000

New client fixes:
 - http://cl/445903108

Original change's description:
> Reland "[includes] Remove SkColorSpace include from SkImageInfo"
>
> This is a reland of commit 2151fa37fa
>
> New client fixes:
>  - https://crrev.com/c/3616345
>
> Original change's description:
> > [includes] Remove SkColorSpace include from SkImageInfo
> >
> > See also https://skia-review.googlesource.com/c/skia/+/525639
> >
> > This should be landed when clients have been fixed.
> >  - https://github.com/flutter/engine/pull/32532
> >  - https://github.com/flutter/engine/pull/32382
> >  - http://cl/438808657
> >  - http://cl/438803822
> >  - http://cl/438807456
> >  - http://cl/438808026
> >  - http://cl/438821192
> >  - https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17542295
> >
> > Change-Id: I04beeb2e2b6132c40508c98f4f281981dadbb0d4
> > Bug: skia:13052
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/526416
> > Commit-Queue: Kevin Lubick <kjlubick@google.com>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
>
> Canary-Chromium-CL: 3616345
> Bug: skia:13052
> Change-Id: I670d3d0d0bab2a86559d9a1184cb36ef008196f3
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/535357
> Reviewed-by: Brian Salomon <bsalomon@google.com>

Bug: skia:13052
Change-Id: Ibb931dde3f0846609df35d2897989eff0499b7f9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/535896
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2022-05-02 13:33:21 +00:00
Brian Osman
05dd660fee Revert "Reland "[includes] Remove SkColorSpace include from SkImageInfo""
This reverts commit 00de8cc000.

Reason for revert: G3 Breakage?

Original change's description:
> Reland "[includes] Remove SkColorSpace include from SkImageInfo"
>
> This is a reland of commit 2151fa37fa
>
> New client fixes:
>  - https://crrev.com/c/3616345
>
> Original change's description:
> > [includes] Remove SkColorSpace include from SkImageInfo
> >
> > See also https://skia-review.googlesource.com/c/skia/+/525639
> >
> > This should be landed when clients have been fixed.
> >  - https://github.com/flutter/engine/pull/32532
> >  - https://github.com/flutter/engine/pull/32382
> >  - http://cl/438808657
> >  - http://cl/438803822
> >  - http://cl/438807456
> >  - http://cl/438808026
> >  - http://cl/438821192
> >  - https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17542295
> >
> > Change-Id: I04beeb2e2b6132c40508c98f4f281981dadbb0d4
> > Bug: skia:13052
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/526416
> > Commit-Queue: Kevin Lubick <kjlubick@google.com>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
>
> Canary-Chromium-CL: 3616345
> Bug: skia:13052
> Change-Id: I670d3d0d0bab2a86559d9a1184cb36ef008196f3
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/535357
> Reviewed-by: Brian Salomon <bsalomon@google.com>

Bug: skia:13052
Change-Id: Ie2d036f0bfcdb481c4227a6d567e38d527c81168
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/535202
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2022-04-29 22:17:12 +00:00
Kevin Lubick
46eaab3959 [bazel] Add shims to help translation into G3
Ran the following commands:
find -name "BUILD.bazel" -exec sed -i -e '1iload("//bazel:macros.bzl", "cc_library", "exports_files_legacy")\nexports_files_legacy()' {} +
buildifier --lint=fix --mode=fix -r .

This had the effect of making sure we can export all of our
files in G3 (until we no longer have legacy targets) and
making all of our cc_libraries shim-able.

bazel/macros.bzl has the human-contributed changes, the rest
were mechanical.

Change-Id: I8e24e30e74b038cfd072cdbe4078bfd1d213dd46
Bug: skia:13211
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/535359
Reviewed-by: Ben Wagner <bungeman@google.com>
2022-04-29 19:27:54 +00:00
John Stiles
59c906795c Remove InlineMarker IR node.
This node was only used to detect recursion while inlining. We no longer
need to do this, because we disallow recursion in all programs.

The removal of one IRNode per inlined function actually allows for
slightly more aggressive inlining, since we restrict inlining based on
IRNode consumption. This allows the "ExponentialGrowth" tests to inline
a bit more deeply than before.

Change-Id: I894dbb1ca3096bb785b67facb01cc9c630f694c4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/534780
Reviewed-by: Arman Uguray <armansito@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-04-29 17:40:58 +00:00
Brian Salomon
efb32fe3c0 Fix -Wunused-but-set-variable warnings
Change-Id: I5a044983e3de84901f29bddca5503167edc8fcee
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/535436
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2022-04-29 15:20:59 +00:00
Kevin Lubick
00de8cc000 Reland "[includes] Remove SkColorSpace include from SkImageInfo"
This is a reland of commit 2151fa37fa

New client fixes:
 - https://crrev.com/c/3616345

Original change's description:
> [includes] Remove SkColorSpace include from SkImageInfo
>
> See also https://skia-review.googlesource.com/c/skia/+/525639
>
> This should be landed when clients have been fixed.
>  - https://github.com/flutter/engine/pull/32532
>  - https://github.com/flutter/engine/pull/32382
>  - http://cl/438808657
>  - http://cl/438803822
>  - http://cl/438807456
>  - http://cl/438808026
>  - http://cl/438821192
>  - https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17542295
>
> Change-Id: I04beeb2e2b6132c40508c98f4f281981dadbb0d4
> Bug: skia:13052
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/526416
> Commit-Queue: Kevin Lubick <kjlubick@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

Canary-Chromium-CL: 3616345
Bug: skia:13052
Change-Id: I670d3d0d0bab2a86559d9a1184cb36ef008196f3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/535357
Reviewed-by: Brian Salomon <bsalomon@google.com>
2022-04-29 14:56:15 +00:00
Kevin Lubick
cadb3a33e1 Revert "[includes] Remove SkColorSpace include from SkImageInfo"
This reverts commit 2151fa37fa.

Reason for revert: Breaking Chrome

Original change's description:
> [includes] Remove SkColorSpace include from SkImageInfo
>
> See also https://skia-review.googlesource.com/c/skia/+/525639
>
> This should be landed when clients have been fixed.
>  - https://github.com/flutter/engine/pull/32532
>  - https://github.com/flutter/engine/pull/32382
>  - http://cl/438808657
>  - http://cl/438803822
>  - http://cl/438807456
>  - http://cl/438808026
>  - http://cl/438821192
>  - https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17542295
>
> Change-Id: I04beeb2e2b6132c40508c98f4f281981dadbb0d4
> Bug: skia:13052
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/526416
> Commit-Queue: Kevin Lubick <kjlubick@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

Bug: skia:13052
Change-Id: I8a9108a333eebefdfa864c757d8c395a6b59335c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/535296
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Kevin Lubick <kjlubick@google.com>
2022-04-28 22:56:15 +00:00
John Stiles
cfcc11bd98 Move recursion tests into general /errors/ directory.
We enforce no-recursion in all programs now, not just Runtime Effects.

Change-Id: I3737329e4526fa1b7fdbb47ccb959f78f507f665
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/535119
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2022-04-28 21:25:41 +00:00
Kevin Lubick
2151fa37fa [includes] Remove SkColorSpace include from SkImageInfo
See also https://skia-review.googlesource.com/c/skia/+/525639

This should be landed when clients have been fixed.
 - https://github.com/flutter/engine/pull/32532
 - https://github.com/flutter/engine/pull/32382
 - http://cl/438808657
 - http://cl/438803822
 - http://cl/438807456
 - http://cl/438808026
 - http://cl/438821192
 - https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17542295

Change-Id: I04beeb2e2b6132c40508c98f4f281981dadbb0d4
Bug: skia:13052
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/526416
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2022-04-28 20:48:11 +00:00
Brian Osman
23d333bdd6 Add support for ANGLE's Metal backend
- Disables MSL via SPIRV (we don't have the necessary DEPS)
- Adds new context type, configs, etc...
- Minor tweaks to the ANGLE test context code

Bug: angleproject:7155
Bug: skia:13272
Change-Id: I258ed19abba01ad96cfe6fca46b558af2340880e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/534569
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2022-04-28 19:53:18 +00:00
Kevin Lubick
62f57a02b3 [includes] Enforce IWYU on src/utils
Client changes:
 - cl/443664347
 - cl/444232853
 - http://ag/17915718
 - http://ag/17913178
 - https://crrev.com/c/3602239

Change-Id: I16bcdbbe2b13bbf52f007b0f131e9ee0c14ed237
Bug: skia:13052
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/532257
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
2022-04-28 17:32:20 +00:00
Jim Van Verth
07aafcf5c9 [graphite] Move more shared types into AtlasTypes.
Bug: skia:13118
Change-Id: Ibfcc8df522a87f8ddf6e185121c0844d453b2012
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/534139
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2022-04-28 15:37:59 +00:00
Robert Phillips
0326a9f27a Move skgpu::graphite::Mask to SkEnumBitMask
This will let us use this utility everywhere.

Bug: skia:12701
Change-Id: I9342d0b40a81789ed93e3ec4009e5602033d6691
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/534662
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-04-28 14:04:16 +00:00
Robert Phillips
87a50d3fcf [graphite] Break ground on local coords support
This just plumbs through a flag that allows snippets to request a
dev2Local matrix uniform and uses it for gradients and the image shader.

Bug: skia:12701
Change-Id: If1eadff8d5e40d81d9e3794db4b7f816127c4b75
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529810
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-04-27 15:25:09 +00:00
John Stiles
850de30a19 Fit Position in 4 bytes.
This limits our error reporting to the first 16MB of SkSL code in a
program, and error marks are limited to a run of 255 characters or
less. In practice, these limits do not affect normal code in any way.
This gives us the same tight memory footprint we originally had when
positions were stored as `int32 fLine`.

Change-Id: Idef04344324870a7b92aca154feb5e1a0121d284
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/533699
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2022-04-27 00:01:06 +00:00
John Stiles
6bcfd35fda Generate SPIR-V golden outputs for switch tests.
These were not being generated because they were in the "settings" test
group; we have switch-rewrite settings that also need to be tested.
This was a blind spot in our golden output coverage; without these
tests, there is very little switch-statement usage in our corpus.
They are now in the SPIR-V test group as well.

Change-Id: Ic23b726d00c3047f2d19f7f6dc41e58e600e991c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/534141
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Arman Uguray <armansito@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-04-26 22:16:43 +00:00
Greg Daniel
7dd8c705a5 Reland "Check that the GrBackendFormat of a promise image is textureable."
This is a reland of commit 866bd64c1b

Original change's description:
> Check that the GrBackendFormat of a promise image is textureable.
>
> Bug: chromium:1311844
> Change-Id: I13bae71305ae9520851cd1ea38a1da737b934dd1
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/532196
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>

Bug: chromium:1311844
Change-Id: I01e2d0e4eb01ee7d97798db6eeff73fec76bf521
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/532408
Auto-Submit: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2022-04-25 18:53:38 +00:00
John Stiles
c6b2e7115a Limit sksl_rt_shader to internal usage only.
We now have a new type of ProgramKind, private runtime shaders.
`sksl_rt_effect.sksl` is now only loaded for these kinds of program.

Rather than having a special-case check for sk_FragCoord in
SkRuntimeEffect, the symbol will no longer exist at all unless a private
options flag is set.

Change-Id: I9223baaf59d74c44d64f322cd57fc841625342b7
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/532784
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2022-04-22 21:06:31 +00:00
John Stiles
20718d3547 Add test demonstrating sk_FragCoord usage in a runtime shader.
Right now nothing prevents it from working. (skslc doesn't use
SkRuntimeEffect::MakeInternal.) This will be fixed in a followup.

Change-Id: Ib8479220e1f194b035516d976a7369d926a07f5d
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/532783
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2022-04-22 21:06:31 +00:00
Brian Osman
46aad8435a Move runtime effect uniform type checking into the compiler
This has two benefits:
1) We get detailed error messages with accurate positions
2) We can actually test these in our golden .rts files.

Thanks to #2, add a new unit test file, and adjust some existing files
that were breaking these rules.

Change-Id: I0b65e2f06f79ce8cbea9bad4c3d27062ec9b6e6c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/532769
Reviewed-by: Arman Uguray <armansito@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2022-04-22 20:54:26 +00:00
Ethan Nicholas
d418ddbfc5 Improved SkSL error positions for return types
Bug: skia:13169
Change-Id: Icf0b720d3e3a13d490aba8495cf9db83d1d62318
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/532762
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2022-04-22 19:13:45 +00:00
John Stiles
bca1b0c955 Add ReducedBlendModeInfo to shared code.
This will allow us to reuse this logic in Graphite.

Change-Id: I649dcd3893a1355af457a2583a6db3066fb87c9a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/532758
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2022-04-22 17:18:31 +00:00
Ethan Nicholas
56217f0722 Improved positions of variable name errors
Bug: skia:13170
Change-Id: I11ef0ea5ac3ae61b24a47805bb3290a37880cfee
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/532536
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2022-04-22 14:39:14 +00:00
Ethan Nicholas
ccd85d5835 Improved positions of for loop errors
Bug: skia:13173
Change-Id: Ifbcce77605dd781563568293fc501dfa31f143da
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/528706
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2022-04-21 16:56:12 +00:00
Jim Van Verth
dfab663577 De-namespace uses of MaskFormat
Bug: skia:13118
Change-Id: Iab67fd1148182fdd29a38b69f27c51b13942a2b5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/532400
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2022-04-21 15:55:21 +00:00
Jim Van Verth
c069b813a7 [graphite] More steps towards a shared DrawAtlas class.
* Move Rectanizer classes to a shared location
* Have GrDrawOpAtlas store SkColorType and explicit bytes-per-pixel
  instead of GrColorType.

Bug: skia:13118
Change-Id: Ib5c3d79394c89dce7f06e8eddf09a5f6a9543a7f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/531320
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2022-04-21 14:20:45 +00:00
Ethan Nicholas
87e472722f Improved error reporting ranges for swizzles
Bug: skia:13171
Change-Id: I6dffb98ac2464f930995cf8ea57e422091d20fd2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/531743
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2022-04-20 20:46:51 +00:00
Kevin Lubick
99d5d0fe67 Fix typo in tests
Change-Id: Id12f811c1dc6a6070bb52ff2278234679ce49aff
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/532136
Reviewed-by: Greg Daniel <egdaniel@google.com>
2022-04-20 16:57:44 +00:00
Jim Van Verth
48d50633ef [graphite] Move some atlas-related types to a shared header
Bug: skia:13118
Change-Id: Ica760f58107de021b7823f69b94809dd2f313ac7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/531739
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2022-04-20 15:35:58 +00:00
John Stiles
721a07f5f6 Optimize away self comparisons in SPIR-V.
(This mirrors an optimization performed in the constant folder.)

Expressions like `OpIEqual %20 %20` or `OpFUnordNotEqual %15 %15` can be
replaced by `true` or `false` on sight. The GLSL spec makes it clear
that checking for NaN is optional:

4.7.1 Range and Precision
"... NaNs are not required to be generated. Support for signaling NaNs
is not required and exceptions are never raised. Operations and built-in
functions that operate on a NaN are not required to return a NaN as the
result."

Change-Id: I2e29b659a73582e9ade0eb61f70f7d362a007c50
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/531550
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2022-04-19 16:10:03 +00:00
John Stiles
fce87a43e6 Move store-cache handling into writeLabel.
Previously, every expression/statement type was responsible for
pruning or clearing the store-cache when branches were involved. This
was difficult to reason about and easy to get wrong, particularly if
the details are not fresh in your mind.

Now, `writeLabel` takes care of the details for you. Pass in the
location of the branch(es) which use the label, and the proper cache
updating behavior will occur automatically.

Some of the label enum types are not strictly necessary and exist for
the benefit of a reader. Specifically:
 - `kBranchlessBlock` and `kBranchIsOnPreviousLine` are synonyms
 - `kBranchIsBelow` and `kBranchesOnBothSides` are also synonyms

The hope is that extra enum names will be easier for a reader to
follow, versus fewer but very-verbose enum names (like
 `kBranchIsBelowOrOnBothSides`).

This change earned some very minor switch-related dividends. Previously,
every label in a switch was treated as a forward-branch, but in fact,
the very first label in a switch is privileged. This is because we are
branching from the previous line, and the store cache is trustworthy in
this case. (Versus "branching from above," where the store cache needs
to be pruned before it can be trusted.)

Change-Id: I38b539069c22be9f0777b632f60f0eab2409d687
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/531540
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-04-19 15:17:01 +00:00
John Stiles
ffc9dec755 Eliminate redundant loads following stores.
We now have two functions `writeOpLoad` and `writeOpStore` which are
in charge of writing SpvOpLoad and SpvOpStore instructions.
`writeOpStore` also keeps track of pointer stores in a "store cache."
Subsequent loads from that same pointer will be found in the cache and
will return the value stored in that pointer instead.

Such a cache definitely cannot work in the face of control flow, so we
make the following concessions:
- `pruneReachableOps` is now `pruneConditionalOps`. Any pointers that
  are altered inside a potentially-unreachable block are cleared from
  the cache entirely.
- The entire store cache is cleared at all OpLabels within a loop.

The cache also cannot work in the presence of swizzled stores, so we
make another significant concession:
- The entire store cache is cleared whenever we store into a non-memory
  pointer (e.g., assigning into a swizzled LValue, such as `foo.xz`).

Despite these significant limitations, this manages to dramatically
shrink many real-world examples.

Change-Id: I0981a0cf7b45b064e153e9ada271494c8e00cad5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530054
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2022-04-18 14:57:48 +00:00
Brian Salomon
2386d3e7d6 mipMapped -> mipmapped
Change-Id: Ib9d4e23159724825dacb7d37ceabfd2aff68f58a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530681
Auto-Submit: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2022-04-18 14:26:19 +00:00
John Stiles
123d29701b Fix half-precision operand types in writeBinaryExpression.
Previously, we would determine the operandType by calling
`getActualType`. This function converts half-precision types to full-
precision ones, which seems to have been unintentional. Fortunately, the
operand type is not actually emitted into the SPIR-V by most code paths
(most paths use the resultType instead) so it was not a significant
impact in practice. A few matrix-based paths emitted ops using this type
and these paths now emit RelaxedPrecision as expected.

Change-Id: I32f4c0327427476fee6b78953284818b7970b6e8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530543
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Arman Uguray <armansito@google.com>
2022-04-15 22:17:47 +00:00
John Stiles
c4f2d8d17c Use op cache to eliminate OpCompositeConstruct + OpCompositeExtract.
Previously, we only handled the simple case of extracting from an
OpConstantComposite. Now we also handle the complex case of extracting
from an OpCompositeConstruct, where vectors can be composed of other
vectors.

This is particularly challenging because OpCompositeConstruct can
contain SpvIds from almost any other instruction, so we need to be
able to decode those instructions and figure out their type. For
instance:

  %5 = OpFAdd Vec2   %1 %2
  %6 = OpFAdd Scalar %3 %4
  %7 = OpCompositeConstruct FloatVec3 %5 %6
  %8 = OpCompositeExtract %7 2

The %8 (OpCompositeExtract) could be replaced with %6 but we need to
peek at the type in *both* OpFAdd instructions to decode this. It
only works when the affected instructions are in-cache, so many
opportunities are currently not optimized because their code still
uses the original, uncached form of writeInstruction.

Change-Id: I5719ae6284f32e1d6f2c898eca282c22b94fc764
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529743
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-04-15 15:50:06 +00:00
Brian Salomon
7bfda9a23d Finish GrMipMapped->GrMipmapped
Change-Id: I3a9e9e90b0ac1b1099830eaca06506bcce794144
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530055
Commit-Queue: Brian Salomon <bsalomon@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2022-04-15 15:43:52 +00:00
Brian Osman
89951e189f Fix SPIR-V handling of fForceNoRTFlip
Bug: skia:13219
Change-Id: I57c5c2aa40e6eb85d5e6045d6f3374d0379efd39
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530337
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2022-04-15 13:08:35 +00:00
Brian Osman
9fe0e3d4e7 SkSL: Add unit tests for new ForceNoRTFlip code-gen option
This removes the assert from the SPIR-V generator so the
tests compile. The generated SPIR-V is incorrect. The next
CL fixes the generator, and restores the assert.

Change-Id: I77b507cf7fb5eac481322887000bd1c73cd5c899
Bug: skia:13219
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530336
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2022-04-15 12:59:07 +00:00
Kevin Lubick
83cee23c98 [bazel] Run buildifier on BUILD.bazel files
buildifier --lint=fix -r .

Change-Id: I6a41858270d20137978f8271c8f6160b51120777
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529751
Reviewed-by: Ben Wagner <bungeman@google.com>
2022-04-14 18:13:43 +00:00
John Stiles
0688ea21b2 Reland "Use op cache when emitting types."
This is a reland of commit 60ff0facbf

Structs are now deduplicated using a [Type*, SpvId] map.

Original change's description:
> Use op cache when emitting types.
>
> We no longer need to maintain a separate `fTypeMap` for mapping types
> to SpvIds, since the op cache handles this automatically.
>
> We also now support deduplicating instructions that don't have a result,
> such as decorations. (In particular, we needed to avoid emitting the
> SpvDecorationArrayStride op every time the array type was accessed, but
> this op doesn't have a result ID.)
>
> Change-Id: I779b8c8e3de5973b8f487b28c0a8ece9a1041845
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529732
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>

Change-Id: I9f6a78d58e8af38a1fd690a8860d8b5aa3193be6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529748
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2022-04-14 17:39:37 +00:00
Brian Osman
028586238e Update vulkan validation errors in generated files
Change-Id: I800fa2a1fb0e64ad478c76ea2d5cda176ea8f48b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529746
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2022-04-14 15:09:37 +00:00
Brian Osman
0d99188804 Revert "Use op cache when emitting types."
This reverts commit 60ff0facbf.

Reason for revert: Broke D3D bots

Original change's description:
> Use op cache when emitting types.
>
> We no longer need to maintain a separate `fTypeMap` for mapping types
> to SpvIds, since the op cache handles this automatically.
>
> We also now support deduplicating instructions that don't have a result,
> such as decorations. (In particular, we needed to avoid emitting the
> SpvDecorationArrayStride op every time the array type was accessed, but
> this op doesn't have a result ID.)
>
> Change-Id: I779b8c8e3de5973b8f487b28c0a8ece9a1041845
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529732
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>

Change-Id: I0e2187f88f2a945fd6f88ce75ff815e03d2f7df5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529747
Auto-Submit: Brian Osman <brianosman@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2022-04-14 14:43:09 +00:00
John Stiles
60ff0facbf Use op cache when emitting types.
We no longer need to maintain a separate `fTypeMap` for mapping types
to SpvIds, since the op cache handles this automatically.

We also now support deduplicating instructions that don't have a result,
such as decorations. (In particular, we needed to avoid emitting the
SpvDecorationArrayStride op every time the array type was accessed, but
this op doesn't have a result ID.)

Change-Id: I779b8c8e3de5973b8f487b28c0a8ece9a1041845
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529732
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2022-04-14 13:32:55 +00:00
John Stiles
c66b72dc46 Use op cache for pointer and function types.
Previously, we stringized the types and put them into fTypeMap. Using
the op cache is a simpler mechanism that should work equally well.

Output diffs are almost all ID reorderings. In a few cases we
managed to deduplicate function types that stringize differently but
come out the same in SPIR-V (e.g. no float/half distinction).

Change-Id: If7de5b2dafa12d05c3c2c497a243e9e3908dfee7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529805
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2022-04-14 13:00:27 +00:00
John Stiles
8a00b0f69d Use op cache when emitting matrix copies.
Change-Id: I3f6e25ec7b31339bfc9bd2435bc9226e6d9be06b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529498
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2022-04-14 00:23:04 +00:00
Kevin Lubick
b98328a27b [bazel] Add license to all our BUILD.bazel files
find -name "BUILD.bazel" -exec sed -i -e '1i licenses(["notice"])\n' {} +

Change-Id: Ie48f163b7d8d6ede9ba5f952e87232dd5c9fa8e6
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529808
Reviewed-by: Ben Wagner <bungeman@google.com>
2022-04-13 19:50:29 +00:00