yes
Build / build (push) Successful in 33s
Test / build_and_test (push) Successful in 24s

This commit is contained in:
2026-06-04 02:45:06 +02:00
parent 7da8eec788
commit decdc79ae7
21 changed files with 540 additions and 108 deletions
+7 -5
View File
@@ -108,12 +108,14 @@ pub inline fn destroy(self: *Self, allocator: std.mem.Allocator) void {
}
pub fn begin(self: *Self, info: *const vk.CommandBufferBeginInfo) VkError!void {
if (!self.pool.flags.reset_command_buffer_bit) {
self.transitionState(.Recording, &.{.Initial}) catch return VkError.ValidationFailed;
} else {
try self.reset(.{});
self.transitionState(.Recording, &.{ .Initial, .Recording, .Executable, .Invalid }) catch return VkError.ValidationFailed;
const implicitly_reset = self.state == .Executable;
self.transitionState(.Recording, &.{ .Initial, .Executable }) catch return VkError.ValidationFailed;
if (implicitly_reset) {
try self.dispatch_table.reset(self, .{});
self.begin_info = null;
}
try self.dispatch_table.begin(self, info);
self.begin_info = info.*;
}
+42 -5
View File
@@ -3,6 +3,7 @@ const vk = @import("vulkan");
const VulkanAllocator = @import("VulkanAllocator.zig");
const NonDispatchable = @import("NonDispatchable.zig").NonDispatchable;
const VkError = @import("error_set.zig").VkError;
const Device = @import("Device.zig");
const Sampler = @import("Sampler.zig");
@@ -16,7 +17,7 @@ const BindingLayout = struct {
array_size: usize,
/// This slice points to an array located after the binding layouts array
immutable_samplers: []*const Sampler,
immutable_samplers: []const *const Sampler,
driver_data: *anyopaque,
};
@@ -68,8 +69,21 @@ pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.Descr
const bindings = local_allocator.alloc(BindingLayout, binding_count) catch return VkError.OutOfHostMemory;
const immutable_samplers = local_allocator.alloc(*const Sampler, immutable_samplers_count) catch return VkError.OutOfHostMemory;
var immutable_samplers_offset: usize = 0;
for (bindings) |*binding| {
binding.* = .{
.descriptor_type = .sampler,
.array_size = 0,
.dynamic_index = 0,
.immutable_samplers = &.{},
.driver_data = undefined,
};
}
var stages: vk.ShaderStageFlags = .{};
var dynamic_descriptor_count: usize = 0;
var dynamic_offset_count: usize = 0;
if (info.p_bindings) |binding_infos| {
const sorted_bindings = command_allocator.dupe(vk.DescriptorSetLayoutBinding, binding_infos[0..info.binding_count]) catch return VkError.OutOfHostMemory;
@@ -84,11 +98,27 @@ pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.Descr
else => binding_info.descriptor_count,
};
const binding_immutable_samplers = if (bindingHasImmutableSamplers(binding_info)) blk: {
const base = binding_info.p_immutable_samplers orelse return VkError.ValidationFailed;
const binding_immutable_samplers = immutable_samplers[immutable_samplers_offset .. immutable_samplers_offset + descriptor_count];
immutable_samplers_offset += descriptor_count;
for (binding_immutable_samplers, base[0..descriptor_count]) |*dst, src| {
dst.* = try NonDispatchable(Sampler).fromHandleObject(src);
}
break :blk binding_immutable_samplers;
} else &.{};
const dynamic_index = dynamic_descriptor_count;
if (bindingHasDynamicOffset(binding_info)) {
dynamic_descriptor_count += descriptor_count;
dynamic_offset_count += descriptor_count;
}
bindings[binding_index] = .{
.descriptor_type = binding_info.descriptor_type,
.array_size = descriptor_count,
.dynamic_index = 0,
.immutable_samplers = immutable_samplers[0..],
.dynamic_index = dynamic_index,
.immutable_samplers = binding_immutable_samplers,
.driver_data = undefined,
};
@@ -100,8 +130,8 @@ pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.Descr
.owner = device,
.heap = heap,
.bindings = bindings,
.dynamic_offset_count = 0,
.dynamic_descriptor_count = 0,
.dynamic_offset_count = dynamic_offset_count,
.dynamic_descriptor_count = dynamic_descriptor_count,
.stages = stages,
.ref_count = std.atomic.Value(usize).init(1),
.vtable = undefined,
@@ -119,6 +149,13 @@ inline fn bindingHasImmutableSamplers(binding: vk.DescriptorSetLayoutBinding) bo
};
}
inline fn bindingHasDynamicOffset(binding: vk.DescriptorSetLayoutBinding) bool {
return switch (binding.descriptor_type) {
.uniform_buffer_dynamic, .storage_buffer_dynamic => true,
else => false,
};
}
pub inline fn destroy(self: *Self, allocator: std.mem.Allocator) void {
self.unref(allocator);
}
+1 -1
View File
@@ -34,7 +34,7 @@ pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.Frame
for (base_attachements, attachments, 0..info.attachment_count) |base_attachment, *attachment, _| {
attachment.* = try NonDispatchable(ImageView).fromHandleObject(base_attachment);
}
} else {
} else if (info.attachment_count != 0) {
return VkError.ValidationFailed;
}
+6 -1
View File
@@ -28,6 +28,7 @@ vtable: *const VTable,
pub const VTable = struct {
destroy: *const fn (*Self, std.mem.Allocator) void,
getRenderAreaGranularity: *const fn (*Self) vk.Extent2D,
};
pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.RenderPassCreateInfo) VkError!Self {
@@ -40,7 +41,7 @@ pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.Rende
for (base_attachements, attachments, 0..info.attachment_count) |base_attachment, *attachment, _| {
attachment.* = base_attachment;
}
} else {
} else if (info.attachment_count != 0) {
return VkError.ValidationFailed;
}
@@ -93,3 +94,7 @@ pub fn destroy(self: *Self, allocator: std.mem.Allocator) void {
allocator.free(self.subpasses);
self.vtable.destroy(self, allocator);
}
pub inline fn getRenderAreaGranularity(self: *Self) vk.Extent2D {
return self.vtable.getRenderAreaGranularity(self);
}
+2
View File
@@ -16,6 +16,7 @@ min_filter: vk.Filter,
address_mode_u: vk.SamplerAddressMode,
address_mode_v: vk.SamplerAddressMode,
address_mode_w: vk.SamplerAddressMode,
border_color: vk.BorderColor,
vtable: *const VTable,
@@ -32,6 +33,7 @@ pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.Sampl
.address_mode_u = info.address_mode_u,
.address_mode_v = info.address_mode_v,
.address_mode_w = info.address_mode_w,
.border_color = info.border_color,
.vtable = undefined,
};
}
+4
View File
@@ -40,6 +40,10 @@ pub inline fn texelSize(format: vk.Format) usize {
return lib.c.vkuFormatTexelBlockSize(@intCast(@intFromEnum(format)));
}
pub inline fn componentCount(format: vk.Format) usize {
return @intCast(lib.c.vkuFormatComponentCount(@intCast(@intFromEnum(format))));
}
pub fn supportsColorAttachemendBlend(format: vk.Format) bool {
return switch (format) {
// Vulkan 1.1 mandatory
+2 -4
View File
@@ -1470,11 +1470,9 @@ pub export fn apeGetRenderAreaGranularity(p_device: vk.Device, p_pass: vk.Render
defer entryPointEndLogTrace();
Dispatchable(Device).checkHandleValidity(p_device) catch |err| return errorLogger(err);
const pass = NonDispatchable(RenderPass).fromHandleObject(p_pass) catch |err| return errorLogger(err);
notImplementedWarning();
_ = p_pass;
_ = granularity;
granularity.* = pass.getRenderAreaGranularity();
}
pub export fn apeInvalidateMappedMemoryRanges(p_device: vk.Device, count: u32, p_ranges: [*]const vk.MappedMemoryRange) callconv(vk.vulkan_call_conv) vk.Result {