X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fdrivers%2Fdri%2Fr128%2Fr128_tex.c;h=b5a19b510af49c0923a7d138c60113e45b3fbdba;hb=09788ce10e354b3af6139c04a13b38df18632b13;hp=1fd12456e1b62cab521dab6da9eac8cd655ca24a;hpb=f753320f0fd2be61c0fa99cffb1c3e5107109c4e;p=mesa.git diff --git a/src/mesa/drivers/dri/r128/r128_tex.c b/src/mesa/drivers/dri/r128/r128_tex.c index 1fd12456e1b..b5a19b510af 100644 --- a/src/mesa/drivers/dri/r128/r128_tex.c +++ b/src/mesa/drivers/dri/r128/r128_tex.c @@ -1,4 +1,3 @@ -/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tex.c,v 1.14 2002/11/05 17:46:08 tsi Exp $ */ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., @@ -34,23 +33,18 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "r128_context.h" -#include "r128_state.h" #include "r128_ioctl.h" -#include "r128_vb.h" -#include "r128_tris.h" #include "r128_tex.h" #include "r128_texobj.h" -#include "context.h" -#include "macros.h" -#include "simple_list.h" -#include "enums.h" -#include "texstore.h" -#include "texformat.h" -#include "teximage.h" -#include "imports.h" -#include "colormac.h" -#include "texobj.h" +#include "main/simple_list.h" +#include "main/enums.h" +#include "main/texstore.h" +#include "main/teximage.h" +#include "main/texobj.h" +#include "main/imports.h" +#include "main/texobj.h" +#include "main/macros.h" #include "xmlpool.h" @@ -136,8 +130,13 @@ static void r128SetTexFilter( r128TexObjPtr t, GLenum minf, GLenum magf ) } } -static void r128SetTexBorderColor( r128TexObjPtr t, GLubyte c[4] ) +static void r128SetTexBorderColor( r128TexObjPtr t, const GLfloat color[4] ) { + GLubyte c[4]; + CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]); + CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]); + CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]); + CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]); t->setup.tex_border_color = r128PackColor( 4, c[0], c[1], c[2], c[3] ); } @@ -166,7 +165,7 @@ static r128TexObjPtr r128AllocTexObj( struct gl_texture_object *texObj ) r128SetTexWrap( t, texObj->WrapS, texObj->WrapT ); r128SetTexFilter( t, texObj->MinFilter, texObj->MagFilter ); - r128SetTexBorderColor( t, texObj->_BorderChan ); + r128SetTexBorderColor( t, texObj->BorderColor.f ); } return t; @@ -174,7 +173,7 @@ static r128TexObjPtr r128AllocTexObj( struct gl_texture_object *texObj ) /* Called by the _mesa_store_teximage[123]d() functions. */ -static const struct gl_texture_format * +static gl_format r128ChooseTextureFormat( GLcontext *ctx, GLint internalFormat, GLenum format, GLenum type ) { @@ -199,9 +198,9 @@ r128ChooseTextureFormat( GLcontext *ctx, GLint internalFormat, case GL_RGBA: case GL_COMPRESSED_RGBA: if (do32bpt) - return &_mesa_texformat_argb8888; + return _dri_texformat_argb8888; else - return &_mesa_texformat_argb4444; + return _dri_texformat_argb4444; /* 16-bit formats with alpha */ case GL_INTENSITY4: @@ -209,7 +208,7 @@ r128ChooseTextureFormat( GLcontext *ctx, GLint internalFormat, case GL_LUMINANCE4_ALPHA4: case GL_RGBA2: case GL_RGBA4: - return &_mesa_texformat_argb4444; + return _dri_texformat_argb4444; /* 32-bit formats with alpha */ case GL_INTENSITY8: @@ -229,9 +228,9 @@ r128ChooseTextureFormat( GLcontext *ctx, GLint internalFormat, case GL_RGBA12: case GL_RGBA16: if (!force16bpt) - return &_mesa_texformat_argb8888; + return _dri_texformat_argb8888; else - return &_mesa_texformat_argb4444; + return _dri_texformat_argb4444; /* non-sized formats without alpha */ case 1: @@ -241,16 +240,16 @@ r128ChooseTextureFormat( GLcontext *ctx, GLint internalFormat, case GL_RGB: case GL_COMPRESSED_RGB: if (do32bpt) - return &_mesa_texformat_argb8888; + return _dri_texformat_argb8888; else - return &_mesa_texformat_rgb565; + return _dri_texformat_rgb565; /* 16-bit formats without alpha */ case GL_LUMINANCE4: case GL_R3_G3_B2: case GL_RGB4: case GL_RGB5: - return &_mesa_texformat_rgb565; + return _dri_texformat_rgb565; /* 32-bit formats without alpha */ case GL_LUMINANCE8: @@ -261,9 +260,9 @@ r128ChooseTextureFormat( GLcontext *ctx, GLint internalFormat, case GL_RGB12: case GL_RGB16: if (!force16bpt) - return &_mesa_texformat_argb8888; + return _dri_texformat_argb8888; else - return &_mesa_texformat_rgb565; + return _dri_texformat_rgb565; /* color-indexed formats */ case GL_COLOR_INDEX: @@ -273,18 +272,18 @@ r128ChooseTextureFormat( GLcontext *ctx, GLint internalFormat, case GL_COLOR_INDEX8_EXT: case GL_COLOR_INDEX12_EXT: case GL_COLOR_INDEX16_EXT: - return &_mesa_texformat_ci8; + return _dri_texformat_ci8; case GL_YCBCR_MESA: if (type == GL_UNSIGNED_SHORT_8_8_APPLE || type == GL_UNSIGNED_BYTE) - return &_mesa_texformat_ycbcr; + return MESA_FORMAT_YCBCR; else - return &_mesa_texformat_ycbcr_rev; + return MESA_FORMAT_YCBCR_REV; default: _mesa_problem( ctx, "unexpected format in %s", __FUNCTION__ ); - return NULL; + return MESA_FORMAT_NONE; } } @@ -462,15 +461,15 @@ static void r128TexEnv( GLcontext *ctx, GLenum target, case GL_TEXTURE_LOD_BIAS: { - CARD32 t = rmesa->setup.tex_cntl_c; + uint32_t t = rmesa->setup.tex_cntl_c; GLint bias; - CARD32 b; + uint32_t b; /* GTH: This isn't exactly correct, but gives good results up to a * certain point. It is better than completely ignoring the LOD * bias. Unfortunately there isn't much range in the bias, the * spec mentions strides that vary between 0.5 and 2.0 but these - * numbers don't seem to relate the the GL LOD bias value at all. + * numbers don't seem to relate to the GL LOD bias value at all. */ if ( param[0] >= 1.0 ) { bias = -128; @@ -484,7 +483,7 @@ static void r128TexEnv( GLcontext *ctx, GLenum target, bias = 127; } - b = (CARD32)bias & 0xff; + b = (uint32_t)bias & 0xff; t &= ~R128_LOD_BIAS_MASK; t |= (b << R128_LOD_BIAS_SHIFT); @@ -532,7 +531,7 @@ static void r128TexParameter( GLcontext *ctx, GLenum target, case GL_TEXTURE_BORDER_COLOR: if ( t->base.bound ) FLUSH_BATCH( rmesa ); - r128SetTexBorderColor( t, tObj->_BorderChan ); + r128SetTexBorderColor( t, tObj->BorderColor.f ); break; case GL_TEXTURE_BASE_LEVEL: @@ -611,5 +610,7 @@ void r128InitTextureFuncs( struct dd_function_table *functions ) functions->NewTextureObject = r128NewTextureObject; functions->DeleteTexture = r128DeleteTexture; functions->IsTextureResident = driIsTextureResident; + + driInitTextureFormats(); }