From 60905f2b19e13b03b5ae981e36ac434c6a4529ae Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Thu, 10 Sep 2015 14:15:59 +0200 Subject: softpipe: Implement and enable textureQueryLod Passes the shader piglit tests and introduces no regressions. This commit finally makes use of the refactoring in previous commits. v2: - adapted the code to changes in previous commits (renames, need_cube_convert stuff) - splitted too long lines Reviewed-by: Brian Paul --- src/gallium/drivers/softpipe/sp_screen.c | 2 +- src/gallium/drivers/softpipe/sp_tex_sample.c | 55 +++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) (limited to 'src/gallium/drivers') diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index 0bfd9c3578c..7ca8a67e109 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -193,9 +193,9 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS: return 4; case PIPE_CAP_TEXTURE_GATHER_SM5: + case PIPE_CAP_TEXTURE_QUERY_LOD: return 1; case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT: - case PIPE_CAP_TEXTURE_QUERY_LOD: case PIPE_CAP_SAMPLE_SHADING: case PIPE_CAP_TEXTURE_GATHER_OFFSETS: return 0; diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index 4a4cddfd308..9f2ba01b66a 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -3603,6 +3603,59 @@ sp_tgsi_get_samples(struct tgsi_sampler *tgsi_sampler, } } +static void +sp_tgsi_query_lod(struct tgsi_sampler *tgsi_sampler, + const unsigned sview_index, + const unsigned sampler_index, + const float s[TGSI_QUAD_SIZE], + const float t[TGSI_QUAD_SIZE], + const float p[TGSI_QUAD_SIZE], + const float c0[TGSI_QUAD_SIZE], + const enum tgsi_sampler_control control, + float mipmap[TGSI_QUAD_SIZE], + float lod[TGSI_QUAD_SIZE]) +{ + static const float lod_in[TGSI_QUAD_SIZE] = { 0.0, 0.0, 0.0, 0.0 }; + + struct sp_tgsi_sampler *sp_tgsi_samp = + (struct sp_tgsi_sampler *)tgsi_sampler; + struct sp_sampler_view *sp_sview; + struct sp_sampler *sp_samp; + const struct sp_filter_funcs *funcs; + int i; + + assert(sview_index < PIPE_MAX_SHADER_SAMPLER_VIEWS); + assert(sampler_index < PIPE_MAX_SAMPLERS); + assert(sp_tgsi_samp->sp_sampler[sampler_index]); + + sp_sview = &sp_tgsi_samp->sp_sview[sview_index]; + sp_samp = sp_tgsi_samp->sp_sampler[sampler_index]; + /* always have a view here but texture is NULL if no sampler view was + * set. */ + if (!sp_sview->base.texture) { + for (i = 0; i < TGSI_QUAD_SIZE; i++) { + mipmap[i] = 0.0f; + lod[i] = 0.0f; + } + return; + } + + if (sp_sview->need_cube_convert) { + float cs[TGSI_QUAD_SIZE]; + float ct[TGSI_QUAD_SIZE]; + float cp[TGSI_QUAD_SIZE]; + + convert_cube(sp_sview, sp_samp, s, t, p, c0, cs, ct, cp); + compute_lambda_lod_unclamped(sp_sview, sp_samp, + cs, ct, cp, lod_in, control, lod); + } else { + compute_lambda_lod_unclamped(sp_sview, sp_samp, + s, t, p, lod_in, control, lod); + } + + get_filters(sp_sview, sp_samp, control, &funcs, NULL, NULL); + funcs->relative_level(sp_sview, sp_samp, lod, mipmap); +} static void sp_tgsi_get_texel(struct tgsi_sampler *tgsi_sampler, @@ -3639,7 +3692,7 @@ sp_create_tgsi_sampler(void) samp->base.get_dims = sp_tgsi_get_dims; samp->base.get_samples = sp_tgsi_get_samples; samp->base.get_texel = sp_tgsi_get_texel; + samp->base.query_lod = sp_tgsi_query_lod; return samp; } - -- cgit v1.2.3