summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDawn Han <dawnhan@google.com>2023-02-17 17:32:05 +0000
committerYiwei Zhang <zzyiwei@chromium.org>2023-02-20 04:00:05 +0000
commitd77e164105c38a08817cb04276f30492ae9de229 (patch)
treef97a7950672d5598b5edb2a509ccdc766a37fd83
parentdeea0549d6f3ece0abd7547dedb0303d0dd081e1 (diff)
downloadminigbm-d77e164105c38a08817cb04276f30492ae9de229.tar.gz
minigbm: Relax the validateBufferSize check
Blob formats (aka buffers) get represented as R8 textures with height of one and width==size. These have no particular stride requirement, even though the host might ask for a pitch that would make sense for a 2D R8 texture with height greater than one. Relax the validateBufferSize check for format_blob rather than set the stride. As blob defined: buffers of this format must have a height of 1, so height doesn't need to be checked specifically. BUG=b:269565421 TEST=CQ Change-Id: I7a8d4dbf292330df0c24b502abd9dbf3dceac728 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4263402 Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
-rw-r--r--cros_gralloc/gralloc4/CrosGralloc4Mapper.cc8
-rw-r--r--virtgpu_cross_domain.c5
2 files changed, 7 insertions, 6 deletions
diff --git a/cros_gralloc/gralloc4/CrosGralloc4Mapper.cc b/cros_gralloc/gralloc4/CrosGralloc4Mapper.cc
index 65fc83c..90d9506 100644
--- a/cros_gralloc/gralloc4/CrosGralloc4Mapper.cc
+++ b/cros_gralloc/gralloc4/CrosGralloc4Mapper.cc
@@ -155,7 +155,13 @@ Return<Error> CrosGralloc4Mapper::validateBufferSize(void* rawHandle,
return Error::BAD_VALUE;
}
- if (stride != crosHandle->pixel_stride) {
+ if (crosHandle->droid_format == HAL_PIXEL_FORMAT_BLOB) {
+ if (stride > crosHandle->pixel_stride) {
+ ALOGE("Failed to validateBufferSize. Oversized stride (%d vs %d).", stride,
+ crosHandle->pixel_stride);
+ return Error::BAD_VALUE;
+ }
+ } else if (stride != crosHandle->pixel_stride) {
ALOGE("Failed to validateBufferSize. Stride mismatch (%d vs %d).", stride,
crosHandle->pixel_stride);
return Error::BAD_VALUE;
diff --git a/virtgpu_cross_domain.c b/virtgpu_cross_domain.c
index 4af9c3a..b94a4ae 100644
--- a/virtgpu_cross_domain.c
+++ b/virtgpu_cross_domain.c
@@ -196,11 +196,6 @@ static int cross_domain_metadata_query(struct driver *drv, struct bo_metadata *m
metadata->memory_idx = addr[14];
metadata->physical_device_idx = addr[15];
- /* Detect buffers, which have no particular stride alignment requirement: */
- if ((metadata->height == 1) && (metadata->format == DRM_FORMAT_R8)) {
- metadata->strides[0] = metadata->width;
- }
-
remaining_size = metadata->total_size;
for (plane = 0; plane < metadata->num_planes; plane++) {
if (plane != 0) {