Ver código fonte

app: analysis script to check for predeleted buffers

darkfi 1 ano atrás
pai
commit
02556716bb
3 arquivos alterados com 56 adições e 4 exclusões
  1. 47 0
      bin/app/script/analyze.py
  2. 8 3
      bin/app/script/traxator.py
  3. 1 1
      bin/app/script/view.py

+ 47 - 0
bin/app/script/analyze.py

@@ -0,0 +1,47 @@
+#!/usr/bin/python
+from traxator import *
+import sys
+
+if len(sys.argv) != 2:
+    print("wrong args", file=sys.stderr)
+    sys.exit(-1)
+fname = sys.argv[1]
+
+epoch = 1
+
+sections = read_trax(fname)
+
+def check(id, i):
+    for j, sect in enumerate(sections):
+        if j >= i:
+            break
+        match sect:
+            case DelBuf(epoch, buf, tag, buftype, stat):
+                assert buf != id
+
+def checktex(id, i):
+    for j, sect in enumerate(sections):
+        if j >= i:
+            break
+        match sect:
+            case DelTex(epoch, buf, tag, stat):
+                assert buf != id
+
+
+for i, sect in enumerate(sections):
+    match sect:
+        case PutDrawCall(_, _, dcs, stats):
+            for dc in dcs:
+                #print(f"DrawCall {dc.dc_id}")
+                for (i, instr) in enumerate(dc.instrs):
+                    match instr:
+                        case Draw(vert_id, ve, _, _, idx_id, ie, _, _, tex, _):
+                            assert ve == ie
+                            if ve != epoch:
+                                continue
+                            if tex:
+                                (tex_id, _, _) = tex
+                                checktex(tex_id, i)
+                            check(vert_id, i)
+                            check(idx_id, i)
+

+ 8 - 3
bin/app/script/traxator.py

@@ -3,6 +3,7 @@ from pydrk import serial
 from collections import namedtuple
 from dataclasses import dataclass
 from typing import Union
+import sys
 
 @dataclass
 class SetScale:
@@ -280,8 +281,8 @@ def read_section(f):
 
     return sect
 
-def read_trax():
-    f = open("trax.dat", "rb")
+def read_trax(fname):
+    f = open(fname, "rb")
     sections = []
     while True:
         if (sect := read_section(f)) is None:
@@ -290,7 +291,11 @@ def read_trax():
     return sections
 
 if __name__ == "__main__":
-    sections = read_trax()
+    if len(sys.argv) != 2:
+        print("wrong args", file=sys.stderr)
+        sys.exit(-1)
+    fname = sys.argv[1]
+    sections = read_trax(fname)
     for sect in sections:
         print(sect)
 

+ 1 - 1
bin/app/script/view.py

@@ -6,7 +6,7 @@ dc_id = 2767617242841734550
 vert_id = 39568
 idx_id = 39569
 
-sections = read_trax()
+sections = read_trax("trax.dat")
 for sect in sections:
     match sect:
         case PutDrawCall(_, _, dcs, stats):