VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
vulkanRenderPipeline.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3//
4// Vulkan render pipeline — VkPipeline creation, caching, and layout management.
5//
6#pragma once
7
8#ifdef VISUTWIN_HAS_VULKAN
9
10#include <memory>
11#include <unordered_map>
12#include <vulkan/vulkan.h>
13
15
16namespace visutwin::canvas
17{
18 class BlendState;
19 class DepthState;
20 class VulkanGraphicsDevice;
21 class VulkanShader;
22 class VertexFormat;
23 struct Primitive;
24 enum class CullMode;
25
26 class VulkanRenderPipeline final : public RenderPipelineBase
27 {
28 public:
29 explicit VulkanRenderPipeline(VulkanGraphicsDevice* device);
30 ~VulkanRenderPipeline() override;
31
32 VkPipeline get(const Primitive& primitive,
33 const std::shared_ptr<VertexFormat>& vertexFormat,
34 const std::shared_ptr<VulkanShader>& shader,
35 const std::shared_ptr<BlendState>& blendState,
36 const std::shared_ptr<DepthState>& depthState,
37 CullMode cullMode,
38 VkFormat colorFormat,
39 VkFormat depthFormat);
40
41 [[nodiscard]] VkPipelineLayout pipelineLayout() const { return _pipelineLayout; }
42 [[nodiscard]] VkDescriptorSetLayout materialSetLayout() const { return _materialSetLayout; }
43 [[nodiscard]] VkDescriptorSetLayout textureSetLayout() const { return _textureSetLayout; }
44
45 private:
46 VkPipeline create(const Primitive& primitive,
47 const std::shared_ptr<VertexFormat>& vertexFormat,
48 const std::shared_ptr<VulkanShader>& shader,
49 const std::shared_ptr<BlendState>& blendState,
50 const std::shared_ptr<DepthState>& depthState,
51 CullMode cullMode,
52 VkFormat colorFormat,
53 VkFormat depthFormat);
54
55 void createLayouts();
56
57 VulkanGraphicsDevice* _device;
58 VkPipelineLayout _pipelineLayout = VK_NULL_HANDLE;
59 VkDescriptorSetLayout _materialSetLayout = VK_NULL_HANDLE;
60 VkDescriptorSetLayout _textureSetLayout = VK_NULL_HANDLE;
61
62 std::unordered_map<uint64_t, VkPipeline> _cache;
63 };
64}
65
66#endif // VISUTWIN_HAS_VULKAN
Describes how vertex and index data should be interpreted for a draw call.
Definition mesh.h:33