mesa: add LodBias quantization from st/mesa
Apparently the quantization math isn't cheap. This further reduces overhead by 2% for drawoverhead/8 textures. The improvement is measured by looking at the sysprof percentage delta and multiplying by 2 (because we have the frontend and gallium threads with equal overhead, so the benefit is doubled compared to 1 thread). Both per-sampler and per-unit lod bias values are quantized. The difference in behavior is that both values are quantized separately and then added up, instead of first added up and then quantized. The worst case error is +- 1/256 in the reduced precision, i.e. off by one in a fixed-point representation, which should be fine. Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Emma Anholt <emma@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11339>
This commit is contained in:
@@ -94,12 +94,6 @@ st_convert_sampler(const struct st_context *st,
|
||||
sampler->normalized_coords = 1;
|
||||
|
||||
sampler->lod_bias += tex_unit_lod_bias;
|
||||
/* Reduce the number of states by allowing only the values that AMD GCN
|
||||
* can represent. Apps use lod_bias for smooth transitions to bigger mipmap
|
||||
* levels.
|
||||
*/
|
||||
sampler->lod_bias = CLAMP(sampler->lod_bias, -16, 16);
|
||||
sampler->lod_bias = roundf(sampler->lod_bias * 256) / 256;
|
||||
|
||||
/* Check that only wrap modes using the border color have the first bit
|
||||
* set.
|
||||
@@ -184,7 +178,7 @@ st_convert_sampler_from_unit(const struct st_context *st,
|
||||
|
||||
msamp = _mesa_get_samplerobj(ctx, texUnit);
|
||||
|
||||
st_convert_sampler(st, texobj, msamp, ctx->Texture.Unit[texUnit].LodBias,
|
||||
st_convert_sampler(st, texobj, msamp, ctx->Texture.Unit[texUnit].LodBiasQuantized,
|
||||
sampler);
|
||||
|
||||
sampler->seamless_cube_map |= ctx->Texture.CubeMapSeamless;
|
||||
|
Reference in New Issue
Block a user