intel/aux_map: Add and use INTEL_AUX_MAP_MAIN_PITCH_SCALEDOWN

Introduce a macro so that drivers don't need to rely on the isl_surf
struct to determine the pitch of the CCS buffer on gfx12. This is useful
during layout queries of dmabufs.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28942>
This commit is contained in:
Nanley Chery 2024-03-07 18:31:35 -05:00 committed by Marge Bot
parent e9653b5833
commit e27d951527
3 changed files with 30 additions and 5 deletions

View file

@ -1325,8 +1325,15 @@ iris_resource_from_handle(struct pipe_screen *pscreen,
assert(!devinfo->has_flat_ccs);
assert(plane_res->bo->size >= plane_res->offset +
main_res->aux.surf.size_B);
assert(main_res->aux.surf.row_pitch_B ==
plane_res->surf.row_pitch_B);
if (devinfo->has_aux_map) {
assert(plane_res->surf.row_pitch_B ==
main_res->surf.row_pitch_B /
INTEL_AUX_MAP_MAIN_PITCH_SCALEDOWN);
} else {
assert(plane_res->surf.row_pitch_B ==
main_res->aux.surf.row_pitch_B);
}
iris_bo_reference(plane_res->bo);
main_res->aux.bo = plane_res->bo;
@ -1670,8 +1677,15 @@ iris_resource_get_param(struct pipe_screen *pscreen,
}
return true;
case PIPE_RESOURCE_PARAM_STRIDE:
*value = wants_cc ? ISL_DRM_CC_PLANE_PITCH_B :
wants_aux ? res->aux.surf.row_pitch_B : res->surf.row_pitch_B;
if (wants_cc) {
*value = ISL_DRM_CC_PLANE_PITCH_B;
} else if (wants_aux) {
*value = screen->devinfo->has_aux_map ?
res->surf.row_pitch_B / INTEL_AUX_MAP_MAIN_PITCH_SCALEDOWN :
res->aux.surf.row_pitch_B;
} else {
*value = res->surf.row_pitch_B;
}
/* Mesa's implementation of eglCreateImage rejects strides of zero (see
* dri2_check_dma_buf_attribs). Ensure we return a non-zero stride as

View file

@ -45,6 +45,16 @@ struct intel_device_info;
#define INTEL_AUX_MAP_ENTRY_VALID_BIT 0x1ull
/**
* The ratio between the granularity of main surface pitch and AUX data pitch
* (when viewed as a surface).
*
* In agreement with Bspec 44930, the kernel expects that every 512B of the
* main surface pitch maps to 64B of the AUX data pitch. This is not
* documented in drm_fourcc.h.
*/
#define INTEL_AUX_MAP_MAIN_PITCH_SCALEDOWN (512 / 64)
struct intel_aux_map_context *
intel_aux_map_init(void *driver_ctx,
struct intel_mapped_pinned_buffer_alloc *buffer_alloc,

View file

@ -2601,7 +2601,8 @@ anv_get_image_subresource_layout(const struct anv_image *image,
assert(isl_drm_modifier_has_aux(image->vk.drm_format_mod));
mem_range = &image->planes[0].compr_ctrl_memory_range;
row_pitch_B = image->planes[0].aux_surface.isl.row_pitch_B;
row_pitch_B = image->planes[0].primary_surface.isl.row_pitch_B /
INTEL_AUX_MAP_MAIN_PITCH_SCALEDOWN;
} else if (mem_plane == 1 &&
image->planes[0].aux_surface.memory_range.size > 0) {
assert(image->n_planes == 1);