virtgpu: improve blob support on ARCVM
This change expands the types of buffers which use blob allocation, to
cover decoder/encoder bitstream buffers. It also adds tiling to the
exported buffer metadata, so that flush/invalidate are properly skipped
on imported blob buffers.
BUG=None
TEST=tast run ARCVM-DUT arc.VideoDecodeAccel.*
Change-Id: I460f4448db9e1bd2f7458f3180c4e92ff3b3d74f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2400839
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: David Stevens <stevensd@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
diff --git a/cros_gralloc/cros_gralloc_driver.cc b/cros_gralloc/cros_gralloc_driver.cc
index a7174d7..ab7c654 100644
--- a/cros_gralloc/cros_gralloc_driver.cc
+++ b/cros_gralloc/cros_gralloc_driver.cc
@@ -217,6 +217,7 @@
hnd->width = drv_bo_get_width(bo);
hnd->height = drv_bo_get_height(bo);
hnd->format = drv_bo_get_format(bo);
+ hnd->tiling = bo->meta.tiling;
hnd->format_modifier = drv_bo_get_plane_format_modifier(bo, 0);
hnd->use_flags = descriptor->use_flags;
bytes_per_pixel = drv_bytes_per_pixel_from_format(hnd->format, 0);
@@ -271,6 +272,7 @@
struct bo *bo;
struct drv_import_fd_data data;
data.format = hnd->format;
+ data.tiling = hnd->tiling;
data.width = hnd->width;
data.height = hnd->height;
@@ -503,4 +505,4 @@
for (const auto &pair : handles_) {
function(pair.first);
}
-}
\ No newline at end of file
+}
diff --git a/cros_gralloc/cros_gralloc_handle.h b/cros_gralloc/cros_gralloc_handle.h
index d2e1607..b5525d1 100644
--- a/cros_gralloc/cros_gralloc_handle.h
+++ b/cros_gralloc/cros_gralloc_handle.h
@@ -31,6 +31,7 @@
uint32_t width;
uint32_t height;
uint32_t format; /* DRM format */
+ uint32_t tiling;
uint64_t format_modifier;
uint64_t use_flags; /* Buffer creation flags */
uint32_t magic;
diff --git a/drv.h b/drv.h
index f19f9de..4a47b76 100644
--- a/drv.h
+++ b/drv.h
@@ -89,6 +89,7 @@
uint32_t width;
uint32_t height;
uint32_t format;
+ uint32_t tiling;
uint64_t use_flags;
};
diff --git a/helpers.c b/helpers.c
index 17b1765..1b5c2a8 100644
--- a/helpers.c
+++ b/helpers.c
@@ -451,6 +451,7 @@
bo->handles[plane].u32 = prime_handle.handle;
}
+ bo->meta.tiling = data->tiling;
return 0;
}
diff --git a/virtio_gpu.c b/virtio_gpu.c
index 38d0249..f9c13f4 100644
--- a/virtio_gpu.c
+++ b/virtio_gpu.c
@@ -687,10 +687,15 @@
uint32_t cmd[VIRGL_PIPE_RES_CREATE_SIZE + 1] = { 0 };
struct drm_virtgpu_resource_create_blob drm_rc_blob = { 0 };
+ uint32_t blob_flags = VIRTGPU_BLOB_FLAG_USE_MAPPABLE | VIRTGPU_BLOB_FLAG_USE_SHAREABLE;
+ if (bo->meta.use_flags & BO_USE_NON_GPU_HW) {
+ blob_flags |= VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE;
+ }
+
stride = drv_stride_from_format(bo->meta.format, bo->meta.width, 0);
drv_bo_from_format(bo, stride, bo->meta.height, bo->meta.format);
bo->meta.total_size = ALIGN(bo->meta.total_size, PAGE_SIZE);
- bo->meta.tiling = VIRTGPU_BLOB_FLAG_USE_MAPPABLE | VIRTGPU_BLOB_FLAG_USE_SHAREABLE;
+ bo->meta.tiling = blob_flags;
cmd[0] = VIRGL_CMD0(VIRGL_CCMD_PIPE_RESOURCE_CREATE, 0, VIRGL_PIPE_RES_CREATE_SIZE);
cmd[VIRGL_PIPE_RES_CREATE_TARGET] = PIPE_TEXTURE_2D;
@@ -704,7 +709,7 @@
drm_rc_blob.cmd_size = 4 * (VIRGL_PIPE_RES_CREATE_SIZE + 1);
drm_rc_blob.size = bo->meta.total_size;
drm_rc_blob.blob_mem = VIRTGPU_BLOB_MEM_HOST3D;
- drm_rc_blob.blob_flags = VIRTGPU_BLOB_FLAG_USE_MAPPABLE | VIRTGPU_BLOB_FLAG_USE_SHAREABLE;
+ drm_rc_blob.blob_flags = blob_flags;
ret = drmIoctl(drv->fd, DRM_IOCTL_VIRTGPU_RESOURCE_CREATE_BLOB, &drm_rc_blob);
if (ret < 0) {
@@ -731,16 +736,16 @@
if (!priv->host_gbm_enabled)
return false;
- // Focus on SW read/write apps for now
- if (use_flags & (BO_USE_RENDERING | BO_USE_HW_VIDEO_ENCODER | BO_USE_HW_VIDEO_DECODER))
+ // Focus on non-GPU apps for now
+ if (use_flags & (BO_USE_RENDERING | BO_USE_TEXTURE))
return false;
// Simple, strictly defined formats for now
- if (format != DRM_FORMAT_YVU420_ANDROID || format != DRM_FORMAT_R8)
+ if (format != DRM_FORMAT_YVU420_ANDROID && format != DRM_FORMAT_R8)
return false;
- if (use_flags & (BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN | BO_USE_LINEAR |
- BO_USE_CAMERA_WRITE | BO_USE_CAMERA_READ))
+ if (use_flags &
+ (BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN | BO_USE_LINEAR | BO_USE_NON_GPU_HW))
return true;
return false;