etnaviv: texture-desc: sample 1D textures using 2D mode
Mipmapping is not working correctly when sampling a 1D texture, likely due to a bad derivative being used by the hardware for the unused dimension. To work around this, do the same trick as already used in texture-state by upgrading 1D textures to 2D samplers with VWARP mode set to repeat. Fixes piglit spec@glsl-1.20@execution@tex-miplevel-selection 1d Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18045>
This commit is contained in:
@@ -60,6 +60,7 @@ struct etna_sampler_view_desc {
|
||||
struct pipe_sampler_view base;
|
||||
/* format-dependent merged with sampler state */
|
||||
uint32_t SAMP_CTRL0;
|
||||
uint32_t SAMP_CTRL0_MASK;
|
||||
uint32_t SAMP_CTRL1;
|
||||
|
||||
struct pipe_resource *res;
|
||||
@@ -149,6 +150,7 @@ etna_create_sampler_view_desc(struct pipe_context *pctx, struct pipe_resource *p
|
||||
sv->base.texture = NULL;
|
||||
pipe_resource_reference(&sv->base.texture, prsc);
|
||||
sv->base.context = pctx;
|
||||
sv->SAMP_CTRL0_MASK = 0xffffffff;
|
||||
|
||||
/* Determine whether target supported */
|
||||
uint32_t target_hw = translate_texture_target(sv->base.target);
|
||||
@@ -176,12 +178,22 @@ etna_create_sampler_view_desc(struct pipe_context *pctx, struct pipe_resource *p
|
||||
bool is_array = false;
|
||||
bool sint = util_format_is_pure_sint(so->format);
|
||||
|
||||
if (sv->base.target == PIPE_TEXTURE_1D_ARRAY) {
|
||||
switch(sv->base.target) {
|
||||
case PIPE_TEXTURE_1D:
|
||||
target_hw = TEXTURE_TYPE_2D;
|
||||
sv->SAMP_CTRL0_MASK = ~VIVS_NTE_DESCRIPTOR_SAMP_CTRL0_VWRAP__MASK;
|
||||
sv->SAMP_CTRL0 = VIVS_NTE_DESCRIPTOR_SAMP_CTRL0_VWRAP(TEXTURE_WRAPMODE_REPEAT);
|
||||
break;
|
||||
case PIPE_TEXTURE_1D_ARRAY:
|
||||
is_array = true;
|
||||
base_height = res->base.array_size;
|
||||
} else if (sv->base.target == PIPE_TEXTURE_2D_ARRAY) {
|
||||
break;
|
||||
case PIPE_TEXTURE_2D_ARRAY:
|
||||
is_array = true;
|
||||
base_depth = res->base.array_size;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#define DESC_SET(x, y) buf[(TEXDESC_##x)>>2] = (y)
|
||||
@@ -287,7 +299,7 @@ etna_emit_texture_desc(struct etna_context *ctx)
|
||||
if ((1 << x) & active_samplers) {
|
||||
struct etna_sampler_state_desc *ss = etna_sampler_state_desc(ctx->sampler[x]);
|
||||
struct etna_sampler_view_desc *sv = etna_sampler_view_desc(ctx->sampler_view[x]);
|
||||
uint32_t SAMP_CTRL0 = ss->SAMP_CTRL0 | sv->SAMP_CTRL0;
|
||||
uint32_t SAMP_CTRL0 = (ss->SAMP_CTRL0 & sv->SAMP_CTRL0_MASK) | sv->SAMP_CTRL0;
|
||||
|
||||
if (texture_use_int_filter(&sv->base, &ss->base, true))
|
||||
SAMP_CTRL0 |= VIVS_NTE_DESCRIPTOR_SAMP_CTRL0_INT_FILTER;
|
||||
|
Reference in New Issue
Block a user