VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
compute.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 on 19.10.2025.
5//
6
7#include "compute.h"
8
9#include <algorithm>
10#include <utility>
11
12namespace visutwin::canvas
13{
14 Compute::Compute(GraphicsDevice* graphicsDevice, const std::shared_ptr<Shader>& shader, std::string name)
15 : _graphicsDevice(graphicsDevice), _shader(shader), _name(std::move(name))
16 {
17 }
18
19 void Compute::setParameter(const std::string& name, Texture* texture)
20 {
21 _textureParameters[name] = texture;
22 }
23
24 Texture* Compute::getTextureParameter(const std::string& name) const
25 {
26 const auto it = _textureParameters.find(name);
27 return it != _textureParameters.end() ? it->second : nullptr;
28 }
29
30 void Compute::setupDispatch(uint32_t x, uint32_t y, uint32_t z)
31 {
32 _dispatchX = std::max(1u, x);
33 _dispatchY = std::max(1u, y);
34 _dispatchZ = std::max(1u, z);
35 }
36} // visutwin
void setupDispatch(uint32_t x, uint32_t y, uint32_t z)
Definition compute.cpp:30
const std::shared_ptr< Shader > & shader() const
Definition compute.h:28
GraphicsDevice * graphicsDevice() const
Definition compute.h:29
Compute(GraphicsDevice *graphicsDevice, const std::shared_ptr< Shader > &shader, std::string name="")
Definition compute.cpp:14
void setParameter(const std::string &name, Texture *texture)
Definition compute.cpp:19
Texture * getTextureParameter(const std::string &name) const
Definition compute.cpp:24
const std::string & name() const
Definition compute.h:30
Abstract GPU interface for resource creation, state management, and draw submission.
GPU texture resource supporting 2D, cubemap, volume, and array formats with mipmap management.
Definition texture.h:57