Commit Graph

175 Commits

Author SHA1 Message Date
John Stiles
ca7657b093 Remove RuntimeShader built-in snippet ID.
This has been replaced by findOrCreateRuntimeEffectSnippet.

Change-Id: I26e1f85c74071b14b75ab86410e4cc30a81bf873
Bug: skia:13405
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/552716
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2022-07-08 14:18:19 +00:00
John Stiles
2d6e13210d Add UniformManager tests for matrix/vector padding.
This checks the padding of a matrix followed by a scalar/vector, and the
padding of a scalar/vector followed by a matrix. The checks support
all mixes of 16- and 32-bit sized elements.

After some investigation, this CL also removes some TODOs in
`get_ubo_aligned_offset`. Our uniform system does not support structs,
which is a large source of disparity between layouts. With structs
removed from the equation, the only difference between layouts seems to
be related to std140 array padding. (std430 and Metal seem to be
entirely the same.)

Change-Id: I76c48ae1e597b98aad8a8f8495ab4a8ad262845b
Bug: skia:13478
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/556356
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2022-07-07 17:14:11 +00:00
John Stiles
f0f4277443 Add UniformManager tests for mixed 16/32-bit scalar/vector packing.
Thankfully, this was already working; no changes in the uniform manager
were needed.

Change-Id: Ic2c4807e8efa63a05127d6f96d8a58ce785bbc1e
Bug: skia:13478
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/556316
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-07-06 20:59:25 +00:00
John Stiles
d1578cfe9b Add padding to properly align mixed-size uniforms.
The UniformManager would previously assert if it detected an alignment
error, but did not actually have any mechanism for automatically adding
padding between misaligned elements. If a user specifies a uniform
layout like `uniform float a; uniform float4 b;`, we now insert padding
between `a` and `b` so that `b` will be properly aligned. (This reuses
the logic that was originally used to trigger the alignment assertion.)

This CL fixes the bug and adds a test. The test is only active for
elements of matching size; mixed half- and full-precision elements
will need improved test logic.

Change-Id: I8c04eb6350fa73bdbcd1a08e1a45b17fee0d4194
Bug: skia:13478
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/555440
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2022-07-02 20:19:12 +00:00
John Stiles
987901fa3f Fix uniform manager handling of mat2 types.
The Stride() function in the UniformManager, when given a matrix type,
was intended to return the stride of a single matrix column. However, it
accidentally called `Stride(1)` instead of `Stride(kNonArray)`, which
meant that it was returning the stride for a `vec2[1]` (four floats)
instead of the stride of a `vec2` (two floats). Interestingly, this
still returned the correct answer for mat3 and mat4, because `vec3`,
`vec4`, `vec3[1]` and `vec4[1]` all have the same stride--four floats.

This CL fixes the bug and adds a test.

Change-Id: I9c06b7da7253a86c1d9545c7e177bc916b49c9b9
Bug: skia:13478
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/555161
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-07-01 13:47:31 +00:00
John Stiles
143f191edd Fix uniform manager handling of vec3 types.
std140, std430, and Metal all agree that non-array vec3 types should
pack like the equivalent vec4.

std140: http://screen/5NHiYze3sk4CbWv
std430: http://screen/8G6CuomyEkxge5t
Metal:  http://screen/7t9LfvmuZmtJ4zq

Our Stride() function in the UniformManager, however, did not pad out
vec3 types. This would manifest as an assertion when the _next_
uniform was added; we would assert because get_ubo_aligned_offset
would mismatch our expected values.

This CL fixes the bug and adds a test.

Change-Id: I33f04f37d68b0099236576f69250ed73d9e010cd
Bug: skia:13478
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/554404
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2022-06-30 20:26:44 +00:00
John Stiles
cb7bfa28fd Simplify unit test logic around Metal half-precision uniforms.
The pattern of treating Metal half-precision uniforms differently was
affecting both existing and upcoming tests, so it's factored out to a
helper function.

Also, added in calls to `doneWithExpectedUniforms`--these aren't
required, but it will give us more thorough test coverage.

