Closed QuantumEntangledAndy closed 2 years ago
As per discussions this has been changed to move the cleanup into an asset system
Anything else you think is needed?
I was thinking about how to handle asset.remove
in general. Perhaps there's a way to tie the renderer in more closely to assets. If it was then the assets could handle render.load and unload along with assets.insert
and assets.remove
. Then loading explicitly can be skipped.
Another thought: I'm wondering if the shader could hold its pipeline in addition to its shader module. Or to make that module also contain the pipeline. That would make it clean up on drop which would be better.
I'll see if I can get this done tomorrow.
I've got an idea to mark Assets
as dirty in case of inserting/removing of shaders (and other possible assets, that may need it). Then in some system we can clean things up and mark Assets
as clean. So we have both: hot reload + avoid extra checks per frame.
There could be different kinds of dirtiness: new shaders, reloading, dropping etc. But we can start with global dirty flag.
I actually like the idea about having the pipeline in a shader asset. This may work. But need a closer look on this.
I had a look at getting the pipeline backend into the shader asset but it causes mut ref issues.
let shader = assets.get_mut(shader_id).unwrap();
let texture = assets.get(material.texture).unwrap();
Lets keep it as is then. For Assets, I would still give a try to a dirty
flag. This can wait for implementation of actual assets reload in thread
Awesome. The next thing I am thinking of is shadow maps. But that will mean making multi pass possible with one light per pass to make the shadow maps. I think that's a little too much refractor for me so I might take a break for a bit and get actual work work done. :)
OK, I will try to prepare myself for shadow maps as well.
This PR adds the following:
renderer.reload()
is called so that all shaders are reloaded fully as suggested by the doc commentdrop_shader_pipeline
that will cause a shaders gpu pipeline to be dropped. If the shader asset still exists it will be recreated on next render allowing for forced updates of a shader (this can be used for hot reloading)