diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-16 23:33:53 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-16 23:33:53 +0100 |
| commit | 3b2bee705cfe5a250bb6049a90b5d734d3125f73 (patch) | |
| tree | f6c7151b6b9c6eecdf7a3a750c4c57e5c528cc0e /src/effects | |
| parent | 0585a596e2fc77239912bd6437ea76b1af5ad0d5 (diff) | |
fix: port Hybrid3D effect to sequence v2 architecture
Hybrid3D was calling Renderer3D::render() which creates its own command
encoder, bypassing the sequence system. Now uses renderer_.draw() with
the passed encoder.
Also adds texture blit support for RotatingCube compositing.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/effects')
| -rw-r--r-- | src/effects/hybrid3_d_effect.cc | 28 | ||||
| -rw-r--r-- | src/effects/rotating_cube_effect.cc | 20 |
2 files changed, 44 insertions, 4 deletions
diff --git a/src/effects/hybrid3_d_effect.cc b/src/effects/hybrid3_d_effect.cc index 0e44853..c13c1e9 100644 --- a/src/effects/hybrid3_d_effect.cc +++ b/src/effects/hybrid3_d_effect.cc @@ -4,6 +4,7 @@ #include "util/fatal_error.h" #include "effects/hybrid3_d_effect.h" +#include "gpu/gpu.h" #include <cmath> Hybrid3D::Hybrid3D(const GpuContext& ctx, @@ -113,6 +114,29 @@ void Hybrid3D::render(WGPUCommandEncoder encoder, WGPUTextureView color_view = nodes.get_view(output_nodes_[0]); WGPUTextureView depth_view = nodes.get_view(depth_node_); - // Render 3D scene - renderer_.render(scene_, camera_, params.time, color_view, depth_view); + // Render 3D scene using sequence encoder + WGPURenderPassColorAttachment color_attachment = {}; +#if !defined(DEMO_CROSS_COMPILE_WIN32) + color_attachment.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED; +#endif + color_attachment.view = color_view; + color_attachment.loadOp = WGPULoadOp_Clear; + color_attachment.storeOp = WGPUStoreOp_Store; + color_attachment.clearValue = {0.05f, 0.05f, 0.05f, 1.0f}; + + WGPURenderPassDepthStencilAttachment depth_attachment = {}; + depth_attachment.view = depth_view; + depth_attachment.depthLoadOp = WGPULoadOp_Clear; + depth_attachment.depthStoreOp = WGPUStoreOp_Store; + depth_attachment.depthClearValue = 1.0f; + + WGPURenderPassDescriptor pass_desc = {}; + pass_desc.colorAttachmentCount = 1; + pass_desc.colorAttachments = &color_attachment; + pass_desc.depthStencilAttachment = &depth_attachment; + + WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc); + renderer_.draw(pass, scene_, camera_, params.time); + wgpuRenderPassEncoderEnd(pass); + wgpuRenderPassEncoderRelease(pass); } diff --git a/src/effects/rotating_cube_effect.cc b/src/effects/rotating_cube_effect.cc index 1f56b8b..a91bc78 100644 --- a/src/effects/rotating_cube_effect.cc +++ b/src/effects/rotating_cube_effect.cc @@ -156,6 +156,21 @@ void RotatingCube::render(WGPUCommandEncoder encoder, wgpuQueueWriteBuffer(ctx_.queue, object_buffer_.buffer, 0, &obj_data, sizeof(ObjectData)); + // Blit input to output if compositing (not reading from source) + if (!input_nodes_.empty() && input_nodes_[0] != "source") { + WGPUTexture input_tex = nodes.get_texture(input_nodes_[0]); + WGPUTexture output_tex = nodes.get_texture(output_nodes_[0]); + if (input_tex && output_tex) { + WGPUTexelCopyTextureInfo src = { + .texture = input_tex, .mipLevel = 0, .aspect = WGPUTextureAspect_All}; + WGPUTexelCopyTextureInfo dst = { + .texture = output_tex, .mipLevel = 0, .aspect = WGPUTextureAspect_All}; + WGPUExtent3D copy_size = {(uint32_t)params.resolution.x, + (uint32_t)params.resolution.y, 1}; + wgpuCommandEncoderCopyTextureToTexture(encoder, &src, &dst, ©_size); + } + } + // Get output views WGPUTextureView color_view = nodes.get_view(output_nodes_[0]); WGPUTextureView depth_view = nodes.get_view(depth_node_); @@ -164,9 +179,10 @@ void RotatingCube::render(WGPUCommandEncoder encoder, WGPURenderPassColorAttachment color_attachment = { .view = color_view, .depthSlice = WGPU_DEPTH_SLICE_UNDEFINED, - .loadOp = WGPULoadOp_Clear, +// .loadOp = WGPULoadOp_Clear, + .loadOp = WGPULoadOp_Load, .storeOp = WGPUStoreOp_Store, - .clearValue = {0.0, 0.0, 0.0, 1.0}}; + .clearValue = {0.0, 0.0, 0.0, 0.0}}; WGPURenderPassDepthStencilAttachment depth_attachment = { .view = depth_view, |
