From 9cb0df4b50593e69f65b65704f5b64f3a12be9b5 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 May 2015 14:21:22 +0800 Subject: [PATCH] ilo: add ilo_image_disable_aux() When aux bo allocation fails, ilo_image_disable_aux() should be called to disable aux buffer. --- src/gallium/drivers/ilo/core/ilo_image.c | 19 +++++++++++++++++++ src/gallium/drivers/ilo/core/ilo_image.h | 5 ++++- src/gallium/drivers/ilo/ilo_resource.c | 12 +++++------- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/ilo/core/ilo_image.c b/src/gallium/drivers/ilo/core/ilo_image.c index cf6c17f..6310932 100644 --- a/src/gallium/drivers/ilo/core/ilo_image.c +++ b/src/gallium/drivers/ilo/core/ilo_image.c @@ -1445,3 +1445,22 @@ ilo_image_init_for_imported(struct ilo_image *img, return true; } + +bool +ilo_image_disable_aux(struct ilo_image *img, const struct ilo_dev *dev) +{ + /* HiZ is required for separate stencil on Gen6 */ + if (ilo_dev_gen(dev) == ILO_GEN(6) && + img->aux.type == ILO_IMAGE_AUX_HIZ && + img->separate_stencil) + return false; + + /* MCS is required for multisample images */ + if (img->aux.type == ILO_IMAGE_AUX_MCS && + img->sample_count > 1) + return false; + + img->aux.enables = 0x0; + + return true; +} diff --git a/src/gallium/drivers/ilo/core/ilo_image.h b/src/gallium/drivers/ilo/core/ilo_image.h index 8307cb6..af15e85 100644 --- a/src/gallium/drivers/ilo/core/ilo_image.h +++ b/src/gallium/drivers/ilo/core/ilo_image.h @@ -164,10 +164,13 @@ ilo_image_init_for_imported(struct ilo_image *img, enum gen_surface_tiling tiling, unsigned bo_stride); +bool +ilo_image_disable_aux(struct ilo_image *img, const struct ilo_dev *dev); + static inline bool ilo_image_can_enable_aux(const struct ilo_image *img, unsigned level) { - return (img->aux.bo && (img->aux.enables & (1 << level))); + return (img->aux.enables & (1 << level)); } /** diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c index 91e4d63..b6f5d26 100644 --- a/src/gallium/drivers/ilo/ilo_resource.c +++ b/src/gallium/drivers/ilo/ilo_resource.c @@ -288,15 +288,13 @@ tex_alloc_bos(struct ilo_texture *tex) switch (tex->image.aux.type) { case ILO_IMAGE_AUX_HIZ: - if (!tex_create_hiz(tex)) { - /* Separate Stencil Buffer requires HiZ to be enabled */ - if (ilo_dev_gen(&is->dev) == ILO_GEN(6) && - tex->image.separate_stencil) - return false; - } + if (!tex_create_hiz(tex) && + !ilo_image_disable_aux(&tex->image, &is->dev)) + return false; break; case ILO_IMAGE_AUX_MCS: - if (!tex_create_mcs(tex)) + if (!tex_create_mcs(tex) && + !ilo_image_disable_aux(&tex->image, &is->dev)) return false; break; default: -- 2.7.4