mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-05 06:28:01 +02:00
gl-renderer: Add NV_packed_float support to utilities
NV_packed_float allows OpenGL ES 2 implementations to support GL_R11F_G11F_B10F FBO and texture format. Note that GL_HALF_FLOAT should be available (the spec is a bit confusing) as type combination with the GL_RGB external format when both NV_packed_float and OES_texture_half_float are supported on OpenGL ES 2. This isn't supported by this wrapper for now because of the implicit conversion in gl_texture_2d_init() that forces a specific type when EXT_texture_storage isn't available. NV_packed_float_linear would require a new utility function to retrieve whether a texture can be linearly interpolated by the texture samplers or not. This hasn't been added for the other formats because there's no users for now but this might be added later. Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This commit is contained in:
parent
8162058c8d
commit
58494e5ba2
3 changed files with 25 additions and 4 deletions
|
|
@ -132,6 +132,7 @@ enum gl_extension_flag {
|
|||
EXTENSION_EXT_TEXTURE_STORAGE = 1ull << 16,
|
||||
EXTENSION_EXT_TEXTURE_TYPE_2_10_10_10_REV = 1ull << 17,
|
||||
EXTENSION_EXT_UNPACK_SUBIMAGE = 1ull << 18,
|
||||
EXTENSION_NV_PACKED_FLOAT = 1ull << 20,
|
||||
EXTENSION_NV_PIXEL_BUFFER_OBJECT = 1ull << 21,
|
||||
EXTENSION_OES_EGL_IMAGE = 1ull << 22,
|
||||
EXTENSION_OES_EGL_IMAGE_EXTERNAL = 1ull << 23,
|
||||
|
|
|
|||
|
|
@ -290,6 +290,7 @@ static const struct gl_extension_table extension_table[] = {
|
|||
EXT("GL_EXT_texture_storage", EXTENSION_EXT_TEXTURE_STORAGE),
|
||||
EXT("GL_EXT_texture_type_2_10_10_10_REV", EXTENSION_EXT_TEXTURE_TYPE_2_10_10_10_REV),
|
||||
EXT("GL_EXT_unpack_subimage", EXTENSION_EXT_UNPACK_SUBIMAGE),
|
||||
EXT("GL_NV_packed_float", EXTENSION_NV_PACKED_FLOAT),
|
||||
EXT("GL_NV_pixel_buffer_object", EXTENSION_NV_PIXEL_BUFFER_OBJECT),
|
||||
EXT("GL_OES_EGL_image", EXTENSION_OES_EGL_IMAGE),
|
||||
EXT("GL_OES_EGL_image_external", EXTENSION_OES_EGL_IMAGE_EXTERNAL),
|
||||
|
|
|
|||
|
|
@ -435,6 +435,9 @@ is_valid_combination_es2(struct gl_renderer *gr,
|
|||
case GL_UNSIGNED_SHORT_5_6_5:
|
||||
return true;
|
||||
|
||||
case GL_UNSIGNED_INT_10F_11F_11F_REV:
|
||||
return gl_extensions_has(gr, EXTENSION_NV_PACKED_FLOAT);
|
||||
|
||||
case GL_HALF_FLOAT_OES:
|
||||
return gl_extensions_has(gr, EXTENSION_OES_TEXTURE_HALF_FLOAT);
|
||||
|
||||
|
|
@ -500,6 +503,10 @@ gl_texture_is_format_supported(struct gl_renderer *gr,
|
|||
return gr->gl_version >= gl_version(3, 0) ||
|
||||
gl_extensions_has(gr, EXTENSION_OES_TEXTURE_FLOAT);
|
||||
|
||||
case GL_R11F_G11F_B10F:
|
||||
return gr->gl_version >= gl_version(3, 0) ||
|
||||
gl_extensions_has(gr, EXTENSION_NV_PACKED_FLOAT);
|
||||
|
||||
case GL_R8I:
|
||||
case GL_R8UI:
|
||||
case GL_R8_SNORM:
|
||||
|
|
@ -521,7 +528,6 @@ gl_texture_is_format_supported(struct gl_renderer *gr,
|
|||
case GL_RGB16UI:
|
||||
case GL_RGB32I:
|
||||
case GL_RGB32UI:
|
||||
case GL_R11F_G11F_B10F:
|
||||
case GL_RGB9_E5:
|
||||
case GL_SRGB8:
|
||||
case GL_RGBA8I:
|
||||
|
|
@ -552,7 +558,7 @@ gl_texture_is_format_supported(struct gl_renderer *gr,
|
|||
* Implementations support at least this subset of formats: GL_R8, GL_RG8,
|
||||
* GL_RGB8, GL_RGB565, GL_RGBA8, GL_RGBA4 and GL_RGB5_A1. Additional formats are
|
||||
* supported depending on extensions: GL_R16F, GL_RG16F, GL_RGB16F, GL_RGBA16F,
|
||||
* GL_R32F, GL_RG32F, GL_RGB32F and GL_RGBA32F.
|
||||
* GL_R32F, GL_RG32F, GL_RGB32F, GL_RGBA32F and GL_R11F_G11F_B10F.
|
||||
*
|
||||
* This is implemented by implicitly converting 'format' into an external
|
||||
* format. If the red and red-green texture formats aren't supported
|
||||
|
|
@ -682,6 +688,11 @@ gl_texture_2d_init(struct gl_renderer *gr,
|
|||
type = GL_FLOAT;
|
||||
break;
|
||||
|
||||
case GL_R11F_G11F_B10F:
|
||||
format = GL_RGB;
|
||||
type = GL_UNSIGNED_INT_10F_11F_11F_REV;
|
||||
break;
|
||||
|
||||
case GL_RGBA8:
|
||||
format = GL_RGBA;
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
|
|
@ -740,6 +751,8 @@ gl_texture_2d_init(struct gl_renderer *gr,
|
|||
* │ Sized internal format │ External format │ Type(s) │
|
||||
* ╞═══════════════════════╪═════════════════╪════════════════════════════════╡
|
||||
* │ GL_RGB565 │ GL_RGB │ GL_UNSIGNED_BYTE │
|
||||
* │ GL_R11F_G11F_B10F │ GL_RGB │ GL_HALF_FLOAT, │
|
||||
* │ │ │ GL_FLOAT │
|
||||
* │ GL_RGBA4 │ GL_RGBA │ GL_UNSIGNED_BYTE │
|
||||
* │ GL_RGB5_A1 │ GL_RGBA │ GL_UNSIGNED_BYTE, │
|
||||
* │ │ │ GL_UNSIGNED_INT_2_10_10_10_REV │
|
||||
|
|
@ -870,10 +883,15 @@ gl_fbo_is_format_supported(struct gl_renderer *gr,
|
|||
case GL_R32F:
|
||||
case GL_RG32F:
|
||||
case GL_RGBA32F:
|
||||
case GL_R11F_G11F_B10F:
|
||||
return gr->gl_version >= gl_version(3, 2) ||
|
||||
gl_extensions_has(gr, EXTENSION_EXT_COLOR_BUFFER_FLOAT);
|
||||
|
||||
case GL_R11F_G11F_B10F:
|
||||
return gr->gl_version >= gl_version(3, 2) ||
|
||||
gl_extensions_has(gr, EXTENSION_EXT_COLOR_BUFFER_FLOAT) ||
|
||||
(gl_extensions_has(gr, EXTENSION_NV_PACKED_FLOAT) &&
|
||||
gl_extensions_has(gr, EXTENSION_EXT_COLOR_BUFFER_HALF_FLOAT));
|
||||
|
||||
case GL_R8_SNORM:
|
||||
case GL_RG8_SNORM:
|
||||
case GL_SRGB8:
|
||||
|
|
@ -904,7 +922,8 @@ gl_fbo_is_format_supported(struct gl_renderer *gr,
|
|||
*
|
||||
* Implementations support at least these formats: GL_RGBA4, GL_RGB5_A1 and
|
||||
* GL_RGB565. Additional formats are supported depending on extensions: GL_R8,
|
||||
* GL_RG8, GL_RGB8, GL_RGBA8, GL_R16F, GL_RG16F, GL_RGB16F and GL_RGBA16F.
|
||||
* GL_RG8, GL_RGB8, GL_RGBA8, GL_R16F, GL_RG16F, GL_RGB16F, GL_RGBA16F and
|
||||
* GL_R11F_G11F_B10F.
|
||||
*
|
||||
* See gl_fbo_is_format_supported().
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue