adding all base handles

This commit is contained in:
2025-11-30 21:43:19 +01:00
parent 71f2b9171b
commit ff1317d412
29 changed files with 1143 additions and 219 deletions

32
src/soft/SoftBinarySemaphore.zig git.filemode.normal_file
View File

@@ -0,0 +1,32 @@
const std = @import("std");
const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.BinarySemaphore;
interface: Interface,
pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const vk.SemaphoreCreateInfo) VkError!*Self {
const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
errdefer allocator.destroy(self);
var interface = try Interface.init(device, allocator, info);
interface.vtable = &.{
.destroy = destroy,
};
self.* = .{
.interface = interface,
};
return self;
}
pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
allocator.destroy(self);
}

32
src/soft/SoftBufferView.zig git.filemode.normal_file
View File

@@ -0,0 +1,32 @@
const std = @import("std");
const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.BufferView;
interface: Interface,
pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const vk.BufferViewCreateInfo) VkError!*Self {
const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
errdefer allocator.destroy(self);
var interface = try Interface.init(device, allocator, info);
interface.vtable = &.{
.destroy = destroy,
};
self.* = .{
.interface = interface,
};
return self;
}
pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
allocator.destroy(self);
}

View File

@@ -5,16 +5,28 @@ const builtin = @import("builtin");
const Debug = std.builtin.OptimizeMode.Debug;
const SoftCommandPool = @import("SoftCommandPool.zig");
const SoftQueue = @import("SoftQueue.zig");
const SoftBuffer = @import("SoftBuffer.zig");
const SoftDeviceMemory = @import("SoftDeviceMemory.zig");
const SoftDescriptorPool = @import("SoftDescriptorPool.zig");
const SoftDescriptorSetLayout = @import("SoftDescriptorSetLayout.zig");
const SoftFence = @import("SoftFence.zig");
const SoftImage = @import("SoftImage.zig");
const SoftImageView = @import("SoftImageView.zig");
pub const SoftBinarySemaphore = @import("SoftBinarySemaphore.zig");
pub const SoftBuffer = @import("SoftBuffer.zig");
pub const SoftBufferView = @import("SoftBufferView.zig");
pub const SoftCommandBuffer = @import("SoftCommandBuffer.zig");
pub const SoftCommandPool = @import("SoftCommandPool.zig");
pub const SoftDescriptorPool = @import("SoftDescriptorPool.zig");
pub const SoftDescriptorSetLayout = @import("SoftDescriptorSetLayout.zig");
pub const SoftDeviceMemory = @import("SoftDeviceMemory.zig");
pub const SoftEvent = @import("SoftEvent.zig");
pub const SoftFence = @import("SoftFence.zig");
pub const SoftFramebuffer = @import("SoftFramebuffer.zig");
pub const SoftImage = @import("SoftImage.zig");
pub const SoftImageView = @import("SoftImageView.zig");
pub const SoftPipeline = @import("SoftPipeline.zig");
pub const SoftPipelineCache = @import("SoftPipelineCache.zig");
pub const SoftPipelineLayout = @import("SoftPipelineLayout.zig");
pub const SoftQueryPool = @import("SoftQueryPool.zig");
pub const SoftRenderPass = @import("SoftRenderPass.zig");
pub const SoftSampler = @import("SoftSampler.zig");
pub const SoftShaderModule = @import("SoftShaderModule.zig");
const VkError = base.VkError;
@@ -41,12 +53,24 @@ pub fn create(physical_device: *base.PhysicalDevice, allocator: std.mem.Allocato
interface.dispatch_table = &.{
.allocateMemory = allocateMemory,
.createBuffer = createBuffer,
.createBufferView = createBufferView,
.createCommandPool = createCommandPool,
.createComputePipeline = createComputePipeline,
.createDescriptorPool = createDescriptorPool,
.createDescriptorSetLayout = createDescriptorSetLayout,
.createEvent = createEvent,
.createFence = createFence,
.createFramebuffer = createFramebuffer,
.createGraphicsPipeline = createGraphicsPipeline,
.createImage = createImage,
.createImageView = createImageView,
.createPipelineCache = createPipelineCache,
.createPipelineLayout = createPipelineLayout,
.createQueryPool = createQueryPool,
.createRenderPass = createRenderPass,
.createSampler = createSampler,
.createSemaphore = createSemaphore,
.createShaderModule = createShaderModule,
.destroy = destroy,
};
@@ -116,6 +140,66 @@ pub fn createImage(interface: *Interface, allocator: std.mem.Allocator, info: *c
}
pub fn createImageView(interface: *Interface, allocator: std.mem.Allocator, info: *const vk.ImageViewCreateInfo) VkError!*base.ImageView {
const image_view = try SoftImageView.create(interface, allocator, info);
return &image_view.interface;
const view = try SoftImageView.create(interface, allocator, info);
return &view.interface;
}
pub fn createBufferView(interface: *Interface, allocator: std.mem.Allocator, info: *const vk.BufferViewCreateInfo) VkError!*base.BufferView {
const view = try SoftBufferView.create(interface, allocator, info);
return &view.interface;
}
pub fn createComputePipeline(interface: *Interface, allocator: std.mem.Allocator, cache: ?*base.PipelineCache, info: *const vk.ComputePipelineCreateInfo) VkError!*base.Pipeline {
const pipeline = try SoftPipeline.createCompute(interface, allocator, cache, info);
return &pipeline.interface;
}
pub fn createEvent(interface: *Interface, allocator: std.mem.Allocator, info: *const vk.EventCreateInfo) VkError!*base.Event {
const event = try SoftEvent.create(interface, allocator, info);
return &event.interface;
}
pub fn createFramebuffer(interface: *Interface, allocator: std.mem.Allocator, info: *const vk.FramebufferCreateInfo) VkError!*base.Framebuffer {
const framebuffer = try SoftFramebuffer.create(interface, allocator, info);
return &framebuffer.interface;
}
pub fn createGraphicsPipeline(interface: *Interface, allocator: std.mem.Allocator, cache: ?*base.PipelineCache, info: *const vk.GraphicsPipelineCreateInfo) VkError!*base.Pipeline {
const pipeline = try SoftPipeline.createGraphics(interface, allocator, cache, info);
return &pipeline.interface;
}
pub fn createPipelineCache(interface: *Interface, allocator: std.mem.Allocator, info: *const vk.PipelineCacheCreateInfo) VkError!*base.PipelineCache {
const cache = try SoftPipelineCache.create(interface, allocator, info);
return &cache.interface;
}
pub fn createPipelineLayout(interface: *Interface, allocator: std.mem.Allocator, info: *const vk.PipelineLayoutCreateInfo) VkError!*base.PipelineLayout {
const layout = try SoftPipelineLayout.create(interface, allocator, info);
return &layout.interface;
}
pub fn createQueryPool(interface: *Interface, allocator: std.mem.Allocator, info: *const vk.QueryPoolCreateInfo) VkError!*base.QueryPool {
const pool = try SoftQueryPool.create(interface, allocator, info);
return &pool.interface;
}
pub fn createRenderPass(interface: *Interface, allocator: std.mem.Allocator, info: *const vk.RenderPassCreateInfo) VkError!*base.RenderPass {
const pass = try SoftRenderPass.create(interface, allocator, info);
return &pass.interface;
}
pub fn createSampler(interface: *Interface, allocator: std.mem.Allocator, info: *const vk.SamplerCreateInfo) VkError!*base.Sampler {
const sampler = try SoftSampler.create(interface, allocator, info);
return &sampler.interface;
}
pub fn createSemaphore(interface: *Interface, allocator: std.mem.Allocator, info: *const vk.SemaphoreCreateInfo) VkError!*base.BinarySemaphore {
const semaphore = try SoftBinarySemaphore.create(interface, allocator, info);
return &semaphore.interface;
}
pub fn createShaderModule(interface: *Interface, allocator: std.mem.Allocator, info: *const vk.ShaderModuleCreateInfo) VkError!*base.ShaderModule {
const module = try SoftShaderModule.create(interface, allocator, info);
return &module.interface;
}

32
src/soft/SoftEvent.zig git.filemode.normal_file
View File

@@ -0,0 +1,32 @@
const std = @import("std");
const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.Event;
interface: Interface,
pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const vk.EventCreateInfo) VkError!*Self {
const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
errdefer allocator.destroy(self);
var interface = try Interface.init(device, allocator, info);
interface.vtable = &.{
.destroy = destroy,
};
self.* = .{
.interface = interface,
};
return self;
}
pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
allocator.destroy(self);
}

