Why SDL_LockYUVOverlay in the same thread?

Dear everyone,
To access an overlay?s pixel data(either for writing or reading),
you must first lock it, then do whatever accessing you need to do, and then unlock it.
If all my accessing in the same thread, is there a need to lock it?

2009-07-17

kedahanzi

2009/7/16 kedahanzi <kedahanzi at 163.com>:

??? To?access?an?overlay?s?pixel?data(either?for?writing?or?reading),
you?must?first?lock?it,?then?do?whatever
accessing?you?need?to?do,?and?then?unlock?it.
??? If all my accessing in the same thread, is there a need to lock it?

Yes, the locking is to control access to the data between the main CPU
and the GPU, not really for access between threads (in fact, I think
that taking the lock is done for all the threads, so it actually
offers no protection at all between threads!).–

first thanks very much for your answer.

According to your answer, SDL_LockYUVOverlay will have no effect
on thread lock?
In other words, If i operates yuv overlay between different thread,
i have to call other lock function for it.

2009-07-17

kedahanzi

??? Pierre Phaneuf
??? 2009-07-17 14:04:16
??? A list for developers using the SDL library. (includes SDL-announce)
???
??? Re: [SDL] why SDL_LockYUVOverlay in the same thread?

2009/7/16 kedahanzi <@kedahanzi>:

    To access an overlay?s pixel data(either for writing or reading),

you must first lock it, then do whatever
accessing you need to do, and then unlock it.
If all my accessing in the same thread, is there a need to lock it?
Yes, the locking is to control access to the data between the main CPU
and the GPU, not really for access between threads (in fact, I think
that taking the lock is done for all the threads, so it actually
offers no protection at all between threads!).–
http://www.google.com/profiles/pphaneuf


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

2009/7/17 kedahanzi <kedahanzi at 163.com>:

According to your answer, SDL_LockYUVOverlay? will have no effect
on thread lock?
In other words, If i operates yuv overlay between different thread,
i have to call other lock function for it.

That seems to be exact.

It does call down into the renderer to actually do the locking, so a
specific renderer might provide locking from threads intervention, but
I don’t think this is very likely.–

2009/7/17 Pierre Phaneuf :

2009/7/17 kedahanzi <kedahanzi at 163.com>:

According to your answer, SDL_LockYUVOverlay? will have no effect
on thread lock?
In other words, If i operates yuv overlay between different thread,
i have to call other lock function for it.

That seems to be exact.

It does call down into the renderer to actually do the locking, so a
specific renderer might provide locking from threads intervention, but
I don’t think this is very likely.

Use the SDL_mutex functions for thread safety (
http://www.libsdl.org/cgi/docwiki.cgi/SDL_CreateMutex ), not surface
or overlay locks.