KDGpu to Vulkan API Mapping
Introduction
This page provides a comprehensive mapping between KDGpu classes and their Vulkan counterparts. For each KDGpu class, you'll find:
- The corresponding Vulkan type(s)
- Key Vulkan functions used internally
- Links to Vulkan specification details
Core Instance & Device API
GPU Resources
Pipelines & Shaders
Descriptors & Resource Bindings
Command Recording & Submission
Synchronization
Presentation
Ray Tracing (KHR Extensions)
Queries
Other
Function Correspondence
This section maps common KDGpu operations to their Vulkan function equivalents.
Buffer Operations
| KDGpu Operation |
Vulkan Functions |
device.createBuffer(options) |
vkCreateBuffer() + vkGetBufferMemoryRequirements() + vkAllocateMemory() + vkBindBufferMemory() |
buffer.map() |
vkMapMemory() |
buffer.unmap() |
vkUnmapMemory() |
buffer.flush() |
vkFlushMappedMemoryRanges() |
buffer.invalidate() |
vkInvalidateMappedMemoryRanges() |
Texture Operations
| KDGpu Operation |
Vulkan Functions |
device.createTexture(options) |
vkCreateImage() + vkGetImageMemoryRequirements() + vkAllocateMemory() + vkBindImageMemory() |
texture.createView(options) |
vkCreateImageView() |
Pipeline Operations
| KDGpu Operation |
Vulkan Functions |
device.createGraphicsPipeline(options) |
vkCreateGraphicsPipelines() |
device.createComputePipeline(options) |
vkCreateComputePipelines() |
device.createShaderModule(spirvCode) |
vkCreateShaderModule() |
Command Recording
| KDGpu Operation |
Vulkan Functions |
recorder.beginRenderPass(options) |
vkCmdBeginRenderPass() or vkCmdBeginRendering() (dynamic rendering) |
passRecorder.setPipeline(pipeline) |
vkCmdBindPipeline() |
passRecorder.setVertexBuffer(index, buffer) |
vkCmdBindVertexBuffers() |
passRecorder.setIndexBuffer(buffer) |
vkCmdBindIndexBuffer() |
passRecorder.setBindGroup(index, bindGroup) |
vkCmdBindDescriptorSets() |
passRecorder.draw(drawCommand) |
vkCmdDraw() |
passRecorder.drawIndexed(drawCommand) |
vkCmdDrawIndexed() |
passRecorder.end() |
vkCmdEndRenderPass() or vkCmdEndRendering() |
recorder.finish() |
vkEndCommandBuffer() |
Synchronization
| KDGpu Operation |
Vulkan Functions |
queue.submit(submitOptions) |
vkQueueSubmit() or vkQueueSubmit2() |
queue.waitUntilIdle() |
vkQueueWaitIdle() |
device.waitUntilIdle() |
vkDeviceWaitIdle() |
fence.wait() |
vkWaitForFences() |
fence.reset() |
vkResetFences() |
Usage Examples
Buffer Creation Comparison
Raw Vulkan:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 | VkBufferCreateInfo bufferInfo = {
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.size = 1024,
.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
.sharingMode = VK_SHARING_MODE_EXCLUSIVE
};
VkBuffer buffer;
vkCreateBuffer(device, &bufferInfo, nullptr, &buffer);
VkMemoryRequirements memReqs;
vkGetBufferMemoryRequirements(device, buffer, &memReqs);
VkMemoryAllocateInfo allocInfo = {
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
.allocationSize = memReqs.size,
.memoryTypeIndex = findMemoryType(memReqs.memoryTypeBits, properties)
};
VkDeviceMemory memory;
vkAllocateMemory(device, &allocInfo, nullptr, &memory);
vkBindBufferMemory(device, buffer, memory, 0);
// ... use buffer ...
vkDestroyBuffer(device, buffer, nullptr);
vkFreeMemory(device, memory, nullptr);
|
KDGpu:
| KDGpu::Buffer buffer = device.createBuffer(KDGpu::BufferOptions{
.size = 1024,
.usage = KDGpu::BufferUsageFlagBits::VertexBufferBit,
.memoryUsage = KDGpu::MemoryUsage::CpuToGpu
});
// ... use buffer ...
// Automatic cleanup when buffer goes out of scope
|
Pipeline Creation Comparison
Raw Vulkan:
| // 50+ lines of pipeline state setup omitted for brevity
VkGraphicsPipelineCreateInfo pipelineInfo = { /* ... */ };
VkPipeline pipeline;
vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &pipeline);
// ... use pipeline ...
vkDestroyPipeline(device, pipeline, nullptr);
|
KDGpu:
| KDGpu::GraphicsPipeline pipeline = device.createGraphicsPipeline(KDGpu::GraphicsPipelineOptions{
.shaderStages = { vertexStage, fragmentStage },
.layout = pipelineLayout,
.renderPass = renderPass,
// ... other options with sensible defaults
});
// ... use pipeline ...
// Automatic cleanup
|
See Also
Updated on 2026-03-14 at 00:03:56 +0000