summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/vc4/vc4_state.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2014-10-02 22:14:03 -0700
committerEric Anholt <[email protected]>2014-10-19 08:42:33 +0100
commit572fba95e4cd85aebdde9bd757c17f719af2af04 (patch)
tree9a8e72c55c67b4a9190e9812ab3e38fc98d5a462 /src/gallium/drivers/vc4/vc4_state.c
parent15eb4c59f6504473989e6a064fda11d6c009ed8f (diff)
vc4: Add support for rebasing texture levels so firstlevel == 0.
GLES2 doesn't have GL_TEXTURE_BASE_LEVEL, so the hardware doesn't. Fixes piglit levelclamp, tex-miplevel-selection, and texture-storage/2D mipmap rendering.
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_state.c')
-rw-r--r--src/gallium/drivers/vc4/vc4_state.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/gallium/drivers/vc4/vc4_state.c b/src/gallium/drivers/vc4/vc4_state.c
index 099006b3e57..d3219b39d61 100644
--- a/src/gallium/drivers/vc4/vc4_state.c
+++ b/src/gallium/drivers/vc4/vc4_state.c
@@ -483,7 +483,28 @@ vc4_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc,
return NULL;
*so = *cso;
+
pipe_reference(NULL, &prsc->reference);
+
+ /* There is no hardware level clamping, and the start address of a
+ * texture may be misaligned, so in that case we have to copy to a
+ * temporary.
+ */
+ if (so->u.tex.first_level) {
+ struct vc4_resource *shadow_parent = vc4_resource(prsc);
+ struct pipe_resource tmpl = shadow_parent->base.b;
+ struct vc4_resource *clone;
+
+ tmpl.width0 = u_minify(tmpl.width0, so->u.tex.first_level);
+ tmpl.height0 = u_minify(tmpl.height0, so->u.tex.first_level);
+ tmpl.last_level = so->u.tex.last_level - so->u.tex.first_level;
+
+ prsc = vc4_resource_create(pctx->screen, &tmpl);
+ clone = vc4_resource(prsc);
+ clone->shadow_parent = &shadow_parent->base.b;
+ /* Flag it as needing update of the contents from the parent. */
+ clone->writes = shadow_parent->writes - 1;
+ }
so->texture = prsc;
so->reference.count = 1;
so->context = pctx;
@@ -514,8 +535,11 @@ vc4_set_sampler_views(struct pipe_context *pctx, unsigned shader,
vc4->dirty |= VC4_DIRTY_TEXSTATE;
for (i = 0; i < nr; i++) {
- if (views[i])
+ if (views[i]) {
new_nr = i + 1;
+ if (views[i]->u.tex.first_level != 0)
+ vc4_update_shadow_baselevel_texture(pctx, views[i]);
+ }
pipe_sampler_view_reference(&stage_tex->textures[i], views[i]);
stage_tex->dirty_samplers |= (1 << i);
}