Bläddra i källkod

app: remove old gfx simulator and associated utilities (trax), and move py scripts to script/

darkfi 1 vecka sedan
förälder
incheckning
a76639f020

+ 0 - 671
bin/app/bin/drawsim.rs

@@ -1,671 +0,0 @@
-/* This file is part of DarkFi (https://dark.fi)
- *
- * Copyright (C) 2020-2026 Dyne.org foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
- */
-
-use async_trait::async_trait;
-use darkfi_serial::{SerialEncodable, SerialDecodable, serialize, Encodable, Decodable, deserialize};
-use std::{
-    fs::{OpenOptions, File},
-    collections::HashMap,
-    sync::{mpsc, Arc, Mutex as SyncMutex},
-    time::{Duration, Instant},
-    ops::{Add, Mul},
-};
-use futures::AsyncWriteExt;
-use miniquad::{
-    conf, window, Backend, Bindings, BlendFactor, BlendState, BlendValue, BufferLayout,
-    BufferSource, BufferType, BufferUsage, Equation, EventHandler, KeyCode, KeyMods, MouseButton,
-    PassAction, Pipeline, PipelineParams, RenderingBackend, ShaderMeta, ShaderSource, TouchPhase,
-    TextureFormat, TextureKind, TextureParams, TextureWrap, UniformDesc, UniformType,
-    VertexAttribute, VertexFormat,
-    UniformBlockLayout,
-};
-
-const FILENAME: &str = "drawinstrs.dat";
-
-const DEBUG_RENDER: bool = false;
-const DEBUG_GFXAPI: bool = false;
-
-#[derive(Clone, Debug, SerialEncodable, SerialDecodable)]
-#[repr(C)]
-pub struct Vertex {
-    pub pos: [f32; 2],
-    pub color: [f32; 4],
-    pub uv: [f32; 2],
-}
-
-#[derive(Clone, Copy, Debug, SerialEncodable, SerialDecodable)]
-pub struct Point {
-    pub x: f32,
-    pub y: f32,
-}
-
-impl Point {
-    pub fn zero() -> Self {
-        Self { x: 0., y: 0. }
-    }
-}
-
-impl From<[f32; 2]> for Point {
-    fn from(pos: [f32; 2]) -> Self {
-        Self { x: pos[0], y: pos[1] }
-    }
-}
-
-impl Add for Point {
-    type Output = Self;
-
-    fn add(self, other: Self) -> Self::Output {
-        Self { x: self.x + other.x, y: self.y + other.y }
-    }
-}
-
-#[derive(Debug, Clone, Copy, SerialEncodable, SerialDecodable)]
-pub struct Rectangle {
-    pub x: f32,
-    pub y: f32,
-    pub w: f32,
-    pub h: f32,
-}
-
-impl From<[f32; 4]> for Rectangle {
-    fn from(rect: [f32; 4]) -> Self {
-        Self { x: rect[0], y: rect[1], w: rect[2], h: rect[3] }
-    }
-}
-
-impl Mul<f32> for Rectangle {
-    type Output = Rectangle;
-
-    fn mul(self, scale: f32) -> Self::Output {
-        Self { x: self.x * scale, y: self.y * scale, w: self.w * scale, h: self.h * scale }
-    }
-}
-
-pub type GfxTextureId = u32;
-pub type GfxBufferId = u32;
-
-#[derive(Clone, Debug, SerialEncodable, SerialDecodable)]
-pub struct GfxDrawCall {
-    pub instrs: Vec<GfxDrawInstruction>,
-    pub dcs: Vec<u64>,
-    pub z_index: u32,
-}
-
-impl GfxDrawCall {
-    fn compile(
-        self,
-        textures: &HashMap<GfxTextureId, miniquad::TextureId>,
-        buffers: &HashMap<GfxBufferId, miniquad::BufferId>,
-    ) -> DrawCall {
-        DrawCall {
-            instrs: self.instrs.into_iter().map(|i| i.compile(textures, buffers)).collect(),
-            dcs: self.dcs,
-            z_index: self.z_index,
-        }
-    }
-}
-
-#[derive(Debug, Clone, SerialEncodable, SerialDecodable)]
-pub enum GfxDrawInstruction {
-    SetScale(f32),
-    Move(Point),
-    ApplyView(Rectangle),
-    Draw(GfxDrawMesh),
-}
-
-impl GfxDrawInstruction {
-    fn compile(
-        self,
-        textures: &HashMap<GfxTextureId, miniquad::TextureId>,
-        buffers: &HashMap<GfxBufferId, miniquad::BufferId>,
-    ) -> DrawInstruction {
-        match self {
-            Self::SetScale(scale) => DrawInstruction::SetScale(scale),
-            Self::Move(off) => DrawInstruction::Move(off),
-            Self::ApplyView(view) => DrawInstruction::ApplyView(view),
-            Self::Draw(mesh) => DrawInstruction::Draw(mesh.compile(textures, buffers)),
-        }
-    }
-}
-
-#[derive(Clone, Debug, SerialEncodable, SerialDecodable)]
-pub struct GfxDrawMesh {
-    pub vertex_buffer: GfxBufferId,
-    pub index_buffer: GfxBufferId,
-    pub texture: Option<GfxTextureId>,
-    pub num_elements: i32,
-}
-
-impl GfxDrawMesh {
-    fn compile(
-        self,
-        textures: &HashMap<GfxTextureId, miniquad::TextureId>,
-        buffers: &HashMap<GfxBufferId, miniquad::BufferId>,
-    ) -> DrawMesh {
-        DrawMesh {
-            vertex_buffer: buffers[&self.vertex_buffer],
-            index_buffer: buffers[&self.index_buffer],
-            texture: self.texture.map(|t| textures[&t]),
-            num_elements: self.num_elements,
-        }
-    }
-}
-
-#[derive(Clone, Debug, SerialEncodable, SerialDecodable)]
-pub enum GraphicsMethod {
-    NewTexture((u16, u16, Vec<u8>, GfxTextureId)),
-    DeleteTexture(GfxTextureId),
-    NewVertexBuffer((Vec<Vertex>, GfxBufferId)),
-    NewIndexBuffer((Vec<u16>, GfxBufferId)),
-    DeleteBuffer(GfxBufferId),
-    ReplaceDrawCalls(Vec<(u64, GfxDrawCall)>),
-}
-
-#[derive(Debug, SerialEncodable, SerialDecodable)]
-struct Instruction {
-    timest: u64,
-    method: GraphicsMethod
-}
-
-pub fn read_instrs() -> Vec<Instruction> {
-    let mut instrs = vec![];
-    let mut f = File::open(FILENAME).unwrap();
-    loop {
-        let Ok(data) = Vec::<u8>::decode(&mut f) else { break };
-
-        let instr: Instruction = deserialize(&data).unwrap();
-        instrs.push(instr);
-    }
-    instrs
-}
-
-#[derive(Clone, Debug)]
-struct DrawMesh {
-    vertex_buffer: miniquad::BufferId,
-    index_buffer: miniquad::BufferId,
-    texture: Option<miniquad::TextureId>,
-    num_elements: i32,
-}
-
-#[derive(Debug, Clone)]
-enum DrawInstruction {
-    SetScale(f32),
-    Move(Point),
-    ApplyView(Rectangle),
-    Draw(DrawMesh),
-}
-
-#[derive(Debug)]
-struct DrawCall {
-    instrs: Vec<DrawInstruction>,
-    dcs: Vec<u64>,
-    z_index: u32,
-}
-
-struct Stage {
-    ctx: Box<dyn RenderingBackend>,
-    pipeline: Pipeline,
-    white_texture: miniquad::TextureId,
-    draw_calls: HashMap<u64, DrawCall>,
-
-    textures: HashMap<GfxTextureId, miniquad::TextureId>,
-    buffers: HashMap<GfxBufferId, miniquad::BufferId>,
-
-    instant: Instant,
-    instrs: Vec<Instruction>,
-}
-
-impl Stage {
-    pub fn new(
-    ) -> Self {
-
-    let mut instrs = read_instrs();
-    instrs.reverse();
-    println!("Loaded instrs");
-
-        let mut ctx: Box<dyn RenderingBackend> = window::new_rendering_backend();
-
-        let white_texture = ctx.new_texture_from_rgba8(1, 1, &[255, 255, 255, 255]);
-
-        let mut shader_meta: ShaderMeta = shader::meta();
-        shader_meta.uniforms.uniforms.push(UniformDesc::new("Projection", UniformType::Mat4));
-        shader_meta.uniforms.uniforms.push(UniformDesc::new("Model", UniformType::Mat4));
-
-        let shader = ctx
-            .new_shader(
-                match ctx.info().backend {
-                    Backend::OpenGl => ShaderSource::Glsl {
-                        vertex: shader::GL_VERTEX,
-                        fragment: shader::GL_FRAGMENT,
-                    },
-                    Backend::Metal => ShaderSource::Msl { program: shader::METAL },
-                },
-                shader_meta,
-            )
-            .unwrap();
-
-        let params = PipelineParams {
-            color_blend: Some(BlendState::new(
-                Equation::Add,
-                BlendFactor::Value(BlendValue::SourceAlpha),
-                BlendFactor::OneMinusValue(BlendValue::SourceAlpha),
-            )),
-            ..Default::default()
-        };
-
-        let pipeline = ctx.new_pipeline(
-            &[BufferLayout::default()],
-            &[
-                VertexAttribute::new("in_pos", VertexFormat::Float2),
-                VertexAttribute::new("in_color", VertexFormat::Float4),
-                VertexAttribute::new("in_uv", VertexFormat::Float2),
-            ],
-            shader,
-            params,
-        );
-
-        Stage {
-            ctx,
-            pipeline,
-            white_texture,
-            draw_calls: HashMap::from([(0, DrawCall { instrs: vec![], dcs: vec![], z_index: 0 })]),
-            textures: HashMap::new(),
-            buffers: HashMap::new(),
-            instant: Instant::now(),
-            instrs,
-        }
-    }
-
-    fn process_method(&mut self, method: GraphicsMethod) {
-        //println!("Received method: {:?}", method);
-        match method {
-            GraphicsMethod::NewTexture((width, height, data, fmt, gfx_texture_id, _)) => {
-                self.method_new_texture(width, height, data, fmt, gfx_texture_id)
-            }
-            GraphicsMethod::DeleteTexture(texture) => self.method_delete_texture(texture),
-            GraphicsMethod::NewVertexBuffer((verts, sendr)) => {
-                self.method_new_vertex_buffer(verts, sendr)
-            }
-            GraphicsMethod::NewIndexBuffer((indices, sendr)) => {
-                self.method_new_index_buffer(indices, sendr)
-            }
-            GraphicsMethod::DeleteBuffer(buffer) => self.method_delete_buffer(buffer),
-            GraphicsMethod::ReplaceDrawCalls(dcs) => self.method_replace_draw_calls(dcs),
-        };
-    }
-
-    fn method_new_texture(
-        &mut self,
-        width: u16,
-        height: u16,
-        data: Vec<u8>,
-        fmt: TextureFormat,
-        gfx_texture_id: GfxTextureId,
-    ) {
-        let texture = self.ctx.new_texture_from_data_and_format(
-            &data,
-            TextureParams {
-                kind: TextureKind::Texture2D,
-                format: fmt,
-                width: width as _,
-                height: height as _,
-                wrap: TextureWrap::Clamp,
-                min_filter: miniquad::FilterMode::Linear,
-                mag_filter: miniquad::FilterMode::Linear,
-                mipmap_filter: miniquad::MipmapFilterMode::None,
-                allocate_mipmaps: false,
-                sample_count: 1,
-            },
-        );
-        if DEBUG_GFXAPI {
-            println!("Invoked method: new_texture({}, {}, ..., {}) -> {:?}",
-                   width, height, gfx_texture_id, texture);
-            //println!("Invoked method: new_texture({}, {}, ..., {}) -> {:?}\n{}",
-            //       width, height, gfx_texture_id, texture,
-            //       ansi_texture(width as usize, height as usize, &data));
-        }
-        self.textures.insert(gfx_texture_id, texture);
-    }
-    fn method_delete_texture(&mut self, gfx_texture_id: GfxTextureId) {
-        let texture = self.textures.remove(&gfx_texture_id).expect("couldn't find gfx_texture_id");
-        if DEBUG_GFXAPI {
-            println!("Invoked method: delete_texture({} => {:?})",
-                   gfx_texture_id, texture);
-        }
-        self.ctx.delete_texture(texture);
-    }
-    fn method_new_vertex_buffer(&mut self, verts: Vec<Vertex>, gfx_buffer_id: GfxBufferId) {
-        let buffer = self.ctx.new_buffer(
-            BufferType::VertexBuffer,
-            BufferUsage::Immutable,
-            BufferSource::slice(&verts),
-        );
-        if DEBUG_GFXAPI {
-            println!("Invoked method: new_vertex_buffer(..., {}) -> {:?}",
-                   gfx_buffer_id, buffer);
-            //println!("Invoked method: new_vertex_buffer({:?}, {}) -> {:?}",
-            //       verts, gfx_buffer_id, buffer);
-        }
-        self.buffers.insert(gfx_buffer_id, buffer);
-    }
-    fn method_new_index_buffer(&mut self, indices: Vec<u16>, gfx_buffer_id: GfxBufferId) {
-        let buffer = self.ctx.new_buffer(
-            BufferType::IndexBuffer,
-            BufferUsage::Immutable,
-            BufferSource::slice(&indices),
-        );
-        if DEBUG_GFXAPI {
-            println!("Invoked method: new_index_buffer({}) -> {:?}",
-                   gfx_buffer_id, buffer);
-            //println!("Invoked method: new_index_buffer({:?}, {}) -> {:?}",
-            //       indices, gfx_buffer_id, buffer);
-        }
-        self.buffers.insert(gfx_buffer_id, buffer);
-    }
-    fn method_delete_buffer(&mut self, gfx_buffer_id: GfxBufferId) {
-        let buffer = self.buffers.remove(&gfx_buffer_id).expect("couldn't find gfx_buffer_id");
-        if DEBUG_GFXAPI {
-            println!("Invoked method: delete_buffer({} => {:?})",
-                   gfx_buffer_id, buffer);
-        }
-        self.ctx.delete_buffer(buffer);
-    }
-    fn method_replace_draw_calls(&mut self, dcs: Vec<(u64, GfxDrawCall)>) {
-        if DEBUG_GFXAPI {
-            println!("Invoked method: replace_draw_calls({:?})", dcs);
-        }
-        for (key, val) in dcs {
-            let val = val.compile(&self.textures, &self.buffers);
-            self.draw_calls.insert(key, val);
-        }
-    }
-}
-
-impl EventHandler for Stage {
-    fn update(&mut self) {
-        let timest = self.instant.elapsed().as_millis() as u64;
-        while let Some(instr) = self.instrs.last() {
-            if instr.timest > timest {
-                break
-            }
-
-            let instr = self.instrs.pop().unwrap();
-            self.process_method(instr.method);
-        }
-    }
-
-    fn draw(&mut self) {
-        self.ctx.begin_default_pass(PassAction::Nothing);
-        self.ctx.apply_pipeline(&self.pipeline);
-
-        // This will make the top left (0, 0) and the bottom right (1, 1)
-        // Default is (-1, 1) -> (1, -1)
-        let proj = glam::Mat4::from_translation(glam::Vec3::new(-1., 1., 0.)) *
-            glam::Mat4::from_scale(glam::Vec3::new(2., -2., 1.));
-
-        let mut uniforms_data = [0u8; 128];
-        let data: [u8; 64] = unsafe { std::mem::transmute_copy(&proj) };
-        uniforms_data[0..64].copy_from_slice(&data);
-        //let data: [u8; 64] = unsafe { std::mem::transmute_copy(&model) };
-        //uniforms_data[64..].copy_from_slice(&data);
-        assert_eq!(128, 2 * UniformType::Mat4.size());
-
-        let (screen_w, screen_h) = miniquad::window::screen_size();
-
-        let mut render_ctx = RenderContext {
-            ctx: &mut self.ctx,
-            draw_calls: &self.draw_calls,
-            uniforms_data,
-            white_texture: self.white_texture,
-            scale: 1.,
-            view: Rectangle::from([0., 0., screen_w, screen_h]),
-            cursor: Point::from([0., 0.]),
-        };
-        render_ctx.draw();
-
-        self.ctx.commit_frame();
-    }
-}
-
-struct RenderContext<'a> {
-    ctx: &'a mut Box<dyn RenderingBackend>,
-    draw_calls: &'a HashMap<u64, DrawCall>,
-    uniforms_data: [u8; 128],
-    white_texture: miniquad::TextureId,
-
-    scale: f32,
-    view: Rectangle,
-    cursor: Point,
-}
-
-impl<'a> RenderContext<'a> {
-    fn draw(&mut self) {
-        if DEBUG_RENDER {
-            println!("RenderContext::draw()");
-        }
-        let curr_pos = Point::zero();
-        self.draw_call(&self.draw_calls[&0], 0);
-        if DEBUG_RENDER {
-            println!("RenderContext::draw() [DONE]");
-        }
-    }
-
-    fn apply_view(&mut self) {
-        let view = self.view * self.scale;
-
-        let (_, screen_height) = window::screen_size();
-
-        let view_x = view.x.round() as i32;
-        let view_y = screen_height - (view.y + view.h);
-        let view_y = view_y.round() as i32;
-        let view_w = view.w.round() as i32;
-        let view_h = view.h.round() as i32;
-
-        //if DEBUG_RENDER {
-        //    println!("=> viewport {view_x} {view_y} {view_w} {view_h}");
-        //}
-        self.ctx.apply_viewport(view_x, view_y, view_w, view_h);
-        self.ctx.apply_scissor_rect(view_x, view_y, view_w, view_h);
-    }
-
-    fn apply_model(&mut self) {
-        let off_x = self.cursor.x / self.view.w;
-        let off_y = self.cursor.y / self.view.h;
-
-        let scale_w = 1. / self.view.w;
-        let scale_h = 1. / self.view.h;
-
-        let model = glam::Mat4::from_translation(glam::Vec3::new(off_x, off_y, 0.)) *
-            glam::Mat4::from_scale(glam::Vec3::new(scale_w, scale_h, 1.));
-
-        let data: [u8; 64] = unsafe { std::mem::transmute_copy(&model) };
-        self.uniforms_data[64..].copy_from_slice(&data);
-        self.ctx.apply_uniforms_from_bytes(self.uniforms_data.as_ptr(), self.uniforms_data.len());
-    }
-
-    fn draw_call(&mut self, draw_call: &DrawCall, indent: u32) {
-        let ws = if DEBUG_RENDER { " ".repeat(indent as usize * 4) } else { String::new() };
-
-        let old_view = self.view;
-        let old_cursor = self.cursor;
-
-        for instr in &draw_call.instrs {
-            match instr {
-                DrawInstruction::SetScale(scale) => {
-                    self.scale = *scale;
-                    if DEBUG_RENDER {
-                        println!("{ws}set_scale({scale})");
-                    }
-                }
-                DrawInstruction::Move(off) => {
-                    self.cursor = old_cursor + *off;
-                    if DEBUG_RENDER {
-                        println!(
-                            "{ws}move({off:?})  cursor={:?}, scale={}, view={:?}",
-                            self.cursor, self.scale, self.view
-                        );
-                    }
-                    self.apply_model();
-                }
-                DrawInstruction::ApplyView(view) => {
-                    self.view = *view;
-                    if DEBUG_RENDER {
-                        println!(
-                            "{ws}apply_view({view:?})  scale={}, view={:?}",
-                            self.scale, self.view
-                        );
-                    }
-                    self.apply_view();
-                }
-                DrawInstruction::Draw(mesh) => {
-                    if DEBUG_RENDER {
-                        println!("{ws}draw({mesh:?})");
-                    }
-                    let texture = match mesh.texture {
-                        Some(texture) => texture,
-                        None => self.white_texture,
-                    };
-                    let bindings = Bindings {
-                        vertex_buffers: vec![mesh.vertex_buffer],
-                        index_buffer: mesh.index_buffer,
-                        images: vec![texture],
-                    };
-                    self.ctx.apply_bindings(&bindings);
-                    self.ctx.draw(0, mesh.num_elements, 1);
-                }
-            }
-        }
-
-        let mut draw_calls: Vec<_> =
-            draw_call.dcs.iter().map(|key| (key, &self.draw_calls[key])).collect();
-        draw_calls.sort_unstable_by_key(|(_, dc)| dc.z_index);
-
-        for (dc_key, dc) in draw_calls {
-            if DEBUG_RENDER {
-                println!("{ws}drawcall {dc_key}");
-            }
-            self.draw_call(dc, indent + 1);
-        }
-
-        self.cursor = old_cursor;
-        self.apply_model();
-
-        self.view = old_view;
-        self.apply_view();
-    }
-}
-
-fn main() {
-    let mut conf = miniquad::conf::Conf {
-        high_dpi: true,
-        window_resizable: true,
-        platform: miniquad::conf::Platform {
-            linux_backend: miniquad::conf::LinuxBackend::WaylandWithX11Fallback,
-            wayland_use_fallback_decorations: false,
-            //blocking_event_loop: true,
-            ..Default::default()
-        },
-        ..Default::default()
-    };
-    let metal = std::env::args().nth(1).as_deref() == Some("metal");
-    conf.platform.apple_gfx_api =
-        if metal { conf::AppleGfxApi::Metal } else { conf::AppleGfxApi::OpenGl };
-
-    miniquad::start(conf, || Box::new(Stage::new()));
-}
-
-mod shader {
-    use super::*;
-
-    pub const GL_VERTEX: &str = r#"#version 100
-    attribute vec2 in_pos;
-    attribute vec4 in_color;
-    attribute vec2 in_uv;
-
-    varying lowp vec4 color;
-    varying lowp vec2 uv;
-
-    uniform mat4 Projection;
-    uniform mat4 Model;
-
-    void main() {
-        gl_Position = Projection * Model * vec4(in_pos, 0, 1);
-        color = in_color;
-        uv = in_uv;
-    }"#;
-
-    pub const GL_FRAGMENT: &str = r#"#version 100
-    varying lowp vec4 color;
-    varying lowp vec2 uv;
-
-    uniform sampler2D tex;
-
-    void main() {
-        gl_FragColor = color * texture2D(tex, uv);
-    }"#;
-
-    pub const METAL: &str = r#"
-    #include <metal_stdlib>
-
-    using namespace metal;
-
-    struct Uniforms
-    {
-        float4x4 Projection;
-        float4x4 Model;
-    };
-
-    struct Vertex
-    {
-        float2 in_pos   [[attribute(0)]];
-        float4 in_color [[attribute(1)]];
-        float2 in_uv    [[attribute(2)]];
-    };
-
-    struct RasterizerData
-    {
-        float4 position [[position]];
-        float4 color [[user(locn0)]];
-        float2 uv [[user(locn1)]];
-    };
-
-    vertex RasterizerData vertexShader(Vertex v [[stage_in]])
-    {
-        RasterizerData out;
-
-        out.position = uniforms.Model * uniforms.Projection * float4(v.in_pos.xy, 0.0, 1.0);
-        out.color = v.in_color;
-        out.uv = v.texcoord;
-
-        return out;
-    }
-
-    fragment float4 fragmentShader(RasterizerData in [[stage_in]], texture2d<float> tex [[texture(0)]], sampler texSmplr [[sampler(0)]])
-    {
-        return in.color * tex.sample(texSmplr, in.uv);
-    }
-
-    "#;
-
-    pub fn meta() -> ShaderMeta {
-        ShaderMeta {
-            images: vec!["tex".to_string()],
-            uniforms: UniformBlockLayout { uniforms: vec![] },
-        }
-    }
-}

