[Soft] fixing 32bits support because I have free will
Mirror Gitea refs to GitHub / mirror (push) Successful in 11s
Test / build_and_test (push) Successful in 5m47s
Build / build (push) Successful in 7m13s

This commit is contained in:
2026-07-30 02:21:36 +02:00
parent 1042b4a422
commit b7629ef4d7
9 changed files with 92 additions and 27 deletions
+7 -7
View File
@@ -80,35 +80,35 @@ pub inline fn mapTo(self: *const Self, comptime T: type) VkError!T {
return self.mapToWithAddedOffset(T, 0);
}
pub inline fn mapAsSlice(self: *const Self, comptime T: type, size: usize) VkError![]T {
pub inline fn mapAsSlice(self: *const Self, comptime T: type, size: vk.DeviceSize) VkError![]T {
return self.mapAsSliceWithAddedOffset(T, 0, size);
}
pub inline fn mapAsWithAddedOffset(self: *const Self, comptime T: type, offset: usize) VkError!*T {
pub inline fn mapAsWithAddedOffset(self: *const Self, comptime T: type, offset: vk.DeviceSize) VkError!*T {
return self.mapAsWithOffset(T, self.interface.offset + offset);
}
pub inline fn mapToWithAddedOffset(self: *const Self, comptime T: type, offset: usize) VkError!T {
pub inline fn mapToWithAddedOffset(self: *const Self, comptime T: type, offset: vk.DeviceSize) VkError!T {
return self.mapToWithOffset(T, self.interface.offset + offset);
}
pub inline fn mapAsSliceWithAddedOffset(self: *const Self, comptime T: type, offset: usize, size: usize) VkError![]T {
pub inline fn mapAsSliceWithAddedOffset(self: *const Self, comptime T: type, offset: vk.DeviceSize, size: vk.DeviceSize) VkError![]T {
return self.mapAsSliceWithOffset(T, self.interface.offset + offset, size);
}
pub fn mapAsWithOffset(self: *const Self, comptime T: type, offset: usize) VkError!*T {
pub fn mapAsWithOffset(self: *const Self, comptime T: type, offset: vk.DeviceSize) VkError!*T {
const memory = if (self.interface.memory) |memory| memory else return VkError.InvalidDeviceMemoryDrv;
const map = try memory.map(offset, @sizeOf(T));
return @alignCast(std.mem.bytesAsValue(T, map));
}
pub fn mapToWithOffset(self: *const Self, comptime T: type, offset: usize) VkError!T {
pub fn mapToWithOffset(self: *const Self, comptime T: type, offset: vk.DeviceSize) VkError!T {
const memory = if (self.interface.memory) |memory| memory else return VkError.InvalidDeviceMemoryDrv;
const map = try memory.map(offset, @sizeOf(T));
return std.mem.bytesToValue(T, map);
}
pub fn mapAsSliceWithOffset(self: *const Self, comptime T: type, offset: usize, size: usize) VkError![]T {
pub fn mapAsSliceWithOffset(self: *const Self, comptime T: type, offset: vk.DeviceSize, size: vk.DeviceSize) VkError![]T {
const memory = if (self.interface.memory) |memory| memory else return VkError.InvalidDeviceMemoryDrv;
const map = try memory.map(offset, size);
return @alignCast(std.mem.bytesAsSlice(T, map));
+1
View File
@@ -128,6 +128,7 @@ pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const v
self.* = .{
.interface = interface,
// SAFETY: the command allocator is initialized after the object is constructed
.command_allocator = undefined,
.commands = .empty,
};
+12 -3
View File
@@ -25,9 +25,10 @@ pub fn create(device: *SoftDevice, allocator: std.mem.Allocator, size: vk.Device
.invalidateRange = invalidateRange,
};
const allocation_size = std.math.cast(usize, size) orelse return VkError.OutOfDeviceMemory;
self.* = .{
.interface = interface,
.data = device.interface.device_allocator.allocator().alloc(u8, size) catch return VkError.OutOfDeviceMemory,
.data = device.interface.device_allocator.allocator().alloc(u8, allocation_size) catch return VkError.OutOfDeviceMemory,
};
return self;
}
@@ -54,10 +55,18 @@ pub fn invalidateRange(interface: *Interface, offset: vk.DeviceSize, size: vk.De
pub fn map(interface: *Interface, offset: vk.DeviceSize, size: vk.DeviceSize) VkError![]u8 {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
if (offset >= self.data.len or (size != vk.WHOLE_SIZE and offset + size > self.data.len)) {
const map_offset = std.math.cast(usize, offset) orelse return VkError.MemoryMapFailed;
if (map_offset >= self.data.len) {
return VkError.MemoryMapFailed;
}
return if (size == vk.WHOLE_SIZE) self.data[offset..] else self.data[offset..(offset + size)];
const map_size = if (size == vk.WHOLE_SIZE)
self.data.len - map_offset
else
std.math.cast(usize, size) orelse return VkError.MemoryMapFailed;
if (map_size > self.data.len - map_offset) {
return VkError.MemoryMapFailed;
}
return self.data[map_offset..][0..map_size];
}
pub fn unmap(_: *Interface) void {
+7 -7
View File
@@ -569,35 +569,35 @@ pub inline fn mapTo(self: *const Self, comptime T: type) VkError!T {
return self.mapToWithAddedOffset(T, 0);
}
pub inline fn mapAsSlice(self: *const Self, comptime T: type, size: usize) VkError![]T {
pub inline fn mapAsSlice(self: *const Self, comptime T: type, size: vk.DeviceSize) VkError![]T {
return self.mapAsSliceWithAddedOffset(T, 0, size);
}
pub inline fn mapAsWithAddedOffset(self: *const Self, comptime T: type, offset: usize) VkError!*T {
pub inline fn mapAsWithAddedOffset(self: *const Self, comptime T: type, offset: vk.DeviceSize) VkError!*T {
return self.mapAsWithOffset(T, self.interface.memory_offset + offset);
}
pub inline fn mapToWithAddedOffset(self: *const Self, comptime T: type, offset: usize) VkError!T {
pub inline fn mapToWithAddedOffset(self: *const Self, comptime T: type, offset: vk.DeviceSize) VkError!T {
return self.mapToWithOffset(T, self.interface.memory_offset + offset);
}
pub inline fn mapAsSliceWithAddedOffset(self: *const Self, comptime T: type, offset: usize, size: usize) VkError![]T {
pub inline fn mapAsSliceWithAddedOffset(self: *const Self, comptime T: type, offset: vk.DeviceSize, size: vk.DeviceSize) VkError![]T {
return self.mapAsSliceWithOffset(T, self.interface.memory_offset + offset, size);
}
pub fn mapAsWithOffset(self: *const Self, comptime T: type, offset: usize) VkError!*T {
pub fn mapAsWithOffset(self: *const Self, comptime T: type, offset: vk.DeviceSize) VkError!*T {
const memory = if (self.interface.memory) |memory| memory else return VkError.InvalidDeviceMemoryDrv;
const map = try memory.map(offset, @sizeOf(T));
return @alignCast(std.mem.bytesAsValue(T, map));
}
pub fn mapToWithOffset(self: *const Self, comptime T: type, offset: usize) VkError!T {
pub fn mapToWithOffset(self: *const Self, comptime T: type, offset: vk.DeviceSize) VkError!T {
const memory = if (self.interface.memory) |memory| memory else return VkError.InvalidDeviceMemoryDrv;
const map = try memory.map(offset, @sizeOf(T));
return std.mem.bytesToValue(T, map);
}
pub fn mapAsSliceWithOffset(self: *const Self, comptime T: type, offset: usize, size: usize) VkError![]T {
pub fn mapAsSliceWithOffset(self: *const Self, comptime T: type, offset: vk.DeviceSize, size: vk.DeviceSize) VkError![]T {
const memory = if (self.interface.memory) |memory| memory else return VkError.InvalidDeviceMemoryDrv;
const map = try memory.map(offset, size);
return @alignCast(std.mem.bytesAsSlice(T, map));
+3 -2
View File
@@ -23,6 +23,7 @@ const F32x4 = zm.F32x4;
const Self = @This();
const @"1GiB" = 1_073_741_824;
const draw_allocator_limit: usize = @intCast(@min(@as(u64, 4) * @"1GiB", @as(u64, std.math.maxInt(usize))));
pub const VertexBuffer = struct {
buffer: *const SoftBuffer,
@@ -196,12 +197,12 @@ pub fn resetInputAttachmentSnapshots(self: *Self) void {
}
pub fn draw(self: *Self, vertex_count: usize, instance_count: usize, first_vertex: usize, first_instance: usize) VkError!void {
var bounded_allocator: BoundedAllocator = .init(self.device.interface.device_allocator.allocator(), 4 * @"1GiB");
var bounded_allocator: BoundedAllocator = .init(self.device.interface.device_allocator.allocator(), draw_allocator_limit);
try self.drawCall(&bounded_allocator, vertex_count, instance_count, first_vertex, first_instance, null, null);
}
pub fn drawIndexed(self: *Self, index_count: usize, instance_count: usize, first_index: usize, first_instance: usize, vertex_offset: i32) VkError!void {
var bounded_allocator: BoundedAllocator = .init(self.device.interface.device_allocator.allocator(), 4 * @"1GiB");
var bounded_allocator: BoundedAllocator = .init(self.device.interface.device_allocator.allocator(), draw_allocator_limit);
const allocator = bounded_allocator.allocator();
const indexed_draw = try self.readIndexBuffer(allocator, index_count, first_index, vertex_offset);
+6 -1
View File
@@ -794,7 +794,12 @@ pub fn readFloat4(map: []const u8, src_format: vk.Format) F32x4 {
c[3] = normalizedI16(std.mem.bytesToValue(u16, map[6..]));
},
.r16g16b16a16_sfloat => c = std.mem.bytesToValue(@Vector(4, f16), map),
.r16g16b16a16_sfloat => {
c[0] = std.mem.bytesToValue(f16, map[0..]);
c[1] = std.mem.bytesToValue(f16, map[2..]);
c[2] = std.mem.bytesToValue(f16, map[4..]);
c[3] = std.mem.bytesToValue(f16, map[6..]);
},
.r32g32b32a32_sfloat => c = std.mem.bytesToValue(F32x4, map),