gallium: make max_anisotropy a unsigned bitfield member
saves us a dword in sampler state, hw can't do non-integer aniso degree anyway. To allow aniso 1x (which seems of dubious value but some hardware (radeons) have such a mode, and even d3d allows specifiying it) redefine anisotropic filtering as disabled only if max_anistropy is 0.
This commit is contained in:
@@ -45,4 +45,6 @@ border_color
|
||||
RGBA color used for out-of-bounds coordinates.
|
||||
max_anisotropy
|
||||
Maximum filtering to apply anisotropically to textures. Setting this to
|
||||
1.0 effectively disables anisotropic filtering.
|
||||
0 disables anisotropic filtering. Any other setting enables anisotropic
|
||||
filtering, however it's not unexpected some drivers only will change their
|
||||
filtering with a setting of 2 and higher.
|
||||
|
@@ -228,10 +228,10 @@ i915_create_sampler_state(struct pipe_context *pipe,
|
||||
minFilt = translate_img_filter( sampler->min_img_filter );
|
||||
magFilt = translate_img_filter( sampler->mag_img_filter );
|
||||
|
||||
if (sampler->max_anisotropy > 1.0)
|
||||
if (sampler->max_anisotropy > 1)
|
||||
minFilt = magFilt = FILTER_ANISOTROPIC;
|
||||
|
||||
if (sampler->max_anisotropy > 2.0) {
|
||||
if (sampler->max_anisotropy > 2) {
|
||||
cso->state[0] |= SS2_MAX_ANISO_4;
|
||||
}
|
||||
|
||||
|
@@ -114,14 +114,12 @@ brw_create_sampler_state( struct pipe_context *pipe,
|
||||
|
||||
/* XXX: anisotropy logic slightly changed:
|
||||
*/
|
||||
if (template->max_anisotropy > 1.0) {
|
||||
if (template->max_anisotropy > 1) {
|
||||
sampler->ss0.min_filter = BRW_MAPFILTER_ANISOTROPIC;
|
||||
sampler->ss0.mag_filter = BRW_MAPFILTER_ANISOTROPIC;
|
||||
|
||||
if (template->max_anisotropy > 2.0) {
|
||||
sampler->ss3.max_aniso = MIN2((template->max_anisotropy - 2) / 2,
|
||||
BRW_ANISORATIO_16);
|
||||
}
|
||||
sampler->ss3.max_aniso = MIN2((template->max_anisotropy - 2) / 2,
|
||||
BRW_ANISORATIO_16);
|
||||
}
|
||||
|
||||
sampler->ss1.r_wrap_mode = translate_wrap_mode(template->wrap_r);
|
||||
|
@@ -139,13 +139,13 @@ nv30_sampler_state_create(struct pipe_context *pipe,
|
||||
|
||||
ps->en = 0;
|
||||
|
||||
if (cso->max_anisotropy >= 8.0) {
|
||||
if (cso->max_anisotropy >= 8) {
|
||||
ps->en |= NV34TCL_TX_ENABLE_ANISO_8X;
|
||||
} else
|
||||
if (cso->max_anisotropy >= 4.0) {
|
||||
if (cso->max_anisotropy >= 4) {
|
||||
ps->en |= NV34TCL_TX_ENABLE_ANISO_4X;
|
||||
} else
|
||||
if (cso->max_anisotropy >= 2.0) {
|
||||
if (cso->max_anisotropy >= 2) {
|
||||
ps->en |= NV34TCL_TX_ENABLE_ANISO_2X;
|
||||
}
|
||||
|
||||
|
@@ -132,26 +132,26 @@ nv40_sampler_state_create(struct pipe_context *pipe,
|
||||
(wrap_mode(cso->wrap_r) << NV40TCL_TEX_WRAP_R_SHIFT));
|
||||
|
||||
ps->en = 0;
|
||||
if (cso->max_anisotropy >= 2.0) {
|
||||
if (cso->max_anisotropy >= 2) {
|
||||
/* no idea, binary driver sets it, works without it.. meh.. */
|
||||
ps->wrap |= (1 << 5);
|
||||
|
||||
if (cso->max_anisotropy >= 16.0) {
|
||||
if (cso->max_anisotropy >= 16) {
|
||||
ps->en |= NV40TCL_TEX_ENABLE_ANISO_16X;
|
||||
} else
|
||||
if (cso->max_anisotropy >= 12.0) {
|
||||
if (cso->max_anisotropy >= 12) {
|
||||
ps->en |= NV40TCL_TEX_ENABLE_ANISO_12X;
|
||||
} else
|
||||
if (cso->max_anisotropy >= 10.0) {
|
||||
if (cso->max_anisotropy >= 10) {
|
||||
ps->en |= NV40TCL_TEX_ENABLE_ANISO_10X;
|
||||
} else
|
||||
if (cso->max_anisotropy >= 8.0) {
|
||||
if (cso->max_anisotropy >= 8) {
|
||||
ps->en |= NV40TCL_TEX_ENABLE_ANISO_8X;
|
||||
} else
|
||||
if (cso->max_anisotropy >= 6.0) {
|
||||
if (cso->max_anisotropy >= 6) {
|
||||
ps->en |= NV40TCL_TEX_ENABLE_ANISO_6X;
|
||||
} else
|
||||
if (cso->max_anisotropy >= 4.0) {
|
||||
if (cso->max_anisotropy >= 4) {
|
||||
ps->en |= NV40TCL_TEX_ENABLE_ANISO_4X;
|
||||
} else {
|
||||
ps->en |= NV40TCL_TEX_ENABLE_ANISO_2X;
|
||||
|
@@ -202,18 +202,18 @@ nv50_sampler_state_create(struct pipe_context *pipe,
|
||||
break;
|
||||
}
|
||||
|
||||
if (cso->max_anisotropy >= 16.0)
|
||||
if (cso->max_anisotropy >= 16)
|
||||
tsc[0] |= (7 << 20);
|
||||
else
|
||||
if (cso->max_anisotropy >= 12.0)
|
||||
if (cso->max_anisotropy >= 12)
|
||||
tsc[0] |= (6 << 20);
|
||||
else {
|
||||
tsc[0] |= (int)(cso->max_anisotropy * 0.5f) << 20;
|
||||
tsc[0] |= (cso->max_anisotropy >> 1) << 20;
|
||||
|
||||
if (cso->max_anisotropy >= 4.0)
|
||||
if (cso->max_anisotropy >= 4)
|
||||
tsc[1] |= NV50TSC_1_1_UNKN_ANISO_35;
|
||||
else
|
||||
if (cso->max_anisotropy >= 2.0)
|
||||
if (cso->max_anisotropy >= 2)
|
||||
tsc[1] |= NV50TSC_1_1_UNKN_ANISO_15;
|
||||
}
|
||||
|
||||
|
@@ -777,7 +777,7 @@ static void*
|
||||
sampler->filter0 |= r300_translate_tex_filters(state->min_img_filter,
|
||||
state->mag_img_filter,
|
||||
state->min_mip_filter,
|
||||
state->max_anisotropy > 1.0);
|
||||
state->max_anisotropy > 0);
|
||||
|
||||
/* Unfortunately, r300-r500 don't support floating-point mipmap lods. */
|
||||
/* We must pass these to the emit function to clamp them properly. */
|
||||
|
@@ -312,15 +312,15 @@ static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip,
|
||||
return retval;
|
||||
}
|
||||
|
||||
static INLINE uint32_t r300_anisotropy(float max_aniso)
|
||||
static INLINE uint32_t r300_anisotropy(unsigned max_aniso)
|
||||
{
|
||||
if (max_aniso >= 16.0f) {
|
||||
if (max_aniso >= 16) {
|
||||
return R300_TX_MAX_ANISO_16_TO_1;
|
||||
} else if (max_aniso >= 8.0f) {
|
||||
} else if (max_aniso >= 8) {
|
||||
return R300_TX_MAX_ANISO_8_TO_1;
|
||||
} else if (max_aniso >= 4.0f) {
|
||||
} else if (max_aniso >= 4) {
|
||||
return R300_TX_MAX_ANISO_4_TO_1;
|
||||
} else if (max_aniso >= 2.0f) {
|
||||
} else if (max_aniso >= 2) {
|
||||
return R300_TX_MAX_ANISO_2_TO_1;
|
||||
} else {
|
||||
return R300_TX_MAX_ANISO_1_TO_1;
|
||||
|
@@ -102,8 +102,8 @@ svga_create_sampler_state(struct pipe_context *pipe,
|
||||
cso->mipfilter = translate_mip_filter(sampler->min_mip_filter);
|
||||
cso->magfilter = translate_img_filter( sampler->mag_img_filter );
|
||||
cso->minfilter = translate_img_filter( sampler->min_img_filter );
|
||||
cso->aniso_level = MAX2( (unsigned) sampler->max_anisotropy, 1 );
|
||||
if(cso->aniso_level != 1)
|
||||
cso->aniso_level = MAX2( sampler->max_anisotropy, 1 );
|
||||
if(sampler->max_anisotropy)
|
||||
cso->magfilter = cso->minfilter = SVGA3D_TEX_FILTER_ANISOTROPIC;
|
||||
cso->lod_bias = sampler->lod_bias;
|
||||
cso->addressu = translate_wrap_mode(sampler->wrap_s);
|
||||
|
@@ -435,11 +435,11 @@ void trace_dump_sampler_state(const struct pipe_sampler_state *state)
|
||||
trace_dump_member(uint, state, compare_mode);
|
||||
trace_dump_member(uint, state, compare_func);
|
||||
trace_dump_member(bool, state, normalized_coords);
|
||||
trace_dump_member(uint, state, max_anisotropy);
|
||||
trace_dump_member(float, state, lod_bias);
|
||||
trace_dump_member(float, state, min_lod);
|
||||
trace_dump_member(float, state, max_lod);
|
||||
trace_dump_member_array(float, state, border_color);
|
||||
trace_dump_member(float, state, max_anisotropy);
|
||||
|
||||
trace_dump_struct_end();
|
||||
}
|
||||
|
@@ -281,10 +281,10 @@ struct pipe_sampler_state
|
||||
unsigned compare_mode:1; /**< PIPE_TEX_COMPARE_x */
|
||||
unsigned compare_func:3; /**< PIPE_FUNC_x */
|
||||
unsigned normalized_coords:1; /**< Are coords normalized to [0,1]? */
|
||||
unsigned max_anisotropy:6;
|
||||
float lod_bias; /**< LOD/lambda bias */
|
||||
float min_lod, max_lod; /**< LOD clamp range, after bias */
|
||||
float border_color[4];
|
||||
float max_anisotropy;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -211,7 +211,7 @@ update_samplers(struct st_context *st)
|
||||
teximg ? teximg->_BaseFormat : GL_RGBA,
|
||||
sampler->border_color);
|
||||
|
||||
sampler->max_anisotropy = texobj->MaxAnisotropy;
|
||||
sampler->max_anisotropy = (texobj->MaxAnisotropy == 1.0 ? 0 : (GLuint)texobj->MaxAnisotropy);
|
||||
|
||||
/* only care about ARB_shadow, not SGI shadow */
|
||||
if (texobj->CompareMode == GL_COMPARE_R_TO_TEXTURE) {
|
||||
|
Reference in New Issue
Block a user