View Full Version : Multiple custom engine rendering using QTimer in QWidget, conflict of multiple calls

23rd July 2019, 08:05
Hi everybody,
I have a custom QWidget class which does a Direct3D12 rendering using a QTimer to draw the frame.
All works good but the problem is I have multiple instance of this widget, meaning multiple drawing of frame.
The problem is QTimer is async so the call can be crossed between all these rendering.
Is there a safe way in Qt to avoid this problem or I have to lock the main thread with a mutex for each drawing of frame?

23rd July 2019, 09:46
I am not quite sure I understand your problem.

All timers work on the thread they are created on, so if you create a timer in a widget it will run on the main thread.

Do these multiple instances show the same content and you want them updated at the same time?


23rd July 2019, 19:24
I was afraid of the QTimer can be executed in same time and then make a conflict but if you say that can never happen, then certainly it's safe.
This is a QTimer which is not one-shot and which has the start using 0 as time parameter to have it refresh at maximum speed.
Something I noticed is if I activate the VSync of the swap chain of Direct3D, I don't have the FPS lock at 60FPS.
I tried to change the QTimer to one shot and start at the end of the frame rendering but still not 60FPS lock.
Normally the VSync block the update at the end of the rendering and you have 60FPS...