[Mesa-dev] [PATCH 11/21] radeon&r200: Add support for ARB_shader_object

Brian Paul brianp at vmware.com
Mon Jun 11 08:41:13 PDT 2012


On 06/11/2012 12:59 AM, Pauli Nieminen wrote:
> Preparation for the mandator support of ARB_shader_object.
>
> I have tested this patch with rv280 only. While only compile testing
> radeon changes.
>
> Signed-off-by: Pauli Nieminen<pauli.nieminen at linux.intel.com>
> ---
>   src/mesa/drivers/dri/r200/r200_tex.c             |   41 ++++++++++++----------
>   src/mesa/drivers/dri/r200/r200_tex.h             |    1 +
>   src/mesa/drivers/dri/r200/r200_texstate.c        |    3 +-
>   src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c |   16 +++++----
>   src/mesa/drivers/dri/radeon/radeon_span.c        |    4 ++-
>   src/mesa/drivers/dri/radeon/radeon_tex.c         |   27 ++++++--------
>   src/mesa/drivers/dri/radeon/radeon_tex.h         |    1 +
>   src/mesa/drivers/dri/radeon/radeon_tex_copy.c    |    2 +-
>   src/mesa/drivers/dri/radeon/radeon_texstate.c    |    4 ++-
>   src/mesa/drivers/dri/radeon/radeon_texture.h     |    4 ++-
>   10 files changed, 57 insertions(+), 46 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/r200/r200_tex.c b/src/mesa/drivers/dri/r200/r200_tex.c
> index fe7c977..f72cad3 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 );
> +}

The whitespace is bit inconsistent in that function.  I'd write all 
the function calls as "foo(a, b)" without extra space before/after the 
parens.


>
>   /**
>    * 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 )
> @@ -379,23 +389,6 @@ static void r200TexParameter( struct gl_context *ctx, GLenum target,
>   	       _mesa_lookup_enum_by_nr( pname ) );
>
>      switch ( pname ) {
> -   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 +482,17 @@ 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 +510,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 756a128..725b45d 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 19e77c5..b25c611 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]) {
> diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
> index ca5dadc..495baec 100644
> --- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
> @@ -249,7 +249,7 @@ void radeon_miptree_unreference(radeon_mipmap_tree **ptr)
>    * @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;
> @@ -260,15 +260,15 @@ static void calculate_min_max_lod(struct gl_texture_object *tObj,
>   	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 */
> @@ -536,17 +536,19 @@ static radeon_mipmap_tree * get_biggest_matching_miptree(radeonTexObj *texObj,
>    * 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",
> diff --git a/src/mesa/drivers/dri/radeon/radeon_span.c b/src/mesa/drivers/dri/radeon/radeon_span.c
> index 1f2ba49..06b1455 100644
> --- a/src/mesa/drivers/dri/radeon/radeon_span.c
> +++ b/src/mesa/drivers/dri/radeon/radeon_span.c
> @@ -43,6 +43,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
>   #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"
>
> @@ -122,7 +123,8 @@ static void radeonSpanRenderStart(struct gl_context * ctx)
>
>   	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);
>   		}
>   	}
> diff --git a/src/mesa/drivers/dri/radeon/radeon_tex.c b/src/mesa/drivers/dri/radeon/radeon_tex.c
> index 71bd464..af29dda 100644
> --- a/src/mesa/drivers/dri/radeon/radeon_tex.c
> +++ b/src/mesa/drivers/dri/radeon/radeon_tex.c
> @@ -312,6 +312,17 @@ static void radeonTexEnv( struct gl_context *ctx, GLenum target,
>      }
>   }
>
> +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
> @@ -328,22 +339,6 @@ static void radeonTexParameter( struct gl_context *ctx, GLenum target,
>   	       _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:
> diff --git a/src/mesa/drivers/dri/radeon/radeon_tex.h b/src/mesa/drivers/dri/radeon/radeon_tex.h
> index 2f0fbe1..fa57c08 100644
> --- a/src/mesa/drivers/dri/radeon/radeon_tex.h
> +++ b/src/mesa/drivers/dri/radeon/radeon_tex.h
> @@ -47,6 +47,7 @@ extern int radeonUploadTexImages( r100ContextPtr rmesa, radeonTexObjPtr t,
>   				  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 );
>
> diff --git a/src/mesa/drivers/dri/radeon/radeon_tex_copy.c b/src/mesa/drivers/dri/radeon/radeon_tex_copy.c
> index 1faf9c8..a6c406b 100644
> --- a/src/mesa/drivers/dri/radeon/radeon_tex_copy.c
> +++ b/src/mesa/drivers/dri/radeon/radeon_tex_copy.c
> @@ -72,7 +72,7 @@ do_copy_texsubimage(struct gl_context *ctx,
>       }
>
>       if (!timg->mt) {
> -        radeon_validate_texture_miptree(ctx,&tobj->base);
> +        radeon_validate_texture_miptree(ctx,&tobj->base.Sampler,&tobj->base);
>       }
>
>       assert(rrb->bo);
> diff --git a/src/mesa/drivers/dri/radeon/radeon_texstate.c b/src/mesa/drivers/dri/radeon/radeon_texstate.c
> index 87f12d5..d2b5b75 100644
> --- a/src/mesa/drivers/dri/radeon/radeon_texstate.c
> +++ b/src/mesa/drivers/dri/radeon/radeon_texstate.c
> @@ -42,6 +42,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
>   #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"
> @@ -1057,7 +1058,7 @@ static GLboolean radeon_validate_texture(struct gl_context *ctx, struct gl_textu
>      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);
> @@ -1076,6 +1077,7 @@ static GLboolean radeon_validate_texture(struct gl_context *ctx, struct gl_textu
>
>      rmesa->recheck_texgen[unit] = GL_TRUE;
>
> +   radeonTexUpdateParameters(ctx, unit);
>      import_tex_obj_state( rmesa, unit, t );
>
>      if (rmesa->recheck_texgen[unit]) {
> diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.h b/src/mesa/drivers/dri/radeon/radeon_texture.h
> index 8f9f5bd..abcce54 100644
> --- a/src/mesa/drivers/dri/radeon/radeon_texture.h
> +++ b/src/mesa/drivers/dri/radeon/radeon_texture.h
> @@ -49,7 +49,9 @@ void radeonFreeTextureImageBuffer(struct gl_context *ctx, struct gl_texture_imag
>
>   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);

Reviewed-by: Brian Paul <brianp at vmware.com>


More information about the mesa-dev mailing list