Commit Graph

81 Commits

Author SHA1 Message Date
Ethan Nicholas
e8ad02c6e9 Revert "Reland "Revert "Omit dead SkSL functions"""
This reverts commit a15f2bfb6f.

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

Change-Id: I64cc7830281ee69bf3377c5b6daa3d96ccf4769e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/293976
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2020-06-04 02:46:55 +00:00
Ethan Nicholas
a15f2bfb6f Reland "Revert "Omit dead SkSL functions""
This reverts commit fd1173ac71.

Reason for revert: TSAN failure: https://chromium-swarm.appspot.com/task?id=4c93823229fa6a10

Original change's description:
> Revert "Revert "Omit dead SkSL functions""
> 
> This reverts commit 7c969f26bc.
> 
> Change-Id: I8fb99f271e2ecaeb83d570cc2d2cf8851bc776f0
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/293338
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>

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

# Not skipping CQ checks because this is a reland.

Change-Id: Iab3ee5a336074676ebd0b761922ececf189752ef
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/293843
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2020-06-03 17:14:18 +00:00
Ethan Nicholas
fd1173ac71 Revert "Revert "Omit dead SkSL functions""
This reverts commit 7c969f26bc.

Change-Id: I8fb99f271e2ecaeb83d570cc2d2cf8851bc776f0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/293338
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2020-06-03 14:22:18 +00:00
Ethan Nicholas
7c969f26bc Revert "Omit dead SkSL functions"
This reverts commit 97fe0cbed2.

Reason for revert: ASAN failures

Original change's description:
> Omit dead SkSL functions
> 
> Now that SkSL inlines functions, dead functions are very common. This
> change causes them to be omitted from the final output.
> 
> Change-Id: Ie466a3f748812eff1a368498365c89d73ab0b7be
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292684
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>

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

Change-Id: Id20c5be67dd574d30d6f978ba610e43aa5018416
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/293241
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2020-06-01 15:00:00 +00:00
Ethan Nicholas
97fe0cbed2 Omit dead SkSL functions
Now that SkSL inlines functions, dead functions are very common. This
change causes them to be omitted from the final output.

Change-Id: Ie466a3f748812eff1a368498365c89d73ab0b7be
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292684
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2020-06-01 14:27:38 +00:00
Ethan Nicholas
70728ef8e7 Revert "Reland "Revert "SkSL function inlining"""
This reverts commit 04ff61faae.

Change-Id: Ieb69c76b161ec9e003982d36bb2e28d055ad47a6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292266
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2020-05-28 13:27:58 +00:00
Ethan Nicholas
04ff61faae Reland "Revert "SkSL function inlining""
This reverts commit 2dd272bf15.

Reason for revert: breaking angle

Original change's description:
> Revert "Revert "SkSL function inlining""
> 
> This reverts commit 1b63b4ac69.
> 
> Change-Id: I8120bb10cecc6889f4f4fd7b4c3a61d250e49219
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291358
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>

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

# Not skipping CQ checks because this is a reland.

Change-Id: Ib3117efd1b77e97899e636bcbc4d84200118bc36
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292264
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2020-05-27 19:57:58 +00:00
Ethan Nicholas
2dd272bf15 Revert "Revert "SkSL function inlining""
This reverts commit 1b63b4ac69.

Change-Id: I8120bb10cecc6889f4f4fd7b4c3a61d250e49219
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291358
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2020-05-27 18:26:47 +00:00
Robert Phillips
1b63b4ac69 Revert "SkSL function inlining"
This reverts commit b65024b5f2.

Reason for revert: Shader compilation failures

Original change's description:
> SkSL function inlining
> 
> This first pass adds "one size fits all" function inlining, without any
> allowances for simple functions that don't need all of this machinery
> in place. Followup CLs will simplify common cases by e.g. not storing
> arguments in variables if they're already variables and not wrapping
> the function body in a loop when it isn't necessary.
> 
> Change-Id: I4fd8c1655ff48b9e4708bcca03a506df34ceadd9
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290127
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>

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

Change-Id: Ia6e643e0dcb66a4f0c2a377b89117047bbc5d058
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290801
Reviewed-by: Robert Phillips <robertphillips@google.com>
2020-05-19 16:10:51 +00:00
Ethan Nicholas
b65024b5f2 SkSL function inlining
This first pass adds "one size fits all" function inlining, without any
allowances for simple functions that don't need all of this machinery
in place. Followup CLs will simplify common cases by e.g. not storing
arguments in variables if they're already variables and not wrapping
the function body in a loop when it isn't necessary.

Change-Id: I4fd8c1655ff48b9e4708bcca03a506df34ceadd9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290127
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2020-05-19 14:22:10 +00:00
Ethan Nicholas
5843012837 Add sample(child, matrix) to SkSL.
This allows fragment processors to sample their children with their
local coordinate system transformed by a matrix.

Change-Id: Ifa848bbd85b939bbc5751fec5cf8f89ee904bf39
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/282590
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2020-04-14 16:07:34 +00:00
Ethan Nicholas
16464c3232 Tracking uniform ownership
This is a prerequisite change for the upcoming sample(child, matrix)
function. By itself, this CL doesn't really change anything; it just
adds an ownership tracking feature which sample(child, matrix) depends
on.

Change-Id: I98b12e5fb062a2535af367931e7a932ea9c63a59
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281337
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2020-04-06 19:02:37 +00:00
Greg Daniel
456f9b5fe9 Reland "Move GrGpuResource GrSurface and GrTexture into src."
This reverts commit f6ed96d1c2.

Reason for revert: google3 change landed

Original change's description:
> Revert "Move GrGpuResource GrSurface and GrTexture into src."
> 
> This reverts commit e5a06ce678.
> 
> Reason for revert: Need to make change in google3 first
> 
> Original change's description:
> > Move GrGpuResource GrSurface and GrTexture into src.
> > 
> > Must land https://chromium-review.googlesource.com/c/chromium/src/+/2087980
> > before this can land.
> > 
> > Bug: skia:7966
> > Change-Id: I60bbb1765bfbb2c96b2bc0c9826b6b9d57eb2a03
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275077
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> 
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> 
> Change-Id: Id39e0a351e49a87209de88a6ad9fadb0219db72c
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:7966
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275216
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>

TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com

Change-Id: I746ce739cb084cefc46f9dab24ef773e7c3cc621
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:7966
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275436
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2020-03-05 19:16:21 +00:00
Greg Daniel
f6ed96d1c2 Revert "Move GrGpuResource GrSurface and GrTexture into src."
This reverts commit e5a06ce678.

Reason for revert: Need to make change in google3 first

Original change's description:
> Move GrGpuResource GrSurface and GrTexture into src.
> 
> Must land https://chromium-review.googlesource.com/c/chromium/src/+/2087980
> before this can land.
> 
> Bug: skia:7966
> Change-Id: I60bbb1765bfbb2c96b2bc0c9826b6b9d57eb2a03
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275077
> Commit-Queue: Greg Daniel <egdaniel@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>

TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com

Change-Id: Id39e0a351e49a87209de88a6ad9fadb0219db72c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:7966
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275216
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2020-03-05 01:46:51 +00:00
Greg Daniel
e5a06ce678 Move GrGpuResource GrSurface and GrTexture into src.
Must land https://chromium-review.googlesource.com/c/chromium/src/+/2087980
before this can land.

Bug: skia:7966
Change-Id: I60bbb1765bfbb2c96b2bc0c9826b6b9d57eb2a03
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275077
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2020-03-04 23:01:31 +00:00
Mike Reed
46f5c5f08b Make SkM44 public
Need to migrate clients from private/ to core/ include
Unexperimentalize concat44() methods on SkCanvas

Change-Id: I64b8816722a9d93316cb8b8691d2d9a3e36f167f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/272464
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-02-21 15:50:31 +00:00
Brian Salomon
b243b4389f Make SkSL CPP code gen copy explicit coord status for cloned FPs
Change-Id: I1479136de8fcab32e2be661fd5fae020b319aab8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/272458
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-02-20 20:12:48 +00:00
Brian Osman
978693cdaa Make invokeChild just return a string containing the child function call
Also removes several unused chunks of code that were declaring unused
variables, etc.

