adding descriptor bindings
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const std = @import("std");
|
||||
const vk = @import("vulkan");
|
||||
const lib = @import("lib.zig");
|
||||
|
||||
const cmd = @import("commands.zig");
|
||||
|
||||
@@ -14,6 +15,7 @@ const CommandPool = @import("CommandPool.zig");
|
||||
const Event = @import("Event.zig");
|
||||
const Image = @import("Image.zig");
|
||||
const Pipeline = @import("Pipeline.zig");
|
||||
const DescriptorSet = @import("DescriptorSet.zig");
|
||||
|
||||
const COMMAND_BUFFER_BASE_CAPACITY = 256;
|
||||
|
||||
@@ -40,6 +42,7 @@ vtable: *const VTable,
|
||||
dispatch_table: *const DispatchTable,
|
||||
|
||||
pub const DispatchTable = struct {
|
||||
bindDescriptorSets: *const fn (*Self, vk.PipelineBindPoint, u32, [lib.VULKAN_MAX_DESCRIPTOR_SETS]?*DescriptorSet, []const u32) VkError!void,
|
||||
bindPipeline: *const fn (*Self, vk.PipelineBindPoint, *Pipeline) VkError!void,
|
||||
begin: *const fn (*Self, *const vk.CommandBufferBeginInfo) VkError!void,
|
||||
clearColorImage: *const fn (*Self, *Image, vk.ImageLayout, *const vk.ClearColorValue, vk.ImageSubresourceRange) VkError!void,
|
||||
@@ -135,6 +138,23 @@ fn cleanCommandList(self: *Self) void {
|
||||
|
||||
// Commands ====================================================================================================
|
||||
|
||||
pub inline fn bindDescriptorSets(self: *Self, bind_point: vk.PipelineBindPoint, first_set: u32, sets: []const vk.DescriptorSet, dynamic_offsets: []const u32) VkError!void {
|
||||
const allocator = self.host_allocator.allocator();
|
||||
|
||||
var inner_sets = [_]?*DescriptorSet{null} ** lib.VULKAN_MAX_DESCRIPTOR_SETS;
|
||||
for (sets, inner_sets[0..sets.len]) |set, *inner_set| {
|
||||
inner_set.* = try NonDispatchable(DescriptorSet).fromHandleObject(set);
|
||||
}
|
||||
|
||||
try self.dispatch_table.bindDescriptorSets(self, bind_point, first_set, inner_sets, dynamic_offsets);
|
||||
self.commands.append(allocator, .{ .BindDescriptorSets = .{
|
||||
.bind_point = bind_point,
|
||||
.first_set = first_set,
|
||||
.sets = inner_sets,
|
||||
.dynamic_offsets = dynamic_offsets,
|
||||
} }) catch return VkError.OutOfHostMemory;
|
||||
}
|
||||
|
||||
pub inline fn bindPipeline(self: *Self, bind_point: vk.PipelineBindPoint, pipeline: *Pipeline) VkError!void {
|
||||
const allocator = self.host_allocator.allocator();
|
||||
try self.dispatch_table.bindPipeline(self, bind_point, pipeline);
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
const std = @import("std");
|
||||
const vk = @import("vulkan");
|
||||
const lib = @import("lib.zig");
|
||||
|
||||
const Buffer = @import("Buffer.zig");
|
||||
const Image = @import("Image.zig");
|
||||
const Pipeline = @import("Pipeline.zig");
|
||||
const DescriptorSet = @import("DescriptorSet.zig");
|
||||
|
||||
pub const CommandType = enum {
|
||||
BindPipeline,
|
||||
BindVertexBuffer,
|
||||
ClearColorImage,
|
||||
CopyBuffer,
|
||||
CopyImage,
|
||||
CopyImageToBuffer,
|
||||
Draw,
|
||||
DrawIndexed,
|
||||
DrawIndexedIndirect,
|
||||
DrawIndirect,
|
||||
FillBuffer,
|
||||
pub const CommandBindDescriptorSets = struct {
|
||||
bind_point: vk.PipelineBindPoint,
|
||||
first_set: u32,
|
||||
sets: [lib.VULKAN_MAX_DESCRIPTOR_SETS]?*DescriptorSet,
|
||||
dynamic_offsets: []const u32,
|
||||
};
|
||||
|
||||
pub const CommandBindPipeline = struct {
|
||||
bind_point: vk.PipelineBindPoint,
|
||||
pipeline: *Pipeline,
|
||||
@@ -84,7 +78,8 @@ pub const CommandFillBuffer = struct {
|
||||
data: u32,
|
||||
};
|
||||
|
||||
pub const Command = union(CommandType) {
|
||||
pub const Command = union(enum) {
|
||||
BindDescriptorSets: CommandBindDescriptorSets,
|
||||
BindPipeline: CommandBindPipeline,
|
||||
BindVertexBuffer: CommandBindVertexBuffer,
|
||||
ClearColorImage: CommandClearColorImage,
|
||||
|
||||
@@ -56,7 +56,7 @@ pub const DRIVER_NAME = "Unnamed Stroll Driver";
|
||||
pub const VULKAN_VERSION = vk.makeApiVersion(0, 1, 0, 0);
|
||||
|
||||
/// Maximum number of descriptor sets per pipeline
|
||||
pub const VULKAN_MAX_DESCRIPTOR_SETS = 32;
|
||||
pub const VULKAN_MAX_DESCRIPTOR_SETS = 4;
|
||||
|
||||
/// The number of push constant ranges is effectively bounded
|
||||
/// by the number of possible shader stages. Not the number of stages that can
|
||||
|
||||
@@ -1674,17 +1674,9 @@ pub export fn strollCmdBindDescriptorSets(
|
||||
defer entryPointEndLogTrace();
|
||||
|
||||
const cmd = Dispatchable(CommandBuffer).fromHandleObject(p_cmd) catch |err| return errorLogger(err);
|
||||
cmd.bindDescriptorSets(bind_point, first, sets[0..count], dynamic_offsets[0..dynamic_offset_count]) catch |err| return errorLogger(err);
|
||||
|
||||
notImplementedWarning();
|
||||
|
||||
_ = cmd;
|
||||
_ = bind_point;
|
||||
_ = layout;
|
||||
_ = first;
|
||||
_ = count;
|
||||
_ = sets;
|
||||
_ = dynamic_offsets;
|
||||
_ = dynamic_offset_count;
|
||||
}
|
||||
|
||||
pub export fn strollCmdBindIndexBuffer(p_cmd: vk.CommandBuffer, p_buffer: vk.Buffer, offset: vk.DeviceSize, index_type: vk.IndexType) callconv(vk.vulkan_call_conv) void {
|
||||
|
||||
Reference in New Issue
Block a user