The fast log2 works better if rho is squared, i.e.
fast_log2(sqrt(2)) == 0.4
0.5 * fast_log2(2) == 0.5
so just square rho, and always divide by 2 afterwards.
Fixes:
GTF-GL45.gtf30.GL3Tests.sgis_texture_lod.sgis_texture_lod_basic_lod_selection
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5820>
dEQP-GLES2.functional.rasterization.interpolation.projected.line_loop_wide
dEQP-GLES2.functional.rasterization.interpolation.projected.line_strip_wide
dEQP-GLES2.functional.rasterization.interpolation.projected.lines_wide
-dEQP-GLES2.functional.shaders.texture_functions.fragment.texture2d_bias
-dEQP-GLES2.functional.shaders.texture_functions.fragment.texture2dproj_vec3_bias
-dEQP-GLES2.functional.shaders.texture_functions.fragment.texture2dproj_vec4_bias
dEQP-GLES2.functional.texture.filtering.2d.linear_mipmap_linear_linear_clamp_rgba8888
dEQP-GLES2.functional.texture.filtering.2d.linear_mipmap_linear_linear_mirror_etc1
dEQP-GLES2.functional.texture.filtering.2d.linear_mipmap_linear_linear_mirror_rgba8888
dEQP-GLES3.functional.clipping.triangle_vertex.clip_two.clip_pos_y_pos_z_and_neg_x_neg_y_neg_z
dEQP-GLES3.functional.draw.random.105
dEQP-GLES3.functional.draw.random.114
-dEQP-GLES3.functional.draw.random.124
dEQP-GLES3.functional.draw.random.135
dEQP-GLES3.functional.draw.random.144
dEQP-GLES3.functional.draw.random.155
lod = lp_build_log2(lodf_bld, rho);
}
else {
+ /* get more accurate results if we just sqaure rho always */
+ if (!rho_squared)
+ rho = lp_build_mul(lodf_bld, rho, rho);
lod = lp_build_fast_log2(lodf_bld, rho);
}
- if (rho_squared) {
- /* log2(x^2) == 0.5*log2(x) */
- lod = lp_build_mul(lodf_bld, lod,
- lp_build_const_vec(bld->gallivm, lodf_bld->type, 0.5F));
- }
+
+ /* log2(x^2) == 0.5*log2(x) */
+ lod = lp_build_mul(lodf_bld, lod,
+ lp_build_const_vec(bld->gallivm, lodf_bld->type, 0.5F));
/* add shader lod bias */
if (lod_bias) {