Skip to contentSkip to conversation

IGT tests for pre-blending 3D LUT interfaces

RFC PATCH New Alex Hung 2 participants 6 messages Oct 4, 2022 Library code

lore
Share & tools
lore

Alex Hung

author
#0 lore raw

cover IGT tests for pre-blending 3D LUT interfaces

This is a draft of the IGT sample tests for the kernel proposal of the pre-blending 3D LUT API. It includes two subtests:

1) verify supported 3D LUT modes returned by a GPU driver, and
2) enable 3D LUT by passing a 3D LUT in the GPU driver.

Notes:

1. This patchset is based the previous work on https://gitlab.freedesktop.org/hwentland/igt-gpu-tools

2. The kernel 3DLUT API proposal "Proposal for Pre-blending 3D LUT interfaces" is sent to dri-devel mailing list.

Alex Hung (4):
include/drm-uapi: Add 3D LUT structs and its attributes lib/igt_kms: Add 3D LUT properties tests/kms_color: add 3D LUT mode tests tests/kms_color: add 3D LUT tests

 include/drm-uapi/drm_mode.h |  18 +++++
 lib/igt_kms.c               |   2 +
 lib/igt_kms.h               |   2 +
 tests/kms_color.c           | 130 ++++++++++++++++++++++++++++++++++++
 tests/kms_color_helper.c    |  71 ++++++++++++++++++++
 tests/kms_color_helper.h    |   2 +
 6 files changed, 225 insertions(+)
Signature · 1 line
2.25.1
author
#1 lore raw

RFC PATCH 1/4 include/drm-uapi: Add 3D LUT structs and its attributes

A struct is defined for 3D LUT modes to be supported by hardware. The elements includes lut_isze, lut_stride, bit_depth, color_format and flags.

This is the same structure as in proposed kernel 3D LUT API.

Note: The kernel 3DLUT API proposal "Proposal for Pre-blending 3D LUT interfaces" is sent to dri-devel mailing list.

---
 include/drm-uapi/drm_mode.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
include/drm-uapi/drm_mode.h +18 -0
index 97198609..2b60de95 100644
@@ -845,6 +845,24 @@ struct drm_color_lut_range {
     __s32 min, max;
 };
 
