cleaning dispatchable handle support
This commit is contained in:
@@ -15,13 +15,7 @@ pub fn init(self: *Self, p_infos: ?*const vk.InstanceCreateInfo, callbacks: ?*co
|
||||
return error.InvalidCreateInfos;
|
||||
}
|
||||
|
||||
self.vtable = .{
|
||||
.destroyInstance = null,
|
||||
.enumeratePhysicalDevices = null,
|
||||
.enumerateInstanceVersion = null,
|
||||
//.enumerateInstanceLayerProperties = null,
|
||||
.enumerateInstanceExtensionProperties = null,
|
||||
};
|
||||
self.vtable = .{};
|
||||
|
||||
if (callbacks) |c| {
|
||||
self.alloc_callbacks = c.*;
|
||||
@@ -37,6 +31,7 @@ pub fn getProcAddr(self: *const Self, name: []const u8) vk.PfnVoidFunction {
|
||||
.{ "vkEnumeratePhysicalDevices", @ptrCast(self.vtable.enumeratePhysicalDevices) },
|
||||
.{ "vkEnumerateInstanceVersion", @ptrCast(self.vtable.enumerateInstanceVersion) },
|
||||
.{ "vkEnumerateInstanceExtensionProperties", @ptrCast(self.vtable.enumerateInstanceExtensionProperties) },
|
||||
.{ "vkGetPhysicalDeviceProperties", @ptrCast(self.vtable.getPhysicalDeviceProperties) },
|
||||
}, allocator) catch return null;
|
||||
defer pfn_map.deinit(allocator);
|
||||
|
||||
@@ -44,9 +39,10 @@ pub fn getProcAddr(self: *const Self, name: []const u8) vk.PfnVoidFunction {
|
||||
}
|
||||
|
||||
pub const VTable = struct {
|
||||
destroyInstance: ?vk.PfnDestroyInstance,
|
||||
enumeratePhysicalDevices: ?vk.PfnEnumeratePhysicalDevices,
|
||||
enumerateInstanceVersion: ?vk.PfnEnumerateInstanceVersion,
|
||||
//enumerateInstanceLayerProperties: vk.PfnEnumerateInstanceProperties,
|
||||
enumerateInstanceExtensionProperties: ?vk.PfnEnumerateInstanceExtensionProperties,
|
||||
destroyInstance: ?vk.PfnDestroyInstance = null,
|
||||
enumeratePhysicalDevices: ?vk.PfnEnumeratePhysicalDevices = null,
|
||||
enumerateInstanceVersion: ?vk.PfnEnumerateInstanceVersion = null,
|
||||
//enumerateInstanceLayerProperties: vk.PfnEnumerateInstanceProperties = null,
|
||||
enumerateInstanceExtensionProperties: ?vk.PfnEnumerateInstanceExtensionProperties = null,
|
||||
getPhysicalDeviceProperties: ?vk.PfnGetPhysicalDeviceProperties = null,
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ const vk = @import("vulkan");
|
||||
const Instance = @import("Instance.zig");
|
||||
|
||||
const Self = @This();
|
||||
const ObjectType: vk.ObjectType = .physical_device;
|
||||
pub const ObjectType: vk.ObjectType = .physical_device;
|
||||
|
||||
props: vk.PhysicalDeviceProperties,
|
||||
queue_families: [3]vk.QueueFamilyProperties,
|
||||
|
||||
@@ -12,11 +12,11 @@ pub fn Dispatchable(comptime T: type) type {
|
||||
object_type: vk.ObjectType,
|
||||
object: *T,
|
||||
|
||||
pub fn create(allocator: std.mem.Allocator, object_type: vk.ObjectType) !*Self {
|
||||
pub fn create(allocator: std.mem.Allocator) !*Self {
|
||||
const object = try allocator.create(Self);
|
||||
object.* = .{
|
||||
.loader_data = .{ .loaderMagic = c.ICD_LOADER_MAGIC },
|
||||
.object_type = object_type,
|
||||
.object_type = T.ObjectType,
|
||||
.object = try allocator.create(T),
|
||||
};
|
||||
return object;
|
||||
@@ -26,6 +26,10 @@ pub fn Dispatchable(comptime T: type) type {
|
||||
allocator.destroy(self.object);
|
||||
allocator.destroy(self);
|
||||
}
|
||||
|
||||
pub inline fn toHandle(self: *Self) usize {
|
||||
return @intFromPtr(self);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -40,6 +44,7 @@ pub inline fn fromHandle(comptime T: type, handle: usize) !*Dispatchable(T) {
|
||||
return dispatchable;
|
||||
}
|
||||
|
||||
pub inline fn toHandle(comptime T: type, handle: *Dispatchable(T)) usize {
|
||||
return @intFromPtr(handle);
|
||||
pub inline fn fromHandleObject(comptime T: type, handle: usize) !*T {
|
||||
const dispatchable_handle = try fromHandle(T, handle);
|
||||
return dispatchable_handle.object;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ pub const dispatchable = @import("dispatchable.zig");
|
||||
pub const Instance = @import("Instance.zig");
|
||||
pub const PhysicalDevice = @import("PhysicalDevice.zig");
|
||||
|
||||
pub const DRIVER_VERSION = vk.makeApiVersion(0, 0, 0, 1);
|
||||
pub const DRIVER_VULKAN_VERSION = vk.makeApiVersion(0, 1, 0, 0);
|
||||
|
||||
pub const std_options: std.Options = .{
|
||||
.log_level = .info,
|
||||
.logFn = logFn,
|
||||
|
||||
Reference in New Issue
Block a user