jK wrote:Zerver isn't able to share a lua enviroment between 2 threads, so it isn't a problem of any callins, it is a problem of rendering in lua in general.
But still it is a problem of lua enviroment sharing and totaly independent of lua itself ... (so it is zerver's problem and not the prob of any lua dev ...)
Usage of LUA is already properly synchronized between Sim and Draw (at least I'd like to think so).
A bigger problem is that the Sim thread can acquire some mutexes and then try to make a GL call. Certain GL calls require the Sim to wait for the rendering thread (which processes all calls sooner or later), but if the rendering thread then tries to acquire one of the mutexes that the Sim thread already has, we have a deadlock. This is extremely difficult to solve, and I honestly think it is a better solution to fix the mod in question.
I have made things easy for mod makers who want to support the current multithreading version - the console churns out error messages if GL calls are made from the Sim. It should not be hard to track them down.
Code: Select all
[ 3646] GML error: Sim thread called gmlGenLists
[ 3646] GML error: Sim thread called gmlGenLists
[ 3653] GML error: Sim thread called gmlNewList
[ 3653] GML error: Sim thread called gmlPushMatrix
[ 3653] GML error: Sim thread called gmlTranslatef
[ 3653] GML error: Sim thread called gmlBegin
[ 3653] GML error: Sim thread called gmlMultiTexCoord2f
[ 3653] GML error: Sim thread called gmlMultiTexCoord4f
The things that remain in the Sim thread are mostly creation of display lists and such. For instance in CA 3073, lups_napalm.lua:
GameFrame()
SpawnNapalmFX()
Lups.AddParticles('JitterParticles2',heatFX)
JitterParticles2.Create()
JitterParticles2:CreateParticle()
glCreateList()