adding base descriptors
This commit is contained in:
30
src/vulkan/DescriptorPool.zig
git.filemode.normal_file
30
src/vulkan/DescriptorPool.zig
git.filemode.normal_file
@@ -0,0 +1,30 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
const vk = @import("vulkan");
|
||||||
|
|
||||||
|
const VkError = @import("error_set.zig").VkError;
|
||||||
|
|
||||||
|
const Device = @import("Device.zig");
|
||||||
|
|
||||||
|
const Self = @This();
|
||||||
|
pub const ObjectType: vk.ObjectType = .descriptor_pool;
|
||||||
|
|
||||||
|
owner: *Device,
|
||||||
|
flags: vk.DescriptorPoolCreateFlags,
|
||||||
|
|
||||||
|
vtable: *const VTable,
|
||||||
|
|
||||||
|
pub const VTable = struct {
|
||||||
|
destroy: *const fn (*Self, std.mem.Allocator) void,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.DescriptorPoolCreateInfo) VkError!Self {
|
||||||
|
_ = allocator;
|
||||||
|
return .{
|
||||||
|
.owner = device,
|
||||||
|
.flags = info.flags,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn destroy(self: *Self, allocator: std.mem.Allocator) void {
|
||||||
|
self.vtable.destroy(self, allocator);
|
||||||
|
}
|
||||||
41
src/vulkan/DescriptorSet.zig
git.filemode.normal_file
41
src/vulkan/DescriptorSet.zig
git.filemode.normal_file
@@ -0,0 +1,41 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
const vk = @import("vulkan");
|
||||||
|
|
||||||
|
const NonDispatchable = @import("NonDispatchable.zig");
|
||||||
|
|
||||||
|
const VkError = @import("error_set.zig").VkError;
|
||||||
|
|
||||||
|
const Device = @import("Device.zig");
|
||||||
|
|
||||||
|
const DescriptorSetLayout = @import("DescriptorSetLayout.zig");
|
||||||
|
|
||||||
|
const Self = @This();
|
||||||
|
pub const ObjectType: vk.ObjectType = .descriptor_set;
|
||||||
|
|
||||||
|
owner: *Device,
|
||||||
|
layouts: []*const DescriptorSetLayout,
|
||||||
|
|
||||||
|
vtable: *const VTable,
|
||||||
|
|
||||||
|
pub const VTable = struct {
|
||||||
|
destroy: *const fn (*Self, std.mem.Allocator) void,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.DescriptorSetAllocateInfo) VkError!Self {
|
||||||
|
var layouts = allocator.alloc(*DescriptorSetLayout, info.descriptor_set_count) catch return VkError.OutOfHostMemory;
|
||||||
|
errdefer allocator.free(layouts);
|
||||||
|
|
||||||
|
for (info.p_set_layouts, 0..info.descriptor_set_count) |p_set_layout, i| {
|
||||||
|
layouts[i] = try NonDispatchable(DescriptorSetLayout).fromHandleObject(p_set_layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
return .{
|
||||||
|
.owner = device,
|
||||||
|
.layouts = layouts,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn destroy(self: *Self, allocator: std.mem.Allocator) void {
|
||||||
|
allocator.free(self.layouts);
|
||||||
|
self.vtable.destroy(self, allocator);
|
||||||
|
}
|
||||||
28
src/vulkan/DescriptorSetLayout.zig
git.filemode.normal_file
28
src/vulkan/DescriptorSetLayout.zig
git.filemode.normal_file
@@ -0,0 +1,28 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
const vk = @import("vulkan");
|
||||||
|
|
||||||
|
const VkError = @import("error_set.zig").VkError;
|
||||||
|
const Device = @import("Device.zig");
|
||||||
|
|
||||||
|
const Self = @This();
|
||||||
|
pub const ObjectType: vk.ObjectType = .descriptor_set_layout;
|
||||||
|
|
||||||
|
owner: *Device,
|
||||||
|
bindings: []const vk.DescriptorSetLayoutBinding,
|
||||||
|
|
||||||
|
vtable: *const VTable,
|
||||||
|
|
||||||
|
pub const VTable = struct {
|
||||||
|
destroy: *const fn (*Self, std.mem.Allocator) void,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.DescriptorSetLayoutCreateInfo) VkError!Self {
|
||||||
|
return .{
|
||||||
|
.owner = device,
|
||||||
|
.bindings = allocator.dupe(info.bindings[0..info.binding_count]) catch return VkError.OutOfHostMemory,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn destroy(self: *Self, allocator: std.mem.Allocator) void {
|
||||||
|
self.vtable.destroy(self, allocator);
|
||||||
|
}
|
||||||
@@ -24,6 +24,9 @@ pub const Queue = @import("Queue.zig");
|
|||||||
pub const Buffer = @import("Buffer.zig");
|
pub const Buffer = @import("Buffer.zig");
|
||||||
pub const CommandBuffer = @import("CommandBuffer.zig");
|
pub const CommandBuffer = @import("CommandBuffer.zig");
|
||||||
pub const CommandPool = @import("CommandPool.zig");
|
pub const CommandPool = @import("CommandPool.zig");
|
||||||
|
pub const DescriptorPool = @import("DescriptorPool.zig");
|
||||||
|
pub const DescriptorSet = @import("DescriptorSet.zig");
|
||||||
|
pub const DescriptorSetLayout = @import("DescriptorSetLayout.zig");
|
||||||
pub const DeviceMemory = @import("DeviceMemory.zig");
|
pub const DeviceMemory = @import("DeviceMemory.zig");
|
||||||
pub const Fence = @import("Fence.zig");
|
pub const Fence = @import("Fence.zig");
|
||||||
pub const Image = @import("Image.zig");
|
pub const Image = @import("Image.zig");
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ const Buffer = @import("Buffer.zig");
|
|||||||
const CommandBuffer = @import("CommandBuffer.zig");
|
const CommandBuffer = @import("CommandBuffer.zig");
|
||||||
const CommandPool = @import("CommandPool.zig");
|
const CommandPool = @import("CommandPool.zig");
|
||||||
const DeviceMemory = @import("DeviceMemory.zig");
|
const DeviceMemory = @import("DeviceMemory.zig");
|
||||||
|
const DescriptorPool = @import("DescriptorPool.zig");
|
||||||
|
const DescriptorSet = @import("DescriptorSet.zig");
|
||||||
|
const DescriptorSetLayout = @import("DescriptorSetLayout.zig");
|
||||||
const Fence = @import("Fence.zig");
|
const Fence = @import("Fence.zig");
|
||||||
const Image = @import("Image.zig");
|
const Image = @import("Image.zig");
|
||||||
const ImageView = @import("ImageView.zig");
|
const ImageView = @import("ImageView.zig");
|
||||||
|
|||||||
Reference in New Issue
Block a user