forked from mirror/vulkan-zig
Compare commits
8 Commits
zig-0.15-c
...
zig-compat
| Author | SHA1 | Date | |
|---|---|---|---|
| d1902bddd6 | |||
|
|
8961518db2 | ||
|
|
7acf3a1163 | ||
|
|
4b7b9a8b94 | ||
|
|
4066c2c526 | ||
|
|
c9c4dae703 | ||
|
|
ecf97034c4 | ||
|
|
3c7d4021e9 |
@@ -2,7 +2,7 @@
|
||||
.name = .vulkan,
|
||||
.fingerprint = 0xbe155a03c72db6af,
|
||||
.version = "0.0.0",
|
||||
.minimum_zig_version = "0.15.0-dev.1518+749f10af4",
|
||||
.minimum_zig_version = "0.15.1",
|
||||
.paths = .{
|
||||
"build.zig",
|
||||
"LICENSE",
|
||||
|
||||
@@ -35,6 +35,7 @@ pub const GraphicsContext = struct {
|
||||
vkb: BaseWrapper,
|
||||
|
||||
instance: Instance,
|
||||
debug_messenger: vk.DebugUtilsMessengerEXT,
|
||||
surface: vk.SurfaceKHR,
|
||||
pdev: vk.PhysicalDevice,
|
||||
props: vk.PhysicalDeviceProperties,
|
||||
@@ -51,10 +52,11 @@ pub const GraphicsContext = struct {
|
||||
|
||||
var extension_names: std.ArrayList([*:0]const u8) = .empty;
|
||||
defer extension_names.deinit(allocator);
|
||||
// these extensions are to support vulkan in mac os
|
||||
try extension_names.append(allocator, vk.extensions.ext_debug_utils.name);
|
||||
// the following extensions are to support vulkan in mac os
|
||||
// see https://github.com/glfw/glfw/issues/2335
|
||||
try extension_names.append(allocator, "VK_KHR_portability_enumeration");
|
||||
try extension_names.append(allocator, "VK_KHR_get_physical_device_properties2");
|
||||
try extension_names.append(allocator, vk.extensions.khr_portability_enumeration.name);
|
||||
try extension_names.append(allocator, vk.extensions.khr_get_physical_device_properties_2.name);
|
||||
|
||||
var glfw_exts_count: u32 = 0;
|
||||
const glfw_exts = c.glfwGetRequiredInstanceExtensions(&glfw_exts_count);
|
||||
@@ -81,6 +83,22 @@ pub const GraphicsContext = struct {
|
||||
self.instance = Instance.init(instance, vki);
|
||||
errdefer self.instance.destroyInstance(null);
|
||||
|
||||
self.debug_messenger = try self.instance.createDebugUtilsMessengerEXT(&.{
|
||||
.message_severity = .{
|
||||
//.verbose_bit_ext = true,
|
||||
//.info_bit_ext = true,
|
||||
.warning_bit_ext = true,
|
||||
.error_bit_ext = true,
|
||||
},
|
||||
.message_type = .{
|
||||
.general_bit_ext = true,
|
||||
.validation_bit_ext = true,
|
||||
.performance_bit_ext = true,
|
||||
},
|
||||
.pfn_user_callback = &debugUtilsMessengerCallback,
|
||||
.p_user_data = null,
|
||||
}, null);
|
||||
|
||||
self.surface = try createSurface(self.instance, window);
|
||||
errdefer self.instance.destroySurfaceKHR(self.surface, null);
|
||||
|
||||
@@ -107,6 +125,7 @@ pub const GraphicsContext = struct {
|
||||
pub fn deinit(self: GraphicsContext) void {
|
||||
self.dev.destroyDevice(null);
|
||||
self.instance.destroySurfaceKHR(self.surface, null);
|
||||
self.instance.destroyDebugUtilsMessengerEXT(self.debug_messenger, null);
|
||||
self.instance.destroyInstance(null);
|
||||
|
||||
// Don't forget to free the tables to prevent a memory leak.
|
||||
@@ -196,6 +215,17 @@ const QueueAllocation = struct {
|
||||
present_family: u32,
|
||||
};
|
||||
|
||||
fn debugUtilsMessengerCallback(severity: vk.DebugUtilsMessageSeverityFlagsEXT, msg_type: vk.DebugUtilsMessageTypeFlagsEXT, callback_data: ?*const vk.DebugUtilsMessengerCallbackDataEXT, _: ?*anyopaque) callconv(.c) vk.Bool32 {
|
||||
const severity_str = if (severity.verbose_bit_ext) "verbose" else if (severity.info_bit_ext) "info" else if (severity.warning_bit_ext) "warning" else if (severity.error_bit_ext) "error" else "unknown";
|
||||
|
||||
const type_str = if (msg_type.general_bit_ext) "general" else if (msg_type.validation_bit_ext) "validation" else if (msg_type.performance_bit_ext) "performance" else if (msg_type.device_address_binding_bit_ext) "device addr" else "unknown";
|
||||
|
||||
const message: [*c]const u8 = if (callback_data) |cb_data| cb_data.p_message else "NO MESSAGE!";
|
||||
std.debug.print("[{s}][{s}]. Message:\n {s}\n", .{ severity_str, type_str, message });
|
||||
|
||||
return .false;
|
||||
}
|
||||
|
||||
fn pickPhysicalDevice(
|
||||
instance: Instance,
|
||||
allocator: Allocator,
|
||||
|
||||
@@ -52,7 +52,7 @@ pub fn isZigPrimitiveType(name: []const u8) bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
pub fn writeIdentifier(w: *std.io.Writer, id: []const u8) !void {
|
||||
pub fn writeIdentifier(w: *std.Io.Writer, id: []const u8) !void {
|
||||
try w.print("{f}", .{std.zig.fmtId(id)});
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ pub const SegmentIterator = struct {
|
||||
|
||||
pub const IdRenderer = struct {
|
||||
tags: []const []const u8,
|
||||
text_cache: std.io.Writer.Allocating,
|
||||
text_cache: std.Io.Writer.Allocating,
|
||||
|
||||
pub fn init(allocator: Allocator, tags: []const []const u8) IdRenderer {
|
||||
return .{
|
||||
|
||||
@@ -102,18 +102,18 @@ pub fn main() !void {
|
||||
};
|
||||
|
||||
const cwd = std.fs.cwd();
|
||||
const xml_src = cwd.readFileAlloc(allocator, xml_path, std.math.maxInt(usize)) catch |err| {
|
||||
const xml_src = cwd.readFileAlloc(xml_path, allocator, .unlimited) catch |err| {
|
||||
std.process.fatal("failed to open input file '{s}' ({s})", .{ xml_path, @errorName(err) });
|
||||
};
|
||||
|
||||
const maybe_video_xml_src = if (maybe_video_xml_path) |video_xml_path|
|
||||
cwd.readFileAlloc(allocator, video_xml_path, std.math.maxInt(usize)) catch |err| {
|
||||
cwd.readFileAlloc(video_xml_path, allocator, .unlimited) catch |err| {
|
||||
std.process.fatal("failed to open input file '{s}' ({s})", .{ video_xml_path, @errorName(err) });
|
||||
}
|
||||
else
|
||||
null;
|
||||
|
||||
var aw: std.io.Writer.Allocating = .init(allocator);
|
||||
var aw: std.Io.Writer.Allocating = .init(allocator);
|
||||
generator.generate(allocator, api, xml_src, maybe_video_xml_src, &aw.writer) catch |err| {
|
||||
if (debug) {
|
||||
return err;
|
||||
|
||||
Reference in New Issue
Block a user