summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/seq_compiler.py37
1 files changed, 25 insertions, 12 deletions
diff --git a/tools/seq_compiler.py b/tools/seq_compiler.py
index fc07f84..18d5a1f 100755
--- a/tools/seq_compiler.py
+++ b/tools/seq_compiler.py
@@ -639,11 +639,7 @@ void RenderTimeline(WGPUSurface surface, float time, int width, int height,
// Clear source
WGPURenderPassColorAttachment clear_attach = {};
- clear_attach.view = g_source_view;
- clear_attach.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED;
- clear_attach.loadOp = WGPULoadOp_Clear;
- clear_attach.storeOp = WGPUStoreOp_Store;
- clear_attach.clearValue = {0.0, 0.0, 0.0, 1.0};
+ gpu_init_color_attachment(clear_attach, g_source_view);
WGPURenderPassDescriptor clear_desc = {};
clear_desc.colorAttachmentCount = 1;
@@ -662,13 +658,10 @@ void RenderTimeline(WGPUSurface surface, float time, int width, int height,
if (surface_texture.status == WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal) {
WGPURenderPassColorAttachment blit_attach = {};
- blit_attach.view = surface_texture.texture
+ WGPUTextureView blit_view = surface_texture.texture
? wgpuTextureCreateView(surface_texture.texture, nullptr)
: nullptr;
- blit_attach.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED;
- blit_attach.loadOp = WGPULoadOp_Clear;
- blit_attach.storeOp = WGPUStoreOp_Store;
- blit_attach.clearValue = {0.0, 0.0, 0.0, 1.0};
+ gpu_init_color_attachment(blit_attach, blit_view);
WGPURenderPassDescriptor blit_desc = {};
blit_desc.colorAttachmentCount = 1;
@@ -717,11 +710,31 @@ void RenderTimeline(WGPUSurface surface, float time, int width, int height,
}
'''
- # Write output
+ # Write C++ output
with open(args.output, 'w') as f:
f.write(all_cpp)
- print(f"Generated {len(sequences)} sequence(s) -> {args.output}")
+ # Write C++ header
+ header_path = os.path.splitext(args.output)[0] + ".h"
+ header_content = f'''// Generated by seq_compiler.py
+// DO NOT EDIT
+#pragma once
+
+#include "gpu/gpu.h"
+#include "gpu/sequence.h"
+
+void InitializeSequences(const GpuContext& ctx, int width, int height);
+Sequence* GetActiveSequence(float time);
+void RenderTimeline(WGPUCommandEncoder encoder, float time, int width, int height,
+ float beat_time, float audio_intensity);
+void RenderTimeline(WGPUSurface surface, float time, int width, int height,
+ float beat_time, float audio_intensity);
+float GetDemoDuration();
+'''
+ with open(header_path, 'w') as f:
+ f.write(header_content)
+
+ print(f"Generated {len(sequences)} sequence(s) -> {args.output} and {header_path}")
if __name__ == '__main__':
main()