+ 2 - 2
bin/app/pydrk/api.py

@@ -648,9 +648,9 @@ class Api:
             sigs.append(serial.decode_str(cur))
         return sigs
 
-    def register_slot(self, node_id, sig_name, slot_name, user_data):
+    def register_slot(self, node_path, sig_name, slot_name, user_data):
         req = bytearray()
-        serial.write_u32(req, node_id)
+        serial.encode_str(req, node_path)
         serial.encode_str(req, sig_name)
         serial.encode_str(req, slot_name)
         serial.encode_varint(req, len(user_data))

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

@@ -1,47 +0,0 @@
-#!/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)
-

+ 0 - 0
bin/app/echo.py → bin/app/script/echo.py


+ 1 - 0
bin/app/script/pydrk

@@ -0,0 +1 @@
+../pydrk

+ 40 - 0
bin/app/script/recv_darkirc_msgs.py

@@ -0,0 +1,40 @@
+#!/usr/bin/python3
+import zmq
+from pydrk import api, serial
+from datetime import datetime
+
+api_client = api.Api(addr="127.0.0.1", port=9484)
+
+context = zmq.Context()
+pub_socket = context.socket(zmq.SUB)
+pub_socket.connect("tcp://127.0.0.1:9485")
+pub_socket.setsockopt(zmq.SUBSCRIBE, b"")
+
+node_path = "/plugin/darkirc"
+sig_name = "recv"
+slot_name = "python_listener"
+user_data = b"darkirc_recv"
+
+slot_id = api_client.register_slot(node_path, sig_name, slot_name, user_data)
+print(f"Registered slot ID: {slot_id}")
+print("Listening...")
+print("=" * 80)
+
+while True:
+    parts = pub_socket.recv_multipart()
+    assert len(parts) == 2
+    signal_data, recv_user_data = parts
+    assert recv_user_data == user_data
+
+    cur = serial.Cursor(signal_data)
+    channel = serial.decode_str(cur)
+    timestamp = serial.read_u64(cur)
+    msg_id_bytes = cur.read(32)
+    msg_id = msg_id_bytes.hex()
+    nick = serial.decode_str(cur)
+    msg = serial.decode_str(cur)
+
+    dt = datetime.fromtimestamp(timestamp / 1000.0)
+    print(f"[{dt.strftime('%Y-%m-%d %H:%M:%S')}] #{channel} <{nick}> {msg}")
+    print(f"  Message ID: {msg_id}")
+    print("-" * 80)

+ 0 - 326
bin/app/script/traxator.py

@@ -1,326 +0,0 @@
-#!/usr/bin/python
-from pydrk import serial
-from collections import namedtuple
-from dataclasses import dataclass
-from typing import Union
-import sys
-
-@dataclass
-class SetScale:
-    scale: float
-
-@dataclass
-class Move:
-    x: float
-    y: float
-
-@dataclass
-class SetPos:
-    x: float
-    y: float
-
-@dataclass
-class ApplyView:
-    x: float
-    y: float
-    w: float
-    h: float
-
-@dataclass
-class Draw:
-    vert_id: int
-    vert_epoch: int
-    vert_tag: str
-    vert_buftype: int
-    index_id: int
-    index_epoch: int
-    index_tag: str
-    index_buftype: int
-    tex: (int, int, str)
-    num_elements: int
-
-Instr = Union[SetScale, Move, SetPos, ApplyView, Draw]
-
-def hex(dat):
-    return " ".join(f"{b:02x}" for b in dat)
-
-DrawCall = namedtuple("DrawCall", [
-    "dc_id",
-    "instrs",
-    "dcs",
-    "z_index",
-    "debug_str"
-])
-
-def read_dc(cur):
-    dc_id = serial.read_u64(cur)
-    instrs = serial.decode_arr(cur, read_instr)
-    dcs = serial.decode_arr(cur, serial.read_u64)
-    z_index = serial.read_u32(cur)
-    debug_str = serial.decode_str(cur)
-    return DrawCall(
-        dc_id,
-        instrs,
-        dcs,
-        z_index,
-        debug_str
-    )
-
-def read_instr(cur):
-    enum = serial.read_u8(cur)
-    match enum:
-        case 0:
-            scale = serial.read_f32(cur)
-            return SetScale(scale)
-        case 1:
-            x = serial.read_f32(cur)
-            y = serial.read_f32(cur)
-            return Move(x, y)
-        case 2:
-            x = serial.read_f32(cur)
-            y = serial.read_f32(cur)
-            #print(f"  set_pos x={x}, y={y}")
-            return SetPos(x, y)
-        case 3:
-            x = serial.read_f32(cur)
-            y = serial.read_f32(cur)
-            w = serial.read_f32(cur)
-            h = serial.read_f32(cur)
-            #print(f"  apply_view x={x}, y={y}, w={w}, h={h}")
-            return ApplyView(x, y, w, h)
-        case 4:
-            vert_id = serial.read_u32(cur)
-            vert_epoch = serial.read_u32(cur)
-            vert_tag = serial.decode_opt(cur, serial.decode_str)
-            vert_buftype = serial.read_u8(cur)
-            index_id = serial.read_u32(cur)
-            index_epoch = serial.read_u32(cur)
-            index_tag = serial.decode_opt(cur, serial.decode_str)
-            index_buftype = serial.read_u8(cur)
-            def read_tex(cur):
-                id = serial.read_u32(cur)
-                epoch = serial.read_u32(cur)
-                tag = serial.decode_opt(cur, serial.decode_str)
-                return (id, epoch, tag)
-            tex = serial.decode_opt(cur, read_tex)
-            num_elements = serial.read_i32(cur)
-            return Draw(
-                vert_id,
-                vert_epoch,
-                vert_tag,
-                vert_buftype,
-                index_id,
-                index_epoch,
-                index_tag,
-                index_buftype,
-                tex,
-                num_elements
-            )
-        case _:
-            raise NotImplementedError
-
-@dataclass
-class Vertex:
-    x: float
-    y: float
-    r: float
-    g: float
-    b: float
-    a: float
-    u: float
-    v: float
-
-@dataclass
-class PutDrawCall:
-    epoch: int
-    batch_id: int
-    timest: int
-    dcs: [DrawCall]
-    stats: [int]
-
-@dataclass
-class PutStartBatch:
-    epoch: int
-    batch_id: int
-    debug_str: str
-    stat: int
-
-@dataclass
-class PutEndBatch:
-    epoch: int
-    batch_id: int
-    stat: int
-
-@dataclass
-class PutTex:
-    epoch: int
-    tex: int
-    tag: str
-    stat: int
-
-@dataclass
-class PutVerts:
-    epoch: int
-    verts: [Vertex]
-    buf: int
-    tag: str
-    buftype: int
-    stat: int
-
-@dataclass
-class PutIdxs:
-    epoch: int
-    idxs: [int]
-    buf: int
-    tag: str
-    buftype: int
-    stat: int
-
-@dataclass
-class DelTex:
-    epoch: int
-    buf: int
-    tag: str
-    stat: int
-
-@dataclass
-class DelBuf:
-    epoch: int
-    buf: int
-    tag: str
-    buftype: int
-    stat: int
-
-@dataclass
-class SetCurr:
-    dc: int
-
-@dataclass
-class SetInstr:
-    idx: int
-
-Section = Union[PutDrawCall, PutTex, PutVerts, PutIdxs, DelTex, DelBuf, SetCurr, SetInstr]
-
-def read_vert(cur):
-    return Vertex(
-        serial.read_f32(cur),
-        serial.read_f32(cur),
-        serial.read_f32(cur),
-        serial.read_f32(cur),
-        serial.read_f32(cur),
-        serial.read_f32(cur),
-        serial.read_f32(cur),
-        serial.read_f32(cur),
-    )
-
-def read_section(f):
-    fpos = f.tell()
-    buf = serial.decode_buf(f)
-    if not buf:
-        return None
-    cur = serial.Cursor(buf)
-    c = serial.read_u8(cur)
-    #print(f"SECTION: {c} {len(buf)}B [{fpos}]")
-    #print(hex(cur.by))
-    match c:
-        case 0:
-            epoch = serial.read_u32(cur)
-            batch_id = serial.read_u32(cur)
-            timest = serial.read_u64(cur)
-            dcs = serial.decode_arr(cur, read_dc)
-            stats = []
-            for _ in dcs:
-                stat = serial.read_u8(cur)
-                stats.append(stat)
-                #print(f"  stat={stat}")
-            #print(f"put_dcs epoch={epoch}, batch_id={batch_id}, timest={timest}, dcs={dcs}, stats={stats}")
-            sect = PutDrawCall(epoch, batch_id, timest, dcs, stats)
-        case 1:
-            epoch = serial.read_u32(cur)
-            batch_id = serial.read_u32(cur)
-            debug_str = serial.decode_opt(cur, serial.decode_str)
-            stat = serial.read_u8(cur)
-            #print(f"put_start_batch epoch={epoch}, batch_id={batch_id}, stat={stat}")
-            sect = PutStartBatch(epoch, batch_id, debug_str, stats)
-        case 2:
-            epoch = serial.read_u32(cur)
-            batch_id = serial.read_u32(cur)
-            stat = serial.read_u8(cur)
-            #print(f"put_end_batch epoch={epoch}, batch_id={batch_id}, stat={stat}")
-            sect = PutEndBatch(epoch, batch_id, stats)
-        case 3:
-            epoch = serial.read_u32(cur)
-            tex = serial.read_u32(cur)
-            tag = serial.decode_opt(cur, serial.decode_str)
-            stat = serial.read_u8(cur)
-            #print(f"put_tex epoch={epoch}, tex={tex}, tag='{tag}', stat={stat}")
-            sect = PutTex(epoch, tex, tag, stat)
-        case 4:
-            epoch = serial.read_u32(cur)
-            verts = serial.decode_arr(cur, read_vert)
-            buf = serial.read_u32(cur)
-            tag = serial.decode_opt(cur, serial.decode_str)
-            buftype = serial.read_u8(cur)
-            stat = serial.read_u8(cur)
-            #print(f"put_verts epoch={epoch}, buf={buf}, tag='{tag}', buftype={buftype}, stat={stat}")
-            sect = PutVerts(epoch, verts, buf, tag, buftype, stat)
-        case 5:
-            epoch = serial.read_u32(cur)
-            idxs = serial.decode_arr(cur, serial.read_u16)
-            buf = serial.read_u32(cur)
-            tag = serial.decode_opt(cur, serial.decode_str)
-            buftype = serial.read_u8(cur)
-            stat = serial.read_u8(cur)
-            #print(f"put_idxs epoch={epoch}, buf={buf}, tag='{tag}', buftype={buftype}, stat={stat}")
-            sect = PutIdxs(epoch, idxs, buf, tag, buftype, stat)
-        case 6:
-            epoch = serial.read_u32(cur)
-            buf = serial.read_u32(cur)
-            tag = serial.decode_opt(cur, serial.decode_str)
-            stat = serial.read_u8(cur)
-            #print(f"del_tex epoch={epoch}, buf={buf}, tag='{tag}', stat={stat}")
-            sect = DelTex(epoch, buf, tag, stat)
-        case 7:
-            epoch = serial.read_u32(cur)
-            buf = serial.read_u32(cur)
-            tag = serial.decode_opt(cur, serial.decode_str)
-            buftype = serial.read_u8(cur)
-            stat = serial.read_u8(cur)
-            #print(f"del_buf epoch={epoch}, buf={buf}, tag='{tag}', buftype={buftype}, stat={stat}")
-            sect = DelBuf(epoch, buf, tag, buftype, stat)
-        case 8:
-            dc = serial.read_u64(cur)
-            #print(f"set_curr dc={dc}")
-            sect = SetCurr(dc)
-        case 9:
-            idx = serial.read_u64(cur)
-            #print(f"set_instr idx={idx}")
-            sect = SetInstr(idx)
-        case _:
-            raise NotImplementedError
-
-    # Crash out if we didn't fully consume the buffer
-    if not cur.is_end():
-        print(hex(cur.remain_data()))
-    assert cur.is_end()
-
-    return sect
-
-def read_trax(fname):
-    f = open(fname, "rb")
-    sections = []
-    while True:
-        if (sect := read_section(f)) is None:
-            break
-        sections.append(sect)
-    return sections
-
-if __name__ == "__main__":
-    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)
-

