Don't use variable descriptor count
This commit is contained in:
@@ -50,7 +50,6 @@ skybox: Skybox,
|
|||||||
player: Player,
|
player: Player,
|
||||||
font: Fonts.Id,
|
font: Fonts.Id,
|
||||||
|
|
||||||
const max_textures = 1024;
|
|
||||||
const max_point_lights = 1024;
|
const max_point_lights = 1024;
|
||||||
const max_directional_lights = 4;
|
const max_directional_lights = 4;
|
||||||
const chunk_descriptor_pool = 1024;
|
const chunk_descriptor_pool = 1024;
|
||||||
@@ -138,9 +137,8 @@ pub fn init() !Game {
|
|||||||
.{
|
.{
|
||||||
.binding = 5,
|
.binding = 5,
|
||||||
.descriptor_type = .sampled_image,
|
.descriptor_type = .sampled_image,
|
||||||
.descriptor_count = max_textures,
|
.descriptor_count = Textures.max_textures,
|
||||||
.stage_flags = .{ .vertex_bit = true, .fragment_bit = true },
|
.stage_flags = .{ .vertex_bit = true, .fragment_bit = true },
|
||||||
.flags = .{ .variable_descriptor_count_bit = true }, // TODO Get rid of this AND somehow integrate with Textures module?
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -418,7 +416,7 @@ pub fn init() !Game {
|
|||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.type = .sampled_image,
|
.type = .sampled_image,
|
||||||
.descriptor_count = max_textures,
|
.descriptor_count = Textures.max_textures,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.type = .uniform_buffer,
|
.type = .uniform_buffer,
|
||||||
@@ -436,7 +434,6 @@ pub fn init() !Game {
|
|||||||
const global_descriptor_set = try engine.allocateDescriptorSet(.{
|
const global_descriptor_set = try engine.allocateDescriptorSet(.{
|
||||||
.descriptor_pool = descriptor_pool,
|
.descriptor_pool = descriptor_pool,
|
||||||
.set_layout = global_descriptor_set_layout,
|
.set_layout = global_descriptor_set_layout,
|
||||||
.variable_descriptor_count = @intCast(textures.array.items.len),
|
|
||||||
});
|
});
|
||||||
engine.setObjectName(global_descriptor_set, "DS Global", .{});
|
engine.setObjectName(global_descriptor_set, "DS Global", .{});
|
||||||
|
|
||||||
|
|||||||
@@ -275,7 +275,6 @@ pub fn init() !*Engine {
|
|||||||
.shader_float_16 = .true,
|
.shader_float_16 = .true,
|
||||||
.descriptor_indexing = .true,
|
.descriptor_indexing = .true,
|
||||||
.descriptor_binding_partially_bound = .true,
|
.descriptor_binding_partially_bound = .true,
|
||||||
.descriptor_binding_variable_descriptor_count = .true,
|
|
||||||
.runtime_descriptor_array = .true,
|
.runtime_descriptor_array = .true,
|
||||||
.scalar_block_layout = .true,
|
.scalar_block_layout = .true,
|
||||||
.imageless_framebuffer = .true,
|
.imageless_framebuffer = .true,
|
||||||
@@ -745,13 +744,11 @@ pub const DescriptorPoolCreateInfo = struct {
|
|||||||
pub const DescriptorSetAllocateInfo = struct {
|
pub const DescriptorSetAllocateInfo = struct {
|
||||||
descriptor_pool: vk.DescriptorPool,
|
descriptor_pool: vk.DescriptorPool,
|
||||||
set_layout: vk.DescriptorSetLayout,
|
set_layout: vk.DescriptorSetLayout,
|
||||||
variable_descriptor_count: ?u32 = null,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const DescriptorSetsAllocateInfo = struct {
|
pub const DescriptorSetsAllocateInfo = struct {
|
||||||
descriptor_pool: vk.DescriptorPool,
|
descriptor_pool: vk.DescriptorPool,
|
||||||
set_layouts: []const vk.DescriptorSetLayout,
|
set_layouts: []const vk.DescriptorSetLayout,
|
||||||
variable_descriptor_counts: []const u32 = &.{},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const DescriptorSetLayoutBinding = struct {
|
pub const DescriptorSetLayoutBinding = struct {
|
||||||
@@ -969,28 +966,13 @@ pub fn allocateDescriptorSet(self: *Engine, allocate_info: DescriptorSetAllocate
|
|||||||
try self.allocateDescriptorSets(.{
|
try self.allocateDescriptorSets(.{
|
||||||
.descriptor_pool = allocate_info.descriptor_pool,
|
.descriptor_pool = allocate_info.descriptor_pool,
|
||||||
.set_layouts = &.{allocate_info.set_layout},
|
.set_layouts = &.{allocate_info.set_layout},
|
||||||
.variable_descriptor_counts = if (allocate_info.variable_descriptor_count) |x| &.{x} else &.{},
|
|
||||||
}, &descriptor_sets);
|
}, &descriptor_sets);
|
||||||
return descriptor_sets[0];
|
return descriptor_sets[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn allocateDescriptorSets(self: *Engine, allocate_info: DescriptorSetsAllocateInfo, descriptor_sets: []vk.DescriptorSet) !void {
|
pub fn allocateDescriptorSets(self: *Engine, allocate_info: DescriptorSetsAllocateInfo, descriptor_sets: []vk.DescriptorSet) !void {
|
||||||
std.debug.assert(descriptor_sets.len >= allocate_info.set_layouts.len);
|
std.debug.assert(descriptor_sets.len >= allocate_info.set_layouts.len);
|
||||||
|
|
||||||
const has_variable_descriptor_counts = allocate_info.variable_descriptor_counts.len > 0;
|
|
||||||
|
|
||||||
var p_next: ?*const anyopaque = null;
|
|
||||||
|
|
||||||
if (has_variable_descriptor_counts) {
|
|
||||||
p_next = &vk.DescriptorSetVariableDescriptorCountAllocateInfo{
|
|
||||||
.p_next = p_next,
|
|
||||||
.descriptor_set_count = @intCast(allocate_info.variable_descriptor_counts.len),
|
|
||||||
.p_descriptor_counts = allocate_info.variable_descriptor_counts.ptr,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
try self.device.allocateDescriptorSets(&.{
|
try self.device.allocateDescriptorSets(&.{
|
||||||
.p_next = p_next,
|
|
||||||
.descriptor_pool = allocate_info.descriptor_pool,
|
.descriptor_pool = allocate_info.descriptor_pool,
|
||||||
.descriptor_set_count = @intCast(allocate_info.set_layouts.len),
|
.descriptor_set_count = @intCast(allocate_info.set_layouts.len),
|
||||||
.p_set_layouts = allocate_info.set_layouts.ptr,
|
.p_set_layouts = allocate_info.set_layouts.ptr,
|
||||||
|
|||||||
Reference in New Issue
Block a user