Some lowp refactoring

1) Move a couple stages around in the enum to places
     that make more sense, and guass_a_to_rbga in the code too.

  2) mirror the SkRasterPipeline stage enum with either:
     LOWP(st): the stage is implemented in low precision
     TODO(st): the stage should be lowp, but isn't
     NOPE(st): the stage shouldn't be done in lowp.

  3) statically enforce that all stages are covered by one of
     LOWP, TODO, or NOPE.

Change-Id: I06c7a7e470663ef73bf652c1b65c0d3c89f0d767
Reviewed-on: https://skia-review.googlesource.com/63800
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
Mike Klein 2017-10-25 12:38:25 -04:00 committed by Skia Commit-Bot
parent 5c19631c77
commit 3cbcb73845
5 changed files with 1582 additions and 1552 deletions

View File

@ -36,62 +36,63 @@ struct SkJumper_Engine;
* If you'd like to see how this works internally, you want to start digging around src/jumper.
*/
#define SK_RASTER_PIPELINE_STAGES(M) \
M(callback) \
M(move_src_dst) M(move_dst_src) \
M(clamp_0) M(clamp_1) M(clamp_a) M(clamp_a_dst) \
M(unpremul) M(premul) M(premul_dst) \
M(set_rgb) M(swap_rb) M(invert) \
M(from_srgb) M(from_srgb_dst) M(to_srgb) \
M(black_color) M(white_color) M(uniform_color) \
M(seed_shader) M(dither) \
M(load_a8) M(load_a8_dst) M(store_a8) M(gather_a8) \
M(load_g8) M(load_g8_dst) M(gather_g8) \
M(load_565) M(load_565_dst) M(store_565) M(gather_565) \
M(load_4444) M(load_4444_dst) M(store_4444) M(gather_4444) \
M(load_f16) M(load_f16_dst) M(store_f16) M(gather_f16) \
M(load_f32) M(load_f32_dst) M(store_f32) \
M(load_8888) M(load_8888_dst) M(store_8888) M(gather_8888) \
M(load_bgra) M(load_bgra_dst) M(store_bgra) M(gather_bgra) \
M(load_u16_be) M(load_rgb_u16_be) M(store_u16_be) \
M(load_tables_u16_be) M(load_tables_rgb_u16_be) \
M(load_tables) M(load_rgba) M(store_rgba) \
M(scale_u8) M(scale_565) M(scale_1_float) \
M( lerp_u8) M( lerp_565) M( lerp_1_float) \
M(dstatop) M(dstin) M(dstout) M(dstover) \
M(srcatop) M(srcin) M(srcout) M(srcover) \
M(clear) M(modulate) M(multiply) M(plus_) M(screen) M(xor_) \
M(colorburn) M(colordodge) M(darken) M(difference) \
M(exclusion) M(hardlight) M(lighten) M(overlay) M(softlight) \
M(hue) M(saturation) M(color) M(luminosity) \
M(srcover_rgba_8888) M(srcover_bgra_8888) \
M(luminance_to_alpha) \
M(matrix_translate) M(matrix_scale_translate) \
M(matrix_2x3) M(matrix_3x4) M(matrix_4x5) M(matrix_4x3) \
M(matrix_perspective) \
M(parametric_r) M(parametric_g) M(parametric_b) \
M(parametric_a) M(gamma) \
M(table_r) M(table_g) M(table_b) M(table_a) \
M(lab_to_xyz) \
M(mirror_x) M(repeat_x) \
M(mirror_y) M(repeat_y) \
M(clamp_x_1) M(mirror_x_1) M(repeat_x_1) \
M(bilinear_nx) M(bilinear_px) M(bilinear_ny) M(bilinear_py) \
M(bicubic_n3x) M(bicubic_n1x) M(bicubic_p1x) M(bicubic_p3x) \
M(bicubic_n3y) M(bicubic_n1y) M(bicubic_p1y) M(bicubic_p3y) \
M(save_xy) M(accumulate) \
M(evenly_spaced_gradient) \
M(gauss_a_to_rgba) M(gradient) \
M(evenly_spaced_2_stop_gradient) \
M(xy_to_unit_angle) \
M(xy_to_radius) \
M(xy_to_2pt_conical_quadratic_min) \
M(xy_to_2pt_conical_quadratic_max) \
M(xy_to_2pt_conical_linear) \
M(mask_2pt_conical_degenerates) M(apply_vector_mask) \
M(byte_tables) M(byte_tables_rgb) \
M(rgb_to_hsl) M(hsl_to_rgb) \
M(clut_3D) M(clut_4D)
#define SK_RASTER_PIPELINE_STAGES(M) \
M(callback) \
M(move_src_dst) M(move_dst_src) \
M(clamp_0) M(clamp_1) M(clamp_a) M(clamp_a_dst) \
M(unpremul) M(premul) M(premul_dst) \
M(set_rgb) M(swap_rb) M(invert) \
M(from_srgb) M(from_srgb_dst) M(to_srgb) \
M(black_color) M(white_color) M(uniform_color) \
M(seed_shader) M(dither) \
M(load_a8) M(load_a8_dst) M(store_a8) M(gather_a8) \
M(load_g8) M(load_g8_dst) M(gather_g8) \
M(load_565) M(load_565_dst) M(store_565) M(gather_565) \
M(load_4444) M(load_4444_dst) M(store_4444) M(gather_4444) \
M(load_f16) M(load_f16_dst) M(store_f16) M(gather_f16) \
M(load_f32) M(load_f32_dst) M(store_f32) \
M(load_8888) M(load_8888_dst) M(store_8888) M(gather_8888) \
M(load_bgra) M(load_bgra_dst) M(store_bgra) M(gather_bgra) \
M(load_u16_be) M(load_rgb_u16_be) M(store_u16_be) \
M(load_tables_u16_be) M(load_tables_rgb_u16_be) M(load_tables) \
M(load_rgba) M(store_rgba) \
M(scale_u8) M(scale_565) M(scale_1_float) \
M( lerp_u8) M( lerp_565) M( lerp_1_float) \
M(dstatop) M(dstin) M(dstout) M(dstover) \
M(srcatop) M(srcin) M(srcout) M(srcover) \
M(clear) M(modulate) M(multiply) M(plus_) M(screen) M(xor_) \
M(colorburn) M(colordodge) M(darken) M(difference) \
M(exclusion) M(hardlight) M(lighten) M(overlay) M(softlight) \
M(hue) M(saturation) M(color) M(luminosity) \
M(srcover_rgba_8888) M(srcover_bgra_8888) \
M(luminance_to_alpha) \
M(matrix_translate) M(matrix_scale_translate) \
M(matrix_2x3) M(matrix_3x4) M(matrix_4x5) M(matrix_4x3) \
M(matrix_perspective) \
M(parametric_r) M(parametric_g) M(parametric_b) \
M(parametric_a) M(gamma) \
M(table_r) M(table_g) M(table_b) M(table_a) \
M(lab_to_xyz) \
M(mirror_x) M(repeat_x) \
M(mirror_y) M(repeat_y) \
M(clamp_x_1) M(mirror_x_1) M(repeat_x_1) \
M(bilinear_nx) M(bilinear_px) M(bilinear_ny) M(bilinear_py) \
M(bicubic_n3x) M(bicubic_n1x) M(bicubic_p1x) M(bicubic_p3x) \
M(bicubic_n3y) M(bicubic_n1y) M(bicubic_p1y) M(bicubic_p3y) \
M(save_xy) M(accumulate) \
M(evenly_spaced_gradient) \
M(gradient) \
M(evenly_spaced_2_stop_gradient) \
M(xy_to_unit_angle) \
M(xy_to_radius) \
M(xy_to_2pt_conical_quadratic_min) \
M(xy_to_2pt_conical_quadratic_max) \
M(xy_to_2pt_conical_linear) \
M(mask_2pt_conical_degenerates) M(apply_vector_mask) \
M(byte_tables) M(byte_tables_rgb) \
M(rgb_to_hsl) M(hsl_to_rgb) \
M(clut_3D) M(clut_4D) \
M(gauss_a_to_rgba)
class SkRasterPipeline {
public:

View File

@ -148,13 +148,13 @@ extern "C" {
#if SK_JUMPER_USE_ASSEMBLY
#if defined(__x86_64__) || defined(_M_X64)
template <SkRasterPipeline::StockStage st>
static constexpr StageFn* hsw_lowp() { return nullptr; }
static constexpr StageFn* hsw_lowp();
template <SkRasterPipeline::StockStage st>
static constexpr StageFn* sse41_lowp() { return nullptr; }
static constexpr StageFn* sse41_lowp();
template <SkRasterPipeline::StockStage st>
static constexpr StageFn* sse2_lowp() { return nullptr; }
static constexpr StageFn* sse2_lowp();
#define LOWP(st) \
template <> constexpr StageFn* hsw_lowp<SkRasterPipeline::st>() { \
@ -166,72 +166,111 @@ extern "C" {
template <> constexpr StageFn* sse2_lowp<SkRasterPipeline::st>() { \
return ASM(st,sse2_lowp); \
}
#define NOPE(st) \
template <> constexpr StageFn* hsw_lowp<SkRasterPipeline::st>() { \
return nullptr; \
} \
template <> constexpr StageFn* sse41_lowp<SkRasterPipeline::st>() { \
return nullptr; \
} \
template <> constexpr StageFn* sse2_lowp<SkRasterPipeline::st>() { \
return nullptr; \
}
#elif defined(__i386__) || defined(_M_IX86)
template <SkRasterPipeline::StockStage st>
static constexpr StageFn* sse2_lowp() { return nullptr; }
static constexpr StageFn* sse2_lowp();
#define LOWP(st) \
template <> constexpr StageFn* sse2_lowp<SkRasterPipeline::st>() { \
return ASM(st,sse2_lowp); \
}
#define NOPE(st) \
template <> constexpr StageFn* sse2_lowp<SkRasterPipeline::st>() { \
return nullptr; \
}
#elif defined(JUMPER_NEON_HAS_LOWP)
template <SkRasterPipeline::StockStage st>
static constexpr StageFn* neon_lowp() { return nullptr; }
static constexpr StageFn* neon_lowp();
#define LOWP(st) \
template <> constexpr StageFn* neon_lowp<SkRasterPipeline::st>() { \
return sk_##st##_lowp; \
}
#define NOPE(st) \
template <> constexpr StageFn* neon_lowp<SkRasterPipeline::st>() { \
return nullptr; \
}
#else
#define LOWP(st)
#define NOPE(st)
#endif
#define TODO(st) NOPE(st) // stages that should be implemented in lowp, but aren't.
NOPE(callback)
LOWP(move_src_dst) LOWP(move_dst_src)
NOPE(clamp_0) NOPE(clamp_1) TODO(clamp_a) TODO(clamp_a_dst)
NOPE(unpremul) LOWP(premul) TODO(premul_dst)
LOWP(set_rgb) LOWP(swap_rb) LOWP(invert)
NOPE(from_srgb) NOPE(from_srgb_dst) NOPE(to_srgb)
LOWP(black_color) LOWP(white_color) LOWP(uniform_color)
LOWP(set_rgb)
LOWP(premul)
LOWP(luminance_to_alpha)
LOWP(load_8888) LOWP(load_8888_dst) LOWP(store_8888)
LOWP(load_bgra) LOWP(load_bgra_dst) LOWP(store_bgra)
LOWP(load_a8) LOWP(load_a8_dst) LOWP(store_a8)
LOWP(load_g8) LOWP(load_g8_dst)
LOWP(load_565) LOWP(load_565_dst) LOWP(store_565)
LOWP(swap_rb)
LOWP(seed_shader) TODO(dither)
LOWP(load_a8) LOWP(load_a8_dst) LOWP(store_a8) LOWP(gather_a8)
LOWP(load_g8) LOWP(load_g8_dst) LOWP(gather_g8)
LOWP(load_565) LOWP(load_565_dst) LOWP(store_565) LOWP(gather_565)
TODO(load_4444) TODO(load_4444_dst) TODO(store_4444) TODO(gather_4444)
NOPE(load_f16) NOPE(load_f16_dst) NOPE(store_f16) NOPE(gather_f16)
NOPE(load_f32) NOPE(load_f32_dst) NOPE(store_f32)
LOWP(load_8888) LOWP(load_8888_dst) LOWP(store_8888) LOWP(gather_8888)
LOWP(load_bgra) LOWP(load_bgra_dst) LOWP(store_bgra) LOWP(gather_bgra)
TODO(load_u16_be) TODO(load_rgb_u16_be) TODO(store_u16_be)
NOPE(load_tables_u16_be) NOPE(load_tables_rgb_u16_be) NOPE(load_tables)
NOPE(load_rgba) NOPE(store_rgba)
LOWP(scale_u8) LOWP(scale_565) LOWP(scale_1_float)
LOWP( lerp_u8) LOWP( lerp_565) LOWP( lerp_1_float)
LOWP(dstatop) LOWP(dstin) LOWP(dstout) LOWP(dstover)
LOWP(srcatop) LOWP(srcin) LOWP(srcout) LOWP(srcover)
LOWP(clear) LOWP(modulate) LOWP(multiply) LOWP(plus_) LOWP(screen) LOWP(xor_)
NOPE(colorburn) NOPE(colordodge) LOWP(darken) LOWP(difference)
LOWP(exclusion) LOWP(hardlight) LOWP(lighten) LOWP(overlay) NOPE(softlight)
NOPE(hue) NOPE(saturation) NOPE(color) NOPE(luminosity)
LOWP(srcover_rgba_8888) LOWP(srcover_bgra_8888)
LOWP(lerp_1_float)
LOWP(lerp_u8)
LOWP(lerp_565)
LOWP(scale_1_float)
LOWP(scale_u8)
LOWP(scale_565)
LOWP(move_src_dst)
LOWP(move_dst_src)
LOWP(clear)
LOWP(srcatop)
LOWP(dstatop)
LOWP(srcin)
LOWP(dstin)
LOWP(srcout)
LOWP(dstout)
LOWP(srcover)
LOWP(dstover)
LOWP(modulate)
LOWP(multiply)
LOWP(screen)
LOWP(xor_)
LOWP(plus_)
LOWP(darken)
LOWP(lighten)
LOWP(difference)
LOWP(exclusion)
LOWP(hardlight)
LOWP(overlay)
LOWP(seed_shader)
LOWP(matrix_translate) LOWP(matrix_scale_translate) LOWP(matrix_2x3) LOWP(matrix_perspective)
LOWP(gather_8888) LOWP(gather_bgra) LOWP(gather_565) LOWP(gather_a8) LOWP(gather_g8)
LOWP(luminance_to_alpha)
LOWP(matrix_translate) LOWP(matrix_scale_translate)
LOWP(matrix_2x3) NOPE(matrix_3x4) TODO(matrix_4x5) TODO(matrix_4x3)
LOWP(matrix_perspective)
NOPE(parametric_r) NOPE(parametric_g) NOPE(parametric_b)
NOPE(parametric_a) NOPE(gamma)
NOPE(table_r) NOPE(table_g) NOPE(table_b) NOPE(table_a)
NOPE(lab_to_xyz)
TODO(mirror_x) TODO(repeat_x)
TODO(mirror_y) TODO(repeat_y)
TODO(clamp_x_1) TODO(mirror_x_1) TODO(repeat_x_1)
TODO(bilinear_nx) TODO(bilinear_px) TODO(bilinear_ny) TODO(bilinear_py)
TODO(bicubic_n3x) TODO(bicubic_n1x) TODO(bicubic_p1x) TODO(bicubic_p3x)
TODO(bicubic_n3y) TODO(bicubic_n1y) TODO(bicubic_p1y) TODO(bicubic_p3y)
TODO(save_xy) TODO(accumulate)
TODO(evenly_spaced_gradient)
TODO(gradient)
TODO(evenly_spaced_2_stop_gradient)
TODO(xy_to_unit_angle)
TODO(xy_to_radius)
TODO(xy_to_2pt_conical_quadratic_min)
TODO(xy_to_2pt_conical_quadratic_max)
TODO(xy_to_2pt_conical_linear)
TODO(mask_2pt_conical_degenerates) TODO(apply_vector_mask)
TODO(byte_tables) TODO(byte_tables_rgb)
NOPE(rgb_to_hsl) NOPE(hsl_to_rgb)
NOPE(clut_3D) NOPE(clut_4D)
NOPE(gauss_a_to_rgba)
#undef LOWP
#undef TODO
#undef NOPE
#endif
// Engines comprise everything we need to run SkRasterPipelines.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1198,23 +1198,6 @@ STAGE(evenly_spaced_gradient, const SkJumper_GradientCtx* c) {
gradient_lookup(c, idx, t, &r, &g, &b, &a);
}
// TODO: move this somewhere not in the middle of the gradients...
STAGE(gauss_a_to_rgba, Ctx::None) {
// x = 1 - x;
// exp(-x * x * 4) - 0.018f;
// ... now approximate with quartic
//
const float c4 = -2.26661229133605957031f;
const float c3 = 2.89795351028442382812f;
const float c2 = 0.21345567703247070312f;
const float c1 = 0.15489584207534790039f;
const float c0 = 0.00030726194381713867f;
a = mad(a, mad(a, mad(a, mad(a, c4, c3), c2), c1), c0);
r = a;
g = a;
b = a;
}
STAGE(gradient, const SkJumper_GradientCtx* c) {
auto t = r;
U32 idx = 0;
@ -1503,3 +1486,19 @@ STAGE(clut_4D, const SkJumper_ColorLookupTableCtx* ctx) {
// "a" was really CMYK's K, so we just set alpha opaque.
a = 1.0f;
}
STAGE(gauss_a_to_rgba, Ctx::None) {
// x = 1 - x;
// exp(-x * x * 4) - 0.018f;
// ... now approximate with quartic
//
const float c4 = -2.26661229133605957031f;
const float c3 = 2.89795351028442382812f;
const float c2 = 0.21345567703247070312f;
const float c1 = 0.15489584207534790039f;
const float c0 = 0.00030726194381713867f;
a = mad(a, mad(a, mad(a, mad(a, c4, c3), c2), c1), c0);
r = a;
g = a;
b = a;
}