r600g: truncate point sampled texture coordinates
authorAlex Deucher <alexdeucher@gmail.com>
Tue, 1 Mar 2011 02:52:19 +0000 (21:52 -0500)
committerAlex Deucher <alexdeucher@gmail.com>
Tue, 1 Mar 2011 03:01:59 +0000 (22:01 -0500)
By default the hardware rounds texcoords.  However,
for point sampled textures, the expected behavior is
to truncate.  When we have point sampled textures,
set the truncate bit in the sampler.

Should fix:
https://bugs.freedesktop.org/show_bug.cgi?id=25871

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_state.c

index 3efdbaba0c37fda1e58cb86ebaa5d3e7b55e87be..a388476b01730a273cb2a74ff4aec15c40746c14 100644 (file)
@@ -305,11 +305,16 @@ static void *evergreen_create_sampler_state(struct pipe_context *ctx,
 {
        struct r600_pipe_state *rstate = CALLOC_STRUCT(r600_pipe_state);
        union util_color uc;
+       uint32_t coord_trunc = 0;
 
        if (rstate == NULL) {
                return NULL;
        }
 
+       if ((state->mag_img_filter == PIPE_TEX_FILTER_NEAREST) ||
+           (state->min_img_filter == PIPE_TEX_FILTER_NEAREST))
+               coord_trunc = 1;
+
        rstate->id = R600_PIPE_STATE_SAMPLER;
        util_pack_color(state->border_color, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
        r600_pipe_state_add_reg(rstate, R_03C000_SQ_TEX_SAMPLER_WORD0_0,
@@ -328,6 +333,7 @@ static void *evergreen_create_sampler_state(struct pipe_context *ctx,
                        0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate, R_03C008_SQ_TEX_SAMPLER_WORD2_0,
                                S_03C008_LOD_BIAS(S_FIXED(CLAMP(state->lod_bias, -16, 16), 8)) |
+                               S_03C008_MC_COORD_TRUNCATE(coord_trunc) |
                                S_03C008_TYPE(1),
                                0xFFFFFFFF, NULL);
 
index c365979e43979f2f7ae4e9d248df22938e7239ff..3f2af7d17bdb463e430896a189951af05bf2898e 100644 (file)
@@ -358,11 +358,16 @@ static void *r600_create_sampler_state(struct pipe_context *ctx,
 {
        struct r600_pipe_state *rstate = CALLOC_STRUCT(r600_pipe_state);
        union util_color uc;
+       uint32_t coord_trunc = 0;
 
        if (rstate == NULL) {
                return NULL;
        }
 
+       if ((state->mag_img_filter == PIPE_TEX_FILTER_NEAREST) ||
+           (state->min_img_filter == PIPE_TEX_FILTER_NEAREST))
+               coord_trunc = 1;
+
        rstate->id = R600_PIPE_STATE_SAMPLER;
        util_pack_color(state->border_color, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
        r600_pipe_state_add_reg(rstate, R_03C000_SQ_TEX_SAMPLER_WORD0_0,
@@ -379,7 +384,9 @@ static void *r600_create_sampler_state(struct pipe_context *ctx,
                        S_03C004_MIN_LOD(S_FIXED(CLAMP(state->min_lod, 0, 15), 6)) |
                        S_03C004_MAX_LOD(S_FIXED(CLAMP(state->max_lod, 0, 15), 6)) |
                        S_03C004_LOD_BIAS(S_FIXED(CLAMP(state->lod_bias, -16, 16), 6)), 0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate, R_03C008_SQ_TEX_SAMPLER_WORD2_0, S_03C008_TYPE(1), 0xFFFFFFFF, NULL);
+       r600_pipe_state_add_reg(rstate, R_03C008_SQ_TEX_SAMPLER_WORD2_0,
+                               S_03C008_MC_COORD_TRUNCATE(coord_trunc) |
+                               S_03C008_TYPE(1), 0xFFFFFFFF, NULL);
        if (uc.ui) {
                r600_pipe_state_add_reg(rstate, R_00A400_TD_PS_SAMPLER0_BORDER_RED, fui(state->border_color[0]), 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_00A404_TD_PS_SAMPLER0_BORDER_GREEN, fui(state->border_color[1]), 0xFFFFFFFF, NULL);