gallivm/sample: always square rho before fast log2
authorDave Airlie <airlied@redhat.com>
Tue, 14 Apr 2020 05:28:05 +0000 (15:28 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 15 Jul 2020 19:46:57 +0000 (05:46 +1000)
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>

.gitlab-ci/deqp-llvmpipe-fails.txt
.gitlab-ci/deqp-virgl-gl-fails.txt
src/gallium/auxiliary/gallivm/lp_bld_sample.c

index 795cc4bab44f02f52478acddf189ae7e394765f8..b2166e7afc05a4fac79b4bc8e24669f2e0365286 100644 (file)
@@ -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
index 8104903f8a8e04cd3d22b6440e9069a5fbe10bef..df790647cf59f4712e5451a681e070af5c876145 100644 (file)
@@ -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
index 18b780d4cb8c9b490f92bcf10a845119a74411cb..686abc086208cf006fe1ff991c41d9337a128716 100644 (file)
@@ -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) {