David Williams wrote:
Yeah... multithreading is pretty tricky. I don't have any firm answers but here are some thoughts.
You say you are making use of mutexes to lock the volume, but how many to you have? I think one per volume is the only safe approach? The important question then is how often do you lock it? For example if you lock it every time you want to access a voxel and then release it afterwards then you'll have a lot of locks/unlocks going on. So you should lock it once, generate a whole region of data, and then unlock it. Or lock it once, extract a large part of the surface, and then unlock it.
I got only one mutex. I wrote Mutexes having in mind that i use mutexes too, to lock my Taskqueues. When i generate a chunk i lock the volume for the whole duration. Problem is it needs ~0.33 seconds for it per Chunk
The extraction is fairly faster. But i dont think i can optimise that even better. I made it from ~1.5s to ~0.33 so im kinda happy.
David Williams wrote:
It's not very good, and we'll pull it out of PolyVox at some point. We'll probably recommend using an external library instead but we need to do some investigation into that.
Sorry to hear that. I found the results pretty appleaing. Only downside is its runtime behavior.
David Williams wrote:
I don't know how well that would work, but if you want to try it then maybe it could be implemented using the underflow/overflow handlers? Your second volume could have an underflow handlers which reads data from your main volume and an overflow handler which wroites it back (locking once in both cases). I think this would save you making a complete copy of the whole volume? Well I'm not really sure but it seems like an interesting idea...
It could work. But its not a thing to test just like that... Ill think about it for sure. Seems neat but somehow tricky.
Reading your idea about the over- and underflow handlers one idea stroke my mind:
Is it safe to assume the largeVolume did not change until the over or underflow callback got called? To be more precise: I guess it would suffice to say the overflow handler? If i got a boolean i set to true everytime the underflow header finished working wouldnt several concurrent read-operations be safe?
Or does the adding of new data invalidate the content, too? I dont know exactly how LargeVolume handles its content and if there is some sorting or similar things going on...
EDIT: Ah... as long as either over- or underflow handler isnt called. When new data is stored int he volume invalidation may occure of course due to the compression going on. My bad. I thought it over and well..duh.
David Williams wrote:
As I recall you can use the VolumeResampler. It has an explicit test for whether the source and dest are the same size and so skips the interpolation.
Thanks for the hint.
Warm regards,
Kuro