gl-renderer: add support for (a|x)bgr16161616 shm formats
These formats are useful because they are often easier to produce on CPU than half-float formats, and abgr16161616 has both >= 10bpc color channels and adequate alpha, unlike abgr2101010. The 16-bpc textures created from buffers with these formats require the GL_EXT_texture_norm16 extension. As WL_SHM_FORMAT_ABGR16161616 was introduced in libwayland 1.20, update Weston's build requirements and CI. The formats also needed to be registered in the pixel format table, and defined in a fallback path if recent libdrm is not available. Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
This commit is contained in:
committed by
Daniel Stone
parent
30de938624
commit
b0ed4a2e3b
@@ -156,6 +156,7 @@ struct gl_renderer {
|
||||
|
||||
bool has_texture_type_2_10_10_10_rev;
|
||||
bool has_gl_texture_rg;
|
||||
bool has_texture_norm16;
|
||||
|
||||
struct gl_shader *current_shader;
|
||||
struct gl_shader *fallback_shader;
|
||||
|
||||
@@ -1822,6 +1822,7 @@ gl_format_from_internal(GLenum internal_format)
|
||||
return GL_RED_EXT;
|
||||
case GL_RG8_EXT:
|
||||
return GL_RG_EXT;
|
||||
case GL_RGBA16_EXT:
|
||||
case GL_RGBA16F:
|
||||
case GL_RGB10_A2:
|
||||
return GL_RGBA;
|
||||
@@ -2035,6 +2036,24 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer,
|
||||
gl_pixel_type = GL_HALF_FLOAT;
|
||||
es->is_opaque = true;
|
||||
break;
|
||||
case WL_SHM_FORMAT_ABGR16161616:
|
||||
if (!gr->has_texture_norm16)
|
||||
goto unsupported;
|
||||
gs->shader_variant = SHADER_VARIANT_RGBA;
|
||||
pitch = wl_shm_buffer_get_stride(shm_buffer) / 8;
|
||||
gl_format[0] = GL_RGBA16_EXT;
|
||||
gl_pixel_type = GL_UNSIGNED_SHORT;
|
||||
es->is_opaque = false;
|
||||
break;
|
||||
case WL_SHM_FORMAT_XBGR16161616:
|
||||
if (!gr->has_texture_norm16)
|
||||
goto unsupported;
|
||||
gs->shader_variant = SHADER_VARIANT_RGBX;
|
||||
pitch = wl_shm_buffer_get_stride(shm_buffer) / 8;
|
||||
gl_format[0] = GL_RGBA16_EXT;
|
||||
gl_pixel_type = GL_UNSIGNED_SHORT;
|
||||
es->is_opaque = true;
|
||||
break;
|
||||
#endif
|
||||
case WL_SHM_FORMAT_YUV420:
|
||||
gs->shader_variant = SHADER_VARIANT_Y_U_V;
|
||||
@@ -3766,6 +3785,10 @@ gl_renderer_display_create(struct weston_compositor *ec,
|
||||
wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_ABGR16161616F);
|
||||
wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_XBGR16161616F);
|
||||
}
|
||||
if (gr->has_texture_norm16) {
|
||||
wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_ABGR16161616);
|
||||
wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_XBGR16161616);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (gr->gl_supports_color_transforms)
|
||||
@@ -3942,6 +3965,9 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
|
||||
weston_check_egl_extension(extensions, "GL_EXT_texture_type_2_10_10_10_REV"))
|
||||
gr->has_texture_type_2_10_10_10_rev = true;
|
||||
|
||||
if (weston_check_egl_extension(extensions, "GL_EXT_texture_norm16"))
|
||||
gr->has_texture_norm16 = true;
|
||||
|
||||
if (gr->gl_version >= gr_gl_version(3, 0) ||
|
||||
weston_check_egl_extension(extensions, "GL_EXT_texture_rg"))
|
||||
gr->has_gl_texture_rg = true;
|
||||
|
||||
Reference in New Issue
Block a user