diff options
Diffstat (limited to 'src/gpu')
| -rw-r--r-- | src/gpu/post_process_helper.cc | 25 | ||||
| -rw-r--r-- | src/gpu/post_process_helper.h | 5 | ||||
| -rw-r--r-- | src/gpu/sequence_v2.cc | 23 |
3 files changed, 44 insertions, 9 deletions
diff --git a/src/gpu/post_process_helper.cc b/src/gpu/post_process_helper.cc index 2e8f6ad..5f2ff56 100644 --- a/src/gpu/post_process_helper.cc +++ b/src/gpu/post_process_helper.cc @@ -36,6 +36,31 @@ WGPURenderPipeline create_post_process_pipeline(WGPUDevice device, return pipeline; } +// Helper to create a simple post-processing pipeline (no effect params) +WGPURenderPipeline create_post_process_pipeline_simple(WGPUDevice device, + WGPUTextureFormat format, + const char* shader_code) { + WGPUBindGroupLayout bgl = + BindGroupLayoutBuilder() + .sampler(PP_BINDING_SAMPLER, WGPUShaderStage_Fragment) + .texture(PP_BINDING_TEXTURE, WGPUShaderStage_Fragment) + .uniform(PP_BINDING_UNIFORMS, + WGPUShaderStage_Vertex | WGPUShaderStage_Fragment) + .build(device); + + const std::string composed_shader = + ShaderComposer::Get().Compose({}, shader_code); + + WGPURenderPipeline pipeline = RenderPipelineBuilder(device) + .shader(composed_shader.c_str()) + .bind_group_layout(bgl) + .format(format) + .build(); + + wgpuBindGroupLayoutRelease(bgl); + return pipeline; +} + // --- PostProcess Implementation Helper --- static GpuBuffer g_dummy_buffer = {nullptr, 0}; diff --git a/src/gpu/post_process_helper.h b/src/gpu/post_process_helper.h index 5a7e9fd..33ef20b 100644 --- a/src/gpu/post_process_helper.h +++ b/src/gpu/post_process_helper.h @@ -31,6 +31,11 @@ WGPURenderPipeline create_post_process_pipeline(WGPUDevice device, WGPUTextureFormat format, const char* shader_code); +// Helper to create a simple post-processing pipeline (no effect params, 3 bindings only) +WGPURenderPipeline create_post_process_pipeline_simple(WGPUDevice device, + WGPUTextureFormat format, + const char* shader_code); + // Helper to update bind group for post-processing effects void pp_update_bind_group(WGPUDevice device, WGPURenderPipeline pipeline, WGPUBindGroup* bind_group, WGPUTextureView input_view, diff --git a/src/gpu/sequence_v2.cc b/src/gpu/sequence_v2.cc index 7c44085..3912849 100644 --- a/src/gpu/sequence_v2.cc +++ b/src/gpu/sequence_v2.cc @@ -11,15 +11,20 @@ NodeRegistry::NodeRegistry(WGPUDevice device, int default_width, int default_height) : device_(device), default_width_(default_width), default_height_(default_height) { - // Create placeholder source/sink nodes (will be updated externally before rendering) - Node placeholder = {}; - placeholder.type = NodeType::U8X4_NORM; - placeholder.width = default_width; - placeholder.height = default_height; - placeholder.texture = nullptr; - placeholder.view = nullptr; - nodes_["source"] = placeholder; - nodes_["sink"] = placeholder; + // Create source/sink nodes with actual textures + Node source_node = {}; + source_node.type = NodeType::U8X4_NORM; + source_node.width = default_width; + source_node.height = default_height; + create_texture(source_node); + nodes_["source"] = source_node; + + Node sink_node = {}; + sink_node.type = NodeType::U8X4_NORM; + sink_node.width = default_width; + sink_node.height = default_height; + create_texture(sink_node); + nodes_["sink"] = sink_node; } NodeRegistry::~NodeRegistry() { |
