Re: pfFlux question

New Message Reply Date view Thread view Subject view Author view

Yair Kurzion (yair++at++polygon.engr.sgi.com)
Thu, 21 Jan 1999 14:34:10 -0800 (PST)


> >There is no direct way to change the buffer size of a Flux. However,
> instead
> >of generating Fluxed GeoSet attributes, you can generate a Fluxed
> GeoSet with
> >normal (not Fluxed) attributes.
> >
> >A Fluxed GeoSet is a multibuffer version of a GeoSet. Each copy of the
> GeoSet
> >has separate pointers to attributes, so you can modify/realloc them in
> an
> >MP-safe way. Of course, you can attach Fluxed GeoSets to a Geode.
> >
> >There are two examples for using fluxed GeoSets:
> >
> >1. pguide/libpf/C++/fluxed_gset.C : Simple example. Changes the number
> of
> > primitives in a Fluxed GeoSet.
>
> I'm still a little confused. I'm looking at the fluxed_gset.C example.
> If I allocate some initial size array for my coordinates inside my flux
> callback function, how would I go back and reallocate more memory later
> on when I have outgrown my list?

Suppose you want to realloc the COORD attribute on a Fluxed GeoSet. Here is
what you should do (similar to the routine change_prim_count in
pguide/libpf/C++/fluxed_gset.C):

1. Get a writable copy of the Fluxed GeoSet. (pfFlux::getWritableData)

   This will return a copy of the multi-buffered GeoSet. You can modify its
   attributes as you please because no other process can see this copy
   until you writeComplete it.

2. Get COORD Attr from the GeoSet you just received. (pfGeoSet::getAttrLists)

   Grab the old Attribute lists. Note that each copy of the Fluxed GeoSet
   should point to a different set of Attribute arrays (see below).

3. Realloc this Attr array to the new size (pfRealloc)

   pfMalloc new attributes if they are NULL or pfRealloc if not NULL.

4. SetAttr on the GeoSet (pfGeoSet::setAttr)

   Store the new attributes on the GeoSet.

5. WriteComplete. (pfFlux::writeComplete)

   Tell Flux that you are done modifying the GeoSet and that it may let other
   processes use it.

When you create a new Fluxed GeoSet as in

   fluxed_gset = new pfFlux(make_fluxed_gset, PFFLUX_DEFAULT_NUM_BUFFERS);

you should write an init routine make_fluxed_gset that allocates new
attribute arrays every time it is invoked. This way the different copies of
the fluxed GeoSet will have different attribute arrays and the above
manipulation will be MP-safe. The sample code in pguide/libpf/C++/fluxed_gset.C
does exactly that.

One more note:
If your GeoSet has an attribute that NEVER needs modification or realloc, you
can use the same array for setting this attribute every time your init routine
is invoked. e.g. If your vertex normals change but the vertices themselves
never change, you can allocate the COORD attribute array only once and use the
same memory for all COORD attributes.

-yair

-- 
\_________  \_____  \__    \__  \_____         Yair Kurzion
\_________  \_____   \__   \__  \_____         yair++at++sgi.com
       \__     \__   \____\__      \__   http://reality.sgi.com/yair
       \__          \__  \__                Work: (650) 933-6502
       \__          \__   \__               Home: (408) 226-9771
       \__          \__    \__             

New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Thu Jan 21 1999 - 14:34:17 PST

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.