Change-Id: I47458736b189d59c0448c6f58b60a9b4ab046db2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/266565
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-01-24 20:23:33 +00:00
Mike Reed
b26b4e7340 Revert "Revert "use SkM44 internally""
This reverts commit f79aacba2b.

Fix: had transposed when converting from colormatrix to m44

Change-Id: I6bc81d0c50bb1bf8d771e4dfa0c25c39de265b1e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/265765
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-01-22 20:19:16 +00:00
Mike Reed
f79aacba2b Revert "use SkM44 internally"
This reverts commit 295cdf8775.

Reason for revert: wacky gm colors, must have busted colormatrixfilter

Original change's description:
> use SkM44 internally
> 
> Today we use SkM44 in canvas, and SkMatrix44 in sksl (and colormatrix).
> This CL tries to move core to use a single type.
> 
> SkMatrix44 has callers in android and chrome, is loaded with double/float
> variants in its API. I am suggesting moving to a private, clean-start,
> API for internal use. SkM44 is much faster, and has a leaner API.
> 
> If eventually we can migrate clients to a shared impl/api, great. For now,
> I want to have one we are free to optimize/use as we see fit without
> worrying about changing client results.
> 
> Change-Id: Id782ac1cc8b8d7f6621970e44e1f9729964d2a94
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/265299
> Commit-Queue: Mike Reed <reed@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

TBR=mtklein@google.com,bsalomon@google.com,brianosman@google.com,fmalita@chromium.org,reed@google.com

Change-Id: I35fcd636f1b57001bb65684e78523b6a94cfebee
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/265764
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-01-22 18:05:34 +00:00
Mike Reed
295cdf8775 use SkM44 internally
Today we use SkM44 in canvas, and SkMatrix44 in sksl (and colormatrix).
This CL tries to move core to use a single type.

SkMatrix44 has callers in android and chrome, is loaded with double/float
variants in its API. I am suggesting moving to a private, clean-start,
API for internal use. SkM44 is much faster, and has a leaner API.

If eventually we can migrate clients to a shared impl/api, great. For now,
I want to have one we are free to optimize/use as we see fit without
worrying about changing client results.

Change-Id: Id782ac1cc8b8d7f6621970e44e1f9729964d2a94
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/265299
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-01-22 17:39:15 +00:00
Mike Reed
55f6fc3064 IWYU -- colorspace no longer includes matrix44
Change-Id: I659552466940b76a339caaf124700303806fd082
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/265456
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-01-21 21:37:32 +00:00
Brian Salomon
bf5c0c0c99 Fixed sampling non-SkSL FPs with coordinates
This fixes an issue where fragment processors which were not written
in pure SkSL did not interact properly with coordinate overrides.

Change-Id: I960173986fd8d6be7322f55ab0d81a533b6b89e5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/252916
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2019-11-14 17:46:18 +00:00
Ethan Nicholas
095f5b4de8 .fp files now support user-defined functions
Bug: skia:
Change-Id: I9903f4c7751474a066b52b1feab39b58a9cb7af2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/238439
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2019-08-30 17:50:45 +00:00
Ethan Nicholas
d4efe685dd SkSL sample() now permits specification of coordinates
Bug: skia:
Change-Id: I16073008ac852f1864bd1d2bd38087a5b661d05a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/232581
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2019-08-30 15:29:13 +00:00
Ethan Nicholas
33c59ed8df added error check for invalid 'in' variables
Bug: skia:
Change-Id: I0e767f322ad10a0ca4c6209c516b538ff36c9279
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/233986
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2019-08-13 15:25:47 +00:00
Ethan Nicholas
1386366e01 renamed SkSL texture() and process() to sample()
Bug: skia:
Change-Id: I2ae0caf08f8434302cae8151ae1ea0fda8d56928
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/230397
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2019-07-29 17:37:38 +00:00
Ethan Nicholas
c6dce5ac87 Child fragment processors are now written as separate functions
Bug: skia:
Change-Id: Icbf8f542637a874b3e2d3513d932b39728fa5e77
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/229385
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2019-07-25 14:48:47 +00:00
Ethan Nicholas
fc9941665b Major rearchitecture of SkSL parsing, focused on improving performance.
Bug: skia:
Change-Id: I83e3a094d26085fc4d586e5d2581e0d61c55634e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/145080
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-06-06 14:33:32 +00:00
Ethan Nicholas
6ad5289ea4 Revert "Child fragment processors are now written as separate functions"
This reverts commit 0364bde2c4.

