adding Vulkan conformance tests as a step
This commit is contained in:
@@ -11,7 +11,7 @@ pub const Interface = base.Fence;
|
||||
interface: Interface,
|
||||
mutex: std.Thread.Mutex,
|
||||
condition: std.Thread.Condition,
|
||||
is_signaled: bool,
|
||||
is_signaled: std.atomic.Value(bool),
|
||||
/// Used by impl queues to know when the fence should be signaled
|
||||
concurrent_submits_count: std.atomic.Value(usize),
|
||||
|
||||
@@ -33,7 +33,7 @@ pub fn create(device: *Device, allocator: std.mem.Allocator, info: *const vk.Fen
|
||||
.interface = interface,
|
||||
.mutex = std.Thread.Mutex{},
|
||||
.condition = std.Thread.Condition{},
|
||||
.is_signaled = info.flags.signaled_bit,
|
||||
.is_signaled = std.atomic.Value(bool).init(info.flags.signaled_bit),
|
||||
.concurrent_submits_count = std.atomic.Value(usize).init(0),
|
||||
};
|
||||
return self;
|
||||
@@ -46,33 +46,25 @@ pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
|
||||
|
||||
pub fn getStatus(interface: *Interface) VkError!void {
|
||||
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
|
||||
self.mutex.lock();
|
||||
defer self.mutex.unlock();
|
||||
if (!self.is_signaled) {
|
||||
if (!self.is_signaled.load(.monotonic)) {
|
||||
return VkError.NotReady;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reset(interface: *Interface) VkError!void {
|
||||
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
|
||||
self.mutex.lock();
|
||||
defer self.mutex.unlock();
|
||||
self.is_signaled = false;
|
||||
self.is_signaled.store(false, .monotonic);
|
||||
}
|
||||
|
||||
pub fn signal(interface: *Interface) VkError!void {
|
||||
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
|
||||
{
|
||||
self.mutex.lock();
|
||||
defer self.mutex.unlock();
|
||||
self.is_signaled = true;
|
||||
}
|
||||
self.is_signaled.store(true, .monotonic);
|
||||
self.condition.broadcast();
|
||||
}
|
||||
|
||||
pub fn wait(interface: *Interface, timeout: u64) VkError!void {
|
||||
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
|
||||
if (self.is_signaled) return;
|
||||
if (self.is_signaled.load(.monotonic)) return;
|
||||
if (timeout == 0) return VkError.Timeout;
|
||||
|
||||
self.mutex.lock();
|
||||
|
||||
@@ -78,6 +78,13 @@ pub inline fn bindSparse(self: *Self, info: []const vk.BindSparseInfo, fence: ?*
|
||||
}
|
||||
|
||||
pub inline fn submit(self: *Self, infos: []const vk.SubmitInfo, p_fence: ?*Fence) VkError!void {
|
||||
if (infos.len == 0) {
|
||||
if (p_fence) |fence| {
|
||||
try fence.signal();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const allocator = self.host_allocator.cloneWithScope(.command).allocator();
|
||||
|
||||
var submit_infos = try SubmitInfo.initBlob(allocator, infos);
|
||||
|
||||
@@ -90,7 +90,6 @@ fn free(context: *anyopaque, ptr: []u8, alignment: Alignment, ret_addr: usize) v
|
||||
pfn_free(self.callbacks.?.p_user_data, ptr.ptr);
|
||||
}
|
||||
}
|
||||
|
||||
getFallbackAllocator().rawFree(ptr, alignment, ret_addr);
|
||||
}
|
||||
|
||||
@@ -99,6 +98,6 @@ inline fn getFallbackAllocator() std.mem.Allocator {
|
||||
@branchHint(.unlikely);
|
||||
return debug_allocator.allocator();
|
||||
} else {
|
||||
return std.heap.c_allocator;
|
||||
return std.heap.page_allocator;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,6 +205,7 @@ const device_pfn_map = block: {
|
||||
functionMapEntryPoint("vkFreeMemory"),
|
||||
functionMapEntryPoint("vkGetBufferMemoryRequirements"),
|
||||
functionMapEntryPoint("vkGetDeviceMemoryCommitment"),
|
||||
functionMapEntryPoint("vkGetDeviceProcAddr"),
|
||||
functionMapEntryPoint("vkGetDeviceQueue"),
|
||||
functionMapEntryPoint("vkGetEventStatus"),
|
||||
functionMapEntryPoint("vkGetFenceStatus"),
|
||||
@@ -497,8 +498,6 @@ pub export fn strollQueueSubmit(p_queue: vk.Queue, count: u32, info: [*]const vk
|
||||
entryPointBeginLogTrace(.vkQueueSubmit);
|
||||
defer entryPointEndLogTrace();
|
||||
|
||||
if (count == 0) return .success;
|
||||
|
||||
const queue = Dispatchable(Queue).fromHandleObject(p_queue) catch |err| return toVkResult(err);
|
||||
const fence = if (p_fence != .null_handle) NonDispatchable(Fence).fromHandleObject(p_fence) catch |err| return toVkResult(err) else null;
|
||||
queue.submit(info[0..count], fence) catch |err| return toVkResult(err);
|
||||
|
||||
@@ -56,6 +56,7 @@ pub inline fn disableIndent() void {
|
||||
|
||||
pub inline fn freeInnerDebugStack() void {
|
||||
debug_stack.deinit(std.heap.c_allocator);
|
||||
debug_stack = .empty;
|
||||
}
|
||||
|
||||
pub inline fn fixme(comptime format: []const u8, args: anytype) void {
|
||||
|
||||
Reference in New Issue
Block a user