+
+/*
+ * struct drm_mode_3dlut_mode - 3D LUT mode information.
+ * @lut_size: number of valid points on every dimension of 3D LUT.
+ * @lut_stride: number of points on every dimension of 3D LUT.
+ * @bit_depth: number of bits of RGB. If color_mode defines entries with higher
+ *             bit_depth the least significant bits will be truncated.
+ * @color_format: fourcc values, ex. DRM_FORMAT_XRGB16161616 or DRM_FORMAT_XBGR16161616.
+ * @flags: flags for hardware-sepcific features
+ */
+struct drm_mode_3dlut_mode {
+	__u16 lut_size;
+	__u16 lut_stride[3];
+	__u16 bit_depth;
+	__u32 color_format;
+	__u32 flags;
+};
+
 /**
  * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
  *
Signature · 1 line
2.25.1
author
#2 lore raw

RFC PATCH 2/4 lib/igt_kms: Add 3D LUT properties

In reply to Alex Hung

Add support for 3D LUT properties.

Note: The kernel 3DLUT API proposal "Proposal for Pre-blending 3D LUT interfaces" is sent to dri-devel mailing list.

---
 lib/igt_kms.c | 2 ++
 lib/igt_kms.h | 2 ++
 2 files changed, 4 insertions(+)
lib/igt_kms.c +2 -0
index 677d26fe..5eb0aaeb 100644
@@ -586,6 +586,8 @@ const char * const igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
 	[IGT_PLANE_GAMMA_LUT] = "PLANE_GAMMA_LUT",
 	[IGT_PLANE_DEGAMMA_MODE] = "PLANE_DEGAMMA_MODE",
 	[IGT_PLANE_DEGAMMA_LUT] = "PLANE_DEGAMMA_LUT",
+	[IGT_PLANE_3D_LUT_MODE] = "PLANE_3D_LUT_MODE",
+	[IGT_PLANE_3D_LUT] = "PLANE_3D_LUT",
 };
 
 const char * const igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
lib/igt_kms.h +2 -0
index 5fac651f..0bcfc7b1 100644
@@ -307,6 +307,8 @@ enum igt_atomic_plane_properties {
        IGT_PLANE_GAMMA_LUT,
        IGT_PLANE_DEGAMMA_MODE,
        IGT_PLANE_DEGAMMA_LUT,
+       IGT_PLANE_3D_LUT_MODE,
+       IGT_PLANE_3D_LUT,
        IGT_NUM_PLANE_PROPS
 };
 
Signature · 1 line
2.25.1
author
#3 lore raw

RFC PATCH 3/4 tests/kms_color: add 3D LUT mode tests

In reply to Alex Hung

This sample test whether whether a GPU driver returns sane 3D LUT modes supported by the hardware.

Note: The kernel 3DLUT API proposal "Proposal for Pre-blending 3D LUT interfaces" is sent to dri-devel mailing list.

---
 tests/kms_color.c        | 34 ++++++++++++++++++++++++++++++++++
 tests/kms_color_helper.c | 36 ++++++++++++++++++++++++++++++++++++
 tests/kms_color_helper.h |  1 +
 3 files changed, 71 insertions(+)
tests/kms_color.c +34 -0
index 00742afa..1539c750 100644
@@ -859,6 +859,36 @@ static bool invalid_plane_ctm_test(data_t *data, igt_plane_t *plane)
 	return true;
 }
 
+static bool plane_3dlut_mode_test(data_t *data, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	drmModePropertyPtr lut_3d_mode = NULL;
+	uint32_t i;
+
+	igt_info("Plane 3D LUT test is running on pipe-%s plane-%s(%s)\n",
+			kmstest_pipe_name(plane->pipe->pipe),
+			kmstest_plane_type_name(plane->type),
+			is_hdr_plane(plane) ? "hdr":"sdr");
+
+	igt_require(igt_plane_has_prop(plane, IGT_PLANE_3D_LUT_MODE));
+	igt_require(igt_plane_has_prop(plane, IGT_PLANE_3D_LUT));
+
+	lut_3d_mode = get_plane_gamma_degamma_mode(plane, IGT_PLANE_3D_LUT_MODE);
+	for (i = 0; i < lut_3d_mode->count_enums; i++) {
+		igt_info("Verifying 3D LUT mode: \'%s\'\n", lut_3d_mode->enums[i].name);
+
+		verify_3dlut_mode(data, lut_3d_mode->enums[i].value);
+		igt_plane_set_prop_enum(plane,
+					IGT_PLANE_3D_LUT_MODE,
+					lut_3d_mode->enums[i].name);
+		igt_assert(igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY) == 0);
+	}
+
+	drmModeFreeProperty(lut_3d_mode);
+
+	return true;
+}
+
 static bool plane_gamma_test(data_t *data, igt_plane_t *plane)
 {
 	igt_output_t *output;
@@ -1549,6 +1579,10 @@ static void run_tests_for_plane(data_t *data, enum pipe pipe)
 	igt_subtest_f("pipe-%s-invalid-plane-ctm-matrix-sizes",
 			kmstest_pipe_name(pipe))
 		run_plane_color_test(data, pipe, invalid_plane_ctm_test);
+
+	igt_describe("Verify for plane 3dlut modes");
+	igt_subtest_f("pipe-%s-plane-3dlut-modes", kmstest_pipe_name(pipe))
+		run_plane_color_test(data, pipe, plane_3dlut_mode_test);
 }
 
 igt_main
tests/kms_color_helper.c +36 -0
index 7ea8282d..5ed313e9 100644
@@ -423,6 +423,42 @@ segment_data_t *get_segment_data(data_t *data,
 	return info;
 }
 
+void verify_3dlut_mode(data_t *data, uint64_t blob_id)
+{
+	struct drm_mode_3dlut_mode *mode_3dlut = NULL;
+	drmModePropertyBlobPtr blob;
+	uint32_t i, j, count;
+
+	blob = drmModeGetPropertyBlob(data->drm_fd, blob_id);
+	igt_assert(blob);
+	igt_assert(blob->length);
+
+	mode_3dlut = (struct drm_mode_3dlut_mode *) blob->data;
+	count = blob->length / sizeof(mode_3dlut[0]);
+	igt_assert(count);
+
+	/* TODO more tests? */
+	for (i = 0; i < count; i++) {
+		igt_assert(mode_3dlut[i].lut_size);
+		igt_assert(mode_3dlut[i].bit_depth);
+
+		for (j = 0; j < 3; j++) {
+			igt_assert(mode_3dlut[i].lut_stride[j]);
+			igt_assert_lte(mode_3dlut[i].lut_size,
+				       mode_3dlut[i].lut_stride[j]);
+		}
+
+		/* check whether color formats are support */
+		if (mode_3dlut[i].color_format != DRM_FORMAT_XRGB16161616 &&
+		    mode_3dlut[i].color_format != DRM_FORMAT_XBGR16161616)
+			igt_info("format 0x%X is not supported\n", mode_3dlut[i].color_format);
+
+	}
+
+	drmModeFreePropertyBlob(blob);
+
+}
+
 void set_advance_gamma(data_t *data, igt_pipe_t *pipe, enum gamma_type type)
 {
 	igt_display_t *display = &data->display;
tests/kms_color_helper.h +1 -0
index c863874f..994ba2be 100644
@@ -117,6 +117,7 @@ gamma_lut_t *pipe_create_linear_lut(segment_data_t *info);
 struct drm_color_lut_ext *create_linear_lut(segment_data_t *info);
 struct drm_color_lut_ext *create_max_lut(segment_data_t *info);
 segment_data_t *get_segment_data(data_t *data, uint64_t blob_id, char *mode);
+void verify_3dlut_mode(data_t *data, uint64_t blob_id);
 void set_pipe_gamma(igt_pipe_t *pipe, uint64_t value,
 		    struct drm_color_lut *lut, uint32_t size);
 void set_advance_gamma(data_t *data, igt_pipe_t *pipe, enum gamma_type type);
Signature · 1 line
2.25.1
author
#4 lore raw

RFC PATCH 4/4 tests/kms_color: add 3D LUT tests

In reply to Alex Hung

This is a sample test that passes a dummy 3D LUT to a proposed 3DLUT API and verifies 3D LUT functionalities by the hardware.

Note: The kernel 3DLUT API proposal "Proposal for Pre-blending 3D LUT interfaces" is sent to dri-devel mailing list.

---
 tests/kms_color.c        | 96 ++++++++++++++++++++++++++++++++++++++++
 tests/kms_color_helper.c | 35 +++++++++++++++
 tests/kms_color_helper.h |  1 +
 3 files changed, 132 insertions(+)
tests/kms_color.c +96 -0
index 1539c750..20bd56e2 100644
@@ -859,6 +859,97 @@ static bool invalid_plane_ctm_test(data_t *data, igt_plane_t *plane)
 	return true;
 }
 
+static bool plane_3dlut_test(data_t *data, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	drmModeModeInfo *mode;
+	igt_output_t *output;
+	struct igt_fb fb;
+	drmModePropertyPtr lut_3d_mode = NULL;
+	igt_pipe_crc_t *pipe_crc = NULL;
+	bool ret = true;
+	uint32_t i;
+	color_t red_green_blue[] = {
+		{ 1.0, 0.0, 0.0 },
+		{ 0.0, 1.0, 0.0 },
+		{ 0.0, 0.0, 1.0 }
+	};
+
+	igt_info("Plane 3D LUT test is running on pipe-%s plane-%s(%s)\n",
+			kmstest_pipe_name(plane->pipe->pipe),
+			kmstest_plane_type_name(plane->type),
+			is_hdr_plane(plane) ? "hdr":"sdr");
+
+	igt_require(igt_plane_has_prop(plane, IGT_PLANE_3D_LUT_MODE));
+	igt_require(igt_plane_has_prop(plane, IGT_PLANE_3D_LUT));
+
+	pipe_crc = igt_pipe_crc_new(data->drm_fd, plane->pipe->pipe, "auto");
+	output = igt_get_single_output_for_pipe(display, plane->pipe->pipe);
+	igt_assert(output);
+
+	igt_output_set_pipe(output, plane->pipe->pipe);
+	mode = igt_output_get_mode(output);
+
+	/* Create a framebuffer at the size of the output. */
+	igt_assert(igt_create_fb(data->drm_fd,
+			      mode->hdisplay,
+			      mode->vdisplay,
+			      DRM_FORMAT_XRGB16161616,
+			      DRM_FORMAT_MOD_LINEAR,
+			      &fb));
+
+	igt_plane_set_fb(plane, &fb);
+
+	lut_3d_mode = get_plane_gamma_degamma_mode(plane, IGT_PLANE_3D_LUT_MODE);
+	for (i = 0; i < lut_3d_mode->count_enums; i++) {
+		igt_crc_t crc_3dlut, crc_fullcolors;
+		void *lut = NULL;
+		uint32_t lut_size = 0;
+
+		igt_info("Teseting with 3D LUT mode: \'%s\'\n", lut_3d_mode->enums[i].name);
+
+		lut = create_max_3dlut(data, lut_3d_mode->enums[i].value, &lut_size);
+
+		/* Draw solid colors without 3D LUT. */
+		disable_plane_prop(plane, IGT_PLANE_3D_LUT);
+		paint_rectangles(data, mode, red_green_blue, &fb);
+		igt_plane_set_fb(plane, &fb);
+		igt_display_commit2(display, display->is_atomic ?
+				COMMIT_ATOMIC : COMMIT_LEGACY);
+		igt_wait_for_vblank(data->drm_fd,
+				display->pipes[plane->pipe->pipe].crtc_offset);
+		igt_pipe_crc_collect_crc(pipe_crc, &crc_fullcolors);
+
+		/* Draw with dummy 3D LUT */
+		paint_gradient_rectangles(data, mode, red_green_blue, &fb);
+		igt_plane_set_fb(plane, &fb);
+		igt_plane_set_prop_enum(plane, IGT_PLANE_3D_LUT_MODE, lut_3d_mode->enums[i].name);
+		igt_plane_replace_prop_blob(plane, IGT_PLANE_3D_LUT, lut, lut_size);
+		igt_assert(igt_display_commit2(display, display->is_atomic ?
+				COMMIT_ATOMIC : COMMIT_LEGACY) == 0);
+		igt_wait_for_vblank(data->drm_fd,
+				display->pipes[plane->pipe->pipe].crtc_offset);
+		igt_pipe_crc_collect_crc(pipe_crc, &crc_3dlut);
+
+		/* TODO Verify CRC values - is checking CRC reasonable? */
+
+		/* TODO Draw with a real 3D LUT that can be verified by eyes */
+
+		/* Draw without 3D LUT again */
+		paint_gradient_rectangles(data, mode, red_green_blue, &fb);
+		igt_plane_set_fb(plane, &fb);
+		disable_plane_prop(plane, IGT_PLANE_3D_LUT);
+		igt_display_commit2(display, display->is_atomic ?
+			COMMIT_ATOMIC : COMMIT_LEGACY);
+
+		free(lut);
+	}
+
+	drmModeFreeProperty(lut_3d_mode);
+	return ret;
+}
+
+
 static bool plane_3dlut_mode_test(data_t *data, igt_plane_t *plane)
 {
 	igt_display_t *display = &data->display;
@@ -1583,6 +1674,11 @@ static void run_tests_for_plane(data_t *data, enum pipe pipe)
 	igt_describe("Verify for plane 3dlut modes");
 	igt_subtest_f("pipe-%s-plane-3dlut-modes", kmstest_pipe_name(pipe))
 		run_plane_color_test(data, pipe, plane_3dlut_mode_test);
+
+	igt_describe("Compare out plane with 3dlut");
+	igt_subtest_f("pipe-%s-plane-3dlut", kmstest_pipe_name(pipe))
+		run_plane_color_test(data, pipe, plane_3dlut_test);
+
 }
 
 igt_main
