SDL_UpdateRect in Multithreaded App

Hi all,

I’m not a guru of SDL, want a little tip. I have an
app with multiple threads, having different thread
change the same surface. I use lock/unlock surface ,
but what about the SDL_UpdateRect()? I guess the
problem of Xlib: unexpected async reply is because of
the problem of UpdateRect from one thread while the
other thread is modifying the surface contents.

or is there some other soluion?

Regards.
Arslan__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better

Lock/unlock of surfaces have nothing to do
with threads. They are related to the way
SDL/device drivers access the surfaces.

IIRC in SDL you only issue SDL calls from the
main thread.

Paulo Pinto> -----Original Message-----

From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org]On Behalf Of
Arslan Basharat
Sent: terca-feira, 23 de Julho de 2002 18:39
To: sdl at libsdl.org
Subject: [SDL] SDL_UpdateRect in Multithreaded App

Hi all,

I’m not a guru of SDL, want a little tip. I have an
app with multiple threads, having different thread
change the same surface. I use lock/unlock surface ,
but what about the SDL_UpdateRect()? I guess the
problem of Xlib: unexpected async reply is because of
the problem of UpdateRect from one thread while the
other thread is modifying the surface contents.

or is there some other soluion?

Regards.
Arslan


Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hi all,

I’m not a guru of SDL, want a little tip. I have an
app with multiple threads, having different thread
change the same surface. I use lock/unlock surface ,
but what about the SDL_UpdateRect()? I guess the
problem of Xlib: unexpected async reply is because of
the problem of UpdateRect from one thread while the
other thread is modifying the surface contents.

Yup, don’t do any graphics calls from a thread besides the main one.
If you really need separate threads updating a surface, make sure that
you use only software surfaces, do the thread-safe locking yourself,
and then signal the main thread when the surface needs to be displayed,
so it can call update rects.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Can you use a video card surface in a thread if you guarantee that no other
thread is using the surface at the same time? Or is part of the SDL library
the problem?

~Rob> ----- Original Message -----

From: Sam Lantinga [mailto:slouken@devolution.com]
Sent: Tuesday, July 23, 2002 11:03 AM
To: sdl at libsdl.org
Subject: Re: [SDL] SDL_UpdateRect in Multithreaded App

Hi all,

I’m not a guru of SDL, want a little tip. I have an
app with multiple threads, having different thread
change the same surface. I use lock/unlock surface ,
but what about the SDL_UpdateRect()? I guess the
problem of Xlib: unexpected async reply is because of
the problem of UpdateRect from one thread while the
other thread is modifying the surface contents.

Yup, don’t do any graphics calls from a thread besides the main one.
If you really need separate threads updating a surface, make sure that
you use only software surfaces, do the thread-safe locking yourself,
and then signal the main thread when the surface needs to be displayed,
so it can call update rects.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Can you use a video card surface in a thread if you guarantee that no other
thread is using the surface at the same time? Or is part of the SDL library
the problem?

It all depends on the underlying OS driver support. Generally though, you
shouldn’t rely on being able to.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Sam Lantinga

Hi all,

I’m not a guru of SDL, want a little tip. I have an
app with multiple threads, having different thread
change the same surface. I use lock/unlock surface ,
but what about the SDL_UpdateRect()? I guess the
problem of Xlib: unexpected async reply is because of
the problem of UpdateRect from one thread while the
other thread is modifying the surface contents.

Yup, don’t do any graphics calls from a thread besides the main one. If
you really need separate threads updating a surface, make sure that you
use only software surfaces, do the thread-safe locking yourself, and
then signal the main thread when the surface needs to be displayed, so
it can call update rects.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

----- Original Message -----
From: sdl-admin@libsdl.org [mailto:sdl-admin at libsdl.org] On Behalf Of
Sent: Tuesday, July 23, 2002 8:03 PM
To: sdl at libsdl.org
Subject: Re: [SDL] SDL_UpdateRect in Multithreaded App