diff options
author | Jakob Bornecrantz <[email protected]> | 2012-08-31 19:48:26 +0200 |
---|---|---|
committer | Jakob Bornecrantz <[email protected]> | 2012-08-31 19:51:02 +0200 |
commit | 6a7dea93fa70d670a5954e47a47075a2703209d4 (patch) | |
tree | c304ff1541078fa21e2c313435f8a64b58bf57c2 /src/gbm/backends/dri | |
parent | 022f6d88616bf5ea3903c5056d6147e9cf356aa9 (diff) |
dri: Rework planar image interface
As discussed with Kristian on #wayland. Pushes the decision of components into
the dri driver giving it greater freedom to allow t to implement YUV samplers
in hardware, and which mode to use.
This interface will also allow drivers like SVGA to implement YUV surfaces
without the need to sub-allocate and instead send 3 seperate buffers for each
channel, currently not implemented.
I have tested these changes on Gallium Svga. Scott tested them on both intel
and Gallium Radeon. Kristan and Pekka tested them on intel.
v2: Fix typo in dri2_from_planar.
v3: Merge in intel changes.
Tested-by: Scott Moreau <[email protected]>
Tested-by: Pekka Paalanen <[email protected]>
Tested-by: Kristian Høgsberg <[email protected]>
Reviewed-by: Kristian Høgsberg <[email protected]>
Signed-off-by: Jakob Bornecrantz <[email protected]>
Diffstat (limited to 'src/gbm/backends/dri')
-rw-r--r-- | src/gbm/backends/dri/gbm_dri.c | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index 1831f137789..d8b1cc78892 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -363,7 +363,7 @@ gbm_dri_bo_import(struct gbm_device *gbm, struct gbm_dri_bo *bo; __DRIimage *image; unsigned dri_use = 0; - int dri_format, width, height, gbm_format, stride, cpp, offset; + int gbm_format; /* Required for query image WIDTH & HEIGHT */ if (dri->image->base.version < 4) @@ -376,20 +376,15 @@ gbm_dri_bo_import(struct gbm_device *gbm, struct wl_drm_buffer *wb = (struct wl_drm_buffer *) buffer; image = wb->driver_buffer; - stride = wb->stride[0]; - offset = wb->offset[0]; - cpp = 4; + switch (wb->format) { case WL_DRM_FORMAT_XRGB8888: - dri_format = __DRI_IMAGE_FORMAT_XRGB8888; gbm_format = GBM_FORMAT_XRGB8888; break; case WL_DRM_FORMAT_ARGB8888: - dri_format = __DRI_IMAGE_FORMAT_ARGB8888; gbm_format = GBM_FORMAT_ARGB8888; break; case WL_DRM_FORMAT_YUYV: - dri_format = __DRI_IMAGE_FORMAT_ARGB8888; gbm_format = GBM_FORMAT_YUYV; break; default: @@ -401,15 +396,15 @@ gbm_dri_bo_import(struct gbm_device *gbm, case GBM_BO_IMPORT_EGL_IMAGE: { + int dri_format; if (dri->lookup_image == NULL) return NULL; image = dri->lookup_image(dri->screen, buffer, dri->lookup_user_data); dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_FORMAT, &dri_format); gbm_format = gbm_dri_to_gbm_format(dri_format); - dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_STRIDE, &stride); - offset = 0; - cpp = 4; + if (gbm_format == 0) + return NULL; break; } @@ -422,13 +417,7 @@ gbm_dri_bo_import(struct gbm_device *gbm, if (bo == NULL) return NULL; - dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_WIDTH, &width); - dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_HEIGHT, &height); - - bo->image = dri->image->createSubImage(image, - width, height, dri_format, - offset, stride / cpp, NULL); - + bo->image = dri->image->dupImage(image, NULL); if (usage & GBM_BO_USE_SCANOUT) dri_use |= __DRI_IMAGE_USE_SCANOUT; @@ -441,10 +430,14 @@ gbm_dri_bo_import(struct gbm_device *gbm, } bo->base.base.gbm = gbm; - bo->base.base.width = width; - bo->base.base.height = height; - bo->base.base.stride = stride; bo->base.base.format = gbm_format; + + dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_WIDTH, + (int*)&bo->base.base.width); + dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_HEIGHT, + (int*)&bo->base.base.height); + dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_STRIDE, + (int*)&bo->base.base.stride); dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_HANDLE, &bo->base.base.handle.s32); |