fixing linter errors
This commit is contained in:
@@ -4,7 +4,6 @@ const base = @import("base");
|
||||
const kmd = @import("kmd.zig");
|
||||
|
||||
const VkError = base.VkError;
|
||||
const Device = base.Device;
|
||||
const FlintDevice = @import("FlintDevice.zig");
|
||||
|
||||
const drm_syncobj_create = 0xbf;
|
||||
@@ -159,5 +158,5 @@ fn destroyHandle(device: *FlintDevice, io: std.Io, handle: u32) void {
|
||||
io,
|
||||
kmd.drmIoctlIowr(drm_syncobj_destroy, SyncObjDestroy),
|
||||
&destroy_info,
|
||||
) catch {};
|
||||
) catch @panic("Caught an error while handling an error");
|
||||
}
|
||||
|
||||
@@ -2,10 +2,8 @@ const std = @import("std");
|
||||
const vk = @import("vulkan");
|
||||
const base = @import("base");
|
||||
|
||||
const lib = @import("lib.zig");
|
||||
|
||||
const VkError = base.VkError;
|
||||
const Device = base.Device;
|
||||
|
||||
const Self = @This();
|
||||
pub const Interface = base.Buffer;
|
||||
|
||||
@@ -3,7 +3,6 @@ const vk = @import("vulkan");
|
||||
const base = @import("base");
|
||||
|
||||
const VkError = base.VkError;
|
||||
const Device = base.Device;
|
||||
|
||||
const Self = @This();
|
||||
pub const Interface = base.BufferView;
|
||||
|
||||
@@ -5,8 +5,6 @@ const kmd = @import("kmd.zig");
|
||||
|
||||
const VkError = base.VkError;
|
||||
const FlintDevice = @import("FlintDevice.zig");
|
||||
const FlintDeviceMemory = @import("FlintDeviceMemory.zig");
|
||||
const FlintImage = @import("FlintImage.zig");
|
||||
|
||||
const MemoryRange = @import("MemoryRange.zig");
|
||||
|
||||
@@ -96,7 +94,7 @@ pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
|
||||
|
||||
pub fn submitGpuBatch(self: *Self, syncs: []const kmd.SyncDependency) VkError!void {
|
||||
try self.interface.submit();
|
||||
defer self.interface.finish() catch {};
|
||||
defer self.interface.finish() catch @panic("Caught an error while handling an error");
|
||||
|
||||
if (self.batch.items.len == 0) return;
|
||||
|
||||
|
||||
@@ -2,9 +2,7 @@ const std = @import("std");
|
||||
const vk = @import("vulkan");
|
||||
const base = @import("base");
|
||||
|
||||
const NonDispatchable = base.NonDispatchable;
|
||||
const VkError = base.VkError;
|
||||
const Device = base.Device;
|
||||
|
||||
const FlintCommandBuffer = @import("FlintCommandBuffer.zig");
|
||||
|
||||
|
||||
@@ -3,9 +3,6 @@ const vk = @import("vulkan");
|
||||
const base = @import("base");
|
||||
|
||||
const VkError = base.VkError;
|
||||
const VulkanAllocator = base.VulkanAllocator;
|
||||
|
||||
const Device = base.Device;
|
||||
|
||||
const Self = @This();
|
||||
pub const Interface = base.DescriptorPool;
|
||||
|
||||
@@ -3,7 +3,6 @@ const vk = @import("vulkan");
|
||||
const base = @import("base");
|
||||
|
||||
const VkError = base.VkError;
|
||||
const Device = base.Device;
|
||||
|
||||
const Self = @This();
|
||||
pub const Interface = base.DescriptorSetLayout;
|
||||
|
||||
@@ -3,7 +3,6 @@ const vk = @import("vulkan");
|
||||
const base = @import("base");
|
||||
|
||||
const VkError = base.VkError;
|
||||
const Device = base.Device;
|
||||
|
||||
const Self = @This();
|
||||
pub const Interface = base.Event;
|
||||
|
||||
@@ -170,7 +170,7 @@ fn destroyHandle(device: *FlintDevice, io: std.Io, handle: u32) void {
|
||||
io,
|
||||
kmd.drmIoctlIowr(drm_syncobj_destroy, SyncObjDestroy),
|
||||
&destroy_info,
|
||||
) catch {};
|
||||
) catch @panic("ioctl failed");
|
||||
}
|
||||
|
||||
fn absoluteTimeout(io: std.Io, timeout: u64) i64 {
|
||||
|
||||
@@ -3,7 +3,6 @@ const vk = @import("vulkan");
|
||||
const base = @import("base");
|
||||
|
||||
const VkError = base.VkError;
|
||||
const Device = base.Device;
|
||||
|
||||
const Self = @This();
|
||||
pub const Interface = base.ImageView;
|
||||
|
||||
@@ -80,17 +80,17 @@ fn requestPhysicalDevices(interface: *Interface, allocator: std.mem.Allocator, d
|
||||
defer version.deinit(allocator);
|
||||
|
||||
const kmd_type: lib.KmdType = if (std.mem.eql(u8, version.name, "i915"))
|
||||
.I915
|
||||
.i915
|
||||
else if (std.mem.eql(u8, version.name, "xe"))
|
||||
.Xe
|
||||
.xe
|
||||
else
|
||||
.Invalid;
|
||||
.invalid;
|
||||
|
||||
if (kmd_type == .Invalid)
|
||||
if (kmd_type == .invalid)
|
||||
continue;
|
||||
|
||||
const physical_device = try FlintPhysicalDevice.create(allocator, interface, &drm_device, kmd_type);
|
||||
errdefer physical_device.interface.release(allocator) catch {};
|
||||
errdefer physical_device.interface.release(allocator) catch @panic("Caught an error while handling an error");
|
||||
|
||||
const dispatchable = try Dispatchable(base.PhysicalDevice).wrap(allocator, &physical_device.interface);
|
||||
errdefer dispatchable.destroy(allocator);
|
||||
|
||||
@@ -9,7 +9,6 @@ const pci_ids = @import("pci_ids.zig").map;
|
||||
const FlintDevice = @import("FlintDevice.zig");
|
||||
|
||||
const VkError = base.VkError;
|
||||
const VulkanAllocator = base.VulkanAllocator;
|
||||
const SurfaceKHR = base.SurfaceKHR;
|
||||
|
||||
const Self = @This();
|
||||
@@ -79,7 +78,7 @@ pub fn create(allocator: std.mem.Allocator, instance: *base.Instance, drm_device
|
||||
break;
|
||||
}
|
||||
|
||||
interface.props.pipeline_cache_uuid = undefined;
|
||||
interface.props.pipeline_cache_uuid = @splat(0);
|
||||
interface.props.limits = .{
|
||||
.max_image_dimension_1d = 4096,
|
||||
.max_image_dimension_2d = 4096,
|
||||
@@ -867,10 +866,10 @@ fn cpuid(leaf_id: u32, subleaf_id: u32) CpuidRegs {
|
||||
}
|
||||
}
|
||||
|
||||
var eax: u32 = undefined;
|
||||
var ebx: u32 = undefined;
|
||||
var ecx: u32 = undefined;
|
||||
var edx: u32 = undefined;
|
||||
var eax: u32 = 0;
|
||||
var ebx: u32 = 0;
|
||||
var ecx: u32 = 0;
|
||||
var edx: u32 = 0;
|
||||
|
||||
asm volatile ("cpuid"
|
||||
: [_] "={eax}" (eax),
|
||||
|
||||
@@ -3,7 +3,6 @@ const vk = @import("vulkan");
|
||||
const base = @import("base");
|
||||
|
||||
const VkError = base.VkError;
|
||||
const Device = base.Device;
|
||||
|
||||
const Self = @This();
|
||||
pub const Interface = base.PipelineLayout;
|
||||
|
||||
@@ -3,7 +3,6 @@ const vk = @import("vulkan");
|
||||
const base = @import("base");
|
||||
|
||||
const VkError = base.VkError;
|
||||
const Device = base.Device;
|
||||
|
||||
const Self = @This();
|
||||
pub const Interface = base.QueryPool;
|
||||
|
||||
@@ -3,7 +3,6 @@ const vk = @import("vulkan");
|
||||
const base = @import("base");
|
||||
|
||||
const VkError = base.VkError;
|
||||
const Device = base.Device;
|
||||
|
||||
const Self = @This();
|
||||
pub const Interface = base.RenderPass;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const std = @import("std");
|
||||
const vk = @import("vulkan");
|
||||
const base = @import("base");
|
||||
const kmd = @import("kmd.zig");
|
||||
|
||||
const VkError = base.VkError;
|
||||
const FlintImage = @import("FlintImage.zig");
|
||||
@@ -158,7 +157,7 @@ fn bitwiseCompatibleFormats(src: vk.Format, dst: vk.Format) bool {
|
||||
|
||||
fn nearestBlitCoordinate(src_0: i32, src_1: i32, dst_0: i32, dst_1: i32, dst: i32, extent: u32) usize {
|
||||
const numerator = @as(i64, 2 * (dst - dst_0) + 1) * @as(i64, src_1 - src_0);
|
||||
const denominator = @as(i64, 2 * (dst_1 - dst_0));
|
||||
const denominator: i64 = 2 * (dst_1 - dst_0);
|
||||
const coordinate = @as(i64, src_0) + @divFloor(numerator, denominator);
|
||||
return @intCast(std.math.clamp(coordinate, 0, @as(i64, extent) - 1));
|
||||
}
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
const vk = @import("vulkan");
|
||||
|
||||
pub const command_base = 0x40;
|
||||
pub const i915_gem_create = 0x1b;
|
||||
pub const i915_gem_mmap_gtt = 0x24;
|
||||
pub const i915_gem_set_domain = 0x1f;
|
||||
pub const i915_gem_execbuffer2 = 0x29;
|
||||
pub const gem_create = 0x1b;
|
||||
pub const gem_mmap_gtt = 0x24;
|
||||
pub const gem_set_domain = 0x1f;
|
||||
pub const gem_execbuffer2 = 0x29;
|
||||
pub const gem_close = 0x09;
|
||||
|
||||
pub const i915_mmap_offset_wb = 2;
|
||||
pub const i915_gem_domain_cpu = 0x00000001;
|
||||
pub const i915_gem_domain_gtt = 0x00000040;
|
||||
pub const i915_exec_blt = 3 << 0;
|
||||
pub const i915_exec_fence_array: u64 = 1 << 19;
|
||||
pub const i915_exec_fence_wait: u32 = 1 << 0;
|
||||
pub const i915_exec_fence_signal: u32 = 1 << 1;
|
||||
pub const mmap_offset_wb = 2;
|
||||
pub const gem_domain_cpu = 0x00000001;
|
||||
pub const gem_domain_gtt = 0x00000040;
|
||||
pub const exec_blt = 3 << 0;
|
||||
pub const exec_fence_array: u64 = 1 << 19;
|
||||
pub const exec_fence_wait: u32 = 1 << 0;
|
||||
pub const exec_fence_signal: u32 = 1 << 1;
|
||||
pub const exec_object_write = 1 << 2;
|
||||
pub const mi_flush_dw: u32 = (0x26 << 23) | 3;
|
||||
|
||||
+43
-26
@@ -2,13 +2,11 @@ const std = @import("std");
|
||||
const vk = @import("vulkan");
|
||||
const base = @import("base");
|
||||
|
||||
const drm = @import("drm.zig");
|
||||
const _i915 = @import("i915.zig");
|
||||
const common_kmd = @import("../kmd.zig");
|
||||
|
||||
const VkError = base.VkError;
|
||||
|
||||
const IOCTL = std.os.linux.IOCTL;
|
||||
|
||||
const Mapping = struct {
|
||||
bytes: []align(std.heap.page_size_min) u8,
|
||||
|
||||
@@ -33,12 +31,17 @@ pub const Device = struct {
|
||||
}
|
||||
|
||||
pub fn allocateMemory(self: *Device, io: std.Io, size: vk.DeviceSize) VkError!Memory {
|
||||
var create = drm.GemCreate{
|
||||
var create = _i915.GemCreate{
|
||||
.size = size,
|
||||
.handle = 0,
|
||||
.pad = 0,
|
||||
};
|
||||
base.utils.ioctl(self.card.handle, io, common_kmd.drmIoctlIowr(drm.command_base + drm.i915_gem_create, drm.GemCreate), &create) catch return VkError.OutOfDeviceMemory;
|
||||
base.utils.ioctl(
|
||||
self.card.handle,
|
||||
io,
|
||||
common_kmd.drmIoctlIowr(_i915.command_base + _i915.gem_create, _i915.GemCreate),
|
||||
&create,
|
||||
) catch return VkError.OutOfDeviceMemory;
|
||||
|
||||
var memory = Memory{
|
||||
.handle = create.handle,
|
||||
@@ -47,7 +50,7 @@ pub const Device = struct {
|
||||
};
|
||||
errdefer memory.deinit(self, io);
|
||||
|
||||
try memory.setDomain(self, io, drm.i915_gem_domain_cpu, 0);
|
||||
try memory.setDomain(self, io, _i915.gem_domain_cpu, 0);
|
||||
return memory;
|
||||
}
|
||||
|
||||
@@ -61,7 +64,7 @@ pub const Device = struct {
|
||||
const batch_map = try batch.map(self, io, 0, batch_size);
|
||||
const batch_words = std.mem.bytesAsSlice(u32, batch_map);
|
||||
@memcpy(batch_words[0..commands.len], commands);
|
||||
batch_words[commands.len + 0] = drm.mi_flush_dw;
|
||||
batch_words[commands.len + 0] = _i915.mi_flush_dw;
|
||||
batch_words[commands.len + 1] = 0;
|
||||
batch_words[commands.len + 2] = 0;
|
||||
batch_words[commands.len + 3] = 0;
|
||||
@@ -71,7 +74,7 @@ pub const Device = struct {
|
||||
}
|
||||
try batch.flushRange(self, io, 0, batch_size);
|
||||
|
||||
var objects = std.ArrayList(drm.ExecObject2).empty;
|
||||
var objects = std.ArrayList(_i915.ExecObject2).empty;
|
||||
defer objects.deinit(allocator);
|
||||
|
||||
var object_handles = std.ArrayList(u32).empty;
|
||||
@@ -86,17 +89,17 @@ pub const Device = struct {
|
||||
.relocs_ptr = 0,
|
||||
.alignment = 0,
|
||||
.offset = 0,
|
||||
.flags = if (relocation.write) drm.exec_object_write else 0,
|
||||
.flags = if (relocation.write) _i915.exec_object_write else 0,
|
||||
.rsvd1 = 0,
|
||||
.rsvd2 = 0,
|
||||
}) catch return VkError.OutOfHostMemory;
|
||||
} else if (relocation.write) {
|
||||
const index = std.mem.indexOfScalar(u32, object_handles.items, relocation.target_handle).?;
|
||||
objects.items[index].flags |= drm.exec_object_write;
|
||||
objects.items[index].flags |= _i915.exec_object_write;
|
||||
}
|
||||
}
|
||||
|
||||
var i915_relocations = std.ArrayList(drm.RelocationEntry).empty;
|
||||
var i915_relocations = std.ArrayList(_i915.RelocationEntry).empty;
|
||||
defer i915_relocations.deinit(allocator);
|
||||
|
||||
for (relocations) |relocation| {
|
||||
@@ -121,17 +124,16 @@ pub const Device = struct {
|
||||
.rsvd2 = 0,
|
||||
}) catch return VkError.OutOfHostMemory;
|
||||
|
||||
var exec_fences = std.ArrayList(drm.ExecFence).empty;
|
||||
var exec_fences = std.ArrayList(_i915.ExecFence).empty;
|
||||
defer exec_fences.deinit(allocator);
|
||||
for (syncs) |sync| {
|
||||
exec_fences.append(allocator, .{
|
||||
.handle = sync.handle,
|
||||
.flags = (if (sync.wait) drm.i915_exec_fence_wait else 0) |
|
||||
(if (sync.signal) drm.i915_exec_fence_signal else 0),
|
||||
.flags = (if (sync.wait) _i915.exec_fence_wait else 0) | (if (sync.signal) _i915.exec_fence_signal else 0),
|
||||
}) catch return VkError.OutOfHostMemory;
|
||||
}
|
||||
|
||||
var execbuffer = drm.ExecBuffer2{
|
||||
var execbuffer = _i915.ExecBuffer2{
|
||||
.buffers_ptr = @intFromPtr(objects.items.ptr),
|
||||
.buffer_count = @intCast(objects.items.len),
|
||||
.batch_start_offset = 0,
|
||||
@@ -140,11 +142,16 @@ pub const Device = struct {
|
||||
.DR4 = 0,
|
||||
.num_cliprects = @intCast(exec_fences.items.len),
|
||||
.cliprects_ptr = if (exec_fences.items.len == 0) 0 else @intFromPtr(exec_fences.items.ptr),
|
||||
.flags = drm.i915_exec_blt | (if (exec_fences.items.len == 0) 0 else drm.i915_exec_fence_array),
|
||||
.flags = _i915.exec_blt | (if (exec_fences.items.len == 0) 0 else _i915.exec_fence_array),
|
||||
.rsvd1 = 0,
|
||||
.rsvd2 = 0,
|
||||
};
|
||||
base.utils.ioctl(self.card.handle, io, common_kmd.drmIoctlIowr(drm.command_base + drm.i915_gem_execbuffer2, drm.ExecBuffer2), &execbuffer) catch return VkError.DeviceLost;
|
||||
base.utils.ioctl(
|
||||
self.card.handle,
|
||||
io,
|
||||
common_kmd.drmIoctlIowr(_i915.command_base + _i915.gem_execbuffer2, _i915.ExecBuffer2),
|
||||
&execbuffer,
|
||||
) catch return VkError.DeviceLost;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -156,11 +163,11 @@ pub const Memory = struct {
|
||||
pub fn deinit(self: *Memory, device: *Device, io: std.Io) void {
|
||||
self.unmap();
|
||||
|
||||
var close = drm.GemClose{
|
||||
var close = _i915.GemClose{
|
||||
.handle = self.handle,
|
||||
.pad = 0,
|
||||
};
|
||||
base.utils.ioctl(device.card.handle, io, common_kmd.drmIoctlIow(drm.gem_close, drm.GemClose), &close) catch {};
|
||||
base.utils.ioctl(device.card.handle, io, common_kmd.drmIoctlIow(_i915.gem_close, _i915.GemClose), &close) catch @panic("Caught an error while handling an error");
|
||||
|
||||
self.* = undefined;
|
||||
}
|
||||
@@ -176,14 +183,19 @@ pub const Memory = struct {
|
||||
return mapping.slice(offset, map_size);
|
||||
}
|
||||
|
||||
var mmap_offset = drm.GemMmapOffset{
|
||||
var mmap_offset = _i915.GemMmapOffset{
|
||||
.handle = self.handle,
|
||||
.pad = 0,
|
||||
.offset = 0,
|
||||
.flags = drm.i915_mmap_offset_wb,
|
||||
.flags = _i915.mmap_offset_wb,
|
||||
.extensions = 0,
|
||||
};
|
||||
base.utils.ioctl(device.card.handle, io, common_kmd.drmIoctlIowr(drm.command_base + drm.i915_gem_mmap_gtt, drm.GemMmapOffset), &mmap_offset) catch return VkError.MemoryMapFailed;
|
||||
base.utils.ioctl(
|
||||
device.card.handle,
|
||||
io,
|
||||
common_kmd.drmIoctlIowr(_i915.command_base + _i915.gem_mmap_gtt, _i915.GemMmapOffset),
|
||||
&mmap_offset,
|
||||
) catch return VkError.MemoryMapFailed;
|
||||
|
||||
if (self.size > std.math.maxInt(usize)) return VkError.MemoryMapFailed;
|
||||
const full_size: usize = @intCast(self.size);
|
||||
@@ -210,21 +222,26 @@ pub const Memory = struct {
|
||||
pub fn flushRange(self: *Memory, device: *Device, io: std.Io, offset: vk.DeviceSize, size: vk.DeviceSize) VkError!void {
|
||||
_ = offset;
|
||||
_ = size;
|
||||
try self.setDomain(device, io, drm.i915_gem_domain_cpu, 0);
|
||||
try self.setDomain(device, io, _i915.gem_domain_cpu, 0);
|
||||
}
|
||||
|
||||
pub fn invalidateRange(self: *Memory, device: *Device, io: std.Io, offset: vk.DeviceSize, size: vk.DeviceSize) VkError!void {
|
||||
_ = offset;
|
||||
_ = size;
|
||||
try self.setDomain(device, io, drm.i915_gem_domain_cpu, 0);
|
||||
try self.setDomain(device, io, _i915.gem_domain_cpu, 0);
|
||||
}
|
||||
|
||||
fn setDomain(self: *Memory, device: *Device, io: std.Io, read_domains: u32, write_domain: u32) VkError!void {
|
||||
var domain = drm.GemSetDomain{
|
||||
var domain = _i915.GemSetDomain{
|
||||
.handle = self.handle,
|
||||
.read_domains = read_domains,
|
||||
.write_domain = write_domain,
|
||||
};
|
||||
base.utils.ioctl(device.card.handle, io, common_kmd.drmIoctlIow(drm.command_base + drm.i915_gem_set_domain, drm.GemSetDomain), &domain) catch return VkError.DeviceLost;
|
||||
base.utils.ioctl(
|
||||
device.card.handle,
|
||||
io,
|
||||
common_kmd.drmIoctlIow(_i915.command_base + _i915.gem_set_domain, _i915.GemSetDomain),
|
||||
&domain,
|
||||
) catch return VkError.DeviceLost;
|
||||
}
|
||||
};
|
||||
|
||||
+53
-52
@@ -1,7 +1,8 @@
|
||||
const std = @import("std");
|
||||
const vk = @import("vulkan");
|
||||
const base = @import("base");
|
||||
const lib = @import("lib.zig");
|
||||
|
||||
const KmdType = @import("lib.zig").KmdType;
|
||||
|
||||
const FlintPhysicalDevice = @import("FlintPhysicalDevice.zig");
|
||||
const i915_kmd = @import("i915/kmd.zig");
|
||||
@@ -32,128 +33,128 @@ pub const SyncDependency = struct {
|
||||
signal: bool = false,
|
||||
};
|
||||
|
||||
pub const Device = union(lib.KmdType) {
|
||||
Invalid: void,
|
||||
I915: i915_kmd.Device,
|
||||
Xe: xe.Device,
|
||||
pub const Device = union(KmdType) {
|
||||
invalid: void,
|
||||
i915: i915_kmd.Device,
|
||||
xe: xe.Device,
|
||||
|
||||
pub fn open(io: std.Io, physical_device: *const FlintPhysicalDevice) VkError!Device {
|
||||
return switch (physical_device.kmd_type) {
|
||||
.I915 => .{ .I915 = try i915_kmd.Device.open(io, physical_device.getNodePath()) },
|
||||
.Xe => .{ .Xe = try xe.Device.open(io, physical_device.getNodePath()) },
|
||||
.Invalid => VkError.InitializationFailed,
|
||||
.i915 => .{ .i915 = try i915_kmd.Device.open(io, physical_device.getNodePath()) },
|
||||
.xe => .{ .xe = try xe.Device.open(io, physical_device.getNodePath()) },
|
||||
.invalid => VkError.InitializationFailed,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn close(self: *Device, io: std.Io) void {
|
||||
switch (self.*) {
|
||||
.I915 => |*device| device.close(io),
|
||||
.Xe => |*device| device.close(io),
|
||||
.Invalid => {},
|
||||
.i915 => |*device| device.close(io),
|
||||
.xe => |*device| device.close(io),
|
||||
.invalid => {},
|
||||
}
|
||||
self.* = .{ .Invalid = {} };
|
||||
self.* = .{ .invalid = {} };
|
||||
}
|
||||
|
||||
pub fn allocateMemory(self: *Device, io: std.Io, size: vk.DeviceSize) VkError!Memory {
|
||||
return switch (self.*) {
|
||||
.I915 => |*device| .{ .I915 = try device.allocateMemory(io, size) },
|
||||
.Xe => |*device| .{ .Xe = try device.allocateMemory(io, size) },
|
||||
.Invalid => VkError.OutOfDeviceMemory,
|
||||
.i915 => |*device| .{ .i915 = try device.allocateMemory(io, size) },
|
||||
.xe => |*device| .{ .xe = try device.allocateMemory(io, size) },
|
||||
.invalid => VkError.OutOfDeviceMemory,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn submitBatch(self: *Device, io: std.Io, allocator: std.mem.Allocator, commands: []const u32, relocations: []const Relocation, syncs: []const SyncDependency) VkError!void {
|
||||
return switch (self.*) {
|
||||
.I915 => |*device| device.submitBatch(io, allocator, commands, relocations, syncs),
|
||||
.Xe => |*device| device.submitBatch(io, allocator, commands, relocations, syncs),
|
||||
.Invalid => VkError.DeviceLost,
|
||||
.i915 => |*device| device.submitBatch(io, allocator, commands, relocations, syncs),
|
||||
.xe => |*device| device.submitBatch(io, allocator, commands, relocations, syncs),
|
||||
.invalid => VkError.DeviceLost,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn file(self: *Device) VkError!std.Io.File {
|
||||
return switch (self.*) {
|
||||
.I915 => |*device| device.card.handle,
|
||||
.Xe => |*device| device.card.handle,
|
||||
.Invalid => VkError.DeviceLost,
|
||||
.i915 => |*device| device.card.handle,
|
||||
.xe => |*device| device.card.handle,
|
||||
.invalid => VkError.DeviceLost,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
pub const Memory = union(lib.KmdType) {
|
||||
Invalid: void,
|
||||
I915: i915_kmd.Memory,
|
||||
Xe: xe.Memory,
|
||||
pub const Memory = union(KmdType) {
|
||||
invalid: void,
|
||||
i915: i915_kmd.Memory,
|
||||
xe: xe.Memory,
|
||||
|
||||
pub fn deinit(self: *Memory, device: *Device, io: std.Io) void {
|
||||
switch (self.*) {
|
||||
.I915 => |*memory| switch (device.*) {
|
||||
.I915 => |*adapter| memory.deinit(adapter, io),
|
||||
.i915 => |*memory| switch (device.*) {
|
||||
.i915 => |*adapter| memory.deinit(adapter, io),
|
||||
else => {},
|
||||
},
|
||||
.Xe => |*memory| switch (device.*) {
|
||||
.Xe => |*adapter| memory.deinit(adapter, io),
|
||||
.xe => |*memory| switch (device.*) {
|
||||
.xe => |*adapter| memory.deinit(adapter, io),
|
||||
else => {},
|
||||
},
|
||||
.Invalid => {},
|
||||
.invalid => {},
|
||||
}
|
||||
self.* = .{ .Invalid = {} };
|
||||
self.* = .{ .invalid = {} };
|
||||
}
|
||||
|
||||
pub fn map(self: *Memory, device: *Device, io: std.Io, offset: vk.DeviceSize, size: vk.DeviceSize) VkError![]u8 {
|
||||
return switch (self.*) {
|
||||
.I915 => |*memory| switch (device.*) {
|
||||
.I915 => |*adapter| memory.map(adapter, io, offset, size),
|
||||
.i915 => |*memory| switch (device.*) {
|
||||
.i915 => |*adapter| memory.map(adapter, io, offset, size),
|
||||
else => VkError.MemoryMapFailed,
|
||||
},
|
||||
.Xe => |*memory| switch (device.*) {
|
||||
.Xe => |*adapter| memory.map(adapter, io, offset, size),
|
||||
.xe => |*memory| switch (device.*) {
|
||||
.xe => |*adapter| memory.map(adapter, io, offset, size),
|
||||
else => VkError.MemoryMapFailed,
|
||||
},
|
||||
.Invalid => VkError.MemoryMapFailed,
|
||||
.invalid => VkError.MemoryMapFailed,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn unmap(self: *Memory) void {
|
||||
switch (self.*) {
|
||||
.I915 => |*memory| memory.unmap(),
|
||||
.Xe => |*memory| memory.unmap(),
|
||||
.Invalid => {},
|
||||
.i915 => |*memory| memory.unmap(),
|
||||
.xe => |*memory| memory.unmap(),
|
||||
.invalid => {},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn flushRange(self: *Memory, device: *Device, io: std.Io, offset: vk.DeviceSize, size: vk.DeviceSize) VkError!void {
|
||||
return switch (self.*) {
|
||||
.I915 => |*memory| switch (device.*) {
|
||||
.I915 => |*adapter| memory.flushRange(adapter, io, offset, size),
|
||||
.i915 => |*memory| switch (device.*) {
|
||||
.i915 => |*adapter| memory.flushRange(adapter, io, offset, size),
|
||||
else => VkError.InvalidDeviceMemoryDrv,
|
||||
},
|
||||
.Xe => |*memory| switch (device.*) {
|
||||
.Xe => |*adapter| memory.flushRange(adapter, io, offset, size),
|
||||
.xe => |*memory| switch (device.*) {
|
||||
.xe => |*adapter| memory.flushRange(adapter, io, offset, size),
|
||||
else => VkError.InvalidDeviceMemoryDrv,
|
||||
},
|
||||
.Invalid => VkError.InvalidDeviceMemoryDrv,
|
||||
.invalid => VkError.InvalidDeviceMemoryDrv,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn invalidateRange(self: *Memory, device: *Device, io: std.Io, offset: vk.DeviceSize, size: vk.DeviceSize) VkError!void {
|
||||
return switch (self.*) {
|
||||
.I915 => |*memory| switch (device.*) {
|
||||
.I915 => |*adapter| memory.invalidateRange(adapter, io, offset, size),
|
||||
.i915 => |*memory| switch (device.*) {
|
||||
.i915 => |*adapter| memory.invalidateRange(adapter, io, offset, size),
|
||||
else => VkError.InvalidDeviceMemoryDrv,
|
||||
},
|
||||
.Xe => |*memory| switch (device.*) {
|
||||
.Xe => |*adapter| memory.invalidateRange(adapter, io, offset, size),
|
||||
.xe => |*memory| switch (device.*) {
|
||||
.xe => |*adapter| memory.invalidateRange(adapter, io, offset, size),
|
||||
else => VkError.InvalidDeviceMemoryDrv,
|
||||
},
|
||||
.Invalid => VkError.InvalidDeviceMemoryDrv,
|
||||
.invalid => VkError.InvalidDeviceMemoryDrv,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn handle(self: *const Memory) VkError!u32 {
|
||||
return switch (self.*) {
|
||||
.I915 => |*memory| memory.handle,
|
||||
.Xe => VkError.FeatureNotPresent,
|
||||
.Invalid => VkError.InvalidDeviceMemoryDrv,
|
||||
.i915 => |*memory| memory.handle,
|
||||
.xe => VkError.FeatureNotPresent,
|
||||
.invalid => VkError.InvalidDeviceMemoryDrv,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
+3
-3
@@ -52,9 +52,9 @@ pub const VULKAN_VERSION = vk.makeApiVersion(
|
||||
pub const IMAGE_MEMORY_ALIGNMENT = std.heap.page_size_max;
|
||||
|
||||
pub const KmdType = enum {
|
||||
Invalid,
|
||||
I915,
|
||||
Xe,
|
||||
invalid,
|
||||
i915,
|
||||
xe,
|
||||
};
|
||||
|
||||
pub const std_options = base.std_options;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
const std = @import("std");
|
||||
|
||||
const PciInfo = struct {
|
||||
id: u16,
|
||||
name: []const u8,
|
||||
|
||||
Reference in New Issue
Block a user