From 75e01d01a53bab40b468897e08b144a1393e1013 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 14 Apr 2020 15:28:05 +1000 Subject: [PATCH] gallivm/sample: always square rho before fast log2 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 Part-of: --- .gitlab-ci/deqp-llvmpipe-fails.txt | 3 --- .gitlab-ci/deqp-virgl-gl-fails.txt | 1 - src/gallium/auxiliary/gallivm/lp_bld_sample.c | 12 +++++++----- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci/deqp-llvmpipe-fails.txt b/.gitlab-ci/deqp-llvmpipe-fails.txt index 795cc4bab44..b2166e7afc0 100644 --- a/.gitlab-ci/deqp-llvmpipe-fails.txt +++ b/.gitlab-ci/deqp-llvmpipe-fails.txt @@ -28,9 +28,6 @@ dEQP-GLES2.functional.rasterization.interpolation.basic.lines_wide 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 diff --git a/.gitlab-ci/deqp-virgl-gl-fails.txt b/.gitlab-ci/deqp-virgl-gl-fails.txt index 8104903f8a8..df790647cf5 100644 --- a/.gitlab-ci/deqp-virgl-gl-fails.txt +++ b/.gitlab-ci/deqp-virgl-gl-fails.txt @@ -39,7 +39,6 @@ dEQP-GLES3.functional.clipping.triangle_vertex.clip_two.clip_neg_y_neg_z_and_neg 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 diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c index 18b780d4cb8..686abc08620 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c @@ -848,13 +848,15 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, 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) { -- 2.30.2