[Mesa-dev] [PATCH 4/9] softpipe: Put mip_filter_func inside a struct
Krzesimir Nowak
krzesimir at kinvolk.io
Wed Sep 9 03:35:33 PDT 2015
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 mip level.
---
src/gallium/drivers/softpipe/sp_tex_sample.c | 28 +++++++++++++++++-----------
src/gallium/drivers/softpipe/sp_tex_sample.h | 5 ++++-
2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index 38bdc93..cd4a659 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -2515,6 +2515,12 @@ mip_filter_linear_2d_linear_repeat_POT(
}
}
+static struct sp_mip mip_linear = {mip_filter_linear};
+static struct sp_mip mip_nearest = {mip_filter_nearest};
+static struct sp_mip mip_none = {mip_filter_none};
+static struct sp_mip mip_none_no_filter_select = {mip_filter_none_no_filter_select};
+static struct sp_mip mip_linear_aniso = {mip_filter_linear_aniso};
+static struct sp_mip mip_linear_2d_linear_repeat_POT = {mip_filter_linear_2d_linear_repeat_POT};
/**
* Do shadow/depth comparisons.
@@ -2918,18 +2924,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;
+ struct sp_mip *mip = 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;
+ mip = &mip_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;
+ mip = &mip_linear_2d_linear_repeat_POT;
}
else {
- mip_filter = sp_samp->mip_filter;
+ mip = &sp_samp->mip;
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 +2945,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);
+ mip->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 +3245,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->mip = mip_none_no_filter_select;
else
- samp->mip_filter = mip_filter_none;
+ samp->mip = mip_none;
break;
case PIPE_TEX_MIPFILTER_NEAREST:
- samp->mip_filter = mip_filter_nearest;
+ samp->mip = mip_nearest;
break;
case PIPE_TEX_MIPFILTER_LINEAR:
@@ -3257,11 +3263,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->mip = mip_linear;
/* Anisotropic filtering extension. */
if (sampler->max_anisotropy > 1) {
- samp->mip_filter = mip_filter_linear_aniso;
+ samp->mip = mip_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 7d1aafc..78541e1 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_mip {
+ 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;
+ struct sp_mip mip;
};
--
2.4.3
More information about the mesa-dev
mailing list