32
src/soft/SoftFramebuffer.zig git.filemode.normal_file
View File

@@ -0,0 +1,32 @@
const std = @import("std");
const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.Framebuffer;
interface: Interface,
pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const vk.FramebufferCreateInfo) VkError!*Self {
const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
errdefer allocator.destroy(self);
var interface = try Interface.init(device, allocator, info);
interface.vtable = &.{
.destroy = destroy,
};
self.* = .{
.interface = interface,
};
return self;
}
pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
allocator.destroy(self);
}

48
src/soft/SoftPipeline.zig git.filemode.normal_file
View File

@@ -0,0 +1,48 @@
const std = @import("std");
const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.Pipeline;
interface: Interface,
pub fn createCompute(device: *base.Device, allocator: std.mem.Allocator, cache: ?*base.PipelineCache, info: *const vk.ComputePipelineCreateInfo) VkError!*Self {
const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
errdefer allocator.destroy(self);
var interface = try Interface.initCompute(device, allocator, cache, info);
interface.vtable = &.{
.destroy = destroy,
};
self.* = .{
.interface = interface,
};
return self;
}
pub fn createGraphics(device: *base.Device, allocator: std.mem.Allocator, cache: ?*base.PipelineCache, info: *const vk.GraphicsPipelineCreateInfo) VkError!*Self {
const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
errdefer allocator.destroy(self);
var interface = try Interface.initGraphics(device, allocator, cache, info);
interface.vtable = &.{
.destroy = destroy,
};
self.* = .{
.interface = interface,
};
return self;
}
pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
allocator.destroy(self);
}

