Add depth buffer support for virtgpu virgl

Bug: b:347022601
Test: Ran app that export/import depth through AHB with cf

Change-Id: I07e60729b18a9f15e0d795c33c462ba4b4f255b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5636740
Tested-by: Jean-François Thibert <jfthibert@google.com>
Reviewed-by: Dawn Han <dawnhan@google.com>
Commit-Queue: Jean-François Thibert <jfthibert@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
This commit is contained in:
Jean-Francois Thibert 2024-06-17 15:13:27 -04:00 committed by Chromeos LUCI
parent 698c5e9e8d
commit 6158bc1fdc
4 changed files with 41 additions and 0 deletions

View file

@ -51,6 +51,11 @@ static const uint32_t texture_source_formats[] = {
DRM_FORMAT_YVU420_ANDROID, DRM_FORMAT_ABGR2101010, DRM_FORMAT_ABGR16161616F
};
static const uint32_t depth_stencil_formats[] = {
DRM_FORMAT_DEPTH16, DRM_FORMAT_DEPTH24, DRM_FORMAT_DEPTH24_STENCIL8,
DRM_FORMAT_DEPTH32, DRM_FORMAT_DEPTH32_STENCIL8
};
extern struct virtgpu_param params[];
struct virgl_blob_metadata_cache {
@ -107,6 +112,16 @@ static uint32_t translate_format(uint32_t drm_fourcc)
case DRM_FORMAT_YVU420:
case DRM_FORMAT_YVU420_ANDROID:
return VIRGL_FORMAT_YV12;
case DRM_FORMAT_DEPTH16:
return VIRGL_FORMAT_Z16_UNORM;
case DRM_FORMAT_DEPTH24:
return VIRGL_FORMAT_Z24X8_UNORM;
case DRM_FORMAT_DEPTH24_STENCIL8:
return VIRGL_FORMAT_Z24_UNORM_S8_UINT;
case DRM_FORMAT_DEPTH32:
return VIRGL_FORMAT_Z32_FLOAT;
case DRM_FORMAT_DEPTH32_STENCIL8:
return VIRGL_FORMAT_Z32_FLOAT_S8X24_UINT;
default:
drv_loge("Unhandled format:%d\n", drm_fourcc);
return 0;
@ -638,6 +653,9 @@ static int virgl_init(struct driver *drv)
virgl_add_combinations(drv, texture_source_formats,
ARRAY_SIZE(texture_source_formats), &LINEAR_METADATA,
BO_USE_TEXTURE_MASK);
virgl_add_combinations(drv, depth_stencil_formats,
ARRAY_SIZE(depth_stencil_formats), &LINEAR_METADATA,
BO_USE_RENDER_MASK | BO_USE_TEXTURE_MASK);
/* NV12 with scanout must flow through virgl_add_combination, so that the native
* support is checked and scanout use_flag can be conditionally stripped. */
virgl_add_combination(drv, DRM_FORMAT_NV12, &LINEAR_METADATA,