fixing linter errors
Test / build_and_test (push) Successful in 5m28s
Build / build (push) Successful in 7m26s

This commit is contained in:
2026-07-15 15:39:16 +02:00
parent 1640013546
commit 2375abf688
116 changed files with 563 additions and 354 deletions
-1
View File
@@ -3,7 +3,6 @@ const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.BinarySemaphore;
-1
View File
@@ -5,7 +5,6 @@ const base = @import("base");
const lib = @import("lib.zig");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.Buffer;
-1
View File
@@ -3,7 +3,6 @@ const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.BufferView;
+7 -5
View File
@@ -3,7 +3,6 @@ const vk = @import("vulkan");
const base = @import("base");
const lib = @import("lib.zig");
const Device = base.Device;
const VkError = base.VkError;
const SoftBuffer = @import("SoftBuffer.zig");
@@ -129,10 +128,9 @@ pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const v
self.* = .{
.interface = interface,
.command_allocator = undefined,
.command_allocator = .init(interface.host_allocator.allocator()),
.commands = .empty,
};
self.command_allocator = .init(self.interface.host_allocator.allocator());
return self;
}
@@ -144,7 +142,7 @@ pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
pub fn execute(self: *Self, device: *ExecutionDevice) VkError!void {
try self.interface.submit();
defer self.interface.finish() catch {};
defer self.interface.finish() catch @panic("Caught an error while handling an error");
for (self.commands.items) |command| {
command.vtable.execute(@ptrCast(command.ptr), device) catch |err| {
@@ -1063,7 +1061,11 @@ pub fn endRenderPass(interface: *Interface) VkError!void {
}
};
self.commands.append(allocator, .{ .ptr = undefined, .vtable = &.{ .execute = CommandImpl.execute } }) catch return VkError.OutOfHostMemory;
self.commands.append(allocator, .{
// SAFETY: this command's execute callback does not inspect its context pointer.
.ptr = undefined,
.vtable = &.{ .execute = CommandImpl.execute },
}) catch return VkError.OutOfHostMemory;
}
pub fn executeCommands(interface: *Interface, commands: *Interface) VkError!void {
-2
View File
@@ -2,9 +2,7 @@ const std = @import("std");
const vk = @import("vulkan");
const base = @import("base");
const NonDispatchable = base.NonDispatchable;
const VkError = base.VkError;
const Device = base.Device;
const SoftCommandBuffer = @import("SoftCommandBuffer.zig");
-1
View File
@@ -5,7 +5,6 @@ const base = @import("base");
const VkError = base.VkError;
const VulkanAllocator = base.VulkanAllocator;
const Device = base.Device;
const SoftDescriptorSet = @import("SoftDescriptorSet.zig");
-1
View File
@@ -3,7 +3,6 @@ const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Buffer = base.Buffer;
const BufferView = base.BufferView;
const ImageView = base.ImageView;
-1
View File
@@ -3,7 +3,6 @@ const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.DescriptorSetLayout;
+1 -5
View File
@@ -1,8 +1,6 @@
const std = @import("std");
const vk = @import("vulkan");
const base = @import("base");
const builtin = @import("builtin");
const config = base.config;
const SoftQueue = @import("SoftQueue.zig");
@@ -33,8 +31,6 @@ const VkError = base.VkError;
const Self = @This();
pub const Interface = base.Device;
const SpawnError = std.Thread.SpawnError;
interface: Interface,
pub fn create(instance: *base.Instance, physical_device: *base.PhysicalDevice, allocator: std.mem.Allocator, info: *const vk.DeviceCreateInfo) VkError!*Self {
@@ -42,7 +38,7 @@ pub fn create(instance: *base.Instance, physical_device: *base.PhysicalDevice, a
var initialized = false;
errdefer {
if (initialized) {
self.interface.destroy(allocator) catch {};
self.interface.destroy(allocator) catch @panic("Caught an error while handling an error");
} else {
allocator.destroy(self);
}
-1
View File
@@ -2,7 +2,6 @@ const std = @import("std");
const vk = @import("vulkan");
const SoftDevice = @import("SoftDevice.zig");
const base = @import("base");
const lib = @import("lib.zig");
const VkError = base.VkError;
-1
View File
@@ -3,7 +3,6 @@ const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.Event;
-1
View File
@@ -3,7 +3,6 @@ const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const blitter = @import("device/blitter.zig");
-2
View File
@@ -61,10 +61,8 @@ const F32x4 = blitter.F32x4;
const U32x4 = blitter.U32x4;
const VkError = base.VkError;
const Device = base.Device;
const SoftBuffer = @import("SoftBuffer.zig");
const SoftDevice = @import("SoftDevice.zig");
const Self = @This();
pub const Interface = base.Image;
-1
View File
@@ -3,7 +3,6 @@ const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.ImageView;
+1 -2
View File
@@ -1,7 +1,6 @@
const std = @import("std");
const vk = @import("vulkan");
const base = @import("base");
const lib = @import("lib.zig");
const SoftPhysicalDevice = @import("SoftPhysicalDevice.zig");
const Dispatchable = base.Dispatchable;
@@ -63,7 +62,7 @@ fn destroy(interface: *Interface, allocator: std.mem.Allocator) VkError!void {
fn requestPhysicalDevices(interface: *Interface, allocator: std.mem.Allocator, _: []base.drm.Card) VkError!void {
// Software driver has only one physical device (the CPU)
const physical_device = try SoftPhysicalDevice.create(allocator, interface);
errdefer physical_device.interface.release(allocator) catch {};
errdefer physical_device.interface.release(allocator) catch @panic("Caught an error while handling an error");
const dispatchable = try Dispatchable(base.PhysicalDevice).wrap(allocator, &physical_device.interface);
errdefer dispatchable.destroy(allocator);
interface.physical_devices.append(allocator, dispatchable) catch return VkError.OutOfHostMemory;
+4 -4
View File
@@ -925,10 +925,10 @@ fn cpuid(leaf_id: u32, subleaf_id: u32) CpuidRegs {
}
}
var eax: u32 = undefined;
var ebx: u32 = undefined;
var ecx: u32 = undefined;
var edx: u32 = undefined;
var eax: u32 = 0;
var ebx: u32 = 0;
var ecx: u32 = 0;
var edx: u32 = 0;
asm volatile ("cpuid"
: [_] "={eax}" (eax),
-2
View File
@@ -7,7 +7,6 @@ const zm = base.zm;
const blitter = @import("device/blitter.zig");
const Device = base.Device;
const VkError = base.VkError;
const SpvRuntimeError = spv.Runtime.RuntimeError;
@@ -31,7 +30,6 @@ pub threadlocal var current_framebuffer_attachment_count: usize = 0;
const NonDispatchable = base.NonDispatchable;
const ShaderModule = base.ShaderModule;
const SoftDevice = @import("SoftDevice.zig");
const SoftBuffer = @import("SoftBuffer.zig");
const SoftBufferView = @import("SoftBufferView.zig");
const SoftImage = @import("SoftImage.zig");
-1
View File
@@ -4,7 +4,6 @@ const base = @import("base");
const spv = @import("spv");
const VkError = base.VkError;
const SoftDevice = @import("SoftDevice.zig");
const SoftShaderModule = @import("SoftShaderModule.zig");
const Self = @This();
-1
View File
@@ -3,7 +3,6 @@ const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.PipelineLayout;
-1
View File
@@ -3,7 +3,6 @@ const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.QueryPool;
+1 -2
View File
@@ -3,9 +3,7 @@ const vk = @import("vulkan");
const base = @import("base");
const ExecutionDevice = @import("device/Device.zig");
const Dispatchable = base.Dispatchable;
const CommandBuffer = base.CommandBuffer;
const SoftDevice = @import("SoftDevice.zig");
const SoftCommandBuffer = @import("SoftCommandBuffer.zig");
@@ -109,6 +107,7 @@ fn executeSubmitInfo(soft_device: *SoftDevice, info: Interface.SubmitInfo) VkErr
try semaphore.wait();
}
// SAFETY: setup initializes every field before execution_device is read.
var execution_device: ExecutionDevice = undefined;
execution_device.setup(soft_device);
defer execution_device.deinit(soft_device.interface.device_allocator.allocator());
-1
View File
@@ -3,7 +3,6 @@ const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.RenderPass;
-1
View File
@@ -6,7 +6,6 @@ const zm = base.zm;
const blitter = @import("device/blitter.zig");
const VkError = base.VkError;
const Device = base.Device;
const F32x4 = zm.F32x4;
const U32x4 = blitter.U32x4;
-3
View File
@@ -2,12 +2,9 @@ const std = @import("std");
const vk = @import("vulkan");
const base = @import("base");
const spv = @import("spv");
const lib = @import("lib.zig");
const VkError = base.VkError;
const Device = base.Device;
const SoftDevice = @import("SoftDevice.zig");
const Self = @This();
pub const Interface = base.ShaderModule;
-1
View File
@@ -1,5 +1,4 @@
const std = @import("std");
const base = @import("base");
const Self = @This();
@@ -1,8 +1,6 @@
const std = @import("std");
const vk = @import("vulkan");
const base = @import("base");
const spv = @import("spv");
const lib = @import("../lib.zig");
const ExecutionDevice = @import("Device.zig");
const PipelineState = ExecutionDevice.PipelineState;
+2 -4
View File
@@ -6,15 +6,11 @@ const spv = @import("spv");
const SoftDescriptorSet = @import("../SoftDescriptorSet.zig");
const SoftDevice = @import("../SoftDevice.zig");
const SoftFramebuffer = @import("../SoftFramebuffer.zig");
const SoftPipeline = @import("../SoftPipeline.zig");
const SoftRenderPass = @import("../SoftRenderPass.zig");
const ComputeDispatcher = @import("ComputeDispatcher.zig");
const Renderer = @import("Renderer.zig");
const VkError = base.VkError;
const Self = @This();
pub const GRAPHICS_PIPELINE_STATE = 0;
@@ -58,7 +54,9 @@ pub fn setup(self: *Self, device: *SoftDevice) void {
.data = switch (i) {
GRAPHICS_PIPELINE_STATE => .{
.graphics = .{
// SAFETY: indexed draws bind the index buffer before the renderer reads it.
.index_buffer = undefined,
// SAFETY: each vertex binding is populated before an attribute reads it.
.vertex_buffers = undefined,
},
},
+2 -3
View File
@@ -9,16 +9,13 @@ const PipelineState = ExecutionDevice.PipelineState;
const BoundedAllocator = @import("BoundedAllocator.zig");
const SoftBuffer = @import("../SoftBuffer.zig");
const SoftDescriptorSet = @import("../SoftDescriptorSet.zig");
const SoftDevice = @import("../SoftDevice.zig");
const SoftFramebuffer = @import("../SoftFramebuffer.zig");
const SoftPipeline = @import("../SoftPipeline.zig");
const SoftRenderPass = @import("../SoftRenderPass.zig");
const blitter = @import("blitter.zig");
const rasterizer = @import("rasterizer.zig");
const vertex_dispatcher = @import("vertex_dispatcher.zig");
const clip = @import("clip.zig");
const VkError = base.VkError;
const F32x4 = zm.F32x4;
@@ -110,7 +107,9 @@ pub const DrawCall = struct {
.vertex_count = vertex_count,
.instance_count = instance_count,
.renderer = renderer,
// SAFETY: draw assigns the viewport before the rasterizer receives this value.
.viewport = undefined,
// SAFETY: draw assigns the scissor before the rasterizer receives this value.
.scissor = undefined,
.color_attachments = framebuffer.interface.attachments[0..],
.depth_attachment = if (render_pass.interface.subpasses[renderer.subpass_index].depth_stencil_attachments) |desc| framebuffer.interface.attachments[desc.attachment] else null,
+1 -1
View File
@@ -1640,7 +1640,7 @@ fn encodeUFloat(value: f32, mantissa_bits: comptime_int) u32 {
return max_exponent << mantissa_bits;
if (adjusted_exponent <= 0) {
const mantissa = @as(u32, @intFromFloat(@round(value * @as(f32, @floatFromInt(1 << (mantissa_bits + exponent_bias - 1))))));
const mantissa: u32 = @intFromFloat(@round(value * @as(f32, @floatFromInt(1 << (mantissa_bits + exponent_bias - 1)))));
return mantissa;
}
+26 -26
View File
@@ -13,12 +13,12 @@ const VkError = base.VkError;
const INTERFACE_BLOB_PADDING = @sizeOf(F32x4);
const ClipPlane = enum {
Left,
Right,
Bottom,
Top,
Near,
Far,
left,
right,
bottom,
top,
near,
far,
};
const MAX_CLIPPED_POLYGON_VERTICES = 16;
@@ -29,7 +29,7 @@ pub const ClippedLine = struct {
};
const ClippedPolygon = struct {
vertices: [MAX_CLIPPED_POLYGON_VERTICES]Vertex = undefined,
vertices: [MAX_CLIPPED_POLYGON_VERTICES]Vertex = std.mem.zeroes([MAX_CLIPPED_POLYGON_VERTICES]Vertex),
len: usize = 0,
fn append(self: *@This(), vertex: Vertex) VkError!void {
@@ -48,12 +48,12 @@ pub fn clipTriangle(allocator: std.mem.Allocator, v0: *const Vertex, v1: *const
try polygon.append(v2.*);
const planes = [_]ClipPlane{
.Left,
.Right,
.Bottom,
.Top,
.Near,
.Far,
.left,
.right,
.bottom,
.top,
.near,
.far,
};
for (planes) |plane| {
@@ -72,12 +72,12 @@ pub fn clipLine(allocator: std.mem.Allocator, v0: *const Vertex, v1: *const Vert
};
const planes = [_]ClipPlane{
.Left,
.Right,
.Bottom,
.Top,
.Near,
.Far,
.left,
.right,
.bottom,
.top,
.near,
.far,
};
for (planes) |plane| {
@@ -131,12 +131,12 @@ pub fn viewportTransformVertex(viewport: vk.Viewport, vertex: *Vertex) void {
fn clipDistance(position: F32x4, plane: ClipPlane) f32 {
const x, const y, const z, const w = position;
return switch (plane) {
.Left => x + w,
.Right => w - x,
.Bottom => y + w,
.Top => w - y,
.Near => z,
.Far => w - z,
.left => x + w,
.right => w - x,
.bottom => y + w,
.top => w - y,
.near => z,
.far => w - z,
};
}
@@ -173,7 +173,7 @@ fn interpolateVertexForClipping(allocator: std.mem.Allocator, a: *const Vertex,
.primitive_restart = false,
.position = a.position + ((b.position - a.position) * zm.f32x4s(t)),
.point_size = a.point_size + ((b.point_size - a.point_size) * t),
.outputs = undefined,
.outputs = @splat(@splat(null)),
};
for (&result.outputs) |*location| {
+4 -4
View File
@@ -8,10 +8,8 @@ const VertexInterpolationLocation = @import("rasterizer/common.zig").VertexInter
const ExecutionDevice = @import("Device.zig");
const Renderer = @import("Renderer.zig");
const SoftImage = @import("../SoftImage.zig");
const SoftPipeline = @import("../SoftPipeline.zig");
const VkError = base.VkError;
const SpvRuntimeError = spv.Runtime.RuntimeError;
const INTERFACE_BLOB_PADDING = @sizeOf(zm.F32x4);
const PROCESSED_INPUTS_STACK_CAPACITY = 4096;
@@ -49,8 +47,10 @@ pub fn shaderInvocation(
const io = draw_call.renderer.device.interface.io();
// SAFETY: fragment dispatch only occurs after a graphics pipeline has been bound.
const pipeline = draw_call.renderer.state.pipeline orelse return undefined;
// SAFETY: fragment dispatch only occurs when the bound pipeline has a fragment stage.
const shader = pipeline.stages.getPtr(.fragment) orelse return undefined;
const runtime = &shader.runtimes[batch_id];
const mutex = &runtime.mutex;
@@ -245,7 +245,7 @@ pub fn shaderInvocation(
}
var depth: ?f32 = null;
var frag_depth: f32 = undefined;
var frag_depth: f32 = 0;
if (rt.readBuiltIn(std.mem.asBytes(&frag_depth), .FragDepth)) {
depth = frag_depth;
} else |err| switch (err) {
@@ -254,7 +254,7 @@ pub fn shaderInvocation(
}
var sample_mask: ?vk.SampleMask = null;
var frag_sample_mask: [1]vk.SampleMask = undefined;
var frag_sample_mask: [1]vk.SampleMask = .{0};
if (rt.readBuiltIn(std.mem.asBytes(&frag_sample_mask), .SampleMask)) {
sample_mask = frag_sample_mask[0];
} else |err| switch (err) {
+1 -1
View File
@@ -133,7 +133,7 @@ pub fn processThenFragmentStage(renderer: *Renderer, allocator: std.mem.Allocato
);
const color_attachment_subresource_size = renderTargetSubresourceSize(render_target, render_target_view, color_range.aspect_mask, color_range.base_mip_level);
access.* = .{
.mutex = undefined,
.mutex = .init,
.base = try render_target.mapAsSliceWithAddedOffset(u8, color_attachment_subresource_offset, color_attachment_subresource_size),
.row_pitch = render_target.getRowPitchMemSizeForMipLevelWithFormat(color_range.aspect_mask, color_range.base_mip_level, color_format),
.texel_size = base.format.texelSize(color_format),
@@ -8,7 +8,6 @@ const common = @import("common.zig");
const fragment = @import("../fragment.zig");
const Renderer = @import("../Renderer.zig");
const SoftImage = @import("../../SoftImage.zig");
const VkError = base.VkError;
const SpvRuntimeError = spv.Runtime.RuntimeError;
+6 -6
View File
@@ -53,14 +53,14 @@ pub fn clampDepthBias(bias: f32, clamp: f32) f32 {
}
pub fn scissorContainsPixel(scissor: vk.Rect2D, x: i32, y: i32) bool {
const min_x: i64 = @as(i64, scissor.offset.x);
const min_y: i64 = @as(i64, scissor.offset.y);
const min_x: i64 = scissor.offset.x;
const min_y: i64 = scissor.offset.y;
const max_x: i64 = min_x + @as(i64, @intCast(scissor.extent.width));
const max_y: i64 = min_y + @as(i64, @intCast(scissor.extent.height));
const pixel_x: i64 = @as(i64, x);
const pixel_y: i64 = @as(i64, y);
const pixel_x: i64 = x;
const pixel_y: i64 = y;
return pixel_x >= min_x and
pixel_x < max_x and
@@ -69,8 +69,8 @@ pub fn scissorContainsPixel(scissor: vk.Rect2D, x: i32, y: i32) bool {
}
pub fn rectContainsPixel(rect: vk.Rect2D, x: usize, y: usize) bool {
const min_x: i64 = @as(i64, rect.offset.x);
const min_y: i64 = @as(i64, rect.offset.y);
const min_x: i64 = rect.offset.x;
const min_y: i64 = rect.offset.y;
const max_x: i64 = min_x + @as(i64, @intCast(rect.extent.width));
const max_y: i64 = min_y + @as(i64, @intCast(rect.extent.height));
@@ -485,6 +485,7 @@ inline fn run(data: RunData) !void {
centroid_b2,
);
const derivative_inputs: ?fragment.DerivativeInputs = if (data.fragment_uses_derivatives) blk: {
// SAFETY: both dx and dy are assigned below before derivatives is returned.
var derivatives: fragment.DerivativeInputs = undefined;
const p_dx = zm.f32x4(@as(f32, @floatFromInt(x)) + 1.5, @as(f32, @floatFromInt(y)) + 0.5, 0.0, 1.0);
+1 -1
View File
@@ -526,7 +526,7 @@ fn isConstantZero(rt: *spv.Runtime, result_word: spv.SpvWord) bool {
const variant = rt.results[result_word].variant orelse return false;
switch (variant) {
.Constant => |constant| {
var value: u32 = undefined;
var value: u32 = 0;
_ = constant.value.read(std.mem.asBytes(&value)) catch return false;
return value == 0;
},