32
src/soft/SoftPipelineCache.zig git.filemode.normal_file
View File

@@ -0,0 +1,32 @@
const std = @import("std");
const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.PipelineCache;
interface: Interface,
pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const vk.PipelineCacheCreateInfo) VkError!*Self {
const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
errdefer allocator.destroy(self);
var interface = try Interface.init(device, allocator, info);
interface.vtable = &.{
.destroy = destroy,
};
self.* = .{
.interface = interface,
};
return self;
}
pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
allocator.destroy(self);
}

32
src/soft/SoftPipelineLayout.zig git.filemode.normal_file
View File

@@ -0,0 +1,32 @@
const std = @import("std");
const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.PipelineLayout;
interface: Interface,
pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const vk.PipelineLayoutCreateInfo) VkError!*Self {
const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
errdefer allocator.destroy(self);
var interface = try Interface.init(device, allocator, info);
interface.vtable = &.{
.destroy = destroy,
};
self.* = .{
.interface = interface,
};
return self;
}
pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
allocator.destroy(self);
}

32
src/soft/SoftQueryPool.zig git.filemode.normal_file
View File

@@ -0,0 +1,32 @@
const std = @import("std");
const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.QueryPool;
interface: Interface,
pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const vk.QueryPoolCreateInfo) VkError!*Self {
const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
errdefer allocator.destroy(self);
var interface = try Interface.init(device, allocator, info);
interface.vtable = &.{
.destroy = destroy,
};
self.* = .{
.interface = interface,
};
return self;
}
pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
allocator.destroy(self);
}

View File

@@ -73,7 +73,8 @@ pub fn submit(interface: *Interface, infos: []Interface.SubmitInfo, p_fence: ?*b
pub fn waitIdle(interface: *Interface) VkError!void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
self.wait_group.wait();
if (!self.wait_group.isDone())
self.wait_group.wait();
}
fn taskRunner(self: *Self, info: Interface.SubmitInfo, p_fence: ?*base.Fence) void {

32
src/soft/SoftRenderPass.zig git.filemode.normal_file
View File

@@ -0,0 +1,32 @@
const std = @import("std");
const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.RenderPass;
interface: Interface,
pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const vk.RenderPassCreateInfo) VkError!*Self {
const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
errdefer allocator.destroy(self);
var interface = try Interface.init(device, allocator, info);
interface.vtable = &.{
.destroy = destroy,
};
self.* = .{
.interface = interface,
};
return self;
}
pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
allocator.destroy(self);
}

32
src/soft/SoftSampler.zig git.filemode.normal_file
View File

