VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_pixel.c@ 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: 23.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#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(void)
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(void)
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(void)
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(void)
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 crPackCopyPixels( x, y, width, height, type );
333 /* XXX why flush here? */
334 packspuFlush( (void *) thread );
335}
336
337void PACKSPU_APIENTRY packspu_Bitmap( GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap )
338{
339 GET_CONTEXT(ctx);
340 CRClientState *clientState = &(ctx->clientState->client);
341
342 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
343 {
344 packspu_ApplyUnpackState();
345 }
346
347 crPackBitmap(width, height, xorig, yorig, xmove, ymove, bitmap, &(clientState->unpack));
348
349 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
350 {
351 packspu_RestoreUnpackState();
352 }
353}
354
355void PACKSPU_APIENTRY packspu_TexImage1D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
356{
357 GET_CONTEXT(ctx);
358 CRClientState *clientState = &(ctx->clientState->client);
359
360 if (!packspu_CheckTexImageParams(internalformat, format, type))
361 {
362 if (pixels || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
363 {
364 crWarning("packspu_TexImage1D invalid internalFormat(%x)/format(%x)/type(%x)", internalformat, format, type);
365 return;
366 }
367 internalformat = packspu_CheckTexImageInternalFormat(internalformat) ? internalformat:GL_RGBA;
368 format = packspu_CheckTexImageFormat(format) ? format:GL_RGBA;
369 type = packspu_CheckTexImageType(type) ? type:GL_UNSIGNED_BYTE;
370 }
371
372 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
373 {
374 packspu_ApplyUnpackState();
375 }
376
377 crPackTexImage1D( target, level, internalformat, width, border, format, type, pixels, &(clientState->unpack) );
378 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
379 {
380 packspu_RestoreUnpackState();
381 }
382}
383
384void PACKSPU_APIENTRY packspu_TexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
385{
386 GET_CONTEXT(ctx);
387 CRClientState *clientState = &(ctx->clientState->client);
388
389 if (!packspu_CheckTexImageParams(internalformat, format, type))
390 {
391 if (pixels || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
392 {
393 crWarning("packspu_TexImage2D invalid internalFormat(%x)/format(%x)/type(%x)", internalformat, format, type);
394 return;
395 }
396 internalformat = packspu_CheckTexImageInternalFormat(internalformat) ? internalformat:GL_RGBA;
397 format = packspu_CheckTexImageFormat(format) ? format:GL_RGBA;
398 type = packspu_CheckTexImageType(type) ? type:GL_UNSIGNED_BYTE;
399 }
400
401 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
402 {
403 packspu_ApplyUnpackState();
404 }
405
406 crPackTexImage2D( target, level, internalformat, width, height, border, format, type, pixels, &(clientState->unpack) );
407 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
408 {
409 packspu_RestoreUnpackState();
410 }
411}
412
413#ifdef GL_EXT_texture3D
414void 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 )
415{
416 GET_CONTEXT(ctx);
417 CRClientState *clientState = &(ctx->clientState->client);
418
419 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
420 {
421 packspu_ApplyUnpackState();
422 }
423
424 crPackTexImage3DEXT( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) );
425 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
426 {
427 packspu_RestoreUnpackState();
428 }
429}
430#endif
431
432#ifdef CR_OPENGL_VERSION_1_2
433void 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 )
434{
435 GET_CONTEXT(ctx);
436 CRClientState *clientState = &(ctx->clientState->client);
437
438 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
439 {
440 packspu_ApplyUnpackState();
441 }
442
443 crPackTexImage3D( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) );
444 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
445 {
446 packspu_RestoreUnpackState();
447 }
448}
449#endif /* CR_OPENGL_VERSION_1_2 */
450
451void PACKSPU_APIENTRY packspu_TexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels )
452{
453 GET_CONTEXT(ctx);
454 CRClientState *clientState = &(ctx->clientState->client);
455
456 if (!packspu_CheckTexImageFormatType(format, type))
457 {
458 crWarning("packspu_TexSubImage1D invalid format(%x)/type(%x)", format, type);
459 return;
460 }
461
462 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
463 {
464 packspu_ApplyUnpackState();
465 }
466
467 crPackTexSubImage1D( target, level, xoffset, width, format, type, pixels, &(clientState->unpack) );
468 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
469 {
470 packspu_RestoreUnpackState();
471 }
472}
473
474void PACKSPU_APIENTRY packspu_TexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels )
475{
476 GET_CONTEXT(ctx);
477 CRClientState *clientState = &(ctx->clientState->client);
478
479 if (!packspu_CheckTexImageFormatType(format, type))
480 {
481 crWarning("packspu_TexSubImage2D invalid format(%x)/type(%x)", format, type);
482 return;
483 }
484
485 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
486 {
487 packspu_ApplyUnpackState();
488 }
489
490 crPackTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels, &(clientState->unpack) );
491 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
492 {
493 packspu_RestoreUnpackState();
494 }
495}
496
497#ifdef CR_OPENGL_VERSION_1_2
498void 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 )
499{
500 GET_CONTEXT(ctx);
501 CRClientState *clientState = &(ctx->clientState->client);
502
503 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
504 {
505 packspu_ApplyUnpackState();
506 }
507
508 crPackTexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels, &(clientState->unpack) );
509 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
510 {
511 packspu_RestoreUnpackState();
512 }
513}
514#endif /* CR_OPENGL_VERSION_1_2 */
515
516void PACKSPU_APIENTRY packspu_ZPixCR( GLsizei width, GLsizei height, GLenum format, GLenum type, GLenum ztype, GLint zparm, GLint length, const GLvoid *pixels )
517{
518 GET_CONTEXT(ctx);
519 CRClientState *clientState = &(ctx->clientState->client);
520 crPackZPixCR( width, height, format, type, ztype, zparm, length, pixels, &(clientState->unpack) );
521}
522
523void PACKSPU_APIENTRY packspu_GetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels)
524{
525 GET_THREAD(thread);
526 ContextInfo *ctx = thread->currentContext;
527 CRClientState *clientState = &(ctx->clientState->client);
528 int writeback = 1;
529
530 /* XXX note: we're not observing the pixel pack parameters here unless PACK PBO is bound
531 * To do so, we'd have to allocate a temporary image buffer (how large???)
532 * and copy the image to the user's buffer using the pixel pack params.
533 */
534
535 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
536 {
537 packspu_ApplyPackState();
538 }
539
540 crPackGetTexImage( target, level, format, type, pixels, &(clientState->pack), &writeback );
541 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
542 {
543 packspu_RestorePackState();
544 }
545
546#ifdef CR_ARB_pixel_buffer_object
547 if (!crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
548#endif
549 {
550 packspuFlush( (void *) thread );
551 CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
552 }
553}
554
555void PACKSPU_APIENTRY packspu_GetCompressedTexImageARB( GLenum target, GLint level, GLvoid * img )
556{
557 GET_THREAD(thread);
558 int writeback = 1;
559
560 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
561 {
562 packspu_ApplyPackState();
563 }
564
565 crPackGetCompressedTexImageARB( target, level, img, &writeback );
566 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
567 {
568 packspu_RestorePackState();
569 }
570
571#ifdef CR_ARB_pixel_buffer_object
572 if (!crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
573#endif
574 {
575 packspuFlush( (void *) thread );
576 CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
577 }
578}
579
580void PACKSPU_APIENTRY
581packspu_CompressedTexImage1DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width,
582 GLint border, GLsizei imagesize, const GLvoid *data)
583{
584 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
585 {
586 packspu_ApplyUnpackState();
587 }
588
589 crPackCompressedTexImage1DARB(target, level, internalformat, width, border, imagesize, data);
590
591 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
592 {
593 packspu_RestoreUnpackState();
594 }
595}
596
597void PACKSPU_APIENTRY
598packspu_CompressedTexImage2DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width,
599 GLsizei height, GLint border, GLsizei imagesize, const GLvoid *data)
600{
601 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
602 {
603 packspu_ApplyUnpackState();
604 }
605
606 crPackCompressedTexImage2DARB(target, level, internalformat, width, height, border, imagesize, data);
607
608 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
609 {
610 packspu_RestoreUnpackState();
611 }
612}
613
614void PACKSPU_APIENTRY
615packspu_CompressedTexImage3DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width,
616 GLsizei height, GLsizei depth, GLint border, GLsizei imagesize, const GLvoid *data)
617{
618 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
619 {
620 packspu_ApplyUnpackState();
621 }
622
623 crPackCompressedTexImage3DARB(target, level, internalformat, width, height, depth, border, imagesize, data);
624
625 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
626 {
627 packspu_RestoreUnpackState();
628 }
629}
630
631void PACKSPU_APIENTRY
632packspu_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, GLsizei width,
633 GLenum format, GLsizei imagesize, const GLvoid *data)
634{
635 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
636 {
637 packspu_ApplyUnpackState();
638 }
639
640 crPackCompressedTexSubImage1DARB(target, level, xoffset, width, format, imagesize, data);
641
642 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
643 {
644 packspu_RestoreUnpackState();
645 }
646}
647
648void PACKSPU_APIENTRY
649packspu_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset,
650 GLsizei width, GLsizei height, GLenum format, GLsizei imagesize, const GLvoid *data)
651{
652 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
653 {
654 packspu_ApplyUnpackState();
655 }
656
657 crPackCompressedTexSubImage2DARB(target, level, xoffset, yoffset, width, height, format, imagesize, data);
658
659 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
660 {
661 packspu_RestoreUnpackState();
662 }
663}
664
665void PACKSPU_APIENTRY
666packspu_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset,
667 GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format,
668 GLsizei imagesize, const GLvoid *data)
669{
670 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
671 {
672 packspu_ApplyUnpackState();
673 }
674
675 crPackCompressedTexSubImage3DARB(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imagesize, data);
676
677 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
678 {
679 packspu_RestoreUnpackState();
680 }
681}
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