ci skip; start of update to zig 0.16
All checks were successful
Build / build (push) Has been skipped
Test / build_and_test (push) Has been skipped

This commit is contained in:
2026-04-16 22:15:07 +02:00
parent ee0ffbe09d
commit 5be875c07e
15 changed files with 243 additions and 105 deletions

1
.gitignore vendored
View File

@@ -1,6 +1,7 @@
.cache/ .cache/
.zig-cache/ .zig-cache/
zig-out/ zig-out/
zig-pkg/
cts/ cts/
cts_report/ cts_report/
scripts/__pycache__/ scripts/__pycache__/

View File

@@ -25,12 +25,6 @@ Then ensure thy Vulkan loader is pointed toward the ICD manifest.
The precise ritual varies by system - consult the tomes of your operating system, or wander the web's endless mausoleum of documentation. The precise ritual varies by system - consult the tomes of your operating system, or wander the web's endless mausoleum of documentation.
Use at your own risk. If thy machine shudders, weeps, or attempts to flee - know that it was warned. Use at your own risk. If thy machine shudders, weeps, or attempts to flee - know that it was warned.
\
\
Thou may also conjure forth a tome of compile commands by doing thus:
```
zig build cdb
```
## Vulkan 1.0 specification ## Vulkan 1.0 specification
@@ -61,12 +55,12 @@ vkCmdClearAttachments | ⚙️ wip
vkCmdClearColorImage | ⚙️ WIP vkCmdClearColorImage | ⚙️ WIP
vkCmdClearDepthStencilImage | ⚙️ WIP vkCmdClearDepthStencilImage | ⚙️ WIP
vkCmdCopyBuffer | ✅ Implemented vkCmdCopyBuffer | ✅ Implemented
vkCmdCopyBufferToImage | ⚙️ WIP vkCmdCopyBufferToImage | ✅ Implemented
vkCmdCopyImage | ⚙️ WIP vkCmdCopyImage | ✅ Implemented
vkCmdCopyImageToBuffer | ⚙️ WIP vkCmdCopyImageToBuffer | ✅ Implemented
vkCmdCopyQueryPoolResults | ⚙️ WIP vkCmdCopyQueryPoolResults | ⚙️ WIP
vkCmdDispatch | ✅ Implemented vkCmdDispatch | ✅ Implemented
vkCmdDispatchIndirect | ⚙️ WIP vkCmdDispatchIndirect | ✅ Implemented
vkCmdDraw | ⚙️ WIP vkCmdDraw | ⚙️ WIP
vkCmdDrawIndexed | ⚙️ WIP vkCmdDrawIndexed | ⚙️ WIP
vkCmdDrawIndexedIndirect | ⚙️ WIP vkCmdDrawIndexedIndirect | ⚙️ WIP
@@ -109,7 +103,7 @@ vkCreateImage | ✅ Implemented
vkCreateImageView | ✅ Implemented vkCreateImageView | ✅ Implemented
vkCreateInstance | ✅ Implemented vkCreateInstance | ✅ Implemented
vkCreatePipelineCache | ⚙️ WIP vkCreatePipelineCache | ⚙️ WIP
vkCreatePipelineLayout | ⚙️ WIP vkCreatePipelineLayout | ✅ Implemented
vkCreateQueryPool | ⚙️ WIP vkCreateQueryPool | ⚙️ WIP
vkCreateRenderPass | ⚙️ WIP vkCreateRenderPass | ⚙️ WIP
vkCreateSampler | ⚙️ WIP vkCreateSampler | ⚙️ WIP
@@ -129,7 +123,7 @@ vkDestroyImageView | ✅ Implemented
vkDestroyInstance | ✅ Implemented vkDestroyInstance | ✅ Implemented
vkDestroyPipeline | ✅ Implemented vkDestroyPipeline | ✅ Implemented
vkDestroyPipelineCache | ⚙️ WIP vkDestroyPipelineCache | ⚙️ WIP
vkDestroyPipelineLayout | ⚙️ WIP vkDestroyPipelineLayout | ✅ Implemented
vkDestroyQueryPool | ⚙️ WIP vkDestroyQueryPool | ⚙️ WIP
vkDestroyRenderPass | ⚙️ WIP vkDestroyRenderPass | ⚙️ WIP
vkDestroySampler | ⚙️ WIP vkDestroySampler | ⚙️ WIP
@@ -157,8 +151,8 @@ vkGetImageSparseMemoryRequirements | ⚙️ WIP
vkGetImageSubresourceLayout | ⚙️ WIP vkGetImageSubresourceLayout | ⚙️ WIP
vkGetInstanceProcAddr | ✅ Implemented vkGetInstanceProcAddr | ✅ Implemented
vkGetPhysicalDeviceFeatures | ✅ Implemented vkGetPhysicalDeviceFeatures | ✅ Implemented
vkGetPhysicalDeviceFormatProperties | ⚙️ WIP vkGetPhysicalDeviceFormatProperties | ✅ Implemented
vkGetPhysicalDeviceImageFormatProperties | ⚙️ WIP vkGetPhysicalDeviceImageFormatProperties | ✅ Implemented
vkGetPhysicalDeviceMemoryProperties | ✅ Implemented vkGetPhysicalDeviceMemoryProperties | ✅ Implemented
vkGetPhysicalDeviceProperties | ✅ Implemented vkGetPhysicalDeviceProperties | ✅ Implemented
vkGetPhysicalDeviceQueueFamilyProperties | ✅ Implemented vkGetPhysicalDeviceQueueFamilyProperties | ✅ Implemented
@@ -173,8 +167,8 @@ vkQueueBindSparse | ⚙️ WIP
vkQueueSubmit | ✅ Implemented vkQueueSubmit | ✅ Implemented
vkQueueWaitIdle | ✅ Implemented vkQueueWaitIdle | ✅ Implemented
vkResetCommandBuffer | ✅ Implemented vkResetCommandBuffer | ✅ Implemented
vkResetCommandPool | ⚙️ WIP vkResetCommandPool | ✅ Implemented
vkResetDescriptorPool | ⚙️ WIP vkResetDescriptorPool | ✅ Implemented
vkResetEvent | ⚙️ WIP vkResetEvent | ⚙️ WIP
vkResetFences | ✅ Implemented vkResetFences | ✅ Implemented
vkSetEvent | ⚙️ WIP vkSetEvent | ⚙️ WIP

