adding Descriptors fundamental implementation

This commit is contained in:
2025-11-27 23:42:05 +01:00
parent a3df2cadd2
commit 7a94396abe
10 changed files with 244 additions and 57 deletions

38
src/soft/SoftDescriptorPool.zig git.filemode.normal_file
View File

@@ -0,0 +1,38 @@
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.DescriptorPool;
interface: Interface,
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;
errdefer allocator.destroy(self);
var interface = try Interface.init(device, allocator, info);
interface.vtable = &.{
.destroy = destroy,
.freeDescriptorSets = freeDescriptorSets,
};
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);
}
pub fn freeDescriptorSets(interface: *Interface, sets: []*base.Dispatchable(base.DescriptorSet)) VkError!void {
_ = interface;
_ = sets;
}

32
src/soft/SoftDescriptorSetLayout.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.DescriptorSetLayout;
interface: Interface,
pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const vk.DescriptorSetLayoutCreateInfo) 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

@@ -10,6 +10,8 @@ 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");
@@ -40,6 +42,8 @@ pub fn create(physical_device: *base.PhysicalDevice, allocator: std.mem.Allocato
.allocateMemory = allocateMemory,
.createBuffer = createBuffer,
.createCommandPool = createCommandPool,
.createDescriptorPool = createDescriptorPool,
.createDescriptorSetLayout = createDescriptorSetLayout,
.createFence = createFence,
.createImage = createImage,
.createImageView = createImageView,
@@ -86,6 +90,16 @@ pub fn createBuffer(interface: *Interface, allocator: std.mem.Allocator, info: *
return &buffer.interface;
}
pub fn createDescriptorPool(interface: *Interface, allocator: std.mem.Allocator, info: *const vk.DescriptorPoolCreateInfo) VkError!*base.DescriptorPool {
const pool = try SoftDescriptorPool.create(interface, allocator, info);
return &pool.interface;
}
pub fn createDescriptorSetLayout(interface: *Interface, allocator: std.mem.Allocator, info: *const vk.DescriptorSetLayoutCreateInfo) VkError!*base.DescriptorSetLayout {
const layout = try SoftDescriptorSetLayout.create(interface, allocator, info);
return &layout.interface;
}
pub fn createFence(interface: *Interface, allocator: std.mem.Allocator, info: *const vk.FenceCreateInfo) VkError!*base.Fence {
const fence = try SoftFence.create(interface, allocator, info);
return &fence.interface;

View File

@@ -13,6 +13,8 @@ pub const SoftBuffer = @import("SoftBuffer.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 SoftFence = @import("SoftFence.zig");
pub const SoftImage = @import("SoftImage.zig");
pub const SoftImageView = @import("SoftImageView.zig");