From f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Apr 2004 00:27:31 +0000 Subject: New glTexImage code. The gl_texture_format struct now has a StoreTexImageFunc that's called by glTex[Sub]Image[123]D to convert the user's texture data into the specific texture format layout. Now it's much easier to add new texture formats (like the 16/32-bit floating point formats). The texutil.[ch] and texutil_tmp.h files are obsolete. --- src/mesa/main/image.c | 87 +++++++++++++++++++++++++++------------------------ 1 file changed, 46 insertions(+), 41 deletions(-) (limited to 'src/mesa/main/image.c') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index d610865996..4eba8e8415 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1,8 +1,3 @@ -/** - * \file image.c - * Image handling. - */ - /* * Mesa 3-D graphics library * Version: 6.1 @@ -28,6 +23,12 @@ */ +/** + * \file image.c + * Image handling. + */ + + #include "glheader.h" #include "bufferobj.h" #include "colormac.h" @@ -141,8 +142,8 @@ GLint _mesa_sizeof_type( GLenum type ) return sizeof(GLint); case GL_FLOAT: return sizeof(GLfloat); - case GL_HALF_FLOAT_NV: - return sizeof(GLhalfNV); + case GL_HALF_FLOAT_ARB: + return sizeof(GLhalfARB); default: return -1; } @@ -170,8 +171,8 @@ GLint _mesa_sizeof_packed_type( GLenum type ) return sizeof(GLuint); case GL_INT: return sizeof(GLint); - case GL_HALF_FLOAT_NV: - return sizeof(GLhalfNV); + case GL_HALF_FLOAT_ARB: + return sizeof(GLhalfARB); case GL_FLOAT: return sizeof(GLfloat); case GL_UNSIGNED_BYTE_3_3_2: @@ -281,8 +282,8 @@ GLint _mesa_bytes_per_pixel( GLenum format, GLenum type ) return comps * sizeof(GLint); case GL_FLOAT: return comps * sizeof(GLfloat); - case GL_HALF_FLOAT_NV: - return comps * sizeof(GLhalfNV); + case GL_HALF_FLOAT_ARB: + return comps * sizeof(GLhalfARB); case GL_UNSIGNED_BYTE_3_3_2: case GL_UNSIGNED_BYTE_2_3_3_REV: if (format == GL_RGB || format == GL_BGR) @@ -333,7 +334,7 @@ GLint _mesa_bytes_per_pixel( GLenum format, GLenum type ) * otherwise. */ GLboolean -_mesa_is_legal_format_and_type( GLenum format, GLenum type ) +_mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type ) { switch (format) { case GL_COLOR_INDEX: @@ -347,8 +348,9 @@ _mesa_is_legal_format_and_type( GLenum format, GLenum type ) case GL_INT: case GL_UNSIGNED_INT: case GL_FLOAT: - case GL_HALF_FLOAT_NV: return GL_TRUE; + case GL_HALF_FLOAT_ARB: + return ctx->Extensions.ARB_half_float_pixel; default: return GL_FALSE; } @@ -368,8 +370,9 @@ _mesa_is_legal_format_and_type( GLenum format, GLenum type ) case GL_INT: case GL_UNSIGNED_INT: case GL_FLOAT: - case GL_HALF_FLOAT_NV: return GL_TRUE; + case GL_HALF_FLOAT_ARB: + return ctx->Extensions.ARB_half_float_pixel; default: return GL_FALSE; } @@ -383,12 +386,13 @@ _mesa_is_legal_format_and_type( GLenum format, GLenum type ) case GL_INT: case GL_UNSIGNED_INT: case GL_FLOAT: - case GL_HALF_FLOAT_NV: case GL_UNSIGNED_BYTE_3_3_2: case GL_UNSIGNED_BYTE_2_3_3_REV: case GL_UNSIGNED_SHORT_5_6_5: case GL_UNSIGNED_SHORT_5_6_5_REV: return GL_TRUE; + case GL_HALF_FLOAT_ARB: + return ctx->Extensions.ARB_half_float_pixel; default: return GL_FALSE; } @@ -403,7 +407,6 @@ _mesa_is_legal_format_and_type( GLenum format, GLenum type ) case GL_INT: case GL_UNSIGNED_INT: case GL_FLOAT: - case GL_HALF_FLOAT_NV: case GL_UNSIGNED_SHORT_4_4_4_4: case GL_UNSIGNED_SHORT_4_4_4_4_REV: case GL_UNSIGNED_SHORT_5_5_5_1: @@ -413,6 +416,8 @@ _mesa_is_legal_format_and_type( GLenum format, GLenum type ) case GL_UNSIGNED_INT_10_10_10_2: case GL_UNSIGNED_INT_2_10_10_10_REV: return GL_TRUE; + case GL_HALF_FLOAT_ARB: + return ctx->Extensions.ARB_half_float_pixel; default: return GL_FALSE; } @@ -1547,9 +1552,9 @@ _mesa_pack_rgba_span_float( GLcontext *ctx, } } break; - case GL_HALF_FLOAT_NV: + case GL_HALF_FLOAT_ARB: { - GLhalfNV *dst = (GLhalfNV *) dstAddr; + GLhalfARB *dst = (GLhalfARB *) dstAddr; switch (dstFormat) { case GL_RED: for (i=0;iSwapBytes) { for (i = 0; i < n; i++) { - GLhalfNV value = s[i]; + GLhalfARB value = s[i]; SWAP2BYTE(value); indexes[i] = (GLuint) _mesa_half_to_float(value); } @@ -2216,7 +2221,7 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4], srcType == GL_SHORT || srcType == GL_UNSIGNED_INT || srcType == GL_INT || - srcType == GL_HALF_FLOAT_NV || + srcType == GL_HALF_FLOAT_ARB || srcType == GL_FLOAT || srcType == GL_UNSIGNED_BYTE_3_3_2 || srcType == GL_UNSIGNED_BYTE_2_3_3_REV || @@ -2395,11 +2400,11 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4], PROCESS(blueIndex, BCOMP, 0.0F, GLfloat, (GLfloat)); PROCESS(alphaIndex, ACOMP, 1.0F, GLfloat, (GLfloat)); break; - case GL_HALF_FLOAT_NV: - PROCESS(redIndex, RCOMP, 0.0F, GLhalfNV, _mesa_half_to_float); - PROCESS(greenIndex, GCOMP, 0.0F, GLhalfNV, _mesa_half_to_float); - PROCESS(blueIndex, BCOMP, 0.0F, GLhalfNV, _mesa_half_to_float); - PROCESS(alphaIndex, ACOMP, 1.0F, GLhalfNV, _mesa_half_to_float); + case GL_HALF_FLOAT_ARB: + PROCESS(redIndex, RCOMP, 0.0F, GLhalfARB, _mesa_half_to_float); + PROCESS(greenIndex, GCOMP, 0.0F, GLhalfARB, _mesa_half_to_float); + PROCESS(blueIndex, BCOMP, 0.0F, GLhalfARB, _mesa_half_to_float); + PROCESS(alphaIndex, ACOMP, 1.0F, GLhalfARB, _mesa_half_to_float); break; case GL_UNSIGNED_BYTE_3_3_2: { @@ -2736,7 +2741,7 @@ _mesa_unpack_color_span_chan( GLcontext *ctx, srcType == GL_SHORT || srcType == GL_UNSIGNED_INT || srcType == GL_INT || - srcType == GL_HALF_FLOAT_NV || + srcType == GL_HALF_FLOAT_ARB || srcType == GL_FLOAT || srcType == GL_UNSIGNED_BYTE_3_3_2 || srcType == GL_UNSIGNED_BYTE_2_3_3_REV || @@ -2752,7 +2757,7 @@ _mesa_unpack_color_span_chan( GLcontext *ctx, srcType == GL_UNSIGNED_INT_2_10_10_10_REV); /* Try simple cases first */ - if (transferOps == 0 ){ + if (transferOps == 0) { if (srcType == CHAN_TYPE) { if (dstFormat == GL_RGBA) { if (srcFormat == GL_RGBA) { @@ -3080,7 +3085,7 @@ _mesa_unpack_color_span_float( GLcontext *ctx, srcType == GL_SHORT || srcType == GL_UNSIGNED_INT || srcType == GL_INT || - srcType == GL_HALF_FLOAT_NV || + srcType == GL_HALF_FLOAT_ARB || srcType == GL_FLOAT || srcType == GL_UNSIGNED_BYTE_3_3_2 || srcType == GL_UNSIGNED_BYTE_2_3_3_REV || @@ -3288,7 +3293,7 @@ _mesa_unpack_index_span( const GLcontext *ctx, GLuint n, srcType == GL_SHORT || srcType == GL_UNSIGNED_INT || srcType == GL_INT || - srcType == GL_HALF_FLOAT_NV || + srcType == GL_HALF_FLOAT_ARB || srcType == GL_FLOAT); ASSERT(dstType == GL_UNSIGNED_BYTE || @@ -3461,9 +3466,9 @@ _mesa_pack_index_span( const GLcontext *ctx, GLuint n, } } break; - case GL_HALF_FLOAT_NV: + case GL_HALF_FLOAT_ARB: { - GLhalfNV *dst = (GLhalfNV *) dest; + GLhalfARB *dst = (GLhalfARB *) dest; GLuint i; for (i = 0; i < n; i++) { dst[i] = _mesa_float_to_half((GLfloat) source[i]); @@ -3507,7 +3512,7 @@ _mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n, srcType == GL_SHORT || srcType == GL_UNSIGNED_INT || srcType == GL_INT || - srcType == GL_HALF_FLOAT_NV || + srcType == GL_HALF_FLOAT_ARB || srcType == GL_FLOAT); ASSERT(dstType == GL_UNSIGNED_BYTE || @@ -3694,9 +3699,9 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n, } } break; - case GL_HALF_FLOAT_NV: + case GL_HALF_FLOAT_ARB: { - GLhalfNV *dst = (GLhalfNV *) dest; + GLhalfARB *dst = (GLhalfARB *) dest; GLuint i; for (i=0;i