From 6f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88ed Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Tue, 12 Jun 2012 21:38:52 +0300 Subject: radeon&r200: Add support for ARB_sampler_objects Preparation for the mandatory support of ARB_sampler_objects. I have tested this patch with rv280 only. Signed-off-by: Pauli Nieminen Reviewed-by: Brian Paul --- src/mesa/drivers/dri/r200/r200_tex.c | 33 ++++++++++++++++++++----------- src/mesa/drivers/dri/r200/r200_tex.h | 1 + src/mesa/drivers/dri/r200/r200_texstate.c | 3 ++- 3 files changed, 25 insertions(+), 12 deletions(-) (limited to 'src/mesa/drivers/dri/r200') diff --git a/src/mesa/drivers/dri/r200/r200_tex.c b/src/mesa/drivers/dri/r200/r200_tex.c index fe7c977ac4e..9d52095e247 100644 --- a/src/mesa/drivers/dri/r200/r200_tex.c +++ b/src/mesa/drivers/dri/r200/r200_tex.c @@ -41,6 +41,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #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" @@ -360,12 +361,21 @@ static void r200TexEnv( struct gl_context *ctx, GLenum target, } } +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 ) @@ -382,20 +392,10 @@ static void r200TexParameter( struct gl_context *ctx, GLenum target, 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: @@ -489,6 +489,16 @@ static struct gl_texture_object *r200NewTextureObject(struct gl_context * ctx, 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 ) @@ -506,4 +516,5 @@ void r200InitTextureFuncs( radeonContextPtr radeon, struct dd_function_table *fu functions->TexEnv = r200TexEnv; functions->TexParameter = r200TexParameter; functions->TexGen = r200TexGen; + functions->NewSamplerObject = r200NewSamplerObject; } diff --git a/src/mesa/drivers/dri/r200/r200_tex.h b/src/mesa/drivers/dri/r200/r200_tex.h index 756a128a196..725b45d04ab 100644 --- a/src/mesa/drivers/dri/r200/r200_tex.h +++ b/src/mesa/drivers/dri/r200/r200_tex.h @@ -48,6 +48,7 @@ extern void r200DestroyTexObj( r200ContextPtr rmesa, radeonTexObjPtr t ); 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 ); diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c b/src/mesa/drivers/dri/r200/r200_texstate.c index 19e77c57fc3..b25c6113960 100644 --- a/src/mesa/drivers/dri/r200/r200_texstate.c +++ b/src/mesa/drivers/dri/r200/r200_texstate.c @@ -1500,7 +1500,7 @@ static GLboolean r200_validate_texture(struct gl_context *ctx, struct gl_texture 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); @@ -1522,6 +1522,7 @@ static GLboolean r200_validate_texture(struct gl_context *ctx, struct gl_texture 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]) { -- cgit v1.2.3