* Configure aux for the resource, but don't allocate it. For images which
* might be shared with modifiers, we must allocate the image and aux data in
* a single bo.
+ *
+ * Returns false on unexpected error (e.g. allocation failed, or invalid
+ * configuration result).
*/
static bool
iris_resource_configure_aux(struct iris_screen *screen,
/**
* Initialize the aux buffer contents.
+ *
+ * Returns false on unexpected error (e.g. mapping a BO failed).
*/
static bool
iris_resource_init_aux_buf(struct iris_resource *res, uint32_t alloc_flags,
if (!(alloc_flags & BO_ALLOC_ZEROED)) {
void *map = iris_bo_map(NULL, res->aux.bo, MAP_WRITE | MAP_RAW);
- if (!map) {
- iris_resource_disable_aux(res);
+ if (!map)
return false;
- }
if (iris_resource_get_aux_state(res, 0, 0) != ISL_AUX_STATE_AUX_INVALID) {
uint8_t memset_value = isl_aux_usage_has_mcs(res->aux.usage) ? 0xFF : 0;
/**
* Allocate the initial aux surface for a resource based on aux.usage
+ *
+ * Returns false on unexpected error (e.g. allocation failed, or invalid
+ * configuration result).
*/
static bool
iris_resource_alloc_separate_aux(struct iris_screen *screen,
uint32_t aux_preferred_alloc_flags;
uint64_t aux_size = 0;
- bool aux_enabled =
- iris_resource_configure_aux(screen, res, false, &aux_size,
- &aux_preferred_alloc_flags);
- aux_enabled = aux_enabled && res->aux.surf.size_B > 0;
+ if (!iris_resource_configure_aux(screen, res, false, &aux_size,
+ &aux_preferred_alloc_flags)) {
+ goto fail;
+ }
+
+ const bool aux_enabled = res->aux.surf.size_B > 0;
const bool separate_aux = aux_enabled && !res->mod_info;
uint64_t aux_offset;
uint64_t bo_size;
if (aux_enabled) {
if (separate_aux) {
if (!iris_resource_alloc_separate_aux(screen, res))
- aux_enabled = false;
+ goto fail;
} else {
res->aux.bo = res->bo;
iris_bo_reference(res->aux.bo);
if (clear_color_state_size > 0)
res->aux.clear_color_offset += aux_offset;
if (!iris_resource_init_aux_buf(res, flags, clear_color_state_size))
- aux_enabled = false;
+ goto fail;
map_aux_addresses(screen, res);
}
}
- if (!aux_enabled) {
- if (res->mod_info && res->mod_info->aux_usage != ISL_AUX_USAGE_NONE)
- goto fail;
- else
- iris_resource_disable_aux(res);
- }
-
return &res->base;
fail: