fixing lots of minor issues
This commit is contained in:
@@ -21,17 +21,19 @@ pub fn Dispatchable(comptime T: type) type {
|
||||
.object_type = T.ObjectType,
|
||||
.object = object,
|
||||
};
|
||||
std.log.debug("Created dispatchable handle at 0x{X}", .{@intFromPtr(self)});
|
||||
std.log.debug("Created dispatchable handle of type '{s}' at 0x{X}", .{ @typeName(T), @intFromPtr(self) });
|
||||
return self;
|
||||
}
|
||||
|
||||
pub inline fn intrusiveDestroy(self: *Self, allocator: std.mem.Allocator) void {
|
||||
self.object.destroy(allocator);
|
||||
allocator.destroy(self);
|
||||
std.log.debug("Destroyed dispatchable handle of type '{s}' at 0x{X}", .{ @typeName(T), @intFromPtr(self) });
|
||||
}
|
||||
|
||||
pub inline fn destroy(self: *Self, allocator: std.mem.Allocator) void {
|
||||
allocator.destroy(self);
|
||||
std.log.debug("Destroyed dispatchable handle of type '{s}' at 0x{X}", .{ @typeName(T), @intFromPtr(self) });
|
||||
}
|
||||
|
||||
pub inline fn toHandle(self: *Self) usize {
|
||||
|
||||
@@ -16,17 +16,19 @@ pub fn NonDispatchable(comptime T: type) type {
|
||||
.object_type = T.ObjectType,
|
||||
.object = object,
|
||||
};
|
||||
std.log.debug("Created non dispatchable handle at 0x{X}", .{@intFromPtr(self)});
|
||||
std.log.debug("Created non dispatchable handle of type '{s}' at 0x{X}", .{ @typeName(T), @intFromPtr(self) });
|
||||
return self;
|
||||
}
|
||||
|
||||
pub inline fn intrusiveDestroy(self: *Self, allocator: std.mem.Allocator) void {
|
||||
self.object.destroy(allocator);
|
||||
allocator.destroy(self);
|
||||
std.log.debug("Destroyed non dispatchable handle of type '{s}' at 0x{X}", .{ @typeName(T), @intFromPtr(self) });
|
||||
}
|
||||
|
||||
pub inline fn destroy(self: *Self, allocator: std.mem.Allocator) void {
|
||||
allocator.destroy(self);
|
||||
std.log.debug("Destroyed non dispatchable handle of type '{s}' at 0x{X}", .{ @typeName(T), @intFromPtr(self) });
|
||||
}
|
||||
|
||||
pub inline fn toHandle(self: *Self) usize {
|
||||
|
||||
23
src/vulkan/RefCounter.zig
git.filemode.normal_file
23
src/vulkan/RefCounter.zig
git.filemode.normal_file
@@ -0,0 +1,23 @@
|
||||
const std = @import("std");
|
||||
|
||||
const Self = @This();
|
||||
|
||||
count: std.atomic.Value(usize),
|
||||
|
||||
pub const init: Self = .{ .count = std.atomic.Value(usize).init(0) };
|
||||
|
||||
pub inline fn ref(self: *Self) void {
|
||||
_ = self.count.fetchAdd(1, .monotonic);
|
||||
}
|
||||
|
||||
pub inline fn unref(self: *Self) void {
|
||||
_ = self.count.fetchSub(1, .monotonic);
|
||||
}
|
||||
|
||||
pub inline fn hasRefs(self: *Self) bool {
|
||||
return self.getRefsCount() == 0;
|
||||
}
|
||||
|
||||
pub inline fn getRefsCount(self: *Self) usize {
|
||||
return self.count.load(.acquire);
|
||||
}
|
||||
@@ -9,8 +9,6 @@ const Alignment = std.mem.Alignment;
|
||||
|
||||
const Self = @This();
|
||||
|
||||
var fallback_allocator: std.heap.ThreadSafeAllocator = .{ .child_allocator = std.heap.c_allocator };
|
||||
|
||||
callbacks: ?vk.AllocationCallbacks,
|
||||
scope: vk.SystemAllocationScope,
|
||||
|
||||
@@ -39,7 +37,7 @@ pub fn from(a: Allocator) *Self {
|
||||
return self;
|
||||
}
|
||||
|
||||
pub fn clone(self: *Self) Self {
|
||||
pub inline fn clone(self: *Self) Self {
|
||||
return self.cloneWithScope(self.scope);
|
||||
}
|
||||
|
||||
@@ -91,5 +89,6 @@ fn free(context: *anyopaque, ptr: []u8, alignment: Alignment, ret_addr: usize) v
|
||||
}
|
||||
|
||||
inline fn getFallbackAllocator() std.mem.Allocator {
|
||||
var fallback_allocator: std.heap.ThreadSafeAllocator = .{ .child_allocator = std.heap.c_allocator };
|
||||
return fallback_allocator.allocator();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ pub const Dispatchable = @import("Dispatchable.zig").Dispatchable;
|
||||
pub const NonDispatchable = @import("NonDispatchable.zig").NonDispatchable;
|
||||
pub const VkError = errors.VkError;
|
||||
pub const VulkanAllocator = @import("VulkanAllocator.zig");
|
||||
pub const RefCounter = @import("RefCounter.zig");
|
||||
|
||||
pub const CommandBuffer = @import("CommandBuffer.zig");
|
||||
pub const Device = @import("Device.zig");
|
||||
|
||||
Reference in New Issue
Block a user