Skip to content

Add mesh/image reloading capabilities #189

Description

@mrparmesan01

This issue is to document the progress and provide context for getting mesh/textures reloading capabilities into TheAtlasEngine.

Requirements

A major requirement for getting this feature worked on is working on vulkan-cpp V6.

Which you can view the progress, here at this issue.

Brief Proposals

There has been some thought as to how I might approach this. Still have not came into a decision quite, yet. Then again, at the time of writing this issue. V6 is still in progress of being developed to support modernized Vulkan API's.

Here are Ideas I have:

Mesh Hot Reloading

We use mesh UUID to find what resources are theirs to render and draw. This allows us to effectively reference to any resources used by a particular entitiy (game object).

This will make it simpler for reloading meshes. Such as if the user decides to hot-reload a 3D model. What we can do is use the lookup for the specific index, then index into the array of buffer handles to invalidate.

Using the index to search in the array what handle to invalidate, which could also be done through the event::mesh_reload event trigger as well.

// <entity_id, buffer_index_id>
// entity_id is the ID the entity uses to look for the specific buffer to load.
// buffer_index_id is the index to the `VkBuffer` or `vk::buffer_stream` handle created
std::unordered_map<uint32_t, uint32_t> entity_ids;
std::vector<vk::buffer_stream> m_buffers{};

// Reloading may look like:
m_buffers[buffer_index].invalidate(/* some reconfigured data */);

Whereas textures reloading would follow the same approach.

In Vulkan Handling this Operation

To perform this operatoin, we may need to perform a buffer copy and the regions of the vertices to flush out currently existing vertices with new vertices.

The example of this operation may work as the following:

vk::buffer_parameters staging_params = {}; // VK_BUFFER_USAGE_TRANSFER_SRC_BIT
vk::buffer_stream staging_buffer(logical_device, staging_params);

staging_buffer.write(vertices);

vk::command_buffer_parameters transfer_cmd_params = {};
vk::command_buffer transfer_command(logical_device, transfer_cmd_params);

transfer_command.begin(...);

// Performs the actual buffer region copies to updating the vertices
vk::buffer_copy_region copy_region = {
    .buffer_size = vertices_size
};
transfer_command.copy_buffer(std::span<buffer_copy_region>(&copy_region, 1));

transfer_command.end();


// Submit -- using the VkQueue handle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    improvementimproving something to be better💠coreCore architectural task with system-wide impacts.

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions