struct winsys_handle *whandle,
unsigned usage)
{
+ assert(templ->target != PIPE_BUFFER);
+
struct iris_screen *screen = (struct iris_screen *)pscreen;
struct iris_bufmgr *bufmgr = screen->bufmgr;
struct iris_resource *res = iris_alloc_resource(pscreen, templ);
res->offset = whandle->offset;
res->external_format = whandle->format;
- if (templ->target == PIPE_BUFFER) {
- res->surf.tiling = ISL_TILING_LINEAR;
+ /* Create a surface for each plane specified by the external format. */
+ if (whandle->plane < util_format_get_num_planes(whandle->format)) {
+
+ const uint64_t modifier =
+ whandle->modifier != DRM_FORMAT_MOD_INVALID ?
+ whandle->modifier : tiling_to_modifier(res->bo->tiling_mode);
+
+ UNUSED const bool isl_surf_created_successfully =
+ iris_resource_configure_main(screen, res, templ, modifier,
+ whandle->stride);
+ assert(isl_surf_created_successfully);
+ assert(res->bo->tiling_mode ==
+ isl_tiling_to_i915_tiling(res->surf.tiling));
+
+ UNUSED const bool ok = iris_resource_configure_aux(screen, res, true);
+ assert(ok);
+ /* The gallium dri layer will create a separate plane resource for the
+ * aux image. iris_resource_finish_aux_import will merge the separate aux
+ * parameters back into a single iris_resource.
+ */
} else {
- /* Create a surface for each plane specified by the external format. */
- if (whandle->plane < util_format_get_num_planes(whandle->format)) {
-
- const uint64_t modifier =
- whandle->modifier != DRM_FORMAT_MOD_INVALID ?
- whandle->modifier : tiling_to_modifier(res->bo->tiling_mode);
-
- UNUSED const bool isl_surf_created_successfully =
- iris_resource_configure_main(screen, res, templ, modifier,
- whandle->stride);
- assert(isl_surf_created_successfully);
- assert(res->bo->tiling_mode ==
- isl_tiling_to_i915_tiling(res->surf.tiling));
-
- UNUSED const bool ok = iris_resource_configure_aux(screen, res, true);
- assert(ok);
- /* The gallium dri layer will create a separate plane resource
- * for the aux image. iris_resource_finish_aux_import will
- * merge the separate aux parameters back into a single
- * iris_resource.
- */
- } else {
- /* Save modifier import information to reconstruct later. After
- * import, this will be available under a second image accessible
- * from the main image with res->base.next. See
- * iris_resource_finish_aux_import.
- */
- res->aux.surf.row_pitch_B = whandle->stride;
- res->aux.offset = whandle->offset;
- res->aux.bo = res->bo;
- res->bo = NULL;
- }
+ /* Save modifier import information to reconstruct later. After import,
+ * this will be available under a second image accessible from the main
+ * image with res->base.next. See iris_resource_finish_aux_import.
+ */
+ res->aux.surf.row_pitch_B = whandle->stride;
+ res->aux.offset = whandle->offset;
+ res->aux.bo = res->bo;
+ res->bo = NULL;
}
return &res->base;
#ifndef NDEBUG
enum isl_aux_usage allowed_usage =
+ usage & PIPE_HANDLE_USAGE_EXPLICIT_FLUSH ? res->aux.usage :
res->mod_info ? res->mod_info->aux_usage : ISL_AUX_USAGE_NONE;
if (res->aux.usage != allowed_usage) {
usage |= PIPE_TRANSFER_UNSYNCHRONIZED;
}
- bool need_resolve = false;
- bool need_color_resolve = false;
-
- if (resource->target != PIPE_BUFFER) {
- bool need_hiz_resolve = iris_resource_level_has_hiz(res, level);
- bool need_stencil_resolve = res->aux.usage == ISL_AUX_USAGE_STC_CCS;
-
- need_color_resolve =
- (res->aux.usage == ISL_AUX_USAGE_CCS_D ||
- res->aux.usage == ISL_AUX_USAGE_CCS_E ||
- res->aux.usage == ISL_AUX_USAGE_GEN12_CCS_E) &&
- iris_has_color_unresolved(res, level, 1, box->z, box->depth);
-
- need_resolve = need_color_resolve ||
- need_hiz_resolve ||
- need_stencil_resolve;
- }
-
bool map_would_stall = false;
if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
- map_would_stall = need_resolve || resource_is_busy(ice, res);
+ map_would_stall =
+ resource_is_busy(ice, res) ||
+ iris_has_invalid_primary(res, level, 1, box->z, box->depth);
if (map_would_stall && (usage & PIPE_TRANSFER_DONTBLOCK) &&
(usage & PIPE_TRANSFER_MAP_DIRECTLY))
* read from the original buffer, we'd simply copy it to a temporary...
* then stall (a bit longer) to read from that buffer.
*
- * Images are less clear-cut. Color resolves are destructive, removing
- * the underlying compression, so we'd rather blit the data to a linear
+ * Images are less clear-cut. Resolves can be destructive, removing some
+ * of the underlying compression, so we'd rather blit the data to a linear
* temporary and map that, to avoid the resolve. (It might be better to
* a tiled temporary and use the tiled_memcpy paths...)
*/
- if (!(usage & PIPE_TRANSFER_DISCARD_RANGE) && !need_color_resolve)
+ if (!(usage & PIPE_TRANSFER_DISCARD_RANGE) &&
+ !iris_has_invalid_primary(res, level, 1, box->z, box->depth)) {
no_gpu = true;
+ }
const struct isl_format_layout *fmtl = isl_format_get_layout(surf->format);
if (fmtl->txc == ISL_TXC_ASTC)
no_gpu = true;
- if ((map_would_stall ||
- res->aux.usage == ISL_AUX_USAGE_CCS_E ||
- res->aux.usage == ISL_AUX_USAGE_GEN12_CCS_E) && !no_gpu) {
+ if (!map_would_stall &&
+ res->aux.usage != ISL_AUX_USAGE_CCS_E &&
+ res->aux.usage != ISL_AUX_USAGE_GEN12_CCS_E) {
+ no_gpu = true;
+ }
+
+ if (!no_gpu) {
/* If we need a synchronous mapping and the resource is busy, or needs
* resolving, we copy to/from a linear temporary buffer using the GPU.
*/
} else {
/* Otherwise we're free to map on the CPU. */
- if (need_resolve) {
+ if (resource->target != PIPE_BUFFER) {
iris_resource_access_raw(ice, res, level, box->z, box->depth,
usage & PIPE_TRANSFER_WRITE);
}