JamesPerlman / TurboNeRF

A render engine for NeRFs!
MIT License
312 stars 16 forks source link

write image on background thread #14

Closed JamesPerlman closed 1 year ago

JamesPerlman commented 1 year ago

please ignore the 7 extra commits, i forgot i was on this branch.

MrNeRF commented 1 year ago

I think it is doing basically the same as in https://github.com/JamesPerlman/NeRFRenderCore/pull/13. I have passed the thread to the next function, because I wanted to make sure that data is written to disk properly. I suspect if you just detach the thread, you give up the ownership and have no control what is happening in the background. This might open a door for bugs because the render buffer is reused and you could accidentally overwrite it in case. This is basically not thread safe.

So, one solution might be in defining the thread outside of the most outer loop and try to join it, before a new one is launched. What do you think? By the way I did not have a chance to test it. I will do it later today

JamesPerlman commented 1 year ago

ahhh yes this is very true, if you make subsequent calls to save_buffer, there is the potential to have race conditions... hmm let me think about this, i will look at your PR again tomorrow.

MrNeRF commented 1 year ago

I build and tested this branch. I don't see any issues popping up. But I believe that the problem with the potential race condition remains.

JamesPerlman commented 1 year ago

I build and tested this branch. I don't see any issues popping up. But I believe that the problem with the potential race condition remains.

awesome, thanks for trying it out. I think let's hold off on multithreading for right now. It needs to be done with extreme care. I will be getting to it very soon, as i rewrite the renderer to work with multiple gpus, and also make sure we can train & preview render at the same time.