VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
renderPassDepthGrab.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3//
4// Created by Arnis Lektauers on 13.02.2026.
5//
7
9#include "scene/camera.h"
10
11namespace visutwin::canvas
12{
14 {
15 if (!_camera) {
16 return;
17 }
18
19 // depth grab publishes scene depth to a globally available slot.
20 // On Metal in this port we can directly reference the depth texture from the source RT.
21 const auto device = this->device();
22 if (!device) {
23 return;
24 }
25
26 const auto sourceTarget = _camera->renderTarget();
27 Texture* sceneDepth = sourceTarget ? sourceTarget->depthBuffer() : nullptr;
28 if (!sceneDepth) {
29 sceneDepth = device->backBuffer() ? device->backBuffer()->depthBuffer() : nullptr;
30 }
31 device->setSceneDepthMap(sceneDepth);
32 }
33
35 {
36 // DEVIATION: no copy pass needed on current Metal path because scene depth is sampled directly.
37 }
38}
std::shared_ptr< GraphicsDevice > device() const
Definition renderPass.h:124
GPU texture resource supporting 2D, cubemap, volume, and array formats with mipmap management.
Definition texture.h:57