--- ray/src/hd/holo.h 1997/11/11 16:59:34 3.5 +++ ray/src/hd/holo.h 2003/02/22 02:07:24 3.20 @@ -1,7 +1,4 @@ -/* Copyright (c) 1997 Silicon Graphics, Inc. */ - -/* SCCSid "$SunId$ SGI" */ - +/* RCSid: $Id: holo.h,v 3.20 2003/02/22 02:07:24 greg Exp $ */ /* * Header file for holodeck programs * @@ -14,21 +11,19 @@ #ifndef HDMAX #define HDMAX 128 /* maximum active holodeck sections */ #endif -#ifndef int2 -#define int2 short + +#ifndef MAXDIRSE +#define MAXDIRSE 32 /* maximum seeks per directory write */ #endif -#ifndef int4 -#define int4 long -#endif #define DCINF (unsigned)((1L<<16)-1) /* special value for infinity */ #define DCLIN (unsigned)(1L<<11) /* linear depth limit */ typedef struct { BYTE r[2][2]; /* ray direction index */ - COLR v; /* value */ - unsigned int2 d; /* depth code */ -} RAYVAL; /* ray value (from second wall) */ + COLR v; /* color value */ + unsigned int2 d; /* depth code (from entry wall) */ +} RAYVAL; /* ray value */ /* * Walls are ordered: X0 X1 X2 WN @@ -71,38 +66,57 @@ typedef struct holo { FVECT xv[3]; /* side vectors (second) */ int2 grid[3]; /* grid resolution (third) */ int fd; /* file descriptor */ - short dirty; /* beam index needs update to file */ + struct { + int s, n; /* dirty section start, length */ + } dirseg[MAXDIRSE+1]; /* dirty beam index segments */ + short dirty; /* number of dirty segments */ double tlin; /* linear range for depth encoding */ - FVECT wn[3]; /* wall normals (derived) */ - double wg[3]; /* wall grid multipliers (derived) */ - double wo[6]; /* wall offsets (derived) */ + FVECT wg[3]; /* wall grid vectors (derived) */ int wi[6]; /* wall super-indices (derived) */ char *priv; /* pointer to private client data */ BEAM **bl; /* beam pointers (memory cache) */ BEAMI bi[1]; /* beam index (extends struct) */ } HOLO; /* holodeck section */ -#define nbeams(hp) (2*((hp)->wi[5]-1)) +typedef struct { + HOLO *h; /* pointer to holodeck */ + int b; /* beam index */ +} HDBEAMI; /* holodeck beam index */ + +#define nbeams(hp) (((hp)->wi[5]-1)<<1) #define biglob(hp) ((hp)->bi) #define blglob(hp) (*(hp)->bl) #define bnrays(hp,i) ((hp)->bl[i]!=NULL ? (hp)->bl[i]->nrm : (hp)->bi[i].nrd) -#define hdflush(hp) (hdfreebeam(hp,0) && hdsync(hp)) +#define hdflush(hp) (hdfreebeam(hp,0), hdsync(hp,0)) +#define hdclobber(hp) (hdkillbeam(hp,0), hdsync(hp,0)) extern HOLO *hdinit(), *hdalloc(); extern BEAM *hdgetbeam(); extern RAYVAL *hdnewrays(); -extern long hdmemuse(), hdfiluse(); +extern unsigned hdmemuse(); +extern long hdfiluse(), hdfilen(), hdallocfrag(); extern double hdray(), hdinter(); extern unsigned hdcode(); +extern int hdfilord(); -extern int hdcachesize; /* target cache size (bytes) */ +#define FF_NEVER 0 /* never free fragments */ +#define FF_WRITE 01 /* free fragment on write */ +#define FF_ALLOC 02 /* free fragment on ray alloc */ +#define FF_READ 04 /* free fragment on read */ +#define FF_KILL 010 /* free fragment on beam kill */ + +extern int hdfragflags; /* tells when to free fragments */ +extern unsigned hdcachesize; /* target cache size (bytes) */ extern unsigned long hdclock; /* holodeck system clock */ extern HOLO *hdlist[HDMAX+1]; /* holodeck pointers (NULL term.) */ extern float hd_depthmap[]; /* depth conversion map */ +extern int hdwg0[6]; /* wall grid 0 index */ +extern int hdwg1[6]; /* wall grid 1 index */ + #define hddepth(hp,dc) ( (dc) >= DCINF ? FHUGE : \ (hp)->tlin * ( (dc) >= DCLIN ? \ hd_depthmap[(dc)-DCLIN] : \ @@ -110,15 +124,15 @@ extern float hd_depthmap[]; /* depth conversion map * #define HOLOFMT "Holodeck" /* file format identifier */ #define HOLOVERS 0 /* file format version number */ -#define HOLOMAGIC (327+HOLOVERS) /* file magic number */ +#define HOLOMAGIC (323+sizeof(long)+8*HOLOVERS) /* file magic number */ /* * A holodeck file consists of an information header terminated by a * blank line, with "FORMAT=Holodeck" somewhere in it. * The first integer after the information header is the * above magic number, which includes the file format version number. - * The first longword after the magic number is the position - * of the SECOND holodeck section, or 0 if there is only one. + * The first longword after the magic number is a pointer to the pointer + * just before the SECOND holodeck section, or 0 if there is only one. * This longword is immediately followed by the first holodeck * section header and directory. * Similarly, every holodeck section in the file is preceeded by