From 08c9534107fcaf06f9b801551524ed5dc724db13 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 16 Feb 2008 10:05:01 -0700 Subject: gallium: implement min vs. mag filter determination for non-mipmapped textures Fixes tests/minmag.c --- src/gallium/drivers/softpipe/sp_tex_sample.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/gallium/drivers') diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index 2f82fd6abe..c0128f81d7 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -476,6 +476,19 @@ choose_mipmap_levels(struct tgsi_sampler *sampler, /* no mipmap selection needed */ *imgFilter = sampler->state->mag_img_filter; *level0 = *level1 = (int) sampler->state->min_lod; + + if (sampler->state->min_img_filter != sampler->state->mag_img_filter) { + /* non-mipmapped texture, but still need to determine if doing + * minification or magnification. + */ + float lambda = compute_lambda(sampler, s, t, p, lodbias); + if (lambda < 0.5) { /* XXX this may need tweaking... */ + *imgFilter = sampler->state->mag_img_filter; + } + else { + *imgFilter = sampler->state->min_img_filter; + } + } } else { float lambda; -- cgit v1.2.3 From 3b2a291888d8e62787de03f8529806fb562bd186 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 16 Feb 2008 13:50:31 -0700 Subject: gallium: tweak texture filter min/mag thresholds --- src/gallium/drivers/softpipe/sp_tex_sample.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/gallium/drivers') diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index c0128f81d7..a15bd43166 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -474,7 +474,6 @@ choose_mipmap_levels(struct tgsi_sampler *sampler, { if (sampler->state->min_mip_filter == PIPE_TEX_MIPFILTER_NONE) { /* no mipmap selection needed */ - *imgFilter = sampler->state->mag_img_filter; *level0 = *level1 = (int) sampler->state->min_lod; if (sampler->state->min_img_filter != sampler->state->mag_img_filter) { @@ -482,13 +481,16 @@ choose_mipmap_levels(struct tgsi_sampler *sampler, * minification or magnification. */ float lambda = compute_lambda(sampler, s, t, p, lodbias); - if (lambda < 0.5) { /* XXX this may need tweaking... */ + if (lambda <= 0.0) { *imgFilter = sampler->state->mag_img_filter; } else { *imgFilter = sampler->state->min_img_filter; } } + else { + *imgFilter = sampler->state->mag_img_filter; + } } else { float lambda; @@ -500,7 +502,7 @@ choose_mipmap_levels(struct tgsi_sampler *sampler, /* vertex shader */ lambda = lodbias; /* not really a bias, but absolute LOD */ - if (lambda < 0.0) { /* XXX threshold depends on the filter */ + if (lambda <= 0.0) { /* XXX threshold depends on the filter */ /* magnifying */ *imgFilter = sampler->state->mag_img_filter; *level0 = *level1 = 0; -- cgit v1.2.3 From 0c6bbd41bd6dc1041eaca7c907d3768d107c1afa Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 16 Feb 2008 13:55:47 -0700 Subject: gallium: add missing mip level clamp --- src/gallium/drivers/softpipe/sp_tex_sample.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gallium/drivers') diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index a15bd43166..c54e9d385c 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -474,7 +474,8 @@ choose_mipmap_levels(struct tgsi_sampler *sampler, { if (sampler->state->min_mip_filter == PIPE_TEX_MIPFILTER_NONE) { /* no mipmap selection needed */ - *level0 = *level1 = (int) sampler->state->min_lod; + *level0 = *level1 = CLAMP((int) sampler->state->min_lod, + 0, (int) sampler->texture->last_level); if (sampler->state->min_img_filter != sampler->state->mag_img_filter) { /* non-mipmapped texture, but still need to determine if doing -- cgit v1.2.3