[info-performer] pfdBuilder Bug in Linux - with attachment

Date view Thread view Subject view Author view

From: Dimi (christop++at++fhw.gr)
Date: 04/07/2005 05:39:15


Hi,
I am at the process of creating a loader for a custom format .dsi and I
am porting the existing IRIX loader to Linux.
Although it is running fine in IRIX I experienced unexpected
segmentation faults in Linux.
After a lot of Debuging I found that it crashes in Linux if the
pfdBuilder is called multiple times (over 400),
and that it crashes in pfdBuilder.c line:2538 (function pfdBuild) when
calling pfQuerySys(PFQSYS_GL, &q);
I attached a simple test loader which creates 600 polys by calling 600
times the pfdBuilder. In my machine it crashes after creating 400
polygons at the above stated command.... In IRIX its working fine
though.
I would be gratefull if anyone could have a look at it and acknowledge
this. If its a Bug please correct the pfdBuilder for future releases.

To solve this Bug I am currently also trying to override the pfdBuild
function not to call pfQuerySys(PFQSYS_GL, &q).
Actually this function is NOT needed at all except in the case when you
set the PFDBLDR_GEN_OPENGL_CLAMPED_TEXTURE_COORDS flag in pfdBuilder.Why

is it called there for every frame? I also noticed that calling this
function slows down processing tremendously.

Unfortunately although I link in a sepereate copy of pfdBuilder.c when
creating my libpfdsi.so the functions defined there are not called
because they are
overriden by the corresponding functions in libpfdu which have the same
name. How can I override the functions defined in lipfdu so that my
pfdBuild function is called?

Thanks in advance
Dimi

// The simple Loader. It should create a pfGeode with 600 Quads but
crashes afer calling
// pfdBuild 400 times.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

#include <Performer/pf.h>
#include <Performer/pfutil.h>
#include <Performer/pfdu.h>
#include <Performer/pr/pfGeoSet.h>
#include <Performer/pr/pfMaterial.h>
#include <Performer/pr/pfTexture.h>
#include <Performer/pf/pfNode.h>
#include <Performer/pf/pfGroup.h>
#include <Performer/pf/pfGeode.h>
#include <Performer/pf/pfSCS.h>

extern "C" pfNode *
pfdLoadFile_dsi (char *fileName)
{
    pfGroup *scs;
    pfdGeom *prim;
    pfNode *node;
    int j, i, k, l;

    /* Restore builder to initial state */
    pfdResetBldrState ();
    pfdResetBldrGeometry ();

    scs = new pfGroup ();

    /* allocate primitive buffer with max 300 vertices */
    prim = pfdNewGeom (4);

    for (int i = 0; i < 600; i++)
    {
        printf("\nPolygon %d", i);

        prim->cbind = PFGS_OFF;
        prim->nbind = PFGS_OFF;
        prim->primtype = PFGS_POLYS;
        prim->numTextures = 0;
        prim->flags = 0;
        prim->numVerts = 4;
        for (l = 0; l < PF_MAX_TEXTURES; l++)
            prim->tbind[l] = PFGS_OFF;

        // For each vertex in the polygon
        prim->coords[3].set(i, 0, 0);
        prim->coords[2].set(i, 0, 1);
        prim->coords[1].set(i+1, 0, 1);
        prim->coords[0].set(i+1, 0, 0);

        pfdAddBldrGeom (prim, 1);

        //printf("Exit1 Num of PolyLists\n");
        node = pfdBuild ();
        scs->addChild (node);
        //printf("Exit2 Num of PolyLists \n");
    }

    // Release primitive buffer
    pfdDelGeom (prim);

    return scs;
}

--
Dimi Christopoulos {christop++at++fhw.gr}|
      VR Software Engineer          |Web: www.fhw.gr
Foundation of the Hellenic World    |Tel. (+30) 21 254 03800,(+30) 21 034 22292
      Athens -  Greece              |Fax. (+30) 21 254 03838,(+30) 21 034 22272


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Thu Apr 07 2005 - 05:38:50 PDT