ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/ambient.c
(Generate patch)

Comparing ray/src/rt/ambient.c (file contents):
Revision 2.27 by greg, Sat Apr 29 10:51:28 1995 UTC vs.
Revision 2.28 by greg, Sun Apr 30 13:24:36 1995 UTC

# Line 48 | Line 48 | static int  nunflshed = 0;     /* number of unflushed ambi
48   #endif
49   #endif
50   #ifndef SORT_INTVL
51 < #define SORT_INTVL      (SORT_THRESH*8)
51 > #define SORT_INTVL      (SORT_THRESH*32)
52   #endif
53 + #ifndef MAX_SORT_INTVL
54 + #define MAX_SORT_INTVL  (SORT_INTVL<<8)
55 + #endif
56  
57   static unsigned long  ambclock = 0;     /* ambient access clock */
58   static unsigned int  nambvals = 0;      /* number of stored ambient values */
# Line 63 | Line 66 | static long  sortintvl = SORT_INTVL;   /* time until nex
66           * claiming our own memory (copy on write).
67           */
68   #define tracktime       (shm_boundary == NULL || ambfp == NULL)
66 #define checksort()     if (ambclock > lastsort+sortintvl && \
67                        nambvals > SORT_THRESH) sortambvals(0)
69  
70   #define  AMBFLUSH       (BUFSIZ/AMBVALSIZ)
71  
# Line 200 | Line 201 | register RAY  *r;
201                  return;
202          }
203                                                  /* resort memory? */
204 <        checksort();
204 >        sortambvals(0);
205                                                  /* get ambient value */
206          setcolor(acol, 0.0, 0.0, 0.0);
207          d = sumambient(acol, r, rdepth,
# Line 586 | Line 587 | int    always;
587          AMBTREE  oldatrunk;
588          AMBVAL  tav, *tap, *pnext;
589          register int    i, j;
590 +                                        /* see if it's time yet */
591 +        if (!always && (ambclock < lastsort+sortintvl ||
592 +                        nambvals < SORT_THRESH))
593 +                return;
594          /*
595           * The idea here is to minimize memory thrashing
596           * in VM systems by improving reference locality.
# Line 653 | Line 658 | int    always;
658                  }
659                  free((char *)avlist1);
660                  free((char *)avlist2);
661 <                if (sortintvl < SORT_INTVL<<6)
661 >                                                /* compute new sort interval */
662 >                sortintvl = ambclock - lastsort;
663 >                if (sortintvl > MAX_SORT_INTVL)
664 >                        sortintvl = MAX_SORT_INTVL;
665 >                else
666                          sortintvl <<= 1;        /* wait twice as long next */
667   #ifdef DEBUG
668                  eputs("done\n");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines