aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/opts/SkRasterPipeline_opts.h
Commit message (Collapse)AuthorAge
* Enable legacy premuls in SkColorSpaceXformGravatar Matt Sarett2017-02-22
| | | | | | | | | | | | | | | | | | | | | ***Will allow for simplified Android framework code, they typically want a color correct transform followed by a gamma encoded premul. ***Chrome does the same, so this will make it easier to replace their codecs. ***Will decrease code size. Both types of premuls are moved off the fast path here - one is essentially unused in production and the other is not "encouraged". ***Will actually make the common case faster: sRGB->sRGB means no color xform, just premul in SkSwizzler. BUG=skia: CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Ia4ec1d273b6f137151f951d37c0ebf975f6b9a3e Reviewed-on: https://skia-review.googlesource.com/8848 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Matt Sarett <msarett@google.com>
* Simplify more: remove SkRasterPipeline::compile().Gravatar Mike Klein2017-02-16
| | | | | | | | | | | | It's easier to work on SkJumper if everything funnels through run(). I don't anticipate huge benefit from compile() without JITing, but it's something we can always put back if we find a need. Change-Id: Id5256fd21495e8195cad1924dbad81856416d913 Reviewed-on: https://skia-review.googlesource.com/8468 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org>
* Implement SkHighContrastFilterGravatar Dominic Mazzoni2017-02-16
| | | | | | | | | | | | | | | | | This is a color filter to apply several contrast adjustments for users with low vision, including inverting the colors (in either RGB or HSL space), applying gamma correction, converting to grayscale, and increasing the contrast. BUG=skia:6235 CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Icb8f3e290932d8bcd9387fb1f39dd20767e15cf6 Reviewed-on: https://skia-review.googlesource.com/7460 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org>
* Make raster pipeline support all pixel conversionsGravatar Matt Sarett2017-02-14
| | | | | | | | | | | BUG=skia: CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Idc76999d0f5591a567b3976cb9db829c350e4be2 Reviewed-on: https://skia-review.googlesource.com/8304 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Matt Sarett <msarett@google.com>
* Pixel conversion refactors: use raster pipeline for 565 and grayGravatar Matt Sarett2017-02-09
| | | | | | | | | | | | | | | I'm trying not to do too much in one CL. But, in general, I hope to drop (non-performance important/optimized) special cases and use the pipeline. BUG=skia: CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I724d3982f1467f6232371360b860484f13b1ede8 Reviewed-on: https://skia-review.googlesource.com/8271 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Matt Sarett <msarett@google.com>
* SkRasterPipeline shader adapterGravatar Florin Malita2017-01-31
| | | | | | | | | | | | | Reland of https://skia-review.googlesource.com/c/7615. (lifted from https://skia-review.googlesource.com/c/7088/) CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I797a2f0ae80209c8637875418e08d2fa03249672 Reviewed-on: https://skia-review.googlesource.com/7731 Commit-Queue: Florin Malita <fmalita@google.com> Reviewed-by: Mike Reed <reed@google.com>
* Revert "SkRasterPipeline shader adapter"Gravatar Florin Malita2017-01-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 6d11ed2951fadc281433606a8edc6774bed39735. Build failure: https://chromium-swarm.appspot.com/task?id=3403da0cdee8c210&refresh=10 ../../../src/core/SkOpts.cpp -o obj/src/core/libskia.SkOpts.o In file included from ../../../src/core/SkOpts.cpp:46: ../../../src/opts/SkRasterPipeline_opts.h:1093:11: error: no member named 'Load4' in '(anonymous namespace)::SkNx<8, float>' SkNf::Load4(buf, &r, &g, &b, &a); ~~~~~~^ 1 error generated. Leak: https://chromium-swarm.appspot.com/task?id=3403df55fd5eaa10&refresh=10 Original change's description: > SkRasterPipeline shader adapter > > (lifted from https://skia-review.googlesource.com/c/7088/) > > R=​mtklein@google.com,herb@google.com,reed@google.com > > CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD > > Change-Id: Idddb84069423c5fc535bea0a65a5b21a4d07084d > Reviewed-on: https://skia-review.googlesource.com/7615 > Commit-Queue: Florin Malita <fmalita@chromium.org> > Reviewed-by: Mike Klein <mtklein@chromium.org> > Reviewed-by: Mike Reed <reed@google.com> > TBR=mtklein@chromium.org,mtklein@google.com,herb@google.com,fmalita@chromium.org,reed@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I68c0be3398bde93cd0842baf25b025c5fe1c3df7 Reviewed-on: https://skia-review.googlesource.com/7730 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Florin Malita <fmalita@chromium.org>
* SkRasterPipeline shader adapterGravatar Florin Malita2017-01-29
| | | | | | | | | | | | | | (lifted from https://skia-review.googlesource.com/c/7088/) R=mtklein@google.com,herb@google.com,reed@google.com CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Idddb84069423c5fc535bea0a65a5b21a4d07084d Reviewed-on: https://skia-review.googlesource.com/7615 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Reed <reed@google.com>
* Move shader register setup to SkRasterPipelineBlitter.Gravatar Mike Klein2017-01-23
| | | | | | | | | | | | | | | | | | | | | We've been seeding the initial values of our registers to x+0.5,y+0.5, 1,0, 0,0,0,0 (useful values for shaders to start with) in all pipelines. This CL changes that to do so only when blitting, and only when we have a shader. The nicest part of this change is that SkRasterPipeline itself no longer needs to have a concept of y, or what x means. It just marches x through [x,x+n), and the blitter handles y and layers the meaning of "dst x coordinate" onto x. This ought to make SkSplicer a little easier to work with too. dm --src gm --config f16 srgb 565 all draws the same. Change-Id: I69d8c1cc14a06e5dfdd6a7493364f43a18f8dec5 Reviewed-on: https://skia-review.googlesource.com/7353 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* SkRasterPipeline: implement support for SkTableColorFilterGravatar Mike Klein2017-01-23
| | | | | | | | | | | | | This adds and uses a byte_tables stage that converts to bytes, looks up in the tables, then converts back to floats. We treat this as color filter as pure math, not considering anything colorspace related: no transfer functions, no gamut to change, etc. Change-Id: If5fefc1bcef61a0fb0ae279002a0dd1547e429ea Reviewed-on: https://skia-review.googlesource.com/7413 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Replace raster pipeline nextafter() calls with SkNu nudgingGravatar Florin Malita2017-01-20
| | | | | | | | | | | | | | | | | | (courtesy of mtklein@) nanobench -m gradient_linear_clamp\$ --config f16 --ms 2000 -q Before: 753.66 After: 658.69 R=mtklein@google.com,herb@google.com CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Ie1442da340f6cfc9aef65bec1f114c0e5db89fcb Reviewed-on: https://skia-review.googlesource.com/7351 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Just clamp to limit-epsilon.Gravatar Mike Klein2017-01-20
| | | | | | | | | | | | | I think the -0.5f was an implementation detail of Herb's bilerp that we don't need here. It happened to also be clamping us to something less than limit (limit-0.5), so we do need to replace that with a little nudge to keep us on tile. Change-Id: I4ebd32e0ad38c724a17dc8bc35d9ea228eeeca32 Reviewed-on: https://skia-review.googlesource.com/7338 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Herb Derby <herb@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
* SkRasterPipeline impl for 2-stop linear gradientsGravatar Florin Malita2017-01-20
| | | | | | | | | | CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Ia2b630cf9c0826fbfc3342707c005030d0529bbc Reviewed-on: https://skia-review.googlesource.com/7186 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Herb Derby <herb@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org>
* Add F16 support to SkPNGImageEncoderGravatar Matt Sarett2017-01-19
| | | | | | | | | | | | BUG=skia: CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Ifd221365a7b9f9a4a4fc5382621e0da7189e1148 Reviewed-on: https://skia-review.googlesource.com/6526 Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
* Reland "Respect full precision for RGB16 PNGs" (part 2)Gravatar Matt Sarett2017-01-19
| | | | | | | | | | | | | | | | | | | | | This lands all the new xform hooks but no change to src/codec. So the new decode features are turned off. I'm relanding this in pieces to try to bisect a strange MSAN error. Original CL: https://skia-review.googlesource.com/c/7085/ BUG=skia: CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN,Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD,Build-Ubuntu-Clang-x86_64-Release-Fast Change-Id: I451a2a29c73ca475e9e7a5ded58d4948d6b8be19 Reviewed-on: https://skia-review.googlesource.com/7277 Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
* Revert "Respect full precision for RGB16 PNGs"Gravatar Matt Sarett2017-01-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 7a090c403da1dad6a2e19f2011158bd894a62d91. Reason for revert: <INSERT REASONING HERE> Original change's description: > Respect full precision for RGB16 PNGs > > BUG=skia: > > CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD > > Change-Id: If58d201daae97bce2f8efbc453c2ec452e682493 > Reviewed-on: https://skia-review.googlesource.com/7085 > Commit-Queue: Matt Sarett <msarett@google.com> > Reviewed-by: Mike Klein <mtklein@chromium.org> > Reviewed-by: Leon Scroggins <scroggo@google.com> > Reviewed-by: Mike Reed <reed@google.com> > TBR=mtklein@chromium.org,mtklein@google.com,msarett@google.com,scroggo@google.com,reed@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Ibd9879bc4f65ca0c2457dd0bfb5eb008d9a8f672 Reviewed-on: https://skia-review.googlesource.com/7183 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Matt Sarett <msarett@google.com>
* Respect full precision for RGB16 PNGsGravatar Matt Sarett2017-01-18
| | | | | | | | | | | | | BUG=skia: CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: If58d201daae97bce2f8efbc453c2ec452e682493 Reviewed-on: https://skia-review.googlesource.com/7085 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Mike Reed <reed@google.com>
* Fix out of bounds read in RP::load_tables_u16_be()Gravatar Matt Sarett2017-01-13
| | | | | | | | | | | BUG=skia: CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I4f6dd002b03812d63bf62342c346ea21f6865466 Reviewed-on: https://skia-review.googlesource.com/7027 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Matt Sarett <msarett@google.com>
* Attempt 3: SkRasterPipelineBlitter: support A8Gravatar Mike Klein2017-01-13
| | | | | | | | | | | Now that SkOpts_hsw.cpp no longer hooks in SkRasterPipeline_opts, it should be safe to try this again. This reverts commit 86d55b312a2649d80890ccf75f24571ada0265f1. Change-Id: I2d495600ca9d3a0f49c2e02fbaaae349cefac3a1 Reviewed-on: https://skia-review.googlesource.com/6985 Reviewed-by: Mike Klein <mtklein@chromium.org>
* Use RasterPipeline to support full precision on 16-bit RGBA pngsGravatar Matt Sarett2017-01-13
| | | | | | | | | | | | Reland of Original Change: https://skia-review.googlesource.com/6260 CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I809984dd9af225103bfbe83492a17c19da7c5e40 Reviewed-on: https://skia-review.googlesource.com/6980 Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
* Revert "Use RasterPipeline to support full precision on 16-bit RGBA pngs"Gravatar Matt Sarett2017-01-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit bb2339da39ab3ee59121acd911920dafcd4a2f72. Reason for revert: Breaks MSAN Original change's description: > Use RasterPipeline to support full precision on 16-bit RGBA pngs > > TODO: Support more precision on 16-bit RGB pngs > > BUG=skia: > > CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD > > Change-Id: I89dfef3b4887b9c4895c17309933883ab90ffa4d > Reviewed-on: https://skia-review.googlesource.com/6260 > Reviewed-by: Mike Reed <reed@google.com> > Reviewed-by: Leon Scroggins <scroggo@google.com> > Reviewed-by: Mike Klein <mtklein@chromium.org> > Commit-Queue: Matt Sarett <msarett@google.com> > TBR=mtklein@chromium.org,mtklein@google.com,msarett@google.com,scroggo@google.com,reed@google.com,reviews@skia.org BUG=skia: NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I47579c20af033a75883e2b35567cb9c690ce54b0 Reviewed-on: https://skia-review.googlesource.com/6975 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Matt Sarett <msarett@google.com>
* Use RasterPipeline to support full precision on 16-bit RGBA pngsGravatar Matt Sarett2017-01-12
| | | | | | | | | | | | | | | TODO: Support more precision on 16-bit RGB pngs BUG=skia: CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I89dfef3b4887b9c4895c17309933883ab90ffa4d Reviewed-on: https://skia-review.googlesource.com/6260 Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Matt Sarett <msarett@google.com>
* Revert "Retry "SkRasterPipelineBlitter: support A8"..."Gravatar Mike Klein2017-01-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit f55ea6a1deb21120944d406124a2984b5009260a. Reason for revert: crbug.com/679147 Original change's description: > Retry "SkRasterPipelineBlitter: support A8"... > > ...preferring SkA8_Coverage_Blitter over SkRasterPipelineBlitter. > > I think we could make this work with SkRasterPipelineBlitter (tell it, draw white in Src mode with this mask), but the existing blitter is pretty hard to beat in efficiency and correctness. > > CQ_INCLUDE_TRYBOTS=skia.primary:Perf-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN,Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD > > > Change-Id: I72df9995c63f3334d8111c59711818cb5ed1e63c > Reviewed-on: https://skia-review.googlesource.com/6627 > Reviewed-by: Mike Klein <mtklein@chromium.org> > Commit-Queue: Mike Klein <mtklein@chromium.org> > TBR=mtklein@chromium.org,brianosman@google.com,reed@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I6a36b4c087a52e54f4d591ded40e6a202fb77068 Reviewed-on: https://skia-review.googlesource.com/6760 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org>
* Retry "SkRasterPipelineBlitter: support A8"...Gravatar Mike Klein2017-01-06
| | | | | | | | | | | | | | ...preferring SkA8_Coverage_Blitter over SkRasterPipelineBlitter. I think we could make this work with SkRasterPipelineBlitter (tell it, draw white in Src mode with this mask), but the existing blitter is pretty hard to beat in efficiency and correctness. CQ_INCLUDE_TRYBOTS=skia.primary:Perf-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN,Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I72df9995c63f3334d8111c59711818cb5ed1e63c Reviewed-on: https://skia-review.googlesource.com/6627 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
* simplify by removing _d stagesGravatar Mike Klein2017-01-06
| | | | | | | | | CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I75e232faee6ad48f65bac5b119a461280b27bbc8 Reviewed-on: https://skia-review.googlesource.com/6661 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Use stack instead of malloc() for most calls to SkRasterPipeline::run().Gravatar Mike Klein2017-01-05
| | | | | | | | | | | | | Also split bench into run/compile variants to measure the effect: Before …f16_compile 1x …f16_run 1.02x …srgb_compile 1.56x …srgb_run 1.61x After …f16_run 1x …f16_compile 1.01x …srgb_compile 1.58x …srgb_run 1.59x CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I8e65fb2acdbb05ccc0b3894f16d7646603c3e74d Reviewed-on: https://skia-review.googlesource.com/6621 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Revert "SkRasterPipelineBlitter: support A8"Gravatar Mike Klein2017-01-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit f44373c119290b501d4aec7385e16d12c28a1f0f. Reason for revert: MSAN Original change's description: > SkRasterPipelineBlitter: support A8 > > This adds support for loading and storing A8, then uses it in SkRasterPipelineBlitter. > > I think this handles all dst formats now: A8, 565, 8888 (by policy, sRGB only) and F16. > > CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel;skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD > > > Change-Id: Id207f6e6c56b6bfcc301d77dd23e0959bb7afba8 > Reviewed-on: https://skia-review.googlesource.com/6554 > Reviewed-by: Mike Reed <reed@google.com> > Commit-Queue: Mike Klein <mtklein@chromium.org> > TBR=mtklein@chromium.org,reed@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I9ead3c3335e1776e9a1639ca0481253821505d67 Reviewed-on: https://skia-review.googlesource.com/6625 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org>
* SkRasterPipelineBlitter: support A8Gravatar Mike Klein2017-01-05
| | | | | | | | | | | | | | This adds support for loading and storing A8, then uses it in SkRasterPipelineBlitter. I think this handles all dst formats now: A8, 565, 8888 (by policy, sRGB only) and F16. CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel;skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Id207f6e6c56b6bfcc301d77dd23e0959bb7afba8 Reviewed-on: https://skia-review.googlesource.com/6554 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Retry trim another instruction off SkRasterPipeline overheadGravatar Mike Klein2017-01-04
| | | | | | | | | | | | | | | | | | | This time, with manual program memory management instead of std::vector<void*>. Using STL types from SkOpts_hsw.cpp is not safe. Things like std::vector<void*> are inlined but not anonymous, so they're deduped by the linker arbitrarily. This is bad when we pick the version compiled with AVX instructions on a machine that doesn't support AVX... std::vector<Stage> was safe before because Stage itself was anonymous. While not anonymous, std::vector<Stage> is unique to the compilation unit, because you can only refer to the anonymous Stage in the compilation unit. CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_chromium_asan_rel_ng;skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I015e27583b6b6ff06b5e9f63e3f40ee6b27d6dbd Reviewed-on: https://skia-review.googlesource.com/6550 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
* auto-generate _d stagesGravatar Mike Klein2017-01-04
| | | | | | | | | | | | Stage foo_d should always be the same logic as stage foo swapping r and dr, g and dg, b and db, a and da. This means we can infer their definitions. CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Ia0a3abb29a201c647d9ec1860211abfbc19b56ae Reviewed-on: https://skia-review.googlesource.com/6555 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Revert "trim another instruction off SkRasterPipeline overhead"Gravatar Mike Klein2017-01-04
| | | | | | | | | | | This reverts commit e61c40707e70a2be9e32227a929173864f7895e1. Reason for revert: this and the ODR caused operations on ContiguousContainerBase::elements_, another std::vector<void*> in Chrome, to start using AVX2 instructions. Boy this is annoying... Change-Id: I2c4837ad70fdef8096db904022b0703b88c6fd6c Reviewed-on: https://skia-review.googlesource.com/6549 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org>
* trim another instruction off SkRasterPipeline overheadGravatar Mike Klein2017-01-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The overhead of a stage today is 3 x86 instructions, typically looking something like this: - movq (%rdi), %rax // Load the next stage function pointer. - addq $0x10, %rdi // Step our progress ahead 16 bytes to that next stage. - jmpq *%rax // Transfer control to that stage. But if we make sure the pointer's in esi/rsi, we can use lodsd/lodsq to do those first two steps in one instruction: - lodsq (%rsi), %rax (≈ movq (%rdi), %rax; addq $0x8, %rsi). - jmpq *%rax This CL rearranges things so that we can take advantage of this and generally trim off an instruction of overhead. Instead of a vector of {Fn, ctx} pairs, we'll flatten it down into a single interlaced program vector of void*, basically just ommitting any null context pointers. We pass the pointer to program as the second argument to Fn, putting it in rsi. These two changes together make getting the next Fn to call or the current context the same cheap lodsq instruction, encapsulated as load_and_increment(). Here's how the simple "modulate" blend stage changes: vmulps %ymm4, %ymm0, %ymm0 vmulps %ymm5, %ymm1, %ymm1 vmulps %ymm6, %ymm2, %ymm2 vmulps %ymm7, %ymm3, %ymm3 movq (%rdi), %rax addq $0x10, %rdi jmpq *%rax ~~~~~~~~> vmulps %ymm4, %ymm0, %ymm0 vmulps %ymm5, %ymm1, %ymm1 vmulps %ymm6, %ymm2, %ymm2 vmulps %ymm7, %ymm3, %ymm3 lodsq (%rsi), %rax jmpq *%rax This does make getting the current context a one-time, destructive operation. It's switched from referring to ctx as a void* directly to using ctx() as a thunk that returns a void*. No stage so far has ever referred to ctx twice, and it all appears to inline, so this seems harmless. "matrix_2x3" is a good example of what stages that use context pointers end up looking like: lodsq (%rsi), %rax vbroadcastss (%rax), %ymm9 vbroadcastss 0x8(%rax), %ymm10 vbroadcastss 0x10(%rax), %ymm8 vfmadd231ps %ymm10, %ymm1, %ymm8 vfmadd231ps %ymm9, %ymm0, %ymm8 vbroadcastss 0x4(%rax), %ymm10 vbroadcastss 0xc(%rax), %ymm11 vbroadcastss 0x14(%rax), %ymm9 vfmadd231ps %ymm11, %ymm1, %ymm9 vfmadd231ps %ymm10, %ymm0, %ymm9 lodsq (%rsi), %rax vmovaps %ymm8, %ymm0 vmovaps %ymm9, %ymm1 jmpq *%rax We can't do this with MSVC, as there's no intrinsic for it I can find, and they disallow inline assembly, and rsi is not used to pass arguments to functions there anyway. ARM doesn't need it... it does this in two instructions naturally anyway. We could do this for 32-bit x86 but I'd just rather focus on x86-64. It's unclear to me that this makes things any faster, but doesn't appear to make things any slower, and makes I think both the code and disassembly simpler. CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Ia7b543a6718c75a33095371924003c5402b3445a Reviewed-on: https://skia-review.googlesource.com/6271 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Fix swapped interpretation of c and e in SkColorSpace_ICCGravatar Matt Sarett2016-12-19
| | | | | | | | | | | | | | | | The ICC errata supports the opposite of what we do. http://www.color.org/icc_specs2.xalter TBR=reed@google.com BUG=skia: CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I18ace7f312926b264e624c30d8cb983eff5c434b Reviewed-on: https://skia-review.googlesource.com/6277 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
* Added optimized sRGB/2.2 gamma stages into A2B color xformGravatar raftias2016-12-15
| | | | | | | | | | | | | | | | Hooked up existing to/from srgb, and to_2dot2 stages into SkColorSpaceXform_A2B. Added a from_2dot2 stage to the raster pipeline to complete the other direction. BUG=skia: CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I3887af3f59f67329d7e843e7355ff54e22cc4ed0 Reviewed-on: https://skia-review.googlesource.com/5840 Commit-Queue: Robert Aftias <raftias@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Matt Sarett <msarett@google.com>
* Revert "Revert "clamp to premul when reading premul sRGB""Gravatar Mike Klein2016-12-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 2e018f548d76b0688f9873c683cffc681fec40ec. Reason for revert: doesn't appear to have been the roll problem. Original change's description: > Revert "clamp to premul when reading premul sRGB" > > This reverts commit 04e10da8362a0dcabd795a4ad53f617719ca0d20. > > Reason for revert: roll? > > Change-Id: Id0a8dcd62763bd6eddde120c513ca97e098a4268 > Reviewed-on: https://skia-review.googlesource.com/6022 > Commit-Queue: Mike Klein <mtklein@chromium.org> > Reviewed-by: Mike Klein <mtklein@chromium.org> > TBR=mtklein@chromium.org,reviews@skia.org,brianosman@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I399ca5e728ce6766c6707682c4c6b685681ffdeb Reviewed-on: https://skia-review.googlesource.com/6025 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org>
* Revert "clamp to premul when reading premul sRGB"Gravatar Mike Klein2016-12-14
| | | | | | | | | | | This reverts commit 04e10da8362a0dcabd795a4ad53f617719ca0d20. Reason for revert: roll? Change-Id: Id0a8dcd62763bd6eddde120c513ca97e098a4268 Reviewed-on: https://skia-review.googlesource.com/6022 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org>
* clamp to premul when reading premul sRGBGravatar Mike Klein2016-12-13
| | | | | | | | | | | | | | | It's pretty easy to start with sound premultiplied linear floats, pack those to sRGB encoded bytes, then read them back to linear floats and find them not quite premultiplied, with a color channel just a smidge greater than the alpha channel. This can happen basically any time we have different transfer functions for alpha and colors... sRGB being the only one we draw into. This is an annoying problem with no known good solution. So apply the clamp hammer. These new calls on SkRasterPipeline should make it impossible to get wrong. CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I4c974f4a7b151f3f684946f1e83d06b1b288fd01 Reviewed-on: https://skia-review.googlesource.com/5945 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* funnel f16 through standard load/store/gatherGravatar Mike Klein2016-12-12
| | | | | | | | | | | | | This is a precursor to using mask load, mask store, and gather instructions for f16. This is a slight performance win too, through slightly simpler code generation. Having done this, it now makes sense to give a name to f16->f32 conversion, from_f16(). Finally, while we're at this, also send store_f32 through store(), so that now all formats use load, gather, and store uniformly. CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I403f16f712936e2bcf3294e72c863cb6c6fbcf0c Reviewed-on: https://skia-review.googlesource.com/5731 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Convert image width and height (used by tiling) to float once.Gravatar Mike Klein2016-12-12
| | | | | | | | | | | The storage cost is the same, so might as well do this when building the pipeline instead of when running it. This also avoids the awkward cvtsi2ss instruction that screws with register renaming. CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I1c7d5bad558870256a31e3da969eee5d80fb93a8 Reviewed-on: https://skia-review.googlesource.com/5782 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* bicubic, attempt gazillionGravatar Mike Klein2016-12-09
| | | | | | | | | | | | | - explicitly separate bilinear_ stages in x and y too BUG=skia: CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Ib7b4f9d26ea6abe9171068e92424479d811ee606 Reviewed-on: https://skia-review.googlesource.com/5636 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Added clamps in SkRasterPipeline's gamma stages.Gravatar raftias2016-12-08
| | | | | | | | | | | | | | Clamping stages were also removed from SkColorSpace_A2B as they are now not needed. BUG=skia: CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I24e2e411e12b463854e980cb10c0e6bafb4a7c42 Reviewed-on: https://skia-review.googlesource.com/5546 Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Robert Aftias <raftias@google.com>
* Refactor bilerp a little.Gravatar Mike Klein2016-12-06
| | | | | | | | | | | | | | | | | | | 1) rename to bilerp_xy, for x,y in {n[egative], p[ositive}; 2) pull out a save_xy stage to save off the original x,y; 3) also calculate the fractional x,y fx,fy once instead of 4 times. 1) is a pure refactor; 2) adds a stage but otherwise is nothing different; 3) changes images a little bit (fractional parts can vary a bit around powers of two). This extends naturally to naive bicubic using 16 bicubic_xy stages. CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I666de5c21e978abb4feb6e3225e5b5920ba6c5b9 Reviewed-on: https://skia-review.googlesource.com/5550 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Herb Derby <herb@google.com>
* remove upper limit on number of pipeline stagesGravatar Mike Klein2016-12-06
| | | | | | | | | | | Bicubic is going to blow right past 48. At this point the fixed preallocation strategy is starting to look naive... at 64 we'd allocate just over 1K for every pipeline (and every compiled pipeline). CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Ib2944ead1217123aba2b6347fd9d5315217540c9 Reviewed-on: https://skia-review.googlesource.com/5551 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Manual byte -> float conversion.Gravatar Mike Klein2016-12-05
| | | | | | | | | | | | | | | | | | | This is a follow-up to reviews.skia.org/5540, which did float -> byte. We use the same trick here exploiting 32768.0f / 0x47000000. The benefit here is smaller than the other CL, but still measurable. The exchange here is: before: int->float, multiply after: OR, FMA The cost of an FMA is the same as a multiply, so we're basically just replacing int->float conversion with a bitwise OR. CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Ieac2247664afa3ff415aec2b48c21505905bee23 Reviewed-on: https://skia-review.googlesource.com/5542 Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Tricky float -> byte conversion in store_8888.Gravatar Mike Klein2016-12-02
| | | | | | | | | | | | | | | | | | | | | In IEEE, for each byte BB, the float 0x470000BB equals 32768.0f + BB*(1/256.0f). So to turn a [0,1] float into a byte, we can - multiply by (255/256.0f) to get into [0,255/256.0f] range, - add 32768.0f to get into [32768.0f, 32768.0f + 255/256.0f] range, - look at the low byte. Those first two of course are an FMA. Using this trick here makes store_8888 measurably faster. Instead of a FMA then float->int trunc, we do an FMA then a bitwise AND. Overall the math goes from 4 FMA + 4 trunc + 3 shift to 4 FMA + 3 AND + 3 shift (we can skip the shift for red and the AND for alpha). As you might guess, AND is cheaper than trunc, so this is a net win. I should be able to follow up with the same trick in reverse in from_8888(). CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I42c8f4a6ea0b6c22160517cf5f9c048f01c9a330 Reviewed-on: https://skia-review.googlesource.com/5540 Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* SkNf_round, use it in store_565 and store_tables.Gravatar Mike Klein2016-12-02
| | | | | | | | | This gives us a place to bottleneck this sort of conversion. Every time I try to use the rounding float -> int instructions, they're just a little slower than working the 1/2 into the scale with FMA. Weird. Change-Id: I7718112b234b4b38ba6af8fef59a47642021839a Reviewed-on: https://skia-review.googlesource.com/5483 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Matt Sarett <msarett@google.com>
* use fma in store_8888Gravatar Mike Klein2016-12-02
| | | | | | | | | | | | | I think we just happened not to here. This improves Adobe -> sRGB pipeline conversion by about 3-4%. While at it, unify all the fma() lambdas into SkNf_fma(). I'd have called it fma(), but IIRC there was some sort of name conflict there with type-generic fma() functions from the C math.h or something silly like that. CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Id176671fec27c984efa4703c5be2fb63b7f0b11f Reviewed-on: https://skia-review.googlesource.com/5474 Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* SkColorSpaceXform bug fixes attempt 2Gravatar Matt Sarett2016-12-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (1) Clamping If we're going to clamp (8888 outputs), we need to clamp properly to alpha (not 1) when we premultiply. This fix is made in SkColorSpaceXform_XYZ. An alternative fix would move all clamping out of the store functions, to before the gamma encoding. This generally makes sense, but the "to 2.2 conversion" may introduce NaNs and always needs a clamp. So another fix is to just have an extra clamp in the store 2.2 function. Since we have two pipelines, let's try this one in SkColorSpaceXform_Pipeline :). (2) Correctly handle the memcpy() case. This is not changed from a previous (reverted) CL. Looks like this only ever worked for RGBA inputs, never got updated when we added BGRA inputs. This probably flew under the radar because the clients are smart enough to avoid performing a color xform altogether when the color spaces match. BUG=skia: CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I0b59239d2488ce9fdbe11efbd96567e420bb9813 Reviewed-on: https://skia-review.googlesource.com/5464 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org>
* Reland "Add RasterPipeline implementation for SkColorSpaceXform"Gravatar Matt Sarett2016-12-01
| | | | | | | | | | | | | | | | | | | This is initially turned on for Linux debug builds, which allows us to start testing. Chrome for Android is a really good candidate for this (will appreciate the code size savings), but I'd first like to run some tests to understand the performance/size tradeoffs a little better. BUG:660416 CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Ifc80e663767df6bb767abb8b12b1ec5cec644ec5 Reviewed-on: https://skia-review.googlesource.com/5452 Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
* Avoid creating std::function in run_pipeline().Gravatar Mike Klein2016-12-01
| | | | | | | | | | | | | | | | | This avoids a malloc/free per SkRasterPipeline::run(), with no downside. $ out/nanobench --benchType skcolorcodec --colorImages images/colorspace/201293.jpg --skps noskps --xform_only --srgb --ms 10000 target: 273µs current: 395µs this CL: 375µs CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Icd62f505f555ebf4ca66ee77a476f59cab68433d Reviewed-on: https://skia-review.googlesource.com/5447 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Matt Sarett <msarett@google.com>