diff options
author | Roland Scheidegger <[email protected]> | 2013-09-13 19:52:09 +0200 |
---|---|---|
committer | Roland Scheidegger <[email protected]> | 2013-09-18 00:00:37 +0200 |
commit | 93b5f7117962ce6f30f4970eb7177b6755f90181 (patch) | |
tree | 821a64003b01797e80315c5c4c5edd7be5140dad /src/gallium | |
parent | b8244b00569828f62137693f251297bc83dee67c (diff) |
gallivm: some bits of seamless cube filtering implementation
Simply adjust wrap mode to clamp_to_edge. This is all that's needed for a
correct implementation for nearest filtering, and it's way better than
using repeat wrap for instance for linear filtering (though obviously this
doesn't actually do seamless filtering).
v2: fix s/t wrap not r/s...
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_sample.c | 1 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_sample.h | 1 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 41 |
3 files changed, 29 insertions, 14 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c index 9b0a92c9cb9..c7753829f3f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c @@ -155,6 +155,7 @@ lp_sampler_static_sampler_state(struct lp_static_sampler_state *state, state->wrap_r = sampler->wrap_r; state->min_img_filter = sampler->min_img_filter; state->mag_img_filter = sampler->mag_img_filter; + state->seamless_cube_map = sampler->seamless_cube_map; if (sampler->max_lod > 0.0f) { state->min_mip_filter = sampler->min_mip_filter; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index e6b9f30d7bb..803a99e3b0c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -114,6 +114,7 @@ struct lp_static_sampler_state unsigned lod_bias_non_zero:1; unsigned apply_min_lod:1; /**< min_lod > 0 ? */ unsigned apply_max_lod:1; /**< max_lod < last_level ? */ + unsigned seamless_cube_map:1; /* Hacks */ unsigned force_nearest_s:1; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 7e98919204d..355e97d76a6 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -2123,8 +2123,21 @@ lp_build_sample_soa(struct gallivm_state *gallivm, debug_printf(" .min_mip_filter = %u\n", derived_sampler_state.min_mip_filter); } - min_img_filter = static_sampler_state->min_img_filter; - mag_img_filter = static_sampler_state->mag_img_filter; + if ((static_texture_state->target == PIPE_TEXTURE_CUBE || + static_texture_state->target == PIPE_TEXTURE_CUBE_ARRAY) && + static_sampler_state->seamless_cube_map) + { + /* + * Seamless filtering ignores wrap modes. + * Setting to CLAMP_TO_EDGE is correct for nearest filtering, for + * bilinear it's not correct but way better than using for instance repeat. + */ + derived_sampler_state.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; + derived_sampler_state.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE; + } + + min_img_filter = derived_sampler_state.min_img_filter; + mag_img_filter = derived_sampler_state.mag_img_filter; /* @@ -2260,16 +2273,16 @@ lp_build_sample_soa(struct gallivm_state *gallivm, LLVMValueRef ilevel0 = NULL, ilevel1 = NULL; boolean use_aos = util_format_fits_8unorm(bld.format_desc) && /* not sure this is strictly needed or simply impossible */ - static_sampler_state->compare_mode == PIPE_TEX_COMPARE_NONE && - lp_is_simple_wrap_mode(static_sampler_state->wrap_s); + derived_sampler_state.compare_mode == PIPE_TEX_COMPARE_NONE && + lp_is_simple_wrap_mode(derived_sampler_state.wrap_s); use_aos &= bld.num_lods <= num_quads || - static_sampler_state->min_img_filter == - static_sampler_state->mag_img_filter; + derived_sampler_state.min_img_filter == + derived_sampler_state.mag_img_filter; if (dims > 1) { - use_aos &= lp_is_simple_wrap_mode(static_sampler_state->wrap_t); + use_aos &= lp_is_simple_wrap_mode(derived_sampler_state.wrap_t); if (dims > 2) { - use_aos &= lp_is_simple_wrap_mode(static_sampler_state->wrap_r); + use_aos &= lp_is_simple_wrap_mode(derived_sampler_state.wrap_r); } } @@ -2278,12 +2291,12 @@ lp_build_sample_soa(struct gallivm_state *gallivm, debug_printf("%s: using floating point linear filtering for %s\n", __FUNCTION__, bld.format_desc->short_name); debug_printf(" min_img %d mag_img %d mip %d wraps %d wrapt %d wrapr %d\n", - static_sampler_state->min_img_filter, - static_sampler_state->mag_img_filter, - static_sampler_state->min_mip_filter, - static_sampler_state->wrap_s, - static_sampler_state->wrap_t, - static_sampler_state->wrap_r); + derived_sampler_state.min_img_filter, + derived_sampler_state.mag_img_filter, + derived_sampler_state.min_mip_filter, + derived_sampler_state.wrap_s, + derived_sampler_state.wrap_t, + derived_sampler_state.wrap_r); } lp_build_sample_common(&bld, texture_index, sampler_index, |