Commit Graph

37 Commits

Author SHA1 Message Date
Mike Reed
5ec22387ff Simplify common case of linear filtering with no mips
Change-Id: I08b4a7bc088705b93a0aa680f6733d09c7ad23dd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/354221
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-01-15 16:47:16 +00:00
Mike Reed
410681932a Use explicit sampling param
Change-Id: Ifcb074365da8113fd5e0186d4afcf41041862e82
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/342761
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-12-10 14:01:58 +00:00
Brian Osman
91292e9482 Runtime Effects: Support 'uniform shader' (vs. 'in shader')
The previous behavior leaked Skia-internal concepts into public SkSL.
Users coming from GLSL will expect that bindable/sampleable objects are
uniform (just like texture2D). This keeps the old support around (and
tested), but updates all of our examples to use 'uniform'.

Bug: skia:10679
Change-Id: I0c98162f5e21dad7014d9778ceb26143d2f6030e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332376
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-11-04 22:29:53 +00:00
Brian Osman
b25e6e15c6 Remove unnecessary casting from SkSL in GMs
Converts examples to use more idiomatic "user" SkSL,
without extra casts, and taking advantage of swizzle.

Change-Id: I4ad4e7b6563b4f09402855cb125546b015622ced
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317388
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-09-16 19:56:07 +00:00
Brian Osman
767f444feb SkRuntimeEffect SkSL has a new signature for main()
There is no more 'inout half4 color'. Effects return their output color.
If an effect wants the input color, it must use the (already existing)
approach of sampling a nullptr input shader.

The change is guarded for Chromium (so we can update their runtime color
filters in skia_renderer.cc).

For the GPU backend, FPs can now override usesExplicitReturn to indicate
that their emitCode will generate a return statement. If that's true,
then writeProcessorFunction doesn't inject the automatic return of the
output color, and emitFragProc will *always* wrap that FP in a helper
function, even as a top-level FP. GrSkSLFP opts in to this behavior, so
that the user-supplied return becomes the actual return in the FP's
emitCode.

Adapting the skvm code to this wasn't too bad: It looks fragile (what
happens if there are multiple returns?), but that's not really possible
today, without varying control flow.

Bug: skia:10613

Change-Id: I205b81fd87dd32bab30b6d6d5fc78853485da036
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/310756
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-08-25 13:36:28 +00:00
Brian Osman
5240e18fff SkRuntimeEffect: Handle different main() signatures on CPU
Bug: skia:10603
Change-Id: Ib4d2b36c09c30a9a112f5a2d2d7060c09009671b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309782
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-08-12 19:21:01 +00:00
Brian Osman
a4b9169fb6 Remove 'in' variables from SkRuntimeEffect
Runtime effects previously allowed two kinds of global input variables:
'in' variables could be bool, int, or float. 'uniform' could be float,
vector, or matrix. Uniform variables worked like you'd expect, but 'in'
variables were baked into the program statically. There was a large
amount of machinery to make this work, and it meant that 'in' variables
needed to have values before we could make decisions about program
caching, and before we could catch some errors. It was also essentially
syntactic sugar over the client just inserting the value into their SkSL
as a string. Finally: No one was using the feature.

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

Bug: skia:10593
Change-Id: I971f620d868b259e652b3114f0b497c2620f4b0c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309050
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-08-10 22:00:44 +00:00
Brian Osman
44fafa6b74 Clean up some boilerplate in runtimeshader.cpp
Change-Id: I068f71d94d506213e6c9b24d7fe5c6d6187e5ac0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/302902
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-07-15 16:50:13 +00:00
Brian Osman
a7685b2343 Runtime effects: Allow null children
Two related things:
1) SkRuntimeEffect will allow null child shaders when calling
   makeshader. This will produce a GrSkSLFP with null FP children.
   Fix some code that assumed that children were non-null.
2) Change the input color passed to any children to be the SkSLFP's
   input color, rather than the default (white). This lets nullptr
   children in runtime effect have the desired behavior (they are the
   paint color or similar, depending on context).

Change-Id: Iabffc50b0a893a56403c5240f32a5da6a88d81f6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/301980
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-07-14 21:33:57 +00:00
Brian Osman
795efd2f04 Add pass-through sampling to SkVM, use it when possible
This produces better shaders when using the arithmetic mode filter, for
example.

