gl-renderer: add support for (a|x)bgr16161616f shm formats

These formats will be eventually be useful for color managed clients
using wl_shm that wish to submit buffers encoding high dynamic range
images.

While the minimum requirement for linearly filterable half float
textures is GL ES 2.0 + GL_OES_texture_half_float_linear, to keep
the code simple, this commit only enables the new formats when
the requirements for color management (notably including GL ES 3.0
and GL_EXT_color_buffer_half_float) are available.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
dev
Manuel Stoeckl 3 years ago
parent 5b357a4bbb
commit 742a0232b0
  1. 23
      libweston/renderer-gl/gl-renderer.c

@ -1821,6 +1821,7 @@ gl_format_from_internal(GLenum internal_format)
return GL_RED_EXT;
case GL_RG8_EXT:
return GL_RG_EXT;
case GL_RGBA16F:
case GL_RGB10_A2:
return GL_RGBA;
default:
@ -2015,6 +2016,24 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer,
gl_pixel_type = GL_UNSIGNED_INT_2_10_10_10_REV_EXT;
es->is_opaque = true;
break;
case WL_SHM_FORMAT_ABGR16161616F:
if (!gr->gl_supports_color_transforms)
goto unsupported;
gs->shader_variant = SHADER_VARIANT_RGBA;
pitch = wl_shm_buffer_get_stride(shm_buffer) / 8;
gl_format[0] = GL_RGBA16F;
gl_pixel_type = GL_HALF_FLOAT;
es->is_opaque = false;
break;
case WL_SHM_FORMAT_XBGR16161616F:
if (!gr->gl_supports_color_transforms)
goto unsupported;
gs->shader_variant = SHADER_VARIANT_RGBX;
pitch = wl_shm_buffer_get_stride(shm_buffer) / 8;
gl_format[0] = GL_RGBA16F;
gl_pixel_type = GL_HALF_FLOAT;
es->is_opaque = true;
break;
#endif
case WL_SHM_FORMAT_YUV420:
gs->shader_variant = SHADER_VARIANT_Y_U_V;
@ -3699,6 +3718,10 @@ gl_renderer_display_create(struct weston_compositor *ec,
wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_ABGR2101010);
wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_XBGR2101010);
}
if (gr->gl_supports_color_transforms) {
wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_ABGR16161616F);
wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_XBGR16161616F);
}
#endif
if (gr->gl_supports_color_transforms)

Loading…
Cancel
Save