VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
vulkanIndexBuffer.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3//
4// Vulkan index buffer — VMA-backed VkBuffer.
5//
6#pragma once
7
8#ifdef VISUTWIN_HAS_VULKAN
9
10#include <vulkan/vulkan.h>
11#include <vk_mem_alloc.h>
12
14
15namespace visutwin::canvas
16{
17 class VulkanIndexBuffer : public IndexBuffer
18 {
19 public:
20 VulkanIndexBuffer(GraphicsDevice* device, IndexFormat format, int numIndices);
21 ~VulkanIndexBuffer() override;
22
23 void* nativeBuffer() const override { return reinterpret_cast<void*>(_buffer); }
24 bool setData(const std::vector<uint8_t>& data) override;
25
26 [[nodiscard]] VkBuffer buffer() const { return _buffer; }
27
28 private:
29 void uploadStaging(const void* data, size_t size);
30
31 VkBuffer _buffer = VK_NULL_HANDLE;
32 VmaAllocation _allocation = VK_NULL_HANDLE;
33 VmaAllocator _allocator = VK_NULL_HANDLE;
34 };
35}
36
37#endif // VISUTWIN_HAS_VULKAN