Compare commits
	
		
			8 Commits
		
	
	
		
			mesa-24.2.
			...
			rgb10_a2ui
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 257f32ad20 | ||
|  | 4e0ece34ed | ||
|  | 8bccaa61d7 | ||
|  | 63d5fd0376 | ||
|  | 08bc1b7343 | ||
|  | 9f92031355 | ||
|  | e56728c9d8 | ||
|  | 644d434137 | 
| @@ -78,7 +78,7 @@ GL_ARB_explicit_attrib_location                       DONE (i915, i965, r300, r6 | ||||
| GL_ARB_occlusion_query2                               DONE (r300, r600, swrast) | ||||
| GL_ARB_sampler_objects                                DONE (i965, r300, r600) | ||||
| GL_ARB_shader_bit_encoding                            DONE | ||||
| GL_ARB_texture_rgb10_a2ui                             DONE (r600) | ||||
| GL_ARB_texture_rgb10_a2ui                             DONE (i965, r600) | ||||
| GL_ARB_texture_swizzle                                DONE (same as EXT version) (i965, r300, r600, swrast) | ||||
| GL_ARB_timer_query                                    DONE | ||||
| GL_ARB_instanced_arrays                               DONE (i965, r300, r600) | ||||
|   | ||||
| @@ -72,6 +72,8 @@ | ||||
| #include "program/program.h" | ||||
| #include "swrast/swrast.h" | ||||
| #include "drivers/common/meta.h" | ||||
| #include "main/enums.h" | ||||
| #include "main/glformats.h" | ||||
|  | ||||
|  | ||||
| /** Return offset in bytes of the field within a vertex struct */ | ||||
| @@ -3158,8 +3160,12 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target, | ||||
|  * ReadPixels() and passed to Tex[Sub]Image(). | ||||
|  */ | ||||
| static GLenum | ||||
| get_temp_image_type(struct gl_context *ctx, GLenum baseFormat) | ||||
| get_temp_image_type(struct gl_context *ctx, gl_format format) | ||||
| { | ||||
|    GLenum baseFormat, type; | ||||
|  | ||||
|    baseFormat = _mesa_get_format_base_format(format); | ||||
|  | ||||
|    switch (baseFormat) { | ||||
|    case GL_RGBA: | ||||
|    case GL_RGB: | ||||
| @@ -3174,7 +3180,7 @@ get_temp_image_type(struct gl_context *ctx, GLenum baseFormat) | ||||
|       else if (ctx->DrawBuffer->Visual.redBits <= 16) | ||||
|          return GL_UNSIGNED_SHORT; | ||||
|       else | ||||
|          return GL_FLOAT; | ||||
|          return _mesa_get_format_datatype(format); | ||||
|    case GL_DEPTH_COMPONENT: | ||||
|       return GL_UNSIGNED_INT; | ||||
|    case GL_DEPTH_STENCIL: | ||||
| @@ -3216,12 +3222,10 @@ _mesa_meta_CopyTexSubImage(struct gl_context *ctx, GLuint dims, | ||||
|       format = GL_RGBA; | ||||
|    } | ||||
|  | ||||
|    type = get_temp_image_type(ctx, texImage->TexFormat); | ||||
|    if (_mesa_is_format_integer_color(texImage->TexFormat)) { | ||||
|       _mesa_problem(ctx, "unsupported integer color copyteximage"); | ||||
|       return; | ||||
|       format = _mesa_base_format_to_integer_format(format); | ||||
|    } | ||||
|  | ||||
|    type = get_temp_image_type(ctx, format); | ||||
|    bpp = _mesa_bytes_per_pixel(format, type); | ||||
|    if (bpp <= 0) { | ||||
|       _mesa_problem(ctx, "Bad bpp in _mesa_meta_CopyTexSubImage()"); | ||||
|   | ||||
| @@ -325,6 +325,7 @@ brw_format_for_mesa_format(gl_format mesa_format) | ||||
|       [MESA_FORMAT_RG1616] = BRW_SURFACEFORMAT_R16G16_UNORM, | ||||
|       [MESA_FORMAT_RG1616_REV] = 0, | ||||
|       [MESA_FORMAT_ARGB2101010] = BRW_SURFACEFORMAT_B10G10R10A2_UNORM, | ||||
|       [MESA_FORMAT_ABGR2101010_UINT] = BRW_SURFACEFORMAT_R10G10B10A2_UINT, | ||||
|       [MESA_FORMAT_Z24_S8] = 0, | ||||
|       [MESA_FORMAT_S8_Z24] = 0, | ||||
|       [MESA_FORMAT_Z16] = 0, | ||||
|   | ||||
| @@ -92,6 +92,7 @@ intelInitExtensions(struct gl_context *ctx) | ||||
| #endif | ||||
|    ctx->Extensions.OES_draw_texture = true; | ||||
|    ctx->Extensions.OES_compressed_ETC1_RGB8_texture = true; | ||||
|    ctx->Extensions.ARB_texture_rgb10_a2ui = true; | ||||
|  | ||||
|    if (intel->gen >= 6) | ||||
|       ctx->Const.GLSLVersion = 130; | ||||
|   | ||||
| @@ -1604,6 +1604,11 @@ get_unpack_rgba_function(gl_format format) | ||||
|       initialized = GL_TRUE; | ||||
|    } | ||||
|  | ||||
|    if (table[format] == NULL) { | ||||
|       _mesa_problem(NULL, "unsupported unpack for format %s", | ||||
|                     _mesa_get_format_name(format)); | ||||
|    } | ||||
|  | ||||
|    return table[format]; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -462,8 +462,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) | ||||
|    } | ||||
| } | ||||
|  | ||||
| /* Customization of integer packing.  We always treat src as uint, and can pack dst | ||||
|  * as any integer type/format combo. | ||||
| /* Customization of unsigned integer packing. | ||||
|  */ | ||||
| #define SRC_TYPE GLuint | ||||
|  | ||||
| @@ -475,6 +474,14 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) | ||||
| #undef SRC_CONVERT | ||||
| #undef FN_NAME | ||||
|  | ||||
| #define DST_TYPE GLint | ||||
| #define SRC_CONVERT(x) MIN2(x, 0x7fffffff) | ||||
| #define FN_NAME pack_int_from_uint_rgba | ||||
| #include "pack_tmp.h" | ||||
| #undef DST_TYPE | ||||
| #undef SRC_CONVERT | ||||
| #undef FN_NAME | ||||
|  | ||||
| #define DST_TYPE GLushort | ||||
| #define SRC_CONVERT(x) MIN2(x, 0xffff) | ||||
| #define FN_NAME pack_ushort_from_uint_rgba | ||||
| @@ -507,18 +514,21 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) | ||||
| #undef SRC_CONVERT | ||||
| #undef FN_NAME | ||||
|  | ||||
| #undef SRC_TYPE | ||||
|  | ||||
| void | ||||
| _mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4], | ||||
|                          GLenum dstFormat, GLenum dstType, | ||||
|                          GLvoid *dstAddr) | ||||
| _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][4], | ||||
|                                 GLenum dstFormat, GLenum dstType, | ||||
|                                 GLvoid *dstAddr) | ||||
| { | ||||
|    GLuint i; | ||||
|  | ||||
|    switch(dstType) { | ||||
|    case GL_UNSIGNED_INT: | ||||
|       pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n); | ||||
|       break; | ||||
|    case GL_INT: | ||||
|       /* No conversion necessary. */ | ||||
|       pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n); | ||||
|       pack_int_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n); | ||||
|       break; | ||||
|    case GL_UNSIGNED_SHORT: | ||||
|       pack_ushort_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n); | ||||
| @@ -532,6 +542,633 @@ _mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4], | ||||
|    case GL_BYTE: | ||||
|       pack_byte_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n); | ||||
|       break; | ||||
|    case GL_UNSIGNED_BYTE_3_3_2: | ||||
|       if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) { | ||||
|          GLubyte *dst = (GLubyte *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 7) << 5) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 7) << 2) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 3)     ); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_BYTE_2_3_3_REV: | ||||
|       if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) { | ||||
|          GLubyte *dst = (GLubyte *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 7)     ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 7) << 3) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 3) << 6); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_SHORT_5_6_5: | ||||
|       if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) << 11) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 63) <<  5) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 31)      ); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_SHORT_5_6_5_REV: | ||||
|       if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31)      ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 63) <<  5) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 31) << 11); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_SHORT_4_4_4_4: | ||||
|       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 15) << 12) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 15) <<  8) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 15) <<  4) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0, 15)      ); | ||||
|          } | ||||
|       } | ||||
|       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][BCOMP], 0, 15) << 12) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 15) <<  8) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 15) <<  4) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0, 15)      ); | ||||
|          } | ||||
|       } | ||||
|       else if (dstFormat == GL_ABGR_EXT) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][ACOMP], 0, 15) << 12) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 15) <<  8) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 15) <<  4) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 15)      ); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_SHORT_4_4_4_4_REV: | ||||
|       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 15)      ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 15) <<  4) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 15) <<  8) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0, 15) << 12); | ||||
|          } | ||||
|       } | ||||
|       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][BCOMP], 0, 15)      ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 15) <<  4) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 15) <<  8) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0, 15) << 12); | ||||
|          } | ||||
|       } | ||||
|       else if (dstFormat == GL_ABGR_EXT) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][ACOMP], 0, 15)      ) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 15) <<  4) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 15) <<  8) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 15) << 12); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_SHORT_5_5_5_1: | ||||
|       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) << 11) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 31) <<  6) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 31) <<  1) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0,  1)      ); | ||||
|          } | ||||
|       } | ||||
|       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][BCOMP], 0, 31) << 11) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 31) <<  6) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 31) <<  1) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0,  1)      ); | ||||
|          } | ||||
|       } | ||||
|       else if (dstFormat == GL_ABGR_EXT) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][ACOMP], 0, 31) << 11) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 31) <<  6) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 31) <<  1) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0,  1)      ); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_SHORT_1_5_5_5_REV: | ||||
|       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31)      ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 31) <<  5) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 31) << 10) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0,  1) << 15); | ||||
|          } | ||||
|       } | ||||
|       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][BCOMP], 0, 31)      ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 31) <<  5) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 31) << 10) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0,  1) << 15); | ||||
|          } | ||||
|       } | ||||
|       else if (dstFormat == GL_ABGR_EXT) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][ACOMP], 0, 31)      ) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 31) <<  5) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 31) << 10) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0,  1) << 15); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_INT_8_8_8_8: | ||||
|       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 255) << 24) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 255) << 16) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 255) <<  8) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0, 255)      ); | ||||
|          } | ||||
|       } | ||||
|       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][BCOMP], 0, 255) << 24) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 255) << 16) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 255) <<  8) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0, 255)      ); | ||||
|          } | ||||
|       } | ||||
|       else if (dstFormat == GL_ABGR_EXT) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][ACOMP], 0, 255) << 24) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 255) << 16) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 255) <<  8) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 255)      ); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_INT_8_8_8_8_REV: | ||||
|       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 255)      ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 255) <<  8) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 255) << 16) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0, 255) << 24); | ||||
|          } | ||||
|       } | ||||
|       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][BCOMP], 0, 255)      ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 255) <<  8) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 255) << 16) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0, 255) << 24); | ||||
|          } | ||||
|       } | ||||
|       else if (dstFormat == GL_ABGR_EXT) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][ACOMP], 0, 255)      ) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 255) <<  8) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 255) << 16) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 255) << 24); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_INT_10_10_10_2: | ||||
|       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 1023) << 22) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 1023) << 12) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 1023) <<  2) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0,    3)      ); | ||||
|          } | ||||
|       } | ||||
|       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][BCOMP], 0, 1023) << 22) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 1023) << 12) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 1023) <<  2) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0,    3)      ); | ||||
|          } | ||||
|       } | ||||
|       else if (dstFormat == GL_ABGR_EXT) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][ACOMP], 0, 1023) << 22) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 1023) << 12) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 1023) <<  2) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0,    3)      ); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_INT_2_10_10_10_REV: | ||||
|       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 1023)      ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 1023) << 10) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 1023) << 20) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0,    3) << 30); | ||||
|          } | ||||
|       } | ||||
|       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][BCOMP], 0, 1023)      ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 1023) << 10) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 1023) << 20) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0,    3) << 30); | ||||
|          } | ||||
|       } | ||||
|       else if (dstFormat == GL_ABGR_EXT) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][ACOMP], 0, 1023)      ) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 1023) << 10) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 1023) << 20) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0,    3) << 30); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    default: | ||||
|       _mesa_problem(ctx, | ||||
|          "Unsupported type (%s) for format (%s)", | ||||
|          _mesa_lookup_enum_by_nr(dstType), | ||||
|          _mesa_lookup_enum_by_nr(dstFormat)); | ||||
|       return; | ||||
|    } | ||||
| } | ||||
|  | ||||
|  | ||||
| /* Customization of signed integer packing. | ||||
|  */ | ||||
| #define SRC_TYPE GLint | ||||
|  | ||||
| #define DST_TYPE GLuint | ||||
| #define SRC_CONVERT(x) MAX2(x, 0) | ||||
| #define FN_NAME pack_uint_from_int_rgba | ||||
| #include "pack_tmp.h" | ||||
| #undef DST_TYPE | ||||
| #undef SRC_CONVERT | ||||
| #undef FN_NAME | ||||
|  | ||||
| #define DST_TYPE GLushort | ||||
| #define SRC_CONVERT(x) MAX2(x, 0) | ||||
| #define FN_NAME pack_ushort_from_int_rgba | ||||
| #include "pack_tmp.h" | ||||
| #undef DST_TYPE | ||||
| #undef SRC_CONVERT | ||||
| #undef FN_NAME | ||||
|  | ||||
| #define DST_TYPE GLshort | ||||
| #define SRC_CONVERT(x) CLAMP(x, -0x8000, 0x7fff) | ||||
| #define FN_NAME pack_short_from_int_rgba | ||||
| #include "pack_tmp.h" | ||||
| #undef DST_TYPE | ||||
| #undef SRC_CONVERT | ||||
| #undef FN_NAME | ||||
|  | ||||
| #define DST_TYPE GLubyte | ||||
| #define SRC_CONVERT(x) MAX2(x, 0) | ||||
| #define FN_NAME pack_ubyte_from_int_rgba | ||||
| #include "pack_tmp.h" | ||||
| #undef DST_TYPE | ||||
| #undef SRC_CONVERT | ||||
| #undef FN_NAME | ||||
|  | ||||
| #define DST_TYPE GLbyte | ||||
| #define SRC_CONVERT(x) CLAMP(x, -0x80, 0x7f) | ||||
| #define FN_NAME pack_byte_from_int_rgba | ||||
| #include "pack_tmp.h" | ||||
| #undef DST_TYPE | ||||
| #undef SRC_CONVERT | ||||
| #undef FN_NAME | ||||
|  | ||||
| #undef SRC_TYPE | ||||
|  | ||||
| void | ||||
| _mesa_pack_rgba_span_from_ints(struct gl_context *ctx, GLuint n, GLint rgba[][4], | ||||
|                                GLenum dstFormat, GLenum dstType, | ||||
|                                GLvoid *dstAddr) | ||||
| { | ||||
|    GLuint i; | ||||
|  | ||||
|    switch(dstType) { | ||||
|    case GL_UNSIGNED_INT: | ||||
|       pack_uint_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n); | ||||
|       break; | ||||
|    case GL_INT: | ||||
|       /* No conversion necessary. */ | ||||
|       pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n); | ||||
|       break; | ||||
|    case GL_UNSIGNED_SHORT: | ||||
|       pack_ushort_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n); | ||||
|       break; | ||||
|    case GL_SHORT: | ||||
|       pack_short_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n); | ||||
|       break; | ||||
|    case GL_UNSIGNED_BYTE: | ||||
|       pack_ubyte_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n); | ||||
|       break; | ||||
|    case GL_BYTE: | ||||
|       pack_byte_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n); | ||||
|       break; | ||||
|    case GL_UNSIGNED_BYTE_3_3_2: | ||||
|       if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) { | ||||
|          GLubyte *dst = (GLubyte *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 7) << 5) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 7) << 2) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 3)     ); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_BYTE_2_3_3_REV: | ||||
|       if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) { | ||||
|          GLubyte *dst = (GLubyte *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 7)     ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 7) << 3) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 3) << 6); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_SHORT_5_6_5: | ||||
|       if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) << 11) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 63) <<  5) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 31)      ); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_SHORT_5_6_5_REV: | ||||
|       if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31)      ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 63) <<  5) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 31) << 11); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_SHORT_4_4_4_4: | ||||
|       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 15) << 12) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 15) <<  8) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 15) <<  4) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0, 15)      ); | ||||
|          } | ||||
|       } | ||||
|       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][BCOMP], 0, 15) << 12) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 15) <<  8) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 15) <<  4) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0, 15)      ); | ||||
|          } | ||||
|       } | ||||
|       else if (dstFormat == GL_ABGR_EXT) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][ACOMP], 0, 15) << 12) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 15) <<  8) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 15) <<  4) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 15)      ); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_SHORT_4_4_4_4_REV: | ||||
|       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 15)      ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 15) <<  4) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 15) <<  8) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0, 15) << 12); | ||||
|          } | ||||
|       } | ||||
|       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][BCOMP], 0, 15)      ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 15) <<  4) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 15) <<  8) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0, 15) << 12); | ||||
|          } | ||||
|       } | ||||
|       else if (dstFormat == GL_ABGR_EXT) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][ACOMP], 0, 15)      ) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 15) <<  4) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 15) <<  8) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 15) << 12); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_SHORT_5_5_5_1: | ||||
|       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) << 11) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 31) <<  6) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 31) <<  1) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0,  1)      ); | ||||
|          } | ||||
|       } | ||||
|       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][BCOMP], 0, 31) << 11) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 31) <<  6) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 31) <<  1) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0,  1)      ); | ||||
|          } | ||||
|       } | ||||
|       else if (dstFormat == GL_ABGR_EXT) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][ACOMP], 0, 31) << 11) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 31) <<  6) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 31) <<  1) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0,  1)      ); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_SHORT_1_5_5_5_REV: | ||||
|       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31)      ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 31) <<  5) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 31) << 10) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0,  1) << 15); | ||||
|          } | ||||
|       } | ||||
|       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][BCOMP], 0, 31)      ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 31) <<  5) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 31) << 10) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0,  1) << 15); | ||||
|          } | ||||
|       } | ||||
|       else if (dstFormat == GL_ABGR_EXT) { | ||||
|          GLushort *dst = (GLushort *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][ACOMP], 0, 31)      ) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 31) <<  5) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 31) << 10) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0,  1) << 15); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_INT_8_8_8_8: | ||||
|       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 255) << 24) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 255) << 16) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 255) <<  8) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0, 255)      ); | ||||
|          } | ||||
|       } | ||||
|       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][BCOMP], 0, 255) << 24) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 255) << 16) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 255) <<  8) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0, 255)      ); | ||||
|          } | ||||
|       } | ||||
|       else if (dstFormat == GL_ABGR_EXT) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][ACOMP], 0, 255) << 24) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 255) << 16) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 255) <<  8) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 255)      ); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_INT_8_8_8_8_REV: | ||||
|       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 255)      ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 255) <<  8) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 255) << 16) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0, 255) << 24); | ||||
|          } | ||||
|       } | ||||
|       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][BCOMP], 0, 255)      ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 255) <<  8) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 255) << 16) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0, 255) << 24); | ||||
|          } | ||||
|       } | ||||
|       else if (dstFormat == GL_ABGR_EXT) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][ACOMP], 0, 255)      ) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 255) <<  8) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 255) << 16) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 255) << 24); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_INT_10_10_10_2: | ||||
|       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 1023) << 22) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 1023) << 12) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 1023) <<  2) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0,    3)      ); | ||||
|          } | ||||
|       } | ||||
|       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][BCOMP], 0, 1023) << 22) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 1023) << 12) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 1023) <<  2) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0,    3)      ); | ||||
|          } | ||||
|       } | ||||
|       else if (dstFormat == GL_ABGR_EXT) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][ACOMP], 0, 1023) << 22) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 1023) << 12) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 1023) <<  2) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0,    3)      ); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    case GL_UNSIGNED_INT_2_10_10_10_REV: | ||||
|       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][RCOMP], 0, 1023)      ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 1023) << 10) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 1023) << 20) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0,    3) << 30); | ||||
|          } | ||||
|       } | ||||
|       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][BCOMP], 0, 1023)      ) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 1023) << 10) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0, 1023) << 20) | ||||
|                    | (CLAMP(rgba[i][ACOMP], 0,    3) << 30); | ||||
|          } | ||||
|       } | ||||
|       else if (dstFormat == GL_ABGR_EXT) { | ||||
|          GLuint *dst = (GLuint *) dstAddr; | ||||
|          for (i=0;i<n;i++) { | ||||
|             dst[i] = (CLAMP(rgba[i][ACOMP], 0, 1023)      ) | ||||
|                    | (CLAMP(rgba[i][BCOMP], 0, 1023) << 10) | ||||
|                    | (CLAMP(rgba[i][GCOMP], 0, 1023) << 20) | ||||
|                    | (CLAMP(rgba[i][RCOMP], 0,    3) << 30); | ||||
|          } | ||||
|       } | ||||
|       break; | ||||
|    default: | ||||
|       _mesa_problem(ctx, | ||||
|          "Unsupported type (%s) for format (%s)", | ||||
|   | ||||
| @@ -145,9 +145,15 @@ _mesa_unpack_image(GLuint dimensions, | ||||
|  | ||||
|  | ||||
| void | ||||
| _mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4], | ||||
|                          GLenum dstFormat, GLenum dstType, | ||||
|                          GLvoid *dstAddr); | ||||
| _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][4], | ||||
|                                 GLenum dstFormat, GLenum dstType, | ||||
|                                 GLvoid *dstAddr); | ||||
|  | ||||
|  | ||||
| void | ||||
| _mesa_pack_rgba_span_from_ints(struct gl_context *ctx, GLuint n, GLint rgba[][4], | ||||
|                                GLenum dstFormat, GLenum dstType, | ||||
|                                GLvoid *dstAddr); | ||||
|  | ||||
|  | ||||
| extern void | ||||
|   | ||||
| @@ -321,6 +321,8 @@ slow_read_rgba_pixels( struct gl_context *ctx, | ||||
|    void *rgba; | ||||
|    GLubyte *dst, *map; | ||||
|    int dstStride, stride, j; | ||||
|    GLboolean is_integer = _mesa_is_enum_format_integer(format); | ||||
|    GLboolean is_unsiged_integer = _mesa_is_format_unsigned(rbFormat); | ||||
|  | ||||
|    dstStride = _mesa_image_row_stride(packing, width, format, type); | ||||
|    dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height, | ||||
| @@ -338,12 +340,17 @@ slow_read_rgba_pixels( struct gl_context *ctx, | ||||
|       goto done; | ||||
|  | ||||
|    for (j = 0; j < height; j++) { | ||||
|       if (_mesa_is_enum_format_integer(format)) { | ||||
|       if (is_integer) { | ||||
| 	 _mesa_unpack_uint_rgba_row(rbFormat, width, map, (GLuint (*)[4]) rgba); | ||||
|          _mesa_rebase_rgba_uint(width, (GLuint (*)[4]) rgba, | ||||
|                                 rb->_BaseFormat); | ||||
| 	 _mesa_pack_rgba_span_int(ctx, width, (GLuint (*)[4]) rgba, format, | ||||
|                                   type, dst); | ||||
|          if (is_unsiged_integer) { | ||||
|             _mesa_pack_rgba_span_from_uints(ctx, width, (GLuint (*)[4]) rgba, format, | ||||
|                                             type, dst); | ||||
|          } else { | ||||
|             _mesa_pack_rgba_span_from_ints(ctx, width, (GLint (*)[4]) rgba, format, | ||||
|                                            type, dst); | ||||
|          } | ||||
|       } else { | ||||
| 	 _mesa_unpack_rgba_row(rbFormat, width, map, (GLfloat (*)[4]) rgba); | ||||
|          _mesa_rebase_rgba_float(width, (GLfloat (*)[4]) rgba, | ||||
|   | ||||
| @@ -306,6 +306,7 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions, | ||||
|    GLfloat (*rgba)[4]; | ||||
|    GLuint (*rgba_uint)[4]; | ||||
|    GLboolean is_integer = _mesa_is_format_integer_color(texImage->TexFormat); | ||||
|    GLboolean is_unsiged_integer = _mesa_is_format_unsigned(texImage->TexFormat); | ||||
|  | ||||
|    /* Allocate buffer for one row of texels */ | ||||
|    rgba = (GLfloat (*)[4]) malloc(4 * width * sizeof(GLfloat)); | ||||
| @@ -361,8 +362,15 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions, | ||||
| 	       _mesa_unpack_uint_rgba_row(texFormat, width, src, rgba_uint); | ||||
|                if (rebaseFormat) | ||||
|                   _mesa_rebase_rgba_uint(width, rgba_uint, rebaseFormat); | ||||
| 	       _mesa_pack_rgba_span_int(ctx, width, rgba_uint, | ||||
| 					format, type, dest); | ||||
|                if (is_unsiged_integer) { | ||||
|                   _mesa_pack_rgba_span_from_uints(ctx, width, | ||||
|                                                   (GLuint (*)[4]) rgba_uint, | ||||
|                                                   format, type, dest); | ||||
|                } else { | ||||
|                   _mesa_pack_rgba_span_from_ints(ctx, width, | ||||
|                                                  (GLint (*)[4]) rgba_uint, | ||||
|                                                  format, type, dest); | ||||
|                } | ||||
| 	    } else { | ||||
| 	       _mesa_unpack_rgba_row(texFormat, width, src, rgba); | ||||
|                if (rebaseFormat) | ||||
|   | ||||
| @@ -3200,6 +3200,7 @@ _mesa_texstore_rgba_int8(TEXSTORE_PARAMS) | ||||
| 						     srcPacking); | ||||
|       const GLuint *src = tempImage; | ||||
|       GLint img, row; | ||||
|       GLboolean is_unsigned = _mesa_is_type_unsigned(srcType); | ||||
|       if (!tempImage) | ||||
|          return GL_FALSE; | ||||
|       for (img = 0; img < srcDepth; img++) { | ||||
| @@ -3207,8 +3208,14 @@ _mesa_texstore_rgba_int8(TEXSTORE_PARAMS) | ||||
|          for (row = 0; row < srcHeight; row++) { | ||||
|             GLbyte *dstTexel = (GLbyte *) dstRow; | ||||
|             GLint i; | ||||
|             for (i = 0; i < srcWidth * components; i++) { | ||||
|                dstTexel[i] = (GLbyte) src[i]; | ||||
|             if (is_unsigned) { | ||||
|                for (i = 0; i < srcWidth * components; i++) { | ||||
|                   dstTexel[i] = (GLbyte) MIN2(src[i], 0x7f); | ||||
|                } | ||||
|             } else { | ||||
|                for (i = 0; i < srcWidth * components; i++) { | ||||
|                   dstTexel[i] = (GLbyte) CLAMP((GLint) src[i], -0x80, 0x7f); | ||||
|                } | ||||
|             } | ||||
|             dstRow += dstRowStride; | ||||
|             src += srcWidth * components; | ||||
| @@ -3270,6 +3277,7 @@ _mesa_texstore_rgba_int16(TEXSTORE_PARAMS) | ||||
| 						     srcPacking); | ||||
|       const GLuint *src = tempImage; | ||||
|       GLint img, row; | ||||
|       GLboolean is_unsigned = _mesa_is_type_unsigned(srcType); | ||||
|       if (!tempImage) | ||||
|          return GL_FALSE; | ||||
|       for (img = 0; img < srcDepth; img++) { | ||||
| @@ -3277,8 +3285,14 @@ _mesa_texstore_rgba_int16(TEXSTORE_PARAMS) | ||||
|          for (row = 0; row < srcHeight; row++) { | ||||
|             GLshort *dstTexel = (GLshort *) dstRow; | ||||
|             GLint i; | ||||
|             for (i = 0; i < srcWidth * components; i++) { | ||||
|                dstTexel[i] = (GLint) src[i]; | ||||
|             if (is_unsigned) { | ||||
|                for (i = 0; i < srcWidth * components; i++) { | ||||
|                   dstTexel[i] = (GLshort) MIN2(src[i], 0x7fff); | ||||
|                } | ||||
|             } else { | ||||
|                for (i = 0; i < srcWidth * components; i++) { | ||||
|                   dstTexel[i] = (GLshort)CLAMP((GLint) src[i], -0x8000, 0x7fff); | ||||
|                } | ||||
|             } | ||||
|             dstRow += dstRowStride; | ||||
|             src += srcWidth * components; | ||||
| @@ -3340,6 +3354,7 @@ _mesa_texstore_rgba_int32(TEXSTORE_PARAMS) | ||||
| 						     srcPacking); | ||||
|       const GLuint *src = tempImage; | ||||
|       GLint img, row; | ||||
|       GLboolean is_unsigned = _mesa_is_type_unsigned(srcType); | ||||
|       if (!tempImage) | ||||
|          return GL_FALSE; | ||||
|       for (img = 0; img < srcDepth; img++) { | ||||
| @@ -3347,8 +3362,14 @@ _mesa_texstore_rgba_int32(TEXSTORE_PARAMS) | ||||
|          for (row = 0; row < srcHeight; row++) { | ||||
|             GLint *dstTexel = (GLint *) dstRow; | ||||
|             GLint i; | ||||
|             for (i = 0; i < srcWidth * components; i++) { | ||||
|                dstTexel[i] = (GLint) src[i]; | ||||
|             if (is_unsigned) { | ||||
|                for (i = 0; i < srcWidth * components; i++) { | ||||
|                   dstTexel[i] = (GLint) MIN2(src[i], 0x7fffffff); | ||||
|                } | ||||
|             } else { | ||||
|                for (i = 0; i < srcWidth * components; i++) { | ||||
|                   dstTexel[i] = (GLint) src[i]; | ||||
|                } | ||||
|             } | ||||
|             dstRow += dstRowStride; | ||||
|             src += srcWidth * components; | ||||
| @@ -3407,6 +3428,7 @@ _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) | ||||
|                               srcFormat, srcType, srcAddr, srcPacking); | ||||
|       const GLuint *src = tempImage; | ||||
|       GLint img, row; | ||||
|       GLboolean is_unsigned = _mesa_is_type_unsigned(srcType); | ||||
|       if (!tempImage) | ||||
|          return GL_FALSE; | ||||
|       for (img = 0; img < srcDepth; img++) { | ||||
| @@ -3414,8 +3436,14 @@ _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) | ||||
|          for (row = 0; row < srcHeight; row++) { | ||||
|             GLubyte *dstTexel = (GLubyte *) dstRow; | ||||
|             GLint i; | ||||
|             for (i = 0; i < srcWidth * components; i++) { | ||||
|                dstTexel[i] = (GLubyte) CLAMP(src[i], 0, 0xff); | ||||
|             if (is_unsigned) { | ||||
|                for (i = 0; i < srcWidth * components; i++) { | ||||
|                   dstTexel[i] = (GLubyte) MIN2(src[i], 0xff); | ||||
|                } | ||||
|             } else { | ||||
|                for (i = 0; i < srcWidth * components; i++) { | ||||
|                   dstTexel[i] = (GLubyte) CLAMP((GLint) src[i], 0, 0xff); | ||||
|                } | ||||
|             } | ||||
|             dstRow += dstRowStride; | ||||
|             src += srcWidth * components; | ||||
| @@ -3474,6 +3502,7 @@ _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) | ||||
|                               srcFormat, srcType, srcAddr, srcPacking); | ||||
|       const GLuint *src = tempImage; | ||||
|       GLint img, row; | ||||
|       GLboolean is_unsigned = _mesa_is_type_unsigned(srcType); | ||||
|       if (!tempImage) | ||||
|          return GL_FALSE; | ||||
|       for (img = 0; img < srcDepth; img++) { | ||||
| @@ -3481,8 +3510,14 @@ _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) | ||||
|          for (row = 0; row < srcHeight; row++) { | ||||
|             GLushort *dstTexel = (GLushort *) dstRow; | ||||
|             GLint i; | ||||
|             for (i = 0; i < srcWidth * components; i++) { | ||||
|                dstTexel[i] = (GLushort) CLAMP(src[i], 0, 0xffff); | ||||
|             if (is_unsigned) { | ||||
|                for (i = 0; i < srcWidth * components; i++) { | ||||
|                   dstTexel[i] = (GLushort) MIN2(src[i], 0xffff); | ||||
|               } | ||||
|             } else { | ||||
|                for (i = 0; i < srcWidth * components; i++) { | ||||
|                   dstTexel[i] = (GLushort) CLAMP((GLint) src[i], 0, 0xffff); | ||||
|                } | ||||
|             } | ||||
|             dstRow += dstRowStride; | ||||
|             src += srcWidth * components; | ||||
| @@ -3540,6 +3575,7 @@ _mesa_texstore_rgba_uint32(TEXSTORE_PARAMS) | ||||
|                               srcWidth, srcHeight, srcDepth, | ||||
|                               srcFormat, srcType, srcAddr, srcPacking); | ||||
|       const GLuint *src = tempImage; | ||||
|       GLboolean is_unsigned = _mesa_is_type_unsigned(srcType); | ||||
|       GLint img, row; | ||||
|       if (!tempImage) | ||||
|          return GL_FALSE; | ||||
| @@ -3548,8 +3584,14 @@ _mesa_texstore_rgba_uint32(TEXSTORE_PARAMS) | ||||
|          for (row = 0; row < srcHeight; row++) { | ||||
|             GLuint *dstTexel = (GLuint *) dstRow; | ||||
|             GLint i; | ||||
|             for (i = 0; i < srcWidth * components; i++) { | ||||
|                dstTexel[i] = src[i]; | ||||
|             if (is_unsigned) { | ||||
|                for (i = 0; i < srcWidth * components; i++) { | ||||
|                   dstTexel[i] = src[i]; | ||||
|                } | ||||
|             } else { | ||||
|                for (i = 0; i < srcWidth * components; i++) { | ||||
|                   dstTexel[i] = MAX2((GLint) src[i], 0); | ||||
|                } | ||||
|             } | ||||
|             dstRow += dstRowStride; | ||||
|             src += srcWidth * components; | ||||
| @@ -3867,6 +3909,7 @@ _mesa_texstore_argb2101010_uint(TEXSTORE_PARAMS) | ||||
|                                                      srcPacking); | ||||
|       const GLuint *src = tempImage; | ||||
|       GLint img, row, col; | ||||
|       GLboolean is_unsigned = _mesa_is_type_unsigned(srcType); | ||||
|       if (!tempImage) | ||||
|          return GL_FALSE; | ||||
|       for (img = 0; img < srcDepth; img++) { | ||||
| @@ -3874,14 +3917,26 @@ _mesa_texstore_argb2101010_uint(TEXSTORE_PARAMS) | ||||
|  | ||||
|          for (row = 0; row < srcHeight; row++) { | ||||
|             GLuint *dstUI = (GLuint *) dstRow; | ||||
|             for (col = 0; col < srcWidth; col++) { | ||||
|                GLushort a,r,g,b; | ||||
|                r = src[RCOMP]; | ||||
|                g = src[GCOMP]; | ||||
|                b = src[BCOMP]; | ||||
|                a = src[ACOMP]; | ||||
|                dstUI[col] = (a << 30) | (r << 20) | (g << 10) | (b); | ||||
|                src += 4; | ||||
|             if (is_unsigned) { | ||||
|                for (col = 0; col < srcWidth; col++) { | ||||
|                   GLushort a,r,g,b; | ||||
|                   r = MIN2(src[RCOMP], 0x3ff); | ||||
|                   g = MIN2(src[GCOMP], 0x3ff); | ||||
|                   b = MIN2(src[BCOMP], 0x3ff); | ||||
|                   a = MIN2(src[ACOMP], 0x003); | ||||
|                   dstUI[col] = (a << 30) | (r << 20) | (g << 10) | (b); | ||||
|                   src += 4; | ||||
|                } | ||||
|             } else { | ||||
|                for (col = 0; col < srcWidth; col++) { | ||||
|                   GLushort a,r,g,b; | ||||
|                   r = CLAMP((GLint) src[RCOMP], 0, 0x3ff); | ||||
|                   g = CLAMP((GLint) src[GCOMP], 0, 0x3ff); | ||||
|                   b = CLAMP((GLint) src[BCOMP], 0, 0x3ff); | ||||
|                   a = CLAMP((GLint) src[ACOMP], 0, 0x003); | ||||
|                   dstUI[col] = (a << 30) | (r << 20) | (g << 10) | (b); | ||||
|                   src += 4; | ||||
|                } | ||||
|             } | ||||
|             dstRow += dstRowStride; | ||||
|          } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user