[Mesa-dev] [PATCH 2/2] r600: set rounding mode for texture array layer selection
Gert Wollny
gert.wollny at collabora.com
Fri Jun 22 09:37:40 UTC 2018
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 3D textures make sure the the default rounding mode and z-filter are
used.
Fixes:
dEQP-GLES3.functional.texture.shadow.2d_array.*
dEQP-GLES3.functional.texture.vertex.2d_array.*
dEQP-GLES3.functional.texture.filtering.2d_array.*
and a number of tests from
dEQP-GLES3.functional.shaders.texture_functions.*2darray
Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
---
src/gallium/drivers/r600/evergreen_state.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index a484f0078a..4ca0cf2fe7 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -2413,6 +2413,27 @@ static void evergreen_emit_sampler_states(struct r600_context *rctx,
rstate = texinfo->states.states[i];
assert(rstate);
+ /* For texture arrays the formula select the layer is (floor(z + 0.5))
+ * The default z-rounding mode doesn't cut it, so we have to override here.
+ * Set the coordinate interpolation and truncate mode accordingly.
+ * Adding the 0.5 offset needs to be done in the shader.
+ * Also make sure that for 3D textures TRUNCATE_COORD is not set and the
+ * z-filter is cleared (which is the default).
+ */
+ 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 if (target == PIPE_TEXTURE_3D) {
+ 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
More information about the mesa-dev
mailing list