summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/vc4/vc4_state.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2018-02-20 16:28:07 +0000
committerEric Anholt <[email protected]>2018-02-23 08:42:13 -0800
commitc824a045ea639b8a93cbc2518b16900402d9150f (patch)
tree44b3e20299663a1aa230b89a340a0211f7594f13 /src/gallium/drivers/vc4/vc4_state.c
parent6deb158ec1e03027d855df6a2513c8595ed95924 (diff)
broadcom/vc4: Fix double-unrefcounting of prsc->next with shadows.
When we set up the shadow resource we were copying the original resource as the template, including its prsc->next field. When we shadowed the first YUV plane's resource for linear-to-tiled conversion, we would end up unbalancing the refcount on the shadow resource's destruction.
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_state.c')
-rw-r--r--src/gallium/drivers/vc4/vc4_state.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/gallium/drivers/vc4/vc4_state.c b/src/gallium/drivers/vc4/vc4_state.c
index b4696ed7981..7bc87b0c4ee 100644
--- a/src/gallium/drivers/vc4/vc4_state.c
+++ b/src/gallium/drivers/vc4/vc4_state.c
@@ -583,12 +583,17 @@ vc4_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc,
(cso->u.tex.first_level != cso->u.tex.last_level)) ||
rsc->vc4_format == VC4_TEXTURE_TYPE_RGBA32R) {
struct vc4_resource *shadow_parent = rsc;
- struct pipe_resource tmpl = *prsc;
-
- tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
- tmpl.width0 = u_minify(tmpl.width0, cso->u.tex.first_level);
- tmpl.height0 = u_minify(tmpl.height0, cso->u.tex.first_level);
- tmpl.last_level = cso->u.tex.last_level - cso->u.tex.first_level;
+ struct pipe_resource tmpl = {
+ .target = prsc->target,
+ .format = prsc->format,
+ .width0 = u_minify(prsc->width0,
+ cso->u.tex.first_level),
+ .height0 = u_minify(prsc->height0,
+ cso->u.tex.first_level),
+ .bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET,
+ .last_level = cso->u.tex.last_level - cso->u.tex.first_level,
+ .nr_samples = prsc->nr_samples,
+ };
/* Create the shadow texture. The rest of the texture
* parameter setup will use the shadow.