implementation of vkCmdFillBuffer and rework of logger
This commit is contained in:
@@ -15,5 +15,20 @@ pub fn deinit(self: *Self) void {
|
||||
|
||||
pub fn dispatch(self: *Self, command: *const cmd.Command) void {
|
||||
_ = self;
|
||||
_ = command;
|
||||
switch (command.*) {
|
||||
.FillBuffer => |data| fillBuffer(&data),
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
||||
fn fillBuffer(data: *const cmd.CommandFillBuffer) void {
|
||||
const memory = if (data.buffer.memory) |memory| memory else unreachable;
|
||||
const raw_memory_map: [*]u32 = @ptrCast(@alignCast(memory.map(data.offset, data.size) catch unreachable));
|
||||
var memory_map: []u32 = raw_memory_map[0..data.size];
|
||||
|
||||
for (0..@divExact(data.size, @sizeOf(u32))) |i| {
|
||||
memory_map[i] = data.data;
|
||||
}
|
||||
|
||||
memory.unmap();
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@ pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const v
|
||||
.getMemoryRequirements = getMemoryRequirements,
|
||||
};
|
||||
|
||||
interface.allowed_memory_types = lib.MEMORY_TYPE_GENERIC_BIT;
|
||||
|
||||
self.* = .{
|
||||
.interface = interface,
|
||||
};
|
||||
|
||||
@@ -25,13 +25,15 @@ pub fn create(device: *SoftDevice, allocator: std.mem.Allocator, size: vk.Device
|
||||
|
||||
self.* = .{
|
||||
.interface = interface,
|
||||
.data = device.device_allocator.allocator().alignedAlloc(u8, std.mem.Alignment.@"16", size) catch return VkError.OutOfDeviceMemory,
|
||||
.data = device.device_allocator.allocator().alloc(u8, size) catch return VkError.OutOfDeviceMemory,
|
||||
};
|
||||
return self;
|
||||
}
|
||||
|
||||
pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
|
||||
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
|
||||
const soft_device: *SoftDevice = @alignCast(@fieldParentPtr("interface", interface.owner));
|
||||
soft_device.device_allocator.allocator().free(self.data);
|
||||
allocator.destroy(self);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ pub fn create(allocator: std.mem.Allocator, instance: *const base.Instance) VkEr
|
||||
interface.props.device_type = .cpu;
|
||||
|
||||
interface.props.limits.max_bound_descriptor_sets = 1024; // tmp
|
||||
interface.props.limits.max_memory_allocation_count = 1024;
|
||||
|
||||
interface.mem_props.memory_type_count = 1;
|
||||
interface.mem_props.memory_types[0] = .{
|
||||
|
||||
@@ -25,7 +25,7 @@ pub const DRIVER_VERSION = vk.makeApiVersion(0, 0, 0, 1);
|
||||
pub const DEVICE_ID = 0x600DCAFE;
|
||||
|
||||
/// Generic system memory.
|
||||
pub const MEMORY_TYPE_GENERIC_BIT = 0x1;
|
||||
pub const MEMORY_TYPE_GENERIC_BIT = 0;
|
||||
|
||||
/// 16 bytes for 128-bit vector types.
|
||||
pub const MEMORY_REQUIREMENTS_ALIGNMENT = 16;
|
||||
|
||||
Reference in New Issue
Block a user