adding indirect dispatch; test skip
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
+31
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();