Change-Id: Ie1e030604c3a9c99122d112603a548b6fe359621
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300209
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-07-01 18:47:34 +00:00
Brian Osman
89bf734d87 Add ceil to skvx/skvm/JIT, and floor/ceil intrinsics to ByteCode
This is enough to get the colorcube GM working on the CPU backend.
(It's not blazingly fast, but it works!)

Change-Id: Ic069861bab162ed49f876fd03af2cbaaec2da628
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297718
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-06-19 15:37:03 +00:00
Mike Klein
f8d68fe7d4 runtime shader children on skvm backend
Mostly plumbing and misc instructions to draw threshold_rt.

Backends differ in what we return when sampling alpha-only
images, so I've switched threshold_rt to use the .a channel,
which everyone agrees on.

I'm pretty confused about what CTM and local matrix to pass
to the child program() calls, so I've just passed no-ops.

Change-Id: I004b428b4e5e27f3963a27dea0ef44e1f57bc3e0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297384
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-06-18 17:37:38 +00:00
Ethan Nicholas
77968f0d32 Revert "fixed sample(..., matrix) with runtime effects"
This reverts commit fb5ede576d.

Reason for revert: major performance regression due to constant shader recompilation

Original change's description:
> fixed sample(..., matrix) with runtime effects
> 
> Change-Id: Id5b7f1b5e992c587be000e112706bedfe00c90fd
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294697
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

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

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

Change-Id: Ica8322e0eab8f00bfc1d4f6d33778eb6493b278f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/295835
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2020-06-11 22:25:53 +00:00
Ethan Nicholas
fb5ede576d fixed sample(..., matrix) with runtime effects
Change-Id: Id5b7f1b5e992c587be000e112706bedfe00c90fd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294697
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-06-10 13:59:15 +00:00
Brian Osman
921cdbb387 Fix dimensions of color_cube_rt slide
Change-Id: Ic6d26b1e3126298ac0de3e88468e3598b3de3d49
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292836
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-05-29 14:59:43 +00:00
Brian Osman
2c28bf9fe0 Directly compute normalized coords in the color cube runtime effect
We can compute these directly, and avoid a whole extra matrix uniform
and multiply to get the same effect.

Change-Id: I25146932fd577f64567abee8df2c001a830ef78f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292574
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-05-28 19:18:43 +00:00
Brian Osman
9c3eccd5d7 Runtime effect implementation of color cube filter
Bug: skia:10274
Change-Id: Ifb2ef8bf031e74d9d5c8183efe5aff4e6f3d2e7c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292562
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-05-28 15:45:48 +00:00
Mike Reed
1f60733fb3 Revert "Revert "move onto new factories for SkMatrix""
This reverts commit c80ee456ad.

fix: update flutter's gn file to add guard

Change-Id: Iac5171c8475d9a862d06255dab1c6f38f10de2f2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291361
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-05-21 16:58:39 +00:00
Mike Reed
c80ee456ad Revert "move onto new factories for SkMatrix"
This reverts commit 046c2b7d90.

Reason for revert: need to update/guard flutter

Original change's description:
> move onto new factories for SkMatrix
> 
> Just rename, no functional changes expected.
> 
> Change-Id: Id77ab1cf6b1cab35087a7c56000750912cf47383
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290831
> Commit-Queue: Mike Reed <reed@google.com>
> Reviewed-by: Florin Malita <fmalita@chromium.org>

TBR=fmalita@chromium.org,reed@google.com

Change-Id: Ic74f177128913374b8c60b4df88f04cf72fbacb3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291359
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-05-21 16:05:20 +00:00
Mike Reed
046c2b7d90 move onto new factories for SkMatrix
Just rename, no functional changes expected.

Change-Id: Id77ab1cf6b1cab35087a7c56000750912cf47383
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290831
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2020-05-21 15:04:09 +00:00
Brian Osman
28590d54f5 Add 'shader' as an alias for 'fragmentProcessor'
Change-Id: I2d95c63de18125e6258709b48b03abd7904b7537
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/278596
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-05-15 13:52:15 +00:00
Brian Osman
b32d66b296 Add layout(srgb_unpremul) to SkSL
For 3 and 4 channel float uniforms, this states that the data supplied
is unpremul sRGB, and transforms that data to the destination color
space (still unpremul) automatically.

Change-Id: I1b420d2fd10640963fa8e6736af3747cfc6e7d5b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/286656
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-05-01 20:12:43 +00:00
Mike Klein
45be07785d length()
- add length() as a special intrinsic
 - style refactoring I wrote to help debug the CL
 - impl dup2,3,4 in program_fn
 - (better) fix dup2,3,4 in byte code interpreter

Change-Id: I7cd94a4bc03efc6af2053e9e6ae18b4da94363ed
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/286896
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-05-01 20:07:40 +00:00
Mike Reed
8520e76f05 migrate spiral demo from canvaskit
- add atan, fract, dividef, subtractf

Also wants mix(), but I'm still learning how to handle 2 args
functions (e.g. how to support atan(y,x) as well)

Change-Id: Ib9f233cd1c4266110cfea68a7d444f834f875f1f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/286276
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-04-30 16:52:22 +00:00
Mike Reed
146722ed8b threshold rtshader
Change-Id: Ia1a0e35f2cb7cf2f7fd1a58b88dc81ec59eced0b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268943
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-02-13 18:00:22 +00:00
Brian Osman
7353dc5490 Change SkSL main() from (float x, float y) to (float2 p)
Change-Id: Id046199edd63535ef07e1dfa65fbc7c0f8cefd00
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269371
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-02-07 20:19:13 +00:00
Brian Osman
3225306f82 In SkRuntimeEffect, just use hash of SkSL as the ID
Change-Id: I2ce210889452756d5d100fbb15f578bb72e2af2a
Bug: skia:9813
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268687
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-02-05 17:52:48 +00:00
Brian Osman
ee426f223f Move SkRuntimeEffect.h to include/effects
Change-Id: I0b11d4210c6e663cfb4854fc33e1396fd79fe9a4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/261780
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-01-02 17:37:46 +00:00
Brian Osman
93de162dc2 Add SkRuntimeEffect::makeShader
This makes the effect *be* the factory, so we can get rid of
SkRuntimeShaderFactory (and later, SkColorFilterFactory).

Change-Id: I2cd95f1380a0ec1e65fe5a18b1226c042598a8bd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/261439
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-12-27 21:50:20 +00:00
Brian Osman
c937bc5025 Improvements to uniform handling in runtime SkSL
- Support array uniforms
- Fix cases where the read head wasn't aligned in onSetData
- Default to float as the CType for half. (half4 was using
  PMColor, and other half types required a layout(ctype...)

Change-Id: I63cb1706071668de0ab80f3d812cd9ad29ff9651
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/258808
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-12-09 17:57:05 +00:00
Ethan Nicholas
31cff27607 Revert "Revert "remove 'in uniform' support from GrSkSLFP, make rules more clear""
This reverts commit 85705c1b3b.

Change-Id: If189dafce53491728296a4292c76af55b05835ac
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244509
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-09-26 18:11:45 +00:00
Ethan Nicholas
85705c1b3b Revert "remove 'in uniform' support from GrSkSLFP, make rules more clear"
This reverts commit ac18a5ca60.

Reason for revert: breaking Chrome roll

Original change's description:
> remove 'in uniform' support from GrSkSLFP, make rules more clear
> 
> Bug: skia:
> Change-Id: Iaa4d33c1bfb295d87343411ba6aacc8fae68ef9c
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244300
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>

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

Change-Id: I6e53f5197c751d961abfa21861b940d4168de213
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244508
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2019-09-26 16:04:26 +00:00
Ethan Nicholas
ac18a5ca60 remove 'in uniform' support from GrSkSLFP, make rules more clear
Bug: skia:
Change-Id: Iaa4d33c1bfb295d87343411ba6aacc8fae68ef9c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244300
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2019-09-26 14:05:10 +00:00
Brian Osman
7e16b58b5a SkRuntimeShaderMaker -> SkRuntimeShaderFactory
This refactor makes it work like the runtime color filter, where inputs
can be updated without generating a new shader key every time.

Change-Id: Ic1762aebae96fd8b7a8a74fb200bc02ec08cc029
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/235798
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-08-21 18:22:33 +00:00
Hal Canary
594fe855a3 gm: simplify several onName
Change-Id: I9c470c2cf5d546626c279ce65626f767292a94e6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/228354
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-07-24 18:05:45 +00:00
Mike Reed
8c31f2bf7f use same signature for shader/colorfilters in sksl
'void main(float x, float y, inout half4 color)'

For colorfilters, x,y are uninitialized
For shaders, color is paint-color

Change-Id: I21c2f570702f117d33646bd8fba0ab4def20a118
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/227439
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2019-07-17 15:47:36 +00:00
Mike Reed
3fd3cc94c3 runtime shaders
This extends the runStriped to all for return data.
GPU impl not done yet, will be done in a follow-on CL.

Change-Id: Ib107d2945f6fdb34ce1b5405a6c88a5ae7e9f7ac
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/221539
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2019-06-20 17:11:05 +00:00