Spring is running in SMP - Page 18

Spring is running in SMP

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Spring is running in SMP

Post by Kloot »

LOS is represented as a 2D grid per allyteam. That makes it possible, just hard wrt. sync.
eyu100
Posts: 182
Joined: 05 Jul 2008, 04:10

Re: Spring is running in SMP

Post by eyu100 »

Kloot wrote:LOS is represented as a 2D grid per allyteam. That makes it possible, just hard wrt. sync.
So there is only one LOS object per allyteam? I want to know how the engine works with it. My best guess for how the LOS is calculated would be that the engine first looks at every unit and calculates their LOS, but I still can't understand how that calculation is used. I can see a CLosMap::At function that returns an unsigned short but I don't know what happens after.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Spring is running in SMP

Post by Tobi »

Every allyteam has a LosMap, this is basically a 16 bits per "pixel" bitmap.

Every unit adds itself to the LosMap, this is done by raycasting against terrain, and incrementing the pixels of the LosMap for the squares the unit can see. The squares it can see are remembered, to be able to remove the unit even after terrain changes etc. (the raycasting may give a different result then.)

Every unit has an array of bitmasks (losStatus), one for each allyteam. These are regularly updated by reading data from the LosMaps of all allyteams. These bitfields may contain the flags LOS_INLOS, LOS_INRADAR, LOS_PREVLOS and LOS_CONTRADAR. (This is used to tracks things like: "Has the unit ever been in LOS, and has it since then always been in radar?")

When a weapon or unit or the renderer wants to know whether a unit is in LOS of allyteam at, it just checks (unit->losStatus[at] & LOS_INLOS) != 0, instead of using the LosMap for it.
Societal
Posts: 64
Joined: 05 May 2009, 13:57

Re: Spring is running in SMP

Post by Societal »

After zerver's patch above posted above:

Code: Select all

Scanning dependencies of target gml
[  1%] Building CXX object rts/lib/CMakeFiles/gml.dir/gml/gml.cpp.obj
E:\Data\spring\rts\lib\gml\gml.cpp:172: error: no matching function for call to
'gmlSingleItemServer<unsigned int, GLhandleARB (*)()>::gmlSingleItemServer(GLuin
t (**)(), int, int)'
E:\Data\spring\rts\lib\gml\gmlcls.h:875: note: candidates are: gmlSingleItemServ
er<T, C>::gmlSingleItemServer(C, int, int) [with T = unsigned int, C = GLhandleA
RB (*)()]
E:\Data\spring\rts\lib\gml\gmlcls.h:865: note:                 gmlSingleItemServ
er<unsigned int, GLhandleARB (*)()>::gmlSingleItemServer(const gmlSingleItemServ
er<unsigned int, GLhandleARB (*)()>&)
E:\Data\spring\rts\lib\gml\gml.cpp:173: error: no matching function for call to
'gmlSingleItemServer<unsigned int, GLhandleARB (*)()>::gmlSingleItemServer(GLhan
dleARB (**)(), int, int)'
E:\Data\spring\rts\lib\gml\gmlcls.h:875: note: candidates are: gmlSingleItemServ
er<T, C>::gmlSingleItemServer(C, int, int) [with T = unsigned int, C = GLhandleA
RB (*)()]
E:\Data\spring\rts\lib\gml\gmlcls.h:865: note:                 gmlSingleItemServ
er<unsigned int, GLhandleARB (*)()>::gmlSingleItemServer(const gmlSingleItemServ
er<unsigned int, GLhandleARB (*)()>&)
E:\Data\spring\rts\lib\gml\gml.cpp:182: error: invalid conversion from 'GLUquadr
ic* (*)()' to 'GLUquadric* (*)()'
E:\Data\spring\rts\lib\gml\gml.cpp:182: error:   initializing argument 1 of 'gml
SingleItemServer<T, C>::gmlSingleItemServer(C, int, int) [with T = GLUquadric*,
C = GLUquadric* (*)()]'
E:\Data\spring\rts\lib\gml\gml.cpp:184: error: invalid conversion from 'void (*)
(GLsizei, GLuint*)' to 'void (*)(GLsizei, GLuint*)'
. . .
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Re: Spring is running in SMP

Post by zerver »

Try removing the & character on line 172 in gml.cpp.

If that makes a difference, remove all the & characters in that section.

