Revert "Add SkVM op trace_done to indicate completion of debug tracing."

This reverts commit 062652067b.

Reason for revert: design change removes need for this op

Original change's description:
> Add SkVM op `trace_done` to indicate completion of debug tracing.
>
> This op can be used to invoke a callback function and dump the log to
> disk when it is ready. SkRuntimeEffect doesn't have any other viable
> mechanisms for detecting that a paint has completed, AFAIK. We can
> wait for ~SkRTShader to occur, but there's no guarantee that this will
> happen quickly, and the SkPaint with the SkRTShader shader can be reused
> over and over again.
>
> Unlike other trace ops, this only needs a trace mask, not an execution
> mask (we are unconditionally done at the end of main).
>
> Change-Id: I6f7ee41f2005b65940d36dee892279d4f245509f
> Bug: skia:12708
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/479876
> Auto-Submit: John Stiles <johnstiles@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Bug: skia:12708
Change-Id: Ic4c4f5dd72541195f07ca32035267a20a82536e7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/481577
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
John Stiles 2021-12-08 12:08:56 -05:00 committed by SkCQ
parent b7f5278009
commit 3856a5854e
10 changed files with 52 additions and 109 deletions

View File

@ -270,7 +270,6 @@ namespace skvm {
VarSlot{immB}, "=", V{z}); break; VarSlot{immB}, "=", V{z}); break;
case Op::trace_enter: write(o, op, TraceHookID{immA}, V{x}, V{y}, FnIdx{immB}); break; case Op::trace_enter: write(o, op, TraceHookID{immA}, V{x}, V{y}, FnIdx{immB}); break;
case Op::trace_exit: write(o, op, TraceHookID{immA}, V{x}, V{y}, FnIdx{immB}); break; case Op::trace_exit: write(o, op, TraceHookID{immA}, V{x}, V{y}, FnIdx{immB}); break;
case Op::trace_done: write(o, op, TraceHookID{immA}, V{x}); break;
case Op::store8: write(o, op, Ptr{immA}, V{x} ); break; case Op::store8: write(o, op, Ptr{immA}, V{x} ); break;
case Op::store16: write(o, op, Ptr{immA}, V{x} ); break; case Op::store16: write(o, op, Ptr{immA}, V{x} ); break;
@ -395,7 +394,6 @@ namespace skvm {
R{x}, R{y}, FnIdx{immB}); break; R{x}, R{y}, FnIdx{immB}); break;
case Op::trace_exit: write(o, op, TraceHookID{immA}, case Op::trace_exit: write(o, op, TraceHookID{immA},
R{x}, R{y}, FnIdx{immB}); break; R{x}, R{y}, FnIdx{immB}); break;
case Op::trace_done: write(o, op, TraceHookID{immA}, R{x}); break;
case Op::store8: write(o, op, Ptr{immA}, R{x} ); break; case Op::store8: write(o, op, Ptr{immA}, R{x} ); break;
case Op::store16: write(o, op, Ptr{immA}, R{x} ); break; case Op::store16: write(o, op, Ptr{immA}, R{x} ); break;
@ -671,12 +669,6 @@ namespace skvm {
if (this->isImm(traceMask.id,~0)) { traceMask = mask; } if (this->isImm(traceMask.id,~0)) { traceMask = mask; }
(void)push(Op::trace_exit, mask.id,traceMask.id,NA,NA, traceHookID, fnIdx); (void)push(Op::trace_exit, mask.id,traceMask.id,NA,NA, traceHookID, fnIdx);
} }
void Builder::trace_done(int traceHookID, I32 traceMask) {
SkASSERT(traceHookID >= 0);
SkASSERT(traceHookID < (int)fTraceHooks.size());
if (this->isImm(traceMask.id, 0)) { return; }
(void)push(Op::trace_done, traceMask.id,NA,NA,NA, traceHookID);
}
void Builder::store8 (Ptr ptr, I32 val) { (void)push(Op::store8 , val.id,NA,NA,NA, ptr.ix); } void Builder::store8 (Ptr ptr, I32 val) { (void)push(Op::store8 , val.id,NA,NA,NA, ptr.ix); }
void Builder::store16(Ptr ptr, I32 val) { (void)push(Op::store16, val.id,NA,NA,NA, ptr.ix); } void Builder::store16(Ptr ptr, I32 val) { (void)push(Op::store16, val.id,NA,NA,NA, ptr.ix); }
@ -2665,7 +2657,6 @@ namespace skvm {
case Op::trace_var: case Op::trace_var:
case Op::trace_enter: case Op::trace_enter:
case Op::trace_exit: case Op::trace_exit:
case Op::trace_done:
/* Force this program to run in the interpreter. */ /* Force this program to run in the interpreter. */
return false; return false;
@ -3604,7 +3595,6 @@ namespace skvm {
case Op::trace_var: case Op::trace_var:
case Op::trace_enter: case Op::trace_enter:
case Op::trace_exit: case Op::trace_exit:
case Op::trace_done:
/* Force this program to run in the interpreter. */ /* Force this program to run in the interpreter. */
return false; return false;
@ -3976,7 +3966,6 @@ namespace skvm {
case Op::trace_var: case Op::trace_var:
case Op::trace_enter: case Op::trace_enter:
case Op::trace_exit: case Op::trace_exit:
case Op::trace_done:
/* Force this program to run in the interpreter. */ /* Force this program to run in the interpreter. */
return false; return false;

View File

@ -432,29 +432,29 @@ namespace skvm {
}; };
// Order matters a little: Ops <=store128 are treated as having side effects. // Order matters a little: Ops <=store128 are treated as having side effects.
#define SKVM_OPS(M) \ #define SKVM_OPS(M) \
M(assert_true) \ M(assert_true) \
M(trace_line) M(trace_var) M(trace_enter) M(trace_exit) M(trace_done) \ M(trace_line) M(trace_var) M(trace_enter) M(trace_exit) \
M(store8) M(store16) M(store32) M(store64) M(store128) \ M(store8) M(store16) M(store32) M(store64) M(store128) \
M(load8) M(load16) M(load32) M(load64) M(load128) \ M(load8) M(load16) M(load32) M(load64) M(load128) \
M(index) \ M(index) \
M(gather8) M(gather16) M(gather32) \ M(gather8) M(gather16) M(gather32) \
M(uniform32) \ M(uniform32) \
M(array32) \ M(array32) \
M(splat) \ M(splat) \
M(add_f32) M(add_i32) \ M(add_f32) M(add_i32) \
M(sub_f32) M(sub_i32) \ M(sub_f32) M(sub_i32) \
M(mul_f32) M(mul_i32) \ M(mul_f32) M(mul_i32) \
M(div_f32) \ M(div_f32) \
M(min_f32) M(max_f32) \ M(min_f32) M(max_f32) \
M(fma_f32) M(fms_f32) M(fnma_f32) \ M(fma_f32) M(fms_f32) M(fnma_f32) \
M(sqrt_f32) \ M(sqrt_f32) \
M(shl_i32) M(shr_i32) M(sra_i32) \ M(shl_i32) M(shr_i32) M(sra_i32) \
M(ceil) M(floor) M(trunc) M(round) M(to_fp16) M(from_fp16) \ M(ceil) M(floor) M(trunc) M(round) M(to_fp16) M(from_fp16) \
M(to_f32) \ M(to_f32) \
M(neq_f32) M(eq_f32) M(eq_i32) \ M(neq_f32) M(eq_f32) M(eq_i32) \
M(gte_f32) M(gt_f32) M(gt_i32) \ M(gte_f32) M(gt_f32) M(gt_i32) \
M(bit_and) M(bit_or) M(bit_xor) M(bit_clear) \ M(bit_and) M(bit_or) M(bit_xor) M(bit_clear) \
M(select) M(select)
// End of SKVM_OPS // End of SKVM_OPS
@ -474,11 +474,11 @@ namespace skvm {
return Op::store8 <= op && op <= Op::index; return Op::store8 <= op && op <= Op::index;
} }
static inline bool is_trace(Op op) { static inline bool is_trace(Op op) {
return Op::trace_line <= op && op <= Op::trace_done; return Op::trace_line <= op && op <= Op::trace_exit;
} }
using Val = int; using Val = int;
// We reserve an impossible Val ID as a sentinel // We reserve an impossibe Val ID as a sentinel
// NA meaning none, n/a, null, nil, etc. // NA meaning none, n/a, null, nil, etc.
static const Val NA = -1; static const Val NA = -1;
@ -611,7 +611,6 @@ namespace skvm {
virtual void var(int slot, int32_t val) = 0; virtual void var(int slot, int32_t val) = 0;
virtual void enter(int fnIdx) = 0; virtual void enter(int fnIdx) = 0;
virtual void exit(int fnIdx) = 0; virtual void exit(int fnIdx) = 0;
virtual void done() = 0;
}; };
class Builder { class Builder {
@ -649,7 +648,6 @@ namespace skvm {
void trace_var (int traceHookID, I32 mask, I32 traceMask, int slot, I32 val); void trace_var (int traceHookID, I32 mask, I32 traceMask, int slot, I32 val);
void trace_enter(int traceHookID, I32 mask, I32 traceMask, int fnIdx); void trace_enter(int traceHookID, I32 mask, I32 traceMask, int fnIdx);
void trace_exit (int traceHookID, I32 mask, I32 traceMask, int fnIdx); void trace_exit (int traceHookID, I32 mask, I32 traceMask, int fnIdx);
void trace_done (int traceHookID, I32 traceMask);
// Store {8,16,32,64,128}-bit varying. // Store {8,16,32,64,128}-bit varying.
void store8 (Ptr ptr, I32 val); void store8 (Ptr ptr, I32 val);

View File

@ -250,12 +250,6 @@ namespace SkVMInterpreterTypes {
} }
break; break;
CASE(Op::trace_done):
if (should_trace(immA, x, x)) {
traceHooks[immA]->done();
}
break;
CASE(Op::index): { CASE(Op::index): {
const int iota[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15, const int iota[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,
16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31, 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,

View File

@ -82,14 +82,12 @@ namespace {
fTrace->fTraceInfo.push_back({SkSL::SkVMTraceInfo::Op::kExit, fTrace->fTraceInfo.push_back({SkSL::SkVMTraceInfo::Op::kExit,
/*data=*/{fnIdx, 0}}); /*data=*/{fnIdx, 0}});
} }
void done() override {
// TODO(skia:12708): write the trace here
}
private: private:
SkSL::SkVMDebugTrace* fTrace; SkSL::SkVMDebugTrace* fTrace;
}; };
} // namespace }
namespace SkSL { namespace SkSL {
@ -395,10 +393,6 @@ void SkVMGenerator::writeProgram(SkSpan<skvm::Val> uniforms,
this->setupGlobals(uniforms, device); this->setupGlobals(uniforms, device);
size_t returnSlot = this->writeFunction(function, arguments); size_t returnSlot = this->writeFunction(function, arguments);
if (fDebugTrace) {
fBuilder->trace_done(fTraceHookID, fTraceMask);
}
// Copy the value from the return slot into outReturn. // Copy the value from the return slot into outReturn.
SkASSERT(function.declaration().returnType().slotCount() == outReturn.size()); SkASSERT(function.declaration().returnType().slotCount() == outReturn.size());
for (size_t i = 0; i < outReturn.size(); ++i) { for (size_t i = 0; i < outReturn.size(); ++i) {

View File

@ -886,7 +886,6 @@ DEF_TEST(SkVM_trace_line, r) {
void var(int, int32_t) override { fBuffer.push_back(-9999999); } void var(int, int32_t) override { fBuffer.push_back(-9999999); }
void enter(int) override { fBuffer.push_back(-9999999); } void enter(int) override { fBuffer.push_back(-9999999); }
void exit(int) override { fBuffer.push_back(-9999999); } void exit(int) override { fBuffer.push_back(-9999999); }
void done() override { fBuffer.push_back(-9999999); }
void line(int lineNum) override { fBuffer.push_back(lineNum); } void line(int lineNum) override { fBuffer.push_back(lineNum); }
std::vector<int> fBuffer; std::vector<int> fBuffer;
@ -912,7 +911,6 @@ DEF_TEST(SkVM_trace_var, r) {
void line(int) override { fBuffer.push_back(-9999999); } void line(int) override { fBuffer.push_back(-9999999); }
void enter(int) override { fBuffer.push_back(-9999999); } void enter(int) override { fBuffer.push_back(-9999999); }
void exit(int) override { fBuffer.push_back(-9999999); } void exit(int) override { fBuffer.push_back(-9999999); }
void done() override { fBuffer.push_back(-9999999); }
void var(int slot, int32_t val) override { void var(int slot, int32_t val) override {
fBuffer.push_back(slot); fBuffer.push_back(slot);
fBuffer.push_back(val); fBuffer.push_back(val);
@ -940,7 +938,6 @@ DEF_TEST(SkVM_trace_enter_exit, r) {
public: public:
void line(int) override { fBuffer.push_back(-9999999); } void line(int) override { fBuffer.push_back(-9999999); }
void var(int, int32_t) override { fBuffer.push_back(-9999999); } void var(int, int32_t) override { fBuffer.push_back(-9999999); }
void done() override { fBuffer.push_back(-9999999); }
void enter(int fnIdx) override { void enter(int fnIdx) override {
fBuffer.push_back(fnIdx); fBuffer.push_back(fnIdx);
fBuffer.push_back(1); fBuffer.push_back(1);
@ -968,36 +965,12 @@ DEF_TEST(SkVM_trace_enter_exit, r) {
REPORTER_ASSERT(r, (testTrace.fBuffer == std::vector<int>{12, 1, 56, 0})); REPORTER_ASSERT(r, (testTrace.fBuffer == std::vector<int>{12, 1, 56, 0}));
} }
DEF_TEST(SkVM_trace_done, r) {
class TestTraceHook : public skvm::TraceHook {
public:
void line(int) override { fBuffer.push_back(-9999999); }
void enter(int) override { fBuffer.push_back(-9999999); }
void exit(int) override { fBuffer.push_back(-9999999); }
void var(int, int32_t) override { fBuffer.push_back(-9999999); }
void done() override { fBuffer.push_back(1); }
std::vector<int> fBuffer;
};
skvm::Builder b;
TestTraceHook testTrace;
int traceHookID = b.attachTraceHook(&testTrace);
b.trace_done(traceHookID, b.splat(0xFFFFFFFF));
b.trace_done(traceHookID, b.splat(0x00000000));
skvm::Program p = b.done();
p.eval(1);
REPORTER_ASSERT(r, (testTrace.fBuffer == std::vector<int>{1}));
}
DEF_TEST(SkVM_trace_multiple_hooks, r) { DEF_TEST(SkVM_trace_multiple_hooks, r) {
class TestTraceHook : public skvm::TraceHook { class TestTraceHook : public skvm::TraceHook {
public: public:
void var(int, int32_t) override { fBuffer.push_back(-9999999); } void var(int, int32_t) override { fBuffer.push_back(-9999999); }
void enter(int) override { fBuffer.push_back(-9999999); } void enter(int) override { fBuffer.push_back(-9999999); }
void exit(int) override { fBuffer.push_back(-9999999); } void exit(int) override { fBuffer.push_back(-9999999); }
void done() override { fBuffer.push_back(-9999999); }
void line(int lineNum) override { fBuffer.push_back(lineNum); } void line(int lineNum) override { fBuffer.push_back(lineNum); }
std::vector<int> fBuffer; std::vector<int> fBuffer;

View File

@ -48,7 +48,7 @@ F2 = float index_by_loop()
F3 = float index_by_complex_loop() F3 = float index_by_complex_loop()
F4 = float index_out_of_bounds_checked() F4 = float index_out_of_bounds_checked()
54 registers, 180 instructions: 54 registers, 179 instructions:
0 r0 = uniform32 ptr0 0 0 r0 = uniform32 ptr0 0
1 r1 = uniform32 ptr0 4 1 r1 = uniform32 ptr0 4
2 r2 = uniform32 ptr0 8 2 r2 = uniform32 ptr0 8
@ -225,8 +225,7 @@ loop:
172 trace_var 0 r53 r53 $29 = r37 172 trace_var 0 r53 r53 $29 = r37
173 trace_var 0 r53 r53 $30 = r41 173 trace_var 0 r53 r53 $30 = r41
174 trace_var 0 r53 r53 $31 = r50 174 trace_var 0 r53 r53 $31 = r50
175 trace_done 0 r53 175 store32 ptr1 r1
176 store32 ptr1 r1 176 store32 ptr2 r37
177 store32 ptr2 r37 177 store32 ptr3 r41
178 store32 ptr3 r41 178 store32 ptr4 r50
179 store32 ptr4 r50

View File

@ -37,7 +37,7 @@ $35 = c_mul_d (float, L43)
$36 = d_mul_c (float, L44) $36 = d_mul_c (float, L44)
F0 = half4 main(float2 xy) F0 = half4 main(float2 xy)
13 registers, 61 instructions: 13 registers, 60 instructions:
0 r0 = uniform32 ptr0 0 0 r0 = uniform32 ptr0 0
1 r1 = uniform32 ptr0 4 1 r1 = uniform32 ptr0 4
2 r2 = uniform32 ptr0 8 2 r2 = uniform32 ptr0 8
@ -95,8 +95,7 @@ loop:
53 trace_line 0 r4 r4 L45 53 trace_line 0 r4 r4 L45
54 trace_line 0 r4 r4 L47 54 trace_line 0 r4 r4 L47
55 trace_exit 0 r4 r4 F0 55 trace_exit 0 r4 r4 F0
56 trace_done 0 r4 56 store32 ptr1 r5
57 store32 ptr1 r5 57 store32 ptr2 r6
58 store32 ptr2 r6 58 store32 ptr3 r7
59 store32 ptr3 r7 59 store32 ptr4 r8
60 store32 ptr4 r8

View File

@ -78,7 +78,7 @@ F8 = bool loop_operator_gt()
F9 = bool loop_operator_eq() F9 = bool loop_operator_eq()
F10 = bool loop_operator_ne() F10 = bool loop_operator_ne()
41 registers, 735 instructions: 41 registers, 734 instructions:
0 r0 = uniform32 ptr0 0 0 r0 = uniform32 ptr0 0
1 r1 = uniform32 ptr0 4 1 r1 = uniform32 ptr0 4
2 r2 = uniform32 ptr0 8 2 r2 = uniform32 ptr0 8
@ -810,8 +810,7 @@ loop:
727 trace_var 0 r34 r34 $11 = r33 727 trace_var 0 r34 r34 $11 = r33
728 trace_var 0 r34 r34 $12 = r35 728 trace_var 0 r34 r34 $12 = r35
729 trace_var 0 r34 r34 $13 = r36 729 trace_var 0 r34 r34 $13 = r36
730 trace_done 0 r34 730 store32 ptr1 r39
731 store32 ptr1 r39 731 store32 ptr2 r33
732 store32 ptr2 r33 732 store32 ptr3 r35
733 store32 ptr3 r35 733 store32 ptr4 r36
734 store32 ptr4 r36

View File

@ -74,7 +74,7 @@ F7 = bool loop_operator_gt()
F8 = bool loop_operator_eq() F8 = bool loop_operator_eq()
F9 = bool loop_operator_ne() F9 = bool loop_operator_ne()
33 registers, 687 instructions: 33 registers, 686 instructions:
0 r0 = uniform32 ptr0 0 0 r0 = uniform32 ptr0 0
1 r1 = uniform32 ptr0 4 1 r1 = uniform32 ptr0 4
2 r2 = uniform32 ptr0 8 2 r2 = uniform32 ptr0 8
@ -758,8 +758,7 @@ loop:
679 trace_var 0 r26 r26 $11 = r25 679 trace_var 0 r26 r26 $11 = r25
680 trace_var 0 r26 r26 $12 = r27 680 trace_var 0 r26 r26 $12 = r27
681 trace_var 0 r26 r26 $13 = r31 681 trace_var 0 r26 r26 $13 = r31
682 trace_done 0 r26 682 store32 ptr1 r28
683 store32 ptr1 r28 683 store32 ptr2 r25
684 store32 ptr2 r25 684 store32 ptr3 r27
685 store32 ptr3 r27 685 store32 ptr4 r31
686 store32 ptr4 r31

View File

@ -155,7 +155,7 @@ F5 = bool highp_param(float value)
F6 = bool mediump_param(half value) F6 = bool mediump_param(half value)
F7 = bool lowp_param(half value) F7 = bool lowp_param(half value)
22 registers, 246 instructions: 22 registers, 245 instructions:
0 r0 = uniform32 ptr0 0 0 r0 = uniform32 ptr0 0
1 r1 = uniform32 ptr0 4 1 r1 = uniform32 ptr0 4
2 r2 = uniform32 ptr0 8 2 r2 = uniform32 ptr0 8
@ -398,8 +398,7 @@ loop:
238 trace_var 0 r21 r21 $9 = r2 238 trace_var 0 r21 r21 $9 = r2
239 trace_var 0 r21 r21 $10 = r3 239 trace_var 0 r21 r21 $10 = r3
240 trace_var 0 r21 r21 $11 = r4 240 trace_var 0 r21 r21 $11 = r4
241 trace_done 0 r21 241 store32 ptr1 r1
242 store32 ptr1 r1 242 store32 ptr2 r2
243 store32 ptr2 r2 243 store32 ptr3 r3
244 store32 ptr3 r3 244 store32 ptr4 r4
245 store32 ptr4 r4