#include "main/context.h"
#include "main/enums.h"
#include "main/image.h"
-#include "main/simple_list.h"
-#include "main/texstore.h"
+#include "util/simple_list.h"
#include "main/teximage.h"
#include "main/texobj.h"
#include "radeon_context.h"
#include "radeon_mipmap_tree.h"
-#include "radeon_state.h"
#include "radeon_ioctl.h"
-#include "radeon_swtcl.h"
#include "radeon_tex.h"
#include "xmlpool.h"
is_clamp_to_border = GL_TRUE;
break;
default:
- _mesa_problem(NULL, "bad S wrap mode in %s", __FUNCTION__);
+ _mesa_problem(NULL, "bad S wrap mode in %s", __func__);
}
- switch ( twrap ) {
- case GL_REPEAT:
- t->pp_txfilter |= RADEON_CLAMP_T_WRAP;
- break;
- case GL_CLAMP:
- t->pp_txfilter |= RADEON_CLAMP_T_CLAMP_GL;
- is_clamp = GL_TRUE;
- break;
- case GL_CLAMP_TO_EDGE:
- t->pp_txfilter |= RADEON_CLAMP_T_CLAMP_LAST;
- break;
- case GL_CLAMP_TO_BORDER:
- t->pp_txfilter |= RADEON_CLAMP_T_CLAMP_GL;
- is_clamp_to_border = GL_TRUE;
- break;
- case GL_MIRRORED_REPEAT:
- t->pp_txfilter |= RADEON_CLAMP_T_MIRROR;
- break;
- case GL_MIRROR_CLAMP_EXT:
- t->pp_txfilter |= RADEON_CLAMP_T_MIRROR_CLAMP_GL;
- is_clamp = GL_TRUE;
- break;
- case GL_MIRROR_CLAMP_TO_EDGE_EXT:
- t->pp_txfilter |= RADEON_CLAMP_T_MIRROR_CLAMP_LAST;
- break;
- case GL_MIRROR_CLAMP_TO_BORDER_EXT:
- t->pp_txfilter |= RADEON_CLAMP_T_MIRROR_CLAMP_GL;
- is_clamp_to_border = GL_TRUE;
- break;
- default:
- _mesa_problem(NULL, "bad T wrap mode in %s", __FUNCTION__);
+ if (t->base.Target != GL_TEXTURE_1D) {
+ switch ( twrap ) {
+ case GL_REPEAT:
+ t->pp_txfilter |= RADEON_CLAMP_T_WRAP;
+ break;
+ case GL_CLAMP:
+ t->pp_txfilter |= RADEON_CLAMP_T_CLAMP_GL;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_CLAMP_TO_EDGE:
+ t->pp_txfilter |= RADEON_CLAMP_T_CLAMP_LAST;
+ break;
+ case GL_CLAMP_TO_BORDER:
+ t->pp_txfilter |= RADEON_CLAMP_T_CLAMP_GL;
+ is_clamp_to_border = GL_TRUE;
+ break;
+ case GL_MIRRORED_REPEAT:
+ t->pp_txfilter |= RADEON_CLAMP_T_MIRROR;
+ break;
+ case GL_MIRROR_CLAMP_EXT:
+ t->pp_txfilter |= RADEON_CLAMP_T_MIRROR_CLAMP_GL;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_MIRROR_CLAMP_TO_EDGE_EXT:
+ t->pp_txfilter |= RADEON_CLAMP_T_MIRROR_CLAMP_LAST;
+ break;
+ case GL_MIRROR_CLAMP_TO_BORDER_EXT:
+ t->pp_txfilter |= RADEON_CLAMP_T_MIRROR_CLAMP_GL;
+ is_clamp_to_border = GL_TRUE;
+ break;
+ default:
+ _mesa_problem(NULL, "bad T wrap mode in %s", __func__);
+ }
}
if ( is_clamp_to_border ) {
#define SCALED_FLOAT_TO_BYTE( x, scale ) \
(((GLuint)((255.0F / scale) * (x))) / 2)
-static void radeonTexEnv( GLcontext *ctx, GLenum target,
+static void radeonTexEnv( struct gl_context *ctx, GLenum target,
GLenum pname, const GLfloat *param )
{
r100ContextPtr rmesa = R100_CONTEXT(ctx);
if ( RADEON_DEBUG & RADEON_STATE ) {
fprintf( stderr, "%s( %s )\n",
- __FUNCTION__, _mesa_lookup_enum_by_nr( pname ) );
+ __func__, _mesa_enum_to_string( pname ) );
}
switch ( pname ) {
case GL_TEXTURE_ENV_COLOR: {
GLubyte c[4];
GLuint envColor;
- UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit->EnvColor );
+ _mesa_unclamped_float_rgba_to_ubyte(c, texUnit->EnvColor);
envColor = radeonPackColor( 4, c[0], c[1], c[2], c[3] );
if ( rmesa->hw.tex[unit].cmd[TEX_PP_TFACTOR] != envColor ) {
RADEON_STATECHANGE( rmesa, tex[unit] );
}
}
+void radeonTexUpdateParameters(struct gl_context *ctx, GLuint unit)
+{
+ struct gl_sampler_object *samp = _mesa_get_samplerobj(ctx, unit);
+ radeonTexObj* t = radeon_tex_obj(ctx->Texture.Unit[unit]._Current);
+
+ radeonSetTexMaxAnisotropy(t , samp->MaxAnisotropy);
+ radeonSetTexFilter(t, samp->MinFilter, samp->MagFilter);
+ radeonSetTexWrap(t, samp->WrapS, samp->WrapT);
+ radeonSetTexBorderColor(t, samp->BorderColor.f);
+}
+
/**
* Changes variables and flags for a state update, which will happen at the
* next UpdateTextureState
*/
-static void radeonTexParameter( GLcontext *ctx, GLenum target,
+static void radeonTexParameter( struct gl_context *ctx,
struct gl_texture_object *texObj,
GLenum pname, const GLfloat *params )
{
radeonTexObj* t = radeon_tex_obj(texObj);
- radeon_print(RADEON_TEXTURE, RADEON_VERBOSE, "%s( %s )\n", __FUNCTION__,
- _mesa_lookup_enum_by_nr( pname ) );
+ radeon_print(RADEON_TEXTURE, RADEON_VERBOSE, "%s( %s )\n", __func__,
+ _mesa_enum_to_string( pname ) );
switch ( pname ) {
- case GL_TEXTURE_MIN_FILTER:
- case GL_TEXTURE_MAG_FILTER:
- case GL_TEXTURE_MAX_ANISOTROPY_EXT:
- radeonSetTexMaxAnisotropy( t, texObj->MaxAnisotropy );
- radeonSetTexFilter( t, texObj->MinFilter, texObj->MagFilter );
- break;
-
- case GL_TEXTURE_WRAP_S:
- case GL_TEXTURE_WRAP_T:
- radeonSetTexWrap( t, texObj->WrapS, texObj->WrapT );
- break;
-
- case GL_TEXTURE_BORDER_COLOR:
- radeonSetTexBorderColor( t, texObj->BorderColor );
- break;
-
case GL_TEXTURE_BASE_LEVEL:
case GL_TEXTURE_MAX_LEVEL:
case GL_TEXTURE_MIN_LOD:
case GL_TEXTURE_MAX_LOD:
-
- /* This isn't the most efficient solution but there doesn't appear to
- * be a nice alternative. Since there's no LOD clamping,
- * we just have to rely on loading the right subset of mipmap levels
- * to simulate a clamped LOD.
- */
- if (t->mt) {
- radeon_miptree_unreference(t->mt);
- t->mt = 0;
- t->validated = GL_FALSE;
- }
+ t->validated = GL_FALSE;
break;
default:
}
}
-static void radeonDeleteTexture( GLcontext *ctx,
+static void radeonDeleteTexture( struct gl_context *ctx,
struct gl_texture_object *texObj )
{
r100ContextPtr rmesa = R100_CONTEXT(ctx);
int i;
radeon_print(RADEON_TEXTURE, RADEON_NORMAL,
- "%s( %p (target = %s) )\n", __FUNCTION__, (void *)texObj,
- _mesa_lookup_enum_by_nr( texObj->Target ) );
+ "%s( %p (target = %s) )\n", __func__, (void *)texObj,
+ _mesa_enum_to_string( texObj->Target ) );
if ( rmesa ) {
radeon_firevertices(&rmesa->radeon);
- for ( i = 0 ; i < rmesa->radeon.glCtx->Const.MaxTextureUnits ; i++ ) {
+ for ( i = 0 ; i < rmesa->radeon.glCtx.Const.MaxTextureUnits ; i++ ) {
if ( t == rmesa->state.texture.unit[i].texobj ) {
rmesa->state.texture.unit[i].texobj = NULL;
rmesa->hw.tex[i].dirty = GL_FALSE;
}
}
- if (t->mt) {
- radeon_miptree_unreference(t->mt);
- t->mt = 0;
- }
+ radeon_miptree_unreference(&t->mt);
+
/* Free mipmap images and the texture object itself */
_mesa_delete_texture_object(ctx, texObj);
}
* Basically impossible to do this on the fly - just collect some
* basic info & do the checks from ValidateState().
*/
-static void radeonTexGen( GLcontext *ctx,
+static void radeonTexGen( struct gl_context *ctx,
GLenum coord,
GLenum pname,
const GLfloat *params )
* texture object from the core mesa gl_texture_object. Not done at this time.
*/
static struct gl_texture_object *
-radeonNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+radeonNewTextureObject( struct gl_context *ctx, GLuint name, GLenum target )
{
r100ContextPtr rmesa = R100_CONTEXT(ctx);
radeonTexObj* t = CALLOC_STRUCT(radeon_tex_obj);
- _mesa_initialize_texture_object(&t->base, name, target);
- t->base.MaxAnisotropy = rmesa->radeon.initialMaxAnisotropy;
+ _mesa_initialize_texture_object(ctx, &t->base, name, target);
+ t->base.Sampler.MaxAnisotropy = rmesa->radeon.initialMaxAnisotropy;
t->border_fallback = GL_FALSE;
t->pp_txformat = (RADEON_TXFORMAT_ENDIAN_NO_SWAP |
RADEON_TXFORMAT_PERSPECTIVE_ENABLE);
- radeonSetTexWrap( t, t->base.WrapS, t->base.WrapT );
- radeonSetTexMaxAnisotropy( t, t->base.MaxAnisotropy );
- radeonSetTexFilter( t, t->base.MinFilter, t->base.MagFilter );
- radeonSetTexBorderColor( t, t->base.BorderColor );
+ radeonSetTexWrap( t, t->base.Sampler.WrapS, t->base.Sampler.WrapT );
+ radeonSetTexMaxAnisotropy( t, t->base.Sampler.MaxAnisotropy );
+ radeonSetTexFilter( t, t->base.Sampler.MinFilter, t->base.Sampler.MagFilter );
+ radeonSetTexBorderColor( t, t->base.Sampler.BorderColor.f );
return &t->base;
}
+static struct gl_sampler_object *
+radeonNewSamplerObject(struct gl_context *ctx, GLuint name)
+{
+ r100ContextPtr rmesa = R100_CONTEXT(ctx);
+ struct gl_sampler_object *samp = _mesa_new_sampler_object(ctx, name);
+ if (samp)
+ samp->MaxAnisotropy = rmesa->radeon.initialMaxAnisotropy;
+ return samp;
+}
+
-void radeonInitTextureFuncs( struct dd_function_table *functions )
+void radeonInitTextureFuncs( radeonContextPtr radeon, struct dd_function_table *functions )
{
- functions->ChooseTextureFormat = radeonChooseTextureFormat_mesa;
- functions->TexImage1D = radeonTexImage1D;
- functions->TexImage2D = radeonTexImage2D;
- functions->TexSubImage1D = radeonTexSubImage1D;
- functions->TexSubImage2D = radeonTexSubImage2D;
- functions->GetTexImage = radeonGetTexImage;
- functions->GetCompressedTexImage = radeonGetCompressedTexImage;
+ radeon_init_common_texture_funcs(radeon, functions);
functions->NewTextureObject = radeonNewTextureObject;
// functions->BindTexture = radeonBindTexture;
functions->TexEnv = radeonTexEnv;
functions->TexParameter = radeonTexParameter;
functions->TexGen = radeonTexGen;
-
- functions->CompressedTexImage2D = radeonCompressedTexImage2D;
- functions->CompressedTexSubImage2D = radeonCompressedTexSubImage2D;
-
- functions->GenerateMipmap = radeonGenerateMipmap;
-
- functions->NewTextureImage = radeonNewTextureImage;
- functions->FreeTexImageData = radeonFreeTexImageData;
- functions->MapTexture = radeonMapTexture;
- functions->UnmapTexture = radeonUnmapTexture;
-
- driInitTextureFormats();
+ functions->NewSamplerObject = radeonNewSamplerObject;
}