Edit: On second thought not a good idea at all. Might compile, but will crash. Will try to post some fixed code here.
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Re: Spring is running in SMP

Post by zerver »

Replace the corresponding section in gml.cpp with this:

Code: Select all

// Item server instances
#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3) && (__GNUC_PATCHLEVEL__ == 0)
// gcc has issues with attributes in function pointers it seems

gmlSingleItemServer<GLhandleARB, GLhandleARB (**)(void)> gmlProgramServer(&glCreateProgram, 2, 0);
gmlSingleItemServer<GLhandleARB, GLhandleARB (**)(void)> gmlProgramObjectARBServer(&glCreateProgramObjectARB, 2, 0);

gmlSingleItemServer<GLUquadric *, GLUquadric *(*)(void)> gmlQuadricServer(&gluNewQuadric, 100, 25);

gmlMultiItemServer<GLuint, GLsizei, void (*)(GLsizei,GLuint *)> gmlTextureServer(&glGenTextures, 100, 25);
gmlMultiItemServer<GLuint, GLsizei, void (**)(GLsizei, GLuint*)> gmlBufferARBServer(&glGenBuffersARB, 2, 0);
gmlMultiItemServer<GLuint, GLsizei, void (**)(GLsizei, GLuint*)> gmlFencesNVServer(&glGenFencesNV, 2, 0);
gmlMultiItemServer<GLuint, GLsizei, void (**)(GLsizei, GLuint*)> gmlProgramsARBServer(&glGenProgramsARB, 2, 0);
gmlMultiItemServer<GLuint, GLsizei, void (**)(GLsizei, GLuint*)> gmlRenderbuffersEXTServer(&glGenRenderbuffersEXT, 2, 0);
gmlMultiItemServer<GLuint, GLsizei, void (**)(GLsizei, GLuint*)> gmlFramebuffersEXTServer(&glGenFramebuffersEXT, 2, 0);
gmlMultiItemServer<GLuint, GLsizei, void (**)(GLsizei, GLuint*)> gmlQueryServer(&glGenQueries, 20, 5);
gmlMultiItemServer<GLuint, GLsizei, void (**)(GLsizei, GLuint*)> gmlBufferServer(&glGenBuffers, 2, 0);

#else

gmlSingleItemServer<GLhandleARB, PFNGLCREATEPROGRAMPROC *> gmlProgramServer(&glCreateProgram, 2, 0);
gmlSingleItemServer<GLhandleARB, PFNGLCREATEPROGRAMOBJECTARBPROC *> gmlProgramObjectARBServer(&glCreateProgramObjectARB, 2, 0);

gmlSingleItemServer<GLUquadric *, GLUquadric *(GML_GLAPIENTRY *)(void)> gmlQuadricServer(&gluNewQuadric, 100, 25);

gmlMultiItemServer<GLuint, GLsizei, void (GML_GLAPIENTRY *)(GLsizei,GLuint *)> gmlTextureServer(&glGenTextures, 100, 25);
gmlMultiItemServer<GLuint, GLsizei, PFNGLGENBUFFERSARBPROC *> gmlBufferARBServer(&glGenBuffersARB, 2, 0);
gmlMultiItemServer<GLuint, GLsizei, PFNGLGENFENCESNVPROC *> gmlFencesNVServer(&glGenFencesNV, 2, 0);
gmlMultiItemServer<GLuint, GLsizei, PFNGLGENPROGRAMSARBPROC *> gmlProgramsARBServer(&glGenProgramsARB, 2, 0);
gmlMultiItemServer<GLuint, GLsizei, PFNGLGENRENDERBUFFERSEXTPROC *> gmlRenderbuffersEXTServer(&glGenRenderbuffersEXT, 2, 0);
gmlMultiItemServer<GLuint, GLsizei, PFNGLGENFRAMEBUFFERSEXTPROC *> gmlFramebuffersEXTServer(&glGenFramebuffersEXT, 2, 0);
gmlMultiItemServer<GLuint, GLsizei, PFNGLGENQUERIESPROC *> gmlQueryServer(&glGenQueries, 20, 5);
gmlMultiItemServer<GLuint, GLsizei, PFNGLGENBUFFERSPROC *> gmlBufferServer(&glGenBuffers, 2, 0);

#endif

