VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_arrays.c@ 34079

Last change on this file since 34079 was 33549, checked in by vboxsync, 14 years ago

crOpenGL/wddm: avoid unrolling drawprimitive calls when possible

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.6 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 "cr_error.h"
8#include "unpack_extend.h"
9#include "unpacker.h"
10#include "cr_glstate.h"
11/**
12 * \mainpage Unpacker
13 *
14 * \section UnpackerIntroduction Introduction
15 *
16 * Chromium consists of all the top-level files in the cr
17 * directory. The unpacker module basically takes care of API dispatch,
18 * and OpenGL state management.
19 *
20 */
21
22void crUnpackExtendVertexPointer(void)
23{
24 GLint size = READ_DATA( 8, GLint );
25 GLenum type = READ_DATA( 12, GLenum );
26 GLsizei stride = READ_DATA( 16, GLsizei );
27 GLintptrARB pointer = (GLintptrARB) READ_DATA( 20, GLuint );
28 cr_unpackDispatch.VertexPointer( size, type, stride, (void *) pointer );
29}
30
31void crUnpackExtendTexCoordPointer(void)
32{
33 GLint size = READ_DATA( 8, GLint );
34 GLenum type = READ_DATA( 12, GLenum );
35 GLsizei stride = READ_DATA( 16, GLsizei );
36 GLintptrARB pointer = READ_DATA( 20, GLuint );
37 cr_unpackDispatch.TexCoordPointer( size, type, stride, (void *) pointer );
38}
39
40void crUnpackExtendNormalPointer(void)
41{
42 GLenum type = READ_DATA( 8, GLenum );
43 GLsizei stride = READ_DATA( 12, GLsizei );
44 GLintptrARB pointer = READ_DATA( 16, GLuint );
45 cr_unpackDispatch.NormalPointer( type, stride, (void *) pointer );
46}
47
48void crUnpackExtendIndexPointer(void)
49{
50 GLenum type = READ_DATA( 8, GLenum );
51 GLsizei stride = READ_DATA( 12, GLsizei );
52 GLintptrARB pointer = READ_DATA( 16, GLuint );
53 cr_unpackDispatch.IndexPointer( type, stride, (void *) pointer );
54}
55
56void crUnpackExtendEdgeFlagPointer(void)
57{
58 GLsizei stride = READ_DATA( 8, GLsizei );
59 GLintptrARB pointer = READ_DATA( 12, GLuint );
60 cr_unpackDispatch.EdgeFlagPointer( stride, (void *) pointer );
61}
62
63void crUnpackExtendColorPointer(void)
64{
65 GLint size = READ_DATA( 8, GLint );
66 GLenum type = READ_DATA( 12, GLenum );
67 GLsizei stride = READ_DATA( 16, GLsizei );
68 GLintptrARB pointer = READ_DATA( 20, GLuint );
69 cr_unpackDispatch.ColorPointer( size, type, stride, (void *) pointer );
70}
71
72void crUnpackExtendFogCoordPointerEXT(void)
73{
74 GLenum type = READ_DATA( 8, GLenum );
75 GLsizei stride = READ_DATA( 12, GLsizei );
76 GLintptrARB pointer = READ_DATA( 16, GLuint );
77 cr_unpackDispatch.FogCoordPointerEXT( type, stride, (void *) pointer );
78}
79
80void crUnpackExtendSecondaryColorPointerEXT(void)
81{
82 GLint size = READ_DATA( 8, GLint );
83 GLenum type = READ_DATA( 12, GLenum );
84 GLsizei stride = READ_DATA( 16, GLsizei );
85 GLintptrARB pointer = READ_DATA( 20, GLuint );
86 cr_unpackDispatch.SecondaryColorPointerEXT( size, type, stride, (void *) pointer );
87}
88
89void crUnpackExtendVertexAttribPointerARB(void)
90{
91 GLuint index = READ_DATA( 8, GLuint);
92 GLint size = READ_DATA( 12, GLint );
93 GLenum type = READ_DATA( 16, GLenum );
94 GLboolean normalized = READ_DATA( 20, GLboolean );
95 GLsizei stride = READ_DATA( 24, GLsizei );
96 GLintptrARB pointer = READ_DATA( 28, GLuint );
97 cr_unpackDispatch.VertexAttribPointerARB( index, size, type, normalized, stride, (void *) pointer );
98}
99
100void crUnpackExtendVertexAttribPointerNV(void)
101{
102 GLuint index = READ_DATA( 8, GLuint);
103 GLint size = READ_DATA( 12, GLint );
104 GLenum type = READ_DATA( 16, GLenum );
105 GLsizei stride = READ_DATA( 20, GLsizei );
106 GLintptrARB pointer = READ_DATA( 24, GLuint );
107 cr_unpackDispatch.VertexAttribPointerNV( index, size, type, stride, (void *) pointer );
108}
109
110void crUnpackExtendInterleavedArrays(void)
111{
112 GLenum format = READ_DATA( 8, GLenum );
113 GLsizei stride = READ_DATA( 12, GLsizei );
114 GLintptrARB pointer = READ_DATA( 16, GLuint );
115 cr_unpackDispatch.InterleavedArrays( format, stride, (void *) pointer );
116}
117
118void crUnpackExtendDrawElements(void)
119{
120 GLenum mode = READ_DATA( 8, GLenum );
121 GLsizei count = READ_DATA( 12, GLsizei );
122 GLenum type = READ_DATA( 16, GLenum );
123 GLintptrARB indices = READ_DATA( 20, GLuint );
124 void * indexptr;
125#ifdef CR_ARB_vertex_buffer_object
126 GLboolean hasidxdata = READ_DATA(24, GLint);
127 indexptr = hasidxdata ? DATA_POINTER(28, void) : (void*)indices;
128#else
129 indexptr = DATA_POINTER(24, void);
130#endif
131 cr_unpackDispatch.DrawElements(mode, count, type, indexptr);
132}
133
134void crUnpackExtendDrawRangeElements(void)
135{
136 GLenum mode = READ_DATA( 8, GLenum );
137 GLuint start = READ_DATA( 12, GLuint );
138 GLuint end = READ_DATA( 16, GLuint );
139 GLsizei count = READ_DATA( 20, GLsizei );
140 GLenum type = READ_DATA( 24, GLenum );
141 GLintptrARB indices = READ_DATA( 28, GLuint );
142 void * indexptr;
143#ifdef CR_ARB_vertex_buffer_object
144 GLboolean hasidxdata = READ_DATA(32, GLint);
145 indexptr = hasidxdata ? DATA_POINTER(36, void) : (void*)indices;
146#else
147 indexptr = DATA_POINTER(32, void);
148#endif
149 cr_unpackDispatch.DrawRangeElements(mode, start, end, count, type, indexptr);
150}
151
152void crUnpackMultiDrawArraysEXT(void)
153{
154 crError( "Can't decode MultiDrawArraysEXT" );
155}
156
157void crUnpackMultiDrawElementsEXT(void)
158{
159 crError( "Can't decode MultiDrawElementsEXT" );
160}
161
162static void crUnpackSetClientPointerByIndex(int index, GLint size,
163 GLenum type, GLboolean normalized,
164 GLsizei stride, const GLvoid *pointer, CRClientState *c)
165{
166 /*crDebug("crUnpackSetClientPointerByIndex: %i(s=%i, t=0x%x, n=%i, str=%i) -> %p", index, size, type, normalized, stride, pointer);*/
167
168 if (index<7)
169 {
170 switch (index)
171 {
172 case 0:
173 cr_unpackDispatch.VertexPointer(size, type, stride, pointer);
174 break;
175 case 1:
176 cr_unpackDispatch.ColorPointer(size, type, stride, pointer);
177 break;
178 case 2:
179 cr_unpackDispatch.FogCoordPointerEXT(type, stride, pointer);
180 break;
181 case 3:
182 cr_unpackDispatch.SecondaryColorPointerEXT(size, type, stride, pointer);
183 break;
184 case 4:
185 cr_unpackDispatch.EdgeFlagPointer(stride, pointer);
186 break;
187 case 5:
188 cr_unpackDispatch.IndexPointer(type, stride, pointer);
189 break;
190 case 6:
191 cr_unpackDispatch.NormalPointer(type, stride, pointer);
192 break;
193 }
194 }
195 else if (index<(7+CR_MAX_TEXTURE_UNITS))
196 {
197 int curTexUnit = c->curClientTextureUnit;
198 if ((index-7)!=curTexUnit)
199 {
200 cr_unpackDispatch.ClientActiveTextureARB(GL_TEXTURE0_ARB+index-7);
201 }
202 cr_unpackDispatch.TexCoordPointer(size, type, stride, pointer);
203 if ((index-7)!=curTexUnit)
204 {
205 cr_unpackDispatch.ClientActiveTextureARB(GL_TEXTURE0_ARB+curTexUnit);
206 }
207 }
208 else
209 {
210 cr_unpackDispatch.VertexAttribPointerARB(index-7-CR_MAX_TEXTURE_UNITS,
211 size, type, normalized, stride, pointer);
212 }
213}
214
215void crUnpackExtendLockArraysEXT(void)
216{
217 GLint first = READ_DATA(sizeof(int) + 4, GLint);
218 GLint count = READ_DATA(sizeof(int) + 8, GLint);
219 int numenabled = READ_DATA(sizeof(int) + 12, int);
220
221 CRContext *g = crStateGetCurrent();
222 CRClientState *c = &g->client;
223 CRClientPointer *cp;
224 int i, index, offset;
225 unsigned char *data;
226
227 offset = 2*sizeof(int)+12;
228
229 /*crDebug("crUnpackExtendLockArraysEXT(%i, %i) ne=%i", first, count, numenabled);*/
230
231 for (i=0; i<numenabled; ++i)
232 {
233 index = READ_DATA(offset, int);
234 offset += sizeof(int);
235 cp = crStateGetClientPointerByIndex(index, &c->array);
236 CRASSERT(cp && cp->enabled && (!cp->buffer || !cp->buffer->id));
237 data = crAlloc((first+count)*cp->bytesPerIndex);
238 crMemcpy(data+first*cp->bytesPerIndex, DATA_POINTER(offset, GLvoid), count*cp->bytesPerIndex);
239 offset += count*cp->bytesPerIndex;
240 /*crDebug("crUnpackExtendLockArraysEXT: old cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i",
241 index, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/
242 crUnpackSetClientPointerByIndex(index, cp->size, cp->type, cp->normalized, 0, data, c);
243 /*crDebug("crUnpackExtendLockArraysEXT: new cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i",
244 index, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/
245 }
246 cr_unpackDispatch.LockArraysEXT(first, count);
247}
248
249void crUnpackExtendUnlockArraysEXT(void)
250{
251 int i;
252 CRContext *g = crStateGetCurrent();
253 CRClientState *c = &g->client;
254 CRClientPointer *cp;
255
256 /*crDebug("crUnpackExtendUnlockArraysEXT");*/
257
258 cr_unpackDispatch.UnlockArraysEXT();
259
260 for (i=0; i<CRSTATECLIENT_MAX_VERTEXARRAYS; ++i)
261 {
262 cp = crStateGetClientPointerByIndex(i, &c->array);
263 if (cp->enabled)
264 {
265 /*crDebug("crUnpackExtendUnlockArraysEXT: old cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i",
266 i, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/
267 crUnpackSetClientPointerByIndex(i, cp->size, cp->type, cp->normalized, cp->prevStride, cp->prevPtr, c);
268 /*crDebug("crUnpackExtendUnlockArraysEXT: new cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i",
269 i, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/
270 }
271 }
272}
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