How to picture the EGL surfaces are shared/used between producer are consumer w.r.t EGL_STREAM_FIFO_LENGTH_KHR and EGL_BUFFER_COUNT_KHR.

I mean how many EGL surfaces are created when EGL_BUFFER_COUNT_KHR = 3 vs EGL_STREAM_FIFO_LENGTH_KHR is 2.

It appears you are referring to these two EGL extensions:

After a quick scan of these, it sounds like EGL_BUFFER_COUNT_KHR was removed and is implicitly 3. Conceptually this is just the number of spare buffers available, in-use or not.

Whereas EGL_STREAM_FIFO_LENGTH_KHR is a stream property which provides a way to configure whether the stream operates in Mailbox mode or FIFO mode (and if FIFO, to configure the length of the FIFO).

In terms of how to picture this, it’s like a swap chain. Images are rendered (by the producer), and they go into a queue (called the stream in this case). On the other end of the queue, the consumer dequeues images and processes them.

If the stream’s EGL_STREAM_FIFO_LENGTH_KHR > 0, then the stream is in FIFO mode and the count set on this state is the max num images in this queue. The consumer dequeues images in the same order that the producer queued them. If the producer inserts new frames into the queue faster than the consumer can consume them , then the producer will block once there are this many images in the queue. That is, there’s back pressure through the stream in FIFO mode.

On the other hand, if EGL_STREAM_FIFO_LENGTH_KHR = 0, then the stream is in Mailbox mode. In this mode, the producer generates frames as fast as it wants and the consumer always obtains the last complete frame rendered by the producer. So in Mailbox mode, images can be completely skipped by the consumer, and there is no explicit back pressure to the producer through the stream.