Reason for revert: bot breakage, e.g. https://chromium-swarm.appspot.com/task?id=44942724fab4b710 and https://chromium-swarm.appspot.com/task?id=44938767e5fbb810
Original change's description:
> Child fragment processors are now written as separate functions
> instead of inline
> 
> Bug: skia:
> Change-Id: I3c6c876fea9cfcc311fc09c0fdf0375b776004aa
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/210632
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>

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

Change-Id: If33c1f554a090cd7541878e77712d5ce968ec70a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/211943
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2019-05-03 13:13:47 +00:00
Ethan Nicholas
0364bde2c4 Child fragment processors are now written as separate functions
instead of inline

Bug: skia:
Change-Id: I3c6c876fea9cfcc311fc09c0fdf0375b776004aa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/210632
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-02 20:48:47 +00:00
Mike Klein
c0bd9f9fe5 rewrite includes to not need so much -Ifoo
Current strategy: everything from the top

Things to look at first are the manual changes:

   - added tools/rewrite_includes.py
   - removed -Idirectives from BUILD.gn
   - various compile.sh simplifications
   - tweak tools/embed_resources.py
   - update gn/find_headers.py to write paths from the top
   - update gn/gn_to_bp.py SkUserConfig.h layout
     so that #include "include/config/SkUserConfig.h" always
     gets the header we want.

No-Presubmit: true
Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-04-24 16:27:11 +00:00
Ethan Nicholas
bcd51e8e6d SkSL 'key' variables can now be controlled by 'when' expressions
Bug: skia:8880
Change-Id: I075ef57035b37250196d85bc6767eb877e445aa2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206698
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2019-04-09 17:46:56 +00:00
Ethan Nicholas
858feccb58 Got RelaxedPrecision decorations working again in SPIR-V, and removed
no-longer-needed old-style precision handling code.

Bug: skia:8829
Change-Id: I72fc2ee2a305c9c72a3efa92dd44d18239eabaf2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/198169
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2019-03-07 19:56:59 +00:00
Florin Malita
390f9bd8ba Fix handling of SkSL nullable FPs
Bug: skia:8798
Change-Id: Iec311c9d834a6f35b0a4481dbd748532107cd4b1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/197108
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-03-04 22:09:20 +00:00
Ethan Nicholas
ee1c8a733e Revert "Revert "SkSL now supports null child processors""
This reverts commit bce7d86270.

Bug: skia:
Change-Id: I3ccaf47b3d4b9dcb9e049671117183a374526032
Reviewed-on: https://skia-review.googlesource.com/c/194185
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2019-02-22 17:50:30 +00:00
Robert Phillips
bce7d86270 Revert "SkSL now supports null child processors"
This reverts commit 0e8dc4ce36.

Reason for revert: ASAN complaints

Original change's description:
> SkSL now supports null child processors
> 
> Bug: skia:
> Change-Id: Icb3f2d57b393e3d40247aaad98c17344b507f0d7
> Reviewed-on: https://skia-review.googlesource.com/c/193379
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Florin Malita <fmalita@chromium.org>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>

TBR=bsalomon@google.com,ethannicholas@google.com,fmalita@chromium.org

Change-Id: Ibf739b3c6afd32d44f6b20705922618c29960d16
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/c/194020
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2019-02-21 22:54:08 +00:00
Ethan Nicholas
0e8dc4ce36 SkSL now supports null child processors
Bug: skia:
Change-Id: Icb3f2d57b393e3d40247aaad98c17344b507f0d7
Reviewed-on: https://skia-review.googlesource.com/c/193379
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2019-02-21 21:50:32 +00:00
Ethan Nicholas
e1f5502969 Reland "SkSL is now pickier about type conversions"
This is a reland of 91c1d08bc3

Original change's description:
> SkSL is now pickier about type conversions
> 
> Bug: skia:
> Change-Id: I4e8b8f229f4e4344f160b0dbb41832764d0b75bd
> Reviewed-on: https://skia-review.googlesource.com/c/188311
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

Bug: skia:
Change-Id: I727cad061afc0a5ee6f4d2df789330d809dd110a
Reviewed-on: https://skia-review.googlesource.com/c/189643
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2019-02-06 02:40:59 +00:00
Ethan Nicholas
c83da98d50 Revert "SkSL is now pickier about type conversions"
This reverts commit 91c1d08bc3.

Reason for revert: breaking everything

Original change's description:
> SkSL is now pickier about type conversions
> 
> Bug: skia:
> Change-Id: I4e8b8f229f4e4344f160b0dbb41832764d0b75bd
> Reviewed-on: https://skia-review.googlesource.com/c/188311
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

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

Change-Id: I670fa9215d3ca0ce738edc24e832b6d968599cb1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/c/189642
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2019-02-05 21:54:51 +00:00
Ethan Nicholas
91c1d08bc3 SkSL is now pickier about type conversions
Bug: skia:
Change-Id: I4e8b8f229f4e4344f160b0dbb41832764d0b75bd
Reviewed-on: https://skia-review.googlesource.com/c/188311
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-02-05 21:36:33 +00:00
Brian Osman
495993a5e3 Remove GrColor4f
All uses have been converted to SkPMColor4f (or similar).

Bug: skia:
Change-Id: I220bd5eaf6c35b17321c1e8bc92ace7ff92908c4
Reviewed-on: https://skia-review.googlesource.com/c/162749
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2018-10-16 20:37:58 +00:00
Michael Ludwig
9094f2c8b5 Add fields to fragmentProcessors in sksl code.
Getters for GrFragmentProcessor's optimization flags and state are
exposed as constant fields on the fragmentProcessor variable in sksl.
The CPP code generation then emits extra instructions to invoke the
particular getter when building the final sksl string at runtime.

Bug: skia:
Change-Id: If6bf4f4df6c446fb6331484d36effb1386172918
Reviewed-on: https://skia-review.googlesource.com/152381
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2018-09-07 17:52:05 +00:00
Michael Ludwig
1fc5fbd804 Reland "Redo how extra emit code flushing operates" with type fix.
This reverts commit d0440195d5.

Reason for revert: Fixes size_t -> int that was triggering ASAN failures.

Original change's description:
> Revert "Redo how extra emit code flushing operates"
>
> This reverts commit 9b8181b05a.
>
> Reason for revert: <INSERT REASONING HERE>
>
> Original change's description:
> > Redo how extra emit code flushing operates
> >
> > The previous implementation of flushEmittedCode(), that flushed on
> > demand when a process() was encountered, was brittle and susceptible to
> > mangling the expected sksl when fOut was modified outside of its
> > control. Given that writeFunction() and generateCode() in the parent
> > class all do this, it's possible to generate a simple SkSL snippet that
> > would generate a CPP file that builds invalid final SkSL:
> >
> > ```
> > in fragmentProcessor child;
> > bool someGlobalVar = ...;
> > void main() {
> >     if (someGlobalVar) {
> >         sk_OutColor = process(child, sk_InColor);
> >     } else {
> >         sk_OutColor = half4(1);
> >     }
> > }
> > ```
> >
> > The CPP generated code *should* insert 'bool someGlobalVar' at the start
> > but because of the early flush from the child process and because of
> > how fOut was overwritten, someGlobalVar's declaration is put into a
> > stream that is not visible to the flush and ends up being inserted into
> > the output sksl in an incorrect location (namely after the if condition
> > that depends on it).
> >
> > This CL updates the extra emitted code logic to support multiple blocks
> > of extra CPP code. When a flush point occurs in SkSL writing, a special
> > token is inserted into the SkSL and a new CPP code buffer is associated
> > with that token. Then once all of the SkSL is accumulated into the root
> > output stream, it is processed into sections for each extra CPP block.
> > Special logic is done so that the SkSL that is emitted before the next
> > CPP block terminates at the end of the last valid statement before the
> > special token.
> >
> > A unit test demonstrating this failure condition is added to SkSLFPTest
> > and the CL properly passes. Since this bug did not trigger on existing
> > .fp files, the updated generator does not modify the generated FPs.
> >
> > Bug: skia:
> > Change-Id: Ib74911942080f1b964159807a06805bc52898789
> > Reviewed-on: https://skia-review.googlesource.com/152321
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
>
> TBR=ethannicholas@google.com,michaelludwig@google.com
>
> Change-Id: Id0f908453b596873f43b86a1c14eed48b2474a76
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:
> Reviewed-on: https://skia-review.googlesource.com/152660
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

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

