summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeha Bhende <[email protected]>2017-07-20 13:59:36 -0700
committerBrian Paul <[email protected]>2017-07-22 13:18:56 -0600
commitacfb1583a560339b500a94bc13bf73675e7ed422 (patch)
tree3e7cd84f3b0162a54efcd2e2fb03845474943fb0 /src
parentdc62ddfb39e2287f1376df94e15bf108a73f12b0 (diff)
svga: fix unnormalized->normalized texture coordinate conversion
Sometimes, converting unnormalized coordinates to normalized coordinates requires an epsilon value to produce the right texels with nearest filtering. Adding 0.0001 to the coordinates when the min/mag filter is nearest fixes the issue. Fixes piglit test fbo-blit-scaled-linear Tested with mtt-piglit, mtt-glretrace Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Charmaine Lee <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/svga/svga_shader.c5
-rw-r--r--src/gallium/drivers/svga/svga_shader.h1
-rw-r--r--src/gallium/drivers/svga/svga_tgsi_vgpu10.c32
3 files changed, 35 insertions, 3 deletions
diff --git a/src/gallium/drivers/svga/svga_shader.c b/src/gallium/drivers/svga/svga_shader.c
index 74c829eefc1..9e2b65771cd 100644
--- a/src/gallium/drivers/svga/svga_shader.c
+++ b/src/gallium/drivers/svga/svga_shader.c
@@ -246,6 +246,11 @@ svga_init_shader_key_common(const struct svga_context *svga,
key->tex[i].width_height_idx = idx++;
key->tex[i].unnormalized = TRUE;
++key->num_unnormalized_coords;
+
+ if (sampler->magfilter == SVGA3D_TEX_FILTER_NEAREST ||
+ sampler->minfilter == SVGA3D_TEX_FILTER_NEAREST) {
+ key->tex[i].texel_bias = TRUE;
+ }
}
}
}
diff --git a/src/gallium/drivers/svga/svga_shader.h b/src/gallium/drivers/svga/svga_shader.h
index ec116c031d5..a594d120f84 100644
--- a/src/gallium/drivers/svga/svga_shader.h
+++ b/src/gallium/drivers/svga/svga_shader.h
@@ -97,6 +97,7 @@ struct svga_compile_key
unsigned compare_mode:1;
unsigned compare_func:3;
unsigned unnormalized:1;
+ unsigned texel_bias:1;
unsigned width_height_idx:5; /**< texture unit */
unsigned is_array:1;
unsigned sprite_texgen:1;
diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
index c7a1336d073..93a76ef49f1 100644
--- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
+++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
@@ -4854,9 +4854,24 @@ setup_texcoord(struct svga_shader_emitter_v10 *emit,
struct tgsi_full_dst_register tmp_dst = make_dst_temp_reg(tmp);
struct tgsi_full_src_register scale_src = make_src_const_reg(scale_index);
- /* MUL tmp, coord, const[] */
- emit_instruction_op2(emit, VGPU10_OPCODE_MUL, &tmp_dst,
- coord, &scale_src, FALSE);
+ if (emit->key.tex[unit].texel_bias) {
+ /* to fix texture coordinate rounding issue, 0.0001 offset is
+ * been added. This fixes piglit test fbo-blit-scaled-linear. */
+ struct tgsi_full_src_register offset =
+ make_immediate_reg_float(emit, 0.0001f);
+
+ /* ADD tmp, coord, offset */
+ emit_instruction_op2(emit, VGPU10_OPCODE_ADD, &tmp_dst,
+ coord, &offset, FALSE);
+ /* MUL tmp, tmp, scale */
+ emit_instruction_op2(emit, VGPU10_OPCODE_MUL, &tmp_dst,
+ &tmp_src, &scale_src, FALSE);
+ }
+ else {
+ /* MUL tmp, coord, const[] */
+ emit_instruction_op2(emit, VGPU10_OPCODE_MUL, &tmp_dst,
+ coord, &scale_src, FALSE);
+ }
return tmp_src;
}
else {
@@ -6287,6 +6302,17 @@ alloc_common_immediates(struct svga_shader_emitter_v10 *emit)
alloc_immediate_int4(emit, 22, 30, 0, 0);
}
+ unsigned i;
+
+ for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
+ if (emit->key.tex[i].texel_bias) {
+ /* Replace 0.0f if more immediate float value is needed */
+ emit->common_immediate_pos[n++] =
+ alloc_immediate_float4(emit, 0.0001f, 0.0f, 0.0f, 0.0f);
+ break;
+ }
+ }
+
assert(n <= ARRAY_SIZE(emit->common_immediate_pos));
emit->num_common_immediates = n;
}