Closed vorg closed 1 year ago
Currently we do
const hash = material.id + '_' + program.id
let pipeline = this._pipelineCache[hash]
One solution would be adding lastChangeTimestamp
to the material. It would be up to material to not to change that flag if set props with values that actually didn't change.
const hash = material.id +
'_' + material.lastChangeTimestamp +
'_'+ program.id +
'_' + geometry.primitive
let pipeline = this._pipelineCache[hash]
To set that lastChangeTimestamp i would need to if check on set if any pipeline modifying props has been set. Eg if opts.blend || opts.depthTest || ... which is brittle (i need to check all props and remember to update if i add any new ones) but most GC friendly
Fixed with dirty flags
Currently to change e.g. primitive from triangles to lines requires creating new material that would trigger creating new geometry pipeline. This is especially troubling because we take primitive from geometry...
primitive: geometry.primitive
so changing geometry actually doesn't trigger pipeline change. https://github.com/pex-gl/pex-renderer/blob/master/index.js#L660