Change-Id: I3ccf2fee6ef96c6102dbe1c2c2ef6c14a701b8fd
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/152663
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2018-09-07 17:15:13 +00:00
Michael Ludwig
d0440195d5 Revert "Redo how extra emit code flushing operates"
This reverts commit 9b8181b05a.

Reason for revert: <INSERT REASONING HERE>

Original change's description:
> Redo how extra emit code flushing operates
> 
> The previous implementation of flushEmittedCode(), that flushed on
> demand when a process() was encountered, was brittle and susceptible to
> mangling the expected sksl when fOut was modified outside of its
> control. Given that writeFunction() and generateCode() in the parent
> class all do this, it's possible to generate a simple SkSL snippet that
> would generate a CPP file that builds invalid final SkSL:
> 
> ```
> in fragmentProcessor child;
> bool someGlobalVar = ...;
> void main() {
>     if (someGlobalVar) {
>         sk_OutColor = process(child, sk_InColor);
>     } else {
>         sk_OutColor = half4(1);
>     }
> }
> ```
> 
> The CPP generated code *should* insert 'bool someGlobalVar' at the start
> but because of the early flush from the child process and because of
> how fOut was overwritten, someGlobalVar's declaration is put into a
> stream that is not visible to the flush and ends up being inserted into
> the output sksl in an incorrect location (namely after the if condition
> that depends on it).
> 
> This CL updates the extra emitted code logic to support multiple blocks
> of extra CPP code. When a flush point occurs in SkSL writing, a special
> token is inserted into the SkSL and a new CPP code buffer is associated
> with that token. Then once all of the SkSL is accumulated into the root
> output stream, it is processed into sections for each extra CPP block.
> Special logic is done so that the SkSL that is emitted before the next
> CPP block terminates at the end of the last valid statement before the
> special token.
> 
> A unit test demonstrating this failure condition is added to SkSLFPTest
> and the CL properly passes. Since this bug did not trigger on existing
> .fp files, the updated generator does not modify the generated FPs.
> 
> Bug: skia:
> Change-Id: Ib74911942080f1b964159807a06805bc52898789
> Reviewed-on: https://skia-review.googlesource.com/152321
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>

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

Change-Id: Id0f908453b596873f43b86a1c14eed48b2474a76
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/152660
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2018-09-07 14:25:10 +00:00
Michael Ludwig
9b8181b05a Redo how extra emit code flushing operates
The previous implementation of flushEmittedCode(), that flushed on
demand when a process() was encountered, was brittle and susceptible to
mangling the expected sksl when fOut was modified outside of its
control. Given that writeFunction() and generateCode() in the parent
class all do this, it's possible to generate a simple SkSL snippet that
would generate a CPP file that builds invalid final SkSL:

```
in fragmentProcessor child;
bool someGlobalVar = ...;
void main() {
    if (someGlobalVar) {
        sk_OutColor = process(child, sk_InColor);
    } else {
        sk_OutColor = half4(1);
    }
}
```

