diff options
-rw-r--r-- | BUILD.gn | 18 | ||||
-rw-r--r-- | DEPS | 2 | ||||
-rw-r--r-- | bench/SkXbyakBench.cpp | 79 | ||||
-rw-r--r-- | gn/bench.gni | 1 | ||||
-rw-r--r-- | public.bzl | 6 | ||||
-rw-r--r-- | src/opts/SkXbyak.cpp | 162 | ||||
-rw-r--r-- | third_party/xbyak/BUILD.gn | 13 |
7 files changed, 0 insertions, 281 deletions
@@ -23,7 +23,6 @@ declare_args() { skia_use_lua = false skia_use_mesa = false skia_use_piex = !is_win - skia_use_xbyak = false skia_use_zlib = true skia_android_serial = "" @@ -517,22 +516,6 @@ optional("webp") { ] } -optional("xbyak") { - enabled = skia_use_xbyak - public_defines = [ "SK_RASTER_PIPELINE_HAS_JIT" ] - - deps = [ - "//third_party/xbyak", - ] - - # xbyak uses exceptions, but SkXbyak catches them all. - configs_to_remove = [ "//gn:no_exceptions" ] - - sources = [ - "src/opts/SkXbyak.cpp", - ] -} - optional("xml") { enabled = skia_use_expat public_defines = [ "SK_XML" ] @@ -574,7 +557,6 @@ component("skia") { ":ssse3", ":typeface_freetype", ":webp", - ":xbyak", ":xml", ] @@ -42,8 +42,6 @@ deps = { # microhttpd for skiaserve "third_party/externals/microhttpd" : "https://android.googlesource.com/platform/external/libmicrohttpd@748945ec6f1c67b7efc934ab0808e1d32f2fb98d", - - "third_party/externals/xbyak" : "https://skia.googlesource.com/third_party/xbyak@3a99e90", } recursedeps = [ "common" ] diff --git a/bench/SkXbyakBench.cpp b/bench/SkXbyakBench.cpp deleted file mode 100644 index 98f795d9f8..0000000000 --- a/bench/SkXbyakBench.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2017 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "Benchmark.h" -#include "SkHalf.h" -#include "SkNx.h" -#include "SkRasterPipeline.h" - -static void hand_written(uint64_t* buf, int n) { - while (n --> 0) { - Sk4f rgba = SkHalfToFloat_finite_ftz(*buf); - - float a = rgba[3], - scale = a == 0 ? 1 : 1.0f/a; - rgba *= Sk4f{scale,scale,scale,1}; - - SkFloatToHalf_finite_ftz(rgba).store(buf++); - } -} - -class SkXbyakBench : public Benchmark { -public: - enum Mode { kHandWritten, kInterpreted, kJITCompiled }; - - SkXbyakBench(Mode mode) : fMode(mode) { - memset(fBuf, 0, sizeof(fBuf)); - if (mode == kInterpreted || mode == kJITCompiled) { - fPtr = &fBuf; - fP.append(SkRasterPipeline::load_f16, &fPtr); - fP.append(SkRasterPipeline::unpremul); - fP.append(SkRasterPipeline::store_f16, &fPtr); - } - - if (mode == kJITCompiled) { - fFn = fP.compile(); - } - } - bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; } - - const char* onGetName() override { - switch(fMode) { - case kHandWritten: return "SkXbyak_HandWritten"; - case kInterpreted: return "SkXbyak_Interpreted"; - case kJITCompiled: return "SkXbyak_JITCompiled"; - } - return ""; - } - - void onDraw(int loops, SkCanvas*) override { - switch (fMode) { - case kHandWritten: - while (loops --> 0) { hand_written(fBuf, N); } - break; - case kInterpreted: - while (loops --> 0) { fP.run(0,0,N); } - break; - case kJITCompiled: - while (loops --> 0) { fFn(0,0,N); } - break; - } - } - -private: - static const int N = 1024; // TODO: 1023, making the tail jagged - - SkRasterPipeline fP; - Mode fMode; - uint64_t fBuf[N]; - void* fPtr; - std::function<void(size_t, size_t, size_t)> fFn; -}; - -DEF_BENCH( return new SkXbyakBench(SkXbyakBench::kHandWritten); ) -DEF_BENCH( return new SkXbyakBench(SkXbyakBench::kInterpreted); ) -DEF_BENCH( return new SkXbyakBench(SkXbyakBench::kJITCompiled); ) diff --git a/gn/bench.gni b/gn/bench.gni index 48e88ef3bc..d6252927c9 100644 --- a/gn/bench.gni +++ b/gn/bench.gni @@ -111,7 +111,6 @@ bench_sources = [ "$_bench/SKPAnimationBench.cpp", "$_bench/SKPBench.cpp", "$_bench/SkRasterPipelineBench.cpp", - "$_bench/SkXbyakBench.cpp", "$_bench/StreamBench.cpp", "$_bench/SortBench.cpp", "$_bench/StrokeBench.cpp", diff --git a/public.bzl b/public.bzl index 1a959b2c1d..ce01b7d350 100644 --- a/public.bzl +++ b/public.bzl @@ -172,8 +172,6 @@ BASE_SRCS_UNIX = struct( "src/opts/SkBitmapProcState_opts_none.cpp", "src/opts/SkBlitMask_opts_none.cpp", "src/opts/SkBlitRow_opts_none.cpp", - # Experiment. Google3 doesn't have the library it needs. - "src/opts/SkXbyak.cpp", "src/ports/*CG*", "src/ports/*WIC*", "src/ports/*android*", @@ -218,8 +216,6 @@ BASE_SRCS_ANDROID = struct( "src/opts/*x86*", "src/opts/SkBlitMask_opts_none.cpp", "src/opts/SkBlitRow_opts_none.cpp", - # Experiment. Google3 doesn't have the library it needs. - "src/opts/SkXbyak.cpp", "src/ports/*CG*", "src/ports/*FontConfig*", "src/ports/*WIC*", @@ -271,8 +267,6 @@ BASE_SRCS_IOS = struct( "src/opts/*x86*", "src/opts/SkBlitMask_opts_arm*.cpp", "src/opts/SkBlitRow_opts_arm*.cpp", - # Experiment. Google3 doesn't have the library it needs. - "src/opts/SkXbyak.cpp", "src/ports/*CG*", "src/ports/*FontConfig*", "src/ports/*FreeType*", diff --git a/src/opts/SkXbyak.cpp b/src/opts/SkXbyak.cpp deleted file mode 100644 index 501d68752a..0000000000 --- a/src/opts/SkXbyak.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright 2016 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "SkCpu.h" -#include "SkRasterPipeline.h" -#include <memory> - -#if defined(__clang__) - #pragma clang diagnostic ignored "-Wduplicate-enum" -#endif -#define XBYAK_NO_OP_NAMES // xor(), not(), etc. -> xor_(), not_(), etc. -#include "xbyak/xbyak.h" - -namespace { - - struct Pipeline : public Xbyak::CodeGenerator { - - static std::shared_ptr<Pipeline> Create(const SkRasterPipeline::Stage* stages, int n) { - if (!SkCpu::Supports(SkCpu::HSW)) { - // TODO: other targets? - return nullptr; - } - - bool supported = true; - auto pipeline = std::make_shared<Pipeline>(stages, n, &supported); - if (supported) { - return pipeline; - } - return nullptr; - } - - Pipeline(const SkRasterPipeline::Stage* stages, int nstages, bool* supported) { - // Set up some register name aliases. - // y = rsi - auto x = rdi, n = rdx; - auto r = ymm0, g = ymm1, b = ymm2, a = ymm3, - dr = ymm4, dg = ymm5, db = ymm6, da = ymm7; - - Xbyak::Label floatOneStorage, - start; - - // TODO: set up (x+0.5,y+0.5) in (r,g) - vxorps(r,r); - vxorps(g,g); - vxorps(b,b); - vxorps(a,a); - vxorps(dr,dr); - vxorps(dg,dg); - vxorps(db,db); - vxorps(da,da); - - auto zero = ymm14, - one = ymm15; - vxorps(zero, zero); - vbroadcastss(one, ptr[rip + floatOneStorage]); - - L(start); - //trap(); - for (int i = 0; i < nstages; i++) { - switch(stages[i].stage) { - case SkRasterPipeline::load_f16: - mov(rax, (size_t)stages[i].ctx); - mov(rax, ptr[rax]); - - vmovdqu(xmm0, ptr[rax+x*8+ 0]); - vmovdqu(xmm1, ptr[rax+x*8+16]); - vmovdqu(xmm2, ptr[rax+x*8+32]); - vmovdqu(xmm3, ptr[rax+x*8+48]); - - vpunpcklwd(xmm8, xmm1, xmm0); vpunpckhwd(xmm0 , xmm1, xmm0); - vpunpcklwd(xmm1, xmm3, xmm2); vpunpckhwd(xmm2 , xmm3, xmm2); - vpunpcklwd(xmm9, xmm0, xmm8); vpunpckhwd(xmm8 , xmm0, xmm8); - vpunpcklwd(xmm3, xmm2, xmm1); vpunpckhwd(xmm10, xmm2, xmm1); - - vpunpcklqdq(xmm0, xmm3, xmm9); vcvtph2ps(ymm0, xmm0); - vpunpckhqdq(xmm1, xmm3, xmm9); vcvtph2ps(ymm1, xmm1); - vpunpcklqdq(xmm2, xmm10, xmm8); vcvtph2ps(ymm2, xmm2); - vpunpckhqdq(xmm3, xmm10, xmm8); vcvtph2ps(ymm3, xmm3); - break; - - case SkRasterPipeline::unpremul: - vcmpeqps(ymm10, zero, a); // ymm10: a == 0 - vdivps(ymm11, one, a); // ymm11: 1/a - vblendvps(ymm10, ymm10, zero, ymm11); // ymm10: (a==0) ? 0 : 1/a - vmulps(r, r, ymm10); - vmulps(g, g, ymm10); - vmulps(b, b, ymm10); - break; - - case SkRasterPipeline::store_f16: - mov(rax, (size_t)stages[i].ctx); - mov(rax, ptr[rax]); - - vcvtps2ph(xmm8 , ymm0, 4); - vcvtps2ph(xmm9 , ymm1, 4); - vcvtps2ph(xmm10, ymm2, 4); - vcvtps2ph(xmm11, ymm3, 4); - - vpunpcklwd(xmm12, xmm9 , xmm8 ); - vpunpckhwd(xmm8 , xmm9 , xmm8 ); - vpunpcklwd(xmm9 , xmm11, xmm10); - vpunpckhwd(xmm10, xmm11, xmm10); - - vpunpckldq(xmm11, xmm9 , xmm12); vmovdqu(ptr[rax+x*8+ 0], xmm11); - vpunpckhdq(xmm9 , xmm9 , xmm12); vmovdqu(ptr[rax+x*8+16], xmm9 ); - vpunpckldq(xmm9 , xmm10, xmm8 ); vmovdqu(ptr[rax+x*8+32], xmm9 ); - vpunpckhdq(xmm8 , xmm10, xmm8 ); vmovdqu(ptr[rax+x*8+48], xmm8 ); - break; - - default: - *supported = false; - return; - } - } - add(x, 8); - cmp(x, n); - jl(start); - - vzeroupper(); - ret(); - L(floatOneStorage); df(1.0f); - } - - void df(float f) { - union { float f; uint32_t x; } pun = {f}; - dd(pun.x); - } - void dp(void* p) { - union { void* p; uint64_t x; } pun = {p}; - dq(pun.x); - } - - void trap() { - dw(0x0b0f); - } - }; - -} // namespace - -std::function<void(size_t, size_t, size_t)> SkRasterPipeline::jit() const { - try { - if (auto pipeline = Pipeline::Create(fStages.data(), SkToInt(fStages.size()))) { - return [pipeline] (size_t x, size_t y, size_t n) { - auto call = pipeline->getCode<void(*)(size_t, size_t, size_t)>(); - //printf("fn addr: %p\n", (void*)call); - call(x,y,n); - }; - } -#if 0 - SkDebugf("Cannot yet JIT with xbyak:\n"); - this->dump(); -#endif - return nullptr; - } catch(...) { - SkDebugf("caught exception\n"); - return nullptr; - } -} diff --git a/third_party/xbyak/BUILD.gn b/third_party/xbyak/BUILD.gn deleted file mode 100644 index 7595c32f2c..0000000000 --- a/third_party/xbyak/BUILD.gn +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2016 Google Inc. -# -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -declare_args() { -} - -import("../third_party.gni") - -third_party("xbyak") { - public_include_dirs = [ "../externals/xbyak/" ] -} |