tests/kms_color_helper.c +35 -0
index 5ed313e9..c84ec7fa 100644
@@ -423,6 +423,41 @@ segment_data_t *get_segment_data(data_t *data,
 	return info;
 }
 
+void *create_max_3dlut(data_t *data, uint64_t blob_id, uint32_t *lut_size)
+{
+	struct drm_mode_3dlut_mode *mode_3dlut = NULL;
+	drmModePropertyBlobPtr blob;
+	uint32_t fmt = 0;
+	void *lut = NULL;
+
+	blob = drmModeGetPropertyBlob(data->drm_fd, blob_id);
+	igt_assert(blob);
+	igt_assert(blob->length);
+
+	/* test with the first 3dlut */
+	mode_3dlut = (struct drm_mode_3dlut_mode *) blob->data;
+	fmt = mode_3dlut->color_format;
+	if (fmt == DRM_FORMAT_XRGB16161616 || fmt == DRM_FORMAT_XBGR16161616)
+		*lut_size = pow(mode_3dlut->lut_size, 3) * sizeof(uint64_t);
+	else if (fmt == DRM_FORMAT_XRGB8888 || fmt == DRM_FORMAT_XBGR8888)
+		*lut_size = pow(mode_3dlut->lut_size, 3) * sizeof(uint32_t);
+	else
+		return lut;
+
+	lut = malloc(sizeof(struct drm_mode_3dlut_mode) * (*lut_size));
+	igt_assert(lut);
+
+	/* TODO create 3dlut - fill with dummy values for now */
+	if (mode_3dlut->color_format == DRM_FORMAT_XRGB16161616)
+		memset(lut, 0x5A, *lut_size);
+	else if (mode_3dlut->color_format == DRM_FORMAT_XBGR16161616)
+		memset(lut, 0xA5, *lut_size);
+	else
+		memset(lut, 0, *lut_size);
+
+	return lut;
+}
+
 void verify_3dlut_mode(data_t *data, uint64_t blob_id)
 {
 	struct drm_mode_3dlut_mode *mode_3dlut = NULL;
tests/kms_color_helper.h +1 -0
index 994ba2be..b097b77a 100644
@@ -117,6 +117,7 @@ gamma_lut_t *pipe_create_linear_lut(segment_data_t *info);
 struct drm_color_lut_ext *create_linear_lut(segment_data_t *info);
 struct drm_color_lut_ext *create_max_lut(segment_data_t *info);
 segment_data_t *get_segment_data(data_t *data, uint64_t blob_id, char *mode);
+void *create_max_3dlut(data_t *data, uint64_t blob_id, uint32_t *lut_size);
 void verify_3dlut_mode(data_t *data, uint64_t blob_id);
 void set_pipe_gamma(igt_pipe_t *pipe, uint64_t value,
 		    struct drm_color_lut *lut, uint32_t size);
Signature · 1 line
2.25.1
#5 lore raw

[igt-dev] ✗ Fi.CI.BUILD: failure for IGT tests for pre-blending 3D LUT interfaces

In reply to Alex Hung
== Series Details ==

== Series Details ==

Series: IGT tests for pre-blending 3D LUT interfaces
URL : https://patchwork.freedesktop.org/series/109402/
State : failure

== Summary ==

Applying: include/drm-uapi: Add 3D LUT structs and its attributes Using index info to reconstruct a base tree...
M include/drm-uapi/drm_mode.h
Falling back to patching base and 3-way merge...
Auto-merging include/drm-uapi/drm_mode.h
CONFLICT (content): Merge conflict in include/drm-uapi/drm_mode.h Patch failed at 0001 include/drm-uapi: Add 3D LUT structs and its attributes When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".