Compare commits
2 Commits
8f68ce4bf7
...
1378812a12
| Author | SHA1 | Date | |
|---|---|---|---|
|
1378812a12
|
|||
|
ac5e14f647
|
29
build.zig
29
build.zig
@@ -6,7 +6,7 @@ const ImplementationDesc = struct {
|
||||
name: []const u8,
|
||||
root_source_file: []const u8,
|
||||
vulkan_version: std.SemanticVersion,
|
||||
custom: ?*const fn (*std.Build, *std.Build.Step.Compile) anyerror!void = null,
|
||||
custom: ?*const fn (*std.Build, *std.Build.Step.Compile, *std.Build.Step.Options) anyerror!void = null,
|
||||
};
|
||||
|
||||
const implementations = [_]ImplementationDesc{
|
||||
@@ -41,11 +41,16 @@ pub fn build(b: *std.Build) !void {
|
||||
.registry = vulkan_headers.path("registry/vk.xml"),
|
||||
}).module("vulkan-zig");
|
||||
|
||||
const logs_option = b.option(bool, "logs", "Driver logs") orelse false;
|
||||
|
||||
const options = b.addOptions();
|
||||
options.addOption(bool, "logs", logs_option);
|
||||
|
||||
base_mod.addImport("vulkan", vulkan);
|
||||
base_mod.addSystemIncludePath(vulkan_headers.path("include"));
|
||||
base_mod.addSystemIncludePath(vulkan_utility_libraries.path("include"));
|
||||
|
||||
const use_llvm = b.option(bool, "use-llvm", "use llvm") orelse (b.release_mode != .off);
|
||||
const use_llvm = b.option(bool, "use-llvm", "LLVM build") orelse (b.release_mode != .off);
|
||||
|
||||
for (implementations) |impl| {
|
||||
const lib_mod = b.createModule(.{
|
||||
@@ -68,7 +73,7 @@ pub fn build(b: *std.Build) !void {
|
||||
});
|
||||
|
||||
if (impl.custom) |custom| {
|
||||
custom(b, lib) catch continue;
|
||||
custom(b, lib, options) catch continue;
|
||||
}
|
||||
|
||||
const icd_file = b.addWriteFile(
|
||||
@@ -118,6 +123,8 @@ pub fn build(b: *std.Build) !void {
|
||||
impl_docs_step.dependOn(&impl_install_docs.step);
|
||||
}
|
||||
|
||||
base_mod.addOptions("config", options);
|
||||
|
||||
const autodoc_test = b.addObject(.{
|
||||
.name = "lib",
|
||||
.root_module = base_mod,
|
||||
@@ -133,7 +140,7 @@ pub fn build(b: *std.Build) !void {
|
||||
docs_step.dependOn(&install_docs.step);
|
||||
}
|
||||
|
||||
fn customSoft(b: *std.Build, lib: *std.Build.Step.Compile) !void {
|
||||
fn customSoft(b: *std.Build, lib: *std.Build.Step.Compile, options: *std.Build.Step.Options) !void {
|
||||
const cpuinfo = b.lazyDependency("cpuinfo", .{}) orelse return error.UnresolvedDependency;
|
||||
lib.root_module.addSystemIncludePath(cpuinfo.path("include"));
|
||||
lib.root_module.linkLibrary(cpuinfo.artifact("cpuinfo"));
|
||||
@@ -145,11 +152,17 @@ fn customSoft(b: *std.Build, lib: *std.Build.Step.Compile) !void {
|
||||
}).module("spv");
|
||||
lib.root_module.addImport("spv", spv);
|
||||
|
||||
const debug_allocator_option = b.option(bool, "debug-allocator", "debug device allocator") orelse false;
|
||||
const debug_allocator_option = b.option(bool, "debug-allocator", "Debug device allocator") orelse false;
|
||||
const shaders_simd_option = b.option(bool, "shader-simd", "Shaders SIMD acceleration") orelse true;
|
||||
const single_threaded_compute_option = b.option(bool, "single-threaded-compute", "Single threaded compute shaders execution") orelse true;
|
||||
const compute_dump_early_results_table_option = b.option(u32, "compute-dump-early-results-table", "Dump compute shaders results table before invocation");
|
||||
const compute_dump_final_results_table_option = b.option(u32, "compute-dump-final-results-table", "Dump compute shaders results table after invocation");
|
||||
|
||||
const options = b.addOptions();
|
||||
options.addOption(bool, "debug_allocator", debug_allocator_option);
|
||||
lib.root_module.addOptions("config", options);
|
||||
options.addOption(bool, "shaders_simd", shaders_simd_option);
|
||||
options.addOption(bool, "single_threaded_compute", single_threaded_compute_option);
|
||||
options.addOption(?u32, "compute_dump_early_results_table", compute_dump_early_results_table_option);
|
||||
options.addOption(?u32, "compute_dump_final_results_table", compute_dump_final_results_table_option);
|
||||
}
|
||||
|
||||
fn addCTS(b: *std.Build, target: std.Build.ResolvedTarget, impl: *const ImplementationDesc, impl_lib: *std.Build.Step.Compile, comptime mode: RunningMode) !*std.Build.Step {
|
||||
@@ -270,6 +283,8 @@ fn addMultithreadedCTS(b: *std.Build, target: std.Build.ResolvedTarget, impl: *c
|
||||
const run = b.addSystemCommand(&[_][]const u8{"deqp-runner"});
|
||||
run.step.dependOn(&impl_lib.step);
|
||||
|
||||
std.debug.print("test {s}\n", .{mustpass_path});
|
||||
|
||||
run.addArg("run");
|
||||
run.addArg("--deqp");
|
||||
run.addArg(cts_exe_path);
|
||||
|
||||
@@ -2,7 +2,7 @@ const std = @import("std");
|
||||
const vk = @import("vulkan");
|
||||
const base = @import("base");
|
||||
const builtin = @import("builtin");
|
||||
const config = @import("config");
|
||||
const config = base.config;
|
||||
|
||||
const SoftQueue = @import("SoftQueue.zig");
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const v
|
||||
self.* = .{
|
||||
.interface = interface,
|
||||
.module = spv.Module.init(allocator, code, .{
|
||||
.use_simd_vectors_specializations = !base.env.hasEnvVar(lib.NO_SHADER_SIMD_ENV_NAME),
|
||||
.use_simd_vectors_specializations = base.config.shaders_simd,
|
||||
}) catch |err| switch (err) {
|
||||
spv.Module.ModuleError.OutOfMemory => return VkError.OutOfHostMemory,
|
||||
else => {
|
||||
|
||||
@@ -35,26 +35,13 @@ early_dump: ?u32,
|
||||
final_dump: ?u32,
|
||||
|
||||
pub fn init(device: *SoftDevice, state: *PipelineState) Self {
|
||||
const early_dumb_env_var = base.env.getEnvVar(lib.DUMP_EARLY_RESULT_TABLE_ENV_NAME);
|
||||
const final_dumb_env_var = base.env.getEnvVar(lib.DUMP_FINAL_RESULT_TABLE_ENV_NAME);
|
||||
|
||||
return .{
|
||||
.device = device,
|
||||
.state = state,
|
||||
.batch_size = 0,
|
||||
.invocation_index = .init(0),
|
||||
.early_dump = blk: {
|
||||
if (early_dumb_env_var) |val| {
|
||||
break :blk std.fmt.parseInt(u32, std.mem.span(val.ptr), 10) catch null;
|
||||
}
|
||||
break :blk null;
|
||||
},
|
||||
.final_dump = blk: {
|
||||
if (final_dumb_env_var) |val| {
|
||||
break :blk std.fmt.parseInt(u32, std.mem.span(val.ptr), 10) catch null;
|
||||
}
|
||||
break :blk null;
|
||||
},
|
||||
.early_dump = base.config.compute_dump_early_results_table,
|
||||
.final_dump = base.config.compute_dump_final_results_table,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -76,7 +63,7 @@ pub fn dispatch(self: *Self, group_count_x: u32, group_count_y: u32, group_count
|
||||
|
||||
var wg: std.Io.Group = .init;
|
||||
for (0..@min(self.batch_size, group_count)) |batch_id| {
|
||||
if (base.env.hasEnvVar(lib.SINGLE_THREAD_COMPUTE_EXECUTION_ENV_NAME)) {
|
||||
if (base.config.single_threaded_compute) {
|
||||
@branchHint(.cold); // Should only be reached for debugging
|
||||
|
||||
runWrapper(
|
||||
|
||||
@@ -40,11 +40,6 @@ pub const VULKAN_VERSION = vk.makeApiVersion(0, 1, 0, 0);
|
||||
pub const DRIVER_VERSION = vk.makeApiVersion(0, 0, 0, 1);
|
||||
pub const DEVICE_ID = 0x600DCAFE;
|
||||
|
||||
pub const NO_SHADER_SIMD_ENV_NAME = "STROLL_SOFT_NO_SIMD";
|
||||
pub const SINGLE_THREAD_COMPUTE_EXECUTION_ENV_NAME = "STROLL_SOFT_SINGLE_THREAD_COMPUTE_EXECUTION";
|
||||
pub const DUMP_EARLY_RESULT_TABLE_ENV_NAME = "STROLL_SOFT_DUMP_EARLY_RESULT_TABLE_FOR_INVOCATION";
|
||||
pub const DUMP_FINAL_RESULT_TABLE_ENV_NAME = "STROLL_SOFT_DUMP_FINAL_RESULT_TABLE_FOR_INVOCATION";
|
||||
|
||||
/// Generic system memory.
|
||||
pub const MEMORY_TYPE_GENERIC_BIT = 0;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const vk = @import("vulkan");
|
||||
const config = @import("config");
|
||||
const config = @import("lib.zig").config;
|
||||
|
||||
const VkError = @import("error_set.zig").VkError;
|
||||
const Dispatchable = @import("Dispatchable.zig").Dispatchable;
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub fn hasEnvVar(name: []const u8) bool {
|
||||
return getEnvVar(name) != null;
|
||||
}
|
||||
|
||||
pub fn getEnvVar(name: []const u8) ?[:0]const u8 {
|
||||
if (builtin.os.tag == .windows)
|
||||
return null;
|
||||
|
||||
if (std.mem.indexOfScalar(u8, name, '=') != null)
|
||||
return null;
|
||||
|
||||
var ptr = std.c.environ;
|
||||
while (ptr[0]) |line| : (ptr += 1) {
|
||||
var line_i: usize = 0;
|
||||
while (line[line_i] != 0) : (line_i += 1) {
|
||||
if (line_i == name.len) break;
|
||||
if (line[line_i] != name[line_i]) break;
|
||||
}
|
||||
if ((line_i != name.len) or (line[line_i] != '=')) continue;
|
||||
|
||||
return std.mem.sliceTo(line + line_i + 1, 0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -11,7 +11,7 @@ pub const errors = @import("error_set.zig");
|
||||
pub const lib_vulkan = @import("lib_vulkan.zig");
|
||||
pub const logger = @import("logger.zig");
|
||||
pub const format = @import("format.zig");
|
||||
pub const env = @import("environment.zig");
|
||||
pub const config = @import("config");
|
||||
|
||||
pub const Dispatchable = @import("Dispatchable.zig").Dispatchable;
|
||||
pub const NonDispatchable = @import("NonDispatchable.zig").NonDispatchable;
|
||||
|
||||
@@ -14,14 +14,14 @@ comptime {
|
||||
var mutex: std.Io.Mutex = .init;
|
||||
|
||||
pub inline fn fixme(comptime format: []const u8, args: anytype) void {
|
||||
if (!lib.env.hasEnvVar("STROLL_DEBUG_LOGS")) {
|
||||
if (!lib.config.logs) {
|
||||
return;
|
||||
}
|
||||
std.log.scoped(.FIXME).warn("FIXME: " ++ format, args);
|
||||
}
|
||||
|
||||
pub fn log(comptime level: std.log.Level, comptime scope: @EnumLiteral(), comptime format: []const u8, args: anytype) void {
|
||||
if (!lib.env.hasEnvVar("STROLL_DEBUG_LOGS")) {
|
||||
if (!lib.config.logs) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user