mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
gallium: Add TEX_FILTER_ANISO img filter
Hardware almost universally expects us to set a special filtering mode when anisotropic filtering is enabled, as opposed to varying a max-aniso values. Do this once in the state tracker & simplify the driver code.
This commit is contained in:
parent
feb02084a8
commit
98ae83d5cc
5 changed files with 35 additions and 31 deletions
|
|
@ -71,6 +71,8 @@ static unsigned translate_img_filter( unsigned filter )
|
|||
return FILTER_NEAREST;
|
||||
case PIPE_TEX_FILTER_LINEAR:
|
||||
return FILTER_LINEAR;
|
||||
case PIPE_TEX_FILTER_ANISO:
|
||||
return FILTER_ANISOTROPIC;
|
||||
default:
|
||||
assert(0);
|
||||
return FILTER_NEAREST;
|
||||
|
|
@ -84,7 +86,7 @@ static unsigned translate_mip_filter( unsigned filter )
|
|||
return MIPFILTER_NONE;
|
||||
case PIPE_TEX_MIPFILTER_NEAREST:
|
||||
return MIPFILTER_NEAREST;
|
||||
case PIPE_TEX_FILTER_LINEAR:
|
||||
case PIPE_TEX_MIPFILTER_LINEAR:
|
||||
return MIPFILTER_LINEAR;
|
||||
default:
|
||||
assert(0);
|
||||
|
|
@ -211,16 +213,11 @@ i915_create_sampler_state(struct pipe_context *pipe,
|
|||
cso->templ = sampler;
|
||||
|
||||
mipFilt = translate_mip_filter(sampler->min_mip_filter);
|
||||
if (sampler->max_anisotropy > 1.0) {
|
||||
minFilt = FILTER_ANISOTROPIC;
|
||||
magFilt = FILTER_ANISOTROPIC;
|
||||
if (sampler->max_anisotropy > 2.0) {
|
||||
cso->state[0] |= SS2_MAX_ANISO_4;
|
||||
}
|
||||
}
|
||||
else {
|
||||
minFilt = translate_img_filter( sampler->min_img_filter );
|
||||
magFilt = translate_img_filter( sampler->mag_img_filter );
|
||||
minFilt = translate_img_filter( sampler->min_img_filter );
|
||||
magFilt = translate_img_filter( sampler->mag_img_filter );
|
||||
|
||||
if (sampler->max_anisotropy > 2.0) {
|
||||
cso->state[0] |= SS2_MAX_ANISO_4;
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -136,6 +136,9 @@ static void brw_update_sampler_state( const struct pipe_sampler_state *pipe_samp
|
|||
case PIPE_TEX_FILTER_LINEAR:
|
||||
sampler->ss0.min_filter = BRW_MAPFILTER_LINEAR;
|
||||
break;
|
||||
case PIPE_TEX_FILTER_ANISO:
|
||||
sampler->ss0.min_filter = BRW_MAPFILTER_ANISOTROPIC;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -155,26 +158,23 @@ static void brw_update_sampler_state( const struct pipe_sampler_state *pipe_samp
|
|||
}
|
||||
/* Set Anisotropy:
|
||||
*/
|
||||
if (pipe_sampler->max_anisotropy > 1.0) {
|
||||
sampler->ss0.min_filter = BRW_MAPFILTER_ANISOTROPIC;
|
||||
sampler->ss0.mag_filter = BRW_MAPFILTER_ANISOTROPIC;
|
||||
|
||||
if (pipe_sampler->max_anisotropy > 2.0) {
|
||||
sampler->ss3.max_aniso = MAX2((pipe_sampler->max_anisotropy - 2) / 2,
|
||||
BRW_ANISORATIO_16);
|
||||
}
|
||||
switch (pipe_sampler->mag_img_filter) {
|
||||
case PIPE_TEX_FILTER_NEAREST:
|
||||
sampler->ss0.mag_filter = BRW_MAPFILTER_NEAREST;
|
||||
break;
|
||||
case PIPE_TEX_FILTER_LINEAR:
|
||||
sampler->ss0.mag_filter = BRW_MAPFILTER_LINEAR;
|
||||
break;
|
||||
case PIPE_TEX_FILTER_ANISO:
|
||||
sampler->ss0.mag_filter = BRW_MAPFILTER_LINEAR;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
else {
|
||||
switch (pipe_sampler->mag_img_filter) {
|
||||
case PIPE_TEX_FILTER_NEAREST:
|
||||
sampler->ss0.mag_filter = BRW_MAPFILTER_NEAREST;
|
||||
break;
|
||||
case PIPE_TEX_FILTER_LINEAR:
|
||||
sampler->ss0.mag_filter = BRW_MAPFILTER_LINEAR;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (pipe_sampler->max_anisotropy > 2.0) {
|
||||
sampler->ss3.max_aniso = MAX2((pipe_sampler->max_anisotropy - 2) / 2,
|
||||
BRW_ANISORATIO_16);
|
||||
}
|
||||
|
||||
sampler->ss1.s_wrap_mode = translate_wrap_mode(pipe_sampler->wrap_s);
|
||||
|
|
|
|||
|
|
@ -714,6 +714,7 @@ sp_get_samples_2d_common(struct tgsi_sampler *sampler,
|
|||
}
|
||||
break;
|
||||
case PIPE_TEX_FILTER_LINEAR:
|
||||
case PIPE_TEX_FILTER_ANISO:
|
||||
for (j = 0; j < QUAD_SIZE; j++) {
|
||||
float tx[4][4], a, b;
|
||||
int x0, y0, x1, y1, c;
|
||||
|
|
@ -846,6 +847,7 @@ sp_get_samples_3d(struct tgsi_sampler *sampler,
|
|||
}
|
||||
break;
|
||||
case PIPE_TEX_FILTER_LINEAR:
|
||||
case PIPE_TEX_FILTER_ANISO:
|
||||
for (j = 0; j < QUAD_SIZE; j++) {
|
||||
float texel0[4][4], texel1[4][4];
|
||||
float xw, yw, zw; /* interpolation weights */
|
||||
|
|
@ -972,6 +974,7 @@ sp_get_samples_rect(struct tgsi_sampler *sampler,
|
|||
}
|
||||
break;
|
||||
case PIPE_TEX_FILTER_LINEAR:
|
||||
case PIPE_TEX_FILTER_ANISO:
|
||||
for (j = 0; j < QUAD_SIZE; j++) {
|
||||
float tx[4][4], a, b;
|
||||
int x0, y0, x1, y1, c;
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ enum pipe_texture_target {
|
|||
*/
|
||||
#define PIPE_TEX_FILTER_NEAREST 0
|
||||
#define PIPE_TEX_FILTER_LINEAR 1
|
||||
/* #define PIPE_TEX_FILTER_ANISO 2 */
|
||||
#define PIPE_TEX_FILTER_ANISO 2
|
||||
|
||||
|
||||
#define PIPE_TEX_COMPARE_NONE 0
|
||||
|
|
|
|||
|
|
@ -160,6 +160,10 @@ update_samplers(struct st_context *st)
|
|||
#endif
|
||||
|
||||
sampler->max_anisotropy = texobj->MaxAnisotropy;
|
||||
if (sampler->max_anisotropy > 1.0) {
|
||||
sampler->min_img_filter = PIPE_TEX_FILTER_ANISO;
|
||||
sampler->mag_img_filter = PIPE_TEX_FILTER_ANISO;
|
||||
}
|
||||
|
||||
/* only care about ARB_shadow, not SGI shadow */
|
||||
if (texobj->CompareMode == GL_COMPARE_R_TO_TEXTURE) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue