I already had the texture's wrapping set up to use different behavior for
nearest or linear, so we just needed to saturate the coordinates in linear
mode to get the "proper" blend between the edge and border values.
struct {
unsigned compare_mode:1;
unsigned compare_func:3;
- unsigned wrap_s:3;
- unsigned wrap_t:3;
+ bool clamp_s:1;
+ bool clamp_t:1;
+ bool clamp_r:1;
};
struct {
uint16_t msaa_width, msaa_height;
for (int i = 0; i < ARRAY_SIZE(c->key->tex); i++) {
for (int j = 0; j < 4; j++)
tex_options.swizzles[i][j] = c->key->tex[i].swizzle[j];
+
+ if (c->key->tex[i].clamp_s)
+ tex_options.saturate_s |= 1 << i;
+ if (c->key->tex[i].clamp_t)
+ tex_options.saturate_t |= 1 << i;
+ if (c->key->tex[i].clamp_r)
+ tex_options.saturate_r |= 1 << i;
}
NIR_PASS_V(c->s, nir_lower_tex, &tex_options);
} else if (sampler){
key->tex[i].compare_mode = sampler_state->compare_mode;
key->tex[i].compare_func = sampler_state->compare_func;
- key->tex[i].wrap_s = sampler_state->wrap_s;
- key->tex[i].wrap_t = sampler_state->wrap_t;
+ key->tex[i].clamp_s =
+ sampler_state->wrap_s == PIPE_TEX_WRAP_CLAMP;
+ key->tex[i].clamp_t =
+ sampler_state->wrap_t == PIPE_TEX_WRAP_CLAMP;
+ key->tex[i].clamp_r =
+ sampler_state->wrap_r == PIPE_TEX_WRAP_CLAMP;
}
}