@@ -0,0 +1,32 @@
const std = @import("std");
const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.Sampler;
interface: Interface,
pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const vk.SamplerCreateInfo) VkError!*Self {
const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
errdefer allocator.destroy(self);
var interface = try Interface.init(device, allocator, info);
interface.vtable = &.{
.destroy = destroy,
};
self.* = .{
.interface = interface,
};
return self;
}
pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
allocator.destroy(self);
}

32
src/soft/SoftShaderModule.zig git.filemode.normal_file
View File

@@ -0,0 +1,32 @@
const std = @import("std");
const vk = @import("vulkan");
const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Self = @This();
pub const Interface = base.ShaderModule;
interface: Interface,
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;
errdefer allocator.destroy(self);
var interface = try Interface.init(device, allocator, info);
interface.vtable = &.{
.destroy = destroy,
};
self.* = .{
.interface = interface,
};
return self;
}
pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
allocator.destroy(self);
}

View File

@@ -9,15 +9,26 @@ pub const SoftDevice = @import("SoftDevice.zig");
pub const SoftPhysicalDevice = @import("SoftPhysicalDevice.zig");
pub const SoftQueue = @import("SoftQueue.zig");
pub const SoftBinarySemaphore = @import("SoftBinarySemaphore.zig");
pub const SoftBuffer = @import("SoftBuffer.zig");
pub const SoftBufferView = @import("SoftBufferView.zig");
pub const SoftCommandBuffer = @import("SoftCommandBuffer.zig");
pub const SoftCommandPool = @import("SoftCommandPool.zig");
pub const SoftDeviceMemory = @import("SoftDeviceMemory.zig");
pub const SoftDescriptorPool = @import("SoftDescriptorPool.zig");
pub const SoftDescriptorSetLayout = @import("SoftDescriptorSetLayout.zig");
pub const SoftDeviceMemory = @import("SoftDeviceMemory.zig");
pub const SoftEvent = @import("SoftEvent.zig");
pub const SoftFence = @import("SoftFence.zig");
pub const SoftFramebuffer = @import("SoftFramebuffer.zig");
pub const SoftImage = @import("SoftImage.zig");
pub const SoftImageView = @import("SoftImageView.zig");
pub const SoftPipeline = @import("SoftPipeline.zig");
pub const SoftPipelineCache = @import("SoftPipelineCache.zig");
pub const SoftPipelineLayout = @import("SoftPipelineLayout.zig");
pub const SoftQueryPool = @import("SoftQueryPool.zig");
pub const SoftRenderPass = @import("SoftRenderPass.zig");
pub const SoftSampler = @import("SoftSampler.zig");
pub const SoftShaderModule = @import("SoftShaderModule.zig");
pub const Instance = SoftInstance;
@@ -50,17 +61,30 @@ comptime {
}
test {
std.testing.refAllDecls(base);
std.testing.refAllDecls(SoftInstance);
std.testing.refAllDecls(SoftDevice);
std.testing.refAllDecls(SoftPhysicalDevice);
std.testing.refAllDecls(SoftQueue);
std.testing.refAllDecls(Executor);
std.testing.refAllDecls(SoftBinarySemaphore);
std.testing.refAllDecls(SoftBuffer);
std.testing.refAllDecls(SoftBufferView);
std.testing.refAllDecls(SoftCommandBuffer);
std.testing.refAllDecls(SoftCommandPool);
std.testing.refAllDecls(SoftDescriptorPool);
std.testing.refAllDecls(SoftDescriptorSetLayout);
std.testing.refAllDecls(SoftDevice);
std.testing.refAllDecls(SoftDeviceMemory);
std.testing.refAllDecls(SoftEvent);
std.testing.refAllDecls(SoftFence);
std.testing.refAllDecls(SoftFramebuffer);
std.testing.refAllDecls(SoftImage);
std.testing.refAllDecls(SoftImageView);
std.testing.refAllDecls(Executor);
std.testing.refAllDecls(SoftInstance);
std.testing.refAllDecls(SoftPhysicalDevice);
std.testing.refAllDecls(SoftPipeline);
std.testing.refAllDecls(SoftPipelineCache);
std.testing.refAllDecls(SoftPipelineLayout);
std.testing.refAllDecls(SoftQueryPool);
std.testing.refAllDecls(SoftQueue);
std.testing.refAllDecls(SoftRenderPass);
std.testing.refAllDecls(SoftSampler);
std.testing.refAllDecls(SoftShaderModule);
std.testing.refAllDecls(base);
}