adding bounded arena allocator to renderer
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
//! Atomic based spin mutex
|
||||
const std = @import("std");
|
||||
|
||||
mutex: std.atomic.Mutex = .unlocked,
|
||||
|
||||
pub fn lock(self: *@This()) void {
|
||||
if (self.mutex.tryLock()) {
|
||||
@branchHint(.likely);
|
||||
return;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
if (self.mutex.tryLock()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unlock(self: *@This()) void {
|
||||
self.mutex.unlock();
|
||||
}
|
||||
@@ -55,7 +55,6 @@ pub const VkError = error{
|
||||
InvalidHandleDrv,
|
||||
InvalidPipelineDrv,
|
||||
InvalidDeviceMemoryDrv,
|
||||
MemoryFootprintTooBigDrv,
|
||||
};
|
||||
|
||||
pub inline fn errorLogger(err: VkError) void {
|
||||
|
||||
@@ -4,29 +4,9 @@ const builtin = @import("builtin");
|
||||
const Allocator = std.mem.Allocator;
|
||||
const Alignment = std.mem.Alignment;
|
||||
|
||||
/// Atomic based spin mutex
|
||||
const AtomicMutex = struct {
|
||||
mutex: std.atomic.Mutex = .unlocked,
|
||||
const SpinMutex = @import("SpinMutex.zig");
|
||||
|
||||
fn lock(self: *@This()) void {
|
||||
if (self.mutex.tryLock()) {
|
||||
@branchHint(.likely);
|
||||
return;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
if (self.mutex.tryLock()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn unlock(self: *@This()) void {
|
||||
self.mutex.unlock();
|
||||
}
|
||||
};
|
||||
|
||||
var mutex: AtomicMutex = .{};
|
||||
var mutex: SpinMutex = .{};
|
||||
var child_allocator: std.mem.Allocator = if (builtin.link_libc) std.heap.c_allocator else std.heap.smp_allocator;
|
||||
|
||||
pub const fallback_host_allocator: Allocator = .{
|
||||
|
||||
@@ -19,6 +19,7 @@ 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 SpinMutex = @import("SpinMutex.zig");
|
||||
|
||||
pub const CommandBuffer = @import("CommandBuffer.zig");
|
||||
pub const Device = @import("Device.zig");
|
||||
|
||||
Reference in New Issue
Block a user