diff options
author | Pauli Nieminen <[email protected]> | 2012-06-12 21:38:52 +0300 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2012-08-01 15:31:16 -0700 |
commit | 6f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88ed (patch) | |
tree | c58ab2a0d102202d55daf280c09141bb74198f6c /src/mesa/drivers/dri/radeon | |
parent | 10169e7adc40b445776453fcc6d3227d7dda5879 (diff) |
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 <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/radeon')
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c | 16 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_span.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_tex.c | 38 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_tex.h | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_tex_copy.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_texstate.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_texture.h | 4 |
7 files changed, 42 insertions, 27 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c index 413ad83ade1..0ef6457f513 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 92f3d332a4b..0617adc5bc5 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" @@ -124,7 +125,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 71bd464266f..fcd9a76a998 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: @@ -433,6 +428,16 @@ radeonNewTextureObject( struct gl_context *ctx, GLuint name, GLenum target ) } +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 ) { @@ -445,4 +450,5 @@ void radeonInitTextureFuncs( radeonContextPtr radeon, struct dd_function_table * functions->TexEnv = radeonTexEnv; functions->TexParameter = radeonTexParameter; functions->TexGen = radeonTexGen; + functions->NewSamplerObject = radeonNewSamplerObject; } diff --git a/src/mesa/drivers/dri/radeon/radeon_tex.h b/src/mesa/drivers/dri/radeon/radeon_tex.h index 2f0fbe1d73e..fa57c08987d 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 1faf9c81db9..a6c406b2bff 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 87f12d5179c..d2b5b755d6e 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 8f9f5bd128e..abcce54806d 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); |