summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2013-10-04 15:56:01 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2013-10-04 15:56:01 +0200
commitcec463b7debe19d0014e32c81ea24936dbf15a14 (patch)
tree67a5f0f950ca5f4f2d51c6bebb6328d3becbe0d8
parentc45804d3cbc76c986317e02a8c6ab4a603b1e742 (diff)
driver: NPOT textures only support clamp to edge wrap mode
Force wrapping mode to "clamp to edge" in case client requests otherwise. This fixes the texture issue in Dark Places.
-rw-r--r--native/driver/etna_internal.h1
-rw-r--r--native/driver/etna_pipe.c4
-rw-r--r--native/driver/etna_texture.c12
3 files changed, 16 insertions, 1 deletions
diff --git a/native/driver/etna_internal.h b/native/driver/etna_internal.h
index e791992..922813b 100644
--- a/native/driver/etna_internal.h
+++ b/native/driver/etna_internal.h
@@ -186,6 +186,7 @@ struct compiled_sampler_view
{
/* sampler offset +4*sampler, interleave when committing state */
uint32_t TE_SAMPLER_CONFIG0;
+ uint32_t TE_SAMPLER_CONFIG0_MASK;
uint32_t TE_SAMPLER_CONFIG1;
uint32_t TE_SAMPLER_SIZE;
uint32_t TE_SAMPLER_LOG_SIZE;
diff --git a/native/driver/etna_pipe.c b/native/driver/etna_pipe.c
index 91df5f4..9ba6c56 100644
--- a/native/driver/etna_pipe.c
+++ b/native/driver/etna_pipe.c
@@ -636,7 +636,9 @@ static void sync_context(struct pipe_context *restrict pipe)
/* set active samplers to their configuration value (determined by both the sampler state and sampler view),
* set inactive sampler config to 0 */
/*02000*/ EMIT_STATE(TE_SAMPLER_CONFIG0(x), TE_SAMPLER_CONFIG0[x],
- ((1<<x) & active_samplers)?(e->sampler[x].TE_SAMPLER_CONFIG0 | e->sampler_view[x].TE_SAMPLER_CONFIG0):0);
+ ((1<<x) & active_samplers)?(
+ (e->sampler[x].TE_SAMPLER_CONFIG0 & e->sampler_view[x].TE_SAMPLER_CONFIG0_MASK) |
+ e->sampler_view[x].TE_SAMPLER_CONFIG0):0);
}
}
if(unlikely(dirty & (ETNA_STATE_SAMPLER_VIEWS)))
diff --git a/native/driver/etna_texture.c b/native/driver/etna_texture.c
index 94043fe..3b4d135 100644
--- a/native/driver/etna_texture.c
+++ b/native/driver/etna_texture.c
@@ -117,6 +117,7 @@ static struct pipe_sampler_view *etna_pipe_create_sampler_view(struct pipe_conte
VIVS_TE_SAMPLER_CONFIG0_TYPE(translate_texture_target(res->base.target, false)) |
VIVS_TE_SAMPLER_CONFIG0_FORMAT(translate_texture_format(sv->base.format, false));
/* merged with sampler state */
+ cs->TE_SAMPLER_CONFIG0_MASK = 0xffffffff;
cs->TE_SAMPLER_CONFIG1 =
VIVS_TE_SAMPLER_CONFIG1_SWIZZLE_R(templat->swizzle_r) |
@@ -130,6 +131,8 @@ static struct pipe_sampler_view *etna_pipe_create_sampler_view(struct pipe_conte
cs->TE_SAMPLER_LOG_SIZE =
VIVS_TE_SAMPLER_LOG_SIZE_WIDTH(etna_log2_fixp55(res->base.width0)) |
VIVS_TE_SAMPLER_LOG_SIZE_HEIGHT(etna_log2_fixp55(res->base.height0));
+
+ /* Set up levels-of-detail */
/* XXX in principle we only have to define lods sv->first_level .. sv->last_level */
for(int lod=0; lod<=res->base.last_level; ++lod)
{
@@ -138,6 +141,15 @@ static struct pipe_sampler_view *etna_pipe_create_sampler_view(struct pipe_conte
cs->min_lod = sv->base.u.tex.first_level << 5;
cs->max_lod = MIN2(sv->base.u.tex.last_level, res->base.last_level) << 5;
+ /* Workaround for npot textures -- it appears that only CLAMP_TO_EDGE is supported */
+ if(!util_is_power_of_two(res->base.width0) || !util_is_power_of_two(res->base.height0))
+ {
+ cs->TE_SAMPLER_CONFIG0_MASK = ~(VIVS_TE_SAMPLER_CONFIG0_UWRAP__MASK |
+ VIVS_TE_SAMPLER_CONFIG0_VWRAP__MASK);
+ cs->TE_SAMPLER_CONFIG0 |= VIVS_TE_SAMPLER_CONFIG0_UWRAP(TEXTURE_WRAPMODE_CLAMP_TO_EDGE) |
+ VIVS_TE_SAMPLER_CONFIG0_VWRAP(TEXTURE_WRAPMODE_CLAMP_TO_EDGE);
+ }
+
sv->internal = cs;
pipe_reference_init(&sv->base.reference, 1);
return &sv->base;