Change-Id: I3f76a775816242cd1e5de9be1a96486738ddb12f
Bug: skia:13478
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/554998
Reviewed-by: James Godfrey-Kittle <jamesgk@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: James Godfrey-Kittle <jamesgk@google.com>
2022-06-30 19:24:43 +00:00
John Stiles
9a9a6925ac Add unit test verifying int encoding of uniforms.
Similar to floats, Metal expects short-int uniforms to be passed in 16
bits, but other layouts always use 32 bits for integers.

Change-Id: I99575349d8547876ab6dab00f393158fbeea5385
Bug: skia:13478
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/554345
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2022-06-30 16:41:04 +00:00
Robert Phillips
3c4759d04c [graphite] Add runtime effects to new API proposal
Bug: skia:13430
Change-Id: I4958b0d14f7805889ed2061fe929778f69d40c48
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/549566
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2022-06-30 15:23:13 +00:00
John Stiles
eb35a3783e Add unit test verifying float encoding of uniforms.
This test verifies that float scalars and vectors can be added as
uniforms. In Metal, this is a particularly interesting challenge because
we represent half values as 16-bit floats.

Change-Id: I4ce2280a61afee905ac5980792b6dbe6e4be572f
Bug: skia:13478
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/554344
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2022-06-30 14:06:26 +00:00
John Stiles
91c25e9b05 Reland "Create simple unit test for UniformManager types and layouts."
This reverts commit 6c05f9064f.

Reason for revert: fixed in release

Original change's description:
> Revert "Create simple unit test for UniformManager types and layouts."
>
> This reverts commit c42782ad74.
>
> Reason for revert: breaks in release
>
> Original change's description:
> > Create simple unit test for UniformManager types and layouts.
> >
> > The first test is an extremely simple check (can we create a uniform of
> > every allowed type in every layout?) and already uncovered a bug, so
> > we're off to a good start.
> >
> > Change-Id: If9d6aa9c0845727c5422185094711734951c2e0a
> > Bug: skia:13478
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/554339
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Auto-Submit: John Stiles <johnstiles@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Commit-Queue: John Stiles <johnstiles@google.com>
>
> Bug: skia:13478
> Change-Id: I75c051c3daee63cad0ffd55e3823d9eb333980ee
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/554398
> Auto-Submit: John Stiles <johnstiles@google.com>
> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>

Bug: skia:13478
Change-Id: Ic8fafda7c2149cbb07e3469fe7165787e110114e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/554400
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-06-30 14:03:22 +00:00
John Stiles
6c05f9064f Revert "Create simple unit test for UniformManager types and layouts."
This reverts commit c42782ad74.

Reason for revert: breaks in release

Original change's description:
> Create simple unit test for UniformManager types and layouts.
>
> The first test is an extremely simple check (can we create a uniform of
> every allowed type in every layout?) and already uncovered a bug, so
> we're off to a good start.
>
> Change-Id: If9d6aa9c0845727c5422185094711734951c2e0a
> Bug: skia:13478
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/554339
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

Bug: skia:13478
Change-Id: I75c051c3daee63cad0ffd55e3823d9eb333980ee
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/554398
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2022-06-30 12:09:18 +00:00
John Stiles
c42782ad74 Create simple unit test for UniformManager types and layouts.
The first test is an extremely simple check (can we create a uniform of
every allowed type in every layout?) and already uncovered a bug, so
we're off to a good start.

Change-Id: If9d6aa9c0845727c5422185094711734951c2e0a
Bug: skia:13478
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/554339
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-06-30 01:43:37 +00:00
Greg Daniel
bf65800589 [Graphite] Store Task Graph on Recording.
Bug: skia:13357
Change-Id: Ib2566e9c38f667368b20f18ed2b1851615602cad
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/548480
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2022-06-29 20:42:49 +00:00
Robert Phillips
c0cd71d4fd [graphite] Add compile guards to precompile system (take 2)
Bug: skia:13430
Change-Id: I64d6049fec8cc942a8f7c56c01ba292cc8f3835c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/554378
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2022-06-29 19:37:15 +00:00
Kevin Lubick
187340c89e Revert "[graphite] Add compile guards to precompile system"
This reverts commit 1da712adda.

