ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/raypwin.c
Revision: 2.6
Committed: Tue Dec 15 19:13:45 2009 UTC (14 years, 3 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad4R0
Changes since 2.5: +12 -11 lines
Log Message:
Update to return type of ray_psend()

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: raypwin.c,v 2.5 2008/04/17 18:48:09 greg Exp $";
3 #endif
4 /*
5 * raypwin.c - interface for parallel rendering using Radiance (Windows ver)
6 *
7 * External symbols declared in ray.h
8 */
9
10 #include "copyright.h"
11
12 /*
13 * See raypcalls.c for an explanation of these routines.
14 */
15
16 /***** XXX CURRENTLY, THIS IS JUST A COLLECTION OF IMPOTENT STUBS XXX *****/
17
18 #include "ray.h"
19
20 int ray_pnprocs = 0; /* number of child processes */
21 int ray_pnidle = 0; /* number of idle children */
22
23 static RAY queued_ray;
24
25 void
26 ray_pinit( /* initialize ray-tracing processes */
27 char *otnm,
28 int nproc
29 )
30 {
31 ray_pdone(0);
32 ray_init(otnm);
33 ray_popen(nproc);
34 }
35
36
37 int
38 ray_psend( /* add a ray to our send queue */
39 RAY *r
40 )
41 {
42 if (r == NULL)
43 return(0);
44 if (ray_pnidle <= 0)
45 return(0);
46 queued_ray = *r;
47 ray_pnidle = 0;
48 return(1);
49 }
50
51
52 int
53 ray_pqueue( /* queue a ray for computation */
54 RAY *r
55 )
56 {
57 if (r == NULL)
58 return(0);
59 if (ray_pnidle <= 0) {
60 RAY new_ray = *r;
61 *r = queued_ray;
62 queued_ray = new_ray;
63 }
64 samplendx++;
65 rayvalue(r);
66 return(1);
67 }
68
69
70 int
71 ray_presult( /* check for a completed ray */
72 RAY *r,
73 int poll
74 )
75 {
76 if (r == NULL)
77 return(0);
78 if (ray_pnidle <= 0) {
79 *r = queued_ray;
80 samplendx++;
81 rayvalue(r);
82 ray_pnidle = 1;
83 return(1);
84 }
85 return(0);
86 }
87
88
89 void
90 ray_pdone( /* reap children and free data */
91 int freall
92 )
93 {
94 ray_done(freall);
95 ray_pnprocs = ray_pnidle = 0;
96 }
97
98
99 void
100 ray_popen( /* open the specified # processes */
101 int nadd
102 )
103 {
104 if (ray_pnprocs + nadd > 1) {
105 error(WARNING, "only single process supported");
106 nadd = 1 - ray_pnprocs;
107 }
108 ray_pnprocs += nadd;
109 ray_pnidle += nadd;
110 }
111
112
113 void
114 ray_pclose( /* close one or more child processes */
115 int nsub
116 )
117 {
118 if (nsub > ray_pnprocs)
119 nsub = ray_pnprocs;
120 ray_pnprocs -= nsub;
121 if ((ray_pnidle -= nsub) < 0)
122 ray_pnidle = 0;
123 }
124
125
126 void
127 quit(ec) /* make sure exit is called */
128 int ec;
129 {
130 exit(ec);
131 }