From: Gert Wollny <gw.foss...@gmail.com> For texture array lookup the slice index is evaluated according to idx = floor(z + 0.5)
This patch implements the first part by adding 0.5 to the according texture coordinate when appropriate. Fixes multi-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.* (In the multi-sample case the rounding accuracy is not tested.) v2: - Don't apply texture offset correction for GATHER*O (corrects piglit failures reported by Dave Airlie) - unconditionally set the texture offset to 1 (=0.5) because the shader can't set an offset for the array index (Roland Scheidegger) v3: - Set texture offset also for GATHER*0 via SET_TEXTURE_OFFSET to be consistent for all GATHER operations (thanks Roland Scheidegger for pointing out this inconsistency). - Don't set the offset for GET_TEXTURE_RESINFO operations - correct typos (Roland) Acked-by: Roland Scheidegger <srol...@vmware.com> (v2) Signed-off-by: Gert Wollny <gert.wol...@collabora.com> --- src/gallium/drivers/r600/r600_shader.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c index c466a48262..ffc272cf6f 100644 --- a/src/gallium/drivers/r600/r600_shader.c +++ b/src/gallium/drivers/r600/r600_shader.c @@ -7456,6 +7456,7 @@ static int tgsi_tex(struct r600_shader_ctx *ctx) int8_t offset_x = 0, offset_y = 0, offset_z = 0; boolean has_txq_cube_array_z = false; unsigned sampler_index_mode; + int *array_index_offset = NULL; if (inst->Instruction.Opcode == TGSI_OPCODE_TXQ && ((inst->Texture.Texture == TGSI_TEXTURE_CUBE_ARRAY || @@ -8251,7 +8252,15 @@ static int tgsi_tex(struct r600_shader_ctx *ctx) tex.src_gpr = ctx->file_offset[inst->TexOffsets[0].File] + inst->TexOffsets[0].Index; tex.src_sel_x = inst->TexOffsets[0].SwizzleX; tex.src_sel_y = inst->TexOffsets[0].SwizzleY; - tex.src_sel_z = inst->TexOffsets[0].SwizzleZ; + + if (inst->Texture.Texture == TGSI_TEXTURE_2D_ARRAY || + inst->Texture.Texture == TGSI_TEXTURE_SHADOW2D_ARRAY || + inst->Texture.Texture == TGSI_TEXTURE_CUBE_ARRAY || + inst->Texture.Texture == TGSI_TEXTURE_SHADOWCUBE_ARRAY) + tex.src_sel_z = PIPE_SWIZZLE_1; + else + tex.src_sel_z = inst->TexOffsets[0].SwizzleZ; + tex.src_sel_w = 4; tex.dst_sel_x = 7; @@ -8411,18 +8420,34 @@ static int tgsi_tex(struct r600_shader_ctx *ctx) opcode == FETCH_OP_SAMPLE_C_LB) { /* the array index is read from Y */ tex.coord_type_y = 0; + array_index_offset = &tex.offset_y; } else { /* the array index is read from Z */ tex.coord_type_z = 0; tex.src_sel_z = tex.src_sel_y; + array_index_offset = &tex.offset_z; + } } else if (inst->Texture.Texture == TGSI_TEXTURE_2D_ARRAY || inst->Texture.Texture == TGSI_TEXTURE_SHADOW2D_ARRAY || ((inst->Texture.Texture == TGSI_TEXTURE_CUBE_ARRAY || inst->Texture.Texture == TGSI_TEXTURE_SHADOWCUBE_ARRAY) && - (ctx->bc->chip_class >= EVERGREEN))) + (ctx->bc->chip_class >= EVERGREEN))) { /* the array index is read from Z */ tex.coord_type_z = 0; + array_index_offset = &tex.offset_z; + } + + /* We have array access, the coordinates are not int and we use the + * offset registers -> add 0.5 to the array index to adjust it according + * to floor(z + 0.5). The floor operation is set as TRUNC in the texture + * state. + */ + if (array_index_offset && + opcode != FETCH_OP_LD && opcode != FETCH_OP_GET_TEXTURE_RESINFO && + opcode != FETCH_OP_GATHER4_C_O && opcode != FETCH_OP_GATHER4_O) { + *array_index_offset = 1; + } /* mask unused source components */ if (opcode == FETCH_OP_SAMPLE || opcode == FETCH_OP_GATHER4) { -- 2.16.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev