adding indirect dispatch; test skip
All checks were successful
Test / build_and_test (push) Has been skipped
Build / build (push) Successful in 2m55s

This commit is contained in:
2026-03-09 01:39:03 +01:00
parent 8542912426
commit 32f886054f
5 changed files with 45 additions and 14 deletions

View File

@@ -9,7 +9,7 @@ on:
jobs:
build_and_test:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'ci skip')"
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'test skip')"
steps:
- uses: actions/checkout@v4

View File

@@ -45,7 +45,7 @@ zig build cdb
Name | Status
-----------------------------------------------|--------
vkAllocateCommandBuffers | ✅ Implemented
vkAllocateDescriptorSets | ⚙️ WIP
vkAllocateDescriptorSets | ✅ Implemented
vkAllocateMemory | ✅ Implemented
vkBeginCommandBuffer | ✅ Implemented
vkBindBufferMemory | ✅ Implemented
@@ -54,7 +54,7 @@ vkCmdBeginQuery | ⚙️ WIP
vkCmdBeginRenderPass | ⚙️ WIP
vkCmdBindDescriptorSets | ✅ Implemented
vkCmdBindIndexBuffer | ⚙️ WIP
vkCmdBindPipeline | ⚙️ WIP
vkCmdBindPipeline | ✅ Implemented
vkCmdBindVertexBuffers | ⚙️ WIP
vkCmdBlitImage | ⚙️ WIP
vkCmdClearAttachments | ⚙️ wip
@@ -114,7 +114,7 @@ vkCreateQueryPool | ⚙️ WIP
vkCreateRenderPass | ⚙️ WIP
vkCreateSampler | ⚙️ WIP
vkCreateSemaphore | ⚙️ WIP
vkCreateShaderModule | ⚙️ WIP
vkCreateShaderModule | ✅ Implemented
vkDestroyBuffer | ✅ Implemented
vkDestroyBufferView | ⚙️ WIP
vkDestroyCommandPool | ✅ Implemented
@@ -134,7 +134,7 @@ vkDestroyQueryPool | ⚙️ WIP
vkDestroyRenderPass | ⚙️ WIP
vkDestroySampler | ⚙️ WIP
vkDestroySemaphore | ⚙️ WIP
vkDestroyShaderModule | ⚙️ WIP
vkDestroyShaderModule | ✅ Implemented
vkDeviceWaitIdle | ✅ Implemented
vkEndCommandBuffer | ✅ Implemented
vkEnumerateDeviceExtensionProperties | ⚙️ WIP
@@ -142,7 +142,7 @@ vkEnumerateDeviceLayerProperties | ⚙️ WIP
vkEnumerateInstanceExtensionProperties | ⚙️ WIP
vkEnumerateInstanceLayerProperties | ⚙️ WIP
vkEnumeratePhysicalDevices | ✅ Implemented
vkFlushMappedMemoryRanges | ⚙️ WIP
vkFlushMappedMemoryRanges | ✅ Implemented
vkFreeCommandBuffers | ✅ Implemented
vkFreeDescriptorSets | ✅ Implemented
vkFreeMemory | ✅ Implemented
@@ -166,7 +166,7 @@ vkGetPhysicalDeviceSparseImageFormatProperties | ⚙️ WIP
vkGetPipelineCacheData | ⚙️ WIP
vkGetQueryPoolResults | ⚙️ WIP
vkGetRenderAreaGranularity | ⚙️ WIP
vkInvalidateMappedMemoryRanges | ⚙️ WIP
vkInvalidateMappedMemoryRanges | ✅ Implemented
vkMapMemory | ✅ Implemented
vkMergePipelineCaches | ⚙️ WIP
vkQueueBindSparse | ⚙️ WIP
@@ -179,7 +179,7 @@ vkResetEvent | ⚙️ WIP
vkResetFences | ✅ Implemented
vkSetEvent | ⚙️ WIP
vkUnmapMemory | ✅ Implemented
vkUpdateDescriptorSets | ⚙️ WIP
vkUpdateDescriptorSets | ✅ Implemented
vkWaitForFences | ✅ Implemented
</details>

View File

