rename Arg to Ptr

This makes almost all existing code read more clearly.

Change-Id: I314331d9aa2ecb4664557efc7972e1a820afc250
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/352085
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
Mike Klein 2021-01-08 13:45:42 -06:00
parent 7296c2366a
commit 00e43df25b
11 changed files with 197 additions and 198 deletions

View File

@ -191,10 +191,9 @@ namespace skvm {
static void write(SkWStream* o, Op op) {
o->writeText(name(op));
}
static void write(SkWStream* o, Arg a) {
write(o, "arg(");
o->writeDecAsText(a.ix);
write(o, ")");
static void write(SkWStream* o, Ptr p) {
write(o, "ptr");
o->writeDecAsText(p.ix);
}
static void write(SkWStream* o, V v) {
write(o, "v");
@ -237,25 +236,25 @@ namespace skvm {
switch (op) {
case Op::assert_true: write(o, op, V{x}, V{y}); break;
case Op::store8: write(o, op, Arg{immy} , V{x} ); break;
case Op::store16: write(o, op, Arg{immy} , V{x} ); break;
case Op::store32: write(o, op, Arg{immy} , V{x} ); break;
case Op::store64: write(o, op, Arg{immz} , V{x},V{y} ); break;
case Op::store128: write(o, op, Arg{immz>>1}, V{x},V{y},Hex{immz&1}); break;
case Op::store8: write(o, op, Ptr{immy} , V{x} ); break;
case Op::store16: write(o, op, Ptr{immy} , V{x} ); break;
case Op::store32: write(o, op, Ptr{immy} , V{x} ); break;
case Op::store64: write(o, op, Ptr{immz} , V{x},V{y} ); break;
case Op::store128: write(o, op, Ptr{immz>>1}, V{x},V{y},Hex{immz&1}); break;
case Op::index: write(o, V{id}, "=", op); break;
case Op::load8: write(o, V{id}, "=", op, Arg{immy}); break;
case Op::load16: write(o, V{id}, "=", op, Arg{immy}); break;
case Op::load32: write(o, V{id}, "=", op, Arg{immy}); break;
case Op::load64: write(o, V{id}, "=", op, Arg{immy}, Hex{immz}); break;
case Op::load128: write(o, V{id}, "=", op, Arg{immy}, Hex{immz}); break;
case Op::load8: write(o, V{id}, "=", op, Ptr{immy}); break;
case Op::load16: write(o, V{id}, "=", op, Ptr{immy}); break;
case Op::load32: write(o, V{id}, "=", op, Ptr{immy}); break;
case Op::load64: write(o, V{id}, "=", op, Ptr{immy}, Hex{immz}); break;
case Op::load128: write(o, V{id}, "=", op, Ptr{immy}, Hex{immz}); break;
case Op::gather8: write(o, V{id}, "=", op, Arg{immy}, Hex{immz}, V{x}); break;
case Op::gather16: write(o, V{id}, "=", op, Arg{immy}, Hex{immz}, V{x}); break;
case Op::gather32: write(o, V{id}, "=", op, Arg{immy}, Hex{immz}, V{x}); break;
case Op::gather8: write(o, V{id}, "=", op, Ptr{immy}, Hex{immz}, V{x}); break;
case Op::gather16: write(o, V{id}, "=", op, Ptr{immy}, Hex{immz}, V{x}); break;
case Op::gather32: write(o, V{id}, "=", op, Ptr{immy}, Hex{immz}, V{x}); break;
case Op::uniform32: write(o, V{id}, "=", op, Arg{immy}, Hex{immz}); break;
case Op::uniform32: write(o, V{id}, "=", op, Ptr{immy}, Hex{immz}); break;
case Op::splat: write(o, V{id}, "=", op, Splat{immy}); break;
@ -349,25 +348,25 @@ namespace skvm {
switch (op) {
case Op::assert_true: write(o, op, R{x}, R{y}); break;
case Op::store8: write(o, op, Arg{immy} , R{x} ); break;
case Op::store16: write(o, op, Arg{immy} , R{x} ); break;
case Op::store32: write(o, op, Arg{immy} , R{x} ); break;
case Op::store64: write(o, op, Arg{immz} , R{x}, R{y} ); break;
case Op::store128: write(o, op, Arg{immz>>1}, R{x}, R{y}, Hex{immz&1}); break;
case Op::store8: write(o, op, Ptr{immy} , R{x} ); break;
case Op::store16: write(o, op, Ptr{immy} , R{x} ); break;
case Op::store32: write(o, op, Ptr{immy} , R{x} ); break;
case Op::store64: write(o, op, Ptr{immz} , R{x}, R{y} ); break;
case Op::store128: write(o, op, Ptr{immz>>1}, R{x}, R{y}, Hex{immz&1}); break;
case Op::index: write(o, R{d}, "=", op); break;
case Op::load8: write(o, R{d}, "=", op, Arg{immy}); break;
case Op::load16: write(o, R{d}, "=", op, Arg{immy}); break;
case Op::load32: write(o, R{d}, "=", op, Arg{immy}); break;
case Op::load64: write(o, R{d}, "=", op, Arg{immy}, Hex{immz}); break;
case Op::load128: write(o, R{d}, "=", op, Arg{immy}, Hex{immz}); break;
case Op::load8: write(o, R{d}, "=", op, Ptr{immy}); break;
case Op::load16: write(o, R{d}, "=", op, Ptr{immy}); break;
case Op::load32: write(o, R{d}, "=", op, Ptr{immy}); break;
case Op::load64: write(o, R{d}, "=", op, Ptr{immy}, Hex{immz}); break;
case Op::load128: write(o, R{d}, "=", op, Ptr{immy}, Hex{immz}); break;
case Op::gather8: write(o, R{d}, "=", op, Arg{immy}, Hex{immz}, R{x}); break;
case Op::gather16: write(o, R{d}, "=", op, Arg{immy}, Hex{immz}, R{x}); break;
case Op::gather32: write(o, R{d}, "=", op, Arg{immy}, Hex{immz}, R{x}); break;
case Op::gather8: write(o, R{d}, "=", op, Ptr{immy}, Hex{immz}, R{x}); break;
case Op::gather16: write(o, R{d}, "=", op, Ptr{immy}, Hex{immz}, R{x}); break;
case Op::gather32: write(o, R{d}, "=", op, Ptr{immy}, Hex{immz}, R{x}); break;
case Op::uniform32: write(o, R{d}, "=", op, Arg{immy}, Hex{immz}); break;
case Op::uniform32: write(o, R{d}, "=", op, Ptr{immy}, Hex{immz}); break;
case Op::splat: write(o, R{d}, "=", op, Splat{immy}); break;
@ -576,7 +575,7 @@ namespace skvm {
return false;
}
Arg Builder::arg(int stride) {
Ptr Builder::arg(int stride) {
int ix = (int)fStrides.size();
fStrides.push_back(stride);
return {ix};
@ -590,39 +589,39 @@ namespace skvm {
#endif
}
void Builder::store8 (Arg ptr, I32 val) { (void)push(Op::store8 , val.id,NA,NA, ptr.ix); }
void Builder::store16(Arg ptr, I32 val) { (void)push(Op::store16, val.id,NA,NA, ptr.ix); }
void Builder::store32(Arg ptr, I32 val) { (void)push(Op::store32, val.id,NA,NA, ptr.ix); }
void Builder::store64(Arg ptr, I32 lo, I32 hi) {
void Builder::store8 (Ptr ptr, I32 val) { (void)push(Op::store8 , val.id,NA,NA, ptr.ix); }
void Builder::store16(Ptr ptr, I32 val) { (void)push(Op::store16, val.id,NA,NA, ptr.ix); }
void Builder::store32(Ptr ptr, I32 val) { (void)push(Op::store32, val.id,NA,NA, ptr.ix); }
void Builder::store64(Ptr ptr, I32 lo, I32 hi) {
(void)push(Op::store64, lo.id,hi.id,NA, NA,ptr.ix);
}
void Builder::store128(Arg ptr, I32 lo, I32 hi, int lane) {
void Builder::store128(Ptr ptr, I32 lo, I32 hi, int lane) {
(void)push(Op::store128, lo.id,hi.id,NA, NA,(ptr.ix<<1)|(lane&1));
}
I32 Builder::index() { return {this, push(Op::index , NA,NA,NA,0) }; }
I32 Builder::load8 (Arg ptr) { return {this, push(Op::load8 , NA,NA,NA, ptr.ix) }; }
I32 Builder::load16(Arg ptr) { return {this, push(Op::load16, NA,NA,NA, ptr.ix) }; }
I32 Builder::load32(Arg ptr) { return {this, push(Op::load32, NA,NA,NA, ptr.ix) }; }
I32 Builder::load64(Arg ptr, int lane) {
I32 Builder::load8 (Ptr ptr) { return {this, push(Op::load8 , NA,NA,NA, ptr.ix) }; }
I32 Builder::load16(Ptr ptr) { return {this, push(Op::load16, NA,NA,NA, ptr.ix) }; }
I32 Builder::load32(Ptr ptr) { return {this, push(Op::load32, NA,NA,NA, ptr.ix) }; }
I32 Builder::load64(Ptr ptr, int lane) {
return {this, push(Op::load64 , NA,NA,NA, ptr.ix,lane) };
}
I32 Builder::load128(Arg ptr, int lane) {
I32 Builder::load128(Ptr ptr, int lane) {
return {this, push(Op::load128, NA,NA,NA, ptr.ix,lane) };
}
I32 Builder::gather8 (Arg ptr, int offset, I32 index) {
I32 Builder::gather8 (Ptr ptr, int offset, I32 index) {
return {this, push(Op::gather8 , index.id,NA,NA, ptr.ix,offset)};
}
I32 Builder::gather16(Arg ptr, int offset, I32 index) {
I32 Builder::gather16(Ptr ptr, int offset, I32 index) {
return {this, push(Op::gather16, index.id,NA,NA, ptr.ix,offset)};
}
I32 Builder::gather32(Arg ptr, int offset, I32 index) {
I32 Builder::gather32(Ptr ptr, int offset, I32 index) {
return {this, push(Op::gather32, index.id,NA,NA, ptr.ix,offset)};
}
I32 Builder::uniform32(Arg ptr, int offset) {
I32 Builder::uniform32(Ptr ptr, int offset) {
return {this, push(Op::uniform32, NA,NA,NA, ptr.ix, offset)};
}
@ -1140,7 +1139,7 @@ namespace skvm {
#endif
}
Color Builder::load(PixelFormat f, Arg ptr) {
Color Builder::load(PixelFormat f, Ptr ptr) {
switch (byte_size(f)) {
case 1: return unpack(f, load8 (ptr));
case 2: return unpack(f, load16(ptr));
@ -1171,7 +1170,7 @@ namespace skvm {
return {};
}
Color Builder::gather(PixelFormat f, Arg ptr, int offset, I32 index) {
Color Builder::gather(PixelFormat f, Ptr ptr, int offset, I32 index) {
switch (byte_size(f)) {
case 1: return unpack(f, gather8 (ptr, offset, index));
case 2: return unpack(f, gather16(ptr, offset, index));
@ -1220,7 +1219,7 @@ namespace skvm {
return packed;
}
bool Builder::store(PixelFormat f, Arg ptr, Color c) {
bool Builder::store(PixelFormat f, Ptr ptr, Color c) {
// Detect a grayscale PixelFormat: r,g,b bit counts and shifts all equal.
if (f.r_bits == f.g_bits && f.g_bits == f.b_bits &&
f.r_shift == f.g_shift && f.g_shift == f.b_shift) {

View File

@ -471,7 +471,7 @@ namespace skvm {
// NA meaning none, n/a, null, nil, etc.
static const Val NA = -1;
struct Arg { int ix; };
struct Ptr { int ix; };
// 32-bit signed integer (with both signed sra() and unsigned/logical shr() available).
// Think "int" or "int32_t".
@ -574,14 +574,14 @@ namespace skvm {
};
struct Uniform {
Arg ptr;
Ptr ptr;
int offset;
};
struct Uniforms {
Arg base;
Ptr base;
std::vector<int> buf;
explicit Uniforms(int init) : base(Arg{0}), buf(init) {}
explicit Uniforms(int init) : base(Ptr{0}), buf(init) {}
Uniform push(int val) {
buf.push_back(val);
@ -653,14 +653,14 @@ namespace skvm {
// Declare an argument with given stride (use stride=0 for uniforms).
// TODO: different types for varying and uniforms?
Arg arg(int stride);
Ptr arg(int stride);
// Convenience arg() wrappers for most common strides, sizeof(T) and 0.
template <typename T>
Arg varying() { return this->arg(sizeof(T)); }
Arg uniform() { return this->arg(0); }
Ptr varying() { return this->arg(sizeof(T)); }
Ptr uniform() { return this->arg(0); }
// TODO: allow uniform (i.e. Arg) offsets to store* and load*?
// TODO: allow uniform (i.e. Ptr) offsets to store* and load*?
// TODO: sign extension (signed types) for <32-bit loads?
// TODO: unsigned integer operations where relevant (just comparisons?)?
@ -672,36 +672,36 @@ namespace skvm {
// TODO: Half asserts?
// Store {8,16,32,64,128}-bit varying.
void store8 (Arg ptr, I32 val);
void store16 (Arg ptr, I32 val);
void store32 (Arg ptr, I32 val);
void storeF (Arg ptr, F32 val) { store32(ptr, pun_to_I32(val)); }
void store64 (Arg ptr, I32 lo, I32 hi); // *ptr = lo|(hi<<32)
void store128(Arg ptr, I32 lo, I32 hi, int lane); // 64-bit lane 0-1 at ptr = lo|(hi<<32).
void store8 (Ptr ptr, I32 val);
void store16 (Ptr ptr, I32 val);
void store32 (Ptr ptr, I32 val);
void storeF (Ptr ptr, F32 val) { store32(ptr, pun_to_I32(val)); }
void store64 (Ptr ptr, I32 lo, I32 hi); // *ptr = lo|(hi<<32)
void store128(Ptr ptr, I32 lo, I32 hi, int lane); // 64-bit lane 0-1 at ptr = lo|(hi<<32).
// Returns varying {n, n-1, n-2, ..., 1}, where n is the argument to Program::eval().
I32 index();
// Load {8,16,32,64,128}-bit varying.
I32 load8 (Arg ptr);
I32 load16 (Arg ptr);
I32 load32 (Arg ptr);
F32 loadF (Arg ptr) { return pun_to_F32(load32(ptr)); }
I32 load64 (Arg ptr, int lane); // Load 32-bit lane 0-1 of 64-bit value.
I32 load128(Arg ptr, int lane); // Load 32-bit lane 0-3 of 128-bit value.
I32 load8 (Ptr ptr);
I32 load16 (Ptr ptr);
I32 load32 (Ptr ptr);
F32 loadF (Ptr ptr) { return pun_to_F32(load32(ptr)); }
I32 load64 (Ptr ptr, int lane); // Load 32-bit lane 0-1 of 64-bit value.
I32 load128(Ptr ptr, int lane); // Load 32-bit lane 0-3 of 128-bit value.
// Load i32/f32 uniform with byte-count offset.
I32 uniform32(Arg ptr, int offset);
F32 uniformF (Arg ptr, int offset) { return pun_to_F32(uniform32(ptr,offset)); }
I32 uniform32(Ptr ptr, int offset);
F32 uniformF (Ptr ptr, int offset) { return pun_to_F32(uniform32(ptr,offset)); }
// Push and load this color as a uniform.
Color uniformColor(SkColor4f, Uniforms*);
// Gather u8,u16,i32 with varying element-count index from *(ptr + byte-count offset).
I32 gather8 (Arg ptr, int offset, I32 index);
I32 gather16(Arg ptr, int offset, I32 index);
I32 gather32(Arg ptr, int offset, I32 index);
F32 gatherF (Arg ptr, int offset, I32 index) {
I32 gather8 (Ptr ptr, int offset, I32 index);
I32 gather16(Ptr ptr, int offset, I32 index);
I32 gather32(Ptr ptr, int offset, I32 index);
F32 gatherF (Ptr ptr, int offset, I32 index) {
return pun_to_F32(gather32(ptr, offset, index));
}
@ -868,9 +868,9 @@ namespace skvm {
F32 from_unorm(int bits, I32); // E.g. from_unorm(8, x) -> x * (1/255.0f)
I32 to_unorm(int bits, F32); // E.g. to_unorm(8, x) -> round(x * 255)
Color load(PixelFormat, Arg ptr);
bool store(PixelFormat, Arg ptr, Color);
Color gather(PixelFormat, Arg ptr, int offset, I32 index);
Color load(PixelFormat, Ptr ptr);
bool store(PixelFormat, Ptr ptr, Color);
Color gather(PixelFormat, Ptr ptr, int offset, I32 index);
Color gather(PixelFormat f, Uniform u, I32 index) {
return gather(f, u.ptr, u.offset, index);
}
@ -1137,17 +1137,17 @@ namespace skvm {
static inline void assert_true(I32 cond, F32 debug) { cond->assert_true(cond,debug); }
static inline void assert_true(I32 cond) { cond->assert_true(cond); }
static inline void store8 (Arg ptr, I32 val) { val->store8 (ptr, val); }
static inline void store16 (Arg ptr, I32 val) { val->store16 (ptr, val); }
static inline void store32 (Arg ptr, I32 val) { val->store32 (ptr, val); }
static inline void storeF (Arg ptr, F32 val) { val->storeF (ptr, val); }
static inline void store64 (Arg ptr, I32 lo, I32 hi) { lo ->store64 (ptr, lo,hi); }
static inline void store128(Arg ptr, I32 lo, I32 hi, int ix) { lo ->store128(ptr, lo,hi, ix); }
static inline void store8 (Ptr ptr, I32 val) { val->store8 (ptr, val); }
static inline void store16 (Ptr ptr, I32 val) { val->store16 (ptr, val); }
static inline void store32 (Ptr ptr, I32 val) { val->store32 (ptr, val); }
static inline void storeF (Ptr ptr, F32 val) { val->storeF (ptr, val); }
static inline void store64 (Ptr ptr, I32 lo, I32 hi) { lo ->store64 (ptr, lo,hi); }
static inline void store128(Ptr ptr, I32 lo, I32 hi, int ix) { lo ->store128(ptr, lo,hi, ix); }
static inline I32 gather8 (Arg ptr, int off, I32 ix) { return ix->gather8 (ptr, off, ix); }
static inline I32 gather16(Arg ptr, int off, I32 ix) { return ix->gather16(ptr, off, ix); }
static inline I32 gather32(Arg ptr, int off, I32 ix) { return ix->gather32(ptr, off, ix); }
static inline F32 gatherF (Arg ptr, int off, I32 ix) { return ix->gatherF (ptr, off, ix); }
static inline I32 gather8 (Ptr ptr, int off, I32 ix) { return ix->gather8 (ptr, off, ix); }
static inline I32 gather16(Ptr ptr, int off, I32 ix) { return ix->gather16(ptr, off, ix); }
static inline I32 gather32(Ptr ptr, int off, I32 ix) { return ix->gather32(ptr, off, ix); }
static inline F32 gatherF (Ptr ptr, int off, I32 ix) { return ix->gatherF (ptr, off, ix); }
static inline I32 gather8 (Uniform u, I32 ix) { return ix->gather8 (u, ix); }
static inline I32 gather16(Uniform u, I32 ix) { return ix->gather16(u, ix); }
@ -1232,8 +1232,8 @@ namespace skvm {
static inline F32 from_unorm(int bits, I32 x) { return x->from_unorm(bits,x); }
static inline I32 to_unorm(int bits, F32 x) { return x-> to_unorm(bits,x); }
static inline bool store(PixelFormat f, Arg p, Color c) { return c->store(f,p,c); }
static inline Color gather(PixelFormat f, Arg p, int off, I32 ix) {
static inline bool store(PixelFormat f, Ptr p, Color c) { return c->store(f,p,c); }
static inline Color gather(PixelFormat f, Ptr p, int off, I32 ix) {
return ix->gather(f,p,off,ix);
}
static inline Color gather(PixelFormat f, Uniform u, I32 ix) {

View File

@ -191,7 +191,7 @@ namespace {
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) {
// First two arguments are always uniforms and the destination buffer.
uniforms->base = p->uniform();
skvm::Arg dst_ptr = p->arg(SkColorTypeBytesPerPixel(params.dst.colorType()));
skvm::Ptr dst_ptr = p->arg(SkColorTypeBytesPerPixel(params.dst.colorType()));
// A SpriteShader (in this file) may next use one argument as its varying source.
// Subsequent arguments depend on params.coverage:
// - Full: (no more arguments)

View File

@ -12,7 +12,7 @@ namespace skvm {
class Assembler;
class Builder;
class Program;
struct Arg;
struct Ptr;
struct I32;
struct F32;
struct Half;

View File

@ -1395,10 +1395,10 @@ bool ProgramToSkVM(const Program& program,
SkVMSignature ignored,
*signature = outSignature ? outSignature : &ignored;
skvm::Arg uniforms = b->uniform();
skvm::Ptr uniforms = b->uniform();
(void)uniforms;
std::vector<skvm::Arg> argPtrs;
std::vector<skvm::Ptr> argPtrs;
std::vector<skvm::Val> argVals;
for (const Variable* p : function.declaration().parameters()) {
@ -1410,7 +1410,7 @@ bool ProgramToSkVM(const Program& program,
}
}
std::vector<skvm::Arg> returnPtrs;
std::vector<skvm::Ptr> returnPtrs;
std::vector<skvm::Val> returnVals;
signature->fReturnSlots = slot_count(function.declaration().returnType());

View File

@ -24,7 +24,7 @@ static void test_jit_and_interpreter(skvm::Program&& program, Fn&& test) {
DEF_TEST(SkVM_eliminate_dead_code, r) {
skvm::Builder b;
{
skvm::Arg arg = b.varying<int>();
skvm::Ptr arg = b.varying<int>();
skvm::I32 l = b.load32(arg);
skvm::I32 a = b.add(l, l);
b.add(a, b.splat(7));
@ -99,7 +99,7 @@ DEF_TEST(SkVM_LoopCounts, r) {
// buf[i] += 1
skvm::Builder b;
skvm::Arg arg = b.varying<int>();
skvm::Ptr arg = b.varying<int>();
b.store32(arg,
b.add(b.splat(1),
b.load32(arg)));
@ -125,7 +125,7 @@ DEF_TEST(SkVM_LoopCounts, r) {
DEF_TEST(SkVM_gather32, r) {
skvm::Builder b;
{
skvm::Arg uniforms = b.uniform(),
skvm::Ptr uniforms = b.uniform(),
buf = b.varying<int>();
skvm::I32 x = b.load32(buf);
b.store32(buf, b.gather32(uniforms,0, b.bit_and(x, b.splat(7))));
@ -173,7 +173,7 @@ DEF_TEST(SkVM_gather32, r) {
DEF_TEST(SkVM_gathers, r) {
skvm::Builder b;
{
skvm::Arg uniforms = b.uniform(),
skvm::Ptr uniforms = b.uniform(),
buf32 = b.varying<int>(),
buf16 = b.varying<uint16_t>(),
buf8 = b.varying<uint8_t>();
@ -231,7 +231,7 @@ DEF_TEST(SkVM_gathers, r) {
DEF_TEST(SkVM_gathers2, r) {
skvm::Builder b;
{
skvm::Arg uniforms = b.uniform(),
skvm::Ptr uniforms = b.uniform(),
buf32 = b.varying<int>(),
buf16 = b.varying<uint16_t>(),
buf8 = b.varying<uint8_t>();
@ -280,7 +280,7 @@ DEF_TEST(SkVM_gathers2, r) {
DEF_TEST(SkVM_bitops, r) {
skvm::Builder b;
{
skvm::Arg ptr = b.varying<int>();
skvm::Ptr ptr = b.varying<int>();
skvm::I32 x = b.load32(ptr);
@ -306,7 +306,7 @@ DEF_TEST(SkVM_bitops, r) {
DEF_TEST(SkVM_select_is_NaN, r) {
skvm::Builder b;
{
skvm::Arg src = b.varying<float>(),
skvm::Ptr src = b.varying<float>(),
dst = b.varying<float>();
skvm::F32 x = b.loadF(src);
@ -338,7 +338,7 @@ DEF_TEST(SkVM_select_is_NaN, r) {
DEF_TEST(SkVM_f32, r) {
skvm::Builder b;
{
skvm::Arg arg = b.varying<float>();
skvm::Ptr arg = b.varying<float>();
skvm::F32 x = b.loadF(arg),
y = b.add(x,x), // y = 2x
@ -448,7 +448,7 @@ DEF_TEST(SkVM_mad, r) {
skvm::Builder b;
{
skvm::Arg arg = b.varying<int>();
skvm::Ptr arg = b.varying<int>();
skvm::F32 x = b.to_F32(b.load32(arg)),
y = b.mad(x,x,x), // x is needed in the future, so r[x] != r[y].
@ -474,7 +474,7 @@ DEF_TEST(SkVM_fms, r) {
// Create a pattern that can be peepholed into an Op::fms_f32.
skvm::Builder b;
{
skvm::Arg arg = b.varying<int>();
skvm::Ptr arg = b.varying<int>();
skvm::F32 x = b.to_F32(b.load32(arg)),
v = b.sub(b.mul(x, b.splat(2.0f)),
@ -496,7 +496,7 @@ DEF_TEST(SkVM_fnma, r) {
// Create a pattern that can be peepholed into an Op::fnma_f32.
skvm::Builder b;
{
skvm::Arg arg = b.varying<int>();
skvm::Ptr arg = b.varying<int>();
skvm::F32 x = b.to_F32(b.load32(arg)),
v = b.sub(b.splat(1.0f),
@ -517,7 +517,7 @@ DEF_TEST(SkVM_fnma, r) {
DEF_TEST(SkVM_madder, r) {
skvm::Builder b;
{
skvm::Arg arg = b.varying<float>();
skvm::Ptr arg = b.varying<float>();
skvm::F32 x = b.loadF(arg),
y = b.mad(x,x,x), // x is needed in the future, so r[x] != r[y].
@ -539,7 +539,7 @@ DEF_TEST(SkVM_madder, r) {
DEF_TEST(SkVM_floor, r) {
skvm::Builder b;
{
skvm::Arg arg = b.varying<float>();
skvm::Ptr arg = b.varying<float>();
b.storeF(arg, b.floor(b.loadF(arg)));
}
@ -556,8 +556,8 @@ DEF_TEST(SkVM_floor, r) {
DEF_TEST(SkVM_round, r) {
skvm::Builder b;
{
skvm::Arg src = b.varying<float>();
skvm::Arg dst = b.varying<int>();
skvm::Ptr src = b.varying<float>();
skvm::Ptr dst = b.varying<int>();
b.store32(dst, b.round(b.loadF(src)));
}
@ -578,9 +578,9 @@ DEF_TEST(SkVM_round, r) {
DEF_TEST(SkVM_min, r) {
skvm::Builder b;
{
skvm::Arg src1 = b.varying<float>();
skvm::Arg src2 = b.varying<float>();
skvm::Arg dst = b.varying<float>();
skvm::Ptr src1 = b.varying<float>();
skvm::Ptr src2 = b.varying<float>();
skvm::Ptr dst = b.varying<float>();
b.storeF(dst, b.min(b.loadF(src1), b.loadF(src2)));
}
@ -600,9 +600,9 @@ DEF_TEST(SkVM_min, r) {
DEF_TEST(SkVM_max, r) {
skvm::Builder b;
{
skvm::Arg src1 = b.varying<float>();
skvm::Arg src2 = b.varying<float>();
skvm::Arg dst = b.varying<float>();
skvm::Ptr src1 = b.varying<float>();
skvm::Ptr src2 = b.varying<float>();
skvm::Ptr dst = b.varying<float>();
b.storeF(dst, b.max(b.loadF(src1), b.loadF(src2)));
}
@ -624,7 +624,7 @@ DEF_TEST(SkVM_hoist, r) {
// The JIT will try again without hoisting, and that'll just need 2 registers.
skvm::Builder b;
{
skvm::Arg arg = b.varying<int>();
skvm::Ptr arg = b.varying<int>();
skvm::I32 x = b.load32(arg);
for (int i = 0; i < 32; i++) {
x = b.add(x, b.splat(i));
@ -644,7 +644,7 @@ DEF_TEST(SkVM_hoist, r) {
DEF_TEST(SkVM_select, r) {
skvm::Builder b;
{
skvm::Arg buf = b.varying<int>();
skvm::Ptr buf = b.varying<int>();
skvm::I32 x = b.load32(buf);
@ -676,7 +676,7 @@ DEF_TEST(SkVM_swap, r) {
// y = *Y
// *X = y
// but this reordering does not produce the same results and is invalid.
skvm::Arg X = b.varying<int>(),
skvm::Ptr X = b.varying<int>(),
Y = b.varying<int>();
skvm::I32 x = b.load32(X),
@ -701,7 +701,7 @@ DEF_TEST(SkVM_NewOps, r) {
// Exercise a somewhat arbitrary set of new ops.
skvm::Builder b;
{
skvm::Arg buf = b.varying<int16_t>(),
skvm::Ptr buf = b.varying<int16_t>(),
uniforms = b.uniform();
skvm::I32 x = b.load16(buf);
@ -1869,7 +1869,7 @@ DEF_TEST(SkVM_Assembler, r) {
DEF_TEST(SkVM_approx_math, r) {
auto eval = [](int N, float values[], auto fn) {
skvm::Builder b;
skvm::Arg inout = b.varying<float>();
skvm::Ptr inout = b.varying<float>();
b.storeF(inout, fn(&b, b.loadF(inout)));
@ -1927,7 +1927,7 @@ DEF_TEST(SkVM_approx_math, r) {
auto test = [r](float arg, float expected, float tolerance, auto prog) {
skvm::Builder b;
skvm::Arg inout = b.varying<float>();
skvm::Ptr inout = b.varying<float>();
b.storeF(inout, prog(b.loadF(inout)));
float actual = arg;
b.done().eval(1, &actual);
@ -1943,9 +1943,9 @@ DEF_TEST(SkVM_approx_math, r) {
auto test2 = [r](float arg0, float arg1, float expected, float tolerance, auto prog) {
skvm::Builder b;
skvm::Arg in0 = b.varying<float>();
skvm::Arg in1 = b.varying<float>();
skvm::Arg out = b.varying<float>();
skvm::Ptr in0 = b.varying<float>();
skvm::Ptr in1 = b.varying<float>();
skvm::Ptr out = b.varying<float>();
b.storeF(out, prog(b.loadF(in0), b.loadF(in1)));
float actual;
b.done().eval(1, &arg0, &arg1, &actual);
@ -2052,7 +2052,7 @@ DEF_TEST(SkVM_min_max, r) {
{
skvm::Builder b;
{
skvm::Arg src = b.varying<float>(),
skvm::Ptr src = b.varying<float>(),
mn = b.varying<float>(),
mx = b.varying<float>();
@ -2081,7 +2081,7 @@ DEF_TEST(SkVM_min_max, r) {
for (int i = 0; i < 8; i++) {
skvm::Builder b;
{
skvm::Arg src = b.varying<float>(),
skvm::Ptr src = b.varying<float>(),
mn = b.varying<float>(),
mx = b.varying<float>();
@ -2106,7 +2106,7 @@ DEF_TEST(SkVM_min_max, r) {
for (int i = 0; i < 8; i++) {
skvm::Builder b;
{
skvm::Arg src = b.varying<float>(),
skvm::Ptr src = b.varying<float>(),
mn = b.varying<float>(),
mx = b.varying<float>();
@ -2135,7 +2135,7 @@ DEF_TEST(SkVM_halfs, r) {
-4.0f,-0.5f,-1.0f,-2.0f};
{
skvm::Builder b;
skvm::Arg src = b.varying<uint16_t>(),
skvm::Ptr src = b.varying<uint16_t>(),
dst = b.varying<float>();
b.storeF(dst, b.from_fp16(b.load16(src)));
@ -2149,7 +2149,7 @@ DEF_TEST(SkVM_halfs, r) {
}
{
skvm::Builder b;
skvm::Arg src = b.varying<float>(),
skvm::Ptr src = b.varying<float>(),
dst = b.varying<uint16_t>();
b.store16(dst, b.to_fp16(b.loadF(src)));
@ -2177,7 +2177,7 @@ DEF_TEST(SkVM_64bit, r) {
{
skvm::Builder b;
{
skvm::Arg wide = b.varying<uint64_t>(),
skvm::Ptr wide = b.varying<uint64_t>(),
lo = b.varying<int>(),
hi = b.varying<int>();
b.store32(lo, b.load64(wide, 0));
@ -2196,7 +2196,7 @@ DEF_TEST(SkVM_64bit, r) {
{
skvm::Builder b;
{
skvm::Arg wide = b.varying<uint64_t>(),
skvm::Ptr wide = b.varying<uint64_t>(),
lo = b.varying<int>(),
hi = b.varying<int>();
b.store64(wide, b.load32(lo), b.load32(hi));
@ -2227,7 +2227,7 @@ DEF_TEST(SkVM_128bit, r) {
{ // Convert RGBA F32 to RGBA 8888, testing 128-bit loads.
skvm::Builder b;
{
skvm::Arg dst = b.arg( 4),
skvm::Ptr dst = b.arg( 4),
src = b.arg(16);
skvm::Color c = b.load(rgba_ffff, src);
@ -2246,7 +2246,7 @@ DEF_TEST(SkVM_128bit, r) {
{ // Convert RGBA 8888 to RGBA F32, testing 128-bit stores.
skvm::Builder b;
{
skvm::Arg dst = b.arg(16),
skvm::Ptr dst = b.arg(16),
src = b.arg( 4);
skvm::Color c = b.load(rgba_8888, src);
@ -2266,7 +2266,7 @@ DEF_TEST(SkVM_128bit, r) {
DEF_TEST(SkVM_is_NaN_is_finite, r) {
skvm::Builder b;
{
skvm::Arg src = b.varying<float>(),
skvm::Ptr src = b.varying<float>(),
nan = b.varying<int>(),
fin = b.varying<int>();
b.store32(nan, is_NaN (b.loadF(src)));
@ -2291,7 +2291,7 @@ DEF_TEST(SkVM_args, r) {
// Test we can handle at least six arguments.
skvm::Builder b;
{
skvm::Arg dst = b.varying<float>(),
skvm::Ptr dst = b.varying<float>(),
A = b.varying<float>(),
B = b.varying<float>(),
C = b.varying<float>(),
@ -2321,7 +2321,7 @@ DEF_TEST(SkVM_badpack, r) {
// originally with a bad arm64 implementation of pack().
skvm::Builder p;
{
skvm::Arg uniforms = p.uniform(),
skvm::Ptr uniforms = p.uniform(),
dst = p.varying<uint16_t>();
skvm::I32 r = round(p.uniformF(uniforms, 8) * 15),
@ -2380,7 +2380,7 @@ DEF_TEST(SkVM_gather_can_hoist, r) {
// First a typical gather scenario with varying index.
{
skvm::Builder b;
skvm::Arg uniforms = b.uniform(),
skvm::Ptr uniforms = b.uniform(),
buf = b.varying<int>();
skvm::I32 ix = b.load32(buf);
b.store32(buf, b.gather32(uniforms,0, ix));
@ -2400,7 +2400,7 @@ DEF_TEST(SkVM_gather_can_hoist, r) {
// Now the same but with a uniform index instead.
{
skvm::Builder b;
skvm::Arg uniforms = b.uniform(),
skvm::Ptr uniforms = b.uniform(),
buf = b.varying<int>();
skvm::I32 ix = b.uniform32(uniforms,8);
b.store32(buf, b.gather32(uniforms,0, ix));
@ -2427,7 +2427,7 @@ DEF_TEST(SkVM_dont_dedup_loads, r) {
constexpr int K = 2;
skvm::Builder b;
{
skvm::Arg buf = b.varying<int>();
skvm::Ptr buf = b.varying<int>();
for (int i = 0; i < K; i++) {
b.store32(buf, b.load32(buf) + 1);
}
@ -2448,7 +2448,7 @@ DEF_TEST(SkVM_dont_dedup_stores, r) {
// will invalidate the first store, meaning we do need to reissue that store operation.
skvm::Builder b;
{
skvm::Arg buf = b.varying<int>();
skvm::Ptr buf = b.varying<int>();
b.store32(buf, b.splat(4));
b.store32(buf, b.splat(5));
b.store32(buf, b.splat(4)); // If we dedup'd, we'd skip this store.

View File

@ -1,7 +1,7 @@
8 registers, 22 instructions:
0 r0 = uniform32 arg(0) 4
1 r1 = uniform32 arg(0) 8
2 r2 = uniform32 arg(0) C
0 r0 = uniform32 ptr0 4
1 r1 = uniform32 ptr0 8
2 r2 = uniform32 ptr0 C
3 r3 = splat FFFFFFFF (nan)
4 r4 = splat 0 (0)
5 r5 = neq_f32 r0 r4
@ -18,7 +18,7 @@
16 r0 = to_f32 r0
17 r0 = mul_f32 r7 r0
loop:
18 store32 arg(1) r0
19 store32 arg(2) r0
20 store32 arg(3) r0
21 store32 arg(4) r0
18 store32 ptr1 r0
19 store32 ptr2 r0
20 store32 ptr3 r0
21 store32 ptr4 r0

View File

@ -1,6 +1,6 @@
13 registers, 35 instructions:
0 r0 = uniform32 arg(0) 0
1 r1 = uniform32 arg(0) C
0 r0 = uniform32 ptr0 0
1 r1 = uniform32 ptr0 C
2 r2 = splat 0 (0)
3 r3 = splat 40000000 (2)
4 r4 = splat 3F800000 (1)
@ -24,14 +24,14 @@ loop:
21 r9 = mul_i32 r9 r1
22 r9 = add_i32 r10 r9
23 r9 = shl_i32 r9 2
24 r10 = gather32 arg(0) 4 r9
24 r10 = gather32 ptr0 4 r9
25 r11 = add_i32 r9 r6
26 r11 = gather32 arg(0) 4 r11
26 r11 = gather32 ptr0 4 r11
27 r12 = add_i32 r9 r7
28 r12 = gather32 arg(0) 4 r12
28 r12 = gather32 ptr0 4 r12
29 r9 = add_i32 r9 r8
30 r9 = gather32 arg(0) 4 r9
31 store32 arg(1) r10
32 store32 arg(2) r11
33 store32 arg(3) r12
34 store32 arg(4) r9
30 r9 = gather32 ptr0 4 r9
31 store32 ptr1 r10
32 store32 ptr2 r11
33 store32 ptr3 r12
34 store32 ptr4 r9

View File

@ -1,6 +1,6 @@
9 registers, 22 instructions:
0 r0 = uniform32 arg(0) 0
1 r1 = uniform32 arg(0) C
0 r0 = uniform32 ptr0 0
1 r1 = uniform32 ptr0 C
2 r0 = trunc r0
3 r2 = splat 1 (1.4012985e-45)
4 r3 = splat 2 (2.8025969e-45)
@ -11,14 +11,14 @@ loop:
8 r5 = mul_i32 r5 r1
9 r5 = add_i32 r0 r5
10 r5 = shl_i32 r5 2
11 r6 = gather32 arg(0) 4 r5
11 r6 = gather32 ptr0 4 r5
12 r7 = add_i32 r5 r2
13 r7 = gather32 arg(0) 4 r7
13 r7 = gather32 ptr0 4 r7
14 r8 = add_i32 r5 r3
15 r8 = gather32 arg(0) 4 r8
15 r8 = gather32 ptr0 4 r8
16 r5 = add_i32 r5 r4
17 r5 = gather32 arg(0) 4 r5
18 store32 arg(1) r6
19 store32 arg(2) r7
20 store32 arg(3) r8
21 store32 arg(4) r5
17 r5 = gather32 ptr0 4 r5
18 store32 ptr1 r6
19 store32 ptr2 r7
20 store32 ptr3 r8
21 store32 ptr4 r5

View File

@ -1,15 +1,15 @@
18 registers, 47 instructions:
0 r0 = uniform32 arg(0) 0
1 r1 = uniform32 arg(0) C
2 r2 = uniform32 arg(0) 10
3 r3 = uniform32 arg(0) 14
4 r4 = uniform32 arg(0) 18
5 r5 = uniform32 arg(0) 1C
6 r6 = uniform32 arg(0) 20
7 r7 = uniform32 arg(0) 24
8 r8 = uniform32 arg(0) 28
9 r9 = uniform32 arg(0) 2C
10 r10 = uniform32 arg(0) 30
0 r0 = uniform32 ptr0 0
1 r1 = uniform32 ptr0 C
2 r2 = uniform32 ptr0 10
3 r3 = uniform32 ptr0 14
4 r4 = uniform32 ptr0 18
5 r5 = uniform32 ptr0 1C
6 r6 = uniform32 ptr0 20
7 r7 = uniform32 ptr0 24
8 r8 = uniform32 ptr0 28
9 r9 = uniform32 ptr0 2C
10 r10 = uniform32 ptr0 30
11 r5 = mul_f32 r5 r0
12 r6 = mul_f32 r6 r0
13 r0 = mul_f32 r7 r0
@ -36,14 +36,14 @@ loop:
33 r14 = mul_i32 r14 r1
34 r14 = add_i32 r15 r14
35 r14 = shl_i32 r14 2
36 r15 = gather32 arg(0) 4 r14
36 r15 = gather32 ptr0 4 r14
37 r16 = add_i32 r14 r11
38 r16 = gather32 arg(0) 4 r16
38 r16 = gather32 ptr0 4 r16
39 r17 = add_i32 r14 r12
40 r17 = gather32 arg(0) 4 r17
40 r17 = gather32 ptr0 4 r17
41 r14 = add_i32 r14 r13
42 r14 = gather32 arg(0) 4 r14
43 store32 arg(1) r15
44 store32 arg(2) r16
45 store32 arg(3) r17
46 store32 arg(4) r14
42 r14 = gather32 ptr0 4 r14
43 store32 ptr1 r15
44 store32 ptr2 r16
45 store32 ptr3 r17
46 store32 ptr4 r14

View File

@ -1,6 +1,6 @@
12 registers, 33 instructions:
0 r0 = uniform32 arg(0) 0
1 r1 = uniform32 arg(0) C
0 r0 = uniform32 ptr0 0
1 r1 = uniform32 ptr0 C
2 r2 = splat 0 (0)
3 r3 = splat 3F800000 (1)
4 r4 = mul_f32 r2 r0
@ -22,14 +22,14 @@ loop:
19 r8 = mul_i32 r8 r1
20 r8 = add_i32 r9 r8
21 r8 = shl_i32 r8 2
22 r9 = gather32 arg(0) 4 r8
22 r9 = gather32 ptr0 4 r8
23 r10 = add_i32 r8 r5
24 r10 = gather32 arg(0) 4 r10
24 r10 = gather32 ptr0 4 r10
25 r11 = add_i32 r8 r6
26 r11 = gather32 arg(0) 4 r11
26 r11 = gather32 ptr0 4 r11
27 r8 = add_i32 r8 r7
28 r8 = gather32 arg(0) 4 r8
29 store32 arg(1) r9
30 store32 arg(2) r10
31 store32 arg(3) r11
32 store32 arg(4) r8
28 r8 = gather32 ptr0 4 r8
29 store32 ptr1 r9
30 store32 ptr2 r10
31 store32 ptr3 r11
32 store32 ptr4 r8