minigbm: conditionally fallback to strip scanout use_flag
Only 2d virtgpu backend needs to fallback here because virtio primary plane only allows DRM_FORMAT_XRGB8888. Most our platforms cannot display YV12 (except msm), thus the fallback is required for the converted DRM_FORMAT_YVU420_ANDROID. For virgl backend, additionally append a BO_USE_LINEAR as a replacement for the hack inside compute_virgl_bind_flags. BUG=b:199524294 TEST=CQ TEST=gralloctest alloc_combinations TEST=android.media.cts.VideoDecoderRotationTest Change-Id: Ic87838ea2aae2b0abf87ed898ad75a3d7e556471 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3166775 Tested-by: Yiwei Zhang <zzyiwei@chromium.org> Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
This commit is contained in:
parent
9f390d92a4
commit
c1413ea43a
13 changed files with 51 additions and 16 deletions
1
amdgpu.c
1
amdgpu.c
|
|
@ -786,6 +786,7 @@ const struct backend backend_amdgpu = {
|
|||
.bo_unmap = amdgpu_unmap_bo,
|
||||
.bo_invalidate = amdgpu_bo_invalidate,
|
||||
.resolve_format = drv_resolve_format_helper,
|
||||
.resolve_use_flags = drv_resolve_use_flags_helper,
|
||||
.num_planes_from_modifier = dri_num_planes_from_modifier,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ bool cros_gralloc_driver::get_resolved_format_and_use_flags(
|
|||
if (resolved_format == DRM_FORMAT_NONE)
|
||||
return false;
|
||||
|
||||
resolved_use_flags = descriptor->use_flags;
|
||||
resolved_use_flags = drv_resolve_use_flags(drv_, resolved_format, descriptor->use_flags);
|
||||
/*
|
||||
* This unmask is a backup in the case DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED is resolved
|
||||
* to non-YUV formats.
|
||||
|
|
@ -153,10 +153,6 @@ bool cros_gralloc_driver::get_resolved_format_and_use_flags(
|
|||
}
|
||||
|
||||
combo = drv_get_combination(drv_, resolved_format, resolved_use_flags);
|
||||
if (!combo && (descriptor->droid_usage & GRALLOC_USAGE_HW_COMPOSER)) {
|
||||
resolved_use_flags &= ~BO_USE_SCANOUT;
|
||||
combo = drv_get_combination(drv_, resolved_format, resolved_use_flags);
|
||||
}
|
||||
if (!combo && (descriptor->droid_usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) &&
|
||||
descriptor->droid_format != HAL_PIXEL_FORMAT_YCbCr_420_888) {
|
||||
// Unmask BO_USE_HW_VIDEO_ENCODER for other formats. They are mostly
|
||||
|
|
|
|||
8
drv.c
8
drv.c
|
|
@ -659,6 +659,14 @@ uint32_t drv_resolve_format(struct driver *drv, uint32_t format, uint64_t use_fl
|
|||
return format;
|
||||
}
|
||||
|
||||
uint64_t drv_resolve_use_flags(struct driver *drv, uint32_t format, uint64_t use_flags)
|
||||
{
|
||||
if (drv->backend->resolve_use_flags)
|
||||
return drv->backend->resolve_use_flags(format, use_flags);
|
||||
|
||||
return use_flags;
|
||||
}
|
||||
|
||||
uint32_t drv_num_buffers_per_bo(struct bo *bo)
|
||||
{
|
||||
uint32_t count = 0;
|
||||
|
|
|
|||
2
drv.h
2
drv.h
|
|
@ -184,6 +184,8 @@ uint32_t drv_stride_from_format(uint32_t format, uint32_t width, size_t plane);
|
|||
|
||||
uint32_t drv_resolve_format(struct driver *drv, uint32_t format, uint64_t use_flags);
|
||||
|
||||
uint64_t drv_resolve_use_flags(struct driver *drv, uint32_t format, uint64_t use_flags);
|
||||
|
||||
size_t drv_num_planes_from_format(uint32_t format);
|
||||
|
||||
size_t drv_num_planes_from_modifier(struct driver *drv, uint32_t format, uint64_t modifier);
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ struct backend {
|
|||
int (*bo_invalidate)(struct bo *bo, struct mapping *mapping);
|
||||
int (*bo_flush)(struct bo *bo, struct mapping *mapping);
|
||||
uint32_t (*resolve_format)(uint32_t format, uint64_t use_flags);
|
||||
uint64_t (*resolve_use_flags)(uint32_t format, uint64_t use_flags);
|
||||
size_t (*num_planes_from_modifier)(struct driver *drv, uint32_t format, uint64_t modifier);
|
||||
int (*resource_info)(struct bo *bo, uint32_t strides[DRV_MAX_PLANES],
|
||||
uint32_t offsets[DRV_MAX_PLANES], uint64_t *format_modifier);
|
||||
|
|
|
|||
6
gbm.c
6
gbm.c
|
|
@ -140,9 +140,9 @@ PUBLIC struct gbm_bo *gbm_bo_create(struct gbm_device *gbm, uint32_t width, uint
|
|||
return NULL;
|
||||
|
||||
/*
|
||||
* HACK: This is for HAL_PIXEL_FORMAT_YV12 buffers allocated by arcvm. None of
|
||||
* our platforms can display YV12, so we can treat as a SW buffer. Remove once
|
||||
* this can be intelligently resolved in the guest. Also see compute_virgl_bind_flags.
|
||||
* HACK: See b/132939420. This is for HAL_PIXEL_FORMAT_YV12 buffers allocated by arcvm. None
|
||||
* of our platforms can display YV12, so we can treat as a SW buffer. Remove once this can
|
||||
* be intelligently resolved in the guest. Also see virgl_resolve_use_flags.
|
||||
*/
|
||||
if (format == GBM_FORMAT_YVU420 && (usage & GBM_BO_USE_LINEAR))
|
||||
format = DRM_FORMAT_YVU420_ANDROID;
|
||||
|
|
|
|||
|
|
@ -665,3 +665,11 @@ uint32_t drv_resolve_format_helper(uint32_t format, uint64_t use_flags)
|
|||
return format;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t drv_resolve_use_flags_helper(uint32_t format, uint64_t use_flags)
|
||||
{
|
||||
if (format == DRM_FORMAT_YVU420_ANDROID)
|
||||
return use_flags & ~BO_USE_SCANOUT;
|
||||
|
||||
return use_flags;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ uint64_t drv_pick_modifier(const uint64_t *modifiers, uint32_t count,
|
|||
bool drv_has_modifier(const uint64_t *list, uint32_t count, uint64_t modifier);
|
||||
uint32_t drv_get_standard_fourcc(uint32_t fourcc_internal);
|
||||
uint32_t drv_resolve_format_helper(uint32_t format, uint64_t use_flags);
|
||||
uint64_t drv_resolve_use_flags_helper(uint32_t format, uint64_t use_flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
1
i915.c
1
i915.c
|
|
@ -685,6 +685,7 @@ const struct backend backend_i915 = {
|
|||
.bo_invalidate = i915_bo_invalidate,
|
||||
.bo_flush = i915_bo_flush,
|
||||
.resolve_format = drv_resolve_format_helper,
|
||||
.resolve_use_flags = drv_resolve_use_flags_helper,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -303,6 +303,7 @@ const struct backend backend_mediatek = {
|
|||
.bo_invalidate = mediatek_bo_invalidate,
|
||||
.bo_flush = mediatek_bo_flush,
|
||||
.resolve_format = mediatek_resolve_format,
|
||||
.resolve_use_flags = drv_resolve_use_flags_helper,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -257,6 +257,7 @@ const struct backend backend_rockchip = {
|
|||
.bo_invalidate = rockchip_bo_invalidate,
|
||||
.bo_flush = rockchip_bo_flush,
|
||||
.resolve_format = drv_resolve_format_helper,
|
||||
.resolve_use_flags = drv_resolve_use_flags_helper,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -404,4 +404,5 @@ const struct backend virtgpu_cross_domain = {
|
|||
.bo_map = cross_domain_bo_map,
|
||||
.bo_unmap = drv_bo_munmap,
|
||||
.resolve_format = drv_resolve_format_helper,
|
||||
.resolve_use_flags = drv_resolve_use_flags_helper,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -426,14 +426,6 @@ static uint32_t compute_virgl_bind_flags(uint64_t use_flags, uint32_t format)
|
|||
handle_flag(&use_flags, BO_USE_HW_VIDEO_ENCODER, &bind,
|
||||
VIRGL_BIND_MINIGBM_HW_VIDEO_ENCODER);
|
||||
|
||||
/*
|
||||
* HACK: This is for HAL_PIXEL_FORMAT_YV12 buffers allocated by arcvm. None of
|
||||
* our platforms can display YV12, so we can treat as a SW buffer. Remove once
|
||||
* this can be intelligently resolved in the guest. Also see gbm_bo_create.
|
||||
*/
|
||||
if (format == DRM_FORMAT_YVU420_ANDROID)
|
||||
bind |= VIRGL_BIND_LINEAR;
|
||||
|
||||
if (use_flags)
|
||||
drv_log("Unhandled bo use flag: %llx\n", (unsigned long long)use_flags);
|
||||
|
||||
|
|
@ -960,6 +952,27 @@ static uint32_t virgl_resolve_format(uint32_t format, uint64_t use_flags)
|
|||
return format;
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t virgl_resolve_use_flags(uint32_t format, uint64_t use_flags)
|
||||
{
|
||||
if (format == DRM_FORMAT_YVU420_ANDROID) {
|
||||
use_flags &= ~BO_USE_SCANOUT;
|
||||
/*
|
||||
* HACK: See b/172389166. This is for HAL_PIXEL_FORMAT_YV12 buffers allocated by
|
||||
* arcvm. None of our platforms can display YV12, so we can treat as a SW buffer.
|
||||
* Remove once this can be intelligently resolved in the guest. Also see
|
||||
* gbm_bo_create.
|
||||
*/
|
||||
use_flags |= BO_USE_LINEAR;
|
||||
return use_flags;
|
||||
}
|
||||
|
||||
if (!params[param_3d].value && format != DRM_FORMAT_XRGB8888)
|
||||
return use_flags & ~BO_USE_SCANOUT;
|
||||
|
||||
return use_flags;
|
||||
}
|
||||
|
||||
static int virgl_resource_info(struct bo *bo, uint32_t strides[DRV_MAX_PLANES],
|
||||
uint32_t offsets[DRV_MAX_PLANES], uint64_t *format_modifier)
|
||||
{
|
||||
|
|
@ -1003,4 +1016,5 @@ const struct backend virtgpu_virgl = { .name = "virtgpu_virgl",
|
|||
.bo_invalidate = virgl_bo_invalidate,
|
||||
.bo_flush = virgl_bo_flush,
|
||||
.resolve_format = virgl_resolve_format,
|
||||
.resolve_use_flags = virgl_resolve_use_flags,
|
||||
.resource_info = virgl_resource_info };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue