clutter/color-state: Add a way to query if fp16 is needed for storage

Some color states, currently only the ones with linear transfer
characteristics, need at least half float formats for storing components
of that color state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3897>
This commit is contained in:
Sebastian Wick 2024-07-18 13:49:46 +02:00 committed by Marge Bot
parent 6a2ce066b0
commit b1370a483e
4 changed files with 48 additions and 5 deletions

View File

@ -893,3 +893,26 @@ clutter_color_state_to_string (ClutterColorState *color_state)
colorspace_name,
transfer_function_name);
}
ClutterEncodingRequiredFormat
clutter_color_state_required_format (ClutterColorState *color_state)
{
ClutterColorStatePrivate *priv;
g_return_val_if_fail (CLUTTER_IS_COLOR_STATE (color_state), FALSE);
priv = clutter_color_state_get_instance_private (color_state);
switch (priv->transfer_function)
{
case CLUTTER_TRANSFER_FUNCTION_LINEAR:
return CLUTTER_ENCODING_REQUIRED_FORMAT_FP16;
case CLUTTER_TRANSFER_FUNCTION_PQ:
return CLUTTER_ENCODING_REQUIRED_FORMAT_UINT10;
case CLUTTER_TRANSFER_FUNCTION_SRGB:
case CLUTTER_TRANSFER_FUNCTION_DEFAULT:
return CLUTTER_ENCODING_REQUIRED_FORMAT_UINT8;
}
g_assert_not_reached ();
}

View File

@ -64,4 +64,7 @@ CLUTTER_EXPORT
gboolean clutter_color_state_equals (ClutterColorState *color_state,
ClutterColorState *other_color_state);
CLUTTER_EXPORT
ClutterEncodingRequiredFormat clutter_color_state_required_format (ClutterColorState *color_state);
G_END_DECLS

View File

@ -1032,6 +1032,21 @@ typedef enum
CLUTTER_TRANSFER_FUNCTION_LINEAR,
} ClutterTransferFunction;
/**
* ClutterEncodingRequiredFormat:
* @CLUTTER_ENCODING_REQUIRED_FORMAT_UINT8: 8bpc uint
* @CLUTTER_ENCODING_REQUIRED_FORMAT_UINT10: 10bpc uint
* @CLUTTER_ENCODING_REQUIRED_FORMAT_FP16: 16bpc floating point
*
* The texture format required to store a specific encoding.
*/
typedef enum
{
CLUTTER_ENCODING_REQUIRED_FORMAT_UINT8 = 0,
CLUTTER_ENCODING_REQUIRED_FORMAT_UINT10 = 1,
CLUTTER_ENCODING_REQUIRED_FORMAT_FP16 = 2,
} ClutterEncodingRequiredFormat;
/**
* ClutterStepMode:
* @CLUTTER_STEP_MODE_START: The change in the value of a

View File

@ -1558,8 +1558,14 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
CoglPixelFormat formats[10];
size_t n_formats = 0;
CoglPixelFormat format;
ClutterEncodingRequiredFormat required_format =
clutter_color_state_required_format (view_color_state);
if (view_transfer_function == CLUTTER_TRANSFER_FUNCTION_LINEAR)
if (required_format <= CLUTTER_ENCODING_REQUIRED_FORMAT_UINT8)
{
formats[n_formats++] = cogl_framebuffer_get_internal_format (framebuffer);
}
else
{
formats[n_formats++] = COGL_PIXEL_FORMAT_XRGB_FP_16161616;
formats[n_formats++] = COGL_PIXEL_FORMAT_XBGR_FP_16161616;
@ -1568,10 +1574,6 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
formats[n_formats++] = COGL_PIXEL_FORMAT_ARGB_FP_16161616_PRE;
formats[n_formats++] = COGL_PIXEL_FORMAT_ABGR_FP_16161616_PRE;
}
else
{
formats[n_formats++] = cogl_framebuffer_get_internal_format (framebuffer);
}
if (meta_monitor_transform_is_rotated (view_transform))
{