Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygentexformat_tmp.h
Go to the documentation of this file.
00001 /* 00002 * Mesa 3-D graphics library 00003 * Version: 6.5.1 00004 * 00005 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 00006 * 00007 * Permission is hereby granted, free of charge, to any person obtaining a 00008 * copy of this software and associated documentation files (the "Software"), 00009 * to deal in the Software without restriction, including without limitation 00010 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00011 * and/or sell copies of the Software, and to permit persons to whom the 00012 * Software is furnished to do so, subject to the following conditions: 00013 * 00014 * The above copyright notice and this permission notice shall be included 00015 * in all copies or substantial portions of the Software. 00016 * 00017 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00018 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00019 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00020 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00021 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00022 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00023 */ 00024 00025 00044 #if DIM == 1 00045 00046 #define TEXEL_ADDR( type, image, i, j, k, size ) \ 00047 ((void) (j), (void) (k), ((type *)(image)->Data + (i) * (size))) 00048 00049 #define FETCH(x) fetch_texel_1d_##x 00050 00051 #elif DIM == 2 00052 00053 #define TEXEL_ADDR( type, image, i, j, k, size ) \ 00054 ((void) (k), \ 00055 ((type *)(image)->Data + ((image)->RowStride * (j) + (i)) * (size))) 00056 00057 #define FETCH(x) fetch_texel_2d_##x 00058 00059 #elif DIM == 3 00060 00061 #define TEXEL_ADDR( type, image, i, j, k, size ) \ 00062 ((type *)(image)->Data + ((image)->ImageOffsets[k] \ 00063 + (image)->RowStride * (j) + (i)) * (size)) 00064 00065 #define FETCH(x) fetch_texel_3d_##x 00066 00067 #else 00068 #error illegal number of texture dimensions 00069 #endif 00070 00071 00072 /* MESA_FORMAT_RGBA **********************************************************/ 00073 00074 /* Fetch texel from 1D, 2D or 3D RGBA texture, returning 4 GLchans */ 00075 static void FETCH(rgba)( const struct gl_texture_image *texImage, 00076 GLint i, GLint j, GLint k, GLchan *texel ) 00077 { 00078 const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 4); 00079 COPY_CHAN4( texel, src ); 00080 } 00081 00082 /* Fetch texel from 1D, 2D or 3D RGBA texture, returning 4 GLfloats */ 00083 static void FETCH(f_rgba)( const struct gl_texture_image *texImage, 00084 GLint i, GLint j, GLint k, GLfloat *texel ) 00085 { 00086 const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 4); 00087 texel[RCOMP] = CHAN_TO_FLOAT(src[0]); 00088 texel[GCOMP] = CHAN_TO_FLOAT(src[1]); 00089 texel[BCOMP] = CHAN_TO_FLOAT(src[2]); 00090 texel[ACOMP] = CHAN_TO_FLOAT(src[3]); 00091 } 00092 00093 #if DIM == 3 00094 /* Store a GLchan RGBA texel */ 00095 static void store_texel_rgba(struct gl_texture_image *texImage, 00096 GLint i, GLint j, GLint k, const void *texel) 00097 { 00098 const GLchan *rgba = (const GLchan *) texel; 00099 GLchan *dst = TEXEL_ADDR(GLchan, texImage, i, j, k, 4); 00100 dst[0] = rgba[RCOMP]; 00101 dst[1] = rgba[GCOMP]; 00102 dst[2] = rgba[BCOMP]; 00103 dst[3] = rgba[ACOMP]; 00104 } 00105 #endif 00106 00107 /* MESA_FORMAT_RGB ***********************************************************/ 00108 00109 /* Fetch texel from 1D, 2D or 3D RGB texture, returning 4 GLchans */ 00110 static void FETCH(rgb)( const struct gl_texture_image *texImage, 00111 GLint i, GLint j, GLint k, GLchan *texel ) 00112 { 00113 const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 3); 00114 texel[RCOMP] = src[0]; 00115 texel[GCOMP] = src[1]; 00116 texel[BCOMP] = src[2]; 00117 texel[ACOMP] = CHAN_MAX; 00118 } 00119 00120 /* Fetch texel from 1D, 2D or 3D RGB texture, returning 4 GLfloats */ 00121 static void FETCH(f_rgb)( const struct gl_texture_image *texImage, 00122 GLint i, GLint j, GLint k, GLfloat *texel ) 00123 { 00124 const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 3); 00125 texel[RCOMP] = CHAN_TO_FLOAT(src[0]); 00126 texel[GCOMP] = CHAN_TO_FLOAT(src[1]); 00127 texel[BCOMP] = CHAN_TO_FLOAT(src[2]); 00128 texel[ACOMP] = 1.0F; 00129 } 00130 00131 #if DIM == 3 00132 static void store_texel_rgb(struct gl_texture_image *texImage, 00133 GLint i, GLint j, GLint k, const void *texel) 00134 { 00135 const GLchan *rgba = (const GLchan *) texel; 00136 GLchan *dst = TEXEL_ADDR(GLchan, texImage, i, j, k, 3); 00137 dst[0] = rgba[RCOMP]; 00138 dst[1] = rgba[GCOMP]; 00139 dst[2] = rgba[BCOMP]; 00140 } 00141 #endif 00142 00143 /* MESA_FORMAT_ALPHA *********************************************************/ 00144 00145 /* Fetch texel from 1D, 2D or 3D ALPHA texture, returning 4 GLchans */ 00146 static void FETCH(alpha)( const struct gl_texture_image *texImage, 00147 GLint i, GLint j, GLint k, GLchan *texel ) 00148 { 00149 const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 1); 00150 texel[RCOMP] = 00151 texel[GCOMP] = 00152 texel[BCOMP] = 0; 00153 texel[ACOMP] = src[0]; 00154 } 00155 00156 #if DIM == 3 00157 static void store_texel_alpha(struct gl_texture_image *texImage, 00158 GLint i, GLint j, GLint k, const void *texel) 00159 { 00160 const GLchan *rgba = (const GLchan *) texel; 00161 GLchan *dst = TEXEL_ADDR(GLchan, texImage, i, j, k, 1); 00162 dst[0] = rgba[ACOMP]; 00163 } 00164 #endif 00165 00166 /* MESA_FORMAT_LUMINANCE *****************************************************/ 00167 00168 /* Fetch texel from 1D, 2D or 3D LUMIN texture, returning 4 GLchans */ 00169 static void FETCH(luminance)( const struct gl_texture_image *texImage, 00170 GLint i, GLint j, GLint k, GLchan *texel ) 00171 { 00172 const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 1); 00173 texel[RCOMP] = 00174 texel[GCOMP] = 00175 texel[BCOMP] = src[0]; 00176 texel[ACOMP] = CHAN_MAX; 00177 } 00178 00179 #if DIM == 3 00180 static void store_texel_luminance(struct gl_texture_image *texImage, 00181 GLint i, GLint j, GLint k, const void *texel) 00182 { 00183 const GLchan *rgba = (const GLchan *) texel; 00184 GLchan *dst = TEXEL_ADDR(GLchan, texImage, i, j, k, 1); 00185 dst[0] = rgba[RCOMP]; 00186 } 00187 #endif 00188 00189 /* MESA_FORMAT_LUMINANCE_ALPHA ***********************************************/ 00190 00191 /* Fetch texel from 1D, 2D or 3D L_A texture, returning 4 GLchans */ 00192 static void FETCH(luminance_alpha)( const struct gl_texture_image *texImage, 00193 GLint i, GLint j, GLint k, GLchan *texel ) 00194 { 00195 const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 2); 00196 texel[RCOMP] = src[0]; 00197 texel[GCOMP] = src[0]; 00198 texel[BCOMP] = src[0]; 00199 texel[ACOMP] = src[1]; 00200 } 00201 00202 #if DIM == 3 00203 static void store_texel_luminance_alpha(struct gl_texture_image *texImage, 00204 GLint i, GLint j, GLint k, const void *texel) 00205 { 00206 const GLchan *rgba = (const GLchan *) texel; 00207 GLchan *dst = TEXEL_ADDR(GLchan, texImage, i, j, k, 2); 00208 dst[0] = rgba[RCOMP]; 00209 dst[1] = rgba[ACOMP]; 00210 } 00211 #endif 00212 00213 /* MESA_FORMAT_INTENSITY *****************************************************/ 00214 00215 /* Fetch texel from 1D, 2D or 3D INT. texture, returning 4 GLchans */ 00216 static void FETCH(intensity)( const struct gl_texture_image *texImage, 00217 GLint i, GLint j, GLint k, GLchan *texel ) 00218 { 00219 const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 1); 00220 texel[RCOMP] = src[0]; 00221 texel[GCOMP] = src[0]; 00222 texel[BCOMP] = src[0]; 00223 texel[ACOMP] = src[0]; 00224 } 00225 00226 #if DIM == 3 00227 static void store_texel_intensity(struct gl_texture_image *texImage, 00228 GLint i, GLint j, GLint k, const void *texel) 00229 { 00230 const GLchan *rgba = (const GLchan *) texel; 00231 GLchan *dst = TEXEL_ADDR(GLchan, texImage, i, j, k, 1); 00232 dst[0] = rgba[RCOMP]; 00233 } 00234 #endif 00235 00236 00237 /* MESA_FORMAT_Z32 ***********************************************************/ 00238 00239 /* Fetch depth texel from 1D, 2D or 3D 32-bit depth texture, 00240 * returning 1 GLfloat. 00241 * Note: no GLchan version of this function. 00242 */ 00243 static void FETCH(f_z32)( const struct gl_texture_image *texImage, 00244 GLint i, GLint j, GLint k, GLfloat *texel ) 00245 { 00246 const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); 00247 texel[0] = src[0] * (1.0F / 0xffffffff); 00248 } 00249 00250 #if DIM == 3 00251 static void store_texel_z32(struct gl_texture_image *texImage, 00252 GLint i, GLint j, GLint k, const void *texel) 00253 { 00254 const GLuint *depth = (const GLuint *) texel; 00255 GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); 00256 dst[0] = *depth; 00257 } 00258 #endif 00259 00260 00261 /* MESA_FORMAT_Z16 ***********************************************************/ 00262 00263 /* Fetch depth texel from 1D, 2D or 3D 16-bit depth texture, 00264 * returning 1 GLfloat. 00265 * Note: no GLchan version of this function. 00266 */ 00267 static void FETCH(f_z16)(const struct gl_texture_image *texImage, 00268 GLint i, GLint j, GLint k, GLfloat *texel ) 00269 { 00270 const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00271 texel[0] = src[0] * (1.0F / 65535.0F); 00272 } 00273 00274 #if DIM == 3 00275 static void store_texel_z16(struct gl_texture_image *texImage, 00276 GLint i, GLint j, GLint k, const void *texel) 00277 { 00278 const GLushort *depth = (const GLushort *) texel; 00279 GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00280 dst[0] = *depth; 00281 } 00282 #endif 00283 00284 00285 /* MESA_FORMAT_RGBA_F32 ******************************************************/ 00286 00287 /* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture, returning 4 GLfloats. 00288 */ 00289 static void FETCH(f_rgba_f32)( const struct gl_texture_image *texImage, 00290 GLint i, GLint j, GLint k, GLfloat *texel ) 00291 { 00292 const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4); 00293 texel[RCOMP] = src[0]; 00294 texel[GCOMP] = src[1]; 00295 texel[BCOMP] = src[2]; 00296 texel[ACOMP] = src[3]; 00297 } 00298 00299 #if DIM == 3 00300 static void store_texel_rgba_f32(struct gl_texture_image *texImage, 00301 GLint i, GLint j, GLint k, const void *texel) 00302 { 00303 const GLfloat *depth = (const GLfloat *) texel; 00304 GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); 00305 dst[0] = depth[RCOMP]; 00306 dst[1] = depth[GCOMP]; 00307 dst[2] = depth[BCOMP]; 00308 dst[3] = depth[ACOMP]; 00309 } 00310 #endif 00311 00312 00313 /* MESA_FORMAT_RGBA_F16 ******************************************************/ 00314 00315 /* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture, 00316 * returning 4 GLfloats. 00317 */ 00318 static void FETCH(f_rgba_f16)( const struct gl_texture_image *texImage, 00319 GLint i, GLint j, GLint k, GLfloat *texel ) 00320 { 00321 const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4); 00322 texel[RCOMP] = _mesa_half_to_float(src[0]); 00323 texel[GCOMP] = _mesa_half_to_float(src[1]); 00324 texel[BCOMP] = _mesa_half_to_float(src[2]); 00325 texel[ACOMP] = _mesa_half_to_float(src[3]); 00326 } 00327 00328 #if DIM == 3 00329 static void store_texel_rgba_f16(struct gl_texture_image *texImage, 00330 GLint i, GLint j, GLint k, const void *texel) 00331 { 00332 const GLfloat *depth = (const GLfloat *) texel; 00333 GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); 00334 dst[0] = _mesa_float_to_half(*depth); 00335 } 00336 #endif 00337 00338 /* MESA_FORMAT_RGB_F32 *******************************************************/ 00339 00340 /* Fetch texel from 1D, 2D or 3D RGB_FLOAT32 texture, 00341 * returning 4 GLfloats. 00342 */ 00343 static void FETCH(f_rgb_f32)( const struct gl_texture_image *texImage, 00344 GLint i, GLint j, GLint k, GLfloat *texel ) 00345 { 00346 const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 3); 00347 texel[RCOMP] = src[0]; 00348 texel[GCOMP] = src[1]; 00349 texel[BCOMP] = src[2]; 00350 texel[ACOMP] = 1.0F; 00351 } 00352 00353 #if DIM == 3 00354 static void store_texel_rgb_f32(struct gl_texture_image *texImage, 00355 GLint i, GLint j, GLint k, const void *texel) 00356 { 00357 const GLfloat *depth = (const GLfloat *) texel; 00358 GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); 00359 dst[0] = *depth; 00360 } 00361 #endif 00362 00363 00364 /* MESA_FORMAT_RGB_F16 *******************************************************/ 00365 00366 /* Fetch texel from 1D, 2D or 3D RGB_FLOAT16 texture, 00367 * returning 4 GLfloats. 00368 */ 00369 static void FETCH(f_rgb_f16)( const struct gl_texture_image *texImage, 00370 GLint i, GLint j, GLint k, GLfloat *texel ) 00371 { 00372 const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 3); 00373 texel[RCOMP] = _mesa_half_to_float(src[0]); 00374 texel[GCOMP] = _mesa_half_to_float(src[1]); 00375 texel[BCOMP] = _mesa_half_to_float(src[2]); 00376 texel[ACOMP] = 1.0F; 00377 } 00378 00379 #if DIM == 3 00380 static void store_texel_rgb_f16(struct gl_texture_image *texImage, 00381 GLint i, GLint j, GLint k, const void *texel) 00382 { 00383 const GLfloat *depth = (const GLfloat *) texel; 00384 GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); 00385 dst[0] = _mesa_float_to_half(*depth); 00386 } 00387 #endif 00388 00389 00390 /* MESA_FORMAT_ALPHA_F32 *****************************************************/ 00391 00392 /* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT32 texture, 00393 * returning 4 GLfloats. 00394 */ 00395 static void FETCH(f_alpha_f32)( const struct gl_texture_image *texImage, 00396 GLint i, GLint j, GLint k, GLfloat *texel ) 00397 { 00398 const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); 00399 texel[RCOMP] = 00400 texel[GCOMP] = 00401 texel[BCOMP] = 0.0F; 00402 texel[ACOMP] = src[0]; 00403 } 00404 00405 #if DIM == 3 00406 static void store_texel_alpha_f32(struct gl_texture_image *texImage, 00407 GLint i, GLint j, GLint k, const void *texel) 00408 { 00409 const GLfloat *rgba = (const GLfloat *) texel; 00410 GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); 00411 dst[0] = rgba[ACOMP]; 00412 } 00413 #endif 00414 00415 00416 /* MESA_FORMAT_ALPHA_F32 *****************************************************/ 00417 00418 /* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT16 texture, 00419 * returning 4 GLfloats. 00420 */ 00421 static void FETCH(f_alpha_f16)( const struct gl_texture_image *texImage, 00422 GLint i, GLint j, GLint k, GLfloat *texel ) 00423 { 00424 const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); 00425 texel[RCOMP] = 00426 texel[GCOMP] = 00427 texel[BCOMP] = 0.0F; 00428 texel[ACOMP] = _mesa_half_to_float(src[0]); 00429 } 00430 00431 #if DIM == 3 00432 static void store_texel_alpha_f16(struct gl_texture_image *texImage, 00433 GLint i, GLint j, GLint k, const void *texel) 00434 { 00435 const GLfloat *rgba = (const GLfloat *) texel; 00436 GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); 00437 dst[0] = _mesa_float_to_half(rgba[ACOMP]); 00438 } 00439 #endif 00440 00441 00442 /* MESA_FORMAT_LUMINANCE_F32 *************************************************/ 00443 00444 /* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture, 00445 * returning 4 GLfloats. 00446 */ 00447 static void FETCH(f_luminance_f32)( const struct gl_texture_image *texImage, 00448 GLint i, GLint j, GLint k, GLfloat *texel ) 00449 { 00450 const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); 00451 texel[RCOMP] = 00452 texel[GCOMP] = 00453 texel[BCOMP] = src[0]; 00454 texel[ACOMP] = 1.0F; 00455 } 00456 00457 #if DIM == 3 00458 static void store_texel_luminance_f32(struct gl_texture_image *texImage, 00459 GLint i, GLint j, GLint k, const void *texel) 00460 { 00461 const GLfloat *rgba = (const GLfloat *) texel; 00462 GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); 00463 dst[0] = rgba[RCOMP]; 00464 } 00465 #endif 00466 00467 00468 /* MESA_FORMAT_LUMINANCE_F16 *************************************************/ 00469 00470 /* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture, 00471 * returning 4 GLfloats. 00472 */ 00473 static void FETCH(f_luminance_f16)( const struct gl_texture_image *texImage, 00474 GLint i, GLint j, GLint k, GLfloat *texel ) 00475 { 00476 const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); 00477 texel[RCOMP] = 00478 texel[GCOMP] = 00479 texel[BCOMP] = _mesa_half_to_float(src[0]); 00480 texel[ACOMP] = 1.0F; 00481 } 00482 00483 #if DIM == 3 00484 static void store_texel_luminance_f16(struct gl_texture_image *texImage, 00485 GLint i, GLint j, GLint k, const void *texel) 00486 { 00487 const GLfloat *rgba = (const GLfloat *) texel; 00488 GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); 00489 dst[0] = _mesa_float_to_half(rgba[RCOMP]); 00490 } 00491 #endif 00492 00493 00494 /* MESA_FORMAT_LUMINANCE_ALPHA_F32 *******************************************/ 00495 00496 /* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture, 00497 * returning 4 GLfloats. 00498 */ 00499 static void FETCH(f_luminance_alpha_f32)( const struct gl_texture_image *texImage, 00500 GLint i, GLint j, GLint k, GLfloat *texel ) 00501 { 00502 const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2); 00503 texel[RCOMP] = 00504 texel[GCOMP] = 00505 texel[BCOMP] = src[0]; 00506 texel[ACOMP] = src[1]; 00507 } 00508 00509 #if DIM == 3 00510 static void store_texel_luminance_alpha_f32(struct gl_texture_image *texImage, 00511 GLint i, GLint j, GLint k, const void *texel) 00512 { 00513 const GLfloat *rgba = (const GLfloat *) texel; 00514 GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2); 00515 dst[0] = rgba[RCOMP]; 00516 dst[1] = rgba[ACOMP]; 00517 } 00518 #endif 00519 00520 00521 /* MESA_FORMAT_LUMINANCE_ALPHA_F16 *******************************************/ 00522 00523 /* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture, 00524 * returning 4 GLfloats. 00525 */ 00526 static void FETCH(f_luminance_alpha_f16)( const struct gl_texture_image *texImage, 00527 GLint i, GLint j, GLint k, GLfloat *texel ) 00528 { 00529 const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2); 00530 texel[RCOMP] = 00531 texel[GCOMP] = 00532 texel[BCOMP] = _mesa_half_to_float(src[0]); 00533 texel[ACOMP] = _mesa_half_to_float(src[1]); 00534 } 00535 00536 #if DIM == 3 00537 static void store_texel_luminance_alpha_f16(struct gl_texture_image *texImage, 00538 GLint i, GLint j, GLint k, const void *texel) 00539 { 00540 const GLfloat *rgba = (const GLfloat *) texel; 00541 GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2); 00542 dst[0] = _mesa_float_to_half(rgba[RCOMP]); 00543 dst[1] = _mesa_float_to_half(rgba[ACOMP]); 00544 } 00545 #endif 00546 00547 00548 /* MESA_FORMAT_INTENSITY_F32 *************************************************/ 00549 00550 /* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture, 00551 * returning 4 GLfloats. 00552 */ 00553 static void FETCH(f_intensity_f32)( const struct gl_texture_image *texImage, 00554 GLint i, GLint j, GLint k, GLfloat *texel ) 00555 { 00556 const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); 00557 texel[RCOMP] = 00558 texel[GCOMP] = 00559 texel[BCOMP] = 00560 texel[ACOMP] = src[0]; 00561 } 00562 00563 #if DIM == 3 00564 static void store_texel_intensity_f32(struct gl_texture_image *texImage, 00565 GLint i, GLint j, GLint k, const void *texel) 00566 { 00567 const GLfloat *rgba = (const GLfloat *) texel; 00568 GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); 00569 dst[0] = rgba[RCOMP]; 00570 } 00571 #endif 00572 00573 00574 /* MESA_FORMAT_INTENSITY_F16 *************************************************/ 00575 00576 /* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture, 00577 * returning 4 GLfloats. 00578 */ 00579 static void FETCH(f_intensity_f16)( const struct gl_texture_image *texImage, 00580 GLint i, GLint j, GLint k, GLfloat *texel ) 00581 { 00582 const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); 00583 texel[RCOMP] = 00584 texel[GCOMP] = 00585 texel[BCOMP] = 00586 texel[ACOMP] = _mesa_half_to_float(src[0]); 00587 } 00588 00589 #if DIM == 3 00590 static void store_texel_intensity_f16(struct gl_texture_image *texImage, 00591 GLint i, GLint j, GLint k, const void *texel) 00592 { 00593 const GLfloat *rgba = (const GLfloat *) texel; 00594 GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); 00595 dst[0] = _mesa_float_to_half(rgba[RCOMP]); 00596 } 00597 #endif 00598 00599 00600 00601 00602 /* 00603 * Begin Hardware formats 00604 */ 00605 00606 /* MESA_FORMAT_RGBA8888 ******************************************************/ 00607 00608 /* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLchans */ 00609 static void FETCH(rgba8888)( const struct gl_texture_image *texImage, 00610 GLint i, GLint j, GLint k, GLchan *texel ) 00611 { 00612 const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); 00613 texel[RCOMP] = UBYTE_TO_CHAN( (s >> 24) ); 00614 texel[GCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff ); 00615 texel[BCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff ); 00616 texel[ACOMP] = UBYTE_TO_CHAN( (s ) & 0xff ); 00617 } 00618 00619 #if DIM == 3 00620 static void store_texel_rgba8888(struct gl_texture_image *texImage, 00621 GLint i, GLint j, GLint k, const void *texel) 00622 { 00623 const GLubyte *rgba = (const GLubyte *) texel; 00624 GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); 00625 *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); 00626 } 00627 #endif 00628 00629 00630 /* MESA_FORMAT_RGBA888_REV ***************************************************/ 00631 00632 /* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLchans */ 00633 static void FETCH(rgba8888_rev)( const struct gl_texture_image *texImage, 00634 GLint i, GLint j, GLint k, GLchan *texel ) 00635 { 00636 const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); 00637 texel[RCOMP] = UBYTE_TO_CHAN( (s ) & 0xff ); 00638 texel[GCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff ); 00639 texel[BCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff ); 00640 texel[ACOMP] = UBYTE_TO_CHAN( (s >> 24) ); 00641 } 00642 00643 #if DIM == 3 00644 static void store_texel_rgba8888_rev(struct gl_texture_image *texImage, 00645 GLint i, GLint j, GLint k, const void *texel) 00646 { 00647 const GLubyte *rgba = (const GLubyte *) texel; 00648 GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); 00649 *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); 00650 } 00651 #endif 00652 00653 00654 /* MESA_FORMAT_ARGB8888 ******************************************************/ 00655 00656 /* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */ 00657 static void FETCH(argb8888)( const struct gl_texture_image *texImage, 00658 GLint i, GLint j, GLint k, GLchan *texel ) 00659 { 00660 const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); 00661 texel[RCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff ); 00662 texel[GCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff ); 00663 texel[BCOMP] = UBYTE_TO_CHAN( (s ) & 0xff ); 00664 texel[ACOMP] = UBYTE_TO_CHAN( (s >> 24) ); 00665 } 00666 00667 #if DIM == 3 00668 static void store_texel_argb8888(struct gl_texture_image *texImage, 00669 GLint i, GLint j, GLint k, const void *texel) 00670 { 00671 const GLubyte *rgba = (const GLubyte *) texel; 00672 GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); 00673 *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); 00674 } 00675 #endif 00676 00677 00678 /* MESA_FORMAT_ARGB8888_REV **************************************************/ 00679 00680 /* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLchans */ 00681 static void FETCH(argb8888_rev)( const struct gl_texture_image *texImage, 00682 GLint i, GLint j, GLint k, GLchan *texel ) 00683 { 00684 const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); 00685 texel[RCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff ); 00686 texel[GCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff ); 00687 texel[BCOMP] = UBYTE_TO_CHAN( (s >> 24) ); 00688 texel[ACOMP] = UBYTE_TO_CHAN( (s ) & 0xff ); 00689 } 00690 00691 #if DIM == 3 00692 static void store_texel_argb8888_rev(struct gl_texture_image *texImage, 00693 GLint i, GLint j, GLint k, const void *texel) 00694 { 00695 const GLubyte *rgba = (const GLubyte *) texel; 00696 GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); 00697 *dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], rgba[ACOMP]); 00698 } 00699 #endif 00700 00701 00702 /* MESA_FORMAT_RGB888 ********************************************************/ 00703 00704 /* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */ 00705 static void FETCH(rgb888)( const struct gl_texture_image *texImage, 00706 GLint i, GLint j, GLint k, GLchan *texel ) 00707 { 00708 const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); 00709 texel[RCOMP] = UBYTE_TO_CHAN( src[2] ); 00710 texel[GCOMP] = UBYTE_TO_CHAN( src[1] ); 00711 texel[BCOMP] = UBYTE_TO_CHAN( src[0] ); 00712 texel[ACOMP] = CHAN_MAX; 00713 } 00714 00715 #if DIM == 3 00716 static void store_texel_rgb888(struct gl_texture_image *texImage, 00717 GLint i, GLint j, GLint k, const void *texel) 00718 { 00719 const GLubyte *rgba = (const GLubyte *) texel; 00720 GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); 00721 dst[0] = rgba[BCOMP]; 00722 dst[1] = rgba[GCOMP]; 00723 dst[2] = rgba[RCOMP]; 00724 } 00725 #endif 00726 00727 00728 /* MESA_FORMAT_BGR888 ********************************************************/ 00729 00730 /* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */ 00731 static void FETCH(bgr888)( const struct gl_texture_image *texImage, 00732 GLint i, GLint j, GLint k, GLchan *texel ) 00733 { 00734 const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); 00735 texel[RCOMP] = UBYTE_TO_CHAN( src[0] ); 00736 texel[GCOMP] = UBYTE_TO_CHAN( src[1] ); 00737 texel[BCOMP] = UBYTE_TO_CHAN( src[2] ); 00738 texel[ACOMP] = CHAN_MAX; 00739 } 00740 00741 #if DIM == 3 00742 static void store_texel_bgr888(struct gl_texture_image *texImage, 00743 GLint i, GLint j, GLint k, const void *texel) 00744 { 00745 const GLubyte *rgba = (const GLubyte *) texel; 00746 GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); 00747 dst[0] = rgba[RCOMP]; 00748 dst[1] = rgba[GCOMP]; 00749 dst[2] = rgba[BCOMP]; 00750 } 00751 #endif 00752 00753 00754 /* use color expansion like (g << 2) | (g >> 4) (does somewhat random rounding) 00755 instead of slow (g << 2) * 255 / 252 (always rounds down) */ 00756 00757 /* MESA_FORMAT_RGB565 ********************************************************/ 00758 00759 /* Fetch texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */ 00760 static void FETCH(rgb565)( const struct gl_texture_image *texImage, 00761 GLint i, GLint j, GLint k, GLchan *texel ) 00762 { 00763 const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00764 const GLushort s = *src; 00765 texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) ); 00766 texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) | ((s >> 9) & 0x3) ); 00767 texel[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) ); 00768 texel[ACOMP] = CHAN_MAX; 00769 } 00770 00771 #if DIM == 3 00772 static void store_texel_rgb565(struct gl_texture_image *texImage, 00773 GLint i, GLint j, GLint k, const void *texel) 00774 { 00775 const GLubyte *rgba = (const GLubyte *) texel; 00776 GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00777 *dst = PACK_COLOR_565(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); 00778 } 00779 #endif 00780 00781 00782 /* MESA_FORMAT_RGB565_REV ****************************************************/ 00783 00784 /* Fetch texel from 1D, 2D or 3D rgb565_rev texture, return 4 GLchans */ 00785 static void FETCH(rgb565_rev)( const struct gl_texture_image *texImage, 00786 GLint i, GLint j, GLint k, GLchan *texel ) 00787 { 00788 const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00789 const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */ 00790 texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) ); 00791 texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) | ((s >> 9) & 0x3) ); 00792 texel[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) ); 00793 texel[ACOMP] = CHAN_MAX; 00794 } 00795 00796 #if DIM == 3 00797 static void store_texel_rgb565_rev(struct gl_texture_image *texImage, 00798 GLint i, GLint j, GLint k, const void *texel) 00799 { 00800 const GLubyte *rgba = (const GLubyte *) texel; 00801 GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00802 *dst = PACK_COLOR_565(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]); 00803 } 00804 #endif 00805 00806 /* MESA_FORMAT_RGBA4444 ******************************************************/ 00807 00808 /* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */ 00809 static void FETCH(rgba4444)( const struct gl_texture_image *texImage, 00810 GLint i, GLint j, GLint k, GLchan *texel ) 00811 { 00812 const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00813 const GLushort s = *src; 00814 texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) | ((s >> 8) & 0xf0) ); 00815 texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) | ((s >> 4) & 0xf0) ); 00816 texel[BCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) | ((s ) & 0xf0) ); 00817 texel[ACOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) | ((s << 4) & 0xf0) ); 00818 } 00819 00820 #if DIM == 3 00821 static void store_texel_rgba4444(struct gl_texture_image *texImage, 00822 GLint i, GLint j, GLint k, const void *texel) 00823 { 00824 const GLubyte *rgba = (const GLubyte *) texel; 00825 GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00826 *dst = PACK_COLOR_4444(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); 00827 } 00828 #endif 00829 00830 00831 /* MESA_FORMAT_ARGB4444 ******************************************************/ 00832 00833 /* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */ 00834 static void FETCH(argb4444)( const struct gl_texture_image *texImage, 00835 GLint i, GLint j, GLint k, GLchan *texel ) 00836 { 00837 const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00838 const GLushort s = *src; 00839 texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) | ((s >> 4) & 0xf0) ); 00840 texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) | ((s ) & 0xf0) ); 00841 texel[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) | ((s << 4) & 0xf0) ); 00842 texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) | ((s >> 8) & 0xf0) ); 00843 } 00844 00845 #if DIM == 3 00846 static void store_texel_argb4444(struct gl_texture_image *texImage, 00847 GLint i, GLint j, GLint k, const void *texel) 00848 { 00849 const GLubyte *rgba = (const GLubyte *) texel; 00850 GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00851 *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); 00852 } 00853 #endif 00854 00855 00856 /* MESA_FORMAT_ARGB4444_REV **************************************************/ 00857 00858 /* Fetch texel from 1D, 2D or 3D argb4444_rev texture, return 4 GLchans */ 00859 static void FETCH(argb4444_rev)( const struct gl_texture_image *texImage, 00860 GLint i, GLint j, GLint k, GLchan *texel ) 00861 { 00862 const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00863 texel[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) | ((s << 4) & 0xf0) ); 00864 texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) | ((s >> 8) & 0xf0) ); 00865 texel[BCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) | ((s >> 4) & 0xf0) ); 00866 texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) | ((s ) & 0xf0) ); 00867 } 00868 00869 #if DIM == 3 00870 static void store_texel_argb4444_rev(struct gl_texture_image *texImage, 00871 GLint i, GLint j, GLint k, const void *texel) 00872 { 00873 const GLubyte *rgba = (const GLubyte *) texel; 00874 GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00875 *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]); 00876 } 00877 #endif 00878 00879 /* MESA_FORMAT_RGBA5551 ******************************************************/ 00880 00881 /* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */ 00882 static void FETCH(rgba5551)( const struct gl_texture_image *texImage, 00883 GLint i, GLint j, GLint k, GLchan *texel ) 00884 { 00885 const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00886 const GLushort s = *src; 00887 texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) ); 00888 texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xf8) | ((s >> 8) & 0x7) ); 00889 texel[BCOMP] = UBYTE_TO_CHAN( ((s << 2) & 0xf8) | ((s >> 3) & 0x7) ); 00890 texel[ACOMP] = UBYTE_TO_CHAN( ((s) & 0x01) ? 255 : 0); 00891 } 00892 00893 #if DIM == 3 00894 static void store_texel_rgba5551(struct gl_texture_image *texImage, 00895 GLint i, GLint j, GLint k, const void *texel) 00896 { 00897 const GLubyte *rgba = (const GLubyte *) texel; 00898 GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00899 *dst = PACK_COLOR_5551(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); 00900 } 00901 #endif 00902 00903 /* MESA_FORMAT_ARGB1555 ******************************************************/ 00904 00905 /* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */ 00906 static void FETCH(argb1555)( const struct gl_texture_image *texImage, 00907 GLint i, GLint j, GLint k, GLchan *texel ) 00908 { 00909 const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00910 const GLushort s = *src; 00911 texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 7) & 0xf8) | ((s >> 12) & 0x7) ); 00912 texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 2) & 0xf8) | ((s >> 7) & 0x7) ); 00913 texel[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) ); 00914 texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 ); 00915 } 00916 00917 #if DIM == 3 00918 static void store_texel_argb1555(struct gl_texture_image *texImage, 00919 GLint i, GLint j, GLint k, const void *texel) 00920 { 00921 const GLubyte *rgba = (const GLubyte *) texel; 00922 GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00923 *dst = PACK_COLOR_1555(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); 00924 } 00925 #endif 00926 00927 00928 /* MESA_FORMAT_ARGB1555_REV **************************************************/ 00929 00930 /* Fetch texel from 1D, 2D or 3D argb1555_rev texture, return 4 GLchans */ 00931 static void FETCH(argb1555_rev)( const struct gl_texture_image *texImage, 00932 GLint i, GLint j, GLint k, GLchan *texel ) 00933 { 00934 const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00935 const GLushort s = (*src << 8) | (*src >> 8); /* byteswap */ 00936 texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 7) & 0xf8) | ((s >> 12) & 0x7) ); 00937 texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 2) & 0xf8) | ((s >> 7) & 0x7) ); 00938 texel[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) ); 00939 texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 ); 00940 } 00941 00942 #if DIM == 3 00943 static void store_texel_argb1555_rev(struct gl_texture_image *texImage, 00944 GLint i, GLint j, GLint k, const void *texel) 00945 { 00946 const GLubyte *rgba = (const GLubyte *) texel; 00947 GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00948 *dst = PACK_COLOR_1555_REV(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); 00949 } 00950 #endif 00951 00952 00953 /* MESA_FORMAT_AL88 **********************************************************/ 00954 00955 /* Fetch texel from 1D, 2D or 3D al88 texture, return 4 GLchans */ 00956 static void FETCH(al88)( const struct gl_texture_image *texImage, 00957 GLint i, GLint j, GLint k, GLchan *texel ) 00958 { 00959 const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00960 texel[RCOMP] = 00961 texel[GCOMP] = 00962 texel[BCOMP] = UBYTE_TO_CHAN( s & 0xff ); 00963 texel[ACOMP] = UBYTE_TO_CHAN( s >> 8 ); 00964 } 00965 00966 #if DIM == 3 00967 static void store_texel_al88(struct gl_texture_image *texImage, 00968 GLint i, GLint j, GLint k, const void *texel) 00969 { 00970 const GLubyte *rgba = (const GLubyte *) texel; 00971 GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00972 *dst = PACK_COLOR_88(rgba[ACOMP], rgba[RCOMP]); 00973 } 00974 #endif 00975 00976 00977 /* MESA_FORMAT_AL88_REV ******************************************************/ 00978 00979 /* Fetch texel from 1D, 2D or 3D al88_rev texture, return 4 GLchans */ 00980 static void FETCH(al88_rev)( const struct gl_texture_image *texImage, 00981 GLint i, GLint j, GLint k, GLchan *texel ) 00982 { 00983 const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00984 texel[RCOMP] = 00985 texel[GCOMP] = 00986 texel[BCOMP] = UBYTE_TO_CHAN( s >> 8 ); 00987 texel[ACOMP] = UBYTE_TO_CHAN( s & 0xff ); 00988 } 00989 00990 #if DIM == 3 00991 static void store_texel_al88_rev(struct gl_texture_image *texImage, 00992 GLint i, GLint j, GLint k, const void *texel) 00993 { 00994 const GLubyte *rgba = (const GLubyte *) texel; 00995 GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); 00996 *dst = PACK_COLOR_88(rgba[RCOMP], rgba[ACOMP]); 00997 } 00998 #endif 00999 01000 01001 /* MESA_FORMAT_RGB332 ********************************************************/ 01002 01003 /* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */ 01004 static void FETCH(rgb332)( const struct gl_texture_image *texImage, 01005 GLint i, GLint j, GLint k, GLchan *texel ) 01006 { 01007 static const GLubyte lut2to8[4] = {0, 85, 170, 255}; 01008 static const GLubyte lut3to8[8] = {0, 36, 73, 109, 146, 182, 219, 255}; 01009 const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); 01010 const GLubyte s = *src; 01011 texel[RCOMP] = UBYTE_TO_CHAN( lut3to8[(s >> 5) & 0x7] ); 01012 texel[GCOMP] = UBYTE_TO_CHAN( lut3to8[(s >> 2) & 0x7] ); 01013 texel[BCOMP] = UBYTE_TO_CHAN( lut2to8[(s ) & 0x3] ); 01014 texel[ACOMP] = CHAN_MAX; 01015 } 01016 01017 #if DIM == 3 01018 static void store_texel_rgb332(struct gl_texture_image *texImage, 01019 GLint i, GLint j, GLint k, const void *texel) 01020 { 01021 const GLubyte *rgba = (const GLubyte *) texel; 01022 GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); 01023 *dst = PACK_COLOR_332(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); 01024 } 01025 #endif 01026 01027 01028 /* MESA_FORMAT_A8 ************************************************************/ 01029 01030 /* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */ 01031 static void FETCH(a8)( const struct gl_texture_image *texImage, 01032 GLint i, GLint j, GLint k, GLchan *texel ) 01033 { 01034 const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); 01035 texel[RCOMP] = 01036 texel[GCOMP] = 01037 texel[BCOMP] = 0; 01038 texel[ACOMP] = UBYTE_TO_CHAN( src[0] ); 01039 } 01040 01041 #if DIM == 3 01042 static void store_texel_a8(struct gl_texture_image *texImage, 01043 GLint i, GLint j, GLint k, const void *texel) 01044 { 01045 const GLubyte *rgba = (const GLubyte *) texel; 01046 GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); 01047 *dst = rgba[ACOMP]; 01048 } 01049 #endif 01050 01051 01052 /* MESA_FORMAT_L8 ************************************************************/ 01053 01054 /* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLchans */ 01055 static void FETCH(l8)( const struct gl_texture_image *texImage, 01056 GLint i, GLint j, GLint k, GLchan *texel ) 01057 { 01058 const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); 01059 texel[RCOMP] = 01060 texel[GCOMP] = 01061 texel[BCOMP] = UBYTE_TO_CHAN( src[0] ); 01062 texel[ACOMP] = CHAN_MAX; 01063 } 01064 01065 #if DIM == 3 01066 static void store_texel_l8(struct gl_texture_image *texImage, 01067 GLint i, GLint j, GLint k, const void *texel) 01068 { 01069 const GLubyte *rgba = (const GLubyte *) texel; 01070 GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); 01071 *dst = rgba[RCOMP]; 01072 } 01073 #endif 01074 01075 01076 /* MESA_FORMAT_I8 ************************************************************/ 01077 01078 /* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLchans */ 01079 static void FETCH(i8)( const struct gl_texture_image *texImage, 01080 GLint i, GLint j, GLint k, GLchan *texel ) 01081 { 01082 const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); 01083 texel[RCOMP] = 01084 texel[GCOMP] = 01085 texel[BCOMP] = 01086 texel[ACOMP] = UBYTE_TO_CHAN( src[0] ); 01087 } 01088 01089 #if DIM == 3 01090 static void store_texel_i8(struct gl_texture_image *texImage, 01091 GLint i, GLint j, GLint k, const void *texel) 01092 { 01093 const GLubyte *rgba = (const GLubyte *) texel; 01094 GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); 01095 *dst = rgba[RCOMP]; 01096 } 01097 #endif 01098 01099 01100 /* MESA_FORMAT_CI8 ***********************************************************/ 01101 01102 /* Fetch CI texel from 1D, 2D or 3D ci8 texture, lookup the index in a 01103 * color table, and return 4 GLchans. 01104 */ 01105 static void FETCH(ci8)( const struct gl_texture_image *texImage, 01106 GLint i, GLint j, GLint k, GLchan *texel ) 01107 { 01108 const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); 01109 const struct gl_color_table *palette; 01110 GLubyte texelUB[4]; 01111 GLuint index; 01112 GET_CURRENT_CONTEXT(ctx); 01113 01114 if (ctx->Texture.SharedPalette) { 01115 palette = &ctx->Texture.Palette; 01116 } 01117 else { 01118 palette = &texImage->TexObject->Palette; 01119 } 01120 if (palette->Size == 0) 01121 return; /* undefined results */ 01122 01123 /* Mask the index against size of palette to avoid going out of bounds */ 01124 index = (*src) & (palette->Size - 1); 01125 01126 { 01127 const GLubyte *table = palette->TableUB; 01128 switch (palette->_BaseFormat) { 01129 case GL_ALPHA: 01130 texelUB[RCOMP] = 01131 texelUB[GCOMP] = 01132 texelUB[BCOMP] = 0; 01133 texelUB[ACOMP] = table[index]; 01134 break;; 01135 case GL_LUMINANCE: 01136 texelUB[RCOMP] = 01137 texelUB[GCOMP] = 01138 texelUB[BCOMP] = table[index]; 01139 texelUB[ACOMP] = 255; 01140 break; 01141 case GL_INTENSITY: 01142 texelUB[RCOMP] = 01143 texelUB[GCOMP] = 01144 texelUB[BCOMP] = 01145 texelUB[ACOMP] = table[index]; 01146 break;; 01147 case GL_LUMINANCE_ALPHA: 01148 texelUB[RCOMP] = 01149 texelUB[GCOMP] = 01150 texelUB[BCOMP] = table[index * 2 + 0]; 01151 texelUB[ACOMP] = table[index * 2 + 1]; 01152 break;; 01153 case GL_RGB: 01154 texelUB[RCOMP] = table[index * 3 + 0]; 01155 texelUB[GCOMP] = table[index * 3 + 1]; 01156 texelUB[BCOMP] = table[index * 3 + 2]; 01157 texelUB[ACOMP] = 255; 01158 break;; 01159 case GL_RGBA: 01160 texelUB[RCOMP] = table[index * 4 + 0]; 01161 texelUB[GCOMP] = table[index * 4 + 1]; 01162 texelUB[BCOMP] = table[index * 4 + 2]; 01163 texelUB[ACOMP] = table[index * 4 + 3]; 01164 break;; 01165 default: 01166 _mesa_problem(ctx, "Bad palette format in fetch_texel_ci8"); 01167 return; 01168 } 01169 #if CHAN_TYPE == GL_UNSIGNED_BYTE 01170 COPY_4UBV(texel, texelUB); 01171 #elif CHAN_TYPE == GL_UNSIGNED_SHORT 01172 texel[0] = UBYTE_TO_USHORT(texelUB[0]); 01173 texel[1] = UBYTE_TO_USHORT(texelUB[1]); 01174 texel[2] = UBYTE_TO_USHORT(texelUB[2]); 01175 texel[3] = UBYTE_TO_USHORT(texelUB[3]); 01176 #else 01177 texel[0] = UBYTE_TO_FLOAT(texelUB[0]); 01178 texel[1] = UBYTE_TO_FLOAT(texelUB[1]); 01179 texel[2] = UBYTE_TO_FLOAT(texelUB[2]); 01180 texel[3] = UBYTE_TO_FLOAT(texelUB[3]); 01181 #endif 01182 } 01183 } 01184 01185 #if DIM == 3 01186 static void store_texel_ci8(struct gl_texture_image *texImage, 01187 GLint i, GLint j, GLint k, const void *texel) 01188 { 01189 const GLubyte *index = (const GLubyte *) texel; 01190 GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); 01191 *dst = *index; 01192 } 01193 #endif 01194 01195 01196 #if FEATURE_EXT_texture_sRGB 01197 01198 /* Fetch texel from 1D, 2D or 3D srgb8 texture, return 4 GLfloats */ 01199 static void FETCH(srgb8)(const struct gl_texture_image *texImage, 01200 GLint i, GLint j, GLint k, GLfloat *texel ) 01201 { 01202 const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); 01203 texel[RCOMP] = nonlinear_to_linear(src[0]); 01204 texel[GCOMP] = nonlinear_to_linear(src[1]); 01205 texel[BCOMP] = nonlinear_to_linear(src[2]); 01206 texel[ACOMP] = CHAN_MAX; 01207 } 01208 01209 #if DIM == 3 01210 static void store_texel_srgb8(struct gl_texture_image *texImage, 01211 GLint i, GLint j, GLint k, const void *texel) 01212 { 01213 const GLubyte *rgba = (const GLubyte *) texel; 01214 GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); 01215 dst[0] = rgba[RCOMP]; /* no conversion */ 01216 dst[1] = rgba[GCOMP]; 01217 dst[2] = rgba[BCOMP]; 01218 } 01219 #endif 01220 01221 /* Fetch texel from 1D, 2D or 3D srgba8 texture, return 4 GLfloats */ 01222 static void FETCH(srgba8)(const struct gl_texture_image *texImage, 01223 GLint i, GLint j, GLint k, GLfloat *texel ) 01224 { 01225 const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4); 01226 texel[RCOMP] = nonlinear_to_linear(src[0]); 01227 texel[GCOMP] = nonlinear_to_linear(src[1]); 01228 texel[BCOMP] = nonlinear_to_linear(src[2]); 01229 texel[ACOMP] = UBYTE_TO_FLOAT(src[3]); /* linear! */ 01230 } 01231 01232 #if DIM == 3 01233 static void store_texel_srgba8(struct gl_texture_image *texImage, 01234 GLint i, GLint j, GLint k, const void *texel) 01235 { 01236 const GLubyte *rgba = (const GLubyte *) texel; 01237 GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4); 01238 dst[0] = rgba[RCOMP]; 01239 dst[1] = rgba[GCOMP]; 01240 dst[2] = rgba[BCOMP]; 01241 } 01242 #endif 01243 01244 /* Fetch texel from 1D, 2D or 3D sl8 texture, return 4 GLfloats */ 01245 static void FETCH(sl8)(const struct gl_texture_image *texImage, 01246 GLint i, GLint j, GLint k, GLfloat *texel ) 01247 { 01248 const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); 01249 texel[RCOMP] = 01250 texel[GCOMP] = 01251 texel[BCOMP] = nonlinear_to_linear(src[0]); 01252 texel[ACOMP] = CHAN_MAX; 01253 } 01254 01255 #if DIM == 3 01256 static void store_texel_sl8(struct gl_texture_image *texImage, 01257 GLint i, GLint j, GLint k, const void *texel) 01258 { 01259 const GLubyte *rgba = (const GLubyte *) texel; 01260 GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); 01261 dst[0] = rgba[RCOMP]; 01262 } 01263 #endif 01264 01265 /* Fetch texel from 1D, 2D or 3D sla8 texture, return 4 GLfloats */ 01266 static void FETCH(sla8)(const struct gl_texture_image *texImage, 01267 GLint i, GLint j, GLint k, GLfloat *texel ) 01268 { 01269 const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2); 01270 texel[RCOMP] = 01271 texel[GCOMP] = 01272 texel[BCOMP] = nonlinear_to_linear(src[0]); 01273 texel[ACOMP] = UBYTE_TO_FLOAT(src[1]); /* linear */ 01274 } 01275 01276 #if DIM == 3 01277 static void store_texel_sla8(struct gl_texture_image *texImage, 01278 GLint i, GLint j, GLint k, const void *texel) 01279 { 01280 const GLubyte *rgba = (const GLubyte *) texel; 01281 GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2); 01282 dst[0] = rgba[RCOMP]; 01283 dst[1] = rgba[ACOMP]; 01284 } 01285 #endif 01286 01287 01288 01289 #endif /* FEATURE_EXT_texture_sRGB */ 01290 01291 01292 01293 /* MESA_FORMAT_YCBCR *********************************************************/ 01294 01295 /* Fetch texel from 1D, 2D or 3D ycbcr texture, return 4 GLchans */ 01296 /* We convert YCbCr to RGB here */ 01297 /* XXX this may break if GLchan != GLubyte */ 01298 static void FETCH(ycbcr)( const struct gl_texture_image *texImage, 01299 GLint i, GLint j, GLint k, GLchan *texel ) 01300 { 01301 const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */ 01302 const GLushort *src1 = src0 + 1; /* odd */ 01303 const GLubyte y0 = (*src0 >> 8) & 0xff; /* luminance */ 01304 const GLubyte cb = *src0 & 0xff; /* chroma U */ 01305 const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */ 01306 const GLubyte cr = *src1 & 0xff; /* chroma V */ 01307 GLint r, g, b; 01308 if (i & 1) { 01309 /* odd pixel: use y1,cr,cb */ 01310 r = (GLint) (1.164 * (y1-16) + 1.596 * (cr-128)); 01311 g = (GLint) (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128)); 01312 b = (GLint) (1.164 * (y1-16) + 2.018 * (cb-128)); 01313 } 01314 else { 01315 /* even pixel: use y0,cr,cb */ 01316 r = (GLint) (1.164 * (y0-16) + 1.596 * (cr-128)); 01317 g = (GLint) (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128)); 01318 b = (GLint) (1.164 * (y0-16) + 2.018 * (cb-128)); 01319 } 01320 texel[RCOMP] = CLAMP(r, 0, CHAN_MAX); 01321 texel[GCOMP] = CLAMP(g, 0, CHAN_MAX); 01322 texel[BCOMP] = CLAMP(b, 0, CHAN_MAX); 01323 texel[ACOMP] = CHAN_MAX; 01324 } 01325 01326 #if DIM == 3 01327 static void store_texel_ycbcr(struct gl_texture_image *texImage, 01328 GLint i, GLint j, GLint k, const void *texel) 01329 { 01330 (void) texImage; 01331 (void) i; 01332 (void) j; 01333 (void) k; 01334 (void) texel; 01335 /* XXX to do */ 01336 } 01337 #endif 01338 01339 01340 /* MESA_FORMAT_YCBCR_REV *****************************************************/ 01341 01342 /* Fetch texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLchans */ 01343 /* We convert YCbCr to RGB here */ 01344 /* XXX this may break if GLchan != GLubyte */ 01345 static void FETCH(ycbcr_rev)( const struct gl_texture_image *texImage, 01346 GLint i, GLint j, GLint k, GLchan *texel ) 01347 { 01348 const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */ 01349 const GLushort *src1 = src0 + 1; /* odd */ 01350 const GLubyte y0 = *src0 & 0xff; /* luminance */ 01351 const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */ 01352 const GLubyte y1 = *src1 & 0xff; /* luminance */ 01353 const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */ 01354 GLint r, g, b; 01355 if (i & 1) { 01356 /* odd pixel: use y1,cr,cb */ 01357 r = (GLint) (1.164 * (y1-16) + 1.596 * (cr-128)); 01358 g = (GLint) (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128)); 01359 b = (GLint) (1.164 * (y1-16) + 2.018 * (cb-128)); 01360 } 01361 else { 01362 /* even pixel: use y0,cr,cb */ 01363 r = (GLint) (1.164 * (y0-16) + 1.596 * (cr-128)); 01364 g = (GLint) (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128)); 01365 b = (GLint) (1.164 * (y0-16) + 2.018 * (cb-128)); 01366 } 01367 texel[RCOMP] = CLAMP(r, 0, CHAN_MAX); 01368 texel[GCOMP] = CLAMP(g, 0, CHAN_MAX); 01369 texel[BCOMP] = CLAMP(b, 0, CHAN_MAX); 01370 texel[ACOMP] = CHAN_MAX; 01371 } 01372 01373 #if DIM == 3 01374 static void store_texel_ycbcr_rev(struct gl_texture_image *texImage, 01375 GLint i, GLint j, GLint k, const void *texel) 01376 { 01377 (void) texImage; 01378 (void) i; 01379 (void) j; 01380 (void) k; 01381 (void) texel; 01382 /* XXX to do */ 01383 } 01384 #endif 01385 01386 01387 /* MESA_TEXFORMAT_Z24_S8 ***************************************************/ 01388 01389 static void FETCH(f_z24_s8)( const struct gl_texture_image *texImage, 01390 GLint i, GLint j, GLint k, GLfloat *texel ) 01391 { 01392 /* only return Z, not stencil data */ 01393 const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); 01394 const GLfloat scale = 1.0F / (GLfloat) 0xffffff; 01395 texel[0] = ((*src) >> 8) * scale; 01396 ASSERT(texImage->TexFormat->MesaFormat == MESA_FORMAT_Z24_S8); 01397 ASSERT(texel[0] >= 0.0F); 01398 ASSERT(texel[0] <= 1.0F); 01399 } 01400 01401 #if DIM == 3 01402 static void store_texel_z24_s8(struct gl_texture_image *texImage, 01403 GLint i, GLint j, GLint k, const void *texel) 01404 { 01405 /* only store Z, not stencil */ 01406 GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); 01407 GLfloat depth = *((GLfloat *) texel); 01408 GLuint zi = ((GLuint) (depth * 0xffffff)) << 8; 01409 *dst = zi | (*dst & 0xff); 01410 } 01411 #endif 01412 01413 01414 /* MESA_TEXFORMAT_S8_Z24 ***************************************************/ 01415 01416 static void FETCH(f_s8_z24)( const struct gl_texture_image *texImage, 01417 GLint i, GLint j, GLint k, GLfloat *texel ) 01418 { 01419 /* only return Z, not stencil data */ 01420 const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); 01421 const GLfloat scale = 1.0F / (GLfloat) 0xffffff; 01422 texel[0] = ((*src) & 0x00ffffff) * scale; 01423 ASSERT(texImage->TexFormat->MesaFormat == MESA_FORMAT_S8_Z24); 01424 ASSERT(texel[0] >= 0.0F); 01425 ASSERT(texel[0] <= 1.0F); 01426 } 01427 01428 #if DIM == 3 01429 static void store_texel_s8_z24(struct gl_texture_image *texImage, 01430 GLint i, GLint j, GLint k, const void *texel) 01431 { 01432 /* only store Z, not stencil */ 01433 GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); 01434 GLfloat depth = *((GLfloat *) texel); 01435 GLuint zi = (GLuint) (depth * 0xffffff); 01436 *dst = zi | (*dst & 0xff000000); 01437 } 01438 #endif 01439 01440 01441 #undef TEXEL_ADDR 01442 #undef DIM 01443 #undef FETCH Generated on Sat May 26 2012 04:19:14 for ReactOS by
1.7.6.1
|