ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/holo.h
(Generate patch)

Comparing ray/src/hd/holo.h (file contents):
Revision 3.1 by gregl, Fri Oct 31 10:23:29 1997 UTC vs.
Revision 3.25 by greg, Thu Sep 9 01:06:19 2004 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1997 Silicon Graphics, Inc. */
2 <
3 < /* SCCSid "$SunId$ SGI" */
4 <
1 > /* RCSid: $Id$ */
2   /*
3   * Header file for holodeck programs
4   *
5   *      9/29/97 GWLarson
6   */
7 + #ifndef _RAD_HOLO_H_
8 + #define _RAD_HOLO_H_
9  
10   #include "standard.h"
11   #include "color.h"
12  
13 + #ifdef __cplusplus
14 + extern "C" {
15 + #endif
16 +
17   #ifndef HDMAX
18   #define HDMAX           128     /* maximum active holodeck sections */
19   #endif
20 < #ifndef int2
21 < #define int2    short
20 >
21 > #ifndef MAXDIRSE
22 > #define MAXDIRSE        32      /* maximum seeks per directory write */
23   #endif
20 #ifndef int4
21 #define int4    long
22 #endif
24  
25   #define DCINF   (unsigned)((1L<<16)-1)  /* special value for infinity */
26   #define DCLIN   (unsigned)(1L<<11)      /* linear depth limit */
27  
28   typedef struct {
29          BYTE    r[2][2];        /* ray direction index */
30 <        COLR    v;              /* value */
31 <        unsigned int2   d;      /* depth code */
32 < } RAYVAL;               /* ray value (from second wall) */
30 >        COLR    v;              /* color value */
31 >        uint16  d;              /* depth code (from entry wall) */
32 > } RAYVAL;               /* ray value */
33  
34   /*
35   * Walls are ordered:           X0      X1      X2      WN
# Line 45 | Line 46 | typedef struct {
46   typedef struct {
47          short   w;              /* wall number */
48          short   i[2];           /* index on wall grid */
49 < } BCOORD[2];            /* beam grid coordinates */
49 > } GCOORD;               /* grid coordinates (two for beam) */
50  
51   typedef struct {
52 <        unsigned int4   nrd;    /* number of beam rays bundled on disk */
53 <        long    fo;             /* position in file */
52 >        uint32  nrd;            /* number of beam rays bundled on disk */
53 >        off_t   fo;             /* position in file */
54   } BEAMI;                /* beam index */
55  
56   typedef struct {
57 <        unsigned int4   nrm;    /* number of beam rays bundled in memory */
57 >        uint32  nrm;            /* number of beam rays bundled in memory */
58          unsigned long   tick;   /* clock tick for LRU replacement */
59   } BEAM;                 /* followed by nrm RAYVAL's */
60  
61 < #define hdbray(bp)      (RAYVAL *)((bp)+1)
61 > #define hdbray(bp)      ((RAYVAL *)((bp)+1))
62   #define hdbsiz(nr)      (sizeof(BEAM)+(nr)*sizeof(RAYVAL))
63  
64   typedef struct {
65          FVECT   orig;           /* prism origin (first) */
66          FVECT   xv[3];          /* side vectors (second) */
67 <        int2    grid[3];        /* grid resolution (third) */
67 >        int16   grid[3];        /* grid resolution (third) */
68   } HDGRID;               /* holodeck section grid (must match HOLO struct) */
69  
70   typedef struct holo {
71          FVECT   orig;           /* prism origin (first) */
72          FVECT   xv[3];          /* side vectors (second) */
73 <        int2    grid[3];        /* grid resolution (third) */
73 >        int16   grid[3];        /* grid resolution (third) */
74          int     fd;             /* file descriptor */
75 <        short   dirty;          /* beam index needs update to file */
75 >        struct {
76 >                int     s, n;           /* dirty section start, length */
77 >        } dirseg[MAXDIRSE+1];   /* dirty beam index segments */
78 >        short   dirty;          /* number of dirty segments */
79          double  tlin;           /* linear range for depth encoding */
80 <        FVECT   wn[3];          /* wall normals (derived) */
77 <        double  wo[6];          /* wall offsets (derived) */
78 <        FVECT   gv[3][2];       /* grid coordinate vectors (derived) */
80 >        FVECT   wg[3];          /* wall grid vectors (derived) */
81          int     wi[6];          /* wall super-indices (derived) */
82          char    *priv;          /* pointer to private client data */
83          BEAM    **bl;           /* beam pointers (memory cache) */
84          BEAMI   bi[1];          /* beam index (extends struct) */
85   } HOLO;                 /* holodeck section */
86  
87 < #define nbeams(hp)      (2*((hp)->wi[5]-1))
87 > typedef struct {
88 >        HOLO    *h;             /* pointer to holodeck */
89 >        int     b;              /* beam index */
90 > } HDBEAMI;              /* holodeck beam index */
91 >
92 > #define nbeams(hp)      (((hp)->wi[5]-1)<<1)
93   #define biglob(hp)      ((hp)->bi)
94   #define blglob(hp)      (*(hp)->bl)
95  
96   #define bnrays(hp,i)    ((hp)->bl[i]!=NULL ? (hp)->bl[i]->nrm : (hp)->bi[i].nrd)
97  
98 < #define hdflush(hp)     (hdfreebeam(hp,0) && hdsync(hp))
98 > #define hdflush(hp)     (hdfreebeam(hp,0), hdsync(hp,0))
99 > #define hdclobber(hp)   (hdkillbeam(hp,0), hdsync(hp,0))
100  
101 < extern HOLO     *hdinit();
101 > /*
102 > extern HOLO     *hdinit(), *hdalloc();
103   extern BEAM     *hdgetbeam();
104   extern RAYVAL   *hdnewrays();
105 < extern long     hdmemuse(), hdfiluse();
105 > extern unsigned hdmemuse();
106 > extern off_t    hdfiluse(), hdfilen(), hdallocfrag();
107   extern double   hdray(), hdinter();
108   extern unsigned hdcode();
109 + extern int      hdfilord();
110 + */
111  
112 < extern int      hdcachesize;            /* target cache size (bytes) */
112 > #define FF_NEVER        0               /* never free fragments */
113 > #define FF_WRITE        01              /* free fragment on write */
114 > #define FF_ALLOC        02              /* free fragment on ray alloc */
115 > #define FF_READ         04              /* free fragment on read */
116 > #define FF_KILL         010             /* free fragment on beam kill */
117 >
118 > extern int      hdfragflags;            /* tells when to free fragments */
119 > extern unsigned hdcachesize;            /* target cache size (bytes) */
120   extern unsigned long    hdclock;        /* holodeck system clock */
121   extern HOLO     *hdlist[HDMAX+1];       /* holodeck pointers (NULL term.) */
122  
123   extern float    hd_depthmap[];          /* depth conversion map */
124  
125 + extern int      hdwg0[6];               /* wall grid 0 index */
126 + extern int      hdwg1[6];               /* wall grid 1 index */
127 +
128   #define hddepth(hp,dc)  ( (dc) >= DCINF ? FHUGE : \
129                                  (hp)->tlin * ( (dc) >= DCLIN ? \
130                                          hd_depthmap[(dc)-DCLIN] : \
# Line 110 | Line 132 | extern float   hd_depthmap[];          /* depth conversion map *
132  
133   #define HOLOFMT         "Holodeck"      /* file format identifier */
134   #define HOLOVERS        0               /* file format version number */
135 < #define HOLOMAGIC       (327+HOLOVERS)  /* file magic number */
135 > #define HOLOMAGIC       (323+sizeof(off_t)+8*HOLOVERS)  /* file magic number */
136  
137   /*
138   * A holodeck file consists of an information header terminated by a
139   * blank line, with "FORMAT=Holodeck" somewhere in it.
140   * The first integer after the information header is the
141   * above magic number, which includes the file format version number.
142 < * The first longword after the magic number is the position
143 < * of the SECOND holodeck section, or 0 if there is only one.
142 > * The first longword after the magic number is a pointer to the pointer
143 > * just before the SECOND holodeck section, or 0 if there is only one.
144   * This longword is immediately followed by the first holodeck
145   * section header and directory.
146   * Similarly, every holodeck section in the file is preceeded by
# Line 130 | Line 152 | extern float   hd_depthmap[];          /* depth conversion map *
152   * in future versions, but we thought this would be best for paging speed
153   * in our initial implementation.
154   */
155 +
156 +        /* clumpbeams.c */
157 + extern void clumpbeams(HOLO *hp, int maxcnt, int maxsiz,
158 + int (*cf)(HOLO *hp, int *bqueue, int bqlen));
159 +        /* holo.c */
160 + extern void hdcompgrid(HOLO *hp);
161 + extern int hdbcoord(GCOORD gc[2], HOLO *hp, int i);
162 + extern int hdbindex(HOLO *hp, GCOORD gc[2]);
163 + extern void hdcell(FVECT cp[4], HOLO *hp, GCOORD *gc);
164 + extern int hdlseg(int   lseg[2][3], HOLO        *hp, GCOORD     gc[2]);
165 + extern unsigned int hdcode(HOLO *hp, double d);
166 + extern void hdgrid( FVECT gp, HOLO *hp, FVECT wp);
167 + extern void hdworld(FVECT wp, HOLO *hp, FVECT gp);
168 + extern double hdray(FVECT ro, FVECT rd, HOLO *hp, GCOORD gc[2], BYTE r[2][2]);
169 + extern double hdinter(GCOORD gc[2], BYTE r[2][2], double *ed, HOLO *hp,
170 +                FVECT ro, FVECT rd);
171 +        /* holofile.c */
172 + extern HOLO * hdinit(int fd, HDGRID *hproto);
173 + extern void hddone(HOLO *hp);
174 + extern int hdsync(HOLO *hp, int all);
175 + extern off_t hdfilen(int fd);
176 + extern off_t hdfiluse(int fd);
177 + extern RAYVAL * hdnewrays(HOLO *hp, int i, int nr);
178 + extern BEAM * hdgetbeam(HOLO *hp, int i);
179 + extern void hdloadbeams(HDBEAMI *hb, int n, void (*bf)(BEAM *bp, HDBEAMI *hb));
180 + extern int hdfreebeam(HOLO *hp, int i);
181 + extern int hdfreefrag(HOLO *hp, int i);
182 + extern int hdfragOK(int fd, int *listlen, int32 *listsiz);
183 + extern int hdkillbeam(HOLO *hp, int i);
184 +
185 +
186 + #ifdef __cplusplus
187 + }
188 + #endif
189 + #endif /* _RAD_HOLO_H_ */
190 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines