Merge remote-tracking branch 'cros/main' into 'aosp/master'

Bug: 264408280
Test: build
Change-Id: I4e9f98e0d9626117860375732c4b5633c0e646f9
This commit is contained in:
Yiwei Zhang 2023-01-12 07:04:17 +00:00
commit 6e59e6f189
3 changed files with 39 additions and 28 deletions

5
dri.c
View file

@ -187,7 +187,7 @@ cleanup:
}
const __DRIuseInvalidateExtension use_invalidate = {
.base = { __DRI_USE_INVALIDATE, 1 }
.base = { __DRI_USE_INVALIDATE, 1 },
};
/*
@ -197,8 +197,7 @@ int dri_init(struct driver *drv, const char *dri_so_path, const char *driver_suf
{
char fname[128];
const __DRIextension **(*get_extensions)();
const __DRIextension *loader_extensions[] = { &use_invalidate.base,
NULL };
const __DRIextension *loader_extensions[] = { &use_invalidate.base, NULL };
struct dri_driver *dri = drv->priv;
char *node_name = drmGetRenderDeviceNameFromFd(drv_get_fd(drv));

45
i915.c
View file

@ -45,7 +45,7 @@ static const uint64_t gen11_modifier_order[] = { I915_FORMAT_MOD_Y_TILED, I915_F
DRM_FORMAT_MOD_LINEAR };
static const uint64_t xe_lpdp_modifier_order[] = { I915_FORMAT_MOD_4_TILED, I915_FORMAT_MOD_X_TILED,
DRM_FORMAT_MOD_LINEAR};
DRM_FORMAT_MOD_LINEAR };
struct modifier_support_t {
const uint64_t *order;
@ -271,47 +271,50 @@ static int i915_add_combinations(struct driver *drv)
if (i915->is_mtl) {
struct format_metadata metadata_4_tiled = { .tiling = I915_TILING_4,
.priority = 3,
.modifier = I915_FORMAT_MOD_4_TILED };
.priority = 3,
.modifier = I915_FORMAT_MOD_4_TILED };
/* Support tile4 NV12 and P010 for libva */
#ifdef I915_SCANOUT_4_TILED
const uint64_t nv12_usage =
BO_USE_TEXTURE | BO_USE_HW_VIDEO_DECODER | BO_USE_SCANOUT | hw_protected;
const uint64_t p010_usage = BO_USE_TEXTURE | BO_USE_HW_VIDEO_DECODER | hw_protected |
BO_USE_SCANOUT;
BO_USE_TEXTURE | BO_USE_HW_VIDEO_DECODER | BO_USE_SCANOUT | hw_protected;
const uint64_t p010_usage =
BO_USE_TEXTURE | BO_USE_HW_VIDEO_DECODER | hw_protected | BO_USE_SCANOUT;
#else
const uint64_t nv12_usage = BO_USE_TEXTURE | BO_USE_HW_VIDEO_DECODER;
const uint64_t p010_usage = nv12_usage;
#endif
drv_add_combination(drv, DRM_FORMAT_NV12, &metadata_4_tiled, nv12_usage);
drv_add_combination(drv, DRM_FORMAT_P010, &metadata_4_tiled, p010_usage);
drv_add_combinations(drv, render_formats, ARRAY_SIZE(render_formats), &metadata_4_tiled,
render_not_linear);
drv_add_combinations(drv, scanout_render_formats, ARRAY_SIZE(scanout_render_formats),
&metadata_4_tiled, render_not_linear);
drv_add_combinations(drv, render_formats, ARRAY_SIZE(render_formats),
&metadata_4_tiled, render_not_linear);
drv_add_combinations(drv, scanout_render_formats,
ARRAY_SIZE(scanout_render_formats), &metadata_4_tiled,
render_not_linear);
} else {
struct format_metadata metadata_y_tiled = { .tiling = I915_TILING_Y,
.priority = 3,
.modifier = I915_FORMAT_MOD_Y_TILED };
.priority = 3,
.modifier = I915_FORMAT_MOD_Y_TILED };
/* Support y-tiled NV12 and P010 for libva */
#ifdef I915_SCANOUT_Y_TILED
const uint64_t nv12_usage =
BO_USE_TEXTURE | BO_USE_HW_VIDEO_DECODER | BO_USE_SCANOUT | hw_protected;
const uint64_t p010_usage = BO_USE_TEXTURE | BO_USE_HW_VIDEO_DECODER | hw_protected |
(i915->graphics_version >= 11 ? BO_USE_SCANOUT : 0);
BO_USE_TEXTURE | BO_USE_HW_VIDEO_DECODER | BO_USE_SCANOUT | hw_protected;
const uint64_t p010_usage = BO_USE_TEXTURE | BO_USE_HW_VIDEO_DECODER |
hw_protected |
(i915->graphics_version >= 11 ? BO_USE_SCANOUT : 0);
#else
const uint64_t nv12_usage = BO_USE_TEXTURE | BO_USE_HW_VIDEO_DECODER;
const uint64_t p010_usage = nv12_usage;
#endif
drv_add_combination(drv, DRM_FORMAT_NV12, &metadata_y_tiled, nv12_usage);
drv_add_combination(drv, DRM_FORMAT_P010, &metadata_y_tiled, p010_usage);
drv_add_combinations(drv, render_formats, ARRAY_SIZE(render_formats), &metadata_y_tiled,
render_not_linear);
drv_add_combinations(drv, render_formats, ARRAY_SIZE(render_formats),
&metadata_y_tiled, render_not_linear);
/* Y-tiled scanout isn't available on old platforms so we add
* |scanout_render_formats| without that USE flag.
*/
drv_add_combinations(drv, scanout_render_formats, ARRAY_SIZE(scanout_render_formats),
&metadata_y_tiled, render_not_linear);
drv_add_combinations(drv, scanout_render_formats,
ARRAY_SIZE(scanout_render_formats), &metadata_y_tiled,
render_not_linear);
}
return 0;
}
@ -740,7 +743,7 @@ static int i915_bo_create_from_metadata(struct bo *bo)
/* Set/Get tiling ioctl not supported based on fence availability
Refer : "https://patchwork.freedesktop.org/patch/325343/"
*/
*/
if (i915->num_fences_avail) {
gem_set_tiling.handle = bo->handles[0].u32;
gem_set_tiling.tiling_mode = bo->meta.tiling;
@ -780,7 +783,7 @@ static int i915_bo_import(struct bo *bo, struct drv_import_fd_data *data)
/* Set/Get tiling ioctl not supported based on fence availability
Refer : "https://patchwork.freedesktop.org/patch/325343/"
*/
*/
if (i915->num_fences_avail) {
/* TODO(gsingh): export modifiers and get rid of backdoor tiling. */
gem_get_tiling.handle = bo->handles[0].u32;

View file

@ -985,22 +985,31 @@ static void virgl_3d_resolve_format_and_use_flags(struct driver *drv, uint32_t f
{
*out_format = format;
*out_use_flags = use_flags;
/* resolve flexible format into explicit format */
switch (format) {
case DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED:
/* Camera subsystem requires NV12. */
if (use_flags & (BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE)) {
*out_format = DRM_FORMAT_NV12;
} else {
/* HACK: See b/28671744 */
/* HACK: See b/28671744 and b/264408280 */
*out_format = DRM_FORMAT_XBGR8888;
*out_use_flags &= ~BO_USE_HW_VIDEO_ENCODER;
*out_use_flags |= BO_USE_LINEAR;
}
break;
case DRM_FORMAT_FLEX_YCbCr_420_888:
/* All of our host drivers prefer NV12 as their flexible media format.
* If that changes, this will need to be modified. */
*out_format = DRM_FORMAT_NV12;
/* fallthrough */
break;
default:
break;
}
/* resolve explicit format */
switch (*out_format) {
case DRM_FORMAT_NV12:
case DRM_FORMAT_ABGR8888:
case DRM_FORMAT_ARGB8888:
@ -1009,8 +1018,8 @@ static void virgl_3d_resolve_format_and_use_flags(struct driver *drv, uint32_t f
case DRM_FORMAT_XRGB8888:
/* These are the scanout capable formats to the guest. Strip scanout use_flag if the
* host does not natively support scanout on the requested format. */
if ((use_flags & BO_USE_SCANOUT) &&
!virgl_supports_combination_natively(drv, format, BO_USE_SCANOUT))
if ((*out_use_flags & BO_USE_SCANOUT) &&
!virgl_supports_combination_natively(drv, *out_format, BO_USE_SCANOUT))
*out_use_flags &= ~BO_USE_SCANOUT;
break;
case DRM_FORMAT_YVU420_ANDROID: