wayland: Use existing EGL_TEXTURE_FORMAT for querying wl_buffer texture format
We also reuse EGL_TEXTURE_RGBA and EGL_TEXTURE_RGB, adding only the new planar YUV texture formats: EGL_TEXTURE_Y_U_V_WL, EGL_TEXTURE_Y_UV_WL and EGL_TEXTURE_Y_XUXV_WL. Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
This commit is contained in:
@@ -70,18 +70,11 @@ New Tokens
|
||||
|
||||
EGL_WAYLAND_PLANE_WL 0x31D6
|
||||
|
||||
Possible values for EGL_TEXTURE_FORMAT:
|
||||
|
||||
Accepted as a eglQueryWaylandBufferWL attribute:
|
||||
|
||||
EGL_WAYLAND_BUFFER_COMPONENTS_WL 0x31D7
|
||||
|
||||
Possible values for EGL_WAYLAND_BUFFER_COMPONENTS_WL:
|
||||
|
||||
EGL_WAYLAND_BUFFER_RGB_WL 0x31D8
|
||||
EGL_WAYLAND_BUFFER_RGBA_WL 0x31D9
|
||||
EGL_WAYLAND_BUFFER_Y_U_V_WL 0x31Da
|
||||
EGL_WAYLAND_BUFFER_Y_UV_WL 0x31Db
|
||||
EGL_WAYLAND_BUFFER_Y_XUXV_WL 0x31Dc
|
||||
EGL_TEXTURE_Y_U_V_WL 0x31D7
|
||||
EGL_TEXTURE_Y_UV_WL 0x31D8
|
||||
EGL_TEXTURE_Y_XUXV_WL 0x31D9
|
||||
|
||||
|
||||
Additions to the EGL 1.4 Specification:
|
||||
@@ -106,48 +99,47 @@ Additions to the EGL 1.4 Specification:
|
||||
YUV formats. Depending on the exact YUV format in use, the
|
||||
compositor will have to create one or more EGLImages for the
|
||||
various planes. The eglQueryWaylandBufferWL function should be
|
||||
used to first query the wl_buffer components using
|
||||
EGL_WAYLAND_BUFFER_COMPONENTS_WL as the attribute. If the
|
||||
wl_buffer object is not an EGL wl_buffer (wl_shm and other wayland
|
||||
extensions can create wl_buffer objects), this query will return
|
||||
EGL_FALSE. In that case the wl_buffer can not be used with EGL
|
||||
and the compositor should have another way to get the buffer
|
||||
used to first query the wl_buffer texture format using
|
||||
EGL_TEXTURE_FORMAT as the attribute. If the wl_buffer object is
|
||||
not an EGL wl_buffer (wl_shm and other wayland extensions can
|
||||
create wl_buffer objects of different types), this query will
|
||||
return EGL_FALSE. In that case the wl_buffer can not be used with
|
||||
EGL and the compositor should have another way to get the buffer
|
||||
contents.
|
||||
|
||||
If eglQueryWaylandBufferWL succeeds, the returned value will be
|
||||
one of EGL_WAYLAND_BUFFER_RGB_WL, EGL_WAYLAND_BUFFER_RGBA_WL,
|
||||
EGL_WAYLAND_BUFFER_Y_U_V_WL, EGL_WAYLAND_BUFFER_Y_UV_WL,
|
||||
EGL_WAYLAND_BUFFER_Y_XUXV_WL. The value returned describes how
|
||||
many EGLImages must be used, which components will be sampled from
|
||||
each EGLImage and how they map to rgba components in the shader.
|
||||
The naming conventions separates planes by _ and within each
|
||||
plane, the order or R, G, B, A, Y, U, and V indicates how those
|
||||
components map to the rgba value returned by the sampler. X
|
||||
indicates that the corresponding component in the rgba value isn't
|
||||
used.
|
||||
one of EGL_TEXTURE_RGB, EGL_TEXTURE_RGBA, EGL_TEXTURE_Y_U_V_WL,
|
||||
EGL_TEXTURE_Y_UV_WL, EGL_TEXTURE_Y_XUXV_WL. The value returned
|
||||
describes how many EGLImages must be used, which components will
|
||||
be sampled from each EGLImage and how they map to rgba components
|
||||
in the shader. The naming conventions separates planes by _ and
|
||||
within each plane, the order or R, G, B, A, Y, U, and V indicates
|
||||
how those components map to the rgba value returned by the
|
||||
sampler. X indicates that the corresponding component in the rgba
|
||||
value isn't used.
|
||||
|
||||
RGB and RGBA buffer types:
|
||||
|
||||
EGL_WAYLAND_BUFFER_RGB_WL
|
||||
EGL_TEXTURE_RGB
|
||||
One plane, samples RGB from the texture to rgb in the
|
||||
shader. Alpha channel is not valid.
|
||||
|
||||
EGL_WAYLAND_BUFFER_RGBA_WL 0x31D9
|
||||
EGL_TEXTURE_RGBA
|
||||
One plane, samples RGBA from the texture to rgba in the
|
||||
shader.
|
||||
|
||||
YUV buffer types:
|
||||
|
||||
EGL_WAYLAND_BUFFER_Y_U_V_WL 0x31Da
|
||||
EGL_TEXTURE_Y_U_V_WL
|
||||
Three planes, samples Y from the first plane to r in
|
||||
the shader, U from the second plane to r, and V from
|
||||
the third plane to r.
|
||||
|
||||
EGL_WAYLAND_BUFFER_Y_UV_WL 0x31Db
|
||||
EGL_TEXTURE_Y_UV_WL
|
||||
Two planes, samples Y from the first plane to r in
|
||||
the shader, U and V from the second plane to rg.
|
||||
|
||||
EGL_WAYLAND_BUFFER_Y_XUXV_WL 0x31Dc
|
||||
EGL_TEXTURE_Y_XUXV_WL
|
||||
Two planes, samples Y from the first plane to r in
|
||||
the shader, U and V from the second plane to g and a.
|
||||
|
||||
@@ -174,3 +166,6 @@ Revision History
|
||||
Version 3, July 10, 2012
|
||||
Add eglQueryWaylandBufferWL and the various buffer
|
||||
formats. (Kristian Høgsberg)
|
||||
Version 4, July 19, 2012
|
||||
Use EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB, and EGL_TEXTURE_RGBA,
|
||||
and just define the new YUV texture formats. (Kristian Høgsberg)
|
||||
|
@@ -112,16 +112,12 @@ typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETDRMDISPLAYMESA) (int fd);
|
||||
#ifndef EGL_WL_bind_wayland_display
|
||||
#define EGL_WL_bind_wayland_display 1
|
||||
|
||||
#define EGL_WAYLAND_BUFFER_WL 0x31D5 /* eglCreateImageKHR target */
|
||||
#define EGL_WAYLAND_PLANE_WL 0x31D6 /* eglCreateImageKHR target */
|
||||
#define EGL_WAYLAND_BUFFER_WL 0x31D5 /* eglCreateImageKHR target */
|
||||
#define EGL_WAYLAND_PLANE_WL 0x31D6 /* eglCreateImageKHR target */
|
||||
|
||||
#define EGL_WAYLAND_BUFFER_COMPONENTS_WL 0x31D7 /* eglQueryWaylandBufferWL attribute */
|
||||
|
||||
#define EGL_WAYLAND_BUFFER_RGB_WL 0x31D8
|
||||
#define EGL_WAYLAND_BUFFER_RGBA_WL 0x31D9
|
||||
#define EGL_WAYLAND_BUFFER_Y_U_V_WL 0x31Da
|
||||
#define EGL_WAYLAND_BUFFER_Y_UV_WL 0x31Db
|
||||
#define EGL_WAYLAND_BUFFER_Y_XUXV_WL 0x31Dc
|
||||
#define EGL_TEXTURE_Y_U_V_WL 0x31D7
|
||||
#define EGL_TEXTURE_Y_UV_WL 0x31D8
|
||||
#define EGL_TEXTURE_Y_XUXV_WL 0x31D9
|
||||
|
||||
struct wl_display;
|
||||
struct wl_buffer;
|
||||
|
@@ -1071,42 +1071,42 @@ static const struct wl_drm_format_descriptor {
|
||||
int cpp;
|
||||
} planes[3];
|
||||
} wl_drm_formats[] = {
|
||||
{ WL_DRM_FORMAT_ARGB8888, EGL_WAYLAND_BUFFER_RGBA_WL, 1,
|
||||
{ WL_DRM_FORMAT_ARGB8888, EGL_TEXTURE_RGBA, 1,
|
||||
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_ARGB8888, 4 }, } },
|
||||
|
||||
{ WL_DRM_FORMAT_XRGB8888, EGL_WAYLAND_BUFFER_RGB_WL, 1,
|
||||
{ WL_DRM_FORMAT_XRGB8888, EGL_TEXTURE_RGB, 1,
|
||||
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_XRGB8888, 4 }, } },
|
||||
|
||||
{ WL_DRM_FORMAT_YUV410, EGL_WAYLAND_BUFFER_Y_U_V_WL, 3,
|
||||
{ WL_DRM_FORMAT_YUV410, EGL_TEXTURE_Y_U_V_WL, 3,
|
||||
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
|
||||
{ 1, 2, 2, __DRI_IMAGE_FORMAT_R8, 1 },
|
||||
{ 2, 2, 2, __DRI_IMAGE_FORMAT_R8, 1 } } },
|
||||
|
||||
{ WL_DRM_FORMAT_YUV411, EGL_WAYLAND_BUFFER_Y_U_V_WL, 3,
|
||||
{ WL_DRM_FORMAT_YUV411, EGL_TEXTURE_Y_U_V_WL, 3,
|
||||
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
|
||||
{ 1, 2, 0, __DRI_IMAGE_FORMAT_R8, 1 },
|
||||
{ 2, 2, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
|
||||
|
||||
{ WL_DRM_FORMAT_YUV420, EGL_WAYLAND_BUFFER_Y_U_V_WL, 3,
|
||||
{ WL_DRM_FORMAT_YUV420, EGL_TEXTURE_Y_U_V_WL, 3,
|
||||
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
|
||||
{ 1, 1, 1, __DRI_IMAGE_FORMAT_R8, 1 },
|
||||
{ 2, 1, 1, __DRI_IMAGE_FORMAT_R8, 1 } } },
|
||||
|
||||
{ WL_DRM_FORMAT_YUV422, EGL_WAYLAND_BUFFER_Y_U_V_WL, 3,
|
||||
{ WL_DRM_FORMAT_YUV422, EGL_TEXTURE_Y_U_V_WL, 3,
|
||||
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
|
||||
{ 1, 1, 0, __DRI_IMAGE_FORMAT_R8, 1 },
|
||||
{ 2, 1, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
|
||||
|
||||
{ WL_DRM_FORMAT_YUV444, EGL_WAYLAND_BUFFER_Y_U_V_WL, 3,
|
||||
{ WL_DRM_FORMAT_YUV444, EGL_TEXTURE_Y_U_V_WL, 3,
|
||||
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
|
||||
{ 1, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
|
||||
{ 2, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
|
||||
|
||||
{ WL_DRM_FORMAT_NV12, EGL_WAYLAND_BUFFER_Y_UV_WL, 2,
|
||||
{ WL_DRM_FORMAT_NV12, EGL_TEXTURE_Y_UV_WL, 2,
|
||||
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
|
||||
{ 1, 1, 1, __DRI_IMAGE_FORMAT_GR88, 2 } } },
|
||||
|
||||
{ WL_DRM_FORMAT_NV16, EGL_WAYLAND_BUFFER_Y_UV_WL, 2,
|
||||
{ WL_DRM_FORMAT_NV16, EGL_TEXTURE_Y_UV_WL, 2,
|
||||
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
|
||||
{ 1, 1, 0, __DRI_IMAGE_FORMAT_GR88, 2 } } },
|
||||
|
||||
@@ -1118,7 +1118,7 @@ static const struct wl_drm_format_descriptor {
|
||||
* texture sampler interpolate the Y components correctly when
|
||||
* sampling from plane 0, and interpolate U and V correctly when
|
||||
* sampling from plane 1. */
|
||||
{ WL_DRM_FORMAT_YUYV, EGL_WAYLAND_BUFFER_Y_XUXV_WL, 2,
|
||||
{ WL_DRM_FORMAT_YUYV, EGL_TEXTURE_Y_XUXV_WL, 2,
|
||||
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_GR88, 2 },
|
||||
{ 0, 1, 0, __DRI_IMAGE_FORMAT_ARGB8888, 4 } } }
|
||||
};
|
||||
@@ -1414,7 +1414,7 @@ dri2_query_wayland_buffer_wl(_EGLDriver *drv, _EGLDisplay *disp,
|
||||
return EGL_FALSE;
|
||||
|
||||
format = buffer->driver_format;
|
||||
if (attribute == EGL_WAYLAND_BUFFER_COMPONENTS_WL) {
|
||||
if (attribute == EGL_TEXTURE_FORMAT) {
|
||||
*value = format->components;
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
@@ -888,13 +888,13 @@ egl_g3d_query_wayland_buffer_wl(_EGLDriver *drv, _EGLDisplay *dpy,
|
||||
if (!wayland_buffer_is_drm(&buffer->buffer))
|
||||
return EGL_FALSE;
|
||||
|
||||
if (attribute == EGL_WAYLAND_BUFFER_COMPONENTS_WL) {
|
||||
if (attribute == EGL_TEXTURE_FORMAT) {
|
||||
switch (resource->format) {
|
||||
case PIPE_FORMAT_B8G8R8A8_UNORM:
|
||||
*value = EGL_WAYLAND_BUFFER_RGBA_WL;
|
||||
*value = EGL_TEXTURE_RGBA;
|
||||
return EGL_TRUE;
|
||||
case PIPE_FORMAT_B8G8R8X8_UNORM:
|
||||
*value = EGL_WAYLAND_BUFFER_RGB_WL;
|
||||
*value = EGL_TEXTURE_RGB;
|
||||
return EGL_TRUE;
|
||||
default:
|
||||
return EGL_FALSE;
|
||||
|
Reference in New Issue
Block a user