NDEVR
API Documentation
VulkanComputeDevice.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2026, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: VulkanCompute
28File: VulkanComputeDevice
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include "../../VulkanGraphics/Headers/VulkanDevice.h"
35#include <NDEVR/Pointer.h>
36
37namespace NDEVR
38{
45 class VULKAN_COMPUTE_API VulkanComputeDevice
46 {
47 public:
48 VulkanComputeDevice(const ConstPointer<VulkanDevice>& device);
49 ~VulkanComputeDevice();
50
52 bool supportsCompute() const;
53
55 uint04 computeFamilyIndex() const { return m_compute_family_index; }
56
58 bool hasDedicatedComputeQueue() const { return m_is_dedicated_compute; }
59
61 const ConstPointer<VulkanDevice>& vulkanDevice() const { return m_device; }
62
64 VkDevice device() const { return m_device->device(); }
65
67 VkQueue computeQueue() const { return m_compute_queue; }
68
70 VkCommandPool computeCommandPool() const { return m_compute_command_pool; }
71
73 VkCommandBuffer beginComputeCommands() const;
74
76 void endComputeCommands(VkCommandBuffer cmd, bool wait_for_completion) const;
77
82
85 void resetComputeCommandBuffer(VkCommandBuffer cmd) const;
86
89 void submitComputeCommands(VkCommandBuffer cmd) const;
90
92 void waitComputeQueue() const;
93
96
98 uint04 findMemoryType(uint04 type_filter, uint04 properties) const;
99
103 void beginTransferBatch() const;
104
106 void endTransferBatch() const;
107
109 VkCommandBuffer batchCommandBuffer() const { return m_batch_cmd; }
110
111 private:
113 void discoverComputeQueue();
115 void createComputeCommandPool();
116
117 private:
119 VkQueue m_compute_queue = VK_NULL_HANDLE;
120 VkCommandPool m_compute_command_pool = VK_NULL_HANDLE;
121 mutable VkCommandBuffer m_batch_cmd = VK_NULL_HANDLE;
122 uint04 m_compute_family_index = Constant<uint04>::Invalid;
123 bool m_is_dedicated_compute = false;
124 };
125}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
Definition Pointer.hpp:276
void resetComputeCommandBuffer(VkCommandBuffer cmd) const
Reset a previously submitted (or freshly allocated) command buffer and begin recording.
void submitComputeCommands(VkCommandBuffer cmd) const
End and submit a command buffer without waiting or freeing.
bool hasDedicatedComputeQueue() const
Whether the compute queue is dedicated (not the graphics queue).
void endTransferBatch() const
End the transfer batch: submit the batched command buffer and wait for completion.
VkCommandBuffer beginComputeCommands() const
Allocate and begin a one-time-use compute command buffer.
void endComputeCommands(VkCommandBuffer cmd, bool wait_for_completion) const
End, submit, and optionally wait for a compute command buffer.
VkQueue computeQueue() const
Get the compute queue.
void beginTransferBatch() const
Begin a transfer batch.
uint04 computeFamilyIndex() const
Index of the compute queue family.
VkCommandBuffer batchCommandBuffer() const
Returns the active batch command buffer, or VK_NULL_HANDLE if no batch is active.
VkDevice device() const
Get the VkDevice handle.
Buffer< VkCommandBuffer > allocateComputeCommandBuffers(uint04 count) const
Allocate a batch of command buffers in a single Vulkan call.
VkCommandPool computeCommandPool() const
Get the compute command pool.
const ConstPointer< VulkanDevice > & vulkanDevice() const
Access the underlying VulkanDevice.
void waitComputeQueue() const
Block until all work on the compute queue has completed.
void freeComputeCommandBuffers(const Buffer< VkCommandBuffer > &cmds) const
Free a batch of command buffers.
uint04 findMemoryType(uint04 type_filter, uint04 properties) const
Find a memory type index matching the given filter and properties.
bool supportsCompute() const
Whether this device has a usable compute queue.
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...