Open Lowentwickler opened 2 years ago
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.
dirty
flag to assetsdirty
flag, if the asset was updateddirty
flag is unset