dotrix icon indicating copy to clipboard operation
dotrix copied to clipboard

Assets hot reloading

Open voxelias opened this issue 3 years ago • 1 comments

  • [ ] Add dirty flag to assets
  • [ ] Add timestamp of last file modification
  • [ ] Add a new thread to control last file modification timestamp and reschedule the import
  • [ ] Set dirty flag, if the asset was updated
  • [ ] Make sure buffers being updated and dirty flag is unset

voxelias avatar Apr 23 '22 19:04 voxelias

I am thinking of maybe something like this. Separate the gpu and cpu representations. Assets represents the data on the cpu buffers that on gpu.

Both assets and buffers have a revision number. When an asset is changed the number is incremented.

Gpu objects have a function that is something like which is called as part of the render system.

fn load(&mut self, cpu: & CpuRepresentation) {
  // check if buffer revision == asset revision if not copy data from cpu to gpu
}

Function should return something like.

enum Update {
  Structure,
  Data,
  None
}

A Structure update indicated that the underlaying data structure like buffer size or texture dimensions was changed and that the render system should rebind.

A Data update indicates that new data was put into the buffer but that the structure was not changed. It can just re-queue the same gpu pipeline.

A None update means no change. Depending on the system it may not even want to re-queue the gpu pipeline.

By using revision rather than dirty we are more resistant to the case where there are multiple buffer that need updating off the same cpu data.

QuantumEntangledAndy avatar Apr 24 '22 00:04 QuantumEntangledAndy