rrtrace 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +36 -0
- data/.github/workflows/ci.yml +94 -0
- data/.github/workflows/release.yml +4 -4
- data/Cargo.lock +26 -30
- data/Cargo.toml +8 -4
- data/README.md +77 -16
- data/exe/rrtrace +16 -0
- data/ext/rrtrace/process_manager_posix.h +18 -2
- data/ext/rrtrace/process_manager_windows.h +14 -0
- data/ext/rrtrace/rrtrace.c +153 -44
- data/ext/rrtrace/rrtrace_event.h +6 -15
- data/ext/rrtrace/rrtrace_event_ringbuffer.h +2 -2
- data/ext/rrtrace/shared_memory_posix.h +57 -5
- data/ext/rrtrace/shared_memory_windows.h +38 -3
- data/ext/rrtrace/time_posix.h +29 -0
- data/ext/rrtrace/time_windows.h +33 -0
- data/lib/rrtrace/run.rb +5 -0
- data/lib/rrtrace/version.rb +1 -1
- data/lib/rrtrace.rb +31 -3
- data/libexec/rrtrace +0 -0
- data/mise.toml +5 -2
- data/sig/rrtrace.rbs +3 -0
- data/src/main.rs +114 -32
- data/src/object_scatter.rs +110 -0
- data/src/oneshot_channel.rs +74 -0
- data/src/renderer/vertex_arena.rs +17 -13
- data/src/renderer.rs +268 -37
- data/src/ringbuffer.rs +2 -2
- data/src/shader.wgsl +160 -115
- data/src/trace_state.rs +500 -119
- data/src/universal_notifier.rs +31 -0
- data/taplo.toml +4 -0
- metadata +14 -3
data/src/shader.wgsl
CHANGED
|
@@ -1,115 +1,160 @@
|
|
|
1
|
-
struct Vertex {
|
|
2
|
-
@location(0) position: vec3<f32>,
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
struct CallBox {
|
|
6
|
-
@location(1) start_time: vec2<u32>,
|
|
7
|
-
@location(2) end_time: vec2<u32>,
|
|
8
|
-
@location(3) method_id: u32,
|
|
9
|
-
@location(4) depth: u32,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
struct GCBox {
|
|
13
|
-
@location(1) time: vec2<u32>,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
struct
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
fn
|
|
64
|
-
v
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
1
|
+
struct Vertex {
|
|
2
|
+
@location(0) position: vec3<f32>,
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
struct CallBox {
|
|
6
|
+
@location(1) start_time: vec2<u32>,
|
|
7
|
+
@location(2) end_time: vec2<u32>,
|
|
8
|
+
@location(3) method_id: u32,
|
|
9
|
+
@location(4) depth: u32,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
struct GCBox {
|
|
13
|
+
@location(1) time: vec2<u32>,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
struct LineVertex {
|
|
17
|
+
@location(0) position: f32,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
struct LineSegment {
|
|
21
|
+
@location(1) start_time: vec2<u32>,
|
|
22
|
+
@location(2) end_time: vec2<u32>,
|
|
23
|
+
@location(3) start_pos: vec3<f32>,
|
|
24
|
+
@location(4) end_pos: vec3<f32>,
|
|
25
|
+
@location(5) color: vec4<f32>,
|
|
26
|
+
@location(6) kind: u32,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
struct CameraUniform {
|
|
30
|
+
view_proj: mat4x4<f32>,
|
|
31
|
+
base_time: vec2<u32>, // x: lo, y: hi
|
|
32
|
+
max_depth: u32,
|
|
33
|
+
num_threads: u32,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
struct ThreadInfo {
|
|
37
|
+
lane_id: u32,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@group(0) @binding(0)
|
|
41
|
+
var<uniform> camera: CameraUniform;
|
|
42
|
+
|
|
43
|
+
@group(0) @binding(1)
|
|
44
|
+
var<uniform> thread_info: ThreadInfo;
|
|
45
|
+
|
|
46
|
+
struct VertexOutput {
|
|
47
|
+
@builtin(position) clip_position: vec4<f32>,
|
|
48
|
+
@location(0) color: vec4<f32>,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
fn sub64(a: vec2<u32>, b: vec2<u32>) -> vec2<u32> {
|
|
52
|
+
if (a.x < b.x) {
|
|
53
|
+
let lo = a.x + 0x80000000u - b.x;
|
|
54
|
+
let hi = a.y - 1 - b.y;
|
|
55
|
+
return vec2<u32>(lo, hi);
|
|
56
|
+
} else {
|
|
57
|
+
let lo = a.x - b.x;
|
|
58
|
+
let hi = a.y - b.y;
|
|
59
|
+
return vec2<u32>(lo, hi);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
fn u64tof32(v: vec2<u32>) -> f32 {
|
|
64
|
+
return f32(v.y) * 2147483648.0 + f32(v.x);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
fn get_color(method_id: u32) -> vec4<f32> {
|
|
68
|
+
let m = method_id;
|
|
69
|
+
let r = f32((m * 123u) % 255u) / 255.0;
|
|
70
|
+
let g = f32((m * 456u) % 255u) / 255.0;
|
|
71
|
+
let b = f32((m * 789u) % 255u) / 255.0;
|
|
72
|
+
return vec4<f32>(r, g, b, 1.0);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@vertex
|
|
76
|
+
fn vs_main(
|
|
77
|
+
v: Vertex,
|
|
78
|
+
call: CallBox,
|
|
79
|
+
) -> VertexOutput {
|
|
80
|
+
var end_time: vec2<u32>;
|
|
81
|
+
if (call.end_time.y == 0xffffffffu) {
|
|
82
|
+
end_time = vec2<u32>(0, 0);
|
|
83
|
+
} else {
|
|
84
|
+
end_time = sub64(camera.base_time, call.end_time);
|
|
85
|
+
}
|
|
86
|
+
let start_time = sub64(camera.base_time, call.start_time);
|
|
87
|
+
|
|
88
|
+
let x = select(start_time, end_time, v.position.x > 0.5);
|
|
89
|
+
|
|
90
|
+
let world_pos = vec3<f32>(
|
|
91
|
+
u64tof32(x) / 500000000.0,
|
|
92
|
+
(f32(call.depth) + v.position.y) / f32(camera.max_depth),
|
|
93
|
+
(f32(thread_info.lane_id) + v.position.z) / f32(camera.num_threads),
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
var out: VertexOutput;
|
|
97
|
+
out.color = get_color(call.method_id);
|
|
98
|
+
out.clip_position = camera.view_proj * vec4<f32>(world_pos, 1.0);
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@fragment
|
|
103
|
+
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
|
|
104
|
+
return in.color;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@vertex
|
|
108
|
+
fn vs_line(
|
|
109
|
+
v: LineVertex,
|
|
110
|
+
segment: LineSegment,
|
|
111
|
+
) -> VertexOutput {
|
|
112
|
+
let t = v.position;
|
|
113
|
+
let start_x = select(
|
|
114
|
+
segment.start_pos.x,
|
|
115
|
+
u64tof32(sub64(camera.base_time, segment.start_time)) / 500000000.0,
|
|
116
|
+
segment.kind == 0u,
|
|
117
|
+
);
|
|
118
|
+
let end_x = select(
|
|
119
|
+
segment.end_pos.x,
|
|
120
|
+
u64tof32(sub64(camera.base_time, segment.end_time)) / 500000000.0,
|
|
121
|
+
segment.kind == 0u,
|
|
122
|
+
);
|
|
123
|
+
let world_pos = vec3<f32>(
|
|
124
|
+
mix(start_x, end_x, t),
|
|
125
|
+
mix(segment.start_pos.y, segment.end_pos.y, t),
|
|
126
|
+
mix(
|
|
127
|
+
segment.start_pos.z / f32(max(camera.num_threads, 1u)),
|
|
128
|
+
segment.end_pos.z / f32(max(camera.num_threads, 1u)),
|
|
129
|
+
t,
|
|
130
|
+
),
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
var out: VertexOutput;
|
|
134
|
+
out.color = segment.color;
|
|
135
|
+
out.clip_position = camera.view_proj * vec4<f32>(world_pos, 1.0);
|
|
136
|
+
return out;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
struct GCVertex {
|
|
140
|
+
@location(0) position: vec2<f32>,
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@vertex
|
|
144
|
+
fn vs_gc(
|
|
145
|
+
v: GCVertex,
|
|
146
|
+
gc: GCBox,
|
|
147
|
+
) -> VertexOutput {
|
|
148
|
+
let time = sub64(camera.base_time, gc.time);
|
|
149
|
+
|
|
150
|
+
let world_pos = vec3<f32>(
|
|
151
|
+
u64tof32(time) / 500000000.0,
|
|
152
|
+
v.position.x,
|
|
153
|
+
v.position.y,
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
var out: VertexOutput;
|
|
157
|
+
out.color = vec4<f32>(1.0, 0.5, 0.0, 0.1);
|
|
158
|
+
out.clip_position = camera.view_proj * vec4<f32>(world_pos, 1.0);
|
|
159
|
+
return out;
|
|
160
|
+
}
|