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

Comparing ray/src/rt/rc3.c (file contents):
Revision 2.17 by greg, Thu Nov 15 15:26:52 2012 UTC vs.
Revision 2.20 by greg, Sun Aug 23 00:17:12 2015 UTC

# Line 265 | Line 265 | set_stdout(const LUENT *le, void *p)
265   }
266  
267  
268 < /* Start child processes if we can */
268 > /* Start child processes if we can (call only once in parent!) */
269   int
270   in_rchild()
271   {
# Line 277 | Line 277 | in_rchild()
277                  if (rval < 0)
278                          error(SYSTEM, "open_process() call failed");
279                  if (rval == 0) {        /* if in child, set up & return true */
280 <                        lu_doall(&modconttab, set_stdout, NULL);
280 >                        lu_doall(&modconttab, &set_stdout, NULL);
281                          lu_done(&ofiletab);
282                          while (nchild--) {      /* don't share other pipes */
283                                  close(kida[nchild].pr.w);
# Line 303 | Line 303 | in_rchild()
303                  kida[nchild].infp = fdopen(kida[nchild].pr.r, "rb");
304                  if (kida[nchild].infp == NULL)
305                          error(SYSTEM, "out of memory in in_rchild()");
306 #ifdef getc_unlocked
307                flockfile(kida[nchild].infp);   /* avoid mutex overhead */
308 #endif
306                  kida[nchild++].nr = 0;  /* mark as available */
307          }
308 + #ifdef getc_unlocked
309 +        for (rval = nchild; rval--; )   /* avoid mutex overhead */
310 +                flockfile(kida[rval].infp);
311 + #endif
312          return(0);                      /* return "false" in parent */
313   }
314  
# Line 409 | Line 410 | parental_loop()
410          flockfile(stdin);               /* avoid lock/unlock overhead */
411   #endif
412          while (getvec(orgdir[2*ninq]) == 0 && getvec(orgdir[2*ninq+1]) == 0) {
413 <                if (orgdir[2*ninq+1][0] == 0.0 &&       /* asking for flush? */
414 <                                (orgdir[2*ninq+1][1] == 0.0) &
415 <                                (orgdir[2*ninq+1][2] == 0.0)) {
416 <                        if (ninq) {                     /* preempt our queue */
417 <                                i = next_child_nq(0);
418 <                                n = ninq;
418 <                                memset(orgdir[2*n++], 0, sizeof(FVECT)*2);
419 <                                n *= sizeof(FVECT)*2;
420 <                                if (writebuf(kida[i].pr.w, (char *)orgdir, n) != n)
421 <                                        error(SYSTEM, "pipe write error");
422 <                                kida[i].r1 = lastray+1;
423 <                                lastray += kida[i].nr = ninq;
424 <                                ninq = 0;
425 <                        }
426 <                        if ((yres <= 0) | (xres <= 0) &&
427 <                                        (lastray+1) % accumulate == 0) {
428 <                                while (next_child_nq(1) >= 0)
429 <                                        ;               /* clear the queue */
430 <                                lastdone = lastray %= accumulate;
431 <                                waitflush = 1;          /* flush next */
432 <                        }
433 <                        put_zero_record(++lastray);
434 <                } else if (++ninq >= qlimit ||
413 >                const int       zero_ray = orgdir[2*ninq+1][0] == 0.0 &&
414 >                                                (orgdir[2*ninq+1][1] == 0.0) &
415 >                                                (orgdir[2*ninq+1][2] == 0.0);
416 >                ninq += !zero_ray;
417 >                                /* Zero ray cannot go in input queue */
418 >                if (zero_ray ? ninq : ninq >= qlimit ||
419                              lastray/accumulate != (lastray+ninq)/accumulate) {
420                          i = next_child_nq(0);           /* manages output */
421                          n = ninq;
422 <                        if (accumulate != 1)            /* request flush? */
422 >                        if (accumulate > 1)             /* need terminator? */
423                                  memset(orgdir[2*n++], 0, sizeof(FVECT)*2);
424                          n *= sizeof(FVECT)*2;           /* send assignment */
425                          if (writebuf(kida[i].pr.w, (char *)orgdir, n) != n)
# Line 450 | Line 434 | parental_loop()
434                          }
435                          ninq = 0;
436                  }
437 +                if (zero_ray) {                         /* put bogus record? */
438 +                        if ((yres <= 0) | (xres <= 1) &&
439 +                                        (lastray+1) % accumulate == 0) {
440 +                                while (next_child_nq(1) >= 0)
441 +                                        ;               /* clear the queue */
442 +                                lastdone = lastray = accumulate-1;
443 +                                waitflush = 1;          /* flush next */
444 +                        }
445 +                        put_zero_record(++lastray);
446 +                }
447                  if (raysleft && !--raysleft)
448                          break;                          /* preemptive EOI */
449          }
# Line 531 | Line 525 | feeder_loop()
525                                  error(SYSTEM, "pipe write error");
526                          kida[i].r1 = lastray+1;
527                          lastray += kida[i].nr = ninq;
534                        ninq = 0;
528                          if (lastray < lastdone)         /* RNUMBER wrapped? */
529                                  lastdone = lastray = 0;
530 +                        ninq = 0;
531                  }
532                  if (raysleft && !--raysleft)
533                          break;                          /* preemptive EOI */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines