Retry, Bump stored lowp uniform color to 16-bit storage.
This makes loading into 16-bit channels more natural in _lowp.cpp. Update a unit test to stop using out-of-range "colors". Change-Id: I494687aac87948b60a40de447aa1527cf7167b2d Cq-Include-Trybots: skia.primary:Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-UBSAN_float_cast_overflow Reviewed-on: https://skia-review.googlesource.com/47580 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
parent
98c5d92ee6
commit
f757ae6aa7
@ -82,6 +82,11 @@ void SkRasterPipeline::dump() const {
|
||||
#endif
|
||||
|
||||
void SkRasterPipeline::append_constant_color(SkArenaAlloc* alloc, const float rgba[4]) {
|
||||
SkASSERT(0 <= rgba[0] && rgba[0] <= 1);
|
||||
SkASSERT(0 <= rgba[1] && rgba[1] <= 1);
|
||||
SkASSERT(0 <= rgba[2] && rgba[2] <= 1);
|
||||
SkASSERT(0 <= rgba[3] && rgba[3] <= 1);
|
||||
|
||||
if (rgba[0] == 0 && rgba[1] == 0 && rgba[2] == 0 && rgba[3] == 1) {
|
||||
this->append(black_color);
|
||||
INC_BLACK;
|
||||
@ -92,7 +97,13 @@ void SkRasterPipeline::append_constant_color(SkArenaAlloc* alloc, const float rg
|
||||
auto ctx = alloc->make<SkJumper_UniformColorCtx>();
|
||||
Sk4f color = Sk4f::Load(rgba);
|
||||
color.store(&ctx->r);
|
||||
ctx->rgba = Sk4f_toL32(color);
|
||||
|
||||
// To make loads more direct, we store 8-bit values in 16-bit slots.
|
||||
color = color * 255.0f + 0.5f;
|
||||
ctx->rgba[0] = (uint16_t)color[0];
|
||||
ctx->rgba[1] = (uint16_t)color[1];
|
||||
ctx->rgba[2] = (uint16_t)color[2];
|
||||
ctx->rgba[3] = (uint16_t)color[3];
|
||||
|
||||
this->unchecked_append(uniform_color, ctx);
|
||||
INC_COLOR;
|
||||
|
@ -118,7 +118,7 @@ struct SkJumper_2PtConicalCtx {
|
||||
|
||||
struct SkJumper_UniformColorCtx {
|
||||
float r,g,b,a;
|
||||
uint32_t rgba;
|
||||
uint16_t rgba[4]; // [0,255] in a 16-bit lane.
|
||||
};
|
||||
|
||||
struct SkJumper_ColorLookupTableCtx {
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -139,11 +139,10 @@ SI D join(S lo, S hi) {
|
||||
// ~~~~~~ Basic / misc. stages ~~~~~~ //
|
||||
|
||||
STAGE(uniform_color, const SkJumper_UniformColorCtx* c) {
|
||||
auto rgba = (const uint8_t*)&c->rgba;
|
||||
r = rgba[0];
|
||||
g = rgba[1];
|
||||
b = rgba[2];
|
||||
a = rgba[3];
|
||||
r = c->rgba[0];
|
||||
g = c->rgba[1];
|
||||
b = c->rgba[2];
|
||||
a = c->rgba[3];
|
||||
}
|
||||
STAGE(black_color, Ctx::None) { r = g = b = 0; a = 255; }
|
||||
STAGE(white_color, Ctx::None) { r = g = b = 255; a = 255; }
|
||||
|
@ -278,13 +278,18 @@ DEF_TEST(SkRasterPipeline_repeat_tiling, r) {
|
||||
// so v' becomes negative. :'(
|
||||
|
||||
// Here's a regression test to make sure this doesn't happen.
|
||||
float in [4] = {19133558.0f,0,0,0};
|
||||
float in[4 * SkJumper_kMaxStride];
|
||||
float out[4 * SkJumper_kMaxStride];
|
||||
for (float& f : in) {
|
||||
f = 0;
|
||||
}
|
||||
in[0] = 19133558.0f;
|
||||
|
||||
SkJumper_TileCtx tile = { 9.0f, 1/9.0f };
|
||||
|
||||
SkSTArenaAlloc<256> alloc;
|
||||
SkRasterPipeline p(&alloc);
|
||||
p.append_constant_color(&alloc, in);
|
||||
p.append(SkRasterPipeline::load_rgba, in);
|
||||
p.append(SkRasterPipeline::repeat_x, &tile);
|
||||
p.append(SkRasterPipeline::store_rgba, out);
|
||||
p.run(0,0,1,1);
|
||||
|
Loading…
Reference in New Issue
Block a user