Morph perofrmance !

New Message Reply Date view Thread view Subject view Author view

DreamTeam Ltd. (dreamt++at++netvision.net.il)
Thu, 03 Oct 1996 14:57:44 -0700


Dear performer programmers:

How can I improve the perfomance of pfMorph?
-----------------------------------------------

I build a function that tries to decrease the number of coords and normals that
participate in the morph.

We have two sources that need to be morphed. We wrote a routine to find how many vertices
change in the morph procedure.

For example: We had two sources, each with 10,000 tris and we found out that only 4000 tris
actualy change.

We get the sources information from an existing morph and change it.

The following is the routine.

void morph_optimization(pfMorph *morph);
{
/*The function retreives information from a Morph and checks the differance between the
points in the morph. ( Which vertexes changed)*/
     
    float *src[2];
    ushort *isrc[2];
    int floatsPerElt;
    int src_length;
    floatsPerElt=morph->getSrc(0,0, &src[0], &isrc[2], &srcLength)
     
    int number_of_changes=0;

    for (int i=0;i<src_length;i++)
        if ((abs(src[0][i*floatsPerElt]-src[1][i*floatsPerElt])>tol) ||
            (abs(src[0][i*floatsPerElt+1]-src[1][i*floatsPerElt+1])>tol) ||
            (abs(src[0][i*floatsPerElt+2]-src[1][i*floatsPerElt+2])>tol))
            number_of_changes++;
         
     
/*I built a change_list that contains all the indices that the srcs had changed.
The size of the index_vector is the number_of_changes */
   
    ushort *chang_list=(ushort *)pfMalloc(sizeof(ushort)*number_of_changes
                                                                    , arena);
    int j=0;
    for (int i=0;i<src_length;i++)
        if ((abs(src[0][i*floatsPerElt]-src[1][i*floatsPerElt])>tol) ||
            (abs(src[0][i*floatsPerElt+1]-src[1][i*floatsPerElt+1])>tol) ||
            (abs(src[0][i*floatsPerElt+2]-src[1][i*floatsPerElt+2])>tol))
            chang_list[j++]=i;
         
         
/*I copy src to new_src */
    float **new_src=(float **)pfMalloc(sizeof(float*)*2, arena);
    *new_src[0]=(float *)pfMalloc(sizeof(float*)number_of_changes, arena);
    *new_src[1]=(float *)pfMalloc(sizeof(float*)number_of_changes, arena);
     
    for ( j=0;j<2;j++)
       for ( i=0;i<number_of_changes;i++)
          {
            new_src[j][i*floatsPerElt]=src[j][chang_list[i]*floatsPerElt];
            new_src[j][i*floatsPerElt+1]=src[j][chang_list[i]*floatsPerElt+1];
            new_src[j][i*floatsPerElt+2]=src[j][chang_list[i]*floatsPerElt+2];
         }
     
    float *dst=morph->getDst(0);
   
/*I copy src[0] to dst; */
     
    for (i=0;i<src_length*floatsPerElt;i++)
        dst[i]=src[0][i];
         
    ushort **ilist=(ushort**)pfMalloc(sizeof(ushort*)*2, arena);
     
    ilist[0]=change_list;
    ilist[1]=change_list;
     
    int *nlist=(int *)pfMalloc(sizeof(int)*2, arena);
    
    nlist[0]=number_of_changes;
    nlist[1]=number_of_changes;
      
    morph->setAttr(0, 3, number_of_changes, dst, 2, new_src , ilist, nlist);
      
  
}

The morph that I send to this function is :

  int nSph /*the number of vertexes */
  pfVec3 *dst=(pfVec3*) pfMalloc(sizeof(pfVec3)*nSph, arena);
  pfVec3 **src=(pfVec3*) pfMalloc(sizeof(pfVec3*)*2, arena);
  *src[0]=(pfVec3*) pfMalloc(sizeof(pfVec3)*nSph, arena);
  *src[1]=(pfVec3*) pfMalloc(sizeof(pfVec3)*nSph, arena);

  morph->setAttr(1, 3, nSph, dst, 2, srcs, NULL, NULL);

I set the Attribute of the GeoSet that belong to the geode that is child of morph

   gset->setAttr(PFGS_COORD3, PFGS_PER_VERTEX, dst, NULL);

The problem is:

Trying on a single cpu machine (Onyx RE2/1000, Impact Max, Indy r5000 180Mhz):

When I run the program with this function, I can decrease the time of the
application from 14.6 msecs to 0.6 msecs but the the number of frames stays
constant 17 frams per sceond;

the number of tris in the scene is about 24000

How can we improve the frame rate.

Someone from the performer team told us that we need to use CycleBuffer in order to tell the
draw that the morph is already being done and only to do morph on the changes vertices.

Does CycleBuffer work on a single cpu machine ?

Why doesn't the frame rate improve, when the app decreases so much ?

Please Help

Tnx

Yotam Froynd
Programmer
DreamTeam Ltd.
Tel: +972-9-559855
Fax: +972-9-559615
Email: dreamt++at++netvision.net.il
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:53:43 PDT

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