implementing device creation, device memory, basic buffers copy and buffers fill in Flint
This commit is contained in:
@@ -39,21 +39,21 @@ pub inline fn destroy(self: *Self, allocator: std.mem.Allocator) void {
|
||||
self.vtable.destroy(self, allocator);
|
||||
}
|
||||
|
||||
pub inline fn bindMemory(self: *Self, memory: *DeviceMemory, offset: vk.DeviceSize) VkError!void {
|
||||
if (offset > memory.size or !self.allowed_memory_types.isSet(memory.memory_type_index)) {
|
||||
pub fn bindMemory(self: *Self, memory: *DeviceMemory, offset: vk.DeviceSize) VkError!void {
|
||||
if (offset > memory.size or self.size > memory.size - offset or !self.allowed_memory_types.isSet(memory.memory_type_index)) {
|
||||
return VkError.ValidationFailed;
|
||||
}
|
||||
self.memory = memory;
|
||||
self.offset = offset;
|
||||
}
|
||||
|
||||
pub inline fn getMemoryRequirements(self: *Self, requirements: *vk.MemoryRequirements) void {
|
||||
pub fn getMemoryRequirements(self: *Self, requirements: *vk.MemoryRequirements) void {
|
||||
requirements.size = self.size;
|
||||
requirements.memory_type_bits = self.allowed_memory_types.mask;
|
||||
self.vtable.getMemoryRequirements(self, requirements);
|
||||
}
|
||||
|
||||
pub inline fn getDeviceAddress(self: *Self) VkError!vk.DeviceAddress {
|
||||
pub fn getDeviceAddress(self: *Self) VkError!vk.DeviceAddress {
|
||||
const memory = self.memory orelse return 0;
|
||||
const map = try memory.map(self.offset, self.size);
|
||||
return @intCast(@intFromPtr(map.ptr));
|
||||
|
||||
@@ -28,3 +28,21 @@ pub fn writePacked(comptime T: type, bytes: []u8, value: T) void {
|
||||
const raw: [@sizeOf(T)]u8 = @bitCast(value);
|
||||
@memcpy(bytes[0..@sizeOf(T)], raw[0..]);
|
||||
}
|
||||
|
||||
pub fn ioctl(file: std.Io.File, io: std.Io, request: u32, arg: ?*anyopaque) (std.Io.Cancelable || std.posix.UnexpectedError)!void {
|
||||
const result = try io.operate(.{ .device_io_control = .{
|
||||
.file = file,
|
||||
.code = request,
|
||||
.arg = arg,
|
||||
} });
|
||||
|
||||
const rc = if (@import("builtin").link_libc)
|
||||
@as(c_int, @intCast(result.device_io_control))
|
||||
else
|
||||
@as(usize, @bitCast(@as(isize, @intCast(result.device_io_control))));
|
||||
|
||||
return switch (std.posix.errno(rc)) {
|
||||
.SUCCESS => {},
|
||||
else => |e| std.posix.unexpectedErrno(e),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user