@@ -46,6 +46,7 @@ pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const v
.copyImage = copyImage,
.copyImageToBuffer = copyImageToBuffer,
.dispatch = dispatch,
.dispatchIndirect = dispatchIndirect,
.end = end,
.fillBuffer = fillBuffer,
.reset = reset,
@@ -289,6 +290,36 @@ pub fn dispatch(interface: *Interface, group_count_x: u32, group_count_y: u32, g
self.commands.append(allocator, Command.from(cmd)) catch return VkError.OutOfHostMemory;
}
pub fn dispatchIndirect(interface: *Interface, buffer: *base.Buffer, offset: vk.DeviceSize) VkError!void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
const allocator = self.command_allocator.allocator();
const CommandImpl = struct {
const Impl = @This();
buffer: *SoftBuffer,
offset: vk.DeviceSize,
pub fn execute(impl: *const Impl, device: *ExecutionDevice) VkError!void {
const size = 3 * @sizeOf(u32);
const memory = if (impl.buffer.interface.memory) |memory| memory else return VkError.InvalidDeviceMemoryDrv;
const map: []u32 = @as([*]u32, @ptrCast(@alignCast(try memory.map(impl.offset, size))))[0..3];
std.debug.print("{any}\n", .{map});
try device.compute_routines.dispatch(map[0], map[1], map[2]);
}
};
const cmd = allocator.create(CommandImpl) catch return VkError.OutOfHostMemory;
errdefer allocator.destroy(cmd);
cmd.* = .{
.buffer = @alignCast(@fieldParentPtr("interface", buffer)),
.offset = offset,
};
self.commands.append(allocator, Command.from(cmd)) catch return VkError.OutOfHostMemory;
}
pub fn fillBuffer(interface: *Interface, buffer: *base.Buffer, offset: vk.DeviceSize, size: vk.DeviceSize, data: u32) VkError!void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
const allocator = self.command_allocator.allocator();

View File

@@ -45,6 +45,7 @@ pub const DispatchTable = struct {
copyImage: *const fn (*Self, *Image, vk.ImageLayout, *Image, vk.ImageLayout, []const vk.ImageCopy) VkError!void,
copyImageToBuffer: *const fn (*Self, *Image, vk.ImageLayout, *Buffer, []const vk.BufferImageCopy) VkError!void,
dispatch: *const fn (*Self, u32, u32, u32) VkError!void,
dispatchIndirect: *const fn (*Self, *Buffer, vk.DeviceSize) VkError!void,
end: *const fn (*Self) VkError!void,
fillBuffer: *const fn (*Self, *Buffer, vk.DeviceSize, vk.DeviceSize, u32) VkError!void,
reset: *const fn (*Self, vk.CommandBufferResetFlags) VkError!void,
@@ -152,6 +153,10 @@ pub inline fn dispatch(self: *Self, group_count_x: u32, group_count_y: u32, grou
try self.dispatch_table.dispatch(self, group_count_x, group_count_y, group_count_z);
}
pub inline fn dispatchIndirect(self: *Self, buffer: *Buffer, offset: vk.DeviceSize) VkError!void {
try self.dispatch_table.dispatchIndirect(self, buffer, offset);
}
pub inline fn fillBuffer(self: *Self, buffer: *Buffer, offset: vk.DeviceSize, size: vk.DeviceSize, data: u32) VkError!void {
try self.dispatch_table.fillBuffer(self, buffer, offset, size, data);
}

View File

@@ -1869,12 +1869,7 @@ pub export fn strollCmdDispatchIndirect(p_cmd: vk.CommandBuffer, p_buffer: vk.Bu
const cmd = Dispatchable(CommandBuffer).fromHandleObject(p_cmd) catch |err| return errorLogger(err);
const buffer = NonDispatchable(Buffer).fromHandleObject(p_buffer) catch |err| return errorLogger(err);
notImplementedWarning();
_ = cmd;
_ = buffer;
_ = offset;
cmd.dispatchIndirect(buffer, offset) catch |err| return errorLogger(err);
}
pub export fn strollCmdDraw(p_cmd: vk.CommandBuffer, vertex_count: u32, instance_count: u32, first_vertex: u32, first_instance: u32) callconv(vk.vulkan_call_conv) void {