VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_arrays.cpp@ 78190

Last change on this file since 78190 was 78190, checked in by vboxsync, 6 years ago

Merge first stage of the Chromium cleanup from the branch:

  • r129818 (Remove VBOX_WITH_CR_DISPLAY_LISTS and accompanying code as it was disabled since r108676 and was never brought back (see ​bugref:3456 and ​bugref:8485))
  • r129819 (HostServices/SharedOpenGL: Remove unused main entry point from upstream server process based implementation)
  • r129820 (HostServices/SharedOpenGL: Started eliminating all backends other than HGCM. They are not used and probably wouldn't work anymore anyway)
  • r129821 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill crTimer* API as it is not used anywhere)
  • r129822 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill most from cr_process.h apart from two used methods)
  • r129823 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill crList* API as it is unused)
  • r129824 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill crHullInteriorBox API as it is unused)
  • r129825 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill crWarpPoint API as it is unused)
  • r129826 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill CrSa* API as it is unused and not even compiled in)
  • r129827 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill cr_bbox.h as it is unused)
  • r129828 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove a few crParseUrl() two uses)
  • r129829 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove last crParseURL() use)
  • r129830 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove crParseURL())
  • r129831 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove VBOX_WITH_COCOA_QT and related code when not set as it is the default for years now and we don't support anything else anymore)
  • r129832 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_logo.h)
  • r129833 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused crut_api.h and crut_clientapi.h)
  • r129834 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_dmx.h)
  • r129835 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_perf.h)
  • r129836 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove cr_rand.h and friends as it is not actively used anywhere)
  • r129837 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of all the swapped versions in the packer SPU, we never change endianess from guest to host and don't need it)
  • r129838 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129839 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129840 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused pack_pica.c)
  • r129841 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129842 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of cr_endianess.h and friends)
  • r129843 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused lowercase.py)
  • r129844 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused cr_calllists.h and friends)
  • r129845 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of completely unused idpool.c, not even compiled in)
  • r129846 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused cr_debugopcodes.h and friends)
  • r129847 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Make the cr_mem.h API inline and get rid of the implementation in the util library)
  • r129848 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of SPUOptions and related code as it is of no use for us)
  • r129849 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of cr_environment.h and friends and convert usage to RTEnv* APIs)
  • r129850 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused renderspu_agl.c)
  • r129851 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused code in cr_htable.h)
  • r129853 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Introduce a state paremeter for the unpacker workers instead of reyling on global variables, work in progress)
  • r129854 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Let the caller of crUnpack set up the initial state. This allows to get rid of the global return_ptr and writeback_ptr as they get supplied in the unpacker state by the server)
  • r129855 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of the cr_lastDispatch and cr_unpackDispatch as they are of no use now)
  • r129856 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of the global cr_unpackData and cr_unpackDataEnd symbols by indtroducing another hack to make it possible for certail server dispatch callbacks to access the data buffer)
  • r129857 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: build fix for release builds)
  • r129858 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Make the pointer to the unpacker state non const (is required for the access verification))
  • r129859 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: First iteration of the buffer size validation to prevent out of bound read access + added todos for places where additional checks are needed)
  • r129860 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129861 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129871 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129872 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Stop as soon as the unpacker encountered an error)
  • r129876 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129880 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129882 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Fixed some offsets in unpack_texture.c, 3DMark03 renders correctly again)
  • r130013 (HostServices/SharedOpenGL: Convert files to C++ so we can use C99 featuers on Windows with cl.exe)
  • r130014 (HostServices/SharedOpenGL,GuestHost/OpenGL: WIndows build fixes)
  • r130015 (HostServices/SharedOpenGL,GuestHost/OpenGL: More Windows build fixes)
  • r130036 (Config.kmk: Fix linker error on Windows by temporarily disabling the use of VBoxGuestR3DllMinW2K)
  • r130094 (src/VBox/GuestHost/OpenGL: Revert inlining the allocation/free functions in R3 completely as it doesn't work on Windows if memory is allocated and freed across different DLLs which don't share a common CRT, causes crashes in RtlValidtaeHeap())
  • r130095 (src/VBox/GuestHost/OpenGL,src/VBox/Additions/common/crOpenGL/pack: Don't use floating point specifiers in packspu_GetString() to avoid R6002 errors (couldn't fully understand why they occur suddenly after the rework but this gets rid of it))
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 14.5 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(PCrUnpackerState pState)
23{
24 CHECK_BUFFER_SIZE_STATIC(pState, 20 + sizeof(GLuint) );
25
26 GLint size = READ_DATA(pState, 8, GLint );
27 GLenum type = READ_DATA(pState, 12, GLenum );
28 GLsizei stride = READ_DATA(pState, 16, GLsizei );
29 GLintptrARB pointer = (GLintptrARB) READ_DATA(pState, 20, GLuint );
30 pState->pDispatchTbl->VertexPointer( size, type, stride, (void *) pointer, false /*fRealPtr*/ );
31}
32
33void crUnpackExtendTexCoordPointer(PCrUnpackerState pState)
34{
35 CHECK_BUFFER_SIZE_STATIC(pState, 20 + sizeof(GLuint) );
36
37 GLint size = READ_DATA(pState, 8, GLint );
38 GLenum type = READ_DATA(pState, 12, GLenum );
39 GLsizei stride = READ_DATA(pState, 16, GLsizei );
40 GLintptrARB pointer = READ_DATA(pState, 20, GLuint );
41 pState->pDispatchTbl->TexCoordPointer( size, type, stride, (void *) pointer, false /*fRealPtr*/ );
42}
43
44void crUnpackExtendNormalPointer(PCrUnpackerState pState)
45{
46 CHECK_BUFFER_SIZE_STATIC(pState, 16 + sizeof(GLuint) );
47
48 GLenum type = READ_DATA(pState, 8, GLenum );
49 GLsizei stride = READ_DATA(pState, 12, GLsizei );
50 GLintptrARB pointer = READ_DATA(pState, 16, GLuint );
51 pState->pDispatchTbl->NormalPointer( type, stride, (void *) pointer, false /*fRealPtr*/ );
52}
53
54void crUnpackExtendIndexPointer(PCrUnpackerState pState)
55{
56 CHECK_BUFFER_SIZE_STATIC(pState, 16 + sizeof(GLuint) );
57
58 GLenum type = READ_DATA(pState, 8, GLenum );
59 GLsizei stride = READ_DATA(pState, 12, GLsizei );
60 GLintptrARB pointer = READ_DATA(pState, 16, GLuint );
61 pState->pDispatchTbl->IndexPointer( type, stride, (void *) pointer, false /*fRealPtr*/ );
62}
63
64void crUnpackExtendEdgeFlagPointer(PCrUnpackerState pState)
65{
66 CHECK_BUFFER_SIZE_STATIC(pState, 12 + sizeof(GLuint) );
67
68 GLsizei stride = READ_DATA(pState, 8, GLsizei );
69 GLintptrARB pointer = READ_DATA(pState, 12, GLuint );
70 pState->pDispatchTbl->EdgeFlagPointer( stride, (void *) pointer, false /*fRealPtr*/ );
71}
72
73void crUnpackExtendColorPointer(PCrUnpackerState pState)
74{
75 CHECK_BUFFER_SIZE_STATIC(pState, 20 + sizeof(GLuint) );
76
77 GLint size = READ_DATA(pState, 8, GLint );
78 GLenum type = READ_DATA(pState, 12, GLenum );
79 GLsizei stride = READ_DATA(pState, 16, GLsizei );
80 GLintptrARB pointer = READ_DATA(pState, 20, GLuint );
81 pState->pDispatchTbl->ColorPointer( size, type, stride, (void *) pointer, false /*fRealPtr*/ );
82}
83
84void crUnpackExtendFogCoordPointerEXT(PCrUnpackerState pState)
85{
86 CHECK_BUFFER_SIZE_STATIC(pState, 16 + sizeof(GLuint) );
87
88 GLenum type = READ_DATA(pState, 8, GLenum );
89 GLsizei stride = READ_DATA(pState, 12, GLsizei );
90 GLintptrARB pointer = READ_DATA(pState, 16, GLuint );
91 pState->pDispatchTbl->FogCoordPointerEXT( type, stride, (void *) pointer, false /*fRealPtr*/ );
92}
93
94void crUnpackExtendSecondaryColorPointerEXT(PCrUnpackerState pState)
95{
96 CHECK_BUFFER_SIZE_STATIC(pState, 20 + sizeof(GLuint) );
97
98 GLint size = READ_DATA(pState, 8, GLint );
99 GLenum type = READ_DATA(pState, 12, GLenum );
100 GLsizei stride = READ_DATA(pState, 16, GLsizei );
101 GLintptrARB pointer = READ_DATA(pState, 20, GLuint );
102 pState->pDispatchTbl->SecondaryColorPointerEXT( size, type, stride, (void *) pointer, false /*fRealPtr*/ );
103}
104
105void crUnpackExtendVertexAttribPointerARB(PCrUnpackerState pState)
106{
107 CHECK_BUFFER_SIZE_STATIC(pState, 28 + sizeof(GLuint) );
108
109 GLuint index = READ_DATA(pState, 8, GLuint);
110 GLint size = READ_DATA(pState, 12, GLint );
111 GLenum type = READ_DATA(pState, 16, GLenum );
112 GLboolean normalized = READ_DATA(pState, 20, GLboolean );
113 GLsizei stride = READ_DATA(pState, 24, GLsizei );
114 GLintptrARB pointer = READ_DATA(pState, 28, GLuint );
115 pState->pDispatchTbl->VertexAttribPointerARB( index, size, type, normalized, stride, (void *) pointer, false /*fRealPtr*/ );
116}
117
118void crUnpackExtendVertexAttribPointerNV(PCrUnpackerState pState)
119{
120 CHECK_BUFFER_SIZE_STATIC(pState, 24 + sizeof(GLuint) );
121
122 GLuint index = READ_DATA(pState, 8, GLuint);
123 GLint size = READ_DATA(pState, 12, GLint );
124 GLenum type = READ_DATA(pState, 16, GLenum );
125 GLsizei stride = READ_DATA(pState, 20, GLsizei );
126 GLintptrARB pointer = READ_DATA(pState, 24, GLuint );
127 pState->pDispatchTbl->VertexAttribPointerNV( index, size, type, stride, (void *) pointer, false /*fRealPtr*/ );
128}
129
130void crUnpackExtendInterleavedArrays(PCrUnpackerState pState)
131{
132 CHECK_BUFFER_SIZE_STATIC(pState, 16 + sizeof(GLuint) );
133
134 GLenum format = READ_DATA(pState, 8, GLenum );
135 GLsizei stride = READ_DATA(pState, 12, GLsizei );
136 GLintptrARB pointer = READ_DATA(pState, 16, GLuint );
137 pState->pDispatchTbl->InterleavedArrays( format, stride, (void *) pointer, false /*fRealPtr*/ );
138}
139
140void crUnpackExtendDrawElements(PCrUnpackerState pState)
141{
142#ifdef CR_ARB_vertex_buffer_object
143 CHECK_BUFFER_SIZE_STATIC(pState, 28);
144#else
145 CHECK_BUFFER_SIZE_STATIC(pState, 24);
146#endif
147
148 GLenum mode = READ_DATA(pState, 8, GLenum );
149 GLsizei count = READ_DATA(pState, 12, GLsizei );
150 GLenum type = READ_DATA(pState, 16, GLenum );
151 GLintptrARB indices = READ_DATA(pState, 20, GLuint );
152 void * indexptr;
153
154 size_t cbElem = 0;
155 switch (type)
156 {
157 case GL_UNSIGNED_BYTE:
158 cbElem = sizeof(GLubyte);
159 break;
160 case GL_UNSIGNED_SHORT:
161 cbElem = sizeof(GLubyte);
162 break;
163 case GL_UNSIGNED_INT:
164 cbElem = sizeof(GLubyte);
165 break;
166 default:
167 crError("crUnpackExtendDrawElements: Invalid type (%#x) passed!\n", type);
168 pState->rcUnpack = VERR_INVALID_PARAMETER;
169 return;
170 }
171
172#ifdef CR_ARB_vertex_buffer_object
173 GLboolean hasidxdata = READ_DATA(pState, 24, GLint);
174 indexptr = hasidxdata ? DATA_POINTER(pState, 28, void) : (void*)indices;
175 if (hasidxdata)
176 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_SZ_LAST(pState, indexptr, count, cbElem);
177#else
178 indexptr = DATA_POINTER(pState, 24, void);
179 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_SZ_LAST(pState, indexptr, count, cbElem);
180#endif
181 pState->pDispatchTbl->DrawElements(mode, count, type, indexptr);
182}
183
184void crUnpackExtendDrawRangeElements(PCrUnpackerState pState)
185{
186#ifdef CR_ARB_vertex_buffer_object
187 CHECK_BUFFER_SIZE_STATIC(pState, 36);
188#else
189 CHECK_BUFFER_SIZE_STATIC(pState, 32);
190#endif
191
192 GLenum mode = READ_DATA(pState, 8, GLenum );
193 GLuint start = READ_DATA(pState, 12, GLuint );
194 GLuint end = READ_DATA(pState, 16, GLuint );
195 GLsizei count = READ_DATA(pState, 20, GLsizei );
196 GLenum type = READ_DATA(pState, 24, GLenum );
197 GLintptrARB indices = READ_DATA(pState, 28, GLuint );
198 void * indexptr;
199
200 size_t cbElem = 0;
201 switch (type)
202 {
203 case GL_UNSIGNED_BYTE:
204 cbElem = sizeof(GLubyte);
205 break;
206 case GL_UNSIGNED_SHORT:
207 cbElem = sizeof(GLubyte);
208 break;
209 case GL_UNSIGNED_INT:
210 cbElem = sizeof(GLubyte);
211 break;
212 default:
213 crError("crUnpackExtendDrawElements: Invalid type (%#x) passed!\n", type);
214 pState->rcUnpack = VERR_INVALID_PARAMETER;
215 return;
216 }
217#ifdef CR_ARB_vertex_buffer_object
218 GLboolean hasidxdata = READ_DATA(pState, 32, GLint);
219 indexptr = hasidxdata ? DATA_POINTER(pState, 36, void) : (void*)indices;
220 if (hasidxdata)
221 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_SZ_LAST(pState, indexptr, count, cbElem);
222#else
223 indexptr = DATA_POINTER(pState, 32, void);
224 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_SZ_LAST(pState, indexptr, count, cbElem);
225#endif
226
227 pState->pDispatchTbl->DrawRangeElements(mode, start, end, count, type, indexptr);
228}
229
230void crUnpackMultiDrawArraysEXT(PCrUnpackerState pState)
231{
232 RT_NOREF(pState);
233 crError( "Can't decode MultiDrawArraysEXT" );
234}
235
236void crUnpackMultiDrawElementsEXT(PCrUnpackerState pState)
237{
238 RT_NOREF(pState);
239 crError( "Can't decode MultiDrawElementsEXT" );
240}
241
242static void crUnpackSetClientPointerByIndex(PCrUnpackerState pState, int index, GLint size,
243 GLenum type, GLboolean normalized,
244 GLsizei stride, const GLvoid *pointer, CRClientState *c, int fRealPtr)
245{
246 /*crDebug("crUnpackSetClientPointerByIndex: %i(s=%i, t=0x%x, n=%i, str=%i) -> %p", index, size, type, normalized, stride, pointer);*/
247
248 if (index<7)
249 {
250 switch (index)
251 {
252 case 0:
253 pState->pDispatchTbl->VertexPointer(size, type, stride, pointer, fRealPtr);
254 break;
255 case 1:
256 pState->pDispatchTbl->ColorPointer(size, type, stride, pointer, fRealPtr);
257 break;
258 case 2:
259 pState->pDispatchTbl->FogCoordPointerEXT(type, stride, pointer, fRealPtr);
260 break;
261 case 3:
262 pState->pDispatchTbl->SecondaryColorPointerEXT(size, type, stride, pointer, fRealPtr);
263 break;
264 case 4:
265 pState->pDispatchTbl->EdgeFlagPointer(stride, pointer, fRealPtr);
266 break;
267 case 5:
268 pState->pDispatchTbl->IndexPointer(type, stride, pointer, fRealPtr);
269 break;
270 case 6:
271 pState->pDispatchTbl->NormalPointer(type, stride, pointer, fRealPtr);
272 break;
273 }
274 }
275 else if (index<(7+CR_MAX_TEXTURE_UNITS))
276 {
277 int curTexUnit = c->curClientTextureUnit;
278 if ((index-7)!=curTexUnit)
279 {
280 pState->pDispatchTbl->ClientActiveTextureARB(GL_TEXTURE0_ARB+index-7);
281 }
282 pState->pDispatchTbl->TexCoordPointer(size, type, stride, pointer, fRealPtr);
283 if ((index-7)!=curTexUnit)
284 {
285 pState->pDispatchTbl->ClientActiveTextureARB(GL_TEXTURE0_ARB+curTexUnit);
286 }
287 }
288 else
289 {
290 pState->pDispatchTbl->VertexAttribPointerARB(index-7-CR_MAX_TEXTURE_UNITS,
291 size, type, normalized, stride, pointer, fRealPtr);
292 }
293}
294
295void crUnpackExtendLockArraysEXT(PCrUnpackerState pState)
296{
297 CHECK_BUFFER_SIZE_STATIC(pState, sizeof(int) + 12 + sizeof(int));
298
299 GLint first = READ_DATA(pState, sizeof(int) + 4, GLint);
300 GLint count = READ_DATA(pState, sizeof(int) + 8, GLint);
301 int numenabled = READ_DATA(pState, sizeof(int) + 12, int);
302
303 CRContext *g = crStateGetCurrent();
304 CRClientState *c = &g->client;
305 CRClientPointer *cp;
306 int i, index, offset;
307 uint8_t *data;
308
309 if (first < 0 || count <= 0 || first >= INT32_MAX - count)
310 {
311 crError("crUnpackExtendLockArraysEXT: first(%i) count(%i), parameters out of range", first, count);
312 return;
313 }
314
315 if (numenabled <= 0 || numenabled >= CRSTATECLIENT_MAX_VERTEXARRAYS)
316 {
317 crError("crUnpackExtendLockArraysEXT: numenabled(%i), parameter out of range", numenabled);
318 return;
319 }
320
321 offset = 2 * sizeof(int) + 12;
322
323 /*crDebug("crUnpackExtendLockArraysEXT(%i, %i) ne=%i", first, count, numenabled);*/
324
325 for (i = 0; i < numenabled; ++i)
326 {
327 CHECK_BUFFER_SIZE_STATIC_LAST(pState, offset, int);
328 index = READ_DATA(pState, offset, int);
329 offset += sizeof(int);
330
331 cp = crStateGetClientPointerByIndex(index, &c->array);
332
333 CRASSERT(cp && cp->enabled && (!cp->buffer || !cp->buffer->id));
334
335 if (cp && cp->bytesPerIndex > 0)
336 {
337 if (first + count >= INT32_MAX / cp->bytesPerIndex)
338 {
339 crError("crUnpackExtendLockArraysEXT: first(%i) count(%i) bpi(%i), parameters out of range", first, count, cp->bytesPerIndex);
340 return;
341 }
342
343 data = (uint8_t *)crAlloc((first + count) * cp->bytesPerIndex);
344
345 if (data)
346 {
347 crMemcpy(data + first * cp->bytesPerIndex, DATA_POINTER(pState, offset, GLvoid), count * cp->bytesPerIndex);
348 /*crDebug("crUnpackExtendLockArraysEXT: old cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i",
349 index, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/
350 crUnpackSetClientPointerByIndex(pState, index, cp->size, cp->type, cp->normalized, 0, data, c, 1);
351 /*crDebug("crUnpackExtendLockArraysEXT: new cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i",
352 index, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/
353 }
354 else
355 {
356 crError("crUnpackExtendLockArraysEXT: crAlloc failed");
357 return;
358 }
359 }
360 else
361 {
362 crError("crUnpackExtendLockArraysEXT: wrong CRClientState %i", index);
363 return;
364 }
365
366 offset += count * cp->bytesPerIndex;
367 }
368
369 pState->pDispatchTbl->LockArraysEXT(first, count);
370}
371
372void crUnpackExtendUnlockArraysEXT(PCrUnpackerState pState)
373{
374 int i;
375 CRContext *g = crStateGetCurrent();
376 CRClientState *c = &g->client;
377 CRClientPointer *cp;
378
379 /*crDebug("crUnpackExtendUnlockArraysEXT");*/
380
381 pState->pDispatchTbl->UnlockArraysEXT();
382
383 for (i=0; i<CRSTATECLIENT_MAX_VERTEXARRAYS; ++i)
384 {
385 cp = crStateGetClientPointerByIndex(i, &c->array);
386 if (cp->enabled)
387 {
388 /*crDebug("crUnpackExtendUnlockArraysEXT: old cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i",
389 i, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/
390 unsigned char *prevPtr = cp->prevPtr;
391 int fPrevRealPtr = cp->fPrevRealPtr;
392 cp->prevPtr = NULL;
393 cp->fPrevRealPtr = 0;
394
395 crUnpackSetClientPointerByIndex(pState, i, cp->size, cp->type, cp->normalized, cp->prevStride, prevPtr, c, fPrevRealPtr);
396 /*crDebug("crUnpackExtendUnlockArraysEXT: new cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i",
397 i, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/
398 }
399 }
400}
Note: See TracBrowser for help on using the repository browser.

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