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