From 60f464bbce963704290a793c2b9637f7ed3aded3 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 5 Oct 2021 12:33:15 -0700 Subject: [PATCH] i915g: Check for the scanout-layout conditions before setting level info. Fixes leaks (release) or assertion failures (debug) on allocating small scanout resources, when falling through to the non-scanout-specific layout code, which became more common as of ad50b47a14e9 ("gbm: assume USE_SCANOUT in create_with_modifiers"). Cc: mesa-stable Part-of: --- src/gallium/drivers/i915/i915_resource_texture.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/i915/i915_resource_texture.c b/src/gallium/drivers/i915/i915_resource_texture.c index aac9756c1ed..75a1ce5bf16 100644 --- a/src/gallium/drivers/i915/i915_resource_texture.c +++ b/src/gallium/drivers/i915/i915_resource_texture.c @@ -193,9 +193,6 @@ i9x5_scanout_layout(struct i915_texture *tex) if (pt->last_level > 0 || util_format_get_blocksize(pt->format) != 4) return false; - i915_texture_set_level_info(tex, 0, 1); - i915_texture_set_image_offset(tex, 0, 0, 0, 0); - if (pt->width0 >= 240) { tex->stride = align(util_format_get_stride(pt->format, pt->width0), 64); tex->total_nblocksy = align_nblocksy(pt->format, pt->height0, 8); @@ -208,6 +205,10 @@ i9x5_scanout_layout(struct i915_texture *tex) return false; } + i915_texture_set_level_info(tex, 0, 1); + i915_texture_set_image_offset(tex, 0, 0, 0, 0); + + #if DEBUG_TEXTURE debug_printf("%s size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__, pt->width0, pt->height0, util_format_get_blocksize(pt->format),