From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2045.outbound.protection.outlook.com [40.107.220.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 229FD10E9F4 for ; Fri, 3 Nov 2023 14:34:23 +0000 (UTC) Message-ID: <46567128-61fa-4ef3-a78a-898b0e26db2e@amd.com> Date: Fri, 3 Nov 2023 10:34:16 -0400 Content-Language: en-US To: Pekka Paalanen References: <20230908150315.75977-1-harry.wentland@amd.com> <20230908150315.75977-6-harry.wentland@amd.com> <20230915175258.0181c016.pekka.paalanen@collabora.com> <20230918110218.3c7975c4.pekka.paalanen@collabora.com> From: Harry Wentland In-Reply-To: <20230918110218.3c7975c4.pekka.paalanen@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 Subject: Re: [igt-dev] [RFC PATCH 5/7] igt/color: Add SW color transform functionality List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sebastian Wick , Shashank Sharma , Simon Ser , Alexander Goins , =?UTF-8?Q?Michel_D=C3=A4nzer?= , Xaver Hugl , igt-dev@lists.freedesktop.org, =?UTF-8?Q?Jonas_=C3=85dahl?= , Victoria Brekenfeld , Joshua Ashton , Daniel Vetter , Aleix Pol , Naseer Ahmed , Christopher Braga Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: On 2023-09-18 04:02, Pekka Paalanen wrote: > On Fri, 15 Sep 2023 15:50:52 -0400 > Harry Wentland wrote: > >> On 2023-09-15 10:52, Pekka Paalanen wrote: >>> On Fri, 8 Sep 2023 11:03:13 -0400 >>> Harry Wentland wrote: >>> >>>> In order to test color we want to compare a HW (KMS) transform >>>> with a SW transform. This introduces color transform for an >>>> sRGB EOTF but this can be extended to other transforms. Code is >>>> borrowed from Skia. >>>> >>>> Signed-off-by: Harry Wentland >>>> Cc: Ville Syrjala >>>> Cc: Pekka Paalanen >>>> Cc: Simon Ser >>>> Cc: Harry Wentland >>>> Cc: Melissa Wen >>>> Cc: Jonas Ådahl >>>> Cc: Sebastian Wick >>>> Cc: Shashank Sharma >>>> Cc: Alexander Goins >>>> Cc: Joshua Ashton >>>> Cc: Michel Dänzer >>>> Cc: Aleix Pol >>>> Cc: Xaver Hugl >>>> Cc: Victoria Brekenfeld >>>> Cc: Daniel Vetter >>>> Cc: Uma Shankar >>>> Cc: Naseer Ahmed >>>> Cc: Christopher Braga >>>> --- >>>> lib/igt_color.c | 330 ++++++++++++++++++++++++++++++++++++++++++++++++ >>>> lib/igt_color.h | 105 +++++++++++++++ >>>> lib/igt_fb.c | 6 +- >>>> lib/igt_fb.h | 2 + >>>> lib/meson.build | 1 + >>>> 5 files changed, 441 insertions(+), 3 deletions(-) >>>> create mode 100644 lib/igt_color.c >>>> create mode 100644 lib/igt_color.h > > ... > >>>> +/* >>>> + * A transfer function mapping encoded values to linear values, >>>> + * represented by this 7-parameter piecewise function: >>>> + * >>>> + * linear = sign(encoded) * (c*|encoded| + f) , 0 <= |encoded| < d >>>> + * = sign(encoded) * ((a*|encoded| + b)^g + e), d <= |encoded| >>> >>> The code you have does not actually do the extended form (use of sign >>> and absolute value), but clamps the result to [0.0, 1.0]. >>> >> >> Yes, the intention (and I didn't write this but copied it) is to be able to use >> this to describe most (all?) standard transfer functions. See >> https://github.com/google/skia/blob/main/include/core/SkColorSpace.h > > My complaint is about doc and implementation disagreeing. > > xvYCC and integer-encoded scRGB would need an extended range if anyone > wanted to test those, if they even fit here. I also do not understand > how it can be possible to express PQ EOTF or HLG OETF with this > parameterisation. Maybe it's an approximation on a very limited domain? > I have a feeling Skia maps everything to [0.0, 1.0] and agree that this wouldn't work in the cases you mention (PQ would work with an additional scaling of the values to 125.0). What's here seems to work fine for sRGB but I'll have to hook this all up to amdgpu and test both sRGB and PQ at the very least. Harry > > Thanks, > pq > >>>> + * >>>> + * (A simple gamma transfer function sets g to gamma and a to 1.) >>>> + */ >>>> +struct igt_color_tf { >>>> + float g, a,b,c,d,e,f; >>>> +}; >>>> + >>>> +const struct igt_color_tf srgb_tf = {2.4f, (float)(1/1.055), (float)(0.055/1.055), (float)(1/12.92), 0.04045f, 0, 0}; >>>> + >>>> +/* end of Skia-based code */ >>>> + >>>> +typedef struct igt_pixel { >>>> + float r; >>>> + float g; >>>> + float b; >>>> +} igt_pixel_t; >>> >>> Thanks, >>> pq >> >