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 */ |
165 |
|
static int runcom(char *cs); |
166 |
|
static int rmfile(char *fn); |
167 |
|
static int mvfile(char *fold, char *fnew); |
168 |
< |
static int next_process(void); |
168 |
> |
static int next_process(int reserve); |
169 |
|
static void wait_process(int all); |
170 |
|
static void finish_process(void); |
171 |
|
static void badvalue(int vc); |
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 */ |
751 |
|
op = addarg(op, "-ds .4"); |
752 |
|
else |
753 |
|
op = addarg(op, "-ds 0"); |
754 |
< |
op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5"); |
754 |
> |
op = addarg(op, "-dt .2 -dc .25 -dr 0 -ss 0 -st .5"); |
755 |
|
if (vdef(AMBFILE)) { |
756 |
|
sprintf(op, " -af %s", vval(AMBFILE)); |
757 |
|
op += strlen(op); |
826 |
|
op = addarg(op, "-ds .2 -dj .9"); |
827 |
|
else |
828 |
|
op = addarg(op, "-ds .3"); |
829 |
< |
op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1"); |
829 |
> |
op = addarg(op, "-dt .1 -dc .5 -dr 1 -ss 1 -st .1"); |
830 |
|
if ( (overture = vint(INDIRECT)) ) { |
831 |
|
sprintf(op, " -ab %d", overture); |
832 |
|
op += strlen(op); |
904 |
|
op = addarg(op, "-ds .1 -dj .9"); |
905 |
|
else |
906 |
|
op = addarg(op, "-ds .2"); |
907 |
< |
op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01"); |
907 |
> |
op = addarg(op, "-dt .05 -dc .75 -dr 3 -ss 16 -st .01"); |
908 |
|
sprintf(op, " -ab %d", overture=vint(INDIRECT)+1); |
909 |
|
op += strlen(op); |
910 |
|
if (vdef(AMBFILE)) { |
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) { |
1260 |
|
char *po |
1261 |
|
) |
1262 |
|
{ |
1263 |
< |
char combuf[PATH_MAX]; |
1263 |
> |
#define do_rpiece (sfile[0]!='\0') |
1264 |
> |
char combuf[5*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[32], sfile[PATH_MAX], *pfile = NULL; |
1268 |
|
char pfopts[128]; |
1269 |
|
char vs[32], *vw; |
1270 |
|
int vn, mult; |
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, "%s_%s_rpsync.txt", |
1320 |
> |
vdef(RAWFILE) ? vval(RAWFILE) : vval(PICTURE), |
1321 |
> |
vs); |
1322 |
> |
strcpy(rppopt, "-PP pfXXXXXX"); |
1323 |
> |
} else { |
1324 |
> |
strcpy(rppopt, "-S 1 -PP pfXXXXXX"); |
1325 |
> |
} |
1326 |
> |
pfile = rppopt + strlen(rppopt) - 8; |
1327 |
> |
if (mktemp(pfile) == NULL) { |
1328 |
> |
if (do_rpiece) { |
1329 |
> |
fprintf(stderr, "%s: cannot create\n", pfile); |
1330 |
> |
quit(1); |
1331 |
> |
} |
1332 |
|
pfile = NULL; |
1333 |
+ |
} |
1334 |
|
} |
1335 |
|
vn = 0; /* do each view */ |
1336 |
|
while ((vw = getview(vn++, vs)) != NULL) { |
1337 |
|
if (sayview) |
1338 |
|
myprintview(vw, stdout); |
1322 |
– |
if (!vs[0]) |
1323 |
– |
sprintf(vs, "%d", vn); |
1339 |
|
sprintf(picfile, "%s_%s.hdr", vval(PICTURE), vs); |
1340 |
|
if (vdef(ZFILE)) |
1341 |
|
sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs); |
1357 |
|
touch(picfile); |
1358 |
|
continue; |
1359 |
|
} |
1360 |
< |
if (next_process()) { /* parallel running? */ |
1360 |
> |
/* parallel running? */ |
1361 |
> |
if (do_rpiece) { |
1362 |
> |
if (rfdt < oct1date || !fdate(sfile)) { |
1363 |
> |
int xdiv = 8+nprocs/3, ydiv = 8+nprocs/3; |
1364 |
> |
if (rfdt >= oct1date) { |
1365 |
> |
fprintf(stderr, |
1366 |
> |
"%s: partial output not created with rpiece\n", rawfile); |
1367 |
> |
quit(1); |
1368 |
> |
} |
1369 |
> |
if (rfdt) { /* start fresh */ |
1370 |
> |
rmfile(rawfile); |
1371 |
> |
rfdt = 0; |
1372 |
> |
} |
1373 |
> |
if (!silent) |
1374 |
> |
printf("\techo %d %d > %s\n", |
1375 |
> |
xdiv, ydiv, sfile); |
1376 |
> |
if ((fp = fopen(sfile, "w")) == NULL) { |
1377 |
> |
fprintf(stderr, "%s: cannot create\n", |
1378 |
> |
sfile); |
1379 |
> |
quit(1); |
1380 |
> |
} |
1381 |
> |
fprintf(fp, "%d %d\n", xdiv, ydiv); |
1382 |
> |
fclose(fp); |
1383 |
> |
} |
1384 |
> |
} else if (next_process(0)) { |
1385 |
|
if (pfile != NULL) |
1386 |
< |
sleep(20); |
1386 |
> |
sleep(10); |
1387 |
|
continue; |
1388 |
< |
} |
1388 |
> |
} else if (!inchild()) |
1389 |
> |
pfile = NULL; |
1390 |
|
/* XXX Remember to call finish_process() */ |
1391 |
|
/* build rpict command */ |
1392 |
< |
if (rfdt >= oct1date) { /* recover */ |
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 */ |
1392 |
> |
if (rfdt >= oct1date) { /* already in progress */ |
1393 |
> |
if (do_rpiece) { |
1394 |
> |
sprintf(combuf, "%s -R %s %s%s %s %s%s%s -o %s %s", |
1395 |
> |
c_rpiece, sfile, rppopt, rep, vw, |
1396 |
> |
res, opts, po, rawfile, oct1name); |
1397 |
> |
while (next_process(1)) { |
1398 |
> |
sleep(10); |
1399 |
> |
combuf[strlen(c_rpiece)+2] = 'F'; |
1400 |
> |
} |
1401 |
> |
} else |
1402 |
> |
sprintf(combuf, "%s%s%s%s%s -ro %s %s", c_rpict, |
1403 |
> |
rep, opts, po, zopt, rawfile, oct1name); |
1404 |
> |
if (runcom(combuf)) /* run rpict/rpiece */ |
1405 |
|
goto rperror; |
1406 |
|
} else { |
1407 |
|
if (overture) { /* run overture calculation */ |
1408 |
|
sprintf(combuf, |
1409 |
< |
"%s%s %s%s -x 64 -y 64 -ps 1 %s > %s", |
1409 |
> |
"%s%s %s%s -x 64 -y 64 -ps 1 %s > %s", |
1410 |
|
c_rpict, rep, vw, opts, |
1411 |
|
oct1name, overfile); |
1412 |
< |
if (runcom(combuf)) { |
1413 |
< |
fprintf(stderr, |
1412 |
> |
if (!do_rpiece || !next_process(0)) { |
1413 |
> |
if (runcom(combuf)) { |
1414 |
> |
fprintf(stderr, |
1415 |
|
"%s: error in overture for view %s\n", |
1416 |
< |
progname, vs); |
1417 |
< |
quit(1); |
1418 |
< |
} |
1416 |
> |
progname, vs); |
1417 |
> |
quit(1); |
1418 |
> |
} |
1419 |
|
#ifndef NULL_DEVICE |
1420 |
< |
rmfile(overfile); |
1420 |
> |
rmfile(overfile); |
1421 |
|
#endif |
1422 |
+ |
} else if (do_rpiece) |
1423 |
+ |
sleep(20); |
1424 |
|
} |
1425 |
< |
sprintf(combuf, "%s%s %s %s%s%s%s %s > %s", |
1426 |
< |
c_rpict, rep, vw, res, opts, po, |
1427 |
< |
zopt, oct1name, rawfile); |
1428 |
< |
if (pfile != NULL && inchild()) { |
1429 |
< |
/* rpict persistent mode */ |
1425 |
> |
if (do_rpiece) { |
1426 |
> |
sprintf(combuf, "%s -F %s %s%s %s %s%s%s -o %s %s", |
1427 |
> |
c_rpiece, sfile, rppopt, rep, vw, |
1428 |
> |
res, opts, po, rawfile, oct1name); |
1429 |
> |
while (next_process(1)) |
1430 |
> |
sleep(10); |
1431 |
> |
} else { |
1432 |
> |
sprintf(combuf, "%s%s %s %s%s%s%s %s > %s", |
1433 |
> |
c_rpict, rep, vw, res, opts, po, |
1434 |
> |
zopt, oct1name, rawfile); |
1435 |
> |
} |
1436 |
> |
if ((pfile != NULL) & !do_rpiece) { |
1437 |
|
if (!silent) |
1438 |
|
printf("\t%s\n", combuf); |
1439 |
|
fflush(stdout); |
1440 |
|
sprintf(combuf, "%s%s %s %s%s%s %s > %s", |
1441 |
< |
c_rpict, rep, rppopt, res, opts, |
1442 |
< |
po, oct1name, rawfile); |
1441 |
> |
c_rpict, rep, rppopt, res, |
1442 |
> |
opts, po, oct1name, rawfile); |
1443 |
|
fp = popen(combuf, "w"); |
1444 |
|
if (fp == NULL) |
1445 |
|
goto rperror; |
1446 |
|
myprintview(vw, fp); |
1447 |
|
if (pclose(fp)) |
1448 |
|
goto rperror; |
1449 |
< |
} else { /* rpict normal mode */ |
1450 |
< |
if (runcom(combuf)) |
1392 |
< |
goto rperror; |
1393 |
< |
} |
1449 |
> |
} else if (runcom(combuf)) |
1450 |
> |
goto rperror; |
1451 |
|
} |
1452 |
+ |
if (do_rpiece) { /* need to finish raw, first */ |
1453 |
+ |
finish_process(); |
1454 |
+ |
wait_process(1); |
1455 |
+ |
/* XXX should check sync file to see if really done? */ |
1456 |
+ |
} |
1457 |
|
if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) { |
1458 |
|
/* build pfilt command */ |
1459 |
|
if (mult > 1) |
1477 |
|
mvfile(rawfile, combuf); |
1478 |
|
} else |
1479 |
|
rmfile(rawfile); |
1480 |
< |
finish_process(); /* exit if child */ |
1480 |
> |
if (do_rpiece) /* done with sync file */ |
1481 |
> |
rmfile(sfile); |
1482 |
> |
else |
1483 |
> |
finish_process(); /* exit if child */ |
1484 |
|
} |
1485 |
|
wait_process(1); /* wait for children to finish */ |
1486 |
< |
if (pfile != NULL) { /* clean up rpict persistent mode */ |
1486 |
> |
if (pfile != NULL) { /* clean up persistent rpict */ |
1487 |
|
RT_PID pid; |
1488 |
|
fp = fopen(pfile, "r"); |
1489 |
|
if (fp != NULL) { |
1497 |
|
rperror: |
1498 |
|
fprintf(stderr, "%s: error rendering view %s\n", progname, vs); |
1499 |
|
quit(1); |
1500 |
+ |
#undef do_rpiece |
1501 |
|
} |
1502 |
|
|
1503 |
|
|
1510 |
|
printf("\ttouch %s\n", fn); |
1511 |
|
if (!nprocs) |
1512 |
|
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 |
1513 |
|
return(setfdate(fn, time((time_t *)NULL))); |
1514 |
|
} |
1515 |
|
|
1557 |
|
|
1558 |
|
#ifdef RHAS_FORK_EXEC |
1559 |
|
static int |
1560 |
< |
next_process(void) /* fork the next process (max. nprocs) */ |
1560 |
> |
next_process(int reserve) /* fork the next process */ |
1561 |
|
{ |
1562 |
|
RT_PID child_pid; |
1563 |
|
|
1568 |
|
progname); |
1569 |
|
quit(1); |
1570 |
|
} |
1571 |
+ |
if (reserve > 0 && children_running >= nprocs-reserve) |
1572 |
+ |
return(0); /* caller holding back process(es) */ |
1573 |
|
if (children_running >= nprocs) |
1574 |
|
wait_process(0); /* wait for someone to finish */ |
1575 |
|
fflush(NULL); /* flush output */ |
1576 |
|
child_pid = fork(); /* split process */ |
1577 |
|
if (child_pid == 0) { /* we're the child */ |
1578 |
|
children_running = -1; |
1579 |
+ |
nprocs = 1; |
1580 |
|
return(0); |
1581 |
|
} |
1582 |
|
if (child_pid > 0) { /* we're the parent */ |
1618 |
|
} |
1619 |
|
#else /* ! RHAS_FORK_EXEC */ |
1620 |
|
static int |
1621 |
< |
next_process(void) |
1621 |
> |
next_process(int reserve) |
1622 |
|
{ |
1623 |
|
return(0); /* cannot start new process */ |
1624 |
|
} |