fixing debug allocator
This commit is contained in:
+14
-1
@@ -50,7 +50,7 @@ pub fn init(allocator: std.mem.Allocator, infos: *const vk.InstanceCreateInfo) V
|
||||
};
|
||||
}
|
||||
|
||||
/// Dummy for docs creation and stuff
|
||||
/// Dummy to avoid compile error in tests and doc generation
|
||||
pub fn create(allocator: std.mem.Allocator, infos: *const vk.InstanceCreateInfo) VkError!*Self {
|
||||
_ = allocator;
|
||||
_ = infos;
|
||||
@@ -62,6 +62,19 @@ pub fn deinit(self: *Self, allocator: std.mem.Allocator) VkError!void {
|
||||
try self.dispatch_table.destroy(self, allocator);
|
||||
}
|
||||
|
||||
pub fn enumerateLayerProperties(count: *u32, p_properties: ?[*]vk.LayerProperties) VkError!void {
|
||||
if (comptime !builtin.is_test and @hasDecl(root.Instance, "LAYERS")) {
|
||||
count.* = root.Instance.LAYERS.len;
|
||||
if (p_properties) |properties| {
|
||||
for (root.Instance.LAYERS, properties[0..]) |layer, *prop| {
|
||||
prop.* = layer;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
count.* = 0;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enumerateExtensionProperties(layer_name: ?[]const u8, count: *u32, p_properties: ?[*]vk.ExtensionProperties) VkError!void {
|
||||
if (layer_name) |_| {
|
||||
return VkError.LayerNotPresent;
|
||||
|
||||
@@ -23,6 +23,7 @@ pub const DispatchTable = struct {
|
||||
getImageFormatProperties: *const fn (*Self, vk.Format, vk.ImageType, vk.ImageTiling, vk.ImageUsageFlags, vk.ImageCreateFlags) VkError!vk.ImageFormatProperties,
|
||||
getSparseImageFormatProperties: *const fn (*Self, vk.Format, vk.ImageType, vk.SampleCountFlags, vk.ImageTiling, vk.ImageUsageFlags, ?[*]vk.SparseImageFormatProperties) VkError!u32,
|
||||
enumerateExtensionProperties: *const fn (*const Self, ?[]const u8, *u32, ?[*]vk.ExtensionProperties) VkError!void,
|
||||
enumerateLayerProperties: *const fn (*const Self, *u32, ?[*]vk.LayerProperties) VkError!void,
|
||||
release: *const fn (*Self, std.mem.Allocator) VkError!void,
|
||||
|
||||
// VK_KHR_get_physical_device_properties_2
|
||||
@@ -71,6 +72,10 @@ pub inline fn enumerateExtensionProperties(self: *const Self, layer_name: ?[]con
|
||||
return try self.dispatch_table.enumerateExtensionProperties(self, layer_name, count, p_properties);
|
||||
}
|
||||
|
||||
pub inline fn enumerateLayerProperties(self: *const Self, count: *u32, p_properties: ?[*]vk.LayerProperties) VkError!void {
|
||||
return try self.dispatch_table.enumerateLayerProperties(self, count, p_properties);
|
||||
}
|
||||
|
||||
pub inline fn getImageFormatProperties(
|
||||
self: *Self,
|
||||
format: vk.Format,
|
||||
|
||||
@@ -48,11 +48,11 @@ pub const SurfaceKHR = @import("wsi/SurfaceKHR.zig");
|
||||
pub const SwapchainKHR = @import("wsi/SwapchainKHR.zig");
|
||||
pub const WaylandSurfaceKHR = @import("wsi/WaylandSurfaceKHR.zig");
|
||||
|
||||
fn entryPointBeginLogTrace(comptime scope: @EnumLiteral()) void {
|
||||
inline fn entryPointBeginLogTrace(comptime scope: @EnumLiteral()) void {
|
||||
std.log.scoped(scope).debug("Calling {s}...", .{@tagName(scope)});
|
||||
}
|
||||
|
||||
fn entryPointEndLogTrace() void {}
|
||||
inline fn entryPointEndLogTrace() void {}
|
||||
|
||||
inline fn notImplementedWarning() void {
|
||||
logger.fixme("function not yet implemented", .{});
|
||||
@@ -79,6 +79,7 @@ const icd_pfn_map = std.StaticStringMap(vk.PfnVoidFunction).initComptime(.{
|
||||
const global_pfn_map = std.StaticStringMap(vk.PfnVoidFunction).initComptime(.{
|
||||
functionMapEntryPoint("vkCreateInstance"),
|
||||
functionMapEntryPoint("vkEnumerateInstanceExtensionProperties"),
|
||||
functionMapEntryPoint("vkEnumerateInstanceLayerProperties"),
|
||||
//functionMapEntryPoint("vkEnumerateInstanceVersion"),
|
||||
functionMapEntryPoint("vkGetInstanceProcAddr"),
|
||||
});
|
||||
@@ -94,6 +95,7 @@ const instance_pfn_map = std.StaticStringMap(vk.PfnVoidFunction).initComptime(.{
|
||||
const physical_device_pfn_map = std.StaticStringMap(vk.PfnVoidFunction).initComptime(.{
|
||||
functionMapEntryPoint("vkCreateDevice"),
|
||||
functionMapEntryPoint("vkEnumerateDeviceExtensionProperties"),
|
||||
functionMapEntryPoint("vkEnumerateDeviceLayerProperties"),
|
||||
functionMapEntryPoint("vkGetPhysicalDeviceFeatures"),
|
||||
functionMapEntryPoint("vkGetPhysicalDeviceFeatures2KHR"),
|
||||
functionMapEntryPoint("vkGetPhysicalDeviceFormatProperties"),
|
||||
@@ -316,6 +318,14 @@ pub export fn strollCreateInstance(info: *const vk.InstanceCreateInfo, callbacks
|
||||
return .success;
|
||||
}
|
||||
|
||||
pub export fn strollEnumerateInstanceLayerProperties(property_count: *u32, properties: ?[*]vk.LayerProperties) callconv(vk.vulkan_call_conv) vk.Result {
|
||||
entryPointBeginLogTrace(.vkEnumerateInstanceLayerProperties);
|
||||
defer entryPointEndLogTrace();
|
||||
|
||||
Instance.enumerateLayerProperties(property_count, properties) catch |err| return toVkResult(err);
|
||||
return .success;
|
||||
}
|
||||
|
||||
pub export fn strollEnumerateInstanceExtensionProperties(p_layer_name: ?[*:0]const u8, property_count: *u32, properties: ?[*]vk.ExtensionProperties) callconv(vk.vulkan_call_conv) vk.Result {
|
||||
entryPointBeginLogTrace(.vkEnumerateInstanceExtensionProperties);
|
||||
defer entryPointEndLogTrace();
|
||||
@@ -328,6 +338,7 @@ pub export fn strollEnumerateInstanceExtensionProperties(p_layer_name: ?[*:0]con
|
||||
return .success;
|
||||
}
|
||||
|
||||
/// Do not make it available to GetProcAddr until Vulkan 1.1 is implemented
|
||||
pub export fn strollEnumerateInstanceVersion(version: *u32) callconv(vk.vulkan_call_conv) vk.Result {
|
||||
entryPointBeginLogTrace(.vkEnumerateInstanceVersion);
|
||||
defer entryPointEndLogTrace();
|
||||
@@ -382,6 +393,15 @@ pub export fn strollCreateDevice(p_physical_device: vk.PhysicalDevice, info: *co
|
||||
return .success;
|
||||
}
|
||||
|
||||
pub export fn strollEnumerateDeviceLayerProperties(p_physical_device: vk.PhysicalDevice, property_count: *u32, properties: ?[*]vk.LayerProperties) callconv(vk.vulkan_call_conv) vk.Result {
|
||||
entryPointBeginLogTrace(.vkEnumerateDeviceLayerProperties);
|
||||
defer entryPointEndLogTrace();
|
||||
|
||||
const physical_device = Dispatchable(PhysicalDevice).fromHandleObject(p_physical_device) catch |err| return toVkResult(err);
|
||||
physical_device.enumerateLayerProperties(property_count, properties) catch |err| return toVkResult(err);
|
||||
return .success;
|
||||
}
|
||||
|
||||
pub export fn strollEnumerateDeviceExtensionProperties(p_physical_device: vk.PhysicalDevice, p_layer_name: ?[*:0]const u8, property_count: *u32, properties: ?[*]vk.ExtensionProperties) callconv(vk.vulkan_call_conv) vk.Result {
|
||||
entryPointBeginLogTrace(.vkEnumerateDeviceExtensionProperties);
|
||||
defer entryPointEndLogTrace();
|
||||
|
||||
Reference in New Issue
Block a user