1 /*
2  * Copyright (C) 1997-2005, R3vis Corporation.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17  * USA, or visit http://www.gnu.org/copyleft/lgpl.html.
18  *
19  * Original Contributor:
20  *   Wes Bethel, R3vis Corporation, Marin County, California
21  * Additional Contributor(s):
22  *
23  * The OpenRM project is located at http://openrm.sourceforge.net/.
24  */
25 /*
26  * $Id: rmmultis.h,v 1.9 2005/06/26 18:54:16 wes Exp $
27  * Version: $Name: OpenRM-1-6-0-2-RC2 $
28  * $Revision: 1.9 $
29  * $Log: rmmultis.h,v $
30  * Revision 1.9  2005/06/26 18:54:16  wes
31  * New opcode consolidating  local state and OpenGL attrib stack push/pop.
32  *
33  * Revision 1.8  2005/06/06 02:04:29  wes
34  * Lots of small additions to clean up compiler warnings.
35  *
36  * Revision 1.7  2005/02/24 16:17:25  wes
37  * Added support for fbClears to be set at the RMpipe level. Apps can
38  * still set them at the RMnode level if desired for fine-grained control.
39  *
40  * Revision 1.6  2005/02/19 16:22:50  wes
41  * Distro sync and consolidation.
42  *
43  * Revision 1.5  2005/01/23 17:04:03  wes
44  * Copyright update to 2005.
45  *
46  * Revision 1.4  2004/01/16 16:46:09  wes
47  * Updated copyright line for 2004.
48  *
49  * Revision 1.3  2003/04/05 14:09:31  wes
50  * Added prototypes for private RMpipe routines that clean up interstage buffers.
51  *
52  * Revision 1.2  2003/02/02 02:07:15  wes
53  * Updated copyright to 2003.
54  *
55  * Revision 1.1.1.1  2003/01/28 02:15:23  wes
56  * Manual rebuild of rm150 repository.
57  *
58  * Revision 1.6  2002/08/29 22:20:32  wes
59  *
60  * Massive upgrade to accommodate dynamic object reallocation within
61  * the component manager, and within the context cache. Use the
62  * debug #define DEBUG_LEVEL DEBUG_REALLOC_TRACE to get a printf
63  * whenever a realloc occurs. With this upgrade, there are no
64  * OpenRM limits on the size of the scene graph. There will be external
65  * limits, such as the amount of RAM and the amount of space available
66  * to your OpenGL implementation.
67  *
68  * Revision 1.5  2002/08/17 15:12:19  wes
69  * Added #defines for render-stage pre- and post-traversal callbacks.
70  *
71  * Revision 1.4  2002/06/17 01:04:10  wes
72  * Increased amount of space allocated for matrices to be the same
73  * as RM_COMPONENT_POOL_SIZE. This is overkill.
74  *
75  * Revision 1.3  2002/06/02 15:15:34  wes
76  * Added RMstateCache code to help eliminate the number of state changes
77  * made during the render traversal. The RMstateCache tracks
78  * the actual OpenGL rendering state w/o the need for querying OpenGL
79  * directly, and  is queried by draw code that then decides if any
80  * real state changes are required given the configuration of data
81  * within an RMprimitive.
82  *
83  * Revision 1.2  2002/04/30 19:32:47  wes
84  * Updated copyright dates.
85  *
86  * Revision 1.1  2001/03/31 17:12:11  wes
87  * v1.4.0-alpha-2 checkin.
88  *
89  */
90 
91 #ifndef __rmmtrend_h
92 #define __rmmtrend_h
93 
94 #include "barrier.h"
95 
96 /* 8/11/02 wes. MT_NUM_MATRIX_PAIRS is set to be RM_COMPONENT_POOL_SIZE
97    inside the code in rmmtview.c via the extern global variable */
98 /* #define MT_NUM_MATRIX_PAIRS RM_COMPONENT_POOL_SIZE */
99 #define MT_MAX_STATE_STACK_SIZE 16
100 
101 
102 typedef enum
103 {
104     MT_NOOP                      = 0x0,
105     MT_PUSHATTRIB                = 0x01,
106     MT_POPATTRIB                 = 0x02,
107     MT_PUSHLOAD_MODELVIEW_MATRIX = 0x03,
108     MT_POP_MODELVIEW_MATRIX      = 0x04,
109     MT_PUSHLOAD_PROJ_MATRIX      = 0x05,
110     MT_POP_PROJ_MATRIX           = 0x06,
111     MT_PUSHLOAD_TEXTURE_MATRIX   = 0x07,
112     MT_POP_TEXTURE_MATRIX        = 0x08,
113     MT_DRAW                      = 0x09,
114     MT_FBCLEAR                   = 0x0A,
115     MT_PUSH_TEXTPROPS            = 0x0B,
116     MT_POP_TEXTPROPS             = 0x0C,
117     MT_PUSH_STATE                = 0x0D,
118     MT_POP_STATE                 = 0x0E,
119     MT_PRETRAVERSAL_FUNC         = 0x0F,
120     MT_POSTTRAVERSAL_FUNC        = 0x10,
121     MT_PUSH_STATE_ATTRIB         = 0x11, /* June 2005 */
122     MT_POP_STATE_ATTRIB          = 0x12
123 } RMdisplayListOpcode;
124 
125 typedef struct
126 {
127     int nOpCodes, maxOpCodes;
128     RMdisplayListOpcode *opCodes;
129 
130     int nIndices, maxIndices;
131     int *indices;
132 
133     int nMatrices, maxMatrices;
134     RMmatrix *matrices;
135 } RMdisplayList;
136 
137 typedef struct
138 {
139     /* double buffered, stereo-capable multipass display list buffers. */
140     RMdisplayList *globals[2];
141     RMdisplayList *opaque3D[2], *transparent3D[2], *opaque2D[2];
142     RMdisplayList *rightGlobals[2];
143     RMdisplayList *rightOpaque3D[2], *rightTransparent3D[2], *rightOpaque2D[2];
144 } RMmultipassDisplayList;
145 
146 #define THREAD_WORK 0
147 #define THREAD_QUIT 1
148 
149 typedef struct
150 {
151     RMpipe *p;
152     RMnode *n;
153     int     commandOpcode;
154     int     frameNumber;
155 
156     RMmatrix *initModel;
157     RMmatrix *initView;
158     RMmatrix *initProjection;
159     RMmatrix *initTexture;
160 
161     barrier_t *one, *two;
162 } RMthreadArgs;
163 
164 typedef struct
165 {
166     int           nThreads;
167     RMthread     *threadIDs;
168     RMthreadArgs *args;
169 } RMmultiStageThreadControl;
170 
171 /*#define MTWORKPARMS() (RMpipe *p, RMnode *n, RMstate *s, RMdisplayList *mt, int indx, RMstateCache *rsc) */
172 #define MTWORKPARMS() (RMpipe *p, RMnode *n, RMstate *s, int indx, RMstateCache *rsc)
173 
174 void           private_rmPipeDisplayListsNew(RMpipe *p);
175 RMdisplayList *private_rmPipeDisplayListNew(int nOpcodes, int nIndices, int nMatrices);
176 
177 void           private_rmPipeDisplayListDelete(RMdisplayList *t);
178 void           private_rmPipeDisplayListsDelete(RMpipe *p);
179 
180 void           private_rmPipeDisplayListsInit(RMpipe *p, int evenOdd);
181 
182 void           private_rmView (RMpipe *p, RMnode *n, int frameNumber, RMmatrix *initModelMatrix, RMmatrix *initViewMatrix, RMmatrix *initProjectionMatrix, RMmatrix *initTextureMatrix);
183 
184 void           private_rmRender (RMpipe *p, int frameNumber);
185 
186 void          *private_rmViewThreadFunc(void *args);
187 void          *private_rmRenderThreadFunc(void *args);
188 
189 #define private_rmSelectEvenOddBuffer(a) (((a) & 1) ? 1 : 0)
190 
191 #endif
192 /* EOF */
193