gmlSingleItemServer<GLhandleARB, GLhandleARB (*)(void)> gmlShaderServer_VERTEX(&glCreateShader_VERTEX, 2, 0);
gmlSingleItemServer<GLhandleARB, GLhandleARB (*)(void)> gmlShaderServer_FRAGMENT(&glCreateShader_FRAGMENT, 2, 0);
gmlSingleItemServer<GLhandleARB, GLhandleARB (*)(void)> gmlShaderServer_GEOMETRY_EXT(&glCreateShader_GEOMETRY_EXT, 2, 0);

gmlSingleItemServer<GLhandleARB, GLhandleARB (*)(void)> gmlShaderObjectARBServer_VERTEX(&glCreateShaderObjectARB_VERTEX, 2, 0);
gmlSingleItemServer<GLhandleARB, GLhandleARB (*)(void)> gmlShaderObjectARBServer_FRAGMENT(&glCreateShaderObjectARB_FRAGMENT, 2, 0);
gmlSingleItemServer<GLhandleARB, GLhandleARB (*)(void)> gmlShaderObjectARBServer_GEOMETRY_EXT(&glCreateShaderObjectARB_GEOMETRY_EXT, 2, 0);
and in gml.h replace with this:

Code: Select all

#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3) && (__GNUC_PATCHLEVEL__ == 0)
// gcc has issues with attributes in function pointers it seems

extern gmlSingleItemServer<GLhandleARB, GLhandleARB (**)(void)> gmlProgramServer;
extern gmlSingleItemServer<GLhandleARB, GLhandleARB (**)(void)> gmlProgramObjectARBServer;

extern gmlSingleItemServer<GLUquadric *, GLUquadric *(*)(void)> gmlQuadricServer;

extern gmlMultiItemServer<GLuint, GLsizei, void (*)(GLsizei,GLuint *)> gmlTextureServer;

extern gmlMultiItemServer<GLuint, GLsizei, void (**)(GLsizei, GLuint*)> gmlBufferARBServer;
extern gmlMultiItemServer<GLuint, GLsizei, void (**)(GLsizei, GLuint*)> gmlFencesNVServer;
extern gmlMultiItemServer<GLuint, GLsizei, void (**)(GLsizei, GLuint*)> gmlProgramsARBServer;
extern gmlMultiItemServer<GLuint, GLsizei, void (**)(GLsizei, GLuint*)> gmlRenderbuffersEXTServer;
extern gmlMultiItemServer<GLuint, GLsizei, void (**)(GLsizei, GLuint*)> gmlFramebuffersEXTServer;
extern gmlMultiItemServer<GLuint, GLsizei, void (**)(GLsizei, GLuint*)> gmlQueryServer;
extern gmlMultiItemServer<GLuint, GLsizei, void (**)(GLsizei, GLuint*)> gmlBufferServer;

extern gmlItemSequenceServer<GLuint, GLsizei,GLuint (**)(GLsizei)> gmlListServer;

#else

extern gmlSingleItemServer<GLhandleARB, PFNGLCREATEPROGRAMPROC *> gmlProgramServer;
extern gmlSingleItemServer<GLhandleARB, PFNGLCREATEPROGRAMOBJECTARBPROC *> gmlProgramObjectARBServer;

extern gmlSingleItemServer<GLUquadric *, GLUquadric *(GML_GLAPIENTRY *)(void)> gmlQuadricServer;

extern gmlMultiItemServer<GLuint, GLsizei, void (GML_GLAPIENTRY *)(GLsizei,GLuint *)> gmlTextureServer;

extern gmlMultiItemServer<GLuint, GLsizei, PFNGLGENBUFFERSARBPROC *> gmlBufferARBServer;
extern gmlMultiItemServer<GLuint, GLsizei, PFNGLGENFENCESNVPROC *> gmlFencesNVServer;
extern gmlMultiItemServer<GLuint, GLsizei, PFNGLGENPROGRAMSARBPROC *> gmlProgramsARBServer;
extern gmlMultiItemServer<GLuint, GLsizei, PFNGLGENRENDERBUFFERSEXTPROC *> gmlRenderbuffersEXTServer;
extern gmlMultiItemServer<GLuint, GLsizei, PFNGLGENFRAMEBUFFERSEXTPROC *> gmlFramebuffersEXTServer;
extern gmlMultiItemServer<GLuint, GLsizei, PFNGLGENQUERIESPROC *> gmlQueryServer;
extern gmlMultiItemServer<GLuint, GLsizei, PFNGLGENBUFFERSPROC *> gmlBufferServer;

