Skip to content

Commit

Permalink
minigbm: passthrough GPU_DATA_BUFFER via gbm frontend
Browse files Browse the repository at this point in the history
This is required for modern Android atop a gralloc with the cross_domain
backend or other native backend.

BUG=b:238609372
TEST=build and AHB cts

Change-Id: Id963eeec62c4400cc009384e127c93588c99346e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3777566
Auto-Submit: Yiwei Zhang <[email protected]>
Tested-by: Yiwei Zhang <[email protected]>
Reviewed-by: Jason Macnak <[email protected]>
Commit-Queue: Yiwei Zhang <[email protected]>
  • Loading branch information
zhangyiwei authored and Chromeos LUCI committed Jul 21, 2022
1 parent 29daef0 commit bbe1fd3
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion amdgpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ static int amdgpu_init(struct driver *drv)
*/
drv_modify_combination(drv, DRM_FORMAT_R8, &metadata,
BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE | BO_USE_HW_VIDEO_DECODER |
BO_USE_HW_VIDEO_ENCODER);
BO_USE_HW_VIDEO_ENCODER | BO_USE_GPU_DATA_BUFFER);

/*
* The following formats will be allocated by the DRI backend and may be potentially tiled.
Expand Down
3 changes: 2 additions & 1 deletion dumb_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ static int dumb_driver_init(struct driver *drv)

drv_modify_combination(drv, DRM_FORMAT_R8, &LINEAR_METADATA,
BO_USE_HW_VIDEO_ENCODER | BO_USE_HW_VIDEO_DECODER |
BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE);
BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE |
BO_USE_GPU_DATA_BUFFER);
drv_modify_combination(drv, DRM_FORMAT_NV12, &LINEAR_METADATA,
BO_USE_HW_VIDEO_ENCODER | BO_USE_HW_VIDEO_DECODER |
BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE);
Expand Down
10 changes: 10 additions & 0 deletions gbm.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,16 @@ enum gbm_bo_flags {
* with pixel data.
*/
GBM_BO_USE_FRONT_RENDERING = (1 << 16),

/**
* (1 << 17) is reserved for RenderScript (deprecated in Android 12).
*/

/**
* The buffer will be used as a shader storage or uniform buffer
* object.
*/
GBM_BO_USE_GPU_DATA_BUFFER = (1 << 18),
};

int
Expand Down
2 changes: 2 additions & 0 deletions gbm_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ uint64_t gbm_convert_usage(uint32_t usage)
use_flags |= BO_USE_HW_VIDEO_ENCODER;
if (usage & GBM_BO_USE_FRONT_RENDERING)
use_flags |= BO_USE_FRONT_RENDERING;
if (usage & GBM_BO_USE_GPU_DATA_BUFFER)
use_flags |= BO_USE_GPU_DATA_BUFFER;

return use_flags;
}
2 changes: 1 addition & 1 deletion i915.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static int i915_add_combinations(struct driver *drv)
*/
drv_modify_combination(drv, DRM_FORMAT_R8, &metadata_linear,
BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE | BO_USE_HW_VIDEO_DECODER |
BO_USE_HW_VIDEO_ENCODER);
BO_USE_HW_VIDEO_ENCODER | BO_USE_GPU_DATA_BUFFER);

const uint64_t render_not_linear = unset_flags(render, linear_mask);
const uint64_t scanout_and_render_not_linear = render_not_linear | BO_USE_SCANOUT;
Expand Down
3 changes: 2 additions & 1 deletion mediatek.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ static int mediatek_init(struct driver *drv)
*/
drv_modify_combination(drv, DRM_FORMAT_R8, &metadata,
BO_USE_HW_VIDEO_DECODER | BO_USE_HW_VIDEO_ENCODER |
BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE);
BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE |
BO_USE_GPU_DATA_BUFFER);

/* NV12 format for encoding and display. */
drv_modify_combination(drv, DRM_FORMAT_NV12, &metadata,
Expand Down
4 changes: 2 additions & 2 deletions msm.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static void msm_calculate_layout(struct bo *bo)
DRM_FORMAT_R8 of height one is used for JPEG camera output, so don't
height align that. */
if (bo->meta.format == DRM_FORMAT_YVU420_ANDROID ||
bo->meta.format == DRM_FORMAT_YVU420 ||
bo->meta.format == DRM_FORMAT_YVU420 ||
(bo->meta.format == DRM_FORMAT_R8 && height == 1)) {
assert(bo->meta.tiling != MSM_UBWC_TILING);
alignh = height;
Expand Down Expand Up @@ -260,7 +260,7 @@ static int msm_init(struct driver *drv)
*/
drv_modify_combination(drv, DRM_FORMAT_R8, &LINEAR_METADATA,
BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE | BO_USE_HW_VIDEO_DECODER |
BO_USE_HW_VIDEO_ENCODER);
BO_USE_HW_VIDEO_ENCODER | BO_USE_GPU_DATA_BUFFER);

/*
* Android also frequently requests YV12 formats for some camera implementations
Expand Down
3 changes: 2 additions & 1 deletion rockchip.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ static int rockchip_init(struct driver *drv)
*/
drv_add_combination(drv, DRM_FORMAT_R8, &metadata,
BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE | BO_USE_SW_MASK |
BO_USE_LINEAR | BO_USE_HW_VIDEO_DECODER | BO_USE_HW_VIDEO_ENCODER);
BO_USE_LINEAR | BO_USE_HW_VIDEO_DECODER | BO_USE_HW_VIDEO_ENCODER |
BO_USE_GPU_DATA_BUFFER);

return 0;
}
Expand Down

0 comments on commit bbe1fd3

Please sign in to comment.