Reason for revert: Breaking G3

Original change's description:
> [graphite] Add compile guards to precompile system
>
> Bug: skia:13430
> Change-Id: I6c577b459bc3a699e6c660d21d2b119643fe1f88
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/553877
> Reviewed-by: Eric Boren <borenet@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Robert Phillips <robertphillips@google.com>

Bug: skia:13430
Change-Id: I2fd518c9b7950e362e8c27cc74811f840887c7fa
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/554377
Owners-Override: Kevin Lubick <kjlubick@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2022-06-29 14:58:21 +00:00
Robert Phillips
1da712adda [graphite] Add compile guards to precompile system
Bug: skia:13430
Change-Id: I6c577b459bc3a699e6c660d21d2b119643fe1f88
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/553877
Reviewed-by: Eric Boren <borenet@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-06-29 13:48:45 +00:00
John Stiles
af348ef4b0 Create SkUniform data in findOrCreateRuntimeEffectSnippet.
Graphite expects uniforms to be passed in as a span of SkUniforms.
When making a runtime effect, we now convert the SkRuntimeEffect's
`Uniform` data into SkUniforms as well.

I briefly looked at sharing a single uniform type, but
SkRuntimeEffect::Uniform is public API, so changing it is non-trivial,
and Uniform would not be usable as a direct replacement for SkUniform.
(Uniform is non-POD since it contains an SkString; SkUniform is POD
and we declare a bunch of them at global scope. Also, each class
represents types using a separate enum.)

Change-Id: Idef2141d3a4860529719382840a157b7b0c41643
Bug: skia:13457
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/553595
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2022-06-28 18:45:48 +00:00
Robert Phillips
36d67f462f [graphite] New Combination API
Bug: skia:13430
Change-Id: I816c57d0ed8694d21911c449d67c035580dd63d1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/548776
Reviewed-by: Herb Derby <herb@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-06-27 17:30:16 +00:00
John Stiles
a10e6c1025 Add SkShaderCodeDictionary::findOrCreateRuntimeEffectSnippet.
`findOrCreateRuntimeEffectSnippet` takes a pointer to the runtime effect
and returns a code-snippet ID associated with the runtime effect, with
matching uniform layout, etc. The SkShaderCodeDictionary will maintain a
persistent map from {sksl-hash, uniform set} to code-snippet ID.

http://go/runtime-effects-in-graphite

Change-Id: I9c51667aad96f850184899f3df00a8206a1fe354
Bug: skia:13405
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/552686
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2022-06-27 15:27:46 +00:00
John Stiles
76f32c939f Remove pointer sidecar data in PaintParamsKey.
Pointer data is obliterated when we assemble draw passes, so this
feature didn't work for its intended purpose.

Change-Id: I85331aa7b6212c55fe16081937465c2f38e5a103
Bug: skia:13428
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/552718
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2022-06-24 19:49:55 +00:00
Ethan Nicholas
a3983b64c3 Revert "Add removeUserDefinedSnippet method to ShaderCodeDictionary."
This reverts commit fc51827b56.

