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

Comparing ray/src/util/rad.c (file contents):
Revision 2.92 by greg, Mon Feb 9 16:41:29 2009 UTC vs.
Revision 2.97 by greg, Fri May 28 17:29:14 2010 UTC

# Line 116 | Line 116 | int    sayview = 0;            /* print view out */
116   char    *rvdevice = NULL;       /* rvu output device */
117   char    *viewselect = NULL;     /* specific view only */
118  
119 + #define DEF_RPICT_PATH  "rpict"         /* default rpict path */
120 +
121                                  /* command paths */
122   char    c_oconv[256] = "oconv";
123   char    c_mkillum[256] = "mkillum";
124   char    c_rvu[256] = "rvu";
125 < char    c_rpict[256] = "rpict";
125 > char    c_rpict[256] = DEF_RPICT_PATH;
126 > char    c_rpiece[] = "rpiece";
127   char    c_pfilt[256] = "pfilt";
128  
129   int     overture = 0;           /* overture calculation needed */
# Line 218 | Line 221 | main(
221          if (i >= argc)
222                  goto userr;
223          rifname = argv[i];
221                                /* check command-line options */
222        if ((nprocs > 1) & (viewselect != NULL) & (rvdevice == NULL))
223                nprocs = 1;
224                                  /* assign Radiance root file name */
225          rootname(radname, rifname);
226                                  /* load variable values */
# Line 1158 | Line 1158 | getview(                               /* get view n, or NULL if none */
1158                          goto numview;
1159                  }
1160                  if (viewselect[0] == '-') {     /* already specified */
1161 <                        if (vn != NULL) *vn = '\0';
1161 >                        if (vn != NULL)
1162 >                                strcpy(vn, "0");
1163                          return(viewselect);
1164                  }
1165                  if (vn != NULL) {
# Line 1259 | Line 1260 | rpict(                         /* run rpict and pfilt for each view */
1260          char    *po
1261   )
1262   {
1263 <        char    combuf[PATH_MAX];
1263 > #define do_rpiece       (sfile[0]!='\0')
1264 >        char    combuf[4*PATH_MAX+512];
1265          char    rawfile[PATH_MAX], picfile[PATH_MAX];
1266          char    zopt[PATH_MAX+4], rep[PATH_MAX+16], res[32];
1267 <        char    rppopt[128], *pfile = NULL;
1267 >        char    rppopt[128], sfile[64], *pfile = NULL;
1268          char    pfopts[128];
1269          char    vs[32], *vw;
1270          int     vn, mult;
# Line 1309 | Line 1311 | rpict(                         /* run rpict and pfilt for each view */
1311                          badvalue(REPORT);
1312          }
1313                                          /* set up parallel rendering */
1314 <        if ((nprocs > 1) & (!vdef(ZFILE))) {
1315 <                strcpy(rppopt, "-S 1 -PP pfXXXXXX");
1316 <                pfile = rppopt+9;
1317 <                if (mktemp(pfile) == NULL)
1314 >        sfile[0] = '\0';
1315 >        if ((nprocs > 1) & !touchonly & !vdef(ZFILE) &&
1316 >                                        getview(0, vs) != NULL) {
1317 >                if (!strcmp(c_rpict, DEF_RPICT_PATH) &&
1318 >                                getview(1, NULL) == NULL) {
1319 >                        sprintf(sfile, "rpsync_%s.txt", vs);
1320 >                        strcpy(rppopt, "-PP pfXXXXXX");
1321 >                } else {
1322 >                        strcpy(rppopt, "-S 1 -PP pfXXXXXX");
1323 >                }
1324 >                pfile = rppopt + strlen(rppopt) - 8;
1325 >                if (mktemp(pfile) == NULL) {
1326 >                        if (do_rpiece) {
1327 >                                fprintf(stderr, "%s: cannot create\n", pfile);
1328 >                                quit(1);
1329 >                        }
1330                          pfile = NULL;
1331 +                }
1332          }
1333          vn = 0;                                 /* do each view */
1334          while ((vw = getview(vn++, vs)) != NULL) {
1335                  if (sayview)
1336                          myprintview(vw, stdout);
1322                if (!vs[0])
1323                        sprintf(vs, "%d", vn);
1337                  sprintf(picfile, "%s_%s.hdr", vval(PICTURE), vs);
1338                  if (vdef(ZFILE))
1339                          sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs);
# Line 1342 | Line 1355 | rpict(                         /* run rpict and pfilt for each view */
1355                                  touch(picfile);
1356                          continue;
1357                  }
1358 <                if (next_process()) {           /* parallel running? */
1358 >                                                /* parallel running? */
1359 >                if (do_rpiece) {
1360 >                        if (rfdt < oct1date || !fdate(sfile)) {
1361 >                                int     xdiv = 8+nprocs/3, ydiv = 8+nprocs/3;
1362 >                                rfdt = 0;               /* start fresh */
1363 >                                if (!silent)
1364 >                                        printf("\techo %d %d > %s\n",
1365 >                                                        xdiv, ydiv, sfile);
1366 >                                if ((fp = fopen(sfile, "w")) == NULL) {
1367 >                                        fprintf(stderr, "%s: cannot create\n",
1368 >                                                        sfile);
1369 >                                        quit(1);
1370 >                                }
1371 >                                fprintf(fp, "%d %d\n", xdiv, ydiv);
1372 >                                fclose(fp);
1373 >                        }
1374 >                } else if (next_process()) {
1375                          if (pfile != NULL)
1376 <                                sleep(20);
1376 >                                sleep(10);
1377                          continue;
1378 <                }
1378 >                } else if (!inchild())
1379 >                        pfile = NULL;
1380                  /* XXX Remember to call finish_process() */
1381                                                  /* build rpict command */
1382 <                if (rfdt >= oct1date) {         /* recover */
1383 <                        sprintf(combuf, "%s%s%s%s%s -ro %s %s", c_rpict,
1384 <                                rep, opts, po, zopt, rawfile, oct1name);
1385 <                        if (runcom(combuf))     /* run rpict */
1382 >                if (rfdt >= oct1date) {         /* already in progress */
1383 >                        if (do_rpiece) {
1384 >                                sprintf(combuf, "%s -R %s %s%s %s %s%s%s -o %s %s",
1385 >                                                c_rpiece, sfile, rppopt, rep, vw,
1386 >                                                res, opts, po, rawfile, oct1name);
1387 >                                while (children_running < nprocs-1 &&
1388 >                                                        next_process()) {
1389 >                                        sleep(10);
1390 >                                        combuf[strlen(c_rpiece)+2] = 'F';
1391 >                                }
1392 >                        } else
1393 >                                sprintf(combuf, "%s%s%s%s%s -ro %s %s", c_rpict,
1394 >                                        rep, opts, po, zopt, rawfile, oct1name);
1395 >                        if (runcom(combuf))     /* run rpict/rpiece */
1396                                  goto rperror;
1397                  } else {
1398                          if (overture) {         /* run overture calculation */
# Line 1360 | Line 1400 | rpict(                         /* run rpict and pfilt for each view */
1400                                  "%s%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1401                                                  c_rpict, rep, vw, opts,
1402                                                  oct1name, overfile);
1403 +                                if (do_rpiece)
1404 +                                        while (children_running < nprocs-1 &&
1405 +                                                        next_process())
1406 +                                                sleep(5);
1407                                  if (runcom(combuf)) {
1408                                          fprintf(stderr,
1409                                          "%s: error in overture for view %s\n",
1410                                                  progname, vs);
1411                                          quit(1);
1412                                  }
1413 +                                if (do_rpiece) {
1414 +                                        finish_process();
1415 +                                        wait_process(1);
1416 +                                }
1417   #ifndef NULL_DEVICE
1418                                  rmfile(overfile);
1419   #endif
1420                          }
1421 <                        sprintf(combuf, "%s%s %s %s%s%s%s %s > %s",
1422 <                                        c_rpict, rep, vw, res, opts, po,
1423 <                                        zopt, oct1name, rawfile);
1424 <                        if (pfile != NULL && inchild()) {
1425 <                                                /* rpict persistent mode */
1421 >                        if (do_rpiece) {
1422 >                                sprintf(combuf, "%s -F %s %s%s %s %s%s%s -o %s %s",
1423 >                                                c_rpiece, sfile, rppopt, rep, vw,
1424 >                                                res, opts, po, rawfile, oct1name);
1425 >                                while (children_running < nprocs-1 &&
1426 >                                                        next_process())
1427 >                                        sleep(10);
1428 >                        } else {
1429 >                                sprintf(combuf, "%s%s %s %s%s%s%s %s > %s",
1430 >                                                c_rpict, rep, vw, res, opts, po,
1431 >                                                zopt, oct1name, rawfile);
1432 >                        }
1433 >                        if ((pfile != NULL) & !do_rpiece) {
1434                                  if (!silent)
1435                                          printf("\t%s\n", combuf);
1436                                  fflush(stdout);
1437                                  sprintf(combuf, "%s%s %s %s%s%s %s > %s",
1438 <                                                c_rpict, rep, rppopt, res, opts,
1439 <                                                po, oct1name, rawfile);
1438 >                                                c_rpict, rep, rppopt, res,
1439 >                                                opts, po, oct1name, rawfile);
1440                                  fp = popen(combuf, "w");
1441                                  if (fp == NULL)
1442                                          goto rperror;
1443                                  myprintview(vw, fp);
1444                                  if (pclose(fp))
1445                                          goto rperror;
1446 <                        } else {                /* rpict normal mode */
1447 <                                if (runcom(combuf))
1392 <                                        goto rperror;
1393 <                        }
1446 >                        } else if (runcom(combuf))
1447 >                                goto rperror;
1448                  }
1449 +                if (do_rpiece) {                /* need to finish raw, first */
1450 +                        finish_process();
1451 +                        wait_process(1);
1452 +                        /* XXX should check sync file to see if really done? */
1453 +                }
1454                  if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) {
1455                                                  /* build pfilt command */
1456                          if (mult > 1)
# Line 1415 | Line 1474 | rpict(                         /* run rpict and pfilt for each view */
1474                          mvfile(rawfile, combuf);
1475                  } else
1476                          rmfile(rawfile);
1477 <                finish_process();               /* exit if child */
1477 >                if (do_rpiece)                  /* done with sync file */
1478 >                        rmfile(sfile);
1479 >                else
1480 >                        finish_process();       /* exit if child */
1481          }
1482          wait_process(1);                /* wait for children to finish */
1483 <        if (pfile != NULL) {            /* clean up rpict persistent mode */
1483 >        if (pfile != NULL) {            /* clean up persistent rpict */
1484                  RT_PID  pid;
1485                  fp = fopen(pfile, "r");
1486                  if (fp != NULL) {
# Line 1432 | Line 1494 | rpict(                         /* run rpict and pfilt for each view */
1494   rperror:
1495          fprintf(stderr, "%s: error rendering view %s\n", progname, vs);
1496          quit(1);
1497 + #undef do_rpiece
1498   }
1499  
1500  
# Line 1444 | Line 1507 | touch(                 /* update a file */
1507                  printf("\ttouch %s\n", fn);
1508          if (!nprocs)
1509                  return(0);
1447 #ifdef notused
1448        if (access(fn, F_OK) == -1)             /* create it */
1449                if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1)
1450                        return(-1);
1451 #endif
1510          return(setfdate(fn, time((time_t *)NULL)));
1511   }
1512  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines