Log in

View Full Version : How to Use Frame Buffer with MT


MysteryX
29th October 2015, 09:59
How do you program AviSynth filters for MT? I heard about a frame buffer, and how does it work?

I'm thinking of this. I'm using 8 threads and am processing frame n. I could increase performance 2x by processing the next frame at the same time. I could assume that with 8 threads, the next frame to be processed will usually be n+8.

Now what if it's not? I don't want to be calculating frame n+8 several times in separate threads. If another thread wants to render frame n+8 while my thread is still processing it, is there a way to
1. make the second thread wait
2. finish calculating it and store it in a cache
3. access the frame from the cache in the second thread

How can I do this, or is there a better way to do it?

Basically I want to fill in the data that will be requested next, because when rendering scenes with a DirectX9 device, it returns the previously created scene while we fill in the data of the current scene. It works if I create a 2nd dummy scene but that cuts performance in half!

MysteryX
29th October 2015, 19:31
I just did a quick test. The frame order isn't regular enough to use this approach; it's too often random.

The only way to create a processing queue, then, may be to have a static shared worker thread.