VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_client.c@ 21308

Last change on this file since 21308 was 21308, checked in by vboxsync, 15 years ago

crOpenGL: use host side VBO when possible

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 11.7 KB
Line 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#include "packspu.h"
8#include "cr_packfunctions.h"
9#include "cr_glstate.h"
10#include "packspu_proto.h"
11
12void PACKSPU_APIENTRY packspu_FogCoordPointerEXT( GLenum type, GLsizei stride, const GLvoid *pointer )
13{
14#if CR_ARB_vertex_buffer_object
15 GET_CONTEXT(ctx);
16 if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
17 if (pack_spu.swap)
18 crPackFogCoordPointerEXTSWAP( type, stride, pointer );
19 else
20 crPackFogCoordPointerEXT( type, stride, pointer );
21 }
22#endif
23 crStateFogCoordPointerEXT( type, stride, pointer );
24}
25
26void PACKSPU_APIENTRY packspu_ColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
27{
28#if CR_ARB_vertex_buffer_object
29 GET_CONTEXT(ctx);
30 if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
31 if (pack_spu.swap)
32 crPackColorPointerSWAP( size, type, stride, pointer );
33 else
34 crPackColorPointer( size, type, stride, pointer );
35 }
36#endif
37 crStateColorPointer( size, type, stride, pointer );
38}
39
40void PACKSPU_APIENTRY packspu_SecondaryColorPointerEXT( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
41{
42#if CR_ARB_vertex_buffer_object
43 GET_CONTEXT(ctx);
44 if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
45 if (pack_spu.swap)
46 crPackSecondaryColorPointerEXTSWAP( size, type, stride, pointer );
47 else
48 crPackSecondaryColorPointerEXT( size, type, stride, pointer );
49 }
50#endif
51 crStateSecondaryColorPointerEXT( size, type, stride, pointer );
52}
53
54void PACKSPU_APIENTRY packspu_VertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
55{
56#if CR_ARB_vertex_buffer_object
57 GET_CONTEXT(ctx);
58 CRASSERT(ctx->clientState->extensions.ARB_vertex_buffer_object);
59 if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
60 if (pack_spu.swap)
61 crPackVertexPointerSWAP( size, type, stride, pointer );
62 else
63 crPackVertexPointer( size, type, stride, pointer );
64 }
65#endif
66 crStateVertexPointer( size, type, stride, pointer );
67}
68
69void PACKSPU_APIENTRY packspu_TexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
70{
71#if CR_ARB_vertex_buffer_object
72 GET_CONTEXT(ctx);
73 if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
74 if (pack_spu.swap)
75 crPackTexCoordPointerSWAP( size, type, stride, pointer );
76 else
77 crPackTexCoordPointer( size, type, stride, pointer );
78 }
79#endif
80 crStateTexCoordPointer( size, type, stride, pointer );
81}
82
83void PACKSPU_APIENTRY packspu_NormalPointer( GLenum type, GLsizei stride, const GLvoid *pointer )
84{
85#if CR_ARB_vertex_buffer_object
86 GET_CONTEXT(ctx);
87 if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
88 if (pack_spu.swap)
89 crPackNormalPointerSWAP( type, stride, pointer );
90 else
91 crPackNormalPointer( type, stride, pointer );
92 }
93#endif
94 crStateNormalPointer( type, stride, pointer );
95}
96
97void PACKSPU_APIENTRY packspu_EdgeFlagPointer( GLsizei stride, const GLvoid *pointer )
98{
99#if CR_ARB_vertex_buffer_object
100 GET_CONTEXT(ctx);
101 if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
102 if (pack_spu.swap)
103 crPackEdgeFlagPointerSWAP( stride, pointer );
104 else
105 crPackEdgeFlagPointer( stride, pointer );
106 }
107#endif
108 crStateEdgeFlagPointer( stride, pointer );
109}
110
111void PACKSPU_APIENTRY packspu_VertexAttribPointerARB( GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer )
112{
113#if CR_ARB_vertex_buffer_object
114 GET_CONTEXT(ctx);
115 if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
116 if (pack_spu.swap)
117 crPackVertexAttribPointerARBSWAP( index, size, type, normalized, stride, pointer );
118 else
119 crPackVertexAttribPointerARB( index, size, type, normalized, stride, pointer );
120 }
121#endif
122 crStateVertexAttribPointerARB( index, size, type, normalized, stride, pointer );
123}
124
125void PACKSPU_APIENTRY packspu_VertexAttribPointerNV( GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
126{
127#if CR_ARB_vertex_buffer_object
128 GET_CONTEXT(ctx);
129 if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
130 if (pack_spu.swap)
131 crPackVertexAttribPointerNVSWAP( index, size, type, stride, pointer );
132 else
133 crPackVertexAttribPointerNV( index, size, type, stride, pointer );
134 }
135#endif
136 crStateVertexAttribPointerNV( index, size, type, stride, pointer );
137}
138
139void PACKSPU_APIENTRY packspu_GetPointerv( GLenum pname, GLvoid **params )
140{
141 crStateGetPointerv( pname, params );
142}
143
144void PACKSPU_APIENTRY packspu_InterleavedArrays( GLenum format, GLsizei stride, const GLvoid *pointer )
145{
146#if CR_ARB_vertex_buffer_object
147 GET_CONTEXT(ctx);
148 if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
149 if (pack_spu.swap)
150 crPackInterleavedArraysSWAP( format, stride, pointer );
151 else
152 crPackInterleavedArrays( format, stride, pointer );
153 }
154#endif
155
156 /*crDebug("packspu_InterleavedArrays");*/
157
158 crStateInterleavedArrays( format, stride, pointer );
159}
160
161
162void PACKSPU_APIENTRY
163packspu_ArrayElement( GLint index )
164{
165#if 0
166 GLboolean serverArrays = GL_FALSE;
167
168#if CR_ARB_vertex_buffer_object
169 GET_CONTEXT(ctx);
170 /*crDebug("packspu_ArrayElement index:%i", index);*/
171 if (ctx->clientState->extensions.ARB_vertex_buffer_object)
172 serverArrays = crStateUseServerArrays();
173#endif
174
175 if (serverArrays) {
176 /* Send the DrawArrays command over the wire */
177 if (pack_spu.swap)
178 crPackArrayElementSWAP( index );
179 else
180 crPackArrayElement( index );
181 }
182 else {
183 /* evaluate locally */
184 GET_CONTEXT(ctx);
185 CRClientState *clientState = &(ctx->clientState->client);
186 if (pack_spu.swap)
187 crPackExpandArrayElementSWAP( index, clientState );
188 else
189 crPackExpandArrayElement( index, clientState );
190 }
191#else
192 GET_CONTEXT(ctx);
193 CRClientState *clientState = &(ctx->clientState->client);
194 crPackExpandArrayElement(index, clientState);
195#endif
196}
197
198
199void PACKSPU_APIENTRY
200packspu_DrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices )
201{
202 GLboolean serverArrays = GL_FALSE;
203
204#if CR_ARB_vertex_buffer_object
205 GET_CONTEXT(ctx);
206 /*crDebug("DrawElements count=%d, indices=%p", count, indices);*/
207 if (ctx->clientState->extensions.ARB_vertex_buffer_object)
208 serverArrays = crStateUseServerArrays();
209#endif
210
211 if (serverArrays) {
212 /* Send the DrawArrays command over the wire */
213 if (pack_spu.swap)
214 crPackDrawElementsSWAP( mode, count, type, indices );
215 else
216 crPackDrawElements( mode, count, type, indices );
217 }
218 else {
219 /* evaluate locally */
220 GET_CONTEXT(ctx);
221 CRClientState *clientState = &(ctx->clientState->client);
222 if (pack_spu.swap)
223 crPackExpandDrawElementsSWAP( mode, count, type, indices, clientState );
224 else
225 {
226 //packspu_Begin(mode);
227 crPackExpandDrawElements( mode, count, type, indices, clientState );
228 //packspu_End();
229 }
230 }
231}
232
233
234void PACKSPU_APIENTRY
235packspu_DrawRangeElements( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices )
236{
237 GLboolean serverArrays = GL_FALSE;
238
239#if CR_ARB_vertex_buffer_object
240 GET_CONTEXT(ctx);
241 /*crDebug("DrawRangeElements count=%d", count);*/
242 if (ctx->clientState->extensions.ARB_vertex_buffer_object)
243 serverArrays = crStateUseServerArrays();
244#endif
245
246 if (serverArrays) {
247 /* Send the DrawRangeElements command over the wire */
248 if (pack_spu.swap)
249 crPackDrawRangeElementsSWAP( mode, start, end, count, type, indices );
250 else
251 crPackDrawRangeElements( mode, start, end, count, type, indices );
252 }
253 else {
254 /* evaluate locally */
255 GET_CONTEXT(ctx);
256 CRClientState *clientState = &(ctx->clientState->client);
257 if (pack_spu.swap)
258 crPackExpandDrawRangeElementsSWAP( mode, start, end, count, type, indices, clientState );
259 else
260 {
261 crPackExpandDrawRangeElements( mode, start, end, count, type, indices, clientState );
262 }
263 }
264}
265
266
267void PACKSPU_APIENTRY
268packspu_DrawArrays( GLenum mode, GLint first, GLsizei count )
269{
270 GLboolean serverArrays = GL_FALSE;
271
272#if CR_ARB_vertex_buffer_object
273 GET_CONTEXT(ctx);
274 /*crDebug("DrawArrays count=%d", count);*/
275 if (ctx->clientState->extensions.ARB_vertex_buffer_object)
276 serverArrays = crStateUseServerArrays();
277#endif
278
279 if (serverArrays) {
280 /* Send the DrawArrays command over the wire */
281 if (pack_spu.swap)
282 crPackDrawArraysSWAP( mode, first, count );
283 else
284 crPackDrawArrays( mode, first, count );
285 }
286 else {
287 /* evaluate locally */
288 GET_CONTEXT(ctx);
289 CRClientState *clientState = &(ctx->clientState->client);
290 if (pack_spu.swap)
291 crPackExpandDrawArraysSWAP( mode, first, count, clientState );
292 else
293 crPackExpandDrawArrays( mode, first, count, clientState );
294 }
295}
296
297
298#ifdef CR_EXT_multi_draw_arrays
299void PACKSPU_APIENTRY packspu_MultiDrawArraysEXT( GLenum mode, GLint *first, GLsizei *count, GLsizei primcount )
300{
301 GLint i;
302 for (i = 0; i < primcount; i++) {
303 if (count[i] > 0) {
304 packspu_DrawArrays(mode, first[i], count[i]);
305 }
306 }
307}
308
309void PACKSPU_APIENTRY packspu_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount )
310{
311 GLint i;
312 for (i = 0; i < primcount; i++) {
313 if (count[i] > 0) {
314 packspu_DrawElements(mode, count[i], type, indices[i]);
315 }
316 }
317}
318#endif
319
320
321void PACKSPU_APIENTRY packspu_EnableClientState( GLenum array )
322{
323 crStateEnableClientState(array);
324 crPackEnableClientState(array);
325}
326
327void PACKSPU_APIENTRY packspu_DisableClientState( GLenum array )
328{
329 crStateDisableClientState(array);
330 crPackDisableClientState(array);
331}
332
333void PACKSPU_APIENTRY packspu_ClientActiveTextureARB( GLenum texUnit )
334{
335 crStateClientActiveTextureARB(texUnit);
336 crPackClientActiveTextureARB(texUnit);
337}
338
339void PACKSPU_APIENTRY packspu_EnableVertexAttribArrayARB(GLuint index)
340{
341 crStateEnableVertexAttribArrayARB(index);
342 crPackEnableVertexAttribArrayARB(index);
343}
344
345
346void PACKSPU_APIENTRY packspu_DisableVertexAttribArrayARB(GLuint index)
347{
348 crStateDisableVertexAttribArrayARB(index);
349 crPackDisableVertexAttribArrayARB(index);
350}
351
352void PACKSPU_APIENTRY packspu_Enable( GLenum cap )
353{
354 crStateEnable(cap);
355
356 if (pack_spu.swap)
357 crPackEnableSWAP(cap);
358 else
359 crPackEnable(cap);
360}
361
362
363void PACKSPU_APIENTRY packspu_Disable( GLenum cap )
364{
365 crStateDisable(cap);
366
367 if (pack_spu.swap)
368 crPackDisableSWAP(cap);
369 else
370 crPackDisable(cap);
371}
372
373GLboolean PACKSPU_APIENTRY packspu_IsEnabled(GLenum cap)
374{
375 GLboolean res = crStateIsEnabled(cap);
376#ifdef DEBUG
377 {
378 GET_THREAD(thread);
379 int writeback = 1;
380 GLboolean return_val = (GLboolean) 0;
381 crPackIsEnabled(cap, &return_val, &writeback);
382 packspuFlush( (void *) thread );
383 while (writeback)
384 crNetRecv();
385 CRASSERT(return_val==res);
386 }
387#endif
388
389 return res;
390}
391
392void PACKSPU_APIENTRY packspu_PushClientAttrib( GLbitfield mask )
393{
394 crStatePushClientAttrib(mask);
395 crPackPushClientAttrib(mask);
396}
397
398void PACKSPU_APIENTRY packspu_PopClientAttrib( void )
399{
400 crStatePopClientAttrib();
401 crPackPopClientAttrib();
402}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette