radeonsi: return success/failure from si_alloc_separate_cmask

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9795>
This commit is contained in:
Marek Olšák 2021-03-19 20:43:59 -04:00 committed by Marge Bot
parent 8cd61d1248
commit 1936a046b1
1 changed files with 9 additions and 6 deletions

View File

@ -77,24 +77,28 @@ void si_execute_clears(struct si_context *sctx, struct si_clear_info *info,
sctx->flags |= SI_CONTEXT_WB_L2; sctx->flags |= SI_CONTEXT_WB_L2;
} }
static void si_alloc_separate_cmask(struct si_screen *sscreen, struct si_texture *tex) static bool si_alloc_separate_cmask(struct si_screen *sscreen, struct si_texture *tex)
{ {
/* CMASK for MSAA is allocated in advance or always disabled /* CMASK for MSAA is allocated in advance or always disabled
* by "nofmask" option. * by "nofmask" option.
*/ */
if (tex->cmask_buffer || !tex->surface.cmask_size || tex->buffer.b.b.nr_samples >= 2) if (tex->cmask_buffer)
return; return true;
if (!tex->surface.cmask_size)
return false;
tex->cmask_buffer = tex->cmask_buffer =
si_aligned_buffer_create(&sscreen->b, SI_RESOURCE_FLAG_UNMAPPABLE, PIPE_USAGE_DEFAULT, si_aligned_buffer_create(&sscreen->b, SI_RESOURCE_FLAG_UNMAPPABLE, PIPE_USAGE_DEFAULT,
tex->surface.cmask_size, tex->surface.cmask_alignment); tex->surface.cmask_size, tex->surface.cmask_alignment);
if (tex->cmask_buffer == NULL) if (tex->cmask_buffer == NULL)
return; return false;
tex->cmask_base_address_reg = tex->cmask_buffer->gpu_address >> 8; tex->cmask_base_address_reg = tex->cmask_buffer->gpu_address >> 8;
tex->cb_color_info |= S_028C70_FAST_CLEAR(1); tex->cb_color_info |= S_028C70_FAST_CLEAR(1);
p_atomic_inc(&sscreen->compressed_colortex_counter); p_atomic_inc(&sscreen->compressed_colortex_counter);
return true;
} }
static bool si_set_clear_color(struct si_texture *tex, enum pipe_format surface_format, static bool si_set_clear_color(struct si_texture *tex, enum pipe_format surface_format,
@ -576,8 +580,7 @@ static void si_do_fast_color_clear(struct si_context *sctx, unsigned *buffers,
continue; continue;
/* ensure CMASK is enabled */ /* ensure CMASK is enabled */
si_alloc_separate_cmask(sctx->screen, tex); if (!si_alloc_separate_cmask(sctx->screen, tex))
if (!tex->cmask_buffer)
continue; continue;
/* Do the fast clear. */ /* Do the fast clear. */