I was wondering where that padding came from, thank you, that makes it much clearer now. I've asked the GL questions in the appropriate forum location.
The one thing I am dealing with now is that once I implemented this code into my larger framework, there the code cannot always process every frame, since with GL, if I am doing a lot of stuff, the frame rate can drop. That's fine, but of course, what is happening is that sometimes I get different fields getting combined and so I get some weird visual artifacts when those events happen.
Before you said:
The peripheral is double buffered. The blanking periods can be very short, therefore if you haven't given it a new buffer before the end of frame it will just overwrite the old one again and not release it back to the client.
The only other option is to fully stop the peripheral after every frame, and there you would be relying on interrupt latencies being very low.
I've been thinking about the ways to solve this issue.
1) Create a pool of buffers that get filled in a thread that run a select/dequeue/queue loop. Give this thread a higher priority. (I have CPU to spare). Keep track of newest frame available, transfer into texture either using current mechanism (blocking texture update) or use PBOs if available.
2) I tried using STREAM OFF and STREAM ON, but for some reason I was getting a black frame. No indication of why, I am still exploring this one. This also means that it adds in some wasted time waiting for a frame always, and stalls the GL pipeline, which leads me to the next issue:
Given these are different fields coming out, if I am being too slow reading them, if it constantly replaces the last buffer with TOP then BOTTOM over and over, this probably leads to situations where I have mismatched frames.
So when I call STREAMOFF, do I need to DEQUEUE all the buffers and then REQUEUE them up?
When I use select, that's basically waiting to make sure there is a buffer to dequeue. If I want to get the latest buffers, do I just run DEQUEUE till it fails? Then scrap the returned structures to find the last full pair of TOP/BOTTOM? Then release the ones I am not using and continue with the 2 I am using? If this is possible, then I could use the current direct transfer into GL but not get the stuttering I am seeing.
I'm unclear on how to properly drop frames in a way to always allow the peripheral to have something to write into so I at least get the proper combination of frames and use newer frames, not older ones, when I have to drop.