Tutorial
FM4, S6E2DH/S6E2DF/S6E2D5/S6E2D3 Series, 32-Bit Microcontroller, Graphic Driver User Manual, Doc. No. 002-04387 Rev. *A
49
6.7.3 Draw function
The main draw function calls a draw for each window. Each window draw function checks first the window sync
object. If the sync object signals a timeout the function returns.
ret = mmlGdcSyncWait(&pdbWin->sync, 0);
if
(ret == MML_ERR_GDC_SYNC_TIMEOUT)
return
MML_OK;
Using this mechanism the drawing loop will not consume CPU time if the previous buffer swap is not yet finished.
The next step is rendering the new frame in the back buffer. All these render operations will be pushed in the
command sequencer queue and executed sequential by the hardware. So if we now assign the new buffer to the
window it is possible that the new buffer becomes visible before rendering is finished.
To avoid this it is possible to poll the end of the blit operation using mmlGdcPeFinish(). A better way is to use a sync
object:
UTIL_SUCCESS(ret, mmlGdcPeSync(&pdbWin->sync));
UTIL_SUCCESS(ret, mmlGdcDispWinWaitSync(pdbWin->win, &pdbWin->sync));
UTIL_SUCCESS(ret, mmlGdcDispWinSetSurface(pdbWin->win,
MML_GDC_DISP_BUFF_TARGET_COLOR_BUFF, &pdbWin->sFramebuffer[pdbWin->id] ));
UTIL_SUCCESS(ret, mmlGdcDispWinCommit(pdbWin->win));
It requests a sync object from the pixel engine and pushes it to the window pipe before the new buffer is assigned to
the window. All these functions are non blocking for the CPU and the driver will ensure that the hardware will be
triggered in the correct order.
6.7.4 Swap interval
The windows are set to different swap intervals:
UTIL_SUCCESS(ret, mmlGdcDispWinSetAttribute(s_dbw[i].win, MML_GDC_DISP_WIN_ATTR_SWAP_INTERVAL,
window_assignment[i].swap_interval));
This feature can be used to control the window refresh interval. Very important windows may keep the default swap
interval 1 but low priority windows with may be GPU consuming draw operations can be set to a swap interval 2 or
3. In this case the window will be updated with 30 Hz or 20 Hz for a display with 60 Hz refresh rate.