-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_struct.py
More file actions
61 lines (55 loc) · 1.56 KB
/
fix_struct.py
File metadata and controls
61 lines (55 loc) · 1.56 KB
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
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
import os
import glob
replacement = """struct AudioUniforms {
spectrum: array<vec4<f32>, 256>,
fire_heat: array<vec4<f32>, 256>,
channels: array<vec4<f32>, 8>,
channel_peaks: array<vec4<f32>, 8>,
spatial_channels: array<vec4<f32>, 4>,
num_channels: u32,
mode: u32,
time: f32,
duration: f32,
smooth_time: f32,
heatmap_row: u32,
fft_channels: u32,
num_spatial_channels: u32,
ui_meters_rect: vec4<f32>,
ui_heatmap_rect: vec4<f32>,
ui_fire_rect: vec4<f32>,
};"""
target = """struct AudioUniforms {
spectrum: array<vec4<f32>, 256>,
fire_heat: array<vec4<f32>, 256>,
channels: array<vec4<f32>, 8>,
channel_peaks: array<vec4<f32>, 8>,
num_channels: u32,
mode: u32,
time: f32,
duration: f32,
smooth_time: f32,
heatmap_row: u32,
_pad2: u32,
_pad3: u32,
ui_meters_rect: vec4<f32>,
ui_heatmap_rect: vec4<f32>,
ui_fire_rect: vec4<f32>,
};"""
target2 = target.replace("_pad2: u32,\n _pad3: u32,", "fft_channels: u32,\n _pad: u32,")
count = 0
for f in glob.glob("src/shaders/*.wgsl"):
if "vis_spatial" in f:
continue
with open(f, 'r') as file:
content = file.read()
if target in content:
content = content.replace(target, replacement)
with open(f, 'w') as file:
file.write(content)
count += 1
elif target2 in content:
content = content.replace(target2, replacement)
with open(f, 'w') as file:
file.write(content)
count += 1
print(f"Replaced in {count} files")