From: Gert Wollny <gw.foss...@gmail.com>

The evaluation of the array layer index is "floor(z+0.5)", and the default
rounding mode doesn't correctly evaluate this. Therefore, set the rounding
mode to "trunc" and and z-filter mode to "point".
For other textures make sure the the default rounding mode and z-filter are
used.

Fixes single-sample tests out of:
   dEQP-GLES3.functional.texture.shadow.2d_array.*
   dEQP-GLES3.functional.texture.vertex.2d_array.*
   dEQP-GLES3.functional.texture.filtering.2d_array.*
(With the single sample tests the rounding accuracy is tested too)

v2: * reword comments and commit message
    * clear S_03C008_TRUNC_COORD for all non-array types

v2: reword comments

v3: correct typos and add comment about impact of using TRUNC on all
    coordinates using POINT interpolation.

Acked-by: Roland Scheidegger <srol...@vmware.com> (v2)
Signed-off-by: Gert Wollny <gert.wol...@collabora.com>
---
 src/gallium/drivers/r600/evergreen_state.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/gallium/drivers/r600/evergreen_state.c 
b/src/gallium/drivers/r600/evergreen_state.c
index a484f0078a..5e5e3a0324 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -2413,6 +2413,29 @@ static void evergreen_emit_sampler_states(struct 
r600_context *rctx,
                rstate = texinfo->states.states[i];
                assert(rstate);
 
+               /* For texture arrays the formula to select the layer is 
(floor(z + 0.5)) and
+                * apparently the hardware doesn't trigger this when the 
texture is in ARRAY mode
+                * Neither does the default z-rounding mode provide the 
required 0.5 shift
+                * nor does it round with sufficient accuracy. Consequently set 
the coordinate
+                * interpolation and truncate mode here to get "floor" for 
positive coordinates.
+                * (Note, that this changes the rounding mode for all 
coordinated in POINT
+                * interpolation mode. Adding the 0.5 offset is done in the 
shader.
+                * Also  make sure that for other texture types the default is 
used.
+                */
+               struct r600_pipe_sampler_view   *rview = 
texinfo->views.views[i];
+               if (rview) {
+                       rstate->tex_sampler_words[0] &= C_03C000_Z_FILTER;
+                       enum pipe_texture_target target = 
rview->base.texture->target;
+                       if (target == PIPE_TEXTURE_2D_ARRAY ||
+                               target == PIPE_TEXTURE_CUBE_ARRAY ||
+                               target == PIPE_TEXTURE_1D_ARRAY) {
+                               rstate->tex_sampler_words[0] |= 
S_03C000_Z_FILTER(V_03C000_SQ_TEX_Z_FILTER_POINT);
+                               rstate->tex_sampler_words[2] |= 
S_03C008_TRUNCATE_COORD(1);
+                       } else {
+                               rstate->tex_sampler_words[2] &= 
C_03C008_TRUNCATE_COORD;
+                       }
+               }
+
                radeon_emit(cs, PKT3(PKT3_SET_SAMPLER, 3, 0) | pkt_flags);
                radeon_emit(cs, (resource_id_base + i) * 3);
                radeon_emit_array(cs, rstate->tex_sampler_words, 3);
-- 
2.16.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to