View File

@@ -1,6 +1,5 @@
const std = @import("std"); const std = @import("std");
const Step = std.Build.Step; const Step = std.Build.Step;
const zcc = @import("compile_commands");
const builtin = @import("builtin"); const builtin = @import("builtin");
const ImplementationDesc = struct { const ImplementationDesc = struct {
@@ -33,10 +32,8 @@ pub fn build(b: *std.Build) !void {
.root_source_file = b.path("src/vulkan/lib.zig"), .root_source_file = b.path("src/vulkan/lib.zig"),
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
.link_libc = true,
}); });
const zdt = b.dependency("zdt", .{}).module("zdt");
const zigrc = b.dependency("zigrc", .{}).module("zigrc"); const zigrc = b.dependency("zigrc", .{}).module("zigrc");
const vulkan_headers = b.dependency("vulkan_headers", .{}); const vulkan_headers = b.dependency("vulkan_headers", .{});
const vulkan_utility_libraries = b.dependency("vulkan_utility_libraries", .{}); const vulkan_utility_libraries = b.dependency("vulkan_utility_libraries", .{});
@@ -45,15 +42,12 @@ pub fn build(b: *std.Build) !void {
.registry = vulkan_headers.path("registry/vk.xml"), .registry = vulkan_headers.path("registry/vk.xml"),
}).module("vulkan-zig"); }).module("vulkan-zig");
base_mod.addImport("zdt", zdt);
base_mod.addImport("zigrc", zigrc); base_mod.addImport("zigrc", zigrc);
base_mod.addImport("vulkan", vulkan); base_mod.addImport("vulkan", vulkan);
base_mod.addSystemIncludePath(vulkan_headers.path("include")); base_mod.addSystemIncludePath(vulkan_headers.path("include"));
base_mod.addSystemIncludePath(vulkan_utility_libraries.path("include")); base_mod.addSystemIncludePath(vulkan_utility_libraries.path("include"));
for (implementations) |impl| { for (implementations) |impl| {
var targets = std.ArrayList(*std.Build.Step.Compile){};
const lib_mod = b.createModule(.{ const lib_mod = b.createModule(.{
.root_source_file = b.path(impl.root_source_file), .root_source_file = b.path(impl.root_source_file),
.target = target, .target = target,
@@ -106,10 +100,6 @@ pub fn build(b: *std.Build) !void {
const c_test = addCTest(b, target, optimize, vulkan_headers, &impl, lib) catch continue; const c_test = addCTest(b, target, optimize, vulkan_headers, &impl, lib) catch continue;
try targets.append(b.allocator, c_test);
try targets.append(b.allocator, lib);
_ = zcc.createStep(b, "cdb", try targets.toOwnedSlice(b.allocator));
(try addCTestRunner(b, &impl, c_test, .normal)).dependOn(&lib_install.step); (try addCTestRunner(b, &impl, c_test, .normal)).dependOn(&lib_install.step);
(try addCTestRunner(b, &impl, c_test, .gdb)).dependOn(&lib_install.step); (try addCTestRunner(b, &impl, c_test, .gdb)).dependOn(&lib_install.step);
(try addCTestRunner(b, &impl, c_test, .valgrind)).dependOn(&lib_install.step); (try addCTestRunner(b, &impl, c_test, .valgrind)).dependOn(&lib_install.step);
@@ -152,8 +142,8 @@ pub fn build(b: *std.Build) !void {
fn customSoft(b: *std.Build, lib: *std.Build.Step.Compile) !void { fn customSoft(b: *std.Build, lib: *std.Build.Step.Compile) !void {
const cpuinfo = b.lazyDependency("cpuinfo", .{}) orelse return error.UnresolvedDependency; const cpuinfo = b.lazyDependency("cpuinfo", .{}) orelse return error.UnresolvedDependency;
lib.addSystemIncludePath(cpuinfo.path("include")); lib.root_module.addSystemIncludePath(cpuinfo.path("include"));
lib.linkLibrary(cpuinfo.artifact("cpuinfo")); lib.root_module.linkLibrary(cpuinfo.artifact("cpuinfo"));
const interface = b.lazyDependency("interface", .{}) orelse return error.UnresolvedDependency; const interface = b.lazyDependency("interface", .{}) orelse return error.UnresolvedDependency;
lib.root_module.addImport("interface", interface.module("interface")); lib.root_module.addImport("interface", interface.module("interface"));
@@ -213,14 +203,16 @@ fn addCTestRunner(b: *std.Build, impl: *const ImplementationDesc, exe: *std.Buil
const run_step = b.step( const run_step = b.step(
b.fmt("test-c-{s}{s}", .{ b.fmt("test-c-{s}{s}", .{
impl.name, switch (mode) { impl.name,
switch (mode) {
.normal => "", .normal => "",
.gdb => "-gdb", .gdb => "-gdb",
.valgrind => "-valgrind", .valgrind => "-valgrind",
}, },
}), }),
b.fmt("Run libvulkan_{s} C tests{s}", .{ b.fmt("Run libvulkan_{s} C tests{s}", .{
impl.name, switch (mode) { impl.name,
switch (mode) {
.normal => "", .normal => "",
.gdb => " within GDB", .gdb => " within GDB",
.valgrind => " within Valgrind", .valgrind => " within Valgrind",
@@ -289,14 +281,16 @@ fn addCTS(b: *std.Build, target: std.Build.ResolvedTarget, impl: *const Implemen
const run_step = b.step( const run_step = b.step(
b.fmt("raw-cts-{s}{s}", .{ b.fmt("raw-cts-{s}{s}", .{
impl.name, switch (mode) { impl.name,
switch (mode) {
.normal => "", .normal => "",
.gdb => "-gdb", .gdb => "-gdb",
.valgrind => "-valgrind", .valgrind => "-valgrind",
}, },
}), }),
b.fmt("Run Vulkan conformance tests for libvulkan_{s}{s}", .{ b.fmt("Run Vulkan conformance tests for libvulkan_{s}{s}", .{
impl.name, switch (mode) { impl.name,
switch (mode) {
.normal => "", .normal => "",
.gdb => " within GDB", .gdb => " within GDB",
.valgrind => " within Valgrind", .valgrind => " within Valgrind",
@@ -312,16 +306,10 @@ fn addMultithreadedCTS(b: *std.Build, target: std.Build.ResolvedTarget, impl: *c
const cts = b.dependency("cts_bin", .{}); const cts = b.dependency("cts_bin", .{});
// Some systems may need a manual path management to get to packages (e.g. Github Actions) // Some systems may need a manual path management to get to packages (e.g. Github Actions)
const cache_path = blk: { const cache_path = if (std.zig.EnvVar.get(.ZIG_GLOBAL_CACHE_DIR, &b.graph.environ_map)) |cache_path|
if (std.process.getEnvVarOwned(b.allocator, "ZIG_GLOBAL_CACHE_DIR")) |cache_path| { b.fmt("{s}/../", .{cache_path})
break :blk b.fmt("{s}/../", .{cache_path}); else
} else |err| switch (err) { "";
error.EnvironmentVariableNotFound => {
break :blk "";
},
else => unreachable,
}
};
const cts_exe_name = cts.path(b.fmt("deqp-vk-{s}", .{ const cts_exe_name = cts.path(b.fmt("deqp-vk-{s}", .{
switch (if (target.query.os_tag) |tag| tag else builtin.target.os.tag) { switch (if (target.query.os_tag) |tag| tag else builtin.target.os.tag) {

View File

@@ -2,29 +2,21 @@
.name = .VulkanDriver, .name = .VulkanDriver,
.version = "0.0.1", .version = "0.0.1",
.fingerprint = 0x52cb73649f1107de, .fingerprint = 0x52cb73649f1107de,
.minimum_zig_version = "0.15.2", .minimum_zig_version = "0.16.0",
.dependencies = .{ .dependencies = .{
.compile_commands = .{
.url = "git+https://github.com/the-argus/zig-compile-commands#f74e2d13e43fafab3a71e19557a0e1cfbf0f2e1b",
.hash = "zig_compile_commands-0.0.1-OZg5-a3CAACM-h32Kjb1obTMqrKGs9YoDhorVZ8-LGle",
},
.vulkan_headers = .{ .vulkan_headers = .{
.url = "git+https://github.com/KhronosGroup/Vulkan-Headers?ref=v1.4.330#ee3b5caaa7e372715873c7b9c390ee1c3ca5db25", .url = "git+https://github.com/KhronosGroup/Vulkan-Headers?ref=v1.4.330#ee3b5caaa7e372715873c7b9c390ee1c3ca5db25",
.hash = "N-V-__8AAFXYAQKsK51AAGXB9HziPDFjS_DVUq6_QHVxHrBM", .hash = "N-V-__8AAFXYAQKsK51AAGXB9HziPDFjS_DVUq6_QHVxHrBM",
}, },
.vulkan_zig = .{ .vulkan_zig = .{
.url = "git+https://github.com/catmeow72/vulkan-zig/#8961518db28f88d2cf09ea68e146923de2cfa7f0", .url = "git+https://github.com/Snektron/vulkan-zig#be16fc99f7f794cba90334978c6c5aadeda8094f",
.hash = "vulkan-0.0.0-r7Ytx6hBAwD8X_TN32qlkzul4riK6vFvjtK9fZfRvALg", .hash = "vulkan-0.0.0-r7Ytx-V9AwCwHxS2TaZ-KJCp_3axidu3ASZUg3B512-k",
}, },
.vulkan_utility_libraries = .{ .vulkan_utility_libraries = .{
.url = "git+https://github.com/KhronosGroup/Vulkan-Utility-Libraries.git#ba452bad58bb4d4c64d7fbd872bf69f70141510e", .url = "git+https://github.com/KhronosGroup/Vulkan-Utility-Libraries.git#ba452bad58bb4d4c64d7fbd872bf69f70141510e",
.hash = "N-V-__8AAE42fwC1FFw26LNZ8AaSuGMdgG4vfYkfV_227sET", .hash = "N-V-__8AAE42fwC1FFw26LNZ8AaSuGMdgG4vfYkfV_227sET",
}, },
.zdt = .{
.url = "git+https://codeberg.org/FObersteiner/zdt?ref=v0.8.3-zig_0.15#d68b181f4401466527d7eb3d7c08bc94b43f2ca3",
.hash = "zdt-0.8.3-xr0_vLTNEQB917nKguiLool244ldWllKbhI7Nupl6kmP",
},
.cts_bin = .{ .cts_bin = .{
.url = "git+https://git.kbz8.me/kbz_8/Vulkan-CTS-bin#19ce2da05f8176348064a9fc6688847e5f76a46e", .url = "git+https://git.kbz8.me/kbz_8/Vulkan-CTS-bin#19ce2da05f8176348064a9fc6688847e5f76a46e",
.hash = "N-V-__8AAHDV0xtS93nAGaYd7YWxBLnvHDEplwIpC29izSGa", .hash = "N-V-__8AAHDV0xtS93nAGaYd7YWxBLnvHDEplwIpC29izSGa",
@@ -59,8 +51,8 @@
.lazy = true, .lazy = true,
}, },
.SPIRV_Interpreter = .{ .SPIRV_Interpreter = .{
.url = "git+https://git.kbz8.me/kbz_8/SPIRV-Interpreter#9f586ae9c0414dbcd5545b258733a78b5301fee8", .url = "git+https://git.kbz8.me/kbz_8/SPIRV-Interpreter#4bd688cf07ea7d71c18a02153bb197e7b1e3cd82",
.hash = "SPIRV_Interpreter-0.0.1-ajmpnxCFBADEKjJFMVvGhAEs1Nr-lrsHXDd5uYnUxYor", .hash = "SPIRV_Interpreter-0.0.1-ajmpn1aKBACoxQzshafHCjoUx6OfuFcyt1dumaerdtDo",
}, },
}, },

View File

@@ -177,7 +177,7 @@ pub fn blitImage(interface: *Interface, src: *base.Image, _: vk.ImageLayout, dst
pub fn execute(impl: *const Impl, device: *ExecutionDevice) VkError!void { pub fn execute(impl: *const Impl, device: *ExecutionDevice) VkError!void {
for (impl.regions[0..]) |region| { for (impl.regions[0..]) |region| {
try device.blitter.blitRegion(impl.src, impl.dst, region); try device.blitter.blitRegion(impl.src, impl.dst, region, impl.filter);
} }
} }
}; };

View File

@@ -14,6 +14,8 @@ pub const Interface = base.DescriptorPool;
interface: Interface, interface: Interface,
list: std.ArrayList(*SoftDescriptorSet),
pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const vk.DescriptorPoolCreateInfo) VkError!*Self { pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const vk.DescriptorPoolCreateInfo) VkError!*Self {
const self = allocator.create(Self) catch return VkError.OutOfHostMemory; const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
errdefer allocator.destroy(self); errdefer allocator.destroy(self);
@@ -24,27 +26,48 @@ pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const v
.allocateDescriptorSet = allocateDescriptorSet, .allocateDescriptorSet = allocateDescriptorSet,
.destroy = destroy, .destroy = destroy,
.freeDescriptorSet = freeDescriptorSet, .freeDescriptorSet = freeDescriptorSet,
.reset = reset,
}; };
self.* = .{ self.* = .{
.interface = interface, .interface = interface,
.list = std.ArrayList(*SoftDescriptorSet).initCapacity(allocator, info.max_sets) catch return VkError.OutOfHostMemory,
}; };
return self; return self;
} }
pub fn allocateDescriptorSet(interface: *Interface, layout: *base.DescriptorSetLayout) VkError!*base.DescriptorSet { pub fn allocateDescriptorSet(interface: *Interface, layout: *base.DescriptorSetLayout) VkError!*base.DescriptorSet {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
const allocator = VulkanAllocator.init(null, .object).allocator(); const allocator = VulkanAllocator.init(null, .object).allocator();
const set = try SoftDescriptorSet.create(interface.owner, allocator, layout); const set = try SoftDescriptorSet.create(interface.owner, allocator, layout);
self.list.appendAssumeCapacity(set);
return &set.interface; return &set.interface;
} }
pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void { pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface)); const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
self.list.deinit(allocator);
allocator.destroy(self); allocator.destroy(self);
} }
pub fn freeDescriptorSet(interface: *Interface, set: *base.DescriptorSet) VkError!void { pub fn freeDescriptorSet(interface: *Interface, set: *base.DescriptorSet) VkError!void {
_ = interface; const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
const soft_set: *SoftDescriptorSet = @alignCast(@fieldParentPtr("interface", set));
if (std.mem.indexOfScalar(*SoftDescriptorSet, self.list.items, soft_set)) |pos| {
_ = self.list.orderedRemove(pos);
}
const allocator = VulkanAllocator.init(null, .object).allocator(); const allocator = VulkanAllocator.init(null, .object).allocator();
allocator.destroy(set); allocator.destroy(soft_set);
}
pub fn reset(interface: *Interface, _: vk.DescriptorPoolResetFlags) VkError!void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
const allocator = VulkanAllocator.init(null, .object).allocator();
for (self.list.items) |set| {
allocator.destroy(set);
}
self.list.clearRetainingCapacity();
} }

View File

@@ -101,8 +101,125 @@ fn fastClear(self: *Self, clear_value: vk.ClearValue, clear_format: vk.Format, d
return false; return false;
} }
pub fn blitRegion(_: *Self, src: *const SoftImage, dst: *SoftImage, region: vk.ImageBlit) VkError!void { pub fn blitRegion(_: *Self, src: *const SoftImage, dst: *SoftImage, region: vk.ImageBlit, filter: vk.Filter) VkError!void {
_ = src; var dst_offset_0 = region.dst_offsets[0];
_ = dst; var dst_offset_1 = region.dst_offsets[1];
_ = region; var src_offset_0 = region.src_offsets[0];
var src_offset_1 = region.src_offsets[1];
if (dst_offset_0.x > dst_offset_1.x) {
std.mem.swap(i32, &src_offset_0.x, &src_offset_1.x);
std.mem.swap(i32, &dst_offset_0.x, &dst_offset_1.x);
}
if (dst_offset_0.y > dst_offset_1.y) {
std.mem.swap(i32, &src_offset_0.y, &src_offset_1.y);
std.mem.swap(i32, &dst_offset_0.y, &dst_offset_1.y);
}
if (dst_offset_0.z > dst_offset_1.z) {
std.mem.swap(i32, &src_offset_0.z, &src_offset_1.z);
std.mem.swap(i32, &dst_offset_0.z, &dst_offset_1.z);
}
const src_extent = src.getMipLevelExtent(region.src_subresource.mip_level);
_ = src_extent;
const width_ratio = @as(f32, @floatFromInt(src_offset_1.x - src_offset_0.x)) / @as(f32, @floatFromInt(dst_offset_1.x - dst_offset_0.x));
const height_ratio = @as(f32, @floatFromInt(src_offset_1.y - src_offset_0.y)) / @as(f32, @floatFromInt(dst_offset_1.y - dst_offset_0.y));
const depth_ratio = @as(f32, @floatFromInt(src_offset_1.z - src_offset_0.z)) / @as(f32, @floatFromInt(dst_offset_1.z - dst_offset_0.z));
const x0 = @as(f32, @floatFromInt(src_offset_0.x)) + (0.5 - @as(f32, @floatFromInt(dst_offset_0.x))) * width_ratio;
const y0 = @as(f32, @floatFromInt(src_offset_0.y)) + (0.5 - @as(f32, @floatFromInt(dst_offset_0.y))) * height_ratio;
const z0 = @as(f32, @floatFromInt(src_offset_0.z)) + (0.5 - @as(f32, @floatFromInt(dst_offset_0.z))) * depth_ratio;
_ = x0;
_ = y0;
_ = z0;
const src_format = base.format.fromAspect(src.interface.format, region.src_subresource.aspect_mask);
const dst_format = base.format.fromAspect(dst.interface.format, region.dst_subresource.aspect_mask);
const apply_filter = (filter != .nearest);
const allow_srgb_conversion = apply_filter or base.format.isSrgb(src_format) != base.format.isSrgb(dst_format);
_ = allow_srgb_conversion;
} }
// State state(srcFormat, dstFormat, src->getSampleCount(), dst->getSampleCount(),
// Options{ doFilter, allowSRGBConversion });
// state.clampToEdge = (region.srcOffsets[0].x < 0) ||
// (region.srcOffsets[0].y < 0) ||
// (static_cast<uint32_t>(region.srcOffsets[1].x) > srcExtent.width) ||
// (static_cast<uint32_t>(region.srcOffsets[1].y) > srcExtent.height) ||
// (doFilter && ((x0 < 0.5f) || (y0 < 0.5f)));
// state.filter3D = (region.srcOffsets[1].z - region.srcOffsets[0].z) !=
// (region.dstOffsets[1].z - region.dstOffsets[0].z);
//
// auto blitRoutine = getBlitRoutine(state);
// if(!blitRoutine)
// {
// return;
// }
//
// BlitData data = {
// nullptr, // source
// nullptr, // dest
// assert_cast<uint32_t>(src->rowPitchBytes(srcAspect, region.srcSubresource.mipLevel)), // sPitchB
// assert_cast<uint32_t>(dst->rowPitchBytes(dstAspect, region.dstSubresource.mipLevel)), // dPitchB
// assert_cast<uint32_t>(src->slicePitchBytes(srcAspect, region.srcSubresource.mipLevel)), // sSliceB
// assert_cast<uint32_t>(dst->slicePitchBytes(dstAspect, region.dstSubresource.mipLevel)), // dSliceB
//
// x0,
// y0,
// z0,
// widthRatio,
// heightRatio,
// depthRatio,
//
// region.dstOffsets[0].x, // x0d
// region.dstOffsets[1].x, // x1d
// region.dstOffsets[0].y, // y0d
// region.dstOffsets[1].y, // y1d
// region.dstOffsets[0].z, // z0d
// region.dstOffsets[1].z, // z1d
//
// static_cast<int>(srcExtent.width), // sWidth
// static_cast<int>(srcExtent.height), // sHeight
// static_cast<int>(srcExtent.depth), // sDepth
//
// false, // filter3D
// };
//
// VkImageSubresource srcSubres = {
// region.srcSubresource.aspectMask,
// region.srcSubresource.mipLevel,
// region.srcSubresource.baseArrayLayer
// };
//
// VkImageSubresource dstSubres = {
// region.dstSubresource.aspectMask,
// region.dstSubresource.mipLevel,
// region.dstSubresource.baseArrayLayer
// };
//
// VkImageSubresourceRange dstSubresRange = {
// region.dstSubresource.aspectMask,
// region.dstSubresource.mipLevel,
// 1, // levelCount
// region.dstSubresource.baseArrayLayer,
// region.dstSubresource.layerCount
// };
//
// uint32_t lastLayer = src->getLastLayerIndex(dstSubresRange);
//
// for(; dstSubres.arrayLayer <= lastLayer; srcSubres.arrayLayer++, dstSubres.arrayLayer++)
// {
// data.source = src->getTexelPointer({ 0, 0, 0 }, srcSubres);
// data.dest = dst->getTexelPointer({ 0, 0, 0 }, dstSubres);
//
// ASSERT(data.source < src->end());
// ASSERT(data.dest < dst->end());
//
// blitRoutine(&data);
// }

View File

@@ -21,6 +21,7 @@ pub const VTable = struct {
allocateDescriptorSet: *const fn (*Self, *DescriptorSetLayout) VkError!*DescriptorSet, allocateDescriptorSet: *const fn (*Self, *DescriptorSetLayout) VkError!*DescriptorSet,
destroy: *const fn (*Self, std.mem.Allocator) void, destroy: *const fn (*Self, std.mem.Allocator) void,
freeDescriptorSet: *const fn (*Self, *DescriptorSet) VkError!void, freeDescriptorSet: *const fn (*Self, *DescriptorSet) VkError!void,
reset: *const fn (*Self, vk.DescriptorPoolResetFlags) VkError!void,
}; };
pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.DescriptorPoolCreateInfo) VkError!Self { pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.DescriptorPoolCreateInfo) VkError!Self {
@@ -43,3 +44,7 @@ pub inline fn destroy(self: *Self, allocator: std.mem.Allocator) void {
pub inline fn freeDescriptorSet(self: *Self, set: *DescriptorSet) VkError!void { pub inline fn freeDescriptorSet(self: *Self, set: *DescriptorSet) VkError!void {
try self.vtable.freeDescriptorSet(self, set); try self.vtable.freeDescriptorSet(self, set);
} }
pub inline fn reset(self: *Self, flags: vk.DescriptorPoolResetFlags) VkError!void {
try self.vtable.reset(self, flags);
}

View File

@@ -72,15 +72,6 @@ pub inline fn getMemoryRequirements(self: *Self, requirements: *vk.MemoryRequire
try self.vtable.getMemoryRequirements(self, requirements); try self.vtable.getMemoryRequirements(self, requirements);
} }
pub inline fn getClearFormat(self: *Self) vk.Format {
return if (lib.vku.vkuFormatIsSINT(@intCast(@intFromEnum(self.format))))
.r32g32b32a32_sint
else if (lib.vku.vkuFormatIsUINT(@intCast(@intFromEnum(self.format))))
.r32g32b32a32_uint
else
.r32g32b32a32_sfloat;
}
pub inline fn getTexelSize(self: *const Self) usize { pub inline fn getTexelSize(self: *const Self) usize {
return lib.format.texelSize(self.format); return lib.format.texelSize(self.format);
} }

View File

@@ -1,6 +1,7 @@
const std = @import("std"); const std = @import("std");
const builtin = @import("builtin"); const builtin = @import("builtin");
const vk = @import("vulkan"); const vk = @import("vulkan");
const config = @import("config");
const logger = @import("lib.zig").logger; const logger = @import("lib.zig").logger;
@@ -21,7 +22,15 @@ comptime {
const Self = @This(); const Self = @This();
pub const ObjectType: vk.ObjectType = .instance; pub const ObjectType: vk.ObjectType = .instance;
const DeviceAllocator = struct {
pub inline fn allocator(_: @This()) std.mem.Allocator {
return std.heap.smp_allocator;
}
};
physical_devices: std.ArrayList(*Dispatchable(PhysicalDevice)), physical_devices: std.ArrayList(*Dispatchable(PhysicalDevice)),
threaded: std.Io.Threaded,
allocator: if (config.debug_allocator) std.heap.DebugAllocator(.{}) else DeviceAllocator,
dispatch_table: *const DispatchTable, dispatch_table: *const DispatchTable,
vtable: *const VTable, vtable: *const VTable,

View File

@@ -90,3 +90,31 @@ pub inline fn sliceMemSize(format: vk.Format, width: usize, height: usize) usize
pub inline fn isDepthAndStencil(format: vk.Format) bool { pub inline fn isDepthAndStencil(format: vk.Format) bool {
return lib.vku.vkuFormatIsDepthAndStencil(@intCast(@intFromEnum(format))); return lib.vku.vkuFormatIsDepthAndStencil(@intCast(@intFromEnum(format)));
} }
pub inline fn isSrgb(format: vk.Format) bool {
return lib.vku.vkuFormatIsSRGB(@intCast(@intFromEnum(format)));
}
pub inline fn isSfloat(format: vk.Format) bool {
return lib.vku.vkuFormatIsSFLOAT(@intCast(@intFromEnum(format)));
}
pub inline fn isSint(format: vk.Format) bool {
return lib.vku.vkuFormatIsSINT(@intCast(@intFromEnum(format)));
}
pub inline fn isSnorm(format: vk.Format) bool {
return lib.vku.vkuFormatIsSNORM(@intCast(@intFromEnum(format)));
}
pub inline fn isUfloat(format: vk.Format) bool {
return lib.vku.vkuFormatIsUFLOAT(@intCast(@intFromEnum(format)));
}
pub inline fn isUint(format: vk.Format) bool {
return lib.vku.vkuFormatIsUINT(@intCast(@intFromEnum(format)));
}
pub inline fn isUnorm(format: vk.Format) bool {
return lib.vku.vkuFormatIsUNORM(@intCast(@intFromEnum(format)));
}

View File

@@ -91,7 +91,7 @@ pub const LogVerboseLevel = enum {
TooMuch, TooMuch,
}; };
pub inline fn getLogVerboseLevel() LogVerboseLevel { pub fn getLogVerboseLevel() LogVerboseLevel {
const allocator = std.heap.c_allocator; const allocator = std.heap.c_allocator;
const level = std.process.getEnvVarOwned(allocator, DRIVER_LOGS_ENV_NAME) catch return .None; const level = std.process.getEnvVarOwned(allocator, DRIVER_LOGS_ENV_NAME) catch return .None;
defer allocator.free(level); defer allocator.free(level);

View File

@@ -1517,28 +1517,18 @@ pub export fn strollResetCommandPool(p_device: vk.Device, p_pool: vk.CommandPool
Dispatchable(Device).checkHandleValidity(p_device) catch |err| return toVkResult(err); Dispatchable(Device).checkHandleValidity(p_device) catch |err| return toVkResult(err);
const pool = NonDispatchable(CommandPool).fromHandleObject(p_pool) catch |err| return toVkResult(err); const pool = NonDispatchable(CommandPool).fromHandleObject(p_pool) catch |err| return toVkResult(err);
pool.reset(flags) catch |err| return toVkResult(err);
notImplementedWarning(); return .success;
_ = pool;
_ = flags;
return .error_unknown;
} }
pub export fn strollResetDescriptorPool(p_device: vk.Device, p_pool: vk.DescriptorPool, flags: vk.CommandPoolResetFlags) callconv(vk.vulkan_call_conv) vk.Result { pub export fn strollResetDescriptorPool(p_device: vk.Device, p_pool: vk.DescriptorPool, flags: vk.DescriptorPoolResetFlags) callconv(vk.vulkan_call_conv) vk.Result {
entryPointBeginLogTrace(.vkResetDescriptorPool); entryPointBeginLogTrace(.vkResetDescriptorPool);
defer entryPointEndLogTrace(); defer entryPointEndLogTrace();
Dispatchable(Device).checkHandleValidity(p_device) catch |err| return toVkResult(err); Dispatchable(Device).checkHandleValidity(p_device) catch |err| return toVkResult(err);
const pool = NonDispatchable(DescriptorPool).fromHandleObject(p_pool) catch |err| return toVkResult(err); const pool = NonDispatchable(DescriptorPool).fromHandleObject(p_pool) catch |err| return toVkResult(err);
pool.reset(flags) catch |err| return toVkResult(err);
notImplementedWarning(); return .success;
_ = pool;
_ = flags;
return .error_unknown;
} }
pub export fn strollResetEvent(p_device: vk.Device, p_event: vk.Fence) callconv(vk.vulkan_call_conv) vk.Result { pub export fn strollResetEvent(p_device: vk.Device, p_event: vk.Fence) callconv(vk.vulkan_call_conv) vk.Result {

View File

@@ -4,14 +4,18 @@ const Manager = @import("Manager.zig");
const Self = @This(); const Self = @This();
managers: std.AutoArrayHashMapUnmanaged(std.Thread.Id, Manager), managers: std.AutoArrayHashMapUnmanaged(std.Thread.Id, Manager),
allocator: std.heap.ThreadSafeAllocator, allocator: std.mem.Allocator,
mutex: std.Thread.Mutex, mutex: std.Io.Mutex,
io: std.Io,
pub const init: Self = .{ pub fn init(io: std.Io, allocator: std.mem.Allocator) Self {
.managers = .empty, return .{
.allocator = .{ .child_allocator = std.heap.c_allocator }, .managers = .empty,
.mutex = .{}, .allocator = allocator,
}; .mutex = .init,
.io = io,
};
}
pub fn get(self: *Self) *Manager { pub fn get(self: *Self) *Manager {
const allocator = self.allocator.allocator(); const allocator = self.allocator.allocator();
@@ -23,17 +27,14 @@ pub fn get(self: *Self) *Manager {
} }
pub fn deinit(self: *Self) void { pub fn deinit(self: *Self) void {
{ self.mutex.lockUncancelable();
self.mutex.lock(); defer self.mutex.unlock();
defer self.mutex.unlock();
if (self.managers.getPtr(std.Thread.getCurrentId())) |manager| { if (self.managers.getPtr(std.Thread.getCurrentId())) |manager| {
manager.deinit(); manager.deinit();
_ = self.managers.orderedRemove(std.Thread.getCurrentId()); _ = self.managers.orderedRemove(std.Thread.getCurrentId());
}
} }
if (self.managers.count() == 0) { if (self.managers.count() == 0) {
self.managers.deinit(self.allocator.allocator()); self.managers.deinit(self.allocator);
self.* = .init;
} }
} }

View File

@@ -3,7 +3,6 @@
const std = @import("std"); const std = @import("std");
const builtin = @import("builtin"); const builtin = @import("builtin");
const zdt = @import("zdt");
const root = @import("root"); const root = @import("root");
const lib = @import("../lib.zig"); const lib = @import("../lib.zig");
@@ -39,7 +38,7 @@ pub inline fn nestedFixme(comptime format: []const u8, args: anytype) void {
std.log.scoped(.FIXME).warn("FIXME: " ++ format, args); std.log.scoped(.FIXME).warn("FIXME: " ++ format, args);
} }
pub fn log(comptime level: std.log.Level, comptime scope: @Type(.enum_literal), comptime format: []const u8, args: anytype) void { pub fn log(comptime level: std.log.Level, comptime scope: @EnumLiteral(), comptime format: []const u8, args: anytype) void {
if (lib.getLogVerboseLevel() == .None) { if (lib.getLogVerboseLevel() == .None) {
return; return;
} }