VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_texture.cpp@ 78263

Last change on this file since 78263 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: 28.9 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 "unpacker.h"
8#include "cr_error.h"
9#include "cr_pixeldata.h"
10#include "cr_protocol.h"
11#include "cr_mem.h"
12#include "cr_version.h"
13
14#if defined( GL_EXT_texture3D )
15void crUnpackTexImage3DEXT(PCrUnpackerState pState)
16{
17 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 36, int);
18
19 GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
20 GLint level = READ_DATA(pState, sizeof( int ) + 4, GLint );
21 GLenum internalformat = READ_DATA(pState, sizeof( int ) + 8, GLint );
22 GLsizei width = READ_DATA(pState, sizeof( int ) + 12, GLsizei );
23 GLsizei height = READ_DATA(pState, sizeof( int ) + 16, GLsizei );
24 GLsizei depth = READ_DATA(pState, sizeof( int ) + 20, GLsizei );
25 GLint border = READ_DATA(pState, sizeof( int ) + 24, GLint );
26 GLenum format = READ_DATA(pState, sizeof( int ) + 28, GLenum );
27 GLenum type = READ_DATA(pState, sizeof( int ) + 32, GLenum );
28 int noimagedata = READ_DATA(pState, sizeof( int ) + 36, int );
29 GLvoid *pixels;
30
31 /*If there's no imagedata send, it's either that passed pointer was NULL or
32 there was GL_PIXEL_UNPACK_BUFFER_ARB bound, in both cases 4bytes of passed
33 pointer would convert to either NULL or offset in the bound buffer.
34 */
35 CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, sizeof(int)+40, GLint);
36 if ( noimagedata )
37 pixels = (void*) (uintptr_t) READ_DATA(pState, sizeof(int)+40, GLint);
38 else
39 {
40 size_t cbImg = crImageSize(format, type, width, height);
41 if (RT_UNLIKELY(cbImg == 0))
42 {
43 pState->rcUnpack = VERR_INVALID_PARAMETER;
44 return;
45 }
46 pixels = DATA_POINTER(pState, sizeof( int ) + 44, GLvoid );
47 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, cbImg, GLubyte);
48 }
49
50 pState->pDispatchTbl->TexImage3DEXT(target, level, internalformat, width,
51 height, depth, border, format, type,
52 pixels);
53 INCR_VAR_PTR(pState);
54}
55#endif /* GL_EXT_texture3D */
56
57#if defined( CR_OPENGL_VERSION_1_2 )
58void crUnpackTexImage3D(PCrUnpackerState pState)
59{
60 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 36, int);
61
62 GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
63 GLint level = READ_DATA(pState, sizeof( int ) + 4, GLint );
64 GLint internalformat = READ_DATA(pState, sizeof( int ) + 8, GLint );
65 GLsizei width = READ_DATA(pState, sizeof( int ) + 12, GLsizei );
66 GLsizei height = READ_DATA(pState, sizeof( int ) + 16, GLsizei );
67 GLsizei depth = READ_DATA(pState, sizeof( int ) + 20, GLsizei );
68 GLint border = READ_DATA(pState, sizeof( int ) + 24, GLint );
69 GLenum format = READ_DATA(pState, sizeof( int ) + 28, GLenum );
70 GLenum type = READ_DATA(pState, sizeof( int ) + 32, GLenum );
71 int noimagedata = READ_DATA(pState, sizeof( int ) + 36, int );
72 GLvoid *pixels;
73
74 CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, sizeof(int)+40, GLint);
75 if ( noimagedata )
76 pixels = (void*) (uintptr_t) READ_DATA(pState, sizeof(int)+40, GLint);
77 else
78 {
79 size_t cbImg = crImageSize(format, type, width, height);
80 if (RT_UNLIKELY(cbImg == 0))
81 {
82 pState->rcUnpack = VERR_INVALID_PARAMETER;
83 return;
84 }
85 pixels = DATA_POINTER(pState, sizeof( int ) + 44, GLvoid );
86 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, cbImg, GLubyte);
87 }
88
89 pState->pDispatchTbl->TexImage3D( target, level, internalformat, width, height,
90 depth, border, format, type, pixels );
91 INCR_VAR_PTR(pState);
92}
93#endif /* CR_OPENGL_VERSION_1_2 */
94
95void crUnpackTexImage2D(PCrUnpackerState pState)
96{
97 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 32, int);
98
99 GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
100 GLint level = READ_DATA(pState, sizeof( int ) + 4, GLint );
101 GLint internalformat = READ_DATA(pState, sizeof( int ) + 8, GLint );
102 GLsizei width = READ_DATA(pState, sizeof( int ) + 12, GLsizei );
103 GLsizei height = READ_DATA(pState, sizeof( int ) + 16, GLsizei );
104 GLint border = READ_DATA(pState, sizeof( int ) + 20, GLint );
105 GLenum format = READ_DATA(pState, sizeof( int ) + 24, GLenum );
106 GLenum type = READ_DATA(pState, sizeof( int ) + 28, GLenum );
107 int noimagedata = READ_DATA(pState, sizeof( int ) + 32, int );
108 GLvoid *pixels;
109
110 CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, sizeof(int)+36, GLint);
111 if ( noimagedata )
112 pixels = (void*) (uintptr_t) READ_DATA(pState, sizeof(int)+36, GLint);
113 else
114 {
115 size_t cbImg = crImageSize(format, type, width, height);
116 if (RT_UNLIKELY(cbImg == 0))
117 {
118 pState->rcUnpack = VERR_INVALID_PARAMETER;
119 return;
120 }
121 pixels = DATA_POINTER(pState, sizeof( int ) + 40, GLvoid );
122 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, cbImg, GLubyte);
123 }
124
125 pState->pDispatchTbl->TexImage2D( target, level, internalformat, width, height,
126 border, format, type, pixels );
127 INCR_VAR_PTR(pState);
128}
129
130void crUnpackTexImage1D(PCrUnpackerState pState)
131{
132 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 28, int);
133
134 GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
135 GLint level = READ_DATA(pState, sizeof( int ) + 4, GLint );
136 GLint internalformat = READ_DATA(pState, sizeof( int ) + 8, GLint );
137 GLsizei width = READ_DATA(pState, sizeof( int ) + 12, GLsizei );
138 GLint border = READ_DATA(pState, sizeof( int ) + 16, GLint );
139 GLenum format = READ_DATA(pState, sizeof( int ) + 20, GLenum );
140 GLenum type = READ_DATA(pState, sizeof( int ) + 24, GLenum );
141 int noimagedata = READ_DATA(pState, sizeof( int ) + 28, int );
142 GLvoid *pixels;
143
144 CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, sizeof(int)+32, GLint);
145 if ( noimagedata )
146 pixels = (void*) (uintptr_t) READ_DATA(pState, sizeof(int)+32, GLint);
147 else
148 {
149 size_t cbImg = crImageSize(format, type, width, 1);
150 if (RT_UNLIKELY(cbImg == 0))
151 {
152 pState->rcUnpack = VERR_INVALID_PARAMETER;
153 return;
154 }
155 pixels = DATA_POINTER(pState, sizeof( int ) + 36, GLvoid );
156 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, cbImg, GLubyte);
157 }
158
159 pState->pDispatchTbl->TexImage1D(target, level, internalformat, width, border,
160 format, type, pixels );
161 INCR_VAR_PTR(pState);
162}
163
164void crUnpackDeleteTextures(PCrUnpackerState pState)
165{
166 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 0, GLsizei);
167
168 GLsizei n = READ_DATA(pState, sizeof( int ) + 0, GLsizei );
169 GLuint *textures = DATA_POINTER(pState, sizeof( int ) + 4, GLuint );
170
171 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, textures, n, GLuint);
172 pState->pDispatchTbl->DeleteTextures( n, textures );
173 INCR_VAR_PTR(pState);
174}
175
176
177void crUnpackPrioritizeTextures(PCrUnpackerState pState)
178{
179 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 0, GLsizei);
180
181 GLsizei n = READ_DATA(pState, sizeof( int ) + 0, GLsizei );
182 GLuint *textures = DATA_POINTER(pState, sizeof( int ) + 4, GLuint );
183 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, textures, n, GLuint);
184
185 GLclampf *priorities = DATA_POINTER(pState, sizeof( int ) + 4 + n*sizeof( GLuint ),
186 GLclampf );
187 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, priorities, n, GLclampf);
188
189 pState->pDispatchTbl->PrioritizeTextures( n, textures, priorities );
190 INCR_VAR_PTR(pState);
191}
192
193static size_t crGetTexParameterParamsFromPname(GLenum pname)
194{
195 int cParams = 0;
196
197 switch (pname)
198 {
199 case GL_TEXTURE_MIN_FILTER:
200 case GL_TEXTURE_MAG_FILTER:
201 case GL_TEXTURE_WRAP_R:
202 case GL_TEXTURE_WRAP_S:
203 case GL_TEXTURE_WRAP_T:
204 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
205 case GL_TEXTURE_MIN_LOD:
206 case GL_TEXTURE_MAX_LOD:
207 case GL_TEXTURE_BASE_LEVEL:
208 case GL_TEXTURE_MAX_LEVEL:
209#ifdef CR_ARB_shadow
210 case GL_TEXTURE_COMPARE_MODE_ARB:
211 case GL_TEXTURE_COMPARE_FUNC_ARB:
212#endif
213#ifdef GL_TEXTURE_PRIORITY
214 case GL_TEXTURE_PRIORITY:
215#endif
216#ifdef CR_ARB_shadow_ambient
217 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
218#endif
219#ifdef CR_ARB_depth_texture
220 case GL_DEPTH_TEXTURE_MODE_ARB:
221#endif
222#ifdef CR_SGIS_generate_mipmap
223 case GL_GENERATE_MIPMAP_SGIS:
224#endif
225 cParams = 1;
226 break;
227 case GL_TEXTURE_BORDER_COLOR:
228 cParams = 4;
229 break;
230 default:
231 break; /* Error, handled in caller. */
232 }
233
234 return cParams;
235}
236
237void crUnpackTexParameterfv(PCrUnpackerState pState)
238{
239 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
240
241 GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
242 GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
243 GLfloat *params = DATA_POINTER(pState, sizeof( int ) + 8, GLfloat );
244
245 size_t cParams = crGetTexParameterParamsFromPname(pname);
246 if (RT_UNLIKELY(cParams == 0))
247 {
248 pState->rcUnpack = VERR_INVALID_PARAMETER;
249 return;
250 }
251
252 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, cParams, GLfloat);
253 pState->pDispatchTbl->TexParameterfv( target, pname, params );
254 INCR_VAR_PTR(pState);
255}
256
257void crUnpackTexParameteriv(PCrUnpackerState pState)
258{
259 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
260
261 GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
262 GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
263 GLint *params = DATA_POINTER(pState, sizeof( int ) + 8, GLint );
264
265 size_t cParams = crGetTexParameterParamsFromPname(pname);
266 if (RT_UNLIKELY(cParams == 0))
267 {
268 pState->rcUnpack = VERR_INVALID_PARAMETER;
269 return;
270 }
271
272 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, cParams, GLint);
273 pState->pDispatchTbl->TexParameteriv( target, pname, params );
274 INCR_VAR_PTR(pState);
275}
276
277void crUnpackTexParameterf(PCrUnpackerState pState)
278{
279 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 8, GLfloat);
280
281 GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
282 GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
283 GLfloat param = READ_DATA(pState, sizeof( int ) + 8, GLfloat );
284
285 pState->pDispatchTbl->TexParameterf( target, pname, param );
286 INCR_VAR_PTR(pState);
287}
288
289void crUnpackTexParameteri(PCrUnpackerState pState)
290{
291 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 8, GLint);
292
293 GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
294 GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
295 GLint param = READ_DATA(pState, sizeof( int ) + 8, GLint );
296
297 pState->pDispatchTbl->TexParameteri( target, pname, param );
298 INCR_VAR_PTR(pState);
299}
300
301#if defined(CR_OPENGL_VERSION_1_2)
302void crUnpackTexSubImage3D(PCrUnpackerState pState)
303{
304 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 40, int);
305
306 GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
307 GLint level = READ_DATA(pState, sizeof( int ) + 4, GLint );
308 GLint xoffset = READ_DATA(pState, sizeof( int ) + 8, GLint );
309 GLint yoffset = READ_DATA(pState, sizeof( int ) + 12, GLint );
310 GLint zoffset = READ_DATA(pState, sizeof( int ) + 16, GLint );
311 GLsizei width = READ_DATA(pState, sizeof( int ) + 20, GLsizei );
312 GLsizei height = READ_DATA(pState, sizeof( int ) + 24, GLsizei );
313 GLsizei depth = READ_DATA(pState, sizeof( int ) + 28, GLsizei );
314 GLenum format = READ_DATA(pState, sizeof( int ) + 32, GLenum );
315 GLenum type = READ_DATA(pState, sizeof( int ) + 36, GLenum );
316 int noimagedata = READ_DATA(pState, sizeof( int ) + 40, int );
317 GLvoid *pixels;
318
319 CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, sizeof(int)+44, GLint);
320 if ( noimagedata )
321 pixels = (void*) (uintptr_t) READ_DATA(pState, sizeof(int)+44, GLint);
322 else
323 {
324 size_t cbImg = crImageSize(format, type, width, height);
325 if (RT_UNLIKELY(cbImg == 0))
326 {
327 pState->rcUnpack = VERR_INVALID_PARAMETER;
328 return;
329 }
330 pixels = DATA_POINTER(pState, sizeof( int ) + 48, GLvoid );
331 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, cbImg, GLubyte);
332 }
333
334 pState->pDispatchTbl->PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
335 pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
336 pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
337 pState->pDispatchTbl->PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
338
339 pState->pDispatchTbl->TexSubImage3D(target, level, xoffset, yoffset, zoffset,
340 width, height, depth, format, type, pixels);
341 INCR_VAR_PTR(pState);
342}
343#endif /* CR_OPENGL_VERSION_1_2 */
344
345void crUnpackTexSubImage2D(PCrUnpackerState pState)
346{
347 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 32, int);
348
349 GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
350 GLint level = READ_DATA(pState, sizeof( int ) + 4, GLint );
351 GLint xoffset = READ_DATA(pState, sizeof( int ) + 8, GLint );
352 GLint yoffset = READ_DATA(pState, sizeof( int ) + 12, GLint );
353 GLsizei width = READ_DATA(pState, sizeof( int ) + 16, GLsizei );
354 GLsizei height = READ_DATA(pState, sizeof( int ) + 20, GLsizei );
355 GLenum format = READ_DATA(pState, sizeof( int ) + 24, GLenum );
356 GLenum type = READ_DATA(pState, sizeof( int ) + 28, GLenum );
357 int noimagedata = READ_DATA(pState, sizeof( int ) + 32, int );
358 GLvoid *pixels;
359
360 CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, sizeof(int)+36, GLint);
361 if ( noimagedata )
362 {
363 CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, sizeof(int)+36, GLint);
364 pixels = (void*) (uintptr_t) READ_DATA(pState, sizeof(int)+36, GLint);
365 }
366 else
367 {
368 size_t cbImg = crImageSize(format, type, width, height);
369 if (RT_UNLIKELY(cbImg == 0))
370 {
371 pState->rcUnpack = VERR_INVALID_PARAMETER;
372 return;
373 }
374 pixels = DATA_POINTER(pState, sizeof( int ) + 40, GLvoid );
375 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, cbImg, GLubyte);
376 }
377
378 pState->pDispatchTbl->PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
379 pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
380 pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
381 pState->pDispatchTbl->PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
382
383 pState->pDispatchTbl->TexSubImage2D( target, level, xoffset, yoffset, width,
384 height, format, type, pixels );
385 INCR_VAR_PTR(pState);
386}
387
388void crUnpackTexSubImage1D(PCrUnpackerState pState)
389{
390 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 24, int);
391
392 GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
393 GLint level = READ_DATA(pState, sizeof( int ) + 4, GLint );
394 GLint xoffset = READ_DATA(pState, sizeof( int ) + 8, GLint );
395 GLsizei width = READ_DATA(pState, sizeof( int ) + 12, GLsizei );
396 GLenum format = READ_DATA(pState, sizeof( int ) + 16, GLenum );
397 GLenum type = READ_DATA(pState, sizeof( int ) + 20, GLenum );
398 int noimagedata = READ_DATA(pState, sizeof( int ) + 24, int );
399 GLvoid *pixels;
400
401 CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, sizeof(int)+28, GLint);
402 if ( noimagedata )
403 pixels = (void*) (uintptr_t) READ_DATA(pState, sizeof(int)+28, GLint);
404 else
405 {
406 size_t cbImg = crImageSize(format, type, width, 1);
407 if (RT_UNLIKELY(cbImg == 0))
408 {
409 pState->rcUnpack = VERR_INVALID_PARAMETER;
410 return;
411 }
412 pixels = DATA_POINTER(pState, sizeof( int ) + 32, GLvoid );
413 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, cbImg, GLubyte);
414 }
415
416 pState->pDispatchTbl->PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
417 pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
418 pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
419 pState->pDispatchTbl->PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
420
421 pState->pDispatchTbl->TexSubImage1D( target, level, xoffset, width, format,
422 type, pixels );
423 INCR_VAR_PTR(pState);
424}
425
426
427void crUnpackTexEnvfv(PCrUnpackerState pState)
428{
429 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
430
431 GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
432 GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
433 GLfloat *params = DATA_POINTER(pState, sizeof( int ) + 8, GLfloat );
434
435 size_t cParams = 1;
436 if (pname == GL_TEXTURE_ENV_COLOR)
437 cParams = 4;
438
439 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, cParams, GLfloat);
440 pState->pDispatchTbl->TexEnvfv( target, pname, params );
441 INCR_VAR_PTR(pState);
442}
443
444void crUnpackTexEnviv(PCrUnpackerState pState)
445{
446 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
447
448 GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
449 GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
450 GLint *params = DATA_POINTER(pState, sizeof( int ) + 8, GLint );
451
452 size_t cParams = 1;
453 if (pname == GL_TEXTURE_ENV_COLOR)
454 cParams = 4;
455
456 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, cParams, GLint);
457 pState->pDispatchTbl->TexEnviv( target, pname, params );
458 INCR_VAR_PTR(pState);
459}
460
461void crUnpackTexGendv(PCrUnpackerState pState)
462{
463 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
464
465 GLenum coord = READ_DATA(pState, sizeof( int ) + 0, GLenum );
466 GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
467 GLdouble *params = DATA_POINTER(pState, sizeof( int ) + 8, GLdouble );
468
469 size_t cParams = 1;
470 if (pname == GL_OBJECT_PLANE || pname == GL_EYE_PLANE)
471 cParams = 4;
472
473 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, cParams, GLdouble);
474 pState->pDispatchTbl->TexGendv( coord, pname, params );
475 INCR_VAR_PTR(pState);
476}
477
478void crUnpackTexGenfv(PCrUnpackerState pState)
479{
480 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
481
482 GLenum coord = READ_DATA(pState, sizeof( int ) + 0, GLenum );
483 GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
484 GLfloat *params = DATA_POINTER(pState, sizeof( int ) + 8, GLfloat );
485
486 size_t cParams = 1;
487 if (pname == GL_OBJECT_PLANE || pname == GL_EYE_PLANE)
488 cParams = 4;
489
490 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, cParams, GLfloat);
491 pState->pDispatchTbl->TexGenfv( coord, pname, params );
492 INCR_VAR_PTR(pState);
493}
494
495void crUnpackTexGeniv(PCrUnpackerState pState)
496{
497 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
498
499 GLenum coord = READ_DATA(pState, sizeof( int ) + 0, GLenum );
500 GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
501 GLint *params = DATA_POINTER(pState, sizeof( int ) + 8, GLint );
502
503 size_t cParams = 1;
504 if (pname == GL_OBJECT_PLANE || pname == GL_EYE_PLANE)
505 cParams = 4;
506
507 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, cParams, GLint);
508 pState->pDispatchTbl->TexGeniv( coord, pname, params );
509 INCR_VAR_PTR(pState);
510}
511
512void crUnpackExtendAreTexturesResident(PCrUnpackerState pState)
513{
514 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 8, GLsizei);
515
516 GLsizei n = READ_DATA(pState, 8, GLsizei );
517 const GLuint *textures = DATA_POINTER(pState, 12, const GLuint );
518
519 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, textures, n, GLuint);
520 CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 20 + n * sizeof(GLuint), CRNetworkPointer);
521 SET_RETURN_PTR(pState, 12 + n * sizeof(GLuint));
522 SET_WRITEBACK_PTR(pState, 20 + n * sizeof(GLuint));
523 (void) pState->pDispatchTbl->AreTexturesResident( n, textures, NULL );
524}
525
526
527void crUnpackExtendCompressedTexImage3DARB(PCrUnpackerState pState)
528{
529 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 4 + sizeof(int) + 32, int);
530
531 GLenum target = READ_DATA(pState, 4 + sizeof(int) + 0, GLenum );
532 GLint level = READ_DATA(pState, 4 + sizeof(int) + 4, GLint );
533 GLenum internalformat = READ_DATA(pState, 4 + sizeof(int) + 8, GLenum );
534 GLsizei width = READ_DATA(pState, 4 + sizeof(int) + 12, GLsizei );
535 GLsizei height = READ_DATA(pState, 4 + sizeof(int) + 16, GLsizei );
536 GLsizei depth = READ_DATA(pState, 4 + sizeof(int) + 20, GLsizei );
537 GLint border = READ_DATA(pState, 4 + sizeof(int) + 24, GLint );
538 GLsizei imagesize = READ_DATA(pState, 4 + sizeof(int) + 28, GLsizei );
539 int noimagedata = READ_DATA(pState, 4 + sizeof(int) + 32, int );
540 GLvoid *pixels;
541
542 CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 4 + sizeof(int)+36, GLint);
543 if( noimagedata )
544 pixels = (void*) (uintptr_t) READ_DATA(pState, 4+sizeof(int)+36, GLint);
545 else
546 {
547 pixels = DATA_POINTER(pState, 4 + sizeof( int ) + 40, GLvoid );
548 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, imagesize, GLubyte);
549 }
550
551 pState->pDispatchTbl->CompressedTexImage3DARB(target, level, internalformat,
552 width, height, depth, border,
553 imagesize, pixels);
554}
555
556
557void crUnpackExtendCompressedTexImage2DARB(PCrUnpackerState pState)
558{
559 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 4 + sizeof(int) + 28, int);
560
561 GLenum target = READ_DATA(pState, 4 + sizeof( int ) + 0, GLenum );
562 GLint level = READ_DATA(pState, 4 + sizeof( int ) + 4, GLint );
563 GLenum internalformat = READ_DATA(pState, 4 + sizeof( int ) + 8, GLenum );
564 GLsizei width = READ_DATA(pState, 4 + sizeof( int ) + 12, GLsizei );
565 GLsizei height = READ_DATA(pState, 4 + sizeof( int ) + 16, GLsizei );
566 GLint border = READ_DATA(pState, 4 + sizeof( int ) + 20, GLint );
567 GLsizei imagesize = READ_DATA(pState, 4 + sizeof( int ) + 24, GLsizei );
568 int noimagedata = READ_DATA(pState, 4 + sizeof( int ) + 28, int );
569 GLvoid *pixels;
570
571 CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 4 + sizeof(int)+32, GLint);
572 if ( noimagedata )
573 pixels = (void*) (uintptr_t) READ_DATA(pState, 4+sizeof(int)+32, GLint);
574 else
575 {
576 pixels = DATA_POINTER(pState, 4 + sizeof( int ) + 36, GLvoid );
577 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, imagesize, GLubyte);
578 }
579
580 pState->pDispatchTbl->CompressedTexImage2DARB( target, level, internalformat,
581 width, height, border, imagesize,
582 pixels );
583}
584
585
586void crUnpackExtendCompressedTexImage1DARB(PCrUnpackerState pState)
587{
588 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 4 + sizeof(int) + 24, int);
589
590 GLenum target = READ_DATA(pState, 4 + sizeof(int) + 0, GLenum );
591 GLint level = READ_DATA(pState, 4 + sizeof(int) + 4, GLint );
592 GLenum internalformat = READ_DATA(pState, 4 + sizeof(int) + 8, GLenum );
593 GLsizei width = READ_DATA(pState, 4 + sizeof(int) + 12, GLsizei );
594 GLint border = READ_DATA(pState, 4 + sizeof(int) + 16, GLint );
595 GLsizei imagesize = READ_DATA(pState, 4 + sizeof(int) + 20, GLsizei );
596 int noimagedata = READ_DATA(pState, 4 + sizeof(int) + 24, int );
597 GLvoid *pixels;
598
599 CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 4 + sizeof(int)+28, GLint);
600 if( noimagedata )
601 pixels = (void*) (uintptr_t) READ_DATA(pState, 4+sizeof(int)+28, GLint);
602 else
603 {
604 pixels = DATA_POINTER(pState, 4 + sizeof( int ) + 32, GLvoid );
605 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, imagesize, GLubyte);
606 }
607
608 pState->pDispatchTbl->CompressedTexImage1DARB(target, level, internalformat,
609 width, border, imagesize, pixels);
610}
611
612
613void crUnpackExtendCompressedTexSubImage3DARB(PCrUnpackerState pState)
614{
615 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 4 + sizeof(int) + 40, int);
616
617 GLenum target = READ_DATA(pState, 4 + sizeof(int) + 0, GLenum );
618 GLint level = READ_DATA(pState, 4 + sizeof(int) + 4, GLint );
619 GLint xoffset = READ_DATA(pState, 4 + sizeof(int) + 8, GLint );
620 GLint yoffset = READ_DATA(pState, 4 + sizeof(int) + 12, GLint );
621 GLint zoffset = READ_DATA(pState, 4 + sizeof(int) + 16, GLint );
622 GLsizei width = READ_DATA(pState, 4 + sizeof(int) + 20, GLsizei );
623 GLsizei height = READ_DATA(pState, 4 + sizeof(int) + 24, GLsizei );
624 GLsizei depth = READ_DATA(pState, 4 + sizeof(int) + 28, GLsizei );
625 GLenum format = READ_DATA(pState, 4 + sizeof(int) + 32, GLenum );
626 GLsizei imagesize = READ_DATA(pState, 4 + sizeof(int) + 36, GLsizei );
627 int noimagedata = READ_DATA(pState, 4 + sizeof(int) + 40, int );
628 GLvoid *pixels;
629
630 CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 4 + sizeof(int)+44, GLint);
631 if( noimagedata )
632 pixels = (void*) (uintptr_t) READ_DATA(pState, 4+sizeof(int)+44, GLint);
633 else
634 {
635 pixels = DATA_POINTER(pState, 4 + sizeof( int ) + 48, GLvoid );
636 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, imagesize, GLubyte);
637 }
638
639 pState->pDispatchTbl->CompressedTexSubImage3DARB(target, level, xoffset,
640 yoffset, zoffset, width,
641 height, depth, format,
642 imagesize, pixels);
643}
644
645
646void crUnpackExtendCompressedTexSubImage2DARB(PCrUnpackerState pState)
647{
648 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 4 + sizeof(int) + 32, int);
649
650 GLenum target = READ_DATA(pState, 4 + sizeof(int) + 0, GLenum );
651 GLint level = READ_DATA(pState, 4 + sizeof(int) + 4, GLint );
652 GLint xoffset = READ_DATA(pState, 4 + sizeof(int) + 8, GLint );
653 GLint yoffset = READ_DATA(pState, 4 + sizeof(int) + 12, GLint );
654 GLsizei width = READ_DATA(pState, 4 + sizeof(int) + 16, GLsizei );
655 GLsizei height = READ_DATA(pState, 4 + sizeof(int) + 20, GLsizei );
656 GLenum format = READ_DATA(pState, 4 + sizeof(int) + 24, GLenum );
657 GLsizei imagesize = READ_DATA(pState, 4 + sizeof(int) + 28, GLsizei );
658 int noimagedata = READ_DATA(pState, 4 + sizeof(int) + 32, int );
659 GLvoid *pixels;
660
661 CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 4 + sizeof(int)+36, GLint);
662 if( noimagedata )
663 pixels = (void*) (uintptr_t) READ_DATA(pState, 4+sizeof(int)+36, GLint);
664 else
665 {
666 pixels = DATA_POINTER(pState, 4 + sizeof( int ) + 40, GLvoid );
667 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, imagesize, GLubyte);
668 }
669
670 pState->pDispatchTbl->CompressedTexSubImage2DARB(target, level, xoffset,
671 yoffset, width, height,
672 format, imagesize, pixels);
673}
674
675
676void crUnpackExtendCompressedTexSubImage1DARB(PCrUnpackerState pState)
677{
678 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 4 + sizeof(int) + 24, int);
679
680 GLenum target = READ_DATA(pState, 4 + sizeof(int) + 0, GLenum );
681 GLint level = READ_DATA(pState, 4 + sizeof(int) + 4, GLint );
682 GLint xoffset = READ_DATA(pState, 4 + sizeof(int) + 8, GLint );
683 GLsizei width = READ_DATA(pState, 4 + sizeof(int) + 12, GLsizei );
684 GLenum format = READ_DATA(pState, 4 + sizeof(int) + 16, GLenum );
685 GLsizei imagesize = READ_DATA(pState, 4 + sizeof(int) + 20, GLsizei );
686 int noimagedata = READ_DATA(pState, 4 + sizeof(int) + 24, int );
687 GLvoid *pixels;
688
689 CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 4 + sizeof(int)+28, GLint);
690 if( noimagedata )
691 pixels = (void*) (uintptr_t) READ_DATA(pState, 4+sizeof(int)+28, GLint);
692 else
693 {
694 pixels = DATA_POINTER(pState, 4 + sizeof( int ) + 32, GLvoid );
695 CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, imagesize, GLubyte);
696 }
697
698 pState->pDispatchTbl->CompressedTexSubImage1DARB(target, level, xoffset, width,
699 format, imagesize, pixels);
700}
701
702void crUnpackExtendGetTexImage(PCrUnpackerState pState)
703{
704 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 32, CRNetworkPointer);
705
706 GLenum target = READ_DATA(pState, 8, GLenum );
707 GLint level = READ_DATA(pState, 12, GLint );
708 GLenum format = READ_DATA(pState, 16, GLenum );
709 GLenum type = READ_DATA(pState, 20, GLenum );
710 GLvoid *pixels;
711
712 SET_RETURN_PTR(pState, 24);
713 SET_WRITEBACK_PTR(pState, 32);
714 pixels = DATA_POINTER(pState, 24, GLvoid); /* Used for PBO offset. */
715
716 /*
717 * pixels is not written to, see crServerDispatchGetTexImage(). It is only used as an offset
718 * The data is returned in the writeback pointer set above.
719 */
720 pState->pDispatchTbl->GetTexImage(target, level, format, type, pixels);
721}
722
723void crUnpackExtendGetCompressedTexImageARB(PCrUnpackerState pState)
724{
725 CHECK_BUFFER_SIZE_STATIC_LAST(pState, 24, CRNetworkPointer);
726
727 GLenum target = READ_DATA(pState, 8, GLenum );
728 GLint level = READ_DATA(pState, 12, GLint );
729 GLvoid *img;
730
731 SET_RETURN_PTR(pState, 16 );
732 SET_WRITEBACK_PTR(pState, 24 );
733 img = DATA_POINTER(pState, 16, GLvoid); /* Used for PBO offset. */
734
735 /* see crUnpackExtendGetTexImage() for explanations regarding verification. */
736 pState->pDispatchTbl->GetCompressedTexImageARB( target, level, img );
737}
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