add indirect command buffer to registered meshes
This commit is contained in:
@@ -103,18 +103,34 @@ std::uint32_t renderer::register_mesh(const game::mesh_node &mesh) {
|
||||
context.superframe_allocator, vuk::MemoryUsage::eCPUtoGPU,
|
||||
vuk::DomainFlagBits::eTransferOperation, std::span(mesh.indices));
|
||||
|
||||
const auto indirect_draw = std::array<std::uint32_t, 5>({
|
||||
static_cast<std::uint32_t>(mesh.indices.size()), // index count
|
||||
1, // instance count
|
||||
0, // first index
|
||||
0, // vertex offset (int32 technically)
|
||||
0, // first instance
|
||||
});
|
||||
|
||||
auto [indirect_buffer, indirect_future] = vuk::create_buffer(
|
||||
context.superframe_allocator, vuk::MemoryUsage::eCPUtoGPU,
|
||||
vuk::DomainFlagBits::eTransferOperation,
|
||||
std::span<const std::uint32_t>(indirect_draw));
|
||||
|
||||
auto futures = std::vector<vuk::UntypedValue>();
|
||||
futures.push_back(std::move(vertex_future));
|
||||
futures.push_back(std::move(index_future));
|
||||
futures.push_back(std::move(indirect_future));
|
||||
|
||||
// TODO: Make async?
|
||||
vuk::wait_for_values_explicit(context.superframe_allocator, context.compiler,
|
||||
std::span(futures));
|
||||
|
||||
registered_meshes.insert({id, loaded_mesh{
|
||||
.vertices = std::move(vertex_buffer),
|
||||
.indices = std::move(index_buffer),
|
||||
}});
|
||||
registered_meshes.insert(
|
||||
{id, loaded_mesh{
|
||||
.vertices = std::move(vertex_buffer),
|
||||
.indices = std::move(index_buffer),
|
||||
.indirect_command = std::move(indirect_buffer),
|
||||
}});
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ private:
|
||||
struct loaded_mesh {
|
||||
vuk::Unique<vuk::Buffer> vertices;
|
||||
vuk::Unique<vuk::Buffer> indices;
|
||||
vuk::Unique<vuk::Buffer> indirect_command;
|
||||
};
|
||||
std::unordered_map<std::uint32_t, loaded_mesh> registered_meshes;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user