diff options
Diffstat (limited to 'src/effects/rotating_cube_effect.cc')
| -rw-r--r-- | src/effects/rotating_cube_effect.cc | 20 |
1 files changed, 18 insertions, 2 deletions
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, |
