From: Oarora Etimis <oaroraetimis@gmail.com>
To: "Louis Chauvet" <louis.chauvet@bootlin.com>,
"Haneen Mohammed" <hamohammed.sa@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Melissa Wen" <melissa.srw@gmail.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Maíra Canal" <mairacanal@riseup.net>,
"Harry Wentland" <harry.wentland@amd.com>,
"Pekka Paalanen" <pekka.paalanen@collabora.com>,
"Arthur Grillo" <arthurgrillo@riseup.net>,
"Helen Koike" <helen.fornazier@gmail.com>,
"Vignesh Raman" <vignesh.raman@collabora.com>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Oarora Etimis <oaroraetimis@gmail.com>
Subject: [PATCH 3/4] drm/vkms: add a KUnit test for the precomputed LUT table
Date: Sun, 08 Nov 2026 19:33:11 +0000 [thread overview]
Message-ID: <20261108-lut-v1-3-f762d70ae4cd@gmail.com> (raw)
In-Reply-To: <20261108-lut-v1-0-f762d70ae4cd@gmail.com>
build_lut_table() turns a per-pixel interpolation into a table lookup, so
a wrong entry changes the composed output with no other symptom.
Compare every entry against apply_lut_to_channel_value() for the same
channel and value, for a 4-entry LUT whose channels differ and for the
256-entry sRGB one. The check stops at the first mismatch and prints its
channel, value and both results.
The tables are built with apply_lut_to_channel_value(), so this proves the
lookup matches the interpolation, not that the LUT arithmetic is right;
vkms_color_srgb_inv_srgb() covers the latter.
Signed-off-by: Oarora Etimis <oaroraetimis@gmail.com>
---
drivers/gpu/drm/vkms/tests/vkms_color_test.c | 54 ++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/drivers/gpu/drm/vkms/tests/vkms_color_test.c b/drivers/gpu/drm/vkms/tests/vkms_color_test.c
index 1a1c7cac2f15..cdbb74d16b5e 100644
--- a/drivers/gpu/drm/vkms/tests/vkms_color_test.c
+++ b/drivers/gpu/drm/vkms/tests/vkms_color_test.c
@@ -88,6 +88,21 @@ static const struct vkms_color_lut test_linear_lut = {
.channel_value2index_ratio = 0xf000fll
};
+/* Channels differ, so a table built with the wrong channel does not match. */
+static struct drm_color_lut test_distinct_array[] = {
+ { 0x0000, 0x0000, 0x0000, 0 },
+ { 0x1000, 0x6000, 0xb000, 0 },
+ { 0x2000, 0x4000, 0x9000, 0 },
+ { 0xffff, 0xffff, 0xffff, 0 },
+};
+
+static const struct vkms_color_lut test_distinct_lut = {
+ .base = test_distinct_array,
+ .lut_length = ARRAY_SIZE(test_distinct_array),
+ /* drm_fixp_div(drm_int2fixp(lut_length - 1), drm_int2fixp(0xffff)) */
+ .channel_value2index_ratio = 0x30003ll
+};
+
static void vkms_color_test_get_lut_index(struct kunit *test)
{
s64 lut_index;
@@ -393,6 +408,44 @@ static void vkms_color_ctm_3x4_bt709(struct kunit *test)
KUNIT_EXPECT_LT(test, out.b, 0x100);
}
+static void vkms_color_test_check_lut_table(struct kunit *test,
+ const struct vkms_color_lut *lut,
+ const u16 *table)
+{
+ int i;
+
+ for (i = 0; i < LUT_RESERVED * LUT_TABLE_ENTRIES; i++) {
+ enum lut_channel channel = i / LUT_TABLE_ENTRIES;
+ u16 value = i % LUT_TABLE_ENTRIES;
+ u16 expected = apply_lut_to_channel_value(lut, value, channel);
+
+ if (table[i] != expected) {
+ KUNIT_FAIL(test, "channel %d, value %#06x: 0x%04x != 0x%04x",
+ channel, value, table[i], expected);
+ return;
+ }
+ }
+}
+
+static void vkms_color_test_build_lut_table(struct kunit *test)
+{
+ const struct vkms_color_lut *luts[] = {
+ &test_distinct_lut,
+ &srgb_eotf,
+ };
+ u16 *table;
+ int l;
+
+ table = kunit_kzalloc(test, LUT_RESERVED * LUT_TABLE_ENTRIES * sizeof(*table),
+ GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, table);
+
+ for (l = 0; l < ARRAY_SIZE(luts); l++) {
+ build_lut_table(luts[l], table);
+ vkms_color_test_check_lut_table(test, luts[l], table);
+ }
+}
+
static struct kunit_case vkms_color_test_cases[] = {
KUNIT_CASE(vkms_color_test_get_lut_index),
KUNIT_CASE(vkms_color_test_lerp),
@@ -400,6 +453,7 @@ static struct kunit_case vkms_color_test_cases[] = {
KUNIT_CASE(vkms_color_srgb_inv_srgb),
KUNIT_CASE(vkms_color_ctm_3x4_50_desat),
KUNIT_CASE(vkms_color_ctm_3x4_bt709),
+ KUNIT_CASE(vkms_color_test_build_lut_table),
{}
};
--
2.55.0
next prev parent reply other threads:[~2026-11-08 19:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 19:33 [PATCH 0/4] drm/vkms: speed up composition with a precomputed gamma LUT Oarora Etimis
2026-11-08 19:33 ` [PATCH 1/4] drm/vkms: use the gamma LUT of the state being composed Oarora Etimis
2026-11-08 19:33 ` [PATCH 2/4] drm/vkms: precompute the gamma LUT for every channel value Oarora Etimis
2026-11-08 19:33 ` Oarora Etimis [this message]
2026-11-08 19:33 ` [PATCH 4/4] drm/ci: drop the kms_plane pixel-format xfails for vkms Oarora Etimis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261108-lut-v1-3-f762d70ae4cd@gmail.com \
--to=oaroraetimis@gmail.com \
--cc=airlied@gmail.com \
--cc=arthurgrillo@riseup.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=hamohammed.sa@gmail.com \
--cc=harry.wentland@amd.com \
--cc=helen.fornazier@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=louis.chauvet@bootlin.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mairacanal@riseup.net \
--cc=melissa.srw@gmail.com \
--cc=mripard@kernel.org \
--cc=pekka.paalanen@collabora.com \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
--cc=vignesh.raman@collabora.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®