Skip to main content
GameDev.net gamedev.net
🔒 Locked

Multi-thread and Shaders

Started by widggman Jun 14, 2011 at 3:27 AM 2 replies 900+ views
Original Post
widggman
widggman
Hi,

I have a big question. Let say I have two threads. The first is drawing what I need with OpenGL and the second is updating the data for each frame. But if most of the drawing is done by the fragment shader, is it risky to update the uniforms variables with the second thread ? Or they should be updated by the rendering thread before the full execution, in whatever the state they are left by the second thread ?

Thanks

W

P.S.: This question applies also for Android with OpenGL ES. I just finished some test with the shaders, and it's very slow.. farther than the video card on a desktop. I was expecting something slower, but not that much.

Hodgman
Hodgman
In general -- Any data that's shared between two threads needs special handling. If one thread is writing to data, you must ensure that the other thread is not currently reading that data.
What you're talking about does sound dangerous.
widggman
widggman

In general -- Any data that's shared between two threads needs special handling. If one thread is writing to data, you must ensure that the other thread is not currently reading that data.
What you're talking about does sound dangerous.


thanks!



widggman
widggman
But just to be sure...

If my first thread, for rendering is using the shaders, but the second thread is updating the uniforms data on the shader at the same time. Do you know what kind of result you will have ?

Would you suggest to put a lock on it ? When it's rendering, the second thread as to wait to update and the opposite when it's updating.



Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.