app: analysis script to check for predeleted buffers

This commit is contained in:
darkfi
2025-08-01 13:25:03 +02:00
parent c8ca15fc54
commit 02556716bb
3 changed files with 56 additions and 4 deletions

47
bin/app/script/analyze.py Executable file
View File

@@ -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)

View File

@@ -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)

View File

@@ -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):