diff options
author | Jason Macnak <natsu@google.com> | 2022-06-06 09:37:00 -0700 |
---|---|---|
committer | Jason Macnak <natsu@google.com> | 2022-06-06 09:48:11 -0700 |
commit | c616c5faa0da3df5d20cfb4ae69c393466c40dc0 (patch) | |
tree | f9e50ca8238cfab1eaabe1ddcb36c6934d536872 | |
parent | 335711e592d238b6fe30bf048ac7d9024d5bb638 (diff) | |
parent | f08bb293f6d9e99fd3205ea993d8a770bc16a0d5 (diff) | |
download | minigbm-c616c5faa0da3df5d20cfb4ae69c393466c40dc0.tar.gz |
Merge remote-tracking branch 'aosp/upstream-main' into 'aosp/master'
... to update Minigbm for Cuttlefish to pull in
https://crrev.com/c/3688450 to ensure TRANSFER_FROM_HOST copies happen
when `gralloc->lock()` is called on GPU_DATA_BUFFER usage buffers.
Bug: b/234513607
Test: launch_cvd --gpu_mode=guest_swiftshader
Test: launch_cvd --gpu_mode=gfxstream
Change-Id: I98cbc32a2418ffcf8b138084580e8a783bef7024
-rw-r--r-- | amdgpu.c | 9 | ||||
-rw-r--r-- | dri.c | 21 | ||||
-rw-r--r-- | rockchip.c | 27 | ||||
-rw-r--r-- | virtgpu_virgl.c | 2 |
4 files changed, 37 insertions, 22 deletions
@@ -517,10 +517,10 @@ static int amdgpu_create_bo_linear(struct bo *bo, uint32_t width, uint32_t heigh * aligned. This uses more memory than necessary since the first plane only needs to be * 256 aligned, but it's acceptable for a short-term fix. It's probably safe for other gpu * families, but let's restrict it to Raven and Stoney for now (b/171013552, b/190484589). + * This only applies to the Android YUV (multiplane) format. * */ - if (num_planes > 1 && - (priv->dev_info.family == AMDGPU_FAMILY_RV || - (priv->dev_info.family == AMDGPU_FAMILY_CZ && !(use_flags & BO_USE_HW_VIDEO_ENCODER)))) + if (format == DRM_FORMAT_YVU420_ANDROID && + (priv->dev_info.family == AMDGPU_FAMILY_RV || priv->dev_info.family == AMDGPU_FAMILY_CZ)) stride = ALIGN(stride, 512); else stride = ALIGN(stride, 256); @@ -625,6 +625,9 @@ static int amdgpu_import_bo(struct bo *bo, struct drv_import_fd_data *data) dri_tiling = combo->metadata.tiling != TILE_TYPE_LINEAR; } + bo->meta.num_planes = dri_num_planes_from_modifier(bo->drv, data->format, + data->format_modifier); + if (dri_tiling) return dri_bo_import(bo, data); else @@ -452,19 +452,18 @@ int dri_bo_unmap(struct bo *bo, struct vma *vma) size_t dri_num_planes_from_modifier(struct driver *drv, uint32_t format, uint64_t modifier) { struct dri_driver *dri = drv->priv; - if (!dri->image_extension->queryDmaBufFormatModifierAttribs) { - /* We do not do any modifier checks here. The create will fail - * later if the modifier is not supported. */ - return drv_num_planes_from_format(format); - } + uint64_t planes = 0; - uint64_t planes; - unsigned char ret = dri->image_extension->queryDmaBufFormatModifierAttribs( - dri->device, format, modifier, __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB_PLANE_COUNT, &planes); - if (!ret) - return 0; + /* We do not do any modifier checks here. The create will fail later if the modifier is not + * supported. + */ + if (dri->image_extension->queryDmaBufFormatModifierAttribs && + dri->image_extension->queryDmaBufFormatModifierAttribs( + dri->device, format, modifier, __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB_PLANE_COUNT, + &planes)) + return planes; - return planes; + return drv_num_planes_from_format(format); } bool dri_query_modifiers(struct driver *drv, uint32_t format, int max, uint64_t *modifiers, @@ -6,6 +6,7 @@ #ifdef DRV_ROCKCHIP +#include <drm_fourcc.h> #include <errno.h> #include <inttypes.h> #include <rockchip_drm.h> @@ -18,6 +19,10 @@ #include "drv_priv.h" #include "util.h" +#define DRM_FORMAT_MOD_ROCKCHIP_AFBC \ + DRM_FORMAT_MOD_ARM_AFBC(AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 | AFBC_FORMAT_MOD_SPARSE | \ + AFBC_FORMAT_MOD_YTR) + struct rockchip_private_map_data { void *cached_addr; void *gem_addr; @@ -30,7 +35,8 @@ static const uint32_t scanout_render_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORM static const uint32_t texture_only_formats[] = { DRM_FORMAT_NV12, DRM_FORMAT_YVU420, DRM_FORMAT_YVU420_ANDROID }; -static int afbc_bo_from_format(struct bo *bo, uint32_t width, uint32_t height, uint32_t format) +static int afbc_bo_from_format(struct bo *bo, uint32_t width, uint32_t height, uint32_t format, + uint64_t modifier) { /* We've restricted ourselves to four bytes per pixel. */ const uint32_t pixel_size = 4; @@ -69,7 +75,7 @@ static int afbc_bo_from_format(struct bo *bo, uint32_t width, uint32_t height, u bo->meta.total_size = total_size; - bo->meta.format_modifier = DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC; + bo->meta.format_modifier = modifier; return 0; } @@ -113,6 +119,14 @@ static int rockchip_bo_create_with_modifiers(struct bo *bo, uint32_t width, uint int ret; size_t plane; struct drm_rockchip_gem_create gem_create = { 0 }; + uint64_t afbc_modifier; + + if (drv_has_modifier(modifiers, count, DRM_FORMAT_MOD_ROCKCHIP_AFBC)) + afbc_modifier = DRM_FORMAT_MOD_ROCKCHIP_AFBC; + else if (drv_has_modifier(modifiers, count, DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC)) + afbc_modifier = DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC; + else + afbc_modifier = 0; if (format == DRM_FORMAT_NV12) { uint32_t w_mbs = DIV_ROUND_UP(width, 16); @@ -127,12 +141,10 @@ static int rockchip_bo_create_with_modifiers(struct bo *bo, uint32_t width, uint * driver to store motion vectors. */ bo->meta.total_size += w_mbs * h_mbs * 128; - } else if (width <= 2560 && - drv_has_modifier(modifiers, count, DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC) && - bo->drv->compression) { + } else if (width <= 2560 && afbc_modifier && bo->drv->compression) { /* If the caller has decided they can use AFBC, always * pick that */ - afbc_bo_from_format(bo, width, height, format); + afbc_bo_from_format(bo, width, height, format, afbc_modifier); } else { if (!drv_has_modifier(modifiers, count, DRM_FORMAT_MOD_LINEAR)) { errno = EINVAL; @@ -188,7 +200,8 @@ static void *rockchip_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint3 /* We can only map buffers created with SW access flags, which should * have no modifiers (ie, not AFBC). */ - if (bo->meta.format_modifier == DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC) + if (bo->meta.format_modifier == DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC || + bo->meta.format_modifier == DRM_FORMAT_MOD_ROCKCHIP_AFBC) return MAP_FAILED; gem_map.handle = bo->handles[0].u32; diff --git a/virtgpu_virgl.c b/virtgpu_virgl.c index d2e2e76..8bcfc9d 100644 --- a/virtgpu_virgl.c +++ b/virtgpu_virgl.c @@ -806,7 +806,7 @@ static int virgl_bo_invalidate(struct bo *bo, struct mapping *mapping) // Invalidate is only necessary if the host writes to the buffer. The encoder and // decoder flags don't differentiate between input and output buffers, but we can // use the format to determine whether this buffer could be encoder/decoder output. - host_write_flags = BO_USE_RENDERING | BO_USE_CAMERA_WRITE; + host_write_flags = BO_USE_RENDERING | BO_USE_CAMERA_WRITE | BO_USE_GPU_DATA_BUFFER; if (bo->meta.format == DRM_FORMAT_R8) host_write_flags |= BO_USE_HW_VIDEO_ENCODER; else |