+ 0 - 48
bin/app/script/view.py

@@ -1,48 +0,0 @@
-#!/usr/bin/python
-from traxator import *
-import math
-
-dc_id = 2767617242841734550
-vert_id = 39568
-idx_id = 39569
-
-sections = read_trax("trax.dat")
-for sect in sections:
-    match sect:
-        case PutDrawCall(_, _, dcs, stats):
-            for dc in dcs:
-                if dc.dc_id == dc_id:
-                    print(f"DrawCall {dc_id}")
-                    for (i, instr) in enumerate(dc.instrs):
-                        print(f"  {i}. {instr}")
-                    print()
-        case PutVerts(_, verts, buf, _, _, _):
-            if buf == vert_id:
-                print(f"Vert {vert_id}")
-                print("  n verts:", len(verts))
-                print(verts)
-                print()
-                #for v in verts:
-                #    assert not math.isnan(v.x)
-                #    assert not math.isnan(v.y)
-                #    assert not math.isnan(v.r)
-                #    assert not math.isnan(v.g)
-                #    assert not math.isnan(v.b)
-                #    assert not math.isnan(v.a)
-                #    assert not math.isnan(v.u)
-                #    assert not math.isnan(v.v)
-
-                #    assert not math.isinf(v.x)
-                #    assert not math.isinf(v.y)
-                #    assert not math.isinf(v.r)
-                #    assert not math.isinf(v.g)
-                #    assert not math.isinf(v.b)
-                #    assert not math.isinf(v.a)
-                #    assert not math.isinf(v.u)
-                #    assert not math.isinf(v.v)
-        case PutIdxs(_, idxs, buf, _, _, _):
-            if buf == idx_id:
-                print(f"Idx {idx_id}")
-                print(idxs)
-                print()
-