Reason for revert: Appears to have broken Mac (https://logs.chromium.org/logs/skia/5baefe22efa21e11/+/steps/dm/0/stdout)

Original change's description:
> Add removeUserDefinedSnippet method to ShaderCodeDictionary.
>
> We need to purge out user snippets when they are no longer needed, to
> avoid unbounded memory usage.
>
> Change-Id: Ib33909ec8c94cd6272f1a28e52a7ab92b27dfb0d
> Bug: skia:13405
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/552577
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

Bug: skia:13405
Change-Id: I914eca4f017697fc4c82316b805ebaaa8c72e162
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/552679
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2022-06-24 17:18:09 +00:00
John Stiles
fc51827b56 Add removeUserDefinedSnippet method to ShaderCodeDictionary.
We need to purge out user snippets when they are no longer needed, to
avoid unbounded memory usage.

Change-Id: Ib33909ec8c94cd6272f1a28e52a7ab92b27dfb0d
Bug: skia:13405
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/552577
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2022-06-24 14:12:26 +00:00
John Stiles
a99593bfa9 Add support for int-typed data payloads.
If we are going to create a new snippet ID every time a runtime effect
is painted, we will overflow a byte very rapidly.

Change-Id: Ic094af2a81e590488bf90b60492b004e9135d4a2
Bug: skia:13405
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/551843
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2022-06-22 03:06:16 +00:00
John Stiles
81d55ce3f7 Add BlockReader::pointer(fieldIndex) accessor.
We can now fully round-trip pointers through a PaintParamsKey safely.

Change-Id: I1a2133b39d895996f6c94211a0c5741ad0933398
Bug: skia:13428
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/550703
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-06-17 12:50:55 +00:00
John Stiles
f3c681465e Remove numPointers from SkShaderSnippet.
This undoes http://review.skia.org/550018, and also eliminates the
pointer-related additions to Stack in http://review.skia.org/550179.

When this was originally added, the plan was that pointers would not be
represented in the data payload at all, so we needed a mechanism to
track whether pointers were needed for each snippet type. This is now
handled by the existence of the kPointerIndex data payload field--
you'll assert on field-type mismatch/missing field if you skip the
pointer.

Change-Id: Ie868526d8d9da47819ea08e16aab1a5566f9cff8
Bug: skia:13428
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/550700
Commit-Queue: Robert Phillips <robertphillips@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2022-06-17 12:18:13 +00:00
Greg Daniel
0f1738dea7 [Graphite] Remove CommandBufferTest.
It has served use well, but its time to let it enjoy its life in
retirement.

Change-Id: I47213a7a74a890aa0b04e906fb236c7cc4aabb61
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/550621
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Auto-Submit: Greg Daniel <egdaniel@google.com>
2022-06-17 00:06:19 +00:00
John Stiles
5e2bbe5651 Finish PaintParamsKey support for SkColor4f in a key.
The API for keys containing colors was unfinished--there was a way to
add a single color to a key, but there were was no support in
BlockReader to read the color back out, and only fCount == 1 was
supported.

This CL fills in these gaps, and adds a test verifying that SkColor4f
data can round-trip through a PaintParamsKey successfully.

Change-Id: I9586fbd59e1a091970f44751322c03ad493888f5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/550698
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-06-16 20:28:39 +00:00
John Stiles
a87d30ecd2 Add data payload type for "pointer index."
This will give us stable data in the payload, so that the key itself
will match with operator== regardless of the pointer value. We can
extract pointers from the pointer-data block efficiently, even in the
case of multiple/nested children with embedded pointers, by using the
pointer-index value to fetch from the pointer-span.

Change-Id: Ic3b5f823a631257fd50ec6989b7c0fd1c70e6178
Bug: skia:13428
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/550497
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2022-06-16 17:51:23 +00:00
John Stiles
87f9e464bf Add SkPaintParamsKey::Header structure.
This was originally done with the intent of adding a third field
(number of pointers in the data) but we may be able to get away with
keeping the two-byte Header after all. Having the data in an actual
struct does make refactoring a lot easier, at any rate.

Change-Id: I25a4e46b45f3f9c93eb16bc4d51b6624d7e319ba
Bug: skia:13428
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/550183
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2022-06-16 17:51:10 +00:00
Robert Phillips
47a67a7f4f [graphite] Use CombinationBuilder to create SkPaintParamsKeys directly
Bug: skia:12701
Change-Id: I53bbabb2aba44e3bfc215df81dae1ae59d149263
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/544319
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-06-16 17:16:30 +00:00
Michael Ludwig
5cb9eb4057 [graphite] GridBoundsManager
And a little bit of unit tests and benchmarking...

Change-Id: I56252846c2c00f35e70472e5d8272717d6ec4b25
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/545897
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2022-06-16 15:46:01 +00:00
John Stiles
53be43fbb7 Add pointer-data fields to PaintParamsKey and KeyBuilder.
The BlockReader does not yet support pointer-data; that will be
implemented in a followup CL.

Change-Id: I01cd3712241071095fdb9cde741b8566d2761926
Bug: skia:13428
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/550179
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2022-06-15 20:03:21 +00:00
Herb Derby
8ccbeeebc3 Remove SkMakeSpan
Change-Id: I33121076bac3ceca19c81ff9fb47e4b024a14230
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/549838
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2022-06-15 17:26:32 +00:00
Nicolette Prevost
6dbbf38dc8 [graphite] Refactor Shape to be wrapped into a Geometry class
Create a new Geometry class that encapsulates Shapes, but can later encapsulate Vertices & text subruns. DrawGeometry has been renamed to DrawParams for clarity and now stores a Geometry object instead of a Shape.

Bug: skia:13352
Change-Id: I42781b3eecff9845b893aa99fe78c08fd50fb995
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/547281
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Nicolette Prevost <nicolettep@google.com>
2022-06-15 16:46:19 +00:00
John Stiles
78c1845e66 Update SkMakeRuntimeEffect to return a raw SkRuntimeEffect*.
Previously, we were storing sk_sp<SkRuntimeEffect> objects in static
variables. This would presumably lead to destructors executing during
atexit time, which is unnecessary and can lead to shutdown bugs. We no
longer attempt to free these objects.

Change-Id: I0b09d7ab3dc67c9b8fbc35c81d72ff57b0592c03
Bug: skia:13426
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/549658
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-06-14 23:37:34 +00:00
John Stiles
77ed6cc47e Add unit test for BlockReader class.
We didn't have any unit tests confirming that BlockReader can read back
the data out of a block. This seemed like a gap worth filling.

Change-Id: Iefbd5aec199a520ca1ca84b53faef4fd2f2d9ab4
Bug: skia:13428
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/550017
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2022-06-14 22:46:27 +00:00
John Stiles
f3e875b263 Add more equality/inequality tests to KeyTest.
After making http://review.skia.org/549837 I realized we also needed to
check the case of  data matching, but snippet IDs mismatching.

Change-Id: Iff9d3ec9921e66c1d65e2c4fe8ca0aa279444d7d
Bug: skia:13428
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/549841
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-06-14 17:21:52 +00:00
John Stiles
f1a77106e4 Add equality/inequality tests to KeyTest.
Previously, we didn't seem to have any tests verifying the behavior of
operator== and operator!=.

Change-Id: I1f76b8307a551f687d172782e8a30a01c0718e85
Bug: skia:13428
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/549837
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2022-06-14 17:21:52 +00:00
John Stiles
23564bd500 Split KeyTest into three separate tests with narrower scope.
The tests themselves are the same, just split up into their logical
groupings. From the principle go/unit-testing-overview#properties

"Focused. Above all, unit tests are narrow in scope, validating the
correctness of individual pieces of code rather than the correctness of
the system as a whole."

Change-Id: If4219c7ea447155314db885a1e1f0beb3c444b74
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/549836
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-06-14 16:06:54 +00:00
John Stiles
df4a82a524 Add a data payload to the RuntimeShaderBlock.
Runtime shaders are now distinguished by the hash of their shader text
and number of uniform bytes that they will use. Fortunately, we were
already computing the shader text hash so all we needed to do was
bring it into our data payload.

Change-Id: Ifc0bba6a7f18acd9affca5822e1a54fbff594d88
Bug: skia:13405
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/549100
Reviewed-by: Robert Phillips <robertphillips@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-06-13 21:11:47 +00:00
John Stiles
dbcc328fb0 Add basic Graphite boilerplate for a new RuntimeShader type.
This adds a new SkShaderType for runtime shaders, but it doesn't do
anything interesting yet; for now, we draw solid magenta as a
placeholder.

Change-Id: If0e4af9000d97fcf1184fbed004a64fff8fa4e63
Bug: skia:13405
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/548477
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2022-06-10 18:43:48 +00:00
Robert Phillips
5930798bad [graphite] Add CombinationBuilderTestAccess.h
In an upcoming CL the CombinationBuilderTestAccess object will need
to be accessed in multiple test .cpp files.

Bug: skia:12701
Change-Id: I66c969dbe054b7fd333bcd201fcebed4c1dfcc91
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/548698
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2022-06-10 17:21:13 +00:00
Robert Phillips
7769b5d4c2 [graphite] Remove usage of CreateKey from the CommandBufferTest
Bug: skia:12701
Change-Id: Ibaeedcbf478546f2942df95d362bee8632ba0ded
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/548419
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-06-10 14:20:25 +00:00
Robert Phillips
9eacc01a7f [graphite] Move addition of children out of AddToKey ...
and rename it BeginBlock.

The motivation for this CL is that it is simpler for the combination
system and the shaders to iterate over their children themselves rather
than shoehorning it into AddToKey.

Bug: skia:12701
Change-Id: I334fbcb7ce83af0681fb06d8449125fdbe8b05f3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/547446
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-06-08 18:35:25 +00:00
Robert Phillips
c42960d4f2 [graphite] Split out CombinationBuilder tests
Bug: skia:12701
Change-Id: Ibf7b4ac280eb853e3f5d786bd188ae0ac208609b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/545367
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-06-03 20:06:44 +00:00
Kevin Lubick
4511c7b7fb [bazel] Delete gazelle-based BUILD.bazel files
gazelle ended up being more liability than asset for our C++ rules.

It required devs to manually run the command frequently (and was
easy to forget until the CQ failed). The fact that we still had to
edit the source files (e.g. the "srcs" cc_libraries) meant that
the mixture between generated and hand-written caused some
tension (see include/third_party/vulkan for a good example).

The combination of gazelle and our IWYU enforcement added several
bits of churn without any real benefit. The generated rules
also didn't help identify cases where we were not keeping tight
boundaries (e.g. non-gpu code and gpu code).

Identifying third_party deps automatically ended up being trickier
than anticipated (see the deleted //third_party/file_map_for_bazel.json)

Using the "maximum set of dependencies" worked ok, but ended up
increasing build time unnecessarily. For example, compiling
CanvasKit for WebGL always needed to compile Dawn because
SkSLCompiler.cpp sometimes needs to include tint/tint.h.

Follow-up CLs will rebuild the BUILD.bazel rules without gazelle.

Note to Reviewers:
 - The only file worth manually reviewing here is bazel/Makefile.

Change-Id: I36d6fc3747487fabaf699690780c95f1f6765770
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543976
Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2022-05-31 14:14:54 +00:00
Robert Phillips
dfabbfc0e3 [graphite] Add SkCombinationBuilder.h
This is cleanup left over from a prior CL's review. We will want to
use the combination builder outside of graphite.

This CL is mainly just moving stuff around except for the addition
of the SkCombinationBuilder.buildCombinations method and CreateKey
more accessible outside of Graphite.

Bug: skia:12701
Change-Id: If2cae6fcff5670e488bc14473b7b1d2f9b1fecd7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543196
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-05-23 20:26:17 +00:00
Greg Daniel
8fd61eea0d [graphite] Add SkBudgeted field to Resources.
This also adds support for making a Resources unbudgeted state when it
is pulled out of the cache to be used for an SkImage or Surface. It
then puts the resources back as budgeted when returned to the cache.

Bug: skia:12754
Change-Id: I469ace602aa6f5f708b82655e94557ff8ad45a72
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/538046
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2022-05-23 17:59:54 +00:00
Robert Phillips
b2e3f57866 [graphite] Pull the ShaderType enum out of the ShaderCombo
The ShaderType enum seems like it will persist while the ShaderCombo will not.

Bug: skia:12701
Change-Id: Idf9ed89a50bac46b93a81da3e814207c83b3a1ea
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/541723
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2022-05-20 14:48:11 +00:00