VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_pixel.c@ 48999

Last change on this file since 48999 was 42499, checked in by vboxsync, 12 years ago

crOgl/wddm: per-context connections

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 25.2 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#include "cr_packfunctions.h"
7#include "cr_glstate.h"
8#include "cr_pixeldata.h"
9#include "cr_version.h"
10#include "packspu.h"
11#include "packspu_proto.h"
12
13static GLboolean packspu_CheckTexImageFormat(GLenum format)
14{
15 if (format!=GL_COLOR_INDEX
16 && format!=GL_RED
17 && format!=GL_GREEN
18 && format!=GL_BLUE
19 && format!=GL_ALPHA
20 && format!=GL_RGB
21 && format!=GL_BGR
22 && format!=GL_RGBA
23 && format!=GL_BGRA
24 && format!=GL_LUMINANCE
25 && format!=GL_LUMINANCE_ALPHA
26 && format!=GL_DEPTH_COMPONENT
27 && format!=GL_DEPTH_STENCIL)
28 {
29 /*crWarning("crPackCheckTexImageFormat FAILED format 0x%x isn't valid", format);*/
30 return GL_FALSE;
31 }
32
33 return GL_TRUE;
34}
35
36static GLboolean packspu_CheckTexImageType(GLenum type)
37{
38 if (type!=GL_UNSIGNED_BYTE
39 && type!=GL_BYTE
40 && type!=GL_BITMAP
41 && type!=GL_UNSIGNED_SHORT
42 && type!=GL_SHORT
43 && type!=GL_UNSIGNED_INT
44 && type!=GL_INT
45 && type!=GL_FLOAT
46 && type!=GL_UNSIGNED_BYTE_3_3_2
47 && type!=GL_UNSIGNED_BYTE_2_3_3_REV
48 && type!=GL_UNSIGNED_SHORT_5_6_5
49 && type!=GL_UNSIGNED_SHORT_5_6_5_REV
50 && type!=GL_UNSIGNED_SHORT_4_4_4_4
51 && type!=GL_UNSIGNED_SHORT_4_4_4_4_REV
52 && type!=GL_UNSIGNED_SHORT_5_5_5_1
53 && type!=GL_UNSIGNED_SHORT_1_5_5_5_REV
54 && type!=GL_UNSIGNED_INT_8_8_8_8
55 && type!=GL_UNSIGNED_INT_8_8_8_8_REV
56 && type!=GL_UNSIGNED_INT_10_10_10_2
57 && type!=GL_UNSIGNED_INT_2_10_10_10_REV
58 && type!=GL_UNSIGNED_INT_24_8)
59 {
60 /*crWarning("crPackCheckTexImageType FAILED type 0x%x isn't valid", type);*/
61 return GL_FALSE;
62 }
63
64 return GL_TRUE;
65}
66
67static GLboolean packspu_CheckTexImageInternalFormat(GLint internalformat)
68{
69 if (internalformat!=1
70 && internalformat!=2
71 && internalformat!=3
72 && internalformat!=4
73 && internalformat!=GL_ALPHA
74 && internalformat!=GL_ALPHA4
75 && internalformat!=GL_ALPHA8
76 && internalformat!=GL_ALPHA12
77 && internalformat!=GL_ALPHA16
78 && internalformat!=GL_COMPRESSED_ALPHA
79 && internalformat!=GL_COMPRESSED_LUMINANCE
80 && internalformat!=GL_COMPRESSED_LUMINANCE_ALPHA
81 && internalformat!=GL_COMPRESSED_INTENSITY
82 && internalformat!=GL_COMPRESSED_RGB
83 && internalformat!=GL_COMPRESSED_RGBA
84 && internalformat!=GL_DEPTH_COMPONENT
85 && internalformat!=GL_DEPTH_COMPONENT16
86 && internalformat!=GL_DEPTH_COMPONENT24
87 && internalformat!=GL_DEPTH_COMPONENT32
88 && internalformat!=GL_DEPTH24_STENCIL8
89 && internalformat!=GL_LUMINANCE
90 && internalformat!=GL_LUMINANCE4
91 && internalformat!=GL_LUMINANCE8
92 && internalformat!=GL_LUMINANCE12
93 && internalformat!=GL_LUMINANCE16
94 && internalformat!=GL_LUMINANCE_ALPHA
95 && internalformat!=GL_LUMINANCE4_ALPHA4
96 && internalformat!=GL_LUMINANCE6_ALPHA2
97 && internalformat!=GL_LUMINANCE8_ALPHA8
98 && internalformat!=GL_LUMINANCE12_ALPHA4
99 && internalformat!=GL_LUMINANCE12_ALPHA12
100 && internalformat!=GL_LUMINANCE16_ALPHA16
101 && internalformat!=GL_INTENSITY
102 && internalformat!=GL_INTENSITY4
103 && internalformat!=GL_INTENSITY8
104 && internalformat!=GL_INTENSITY12
105 && internalformat!=GL_INTENSITY16
106 && internalformat!=GL_R3_G3_B2
107 && internalformat!=GL_RGB
108 && internalformat!=GL_RGB4
109 && internalformat!=GL_RGB5
110 && internalformat!=GL_RGB8
111 && internalformat!=GL_RGB10
112 && internalformat!=GL_RGB12
113 && internalformat!=GL_RGB16
114 && internalformat!=GL_RGBA
115 && internalformat!=GL_RGBA2
116 && internalformat!=GL_RGBA4
117 && internalformat!=GL_RGB5_A1
118 && internalformat!=GL_RGBA8
119 && internalformat!=GL_RGB10_A2
120 && internalformat!=GL_RGBA12
121 && internalformat!=GL_RGBA16
122 && internalformat!=GL_SLUMINANCE
123 && internalformat!=GL_SLUMINANCE8
124 && internalformat!=GL_SLUMINANCE_ALPHA
125 && internalformat!=GL_SLUMINANCE8_ALPHA8
126 && internalformat!=GL_SRGB
127 && internalformat!=GL_SRGB8
128 && internalformat!=GL_SRGB_ALPHA
129 && internalformat!=GL_SRGB8_ALPHA8
130#ifdef CR_EXT_texture_compression_s3tc
131 && internalformat!=GL_COMPRESSED_RGB_S3TC_DXT1_EXT
132 && internalformat!=GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
133 && internalformat!=GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
134 && internalformat!=GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
135# ifdef CR_EXT_texture_sRGB
136 && internalformat!=GL_COMPRESSED_SRGB_S3TC_DXT1_EXT
137 && internalformat!=GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
138 && internalformat!=GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
139 && internalformat!=GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
140# endif
141#endif
142 /*@todo ARB_texture_float*/
143 && internalformat!=GL_RGBA32F_ARB
144 && internalformat!=GL_RGB32F_ARB
145 && internalformat!=GL_ALPHA32F_ARB
146 && internalformat!=GL_INTENSITY32F_ARB
147 && internalformat!=GL_LUMINANCE32F_ARB
148 && internalformat!=GL_LUMINANCE_ALPHA32F_ARB
149 && internalformat!=GL_RGBA16F_ARB
150 && internalformat!=GL_RGB16F_ARB
151 && internalformat!=GL_ALPHA16F_ARB
152 && internalformat!=GL_INTENSITY16F_ARB
153 && internalformat!=GL_LUMINANCE16F_ARB
154 && internalformat!=GL_LUMINANCE_ALPHA16F_ARB
155 )
156 {
157 /*crWarning("crPackCheckTexImageInternalFormat FAILED internalformat 0x%x isn't valid", internalformat);*/
158 return GL_FALSE;
159 }
160
161 return GL_TRUE;
162}
163
164static GLboolean packspu_CheckTexImageParams(GLint internalformat, GLenum format, GLenum type)
165{
166 return packspu_CheckTexImageFormat(format)
167 && packspu_CheckTexImageType(type)
168 && packspu_CheckTexImageInternalFormat(internalformat);
169}
170
171static GLboolean packspu_CheckTexImageFormatType(GLenum format, GLenum type)
172{
173 return packspu_CheckTexImageFormat(format)
174 && packspu_CheckTexImageType(type);
175}
176
177static const CRPixelPackState _defaultPacking = {
178 0, /* rowLength */
179 0, /* skipRows */
180 0, /* skipPixels */
181 1, /* alignment */
182 0, /* imageHeight */
183 0, /* skipImages */
184 GL_FALSE, /* swapBytes */
185 GL_FALSE, /* psLSBFirst */
186};
187
188#define APPLY_IF_NEQ(state, field, enum) \
189 if (state.field != _defaultPacking.field) \
190 { \
191 crPackPixelStorei(enum, state.field); \
192 }
193
194#define RESTORE_IF_NEQ(state, field, enum) \
195 if (state.field != _defaultPacking.field) \
196 { \
197 crPackPixelStorei(enum, _defaultPacking.field); \
198 }
199
200static void packspu_ApplyUnpackState()
201{
202 GET_THREAD(thread);
203 ContextInfo *ctx = thread->currentContext;
204 CRClientState *clientState = &(ctx->clientState->client);
205
206 APPLY_IF_NEQ(clientState->unpack, rowLength, GL_UNPACK_ROW_LENGTH);
207 APPLY_IF_NEQ(clientState->unpack, skipRows, GL_UNPACK_SKIP_ROWS);
208 APPLY_IF_NEQ(clientState->unpack, skipPixels, GL_UNPACK_SKIP_PIXELS);
209 APPLY_IF_NEQ(clientState->unpack, alignment, GL_UNPACK_ALIGNMENT);
210 APPLY_IF_NEQ(clientState->unpack, imageHeight, GL_UNPACK_IMAGE_HEIGHT);
211 APPLY_IF_NEQ(clientState->unpack, skipImages, GL_UNPACK_SKIP_IMAGES);
212 APPLY_IF_NEQ(clientState->unpack, swapBytes, GL_UNPACK_SWAP_BYTES);
213 APPLY_IF_NEQ(clientState->unpack, psLSBFirst, GL_UNPACK_LSB_FIRST);
214}
215
216static void packspu_RestoreUnpackState()
217{
218 GET_THREAD(thread);
219 ContextInfo *ctx = thread->currentContext;
220 CRClientState *clientState = &(ctx->clientState->client);
221
222 RESTORE_IF_NEQ(clientState->unpack, rowLength, GL_UNPACK_ROW_LENGTH);
223 RESTORE_IF_NEQ(clientState->unpack, skipRows, GL_UNPACK_SKIP_ROWS);
224 RESTORE_IF_NEQ(clientState->unpack, skipPixels, GL_UNPACK_SKIP_PIXELS);
225 RESTORE_IF_NEQ(clientState->unpack, alignment, GL_UNPACK_ALIGNMENT);
226 RESTORE_IF_NEQ(clientState->unpack, imageHeight, GL_UNPACK_IMAGE_HEIGHT);
227 RESTORE_IF_NEQ(clientState->unpack, skipImages, GL_UNPACK_SKIP_IMAGES);
228 RESTORE_IF_NEQ(clientState->unpack, swapBytes, GL_UNPACK_SWAP_BYTES);
229 RESTORE_IF_NEQ(clientState->unpack, psLSBFirst, GL_UNPACK_LSB_FIRST);
230}
231
232static void packspu_ApplyPackState()
233{
234 GET_THREAD(thread);
235 ContextInfo *ctx = thread->currentContext;
236 CRClientState *clientState = &(ctx->clientState->client);
237
238 APPLY_IF_NEQ(clientState->pack, rowLength, GL_PACK_ROW_LENGTH);
239 APPLY_IF_NEQ(clientState->pack, skipRows, GL_PACK_SKIP_ROWS);
240 APPLY_IF_NEQ(clientState->pack, skipPixels, GL_PACK_SKIP_PIXELS);
241 APPLY_IF_NEQ(clientState->pack, alignment, GL_PACK_ALIGNMENT);
242 APPLY_IF_NEQ(clientState->pack, imageHeight, GL_PACK_IMAGE_HEIGHT);
243 APPLY_IF_NEQ(clientState->pack, skipImages, GL_PACK_SKIP_IMAGES);
244 APPLY_IF_NEQ(clientState->pack, swapBytes, GL_PACK_SWAP_BYTES);
245 APPLY_IF_NEQ(clientState->pack, psLSBFirst, GL_PACK_LSB_FIRST);
246}
247
248static void packspu_RestorePackState()
249{
250 GET_THREAD(thread);
251 ContextInfo *ctx = thread->currentContext;
252 CRClientState *clientState = &(ctx->clientState->client);
253
254 RESTORE_IF_NEQ(clientState->pack, rowLength, GL_PACK_ROW_LENGTH);
255 RESTORE_IF_NEQ(clientState->pack, skipRows, GL_PACK_SKIP_ROWS);
256 RESTORE_IF_NEQ(clientState->pack, skipPixels, GL_PACK_SKIP_PIXELS);
257 RESTORE_IF_NEQ(clientState->pack, alignment, GL_PACK_ALIGNMENT);
258 RESTORE_IF_NEQ(clientState->pack, imageHeight, GL_PACK_IMAGE_HEIGHT);
259 RESTORE_IF_NEQ(clientState->pack, skipImages, GL_PACK_SKIP_IMAGES);
260 RESTORE_IF_NEQ(clientState->pack, swapBytes, GL_PACK_SWAP_BYTES);
261 RESTORE_IF_NEQ(clientState->pack, psLSBFirst, GL_PACK_LSB_FIRST);
262}
263
264void PACKSPU_APIENTRY packspu_PixelStoref( GLenum pname, GLfloat param )
265{
266 /* NOTE: we do not send pixel store parameters to the server!
267 * When we pack a glDrawPixels or glTexImage2D image we interpret
268 * the user's pixel store parameters at that time and pack the
269 * image in a canonical layout (see util/pixel.c).
270 */
271 crStatePixelStoref( pname, param );
272}
273
274void PACKSPU_APIENTRY packspu_PixelStorei( GLenum pname, GLint param )
275{
276 crStatePixelStorei( pname, param );
277}
278
279void PACKSPU_APIENTRY packspu_DrawPixels( GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels )
280{
281 GET_THREAD(thread);
282 ContextInfo *ctx = thread->currentContext;
283 CRClientState *clientState = &(ctx->clientState->client);
284
285 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
286 {
287 packspu_ApplyUnpackState();
288 }
289
290 crPackDrawPixels( width, height, format, type, pixels, &(clientState->unpack) );
291
292 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
293 {
294 packspu_RestoreUnpackState();
295 }
296}
297
298void PACKSPU_APIENTRY packspu_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels )
299{
300 GET_THREAD(thread);
301 ContextInfo *ctx = thread->currentContext;
302 CRClientState *clientState = &(ctx->clientState->client);
303 int writeback;
304
305 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
306 {
307 packspu_ApplyPackState();
308 }
309
310 crPackReadPixels(x, y, width, height, format, type, pixels, &(clientState->pack), &writeback);
311
312 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
313 {
314 packspu_RestorePackState();
315 }
316
317#ifdef CR_ARB_pixel_buffer_object
318 if (!crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
319#endif
320 {
321 pack_spu.ReadPixels++;
322
323 packspuFlush((void *) thread);
324 CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
325 }
326}
327
328/*@todo check with pbo's*/
329void PACKSPU_APIENTRY packspu_CopyPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum type )
330{
331 GET_THREAD(thread);
332 if (pack_spu.swap)
333 crPackCopyPixelsSWAP( x, y, width, height, type );
334 else
335 crPackCopyPixels( x, y, width, height, type );
336 /* XXX why flush here? */
337 packspuFlush( (void *) thread );
338}
339
340void PACKSPU_APIENTRY packspu_Bitmap( GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap )
341{
342 GET_CONTEXT(ctx);
343 CRClientState *clientState = &(ctx->clientState->client);
344
345 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
346 {
347 packspu_ApplyUnpackState();
348 }
349
350 crPackBitmap(width, height, xorig, yorig, xmove, ymove, bitmap, &(clientState->unpack));
351
352 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
353 {
354 packspu_RestoreUnpackState();
355 }
356}
357
358void PACKSPU_APIENTRY packspu_TexImage1D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
359{
360 GET_CONTEXT(ctx);
361 CRClientState *clientState = &(ctx->clientState->client);
362
363 if (!packspu_CheckTexImageParams(internalformat, format, type))
364 {
365 if (pixels || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
366 {
367 crWarning("packspu_TexImage1D invalid internalFormat(%x)/format(%x)/type(%x)", internalformat, format, type);
368 return;
369 }
370 internalformat = packspu_CheckTexImageInternalFormat(internalformat) ? internalformat:GL_RGBA;
371 format = packspu_CheckTexImageFormat(format) ? format:GL_RGBA;
372 type = packspu_CheckTexImageType(type) ? type:GL_UNSIGNED_BYTE;
373 }
374
375 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
376 {
377 packspu_ApplyUnpackState();
378 }
379
380 if (pack_spu.swap)
381 crPackTexImage1DSWAP( target, level, internalformat, width, border, format, type, pixels, &(clientState->unpack) );
382 else
383 crPackTexImage1D( target, level, internalformat, width, border, format, type, pixels, &(clientState->unpack) );
384
385 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
386 {
387 packspu_RestoreUnpackState();
388 }
389}
390
391void PACKSPU_APIENTRY packspu_TexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
392{
393 GET_CONTEXT(ctx);
394 CRClientState *clientState = &(ctx->clientState->client);
395
396 if (!packspu_CheckTexImageParams(internalformat, format, type))
397 {
398 if (pixels || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
399 {
400 crWarning("packspu_TexImage2D invalid internalFormat(%x)/format(%x)/type(%x)", internalformat, format, type);
401 return;
402 }
403 internalformat = packspu_CheckTexImageInternalFormat(internalformat) ? internalformat:GL_RGBA;
404 format = packspu_CheckTexImageFormat(format) ? format:GL_RGBA;
405 type = packspu_CheckTexImageType(type) ? type:GL_UNSIGNED_BYTE;
406 }
407
408 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
409 {
410 packspu_ApplyUnpackState();
411 }
412
413 if (pack_spu.swap)
414 crPackTexImage2DSWAP( target, level, internalformat, width, height, border, format, type, pixels, &(clientState->unpack) );
415 else
416 crPackTexImage2D( target, level, internalformat, width, height, border, format, type, pixels, &(clientState->unpack) );
417
418 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
419 {
420 packspu_RestoreUnpackState();
421 }
422}
423
424#ifdef GL_EXT_texture3D
425void PACKSPU_APIENTRY packspu_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
426{
427 GET_CONTEXT(ctx);
428 CRClientState *clientState = &(ctx->clientState->client);
429
430 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
431 {
432 packspu_ApplyUnpackState();
433 }
434
435 if (pack_spu.swap)
436 crPackTexImage3DEXTSWAP( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) );
437 else
438 crPackTexImage3DEXT( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) );
439
440 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
441 {
442 packspu_RestoreUnpackState();
443 }
444}
445#endif
446
447#ifdef CR_OPENGL_VERSION_1_2
448void PACKSPU_APIENTRY packspu_TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
449{
450 GET_CONTEXT(ctx);
451 CRClientState *clientState = &(ctx->clientState->client);
452
453 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
454 {
455 packspu_ApplyUnpackState();
456 }
457
458 if (pack_spu.swap)
459 crPackTexImage3DSWAP( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) );
460 else
461 crPackTexImage3D( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) );
462
463 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
464 {
465 packspu_RestoreUnpackState();
466 }
467}
468#endif /* CR_OPENGL_VERSION_1_2 */
469
470void PACKSPU_APIENTRY packspu_TexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels )
471{
472 GET_CONTEXT(ctx);
473 CRClientState *clientState = &(ctx->clientState->client);
474
475 if (!packspu_CheckTexImageFormatType(format, type))
476 {
477 crWarning("packspu_TexSubImage1D invalid format(%x)/type(%x)", format, type);
478 return;
479 }
480
481 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
482 {
483 packspu_ApplyUnpackState();
484 }
485
486 if (pack_spu.swap)
487 crPackTexSubImage1DSWAP( target, level, xoffset, width, format, type, pixels, &(clientState->unpack) );
488 else
489 crPackTexSubImage1D( target, level, xoffset, width, format, type, pixels, &(clientState->unpack) );
490
491 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
492 {
493 packspu_RestoreUnpackState();
494 }
495}
496
497void PACKSPU_APIENTRY packspu_TexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels )
498{
499 GET_CONTEXT(ctx);
500 CRClientState *clientState = &(ctx->clientState->client);
501
502 if (!packspu_CheckTexImageFormatType(format, type))
503 {
504 crWarning("packspu_TexSubImage2D invalid format(%x)/type(%x)", format, type);
505 return;
506 }
507
508 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
509 {
510 packspu_ApplyUnpackState();
511 }
512
513 if (pack_spu.swap)
514 crPackTexSubImage2DSWAP( target, level, xoffset, yoffset, width, height, format, type, pixels, &(clientState->unpack) );
515 else
516 crPackTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels, &(clientState->unpack) );
517
518 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
519 {
520 packspu_RestoreUnpackState();
521 }
522}
523
524#ifdef CR_OPENGL_VERSION_1_2
525void PACKSPU_APIENTRY packspu_TexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels )
526{
527 GET_CONTEXT(ctx);
528 CRClientState *clientState = &(ctx->clientState->client);
529
530 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
531 {
532 packspu_ApplyUnpackState();
533 }
534
535 if (pack_spu.swap)
536 crPackTexSubImage3DSWAP( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels, &(clientState->unpack) );
537 else
538 crPackTexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels, &(clientState->unpack) );
539
540 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
541 {
542 packspu_RestoreUnpackState();
543 }
544}
545#endif /* CR_OPENGL_VERSION_1_2 */
546
547void PACKSPU_APIENTRY packspu_ZPixCR( GLsizei width, GLsizei height, GLenum format, GLenum type, GLenum ztype, GLint zparm, GLint length, const GLvoid *pixels )
548{
549 GET_CONTEXT(ctx);
550 CRClientState *clientState = &(ctx->clientState->client);
551 if (pack_spu.swap)
552 crPackZPixCRSWAP( width, height, format, type, ztype, zparm, length, pixels, &(clientState->unpack) );
553 else
554 crPackZPixCR( width, height, format, type, ztype, zparm, length, pixels, &(clientState->unpack) );
555}
556
557void PACKSPU_APIENTRY packspu_GetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels)
558{
559 GET_THREAD(thread);
560 ContextInfo *ctx = thread->currentContext;
561 CRClientState *clientState = &(ctx->clientState->client);
562 int writeback = 1;
563
564 /* XXX note: we're not observing the pixel pack parameters here unless PACK PBO is bound
565 * To do so, we'd have to allocate a temporary image buffer (how large???)
566 * and copy the image to the user's buffer using the pixel pack params.
567 */
568
569 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
570 {
571 packspu_ApplyPackState();
572 }
573
574 if (pack_spu.swap)
575 crPackGetTexImageSWAP( target, level, format, type, pixels, &(clientState->pack), &writeback );
576 else
577 crPackGetTexImage( target, level, format, type, pixels, &(clientState->pack), &writeback );
578
579 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
580 {
581 packspu_RestorePackState();
582 }
583
584#ifdef CR_ARB_pixel_buffer_object
585 if (!crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
586#endif
587 {
588 packspuFlush( (void *) thread );
589 CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
590 }
591}
592
593void PACKSPU_APIENTRY packspu_GetCompressedTexImageARB( GLenum target, GLint level, GLvoid * img )
594{
595 GET_THREAD(thread);
596 int writeback = 1;
597
598 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
599 {
600 packspu_ApplyPackState();
601 }
602
603 if (pack_spu.swap)
604 {
605 crPackGetCompressedTexImageARBSWAP( target, level, img, &writeback );
606 }
607 else
608 {
609 crPackGetCompressedTexImageARB( target, level, img, &writeback );
610 }
611
612 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
613 {
614 packspu_RestorePackState();
615 }
616
617#ifdef CR_ARB_pixel_buffer_object
618 if (!crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
619#endif
620 {
621 packspuFlush( (void *) thread );
622 CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
623 }
624}
625
626void PACKSPU_APIENTRY
627packspu_CompressedTexImage1DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width,
628 GLint border, GLsizei imagesize, const GLvoid *data)
629{
630 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
631 {
632 packspu_ApplyUnpackState();
633 }
634
635 crPackCompressedTexImage1DARB(target, level, internalformat, width, border, imagesize, data);
636
637 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
638 {
639 packspu_RestoreUnpackState();
640 }
641}
642
643void PACKSPU_APIENTRY
644packspu_CompressedTexImage2DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width,
645 GLsizei height, GLint border, GLsizei imagesize, const GLvoid *data)
646{
647 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
648 {
649 packspu_ApplyUnpackState();
650 }
651
652 crPackCompressedTexImage2DARB(target, level, internalformat, width, height, border, imagesize, data);
653
654 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
655 {
656 packspu_RestoreUnpackState();
657 }
658}
659
660void PACKSPU_APIENTRY
661packspu_CompressedTexImage3DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width,
662 GLsizei height, GLsizei depth, GLint border, GLsizei imagesize, const GLvoid *data)
663{
664 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
665 {
666 packspu_ApplyUnpackState();
667 }
668
669 crPackCompressedTexImage3DARB(target, level, internalformat, width, height, depth, border, imagesize, data);
670
671 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
672 {
673 packspu_RestoreUnpackState();
674 }
675}
676
677void PACKSPU_APIENTRY
678packspu_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, GLsizei width,
679 GLenum format, GLsizei imagesize, const GLvoid *data)
680{
681 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
682 {
683 packspu_ApplyUnpackState();
684 }
685
686 crPackCompressedTexSubImage1DARB(target, level, xoffset, width, format, imagesize, data);
687
688 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
689 {
690 packspu_RestoreUnpackState();
691 }
692}
693
694void PACKSPU_APIENTRY
695packspu_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset,
696 GLsizei width, GLsizei height, GLenum format, GLsizei imagesize, const GLvoid *data)
697{
698 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
699 {
700 packspu_ApplyUnpackState();
701 }
702
703 crPackCompressedTexSubImage2DARB(target, level, xoffset, yoffset, width, height, format, imagesize, data);
704
705 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
706 {
707 packspu_RestoreUnpackState();
708 }
709}
710
711void PACKSPU_APIENTRY
712packspu_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset,
713 GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format,
714 GLsizei imagesize, const GLvoid *data)
715{
716 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
717 {
718 packspu_ApplyUnpackState();
719 }
720
721 crPackCompressedTexSubImage3DARB(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imagesize, data);
722
723 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
724 {
725 packspu_RestoreUnpackState();
726 }
727}
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