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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
--
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>
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>