extern gmlItemSequenceServer<GLuint, GLsizei,GLuint (GML_GLAPIENTRY *)(GLsizei)> gmlListServer;

#endif

extern gmlSingleItemServer<GLhandleARB, GLhandleARB (*)(void)> gmlShaderServer_VERTEX;
extern gmlSingleItemServer<GLhandleARB, GLhandleARB (*)(void)> gmlShaderServer_FRAGMENT;
extern gmlSingleItemServer<GLhandleARB, GLhandleARB (*)(void)> gmlShaderServer_GEOMETRY_EXT;

extern gmlSingleItemServer<GLhandleARB, GLhandleARB (*)(void)> gmlShaderObjectARBServer_VERTEX;
extern gmlSingleItemServer<GLhandleARB, GLhandleARB (*)(void)> gmlShaderObjectARBServer_FRAGMENT;
extern gmlSingleItemServer<GLhandleARB, GLhandleARB (*)(void)> gmlShaderObjectARBServer_GEOMETRY_EXT;
Last edited by zerver on 20 Jun 2009, 15:00, edited 2 times in total.
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Re: Spring is running in SMP

Post by zerver »

eyu100 wrote:Spring crashes (access violation) immediately on startup.
I did some thinking and this is possibly caused by your GL version which is 1.3. The SMP version currently requires 1.5, but this may change in the next version.
Societal
Posts: 64
Joined: 05 May 2009, 13:57

Re: Spring is running in SMP

Post by Societal »

USE_GML still doesn't want to build on my Win32 system with GCC 4.4.0 TDM. This was pulled from the master about two hours ago with build type as Debug2 and USE_GML set, everything else default CMake settings:

http://pastebin.com/m3b755804

Anything else I should try?
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Re: Spring is running in SMP

Post by zerver »

Sorry, but I don't know how to help. The errors are obviously very very bogus
invalid conversion from 'GLUquadric* (*)()' to 'GLUquadric* (*)()


Maybe try a different (older) GCC version?
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: Spring is running in SMP

Post by imbaczek »

the bogusness comes from attributes which are a part of the type but aren't printed out. can't say more now, except that i got rid of those errors once in a not-very-finesse way, by changing signatures.
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Re: Spring is running in SMP

Post by zerver »

I just downloaded "4.4.0-tdm-1 (r2)" and it compiles just fine here.

Makes me even more confused.

Edit: Oops, a mistake during installation I see now, will get back with updated results.
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Re: Spring is running in SMP

Post by zerver »

OK, it turned out that the fix itself was the problem. Master should compile now.
Societal
Posts: 64
Joined: 05 May 2009, 13:57

Re: Spring is running in SMP

Post by Societal »

:o Thanks zerver. USE_GML + USE_GML_SIM now compile for me in Win32 with official GCC 4.4.0.
Societal
Posts: 64
Joined: 05 May 2009, 13:57

Re: Spring is running in SMP

Post by Societal »

/screenshot is crashing my MT build. I've tried with and without a /screenshots directory in the read-write directory. A normal build will create the needed directory and image without issue.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Spring is running in SMP

Post by Beherith »

This smp build is made of pure and epic win!
The frame rate is no longer tied to the cpu for me, and I can move up to 3000 core vamps around on dsd while still maintaining 20 fps if they are all in full view. Also, if they are not in view, my fps pop back up to 80! This is with quite high gfx settings.

Oh rite, and turning off threaded optimization gave me another 50% boost. So turning that off is essential.
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Re: Spring is running in SMP

Post by Das Bruce »

Wow, awesome work.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Spring is running in SMP

Post by Beherith »

I enabled lupsmanager in BA, and all the effects showed fine, but it spammed warnings that sim code called GML :(
Can anything be done about this?
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: Spring is running in SMP

Post by imbaczek »

yeah, fix lupsmanager so it doesn't violate GML assumptions.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Spring is running in SMP

Post by jK »

fix what?
it is the fault of zerver/GML!
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Spring is running in SMP

Post by Beherith »

I did not, for even a second try to push blame on the widget.
Post Reply

Return to “Engine”