5.4.4.1.3 Ring Buffer Push-Pull Model

The Ring Buffer uses the producer/consumer model. The processor pushes the required instructions to render frames into the RB. The graphics consume the instructions and inform the processor that these free slots can be recycled. The RB is full when the number of free slots is equal to one. When the tail pointer is equal to the read pointer, the RB is empty. A new instruction can be pushed only if there is enough space available to store the whole instruction. When the memory is updated with one or more instructions, the head pointer is incremented with the total number of words of the batch of instructions. If the end of the RB is reached, the head pointer wraps around.

Use the following software procedure to add a command to the ring buffer queue:

  1. Monitor the Ring Buffer status from the Graphics side by reading the GFX2D_TAIL register. This register is updated by the hardware when the instruction has been successfully read from the memory.
  2. Verify that there is enough space left in the buffer to insert the command. The queue is full when you have inserted N-1 instructions, where N is the number of entries.
  3. Write the instruction at the memory location defined by GFX2D_BASE + GFX2D_HEAD.HEAD*4.
  4. Increment the local head pointer and the GFX2D_HEAD.HEAD register to inform the graphics that new instructions have been added to the queue.
  5. Wait for command completion by polling the BUSY bit in the GFX2D_GS register or wait for an interrupt if programmed.