lowenware / dotrix

A 3D engine with ECS and Vulkan renderer for Rust developers
https://dotrix.rs
MIT License
292 stars 11 forks source link

Handle dropping shader gpu backends #127

Closed QuantumEntangledAndy closed 2 years ago

QuantumEntangledAndy commented 2 years ago

This PR adds the following:

QuantumEntangledAndy commented 2 years ago

As per discussions this has been changed to move the cleanup into an asset system

QuantumEntangledAndy commented 2 years ago

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.

QuantumEntangledAndy commented 2 years ago

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.

voxelias commented 2 years ago

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.

QuantumEntangledAndy commented 2 years ago

I had a look at getting the pipeline backend into the shader asset but it causes mut ref issues.

voxelias commented 2 years ago

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

QuantumEntangledAndy commented 2 years ago

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. :)

voxelias commented 2 years ago

OK, I will try to prepare myself for shadow maps as well.