Currently when we have a blend-to-output color transformation, we have a
16FP shadow buffer representing the blending space. Then we blit from
that to the primary plane fb, which is a regular buffer (fixed-point,
not 16bpc).
The shadow buffer needs to be 16FP because the blending space is linear
with relation to light. So it needs more bits for encoding.
In the next patches we enable the option to offload the blend-to-output
color transformation to KMS, so we'll need the primary plane fb to be
of a 16FP format. In order to do that, we need to be able to find EGL
configs with float-point formats. In this patch we enable that.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This will help reducing the duplicate open-coding of pre- and
post-curves in the following commits. This is also a step towards
eliminating the duplication between struct gl_shader_config and
gl_renderer_color_transform.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Rather than using a two-dimensional array, provide names to the fields.
The fields are primarily used by their names, but we also need the data
as a flat array of floats, so use unions to achieve that: two different
views into the same data.
This makes the code more self-explanatory. In color-operations.c it
removes a handful of temporaries. Comparison in color-properties.c is
simplified. ARRAY_COPY() turns into an assignment.
MAX_PARAMS_PARAM_CURVE is eliminated. Instead of having to maintain a
copy in fragment.glsl, the definition there is automated.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This helps me with VScode when clangd doesn't claim this header to be
full of unknown stuff.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Up to now we were using 10 as the max number of params for color curves
and transfer functions. But this came from LittleCMS, whose parametric
curves may contain up to 10 params.
But out color curves and tf's are not tied to LittleCMS, so let's define
constants to help avoid confusion.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Formats using SHADER_VARIANT_Y_XUXV can now use SHADER_VARIANT_Y_UV
instead with swizzle variations in order to simplify the fragment
shader.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Simplify fragment shader logic by getting rid of the RGBX variant
which can be implemented using texture swizzles instead.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
The channel ordering system currently proposes to swizzle components
in the fragment shader for a few combinations. This commit replaces
this system with texture swizzling parameters in order to support all
the possible combinations in a more efficient way.
This will allow to easily add a lot more formats and as a nice side
effect to force components to 0 or 1, which is useful for opaque
formats.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
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>
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>
EXT_EGL_image_storage provides a mechanism for creating texture
objects that are both EGL image targets and immutable. When available,
this makes the texture object target immutable, preventing
respecifications.
While adding support for that extension, it appeared that the
compositor calls attach_buffer() at every buffer updates and that the
texture object is each time respecified to the same EGL image. This
commit additionally prevents any respecification when
EXT_EGL_image_storage isn't available.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Avoid duplicating the inclusion of the GLES headers by including them
once in gl-renderer-internal.h.
Upgrade GLES3 header to gl32.h.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
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>
Next commits will add support for a bunch of extensions. The extension
flag enumeration is sorted alhpabetically. This commit makes some
space for the coming flags and presets the current values in order to
avoid useless diff lines and ease code review.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This is problematic as we don't have namespacing for these and some of
the macros can interfere with other defines.
This reverts commit 8634c7e349.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This flag ensures support for both the GL_ANDROID_native_fence_sync
and the GL_EXT_disjoint_timer_query extensions at run-time. The GL
features log now reports that flag so the warning log has been
removed.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Storing GL function pointers along with their associated extension
name allows to better track the function pointers declared.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Now that the GL extensions are stored in the gl_extensions bitfield,
there's no need to use booleans anymore.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This commit ensures GL_OES_EGL_image is available before setting up
dma-buf renderer functions because it's not implied by the presence of
the EGL_EXT_image_dma_buf_import extension.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
GL_OES_texture_3D isn't used because of the complexity implied for
correct OpenGL ES 2 support (see commit 734c2278), so there's no need
to check for it. The check also now avoids checking for
GL_EXT_color_buffer_half_float on OpenGL ES 3.2 which includes support
for 16-bit FP renderbuffers by default.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
The GL renderer supports OpenGL ES from version 2.0 to 3.2. It's meant
to correctly link on systems with only OpenGL ES 2, so OpenGL ES 3
symbols can't be used directly. eglGetProcAddress() is currently
defined to not support the querying of non-extension OpenGL ES
functions. Support for that is exposed by the
KHR_get_all_proc_addresses extension. This commit ensures OpenGL ES 3
function addresses can be retrieved by eglGetProcAddress() by checking
for that extension at run-time.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
A new gl_extensions bitfield is added to the renderer to store the
flags supported by the GL implementation. This allows the GL renderer
to easily check for extension support whenever needed.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Get the EGL_WL_bind_wayland_display extension function addresses after
checking for extension availability.
Let the EGL display setup end before trying to bind the Wayland
display in gl-renderer.c. The EGL features log will now report the
extension as supported even if the bind subsequently fails, in which
case a warning is logged.
This commit also avoids calling query_buffer() if the display isn't
bound in fill_buffer_info(), it would otherwise fail or even segfault
if the EGL_WL_bind_wayland_display extension isn't available.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This feature flag is for explicit sync support.
We replace the explicit sync warning by logging supported fence syncs
along with the report EGL features report.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Get eglCreateImageKHR() and eglDestroyImageKHR() function addresses
depending on EGL_KHR_image_base availability.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This second feature flag ensures that either the
EGL_EXT_swap_buffers_with_damage or EGL_EXT_swap_buffers_with_damage
extension is available.
Some function pointer addresses are currently retrieved depending on
the availabilty of their associated extension and some others are
retrieved unconditionally. For consistency reasons, we'll try from now
on in this commit set to first load function pointers depending on the
associated extension availability and then flag features once all the
addresses are retrieved.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This commit introduces feature flags. While an extension flag only
ensures the availability of an extension at run-time, a feature flag
ensures the availability of a minimal OpenGL ES version and/or
extensions in order to easily check for the availability of a specific
feature at run-time.
This first feature ensures the availability of either the
EGL_KHR_no_config_context or EGL_MESA_configless_context extensions.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>