adding base spv interpreter
This commit is contained in:
@@ -130,6 +130,13 @@ 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.addSystemIncludePath(cpuinfo.path("include"));
|
||||||
lib.linkLibrary(cpuinfo.artifact("cpuinfo"));
|
lib.linkLibrary(cpuinfo.artifact("cpuinfo"));
|
||||||
|
|
||||||
|
const spv = b.dependency("SPIRV_Interpreter", .{
|
||||||
|
.@"no-example" = true,
|
||||||
|
.@"no-test" = true,
|
||||||
|
.@"use-llvm" = true,
|
||||||
|
}).module("spv");
|
||||||
|
lib.root_module.addImport("spv", spv);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn addCTest(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, vulkan_headers: *std.Build.Dependency, impl: *const ImplementationDesc, impl_lib: *std.Build.Step.Compile) !*std.Build.Step.Compile {
|
fn addCTest(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, vulkan_headers: *std.Build.Dependency, impl: *const ImplementationDesc, impl_lib: *std.Build.Step.Compile) !*std.Build.Step.Compile {
|
||||||
|
|||||||
@@ -33,6 +33,10 @@
|
|||||||
.url = "https://github.com/Aandreba/zigrc/archive/refs/tags/1.1.0.tar.gz",
|
.url = "https://github.com/Aandreba/zigrc/archive/refs/tags/1.1.0.tar.gz",
|
||||||
.hash = "zigrc-1.0.0-lENlWzvQAACulrbkL9PVhWjFsWSkYhi7AmfSbCM-2Xlh",
|
.hash = "zigrc-1.0.0-lENlWzvQAACulrbkL9PVhWjFsWSkYhi7AmfSbCM-2Xlh",
|
||||||
},
|
},
|
||||||
|
.SPIRV_Interpreter = .{
|
||||||
|
.url = "git+https://git.kbz8.me/kbz_8/SPIRV-Interpreter#e21d26d9975b96a222b70648ceeea9e473e9657f",
|
||||||
|
.hash = "SPIRV_Interpreter-0.0.1-ajmpn2tAAwCBI0oWa3VKlYX3MEM0OxN4iXQ-PwO6_Vhx",
|
||||||
|
},
|
||||||
.cpuinfo = .{
|
.cpuinfo = .{
|
||||||
.url = "git+https://github.com/Kbz-8/cpuinfo#4883954cfcec3f6c9ca9c4aaddfc26107e08726f",
|
.url = "git+https://github.com/Kbz-8/cpuinfo#4883954cfcec3f6c9ca9c4aaddfc26107e08726f",
|
||||||
.hash = "cpuinfo-0.0.1-RLgIQTLRMgF4dLo8AJ-HvnpFsJe6jmXCJjMWWjil6RF1",
|
.hash = "cpuinfo-0.0.1-RLgIQTLRMgF4dLo8AJ-HvnpFsJe6jmXCJjMWWjil6RF1",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const vk = @import("vulkan");
|
const vk = @import("vulkan");
|
||||||
const base = @import("base");
|
const base = @import("base");
|
||||||
|
const spv = @import("spv");
|
||||||
|
|
||||||
const VkError = base.VkError;
|
const VkError = base.VkError;
|
||||||
const Device = base.Device;
|
const Device = base.Device;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const vk = @import("vulkan");
|
const vk = @import("vulkan");
|
||||||
const base = @import("base");
|
const base = @import("base");
|
||||||
|
const spv = @import("spv");
|
||||||
|
const lib = @import("lib.zig");
|
||||||
|
|
||||||
const VkError = base.VkError;
|
const VkError = base.VkError;
|
||||||
const Device = base.Device;
|
const Device = base.Device;
|
||||||
@@ -9,6 +11,7 @@ const Self = @This();
|
|||||||
pub const Interface = base.ShaderModule;
|
pub const Interface = base.ShaderModule;
|
||||||
|
|
||||||
interface: Interface,
|
interface: Interface,
|
||||||
|
module: spv.Module,
|
||||||
|
|
||||||
pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const vk.ShaderModuleCreateInfo) VkError!*Self {
|
pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const vk.ShaderModuleCreateInfo) VkError!*Self {
|
||||||
const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
|
const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
|
||||||
@@ -22,11 +25,22 @@ pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const v
|
|||||||
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.interface = interface,
|
.interface = interface,
|
||||||
|
.module = spv.Module.init(
|
||||||
|
allocator,
|
||||||
|
info.p_code[0..@divExact(info.code_size, 4)],
|
||||||
|
.{
|
||||||
|
.use_simd_vectors_specializations = !std.process.hasEnvVarConstant(lib.NO_SHADER_SIMD_ENV_NAME),
|
||||||
|
},
|
||||||
|
) catch |err| switch (err) {
|
||||||
|
spv.Module.ModuleError.OutOfMemory => return VkError.OutOfHostMemory,
|
||||||
|
else => return VkError.ValidationFailed,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
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.module.deinit(allocator);
|
||||||
allocator.destroy(self);
|
allocator.destroy(self);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ pub const VULKAN_VERSION = vk.makeApiVersion(0, 1, 0, 0);
|
|||||||
pub const DRIVER_VERSION = vk.makeApiVersion(0, 0, 0, 1);
|
pub const DRIVER_VERSION = vk.makeApiVersion(0, 0, 0, 1);
|
||||||
pub const DEVICE_ID = 0x600DCAFE;
|
pub const DEVICE_ID = 0x600DCAFE;
|
||||||
|
|
||||||
|
pub const NO_SHADER_SIMD_ENV_NAME = "STROLL_SOFT_NO_SIMD";
|
||||||
|
|
||||||
/// Generic system memory.
|
/// Generic system memory.
|
||||||
pub const MEMORY_TYPE_GENERIC_BIT = 0;
|
pub const MEMORY_TYPE_GENERIC_BIT = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ pub const ObjectType: vk.ObjectType = .pipeline;
|
|||||||
owner: *Device,
|
owner: *Device,
|
||||||
|
|
||||||
vtable: *const VTable,
|
vtable: *const VTable,
|
||||||
|
bind_point: vk.PipelineBindPoint,
|
||||||
|
stages: vk.ShaderStageFlags,
|
||||||
|
|
||||||
pub const VTable = struct {
|
pub const VTable = struct {
|
||||||
destroy: *const fn (*Self, std.mem.Allocator) void,
|
destroy: *const fn (*Self, std.mem.Allocator) void,
|
||||||
@@ -22,20 +24,34 @@ pub const VTable = struct {
|
|||||||
pub fn initCompute(device: *Device, allocator: std.mem.Allocator, cache: ?*PipelineCache, info: *const vk.ComputePipelineCreateInfo) VkError!Self {
|
pub fn initCompute(device: *Device, allocator: std.mem.Allocator, cache: ?*PipelineCache, info: *const vk.ComputePipelineCreateInfo) VkError!Self {
|
||||||
_ = allocator;
|
_ = allocator;
|
||||||
_ = cache;
|
_ = cache;
|
||||||
_ = info;
|
|
||||||
|
var stages: vk.ShaderStageFlags = .{};
|
||||||
|
for (info.p_stages[0..info.stage_count]) |stage| {
|
||||||
|
stages = stages.merge(stage orelse continue);
|
||||||
|
}
|
||||||
|
|
||||||
return .{
|
return .{
|
||||||
.owner = device,
|
.owner = device,
|
||||||
.vtable = undefined,
|
.vtable = undefined,
|
||||||
|
.bind_point = .compute,
|
||||||
|
.stages = stages,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn initGraphics(device: *Device, allocator: std.mem.Allocator, cache: ?*PipelineCache, info: *const vk.GraphicsPipelineCreateInfo) VkError!Self {
|
pub fn initGraphics(device: *Device, allocator: std.mem.Allocator, cache: ?*PipelineCache, info: *const vk.GraphicsPipelineCreateInfo) VkError!Self {
|
||||||
_ = allocator;
|
_ = allocator;
|
||||||
_ = cache;
|
_ = cache;
|
||||||
_ = info;
|
|
||||||
|
var stages: vk.ShaderStageFlags = .{};
|
||||||
|
for (info.p_stages[0..info.stage_count]) |stage| {
|
||||||
|
stages = stages.merge(stage orelse continue);
|
||||||
|
}
|
||||||
|
|
||||||
return .{
|
return .{
|
||||||
.owner = device,
|
.owner = device,
|
||||||
.vtable = undefined,
|
.vtable = undefined,
|
||||||
|
.bind_point = .graphics,
|
||||||
|
.stages = stages,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ pub const DRIVER_DEBUG_ALLOCATOR_ENV_NAME = "STROLL_DEBUG_ALLOCATOR";
|
|||||||
pub const DRIVER_LOGS_ENV_NAME = "STROLL_LOGS_LEVEL";
|
pub const DRIVER_LOGS_ENV_NAME = "STROLL_LOGS_LEVEL";
|
||||||
|
|
||||||
/// Default driver name
|
/// Default driver name
|
||||||
pub const DRIVER_NAME = "Unnamed Driver";
|
pub const DRIVER_NAME = "Unnamed Stroll Driver";
|
||||||
/// Default Vulkan version
|
/// Default Vulkan version
|
||||||
pub const VULKAN_VERSION = vk.makeApiVersion(0, 1, 0, 0);
|
pub const VULKAN_VERSION = vk.makeApiVersion(0, 1, 0, 0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user