Commit graph

26 commits

Author SHA1 Message Date
Loïc Molinari
891736793a gl-renderer: Add swizzles to texture parameters utilities
OpenGL ES 3 adds support for texture swizzling parameters in order to
let graphics drivers efficiently swizzle R, G, B and A components at
texture look-up, with the nice feature of allowing 0 and 1 as
supported values.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-17 15:54:52 +00:00
Loïc Molinari
5342945bb8 gl-renderer: Add texture parameters utilities
Cache and update texture parameters only when changed by storing
minification/magnification filters, wrap modes and their target into a
dedicated gl_texture_parameters structure and by calling new utility
functions to create and flush parameters.

This structure is itself stored into the buffer state for each texture
of a surface and into the output state for border and shadow textures.

The shader config filled before emitting a draw call now just takes a
pointer to the array of texture ids, a pointer to the array of
parameters and the number of textures.

This allows to simplify the logic in gl-renderer.c, to minimise GL
state changes and to let the utility wrapper validate the parameters.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-17 15:54:52 +00:00
Loïc Molinari
10f8b4ba81 gl-renderer: Adapt gl_fbo_texture_init() to new texture utilities
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
0c8b6ce945 gl-renderer: Add 3D support to texture utilities
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
7e73234313 gl-renderer: Add ARM_rgba8 support to utilities
ARM_rgba8 allows OpenGL ES 2 implementations to support GL_RGBA8 FBO
format.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
85dd477466 gl-renderer: Add EXT_texture_format_BGRA8888 support to utilities
EXT_texture_format_BGRA8888 allows OpenGL ES implementations to
support GL_BGRA8_EXT FBO and texture format.

OpenGL implementations handle the spec differently regarding the use
of GL_BGRA8_EXT or GL_BGRA_EXT with TexStorage*D(), TexImage*D() and
RenderbufferStorage(). A recent revision of the spec (and Mesa)
clarifies all that, but in order to support most drivers we simply
check which method is supported by order of preference.

Co-authored-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
dcee21f02f gl-renderer: Add OES_required_internalformat support to utilities
Before the creation of the EXT_texture_storage extension,
OES_required_internalformat used to guarantee minimal FBO and texture
precisions to OpenGL ES 1 and 2 implementations using sized internal
formats.

Note that new external format and type combinations (like for instance
GL_RGB and GL_UNSIGNED_BYTE for the GL_RGB565 sized internal format)
should be available when OES_required_internalformat is supported.
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.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
43bbd15437 gl-renderer: Add EXT_texture_type_2_10_10_10_REV support
EXT_texture_type_2_10_10_10_REV allows OpenGL ES 2 implementations to
support GL_RGB10_A2 texture format.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
db25130e15 gl-renderer: Add EXT_texture_norm16 support to utilities
EXT_texture_norm16 allows OpenGL ES 3 implementations to support
GL_R16_EXT, GL_R16_SNORM_EXT, GL_RG16_EXT, GL_RG16_SNORM_EXT,
GL_RGB16_EXT, GL_RGB16_SNORM_EXT, GL_RGBA16_EXT and
GL_RGBA16_SNORM_EXT 16-bit fixed-point texture and FBO formats.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
46603446d7 gl-renderer: Add QCOM_render_sRGB_R8_RG8 support to utilities
QCOM_render_sRGB_R8_RG8 allows OpenGL ES 3 implementations to support
GL_SR8_EXT and GL_SRG8_EXT FBO formats.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
e505bbe017 gl-renderer: Add EXT_texture_sRGB_RG8 support to utilities
EXT_texture_sRGB_RG8 allows OpenGL ES 3 implementations to support
GL_SRG8_EXT texture format.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
b2d737f1f0 gl-renderer: Add EXT_texture_sRGB_R8 support to utilities
EXT_texture_sRGB_R8 allows OpenGL ES 3 implementations to support
GL_SR8_EXT texture format.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
e72d7d963d gl-renderer: Add APPLE_texture_packed_float support to utilities
APPLE_texture_packed_float allows OpenGL ES 2 implementations to
support GL_R11F_G11F_B10F and GL_RGB9_A5 texture formats.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
58494e5ba2 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>
2025-02-06 08:42:56 +00:00
Loïc Molinari
8162058c8d gl-renderer: Add EXT_color_buffer_float support to utilities
EXT_color_buffer_float allows OpenGL ES implementations to support
GL_R16F, GL_RG16F, GL_RGBA16F, GL_R32F, GL_RG32F, GL_RGBA32F and
GL_R11F_G11F_B10F FBO formats. All of these are supported by default
from OpenGL ES 3.2.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
2fc9a47e09 gl-renderer: Add EXT_color_buffer_half_float support to utilities
EXT_color_buffer_half_float allows OpenGL ES implementations to
support GL_R16F, GL_RG16F, GL_RGB16F and GL_RGBA16F FBO formats.
GL_R16F, GL_RG16F and GL_RGBA16F are supported by default from OpenGL
ES 3.2.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
37a5c249e5 gl-renderer: Add OES_texture_float support to utilities
OES_texture_float allows OpenGL ES 2 implementations to support
GL_R32F, GL_RG32F, GL_RGB32F and GL_RGBA32F texture formats.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
9048d752c5 gl-renderer: Add OES_texture_half_float support to utilities
OES_texture_half_float allows OpenGL ES 2 implementations to support
GL_R16F, GL_RG16F, GL_RGB16F and GL_RGBA16F texture formats.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
eaf2ec3888 gl-renderer: Add EXT_texture_rg support to utilities
EXT_texture_rg adds support for GL_R8 and GL_RG8 FBOs and textures.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
177efc7a59 gl-renderer: Add EXT_texture_storage support to utilities
OpenGL ES 2 implementations support texture immutability and sized
internal formats using the GL_EXT_texture_storage extension.

Co-authored-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
0cede83390 gl-renderer: Add OpenGL ES 2 support to texture utilities
Use glTexImage2D() instead of glTexStorage2D() and convert coloured
sized internal formats to base formats in order to support OpenGL ES
2.

Co-authored-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
a7611efce9 gl-renderer: Add texture utilities
Add gl_texture_is_format_supported(), gl_texture_2d_init(),
gl_texture_2d_upload() and gl_texture_fini() utilities. The creation
function accepts all the coloured sized internal format from OpenGL ES
3 using glTexStorage2D() to create immutable textures and reduce API
overhead.

Co-authored-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
8c74b48493 gl-renderer: Check for OES_EGL_image to create FBOs from EGLImages
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
dc7299d69c gl-renderer: Check supported FBO formats
Validate the colour-renderable sized internal formats passed to
gl_fbo_init() using a new gl_fbo_is_format_supported() utility. Sized
internal formats are now required. More formats will progressively be
added depending on the OpenGL ES version and the supported extensions.

Support for RGBA8 FBOs is now required by the GL renderer.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
1dc6868947 gl-renderer: Add OpenGL ES 3 sized internal format table
This table will be used as a reference by GL utilities.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00
Loïc Molinari
7f3969c823 gl-renderer: Move utilities to new file gl-utils.c
These utility functions are used (or will be used) in different source
files. This prevents gl-renderer.c from growing too much (the coming
texture utilities are quite verbose) by moving generic functions out.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-06 08:42:56 +00:00