diff options
author | Krzesimir Nowak <[email protected]> | 2015-09-10 14:15:54 +0200 |
---|---|---|
committer | Brian Paul <[email protected]> | 2015-09-10 09:45:14 -0600 |
commit | b9bc6c42c96773a5784897c55da5387045c0e9b3 (patch) | |
tree | c4c35a806e924f525a0cfc7e122cdceb09d263a0 /src/gallium/drivers | |
parent | 16084cd2cf055849933e19047e604d384da81f8e (diff) |
softpipe: Put mip_filter_func inside a struct
Putting this function pointer into a struct enables grouping of
several related functions in a single place. For now it is just a
single function, but the struct will be later extended with a
mip_level_func for returning relative mip level.
v2:
- renamed sp_mip struct to sp_filter_funcs
- renamed sp_filter_funcs instances from mip_foo to funcs_foo
- splitted too long lines
- sp_sampler now holds a pointer to sp_filter_funcs instead of an
instance of it
- some const fixes
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/softpipe/sp_tex_sample.c | 45 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_tex_sample.h | 5 |
2 files changed, 38 insertions, 12 deletions
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index 30c9cb042ea..8f7cb1a3972 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -2515,6 +2515,29 @@ mip_filter_linear_2d_linear_repeat_POT( } } +static const struct sp_filter_funcs funcs_linear = { + mip_filter_linear +}; + +static const struct sp_filter_funcs funcs_nearest = { + mip_filter_nearest +}; + +static const struct sp_filter_funcs funcs_none = { + mip_filter_none +}; + +static const struct sp_filter_funcs funcs_none_no_filter_select = { + mip_filter_none_no_filter_select +}; + +static const struct sp_filter_funcs funcs_linear_aniso = { + mip_filter_linear_aniso +}; + +static const struct sp_filter_funcs funcs_linear_2d_linear_repeat_POT = { + mip_filter_linear_2d_linear_repeat_POT +}; /** * Do shadow/depth comparisons. @@ -2918,18 +2941,18 @@ sample_mip(struct sp_sampler_view *sp_sview, const struct filter_args *filt_args, float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]) { - mip_filter_func mip_filter; + const struct sp_filter_funcs *funcs = NULL; img_filter_func min_img_filter = NULL; img_filter_func mag_img_filter = NULL; if (filt_args->control == tgsi_sampler_gather) { - mip_filter = mip_filter_nearest; + funcs = &funcs_nearest; min_img_filter = get_img_filter(sp_sview, &sp_samp->base, PIPE_TEX_FILTER_LINEAR, true); } else if (sp_sview->pot2d & sp_samp->min_mag_equal_repeat_linear) { - mip_filter = mip_filter_linear_2d_linear_repeat_POT; + funcs = &funcs_linear_2d_linear_repeat_POT; } else { - mip_filter = sp_samp->mip_filter; + funcs = sp_samp->filter_funcs; min_img_filter = get_img_filter(sp_sview, &sp_samp->base, sp_samp->min_img_filter, false); if (sp_samp->min_mag_equal) { mag_img_filter = min_img_filter; @@ -2939,8 +2962,8 @@ sample_mip(struct sp_sampler_view *sp_sview, } } - mip_filter(sp_sview, sp_samp, min_img_filter, mag_img_filter, - s, t, p, c0, lod, filt_args, rgba); + funcs->filter(sp_sview, sp_samp, min_img_filter, mag_img_filter, + s, t, p, c0, lod, filt_args, rgba); if (sp_samp->base.compare_mode != PIPE_TEX_COMPARE_NONE) { sample_compare(sp_sview, sp_samp, s, t, p, c0, lod, filt_args->control, rgba); @@ -3239,13 +3262,13 @@ softpipe_create_sampler_state(struct pipe_context *pipe, switch (sampler->min_mip_filter) { case PIPE_TEX_MIPFILTER_NONE: if (sampler->min_img_filter == sampler->mag_img_filter) - samp->mip_filter = mip_filter_none_no_filter_select; + samp->filter_funcs = &funcs_none_no_filter_select; else - samp->mip_filter = mip_filter_none; + samp->filter_funcs = &funcs_none; break; case PIPE_TEX_MIPFILTER_NEAREST: - samp->mip_filter = mip_filter_nearest; + samp->filter_funcs = &funcs_nearest; break; case PIPE_TEX_MIPFILTER_LINEAR: @@ -3257,11 +3280,11 @@ softpipe_create_sampler_state(struct pipe_context *pipe, sampler->max_anisotropy <= 1) { samp->min_mag_equal_repeat_linear = TRUE; } - samp->mip_filter = mip_filter_linear; + samp->filter_funcs = &funcs_linear; /* Anisotropic filtering extension. */ if (sampler->max_anisotropy > 1) { - samp->mip_filter = mip_filter_linear_aniso; + samp->filter_funcs = &funcs_linear_aniso; /* Override min_img_filter: * min_img_filter needs to be set to NEAREST since we need to access diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.h b/src/gallium/drivers/softpipe/sp_tex_sample.h index 7d1aafc4473..cee545d545a 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.h +++ b/src/gallium/drivers/softpipe/sp_tex_sample.h @@ -128,6 +128,9 @@ struct sp_sampler_view }; +struct sp_filter_funcs { + mip_filter_func filter; +}; struct sp_sampler { struct pipe_sampler_state base; @@ -144,7 +147,7 @@ struct sp_sampler { wrap_linear_func linear_texcoord_t; wrap_linear_func linear_texcoord_p; - mip_filter_func mip_filter; + const struct sp_filter_funcs *filter_funcs; }; |