The CPP generated code *should* insert 'bool someGlobalVar' at the start
but because of the early flush from the child process and because of
how fOut was overwritten, someGlobalVar's declaration is put into a
stream that is not visible to the flush and ends up being inserted into
the output sksl in an incorrect location (namely after the if condition
that depends on it).

This CL updates the extra emitted code logic to support multiple blocks
of extra CPP code. When a flush point occurs in SkSL writing, a special
token is inserted into the SkSL and a new CPP code buffer is associated
with that token. Then once all of the SkSL is accumulated into the root
output stream, it is processed into sections for each extra CPP block.
Special logic is done so that the SkSL that is emitted before the next
CPP block terminates at the end of the last valid statement before the
special token.

A unit test demonstrating this failure condition is added to SkSLFPTest
and the CL properly passes. Since this bug did not trigger on existing
.fp files, the updated generator does not modify the generated FPs.

Bug: skia:
Change-Id: Ib74911942080f1b964159807a06805bc52898789
Reviewed-on: https://skia-review.googlesource.com/152321
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2018-09-07 14:08:59 +00:00
Michael Ludwig
a427559c13 Refactor 'in uniform' CPP code generation
Easily supports mapping ctypes to sksl types with templates that
specify how to send data to the GPU and how to track state changes.
The template logic and type mappings are defined in
SkSLCPPUniformCTypes.* while SkSLCPPCodeGenerator is updated to
utilize it.

It also updates the supported ctypes to properly generate code for
SkPoint, SkIPoint, SkIRect, and GrColor4f. The code generated for
'in uniforms' now also correctly supports conditional uniforms.


Bug: skia:
Change-Id: Ib7c0a873bdd68a966b6a00871f33102dfa2c432d
Reviewed-on: https://skia-review.googlesource.com/150129
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2018-08-31 15:19:58 +00:00
Michael Ludwig
92e4c7fded Support input color argument to process() function in sksl .fp files
--

This expands sksl's capabilities with .fp files. Previously, it was possible to declare "in fragmentProcessor foo" and emit it automatically when "process(foo);" was called. This adds a variant of process that takes a second argument, which must be a half4 expression. This argument specifies the value, or dynamic expression calculated earlier in the parent shader, to use as sk_InColor by the child.

The CL is longer than anticipated because of properly handling dependencies between previous sksl statements and the input to the child. The original writeEmitCode() collected all extra emission code (the calls to build->emitChild) and put them before any call to codeAppendf. This makes it impossible to use a parent's variable, or the output of another child, as the input for process.

To solve this, there is now a flushEmittedCode() function that takes over the logic of outputting the extra emission code and the necessary codeAppendf calls. When invoked, it (by default) only appends completed sksl statements, and places any current expression back at the beginning of the output stream. It now updates fFormatArgs and fExtraEmitCodeCode as it consumes their contents. This allows writeFunctionCall() for a call to "process" to flush all previous statements before it adds its emit child code.

Bug: skia:
Change-Id: I63c41af6f3e0620aa890d10d14436ee6244f0051
Reviewed-on: https://skia-review.googlesource.com/148395
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2018-08-30 20:51:01 +00:00
Brian Osman
c7ad40f76f Remove SK_SUPPORT_GPU checks in tool-only code
Most of this is (obviously) not necessary to do, but once
I started, I figured I'd just get it all. Tools (nanobench,
DM, skiaserve), all GMs, benches, and unit tests, plus support
code (command line parsing and config stuff).

This is almost entirely mechanical.

Bug: skia:
Change-Id: I209500f8df8c5bd43f8298ff26440d1c4d7425fb
Reviewed-on: https://skia-review.googlesource.com/131153
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2018-05-31 18:59:44 +00:00
Greg Daniel
3e8c3458f0 Make generated effects from sksl fp files not need SK_SUPPORT_GPU
Bug: skia:
Change-Id: I42a5c7fe7dc35a23290c8daa754c9fcce07f76fb
Reviewed-on: https://skia-review.googlesource.com/119010
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2018-04-06 18:27:53 +00:00