From: Dorosky, Christopher G (christopher.g.dorosky++at++lmco.com)
Date: 08/06/2001 09:54:10
Pete,
First of all, beware if DEFAULT_NUM_BUFFERS. This does not work correctly if
you have a dbase process, or anything besides app,cull,draw.
Here is a simple explanation.
Lets say you have a single variable, some_var.
If you update this in the app, and read it in the cull or draw (or both),
you can potentially get different values, depending
on how fast each process runs. If your app sets it to 1, and the cull
process then read it, you will get 1.
If the app sets it to 2, but the cull for that frame ran fast, and you
already read it, then you will still have 1.
The next time, you can set to 3, and your cull may get the three, thereby
skipping 2.
You can see how this would stink if the variable was a changing pointer.
Where it really stinks if if you have something
in the scene graph, like a geoset, or a vertex array or something, which
CANNOT change in the middle of the process without causing grief.
If you flux, you can be assured of getting frame accurate data.
Let me do short example without vega .
in app.
my_flux = new pfFlux(sizeof(my_struct), 5 (good number of buffers));
my_struct *p = my_flux->getWritableData();
my_struct->a = 1;
my_struct->b = 2; etc....
my_flux->writeComplete();
In cull or draw or wherever you want to READ the value.
CULL.
p1 = (my_struct *)my_flux->getCurrentData();
use p1->a p1->b as you normally would.
You can also do this for multiple processes writing, but you have to be
careful.
Of course, for this to work, my_flux HAS TO BE VISIBLE in all processes,
which means that you either have to create a pointer to it before the
process fork, or you have to pass it as trav data.
If you have doubts about this, print the address of the flux pointer, and
make sure it is the same thing.
It is entirely possible that for what you are doing that you don't need a
flux (i didn't read the whole example) but that the memory isn't visible in
the separate process. This is a different issue. Check you addresses first,
and make sure they make sense in all processes. If they don't then fix that
first.
Christopher Dorosky
Lead Electronic Systems Engineer - Real Time Simulation
Lockheed Martin Missiles and Fire Control - Dallas
christopher.g.dorosky++at++lmco.com
972-603-2349
-----Original Message-----
From: Siedle, Pete [mailto:P.Siedle++at++tees.ac.uk]
Sent: Monday, August 06, 2001 10:42 AM
To: info-performer++at++sgi.com
Subject: pfFlux help needed please
pfHi
I'm starting to look at using pfFlux's to get some code I have working on a
multi-processor platform / app.
I'm having some problems understanding their use and hoped someone might be
able to shed some light on the matter. I've had a look at the Performer
examples and prog guide but they seem too complicated and sparse
(respectively) to enable me to get my head around!
The code I'm working on is for a vega app, by the way, but I'm having to
embed Performer to get the particular functionality I need!
From reading the prog guide I think I get the concept of why a flux is used
(so each process uses it's own version of the data in a flux, and so the
processes don't corrupt the 'singley' held data and thereby cause the app to
fall over).
However, once I create a pfFlux by doing
pfFlux *flux = pfNewFlux(sizeof (udata), PFFLUX_DEFAULT_NUM_BUFFERS,
vgGetSharedArena());
how do I load my data into the flux, change / alter the data in the flux,
etc?
Anyone out there with a link to a simple explanation / example of pfFlux
use?
Thanks for any help, all advice most welcome (as ever :o)
Pete
PS.
To be a little more detailed: my code has a user defined structure which
holds a load of variables for the app; eg
typedef struct
{
pfTexture *tex;
pfTexEnv *tenv;
float x;
float y;
float z;
}udata;
and in my code I do:
udata *mydata;
....
/*create data struc in shared area*/
mydata = vgMalloc(sizeof(udata), vgGetSharedArena());
/*initialise struct data*/
mydata->tex = pfNewTex(vgGetSharedArena());
if(!pfLoadTexFile(mydata->tex, "psLightmap.rgba"))printf("couldn't find
psLightmap.rgba texture to load\n");
mydata->tenv = pfNewTEnv(vgGetSharedArena());
mydata->x = 0.0; mydata->x = 1.0; mydata->x = 2.0;
Anyway, my code uses the above described data struc and works fine if the
app is run in single proc mode, but crashes out in multi-proc mode. I was
told that I need to handle the 'mydata' struct in a multi-proc manner, ie
use pfFlux's!?!?
So my question is how do you get the mydata data into a pfFlux and use it
(if this is the correct terminology)?
-----------------------------------------------------------------------
List Archives, FAQ, FTP: http://www.sgi.com/software/performer/
Open Development Project: http://oss.sgi.com/projects/performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2b29 : Mon Aug 06 2001 - 09:53:26 PDT