VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
metalComposePass.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3//
4// Compose post-processing pass — CAS sharpening, SSAO, DOF, bloom, tonemapping, gamma.
5// Extracted from MetalGraphicsDevice for single-responsibility decomposition.
6//
7#pragma once
8
9#include <memory>
10#include <vector>
11#include <Metal/Metal.hpp>
12
14
15namespace visutwin::canvas
16{
17 class BlendState;
18 class DepthState;
22 class RenderTarget;
23 class Shader;
24 class VertexBuffer;
25 class VertexFormat;
26
32 {
33 public:
34 explicit MetalComposePass(MetalGraphicsDevice* device);
36
38 void execute(MTL::RenderCommandEncoder* encoder, const ComposePassParams& params,
39 MetalRenderPipeline* pipeline, const std::shared_ptr<RenderTarget>& renderTarget,
40 const std::vector<std::shared_ptr<MetalBindGroupFormat>>& bindGroupFormats,
41 MTL::SamplerState* defaultSampler);
42
44 [[nodiscard]] std::shared_ptr<VertexFormat> vertexFormat() const { return _vertexFormat; }
45
47 [[nodiscard]] std::shared_ptr<VertexBuffer> vertexBuffer() const { return _vertexBuffer; }
48
51 void ensureResources();
52
53 private:
54
55 MetalGraphicsDevice* _device;
56
57 std::shared_ptr<Shader> _shader;
58 std::shared_ptr<VertexFormat> _vertexFormat;
59 std::shared_ptr<VertexBuffer> _vertexBuffer;
60 std::shared_ptr<BlendState> _blendState;
61 std::shared_ptr<DepthState> _depthState;
62 MTL::DepthStencilState* _depthStencilState = nullptr;
63 };
64}
MetalComposePass(MetalGraphicsDevice *device)
void execute(MTL::RenderCommandEncoder *encoder, const ComposePassParams &params, MetalRenderPipeline *pipeline, const std::shared_ptr< RenderTarget > &renderTarget, const std::vector< std::shared_ptr< MetalBindGroupFormat > > &bindGroupFormats, MTL::SamplerState *defaultSampler)
Execute the compose pass on the active render command encoder.
std::shared_ptr< VertexFormat > vertexFormat() const
Shared vertex format (full-screen triangle, 14 floats per vertex).
std::shared_ptr< VertexBuffer > vertexBuffer() const
Shared vertex buffer (3-vertex full-screen triangle).