+ 0 - 119
bin/app/src/gfx/mod.rs

@@ -58,8 +58,6 @@ use prune::PruneMethodHeap;
 mod linalg;
 pub use linalg::{Dimension, Point, Rectangle, Segment, Vector};
 mod shader;
-mod trax;
-use trax::get_trax;
 
 use crate::{
     prop::{BatchGuardId, PropertyAtomicGuard},
@@ -71,7 +69,6 @@ use crate::{
 // This is very noisy so suppress output by default
 const DEBUG_RENDER: bool = false;
 const DEBUG_GFXAPI: bool = false;
-const DEBUG_TRAX: bool = false;
 
 #[macro_export]
 macro_rules! gfxtag {
@@ -363,9 +360,6 @@ impl<'a> RenderContext<'a> {
             let screen_size = miniquad::window::screen_size();
             d!("RenderContext::draw() [screen_size={screen_size:?}]");
         }
-        if DEBUG_TRAX {
-            get_trax().lock().set_curr(0);
-        }
         self.draw_call(&self.draw_calls[&0], 0, DEBUG_RENDER);
         if DEBUG_RENDER {
             d!("RenderContext::draw() [DONE]");
@@ -463,9 +457,6 @@ impl<'a> RenderContext<'a> {
         let old_pipeline = self.gfx_pipeline;
 
         for (idx, instr) in draw_call.instrs.iter().enumerate() {
-            if DEBUG_TRAX {
-                get_trax().lock().set_instr(idx);
-            }
             match instr {
                 GfxDrawInstruction::SetScale(scale) => {
                     self.scale = *scale;
@@ -573,9 +564,6 @@ impl<'a> RenderContext<'a> {
         draw_calls.sort_unstable_by_key(|(_, dc)| dc.z_index);
 
         for (dc_key, dc) in draw_calls {
-            if DEBUG_TRAX {
-                get_trax().lock().set_curr(*dc_key);
-            }
             if is_debug {
                 d!("{ws}drawcall {dc_key}");
             }
@@ -633,9 +621,6 @@ struct Stage {
 
 impl Stage {
     pub fn new() -> Self {
-        if DEBUG_TRAX {
-            get_trax().lock().clear();
-        }
         let mut ctx: Box<dyn RenderingBackend> = window::new_rendering_backend();
 
         let god = GOD.get().unwrap();
@@ -735,9 +720,6 @@ impl Stage {
                         self.method_replace_draw_calls(timest, dcs);
                     }
                 }
-                if DEBUG_TRAX {
-                    get_trax().lock().put_stat(0);
-                }
             }
             GraphicsMethod::StartBatch { batch_id, tag } => {
                 if DEBUG_GFXAPI {
@@ -746,9 +728,6 @@ impl Stage {
                 if !self.pending_batches.insert(*batch_id, vec![]).is_none() {
                     panic!("batch {batch_id} already open!")
                 }
-                if DEBUG_TRAX {
-                    get_trax().lock().put_stat(0);
-                }
             }
             GraphicsMethod::EndBatch { batch_id, timest } => {
                 if self.dropped_batches.remove(batch_id) {
@@ -816,29 +795,17 @@ impl Stage {
             //       ansi_texture(width as usize, height as usize, &data));
         }
         if let Some(_) = self.textures.insert(gfx_texture_id, texture) {
-            if DEBUG_TRAX {
-                get_trax().lock().put_stat(2);
-            }
             panic!("Duplicate texture ID={gfx_texture_id} detected!");
         }
-        if DEBUG_TRAX {
-            get_trax().lock().put_stat(0);
-        }
     }
     pub(self) fn method_delete_texture(&mut self, gfx_texture_id: TextureId) {
         let Some(texture) = self.textures.remove(&gfx_texture_id) else {
-            if DEBUG_TRAX {
-                get_trax().lock().put_stat(2);
-            }
             panic!("unknown texture {gfx_texture_id}")
         };
         if DEBUG_GFXAPI {
             d!("Invoked method: delete_texture({gfx_texture_id} => {texture:?})");
         }
         self.ctx.delete_texture(texture);
-        if DEBUG_TRAX {
-            get_trax().lock().put_stat(0);
-        }
     }
     pub(self) fn method_new_vertex_buffer(&mut self, verts: &[Vertex], gfx_buffer_id: BufferId) {
         let buffer = self.ctx.new_buffer(
@@ -852,14 +819,8 @@ impl Stage {
             //       verts, gfx_buffer_id, buffer);
         }
         if let Some(_) = self.buffers.insert(gfx_buffer_id, buffer) {
-            if DEBUG_TRAX {
-                get_trax().lock().put_stat(2);
-            }
             panic!("Duplicate vertex buffer ID={gfx_buffer_id} detected!")
         }
-        if DEBUG_TRAX {
-            get_trax().lock().put_stat(0);
-        }
     }
     pub(self) fn method_new_index_buffer(&mut self, indices: &[u16], gfx_buffer_id: BufferId) {
         let buffer = self.ctx.new_buffer(
@@ -873,29 +834,17 @@ impl Stage {
             //       indices, gfx_buffer_id, buffer);
         }
         if let Some(_) = self.buffers.insert(gfx_buffer_id, buffer) {
-            if DEBUG_TRAX {
-                get_trax().lock().put_stat(2);
-            }
             panic!("Duplicate index buffer ID={gfx_buffer_id} detected!")
         }
-        if DEBUG_TRAX {
-            get_trax().lock().put_stat(0);
-        }
     }
     pub(self) fn method_delete_buffer(&mut self, gfx_buffer_id: BufferId) {
         let Some(buffer) = self.buffers.remove(&gfx_buffer_id) else {
-            if DEBUG_TRAX {
-                get_trax().lock().put_stat(2);
-            }
             panic!("unknown buffer {gfx_buffer_id}");
         };
         if DEBUG_GFXAPI {
             d!("Invoked method: delete_buffer({gfx_buffer_id} => {buffer:?})");
         }
         self.ctx.delete_buffer(buffer);
-        if DEBUG_TRAX {
-            get_trax().lock().put_stat(0);
-        }
     }
     pub(self) fn method_new_anim(&mut self, gfx_anim_id: AnimId, frames_len: usize, oneshot: bool) {
         if DEBUG_GFXAPI {
@@ -940,9 +889,6 @@ impl Stage {
                 if old_val.timest > batch_timest {
                     // Entire batch is stale, reject all
                     t!("Rejected stale batch {batch_timest}: conflict with newer batch {} on {key}", old_val.timest);
-                    if DEBUG_TRAX {
-                        get_trax().lock().put_stat(3); // New stat: rejected batch
-                    }
                     return;
                 }
             }
@@ -957,55 +903,9 @@ impl Stage {
 
             // Insert/replace draw call
             self.draw_calls.insert(key, val);
-
-            if DEBUG_TRAX {
-                get_trax().lock().put_stat(1); // Success
-            }
         }
     }
 
-    fn trax_method(&self, epoch: EpochIndex, method: &GraphicsMethod) {
-        let mut trax = get_trax().lock();
-        match method {
-            GraphicsMethod::NewTexture((_, _, _, _, gtex_id, tag)) => {
-                trax.put_tex(epoch, *gtex_id, *tag);
-            }
-            GraphicsMethod::DeleteTexture((gtex_id, tag)) => {
-                trax.del_tex(epoch, *gtex_id, *tag);
-            }
-            GraphicsMethod::NewVertexBuffer((verts, gbuff_id, tag)) => {
-                trax.put_verts(epoch, verts.clone(), *gbuff_id, *tag, 0);
-            }
-            GraphicsMethod::NewIndexBuffer((idxs, gbuff_id, tag)) => {
-                trax.put_idxs(epoch, idxs.clone(), *gbuff_id, *tag, 1);
-            }
-            GraphicsMethod::DeleteBuffer((gbuff_id, tag, buftype)) => {
-                trax.del_buf(epoch, *gbuff_id, *tag, *buftype);
-            }
-            GraphicsMethod::NewSeqAnim { .. } => {
-                //trax.put_idxs(epoch, idxs.clone(), *gbuff_id, *tag, 1);
-            }
-            GraphicsMethod::UpdateSeqAnim { .. } => {
-                //trax.put_idxs(epoch, idxs.clone(), *gbuff_id, *tag, 1);
-            }
-            GraphicsMethod::DeleteSeqAnim(..) => {
-                //trax.del_buf(epoch, *gbuff_id, *tag, *buftype);
-            }
-            GraphicsMethod::ReplaceGfxDrawCalls { batch_id, dcs } => {
-                if let Some(bid) = batch_id {
-                    trax.put_dcs(epoch, *bid, dcs);
-                }
-            }
-            GraphicsMethod::StartBatch { batch_id, tag } => {
-                trax.put_start_batch(epoch, *batch_id, *tag);
-            }
-            GraphicsMethod::EndBatch { batch_id, timest: _ } => {
-                trax.put_end_batch(epoch, *batch_id);
-            }
-            GraphicsMethod::Noop => panic!("noop"),
-        };
-    }
-
     fn egl_ctx_is_disabled(&self) -> bool {
         #[cfg(target_os = "android")]
         {
@@ -1020,15 +920,7 @@ impl Stage {
     fn process_methods(&mut self) {
         // Process as many methods as we can
         while let Ok((epoch, method)) = self.method_recv.try_recv() {
-            if DEBUG_TRAX {
-                self.trax_method(epoch, &method);
-            }
             if epoch < self.epoch {
-                if DEBUG_TRAX {
-                    let mut trax = get_trax().lock();
-                    trax.put_stat(1);
-                    trax.flush();
-                }
                 // Discard old rubbish
                 t!(
                     "Discard method with old epoch: {epoch} curr: {} [method={method:?}]",
@@ -1038,9 +930,6 @@ impl Stage {
             }
             assert_eq!(epoch, self.epoch);
             self.process_method(method);
-            if DEBUG_TRAX {
-                get_trax().lock().flush();
-            }
         }
     }
 
@@ -1050,11 +939,6 @@ impl Stage {
         assert!(self.pending_batches.is_empty());
         // Process all cached methods by the pruner from while the screen was off.
         for method in methods {
-            // Stale methods will be dropped by pruner, so they will not be caught by trax
-            // while the screen is off.
-            if DEBUG_TRAX {
-                self.trax_method(self.epoch, &method);
-            }
             // We discard batches here but process_method uses them so implement this
             // workaround.
             match method {
@@ -1075,9 +959,6 @@ impl Stage {
 
                 GraphicsMethod::Noop => panic!("noop"),
             }
-            if DEBUG_TRAX {
-                get_trax().lock().flush();
-            }
         }
 
         // Trigger a full screen redraw by sending a resize event

+ 0 - 169
bin/app/src/gfx/trax.rs

@@ -1,169 +0,0 @@
-/* This file is part of DarkFi (https://dark.fi)
- *
- * Copyright (C) 2020-2026 Dyne.org foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
- */
-
-use darkfi_serial::Encodable;
-use parking_lot::Mutex as SyncMutex;
-use std::{fs::File, sync::OnceLock};
-use tracing::debug;
-
-use super::{BufferId, DebugTag, DrawCall, TextureId, Vertex};
-use crate::{prop::BatchGuardId, EpochIndex};
-
-macro_rules! d { ($($arg:tt)*) => { debug!(target: "gfx::trax", $($arg)*); } }
-
-pub struct Trax {
-    file: File,
-    buf: Vec<u8>,
-}
-
-impl Trax {
-    fn new() -> Self {
-        #[cfg(target_os = "android")]
-        let path = crate::android::get_external_storage_path().join("trax.dat");
-        #[cfg(not(target_os = "android"))] // FIXME:
-        let path = std::path::PathBuf::from(std::env::var("TMPDIR").unwrap()).join("trax.dat");
-
-        let file = File::create(path).unwrap();
-        Self { file, buf: vec![] }
-    }
-
-    pub fn clear(&mut self) {
-        d!("clear");
-        self.file.set_len(0).unwrap();
-    }
-
-    pub fn put_dcs(
-        &mut self,
-        epoch: EpochIndex,
-        batch_id: BatchGuardId,
-        dcs: &Vec<(u64, DrawCall)>,
-    ) {
-        d!("put_dcs({epoch}, {batch_id}, {dcs:?})");
-        0u8.encode(&mut self.buf).unwrap();
-        epoch.encode(&mut self.buf).unwrap();
-        batch_id.encode(&mut self.buf).unwrap();
-        //dcs.encode(&mut self.buf).unwrap();
-    }
-
-    pub fn put_start_batch(
-        &mut self,
-        epoch: EpochIndex,
-        batch_id: BatchGuardId,
-        debug_str: Option<&'static str>,
-    ) {
-        d!("put_start_batch({epoch}, {batch_id})");
-        1u8.encode(&mut self.buf).unwrap();
-        batch_id.encode(&mut self.buf).unwrap();
-        debug_str.encode(&mut self.buf).unwrap();
-    }
-
-    pub fn put_end_batch(&mut self, epoch: EpochIndex, batch_id: BatchGuardId) {
-        d!("put_end_batch({epoch}, {batch_id})");
-        2u8.encode(&mut self.buf).unwrap();
-        batch_id.encode(&mut self.buf).unwrap();
-    }
-
-    pub fn put_tex(&mut self, epoch: EpochIndex, tex: TextureId, tag: DebugTag) {
-        d!("put_tex({epoch}, {tex}, {tag:?})");
-        3u8.encode(&mut self.buf).unwrap();
-        epoch.encode(&mut self.buf).unwrap();
-        tex.encode(&mut self.buf).unwrap();
-        tag.encode(&mut self.buf).unwrap();
-    }
-    pub fn put_verts(
-        &mut self,
-        epoch: EpochIndex,
-        verts: Vec<Vertex>,
-        buf: BufferId,
-        tag: DebugTag,
-        buftype: u8,
-    ) {
-        d!("put_verts({epoch}, ..., {buf}, {tag:?}, {buftype})");
-        4u8.encode(&mut self.buf).unwrap();
-        epoch.encode(&mut self.buf).unwrap();
-        verts.encode(&mut self.buf).unwrap();
-        buf.encode(&mut self.buf).unwrap();
-        tag.encode(&mut self.buf).unwrap();
-        buftype.encode(&mut self.buf).unwrap();
-    }
-    pub fn put_idxs(
-        &mut self,
-        epoch: EpochIndex,
-        idxs: Vec<u16>,
-        buf: BufferId,
-        tag: DebugTag,
-        buftype: u8,
-    ) {
-        d!("put_idxs({epoch}, ..., {buf}, {tag:?}, {buftype})");
-        5u8.encode(&mut self.buf).unwrap();
-        epoch.encode(&mut self.buf).unwrap();
-        idxs.encode(&mut self.buf).unwrap();
-        buf.encode(&mut self.buf).unwrap();
-        tag.encode(&mut self.buf).unwrap();
-        buftype.encode(&mut self.buf).unwrap();
-    }
-    pub fn del_tex(&mut self, epoch: EpochIndex, tex: TextureId, tag: DebugTag) {
-        d!("del_tex({epoch}, {tex}, {tag:?})");
-        6u8.encode(&mut self.buf).unwrap();
-        epoch.encode(&mut self.buf).unwrap();
-        tex.encode(&mut self.buf).unwrap();
-        tag.encode(&mut self.buf).unwrap();
-    }
-    pub fn del_buf(&mut self, epoch: EpochIndex, buf: BufferId, tag: DebugTag, buftype: u8) {
-        d!("del_buf({epoch}, {buf}, {tag:?}, {buftype})");
-        7u8.encode(&mut self.buf).unwrap();
-        epoch.encode(&mut self.buf).unwrap();
-        buf.encode(&mut self.buf).unwrap();
-        tag.encode(&mut self.buf).unwrap();
-        buftype.encode(&mut self.buf).unwrap();
-    }
-
-    pub fn set_curr(&mut self, dc: u64) {
-        d!("set_curr({dc})");
-        8u8.encode(&mut self.buf).unwrap();
-        dc.encode(&mut self.buf).unwrap();
-        self.flush();
-    }
-    pub fn set_instr(&mut self, idx: usize) {
-        d!("set_instr({idx})");
-        9u8.encode(&mut self.buf).unwrap();
-        idx.encode(&mut self.buf).unwrap();
-        self.flush();
-    }
-
-    pub fn put_stat(&mut self, code: u8) {
-        d!("put_stat({code})");
-        code.encode(&mut self.buf).unwrap();
-    }
-
-    pub fn flush(&mut self) {
-        d!("flush");
-        let buf = std::mem::take(&mut self.buf);
-        if buf.is_empty() {
-            d!(" -> skipping flush");
-            return
-        }
-        buf.encode(&mut self.file).unwrap();
-    }
-}
-
-static TRAX: OnceLock<SyncMutex<Trax>> = OnceLock::new();
-
-pub(super) fn get_trax() -> &'static SyncMutex<Trax> {
-    TRAX.get_or_init(|| SyncMutex::new(Trax::new()))
-}

+ 8 - 10
bin/app/src/net.rs

@@ -26,7 +26,7 @@ use crate::{
     expr::SExprCode,
     gfx::{gfxtag, Renderer},
     prop::{PropertyType, Role},
-    scene::{SceneNodeId, SceneNodePtr, ScenePath},
+    scene::{SceneNodeId, SceneNodePtr, ScenePath, Slot},
     ExecutorPtr,
 };
 
@@ -79,10 +79,10 @@ pub struct ZeroMQAdapter {
     */
     sg_root: SceneNodePtr,
     renderer: Renderer,
-    _ex: ExecutorPtr,
+    ex: ExecutorPtr,
 
     zmq_rep: Mutex<zeromq::RepSocket>,
-    _zmq_pub: Mutex<zeromq::PubSocket>,
+    zmq_pub: Mutex<zeromq::PubSocket>,
 }
 
 impl ZeroMQAdapter {
@@ -104,9 +104,9 @@ impl ZeroMQAdapter {
         Arc::new(Self {
             sg_root,
             renderer,
-            _ex: ex,
+            ex,
             zmq_rep: Mutex::new(zmq_rep),
-            _zmq_pub: Mutex::new(zmq_pub),
+            zmq_pub: Mutex::new(zmq_pub),
         })
     }
 
@@ -465,14 +465,13 @@ impl ZeroMQAdapter {
                 sig_names.encode(&mut reply).unwrap();
             }
             Command::RegisterSlot => {
-                /*
-                let node_id = SceneNodeId::decode(&mut cur).unwrap();
+                let node_path: ScenePath = String::decode(&mut cur).unwrap().parse()?;
                 let sig_name = String::decode(&mut cur).unwrap();
                 let slot_name = String::decode(&mut cur).unwrap();
                 let user_data = Vec::<u8>::decode(&mut cur).unwrap();
-                debug!(target: "req", "{:?}({}, {}, {}, {:?})", cmd, node_id, sig_name, slot_name, user_data);
+                debug!(target: "req", "{cmd:?}({node_path}, {sig_name}, {slot_name}, {user_data:?})");
 
-                let node = scene_graph.get_node_mut(node_id).ok_or(Error::NodeNotFound)?;
+                let node = self.sg_root.lookup_node(node_path).ok_or(Error::NodeNotFound)?;
 
                 let (sendr, recvr) = async_channel::unbounded();
                 let slot = Slot { name: slot_name, notify: sendr };
@@ -497,7 +496,6 @@ impl ZeroMQAdapter {
 
                 let slot_id = node.register(&sig_name, slot)?;
                 slot_id.encode(&mut reply).unwrap();
-                */
             }
             Command::UnregisterSlot => {
                 /*