iris: Don't leak compressed resources in iris_create_surface
Before this patch, we were leaking compressed resources in iris_create_surface. Specifically, when we failed to create an uncompressed ISL surface and view for a compressed resource, we didn't unreference the resource pointer we referenced into the pipe_surface. Fix this by delaying the pipe_surface initialization code to after attempting to create the uncompressed surface and view. Cc: 22.1 <mesa-stable> Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17598>
This commit is contained in:
parent
bca601ffe9
commit
6c65e990b6
|
@ -2634,23 +2634,11 @@ iris_create_surface(struct pipe_context *ctx,
|
|||
}
|
||||
|
||||
struct iris_surface *surf = calloc(1, sizeof(struct iris_surface));
|
||||
struct pipe_surface *psurf = &surf->base;
|
||||
struct iris_resource *res = (struct iris_resource *) tex;
|
||||
|
||||
if (!surf)
|
||||
return NULL;
|
||||
|
||||
pipe_reference_init(&psurf->reference, 1);
|
||||
pipe_resource_reference(&psurf->texture, tex);
|
||||
psurf->context = ctx;
|
||||
psurf->format = tmpl->format;
|
||||
psurf->width = tex->width0;
|
||||
psurf->height = tex->height0;
|
||||
psurf->texture = tex;
|
||||
psurf->u.tex.first_layer = tmpl->u.tex.first_layer;
|
||||
psurf->u.tex.last_layer = tmpl->u.tex.last_layer;
|
||||
psurf->u.tex.level = tmpl->u.tex.level;
|
||||
|
||||
uint32_t array_len = tmpl->u.tex.last_layer - tmpl->u.tex.first_layer + 1;
|
||||
|
||||
struct isl_view *view = &surf->view;
|
||||
|
@ -2710,7 +2698,7 @@ iris_create_surface(struct pipe_context *ctx,
|
|||
}
|
||||
#endif
|
||||
|
||||
struct isl_surf isl_surf;
|
||||
struct isl_surf isl_surf = res->surf;
|
||||
uint64_t offset_B = 0;
|
||||
uint32_t tile_x_el = 0, tile_y_el = 0;
|
||||
if (isl_format_is_compressed(res->surf.format)) {
|
||||
|
@ -2738,6 +2726,18 @@ iris_create_surface(struct pipe_context *ctx,
|
|||
|
||||
surf->clear_color = res->aux.clear_color;
|
||||
|
||||
struct pipe_surface *psurf = &surf->base;
|
||||
pipe_reference_init(&psurf->reference, 1);
|
||||
pipe_resource_reference(&psurf->texture, tex);
|
||||
psurf->context = ctx;
|
||||
psurf->format = tmpl->format;
|
||||
psurf->width = isl_surf.logical_level0_px.width;
|
||||
psurf->height = isl_surf.logical_level0_px.height;
|
||||
psurf->texture = tex;
|
||||
psurf->u.tex.first_layer = tmpl->u.tex.first_layer;
|
||||
psurf->u.tex.last_layer = tmpl->u.tex.last_layer;
|
||||
psurf->u.tex.level = tmpl->u.tex.level;
|
||||
|
||||
/* Bail early for depth/stencil - we don't want SURFACE_STATE for them. */
|
||||
if (res->surf.usage & (ISL_SURF_USAGE_DEPTH_BIT |
|
||||
ISL_SURF_USAGE_STENCIL_BIT))
|
||||
|
@ -2776,9 +2776,6 @@ iris_create_surface(struct pipe_context *ctx,
|
|||
return psurf;
|
||||
}
|
||||
|
||||
psurf->width = isl_surf.logical_level0_px.width;
|
||||
psurf->height = isl_surf.logical_level0_px.height;
|
||||
|
||||
struct isl_surf_fill_state_info f = {
|
||||
.surf = &isl_surf,
|
||||
.view = view,
|
||||
|
|
Loading…
Reference in New Issue