#include "main/simple_list.h"
#include "main/teximage.h"
#include "main/texobj.h"
+#include "main/samplerobj.h"
#include "radeon_mipmap_tree.h"
#include "r200_context.h"
}
}
+void r200TexUpdateParameters(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);
+
+ r200SetTexMaxAnisotropy(t , samp->MaxAnisotropy);
+ r200SetTexFilter(t, samp->MinFilter, samp->MagFilter);
+ r200SetTexWrap(t, samp->WrapS, samp->WrapT, samp->WrapR);
+ r200SetTexBorderColor(t, samp->BorderColor.f);
+}
/**
* Changes variables and flags for a state update, which will happen at the
* next UpdateTextureState
*/
-
static void r200TexParameter( struct gl_context *ctx, GLenum target,
struct gl_texture_object *texObj,
GLenum pname, const GLfloat *params )
case GL_TEXTURE_MIN_FILTER:
case GL_TEXTURE_MAG_FILTER:
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
- r200SetTexMaxAnisotropy( t, texObj->Sampler.MaxAnisotropy );
- r200SetTexFilter( t, texObj->Sampler.MinFilter, texObj->Sampler.MagFilter );
- break;
-
case GL_TEXTURE_WRAP_S:
case GL_TEXTURE_WRAP_T:
case GL_TEXTURE_WRAP_R:
- r200SetTexWrap( t, texObj->Sampler.WrapS, texObj->Sampler.WrapT, texObj->Sampler.WrapR );
- break;
-
case GL_TEXTURE_BORDER_COLOR:
- r200SetTexBorderColor( t, texObj->Sampler.BorderColor.f );
- break;
-
case GL_TEXTURE_BASE_LEVEL:
case GL_TEXTURE_MAX_LEVEL:
case GL_TEXTURE_MIN_LOD:
return &t->base;
}
+static struct gl_sampler_object *
+r200NewSamplerObject(struct gl_context *ctx, GLuint name)
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ struct gl_sampler_object *samp = _mesa_new_sampler_object(ctx, name);
+ if (samp)
+ samp->MaxAnisotropy = rmesa->radeon.initialMaxAnisotropy;
+ return samp;
+}
+
void r200InitTextureFuncs( radeonContextPtr radeon, struct dd_function_table *functions )
functions->TexEnv = r200TexEnv;
functions->TexParameter = r200TexParameter;
functions->TexGen = r200TexGen;
+ functions->NewSamplerObject = r200NewSamplerObject;
}
extern void r200InitTextureFuncs( radeonContextPtr radeon, struct dd_function_table *functions );
extern void r200UpdateFragmentShader( struct gl_context *ctx );
+extern void r200TexUpdateParameters(struct gl_context *ctx, GLuint unit);
extern void set_re_cntl_d3d( struct gl_context *ctx, int unit, GLboolean use_d3d );
r200ContextPtr rmesa = R200_CONTEXT(ctx);
radeonTexObj *t = radeon_tex_obj(texObj);
- if (!radeon_validate_texture_miptree(ctx, texObj))
+ if (!radeon_validate_texture_miptree(ctx, _mesa_get_samplerobj(ctx, unit), texObj))
return GL_FALSE;
r200_validate_texgen(ctx, unit);
rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_1] |= 4 << (unit * 3);
rmesa->recheck_texgen[unit] = GL_TRUE;
+ r200TexUpdateParameters(ctx, unit);
import_tex_obj_state( rmesa, unit, t );
if (rmesa->recheck_texgen[unit]) {
* @param[out] pminLod minimal LOD
* @param[out] pmaxLod maximal LOD
*/
-static void calculate_min_max_lod(struct gl_texture_object *tObj,
+static void calculate_min_max_lod(struct gl_sampler_object *samp, struct gl_texture_object *tObj,
unsigned *pminLod, unsigned *pmaxLod)
{
int minLod, maxLod;
case GL_TEXTURE_2D:
case GL_TEXTURE_3D:
case GL_TEXTURE_CUBE_MAP:
- if (tObj->Sampler.MinFilter == GL_NEAREST || tObj->Sampler.MinFilter == GL_LINEAR) {
+ if (samp->MinFilter == GL_NEAREST || samp->MinFilter == GL_LINEAR) {
/* GL_NEAREST and GL_LINEAR only care about GL_TEXTURE_BASE_LEVEL.
*/
minLod = maxLod = tObj->BaseLevel;
} else {
- minLod = tObj->BaseLevel + (GLint)(tObj->Sampler.MinLod);
+ minLod = tObj->BaseLevel + (GLint)(samp->MinLod);
minLod = MAX2(minLod, tObj->BaseLevel);
minLod = MIN2(minLod, tObj->MaxLevel);
- maxLod = tObj->BaseLevel + (GLint)(tObj->Sampler.MaxLod + 0.5);
+ maxLod = tObj->BaseLevel + (GLint)(samp->MaxLod + 0.5);
maxLod = MIN2(maxLod, tObj->MaxLevel);
maxLod = MIN2(maxLod, tObj->Image[0][minLod]->MaxLog2 + minLod);
maxLod = MAX2(maxLod, minLod); /* need at least one level */
* If individual images are stored in different mipmap trees
* use the mipmap tree that has the most of the correct data.
*/
-int radeon_validate_texture_miptree(struct gl_context * ctx, struct gl_texture_object *texObj)
+int radeon_validate_texture_miptree(struct gl_context * ctx,
+ struct gl_sampler_object *samp,
+ struct gl_texture_object *texObj)
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
radeonTexObj *t = radeon_tex_obj(texObj);
radeon_mipmap_tree *dst_miptree;
- if (t->validated || t->image_override) {
+ if (samp == &texObj->Sampler && (t->validated || t->image_override)) {
return GL_TRUE;
}
- calculate_min_max_lod(&t->base, &t->minLod, &t->maxLod);
+ calculate_min_max_lod(samp, &t->base, &t->minLod, &t->maxLod);
radeon_print(RADEON_TEXTURE, RADEON_NORMAL,
"%s: Validating texture %p now, minLod = %d, maxLod = %d\n",
#include "main/glheader.h"
#include "main/texformat.h"
#include "main/renderbuffer.h"
+#include "main/samplerobj.h"
#include "swrast/swrast.h"
#include "swrast/s_renderbuffer.h"
for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
if (ctx->Texture.Unit[i]._ReallyEnabled) {
- radeon_validate_texture_miptree(ctx, ctx->Texture.Unit[i]._Current);
+ radeon_validate_texture_miptree(ctx, _mesa_get_samplerobj(ctx, i),
+ ctx->Texture.Unit[i]._Current);
radeon_swrast_map_texture_images(ctx, ctx->Texture.Unit[i]._Current);
}
}
}
}
+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
_mesa_lookup_enum_by_nr( pname ) );
switch ( pname ) {
- case GL_TEXTURE_MIN_FILTER:
- case GL_TEXTURE_MAG_FILTER:
- case GL_TEXTURE_MAX_ANISOTROPY_EXT:
- radeonSetTexMaxAnisotropy( t, texObj->Sampler.MaxAnisotropy );
- radeonSetTexFilter( t, texObj->Sampler.MinFilter, texObj->Sampler.MagFilter );
- break;
-
- case GL_TEXTURE_WRAP_S:
- case GL_TEXTURE_WRAP_T:
- radeonSetTexWrap( t, texObj->Sampler.WrapS, texObj->Sampler.WrapT );
- break;
-
- case GL_TEXTURE_BORDER_COLOR:
- radeonSetTexBorderColor( t, texObj->Sampler.BorderColor.f );
- break;
-
case GL_TEXTURE_BASE_LEVEL:
case GL_TEXTURE_MAX_LEVEL:
case GL_TEXTURE_MIN_LOD:
}
+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( radeonContextPtr radeon, struct dd_function_table *functions )
{
functions->TexEnv = radeonTexEnv;
functions->TexParameter = radeonTexParameter;
functions->TexGen = radeonTexGen;
+ functions->NewSamplerObject = radeonNewSamplerObject;
}
GLuint face );
extern void radeonDestroyTexObj( r100ContextPtr rmesa, radeonTexObjPtr t );
+extern void radeonTexUpdateParameters(struct gl_context *ctx, GLuint unit);
extern void radeonInitTextureFuncs( radeonContextPtr radeon, struct dd_function_table *functions );
}
if (!timg->mt) {
- radeon_validate_texture_miptree(ctx, &tobj->base);
+ radeon_validate_texture_miptree(ctx, &tobj->base.Sampler, &tobj->base);
}
assert(rrb->bo);
#include "main/texstate.h"
#include "main/texobj.h"
#include "main/enums.h"
+#include "main/samplerobj.h"
#include "radeon_context.h"
#include "radeon_mipmap_tree.h"
radeonTexObj *t = radeon_tex_obj(texObj);
int ret;
- if (!radeon_validate_texture_miptree(ctx, texObj))
+ if (!radeon_validate_texture_miptree(ctx, _mesa_get_samplerobj(ctx, unit), texObj))
return GL_FALSE;
ret = setup_hardware_state(rmesa, t, unit);
rmesa->recheck_texgen[unit] = GL_TRUE;
+ radeonTexUpdateParameters(ctx, unit);
import_tex_obj_state( rmesa, unit, t );
if (rmesa->recheck_texgen[unit]) {
void radeon_teximage_map(radeon_texture_image *image, GLboolean write_enable);
void radeon_teximage_unmap(radeon_texture_image *image);
-int radeon_validate_texture_miptree(struct gl_context * ctx, struct gl_texture_object *texObj);
+int radeon_validate_texture_miptree(struct gl_context * ctx,
+ struct gl_sampler_object *samp,
+ struct gl_texture_object *texObj);
void radeon_swrast_map_texture_images(struct gl_context *ctx, struct gl_texture_object *texObj);