mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 07:00:12 +01:00
amd,util: fix how lod bias is converted to fixed-point
according to internal docs Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20967>
This commit is contained in:
parent
fb5d31c3dd
commit
e673bb4ae4
3 changed files with 10 additions and 8 deletions
|
|
@ -7675,17 +7675,18 @@ radv_init_sampler(struct radv_device *device, struct radv_sampler *sampler,
|
|||
sampler->state[1] = (S_008F34_MIN_LOD(radv_float_to_ufixed(CLAMP(pCreateInfo->minLod, 0, 15), 8)) |
|
||||
S_008F34_MAX_LOD(radv_float_to_ufixed(CLAMP(pCreateInfo->maxLod, 0, 15), 8)) |
|
||||
S_008F34_PERF_MIP(max_aniso_ratio ? max_aniso_ratio + 6 : 0));
|
||||
sampler->state[2] = (S_008F38_LOD_BIAS(radv_float_to_sfixed(CLAMP(pCreateInfo->mipLodBias, -16, 16), 8)) |
|
||||
S_008F38_XY_MAG_FILTER(radv_tex_filter(pCreateInfo->magFilter, max_aniso)) |
|
||||
sampler->state[2] = (S_008F38_XY_MAG_FILTER(radv_tex_filter(pCreateInfo->magFilter, max_aniso)) |
|
||||
S_008F38_XY_MIN_FILTER(radv_tex_filter(pCreateInfo->minFilter, max_aniso)) |
|
||||
S_008F38_MIP_FILTER(radv_tex_mipfilter(pCreateInfo->mipmapMode)));
|
||||
sampler->state[3] = S_008F3C_BORDER_COLOR_TYPE(radv_tex_bordercolor(border_color));
|
||||
|
||||
if (device->physical_device->rad_info.gfx_level >= GFX10) {
|
||||
sampler->state[2] |=
|
||||
S_008F38_LOD_BIAS(radv_float_to_sfixed(CLAMP(pCreateInfo->mipLodBias, -32, 31), 8)) |
|
||||
S_008F38_ANISO_OVERRIDE_GFX10(device->instance->disable_aniso_single_level);
|
||||
} else {
|
||||
sampler->state[2] |=
|
||||
S_008F38_LOD_BIAS(radv_float_to_sfixed(CLAMP(pCreateInfo->mipLodBias, -16, 15), 8)) |
|
||||
S_008F38_DISABLE_LSB_CEIL(device->physical_device->rad_info.gfx_level <= GFX8) |
|
||||
S_008F38_FILTER_PREC_FIX(1) |
|
||||
S_008F38_ANISO_OVERRIDE_GFX8(device->instance->disable_aniso_single_level &&
|
||||
|
|
|
|||
|
|
@ -4816,18 +4816,19 @@ static void *si_create_sampler_state(struct pipe_context *ctx,
|
|||
rstate->val[1] = (S_008F34_MIN_LOD(S_FIXED(CLAMP(state->min_lod, 0, 15), 8)) |
|
||||
S_008F34_MAX_LOD(S_FIXED(CLAMP(state->max_lod, 0, 15), 8)) |
|
||||
S_008F34_PERF_MIP(max_aniso_ratio ? max_aniso_ratio + 6 : 0));
|
||||
rstate->val[2] = (S_008F38_LOD_BIAS(S_FIXED(CLAMP(state->lod_bias, -16, 16), 8)) |
|
||||
S_008F38_XY_MAG_FILTER(si_tex_filter(state->mag_img_filter, max_aniso)) |
|
||||
rstate->val[2] = (S_008F38_XY_MAG_FILTER(si_tex_filter(state->mag_img_filter, max_aniso)) |
|
||||
S_008F38_XY_MIN_FILTER(si_tex_filter(state->min_img_filter, max_aniso)) |
|
||||
S_008F38_MIP_FILTER(si_tex_mipfilter(state->min_mip_filter)));
|
||||
rstate->val[3] = si_translate_border_color(sctx, state, &state->border_color,
|
||||
state->border_color_is_integer);
|
||||
|
||||
if (sscreen->info.gfx_level >= GFX10) {
|
||||
rstate->val[2] |= S_008F38_ANISO_OVERRIDE_GFX10(1);
|
||||
rstate->val[2] |= S_008F38_LOD_BIAS(S_FIXED(CLAMP(state->lod_bias, -32, 31), 8)) |
|
||||
S_008F38_ANISO_OVERRIDE_GFX10(1);
|
||||
} else {
|
||||
rstate->val[0] |= S_008F30_COMPAT_MODE(sctx->gfx_level >= GFX8);
|
||||
rstate->val[2] |= S_008F38_DISABLE_LSB_CEIL(sctx->gfx_level <= GFX8) |
|
||||
rstate->val[2] |= S_008F30_COMPAT_MODE(sctx->gfx_level >= GFX8) |
|
||||
S_008F38_LOD_BIAS(S_FIXED(CLAMP(state->lod_bias, -16, 15), 8)) |
|
||||
S_008F38_DISABLE_LSB_CEIL(sctx->gfx_level <= GFX8) |
|
||||
S_008F38_FILTER_PREC_FIX(1) |
|
||||
S_008F38_ANISO_OVERRIDE_GFX8(sctx->gfx_level >= GFX8);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -792,7 +792,7 @@ bool util_invert_mat4x4(float *out, const float *m);
|
|||
static inline float
|
||||
util_quantize_lod_bias(float lod)
|
||||
{
|
||||
lod = CLAMP(lod, -16, 16);
|
||||
lod = CLAMP(lod, -32, 31);
|
||||
return roundf(lod * 256) / 256;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue