Skip to contentSkip to conversation

tests: Add kms plane alpha blending test, v2.

PATCH In review Maarten Lankhorst 3 participants 6 messages Oct 1, 2018 – Oct 2, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests: Add kms plane alpha blending test, v2.

Add a few tests to test various blending modes.

Some of the tests will skip if pixel mode alpha cannot be enabled with plane alpha at the same time. This is for mali-dp. I didn't test on that platform, but tested with the same check on i915.

The tests won't pass i915 on pre-gen11 hw. i915 has small rounding errors with 0xff and 0x00 alpha, which gives CRC mismatches.

Changes since v1:
- Send the correct version, with the skips for mali-dp in place.

---
 lib/igt_kms.c                 |   2 +
 lib/igt_kms.h                 |   2 +
 tests/Makefile.sources        |   1 +
 tests/kms_plane_alpha_blend.c | 571 ++++++++++++++++++++++++++++++++++
 tests/meson.build             |   1 +
 5 files changed, 577 insertions(+)
 create mode 100644 tests/kms_plane_alpha_blend.c
lib/igt_kms.c +2 -0
index 4563bfd9d25b..e88e96149957 100644
@@ -175,6 +175,8 @@ const char * const igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
 	[IGT_PLANE_IN_FORMATS] = "IN_FORMATS",
 	[IGT_PLANE_COLOR_ENCODING] = "COLOR_ENCODING",
 	[IGT_PLANE_COLOR_RANGE] = "COLOR_RANGE",
+	[IGT_PLANE_PIXEL_BLEND_MODE] = "pixel blend mode",
+	[IGT_PLANE_ALPHA] = "alpha",
 };
 
 const char * const igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
lib/igt_kms.h +2 -0
index 3862efa28be0..3af336f43020 100644
@@ -266,6 +266,8 @@ enum igt_atomic_plane_properties {
        IGT_PLANE_IN_FORMATS,
        IGT_PLANE_COLOR_ENCODING,
        IGT_PLANE_COLOR_RANGE,
+       IGT_PLANE_PIXEL_BLEND_MODE,
+       IGT_PLANE_ALPHA,
        IGT_NUM_PLANE_PROPS
 };
 
tests/Makefile.sources +1 -0
index 109c5397de85..e6f7a364b4b3 100644
@@ -194,6 +194,7 @@ TESTS_progs = \
 	kms_pipe_b_c_ivb \
 	kms_pipe_crc_basic \
 	kms_plane \
+	kms_plane_alpha_blend \
 	kms_plane_lowres \
 	kms_plane_multiple \
 	kms_plane_scaling \
tests/kms_plane_alpha_blend.c new file +571 -0

571 lines not on this page · raw message

tests/meson.build +1 -0
index 14154686676a..83638d768069 100644
@@ -169,6 +169,7 @@ test_progs = [
 	'kms_pipe_b_c_ivb',
 	'kms_pipe_crc_basic',
 	'kms_plane',
+	'kms_plane_alpha_blend',
 	'kms_plane_lowres',
 	'kms_plane_multiple',
 	'kms_plane_scaling',
Signature · 6 lines
2.19.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Reviewed-by on v1 1/1
#1 lore raw
Quoted 133 lines · Maarten Lankhorst

Add a few tests to test various blending modes.

Some of the tests will skip if pixel mode alpha cannot be enabled with plane alpha at the same time. This is for mali-dp. I didn't test on that platform, but tested with the same check on i915.

The tests won't pass i915 on pre-gen11 hw. i915 has small rounding errors with 0xff and 0x00 alpha, which gives CRC mismatches.

Changes since v1:
- Send the correct version, with the skips for mali-dp in place.

---
 lib/igt_kms.c                 |   2 +
 lib/igt_kms.h                 |   2 +
 tests/Makefile.sources        |   1 +
 tests/kms_plane_alpha_blend.c | 571 ++++++++++++++++++++++++++++++++++
 tests/meson.build             |   1 +
 5 files changed, 577 insertions(+)
 create mode 100644 tests/kms_plane_alpha_blend.c
lib/igt_kms.c +2 -0
index 4563bfd9d25b..e88e96149957 100644
@@ -175,6 +175,8 @@ const char * const igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
 	[IGT_PLANE_IN_FORMATS] = "IN_FORMATS",
 	[IGT_PLANE_COLOR_ENCODING] = "COLOR_ENCODING",
 	[IGT_PLANE_COLOR_RANGE] = "COLOR_RANGE",
+	[IGT_PLANE_PIXEL_BLEND_MODE] = "pixel blend mode",
+	[IGT_PLANE_ALPHA] = "alpha",
 };
 
 const char * const igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
lib/igt_kms.h +2 -0
index 3862efa28be0..3af336f43020 100644
@@ -266,6 +266,8 @@ enum igt_atomic_plane_properties {
        IGT_PLANE_IN_FORMATS,
        IGT_PLANE_COLOR_ENCODING,
        IGT_PLANE_COLOR_RANGE,
+       IGT_PLANE_PIXEL_BLEND_MODE,
+       IGT_PLANE_ALPHA,
        IGT_NUM_PLANE_PROPS
 };
 
tests/Makefile.sources +1 -0
index 109c5397de85..e6f7a364b4b3 100644
@@ -194,6 +194,7 @@ TESTS_progs = \
 	kms_pipe_b_c_ivb \
 	kms_pipe_crc_basic \
 	kms_plane \
+	kms_plane_alpha_blend \
 	kms_plane_lowres \
 	kms_plane_multiple \
 	kms_plane_scaling \
tests/kms_plane_alpha_blend.c new file +67 -0
new file mode 100644
index 000000000000..81c8cb916a63
@@ -0,0 +1,571 @@
+/*
+ * Copyright © 2018 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *   Maarten Lankhorst <[email protected]>
+ */
+
+#include "igt.h"
+
+IGT_TEST_DESCRIPTION("Test plane alpha and blending mode properties");
+
+typedef struct {
+	int gfx_fd;
+	igt_display_t display;
+	struct igt_fb xrgb_fb, argb_fb_0, argb_fb_cov_0, argb_fb_7e, argb_fb_cov_7e, argb_fb_fc, argb_fb_cov_fc, argb_fb_100, black_fb, gray_fb;
+	igt_crc_t ref_crc;
+	igt_pipe_crc_t *pipe_crc;
+} data_t;
+
+static void __draw_gradient(struct igt_fb *fb, int w, int h, double a, cairo_t *cr)
+{
+	cairo_pattern_t *pat;
+
+	pat = cairo_pattern_create_linear(0, 0, w, h);
+	cairo_pattern_add_color_stop_rgba(pat, 0.00, 0.00, 0.00, 0.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 0.25, 1.00, 1.00, 0.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 0.50, 0.00, 1.00, 1.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 0.75, 1.00, 0.00, 1.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 1.00, 1.00, 1.00, 1.00, 1.);
+
+	cairo_rectangle(cr, 0, 0, w, h);
+	cairo_set_source(cr, pat);
+	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+	cairo_paint_with_alpha(cr, a);
+	cairo_pattern_destroy(pat);
+}
+
+static void draw_gradient(struct igt_fb *fb, int w, int h, double a)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+
+	__draw_gradient(fb, w, h, a, cr);
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void draw_gradient_coverage(struct igt_fb *fb, int w, int h, uint8_t a)
+{

tests/kms_plane_alpha_blend.c line 77

Quoted 10 lines
tests/kms_plane_alpha_blend.c new file +10 -0
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+	uint8_t *data = cairo_image_surface_get_data(fb->cairo_surface);
+	uint32_t stride = fb->strides[0];
+	int i;
+
+	__draw_gradient(fb, w, h, 1., cr);
+
+	for (; h--; data += stride)
+		for (i = 0; i < w; i++)
+			data[i * 4 + 3] = a;

Hrm. I guess no way to make cairo paint non-premultiplied. It's also interesting that when you specify a source/pattern color you apparently give in non-premultiplied form even though surface source would be in premultiplied form. Cairo seems a bit inconsistent here.

Quoted 51 lines
tests/kms_plane_alpha_blend.c new file +51 -0
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void draw_squares(struct igt_fb *fb, int w, int h, double a)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+
+	igt_paint_color_alpha(cr, 0, 0,         w / 2, h / 2, 1., 0., 0., a);
+	igt_paint_color_alpha(cr, w / 2, 0,     w / 2, h / 2, 0., 1., 0., a);
+	igt_paint_color_alpha(cr, 0, h / 2,     w / 2, h / 2, 0., 0., 1., a);
+	igt_paint_color_alpha(cr, w / 2, h / 2, w / 4, h / 2, 1., 1., 1., a);
+	igt_paint_color_alpha(cr, 3 * w / 4, h / 2, w / 4, h / 2, 0., 0., 0., a);
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void draw_squares_coverage(struct igt_fb *fb, int w, int h, uint8_t as)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+	int i, j;
+	uint32_t *data = (void *)cairo_image_surface_get_data(fb->cairo_surface);
+	uint32_t stride = fb->strides[0] / 4;
+	uint32_t a = as << 24;
+
+	for (j = 0; j < h / 2; j++) {
+		for (i = 0; i < w / 2; i++)
+			data[j * stride + i] = a | 0xff0000;
+
+		for (; i < w; i++)
+			data[j * stride + i] = a | 0xff00;
+	}
+
+	for (j = h / 2; j < h; j++) {
+		for (i = 0; i < w / 2; i++)
+			data[j * stride + i] = a | 0xff;
+
+		for (; i < 3 * w / 4; i++)
+			data[j * stride + i] = a | 0xffffff;
+
+		for (; i < w; i++)
+			data[j * stride + i] = a;
+	}
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void reset_alpha(igt_display_t *display, enum pipe pipe)
+{
+	igt_plane_t *plane;
+

tests/kms_plane_alpha_blend.c line 138

Quoted 10 lines
tests/kms_plane_alpha_blend.c new file +10 -0
+	for_each_plane_on_pipe(display, pipe, plane) {
+		if (igt_plane_has_prop(plane, IGT_PLANE_ALPHA))
+			igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0xffff);
+
+		if (igt_plane_has_prop(plane, IGT_PLANE_PIXEL_BLEND_MODE))
+			igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "Pre-multiplied");
+	}
+}
+
+static bool has_multiplied_alpha(data_t *data, igt_plane_t *plane)

What's this "multiplied alpha"? Is that the constant alpha prop? Why can't we just look for the prop?

Quoted 133 lines
tests/kms_plane_alpha_blend.c new file +133 -0
+{
+	int ret;
+
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0x8080);
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	ret = igt_display_try_commit_atomic(&data->display,
+		DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0xffff);
+	igt_plane_set_fb(plane, NULL);
+
+	return ret == 0;
+}
+
+static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe)
+{
+	drmModeModeInfo *mode;
+	igt_display_t *display = &data->display;
+	int w, h;
+	igt_plane_t *primary = igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY);
+
+	igt_display_reset(display);
+	igt_output_set_pipe(output, pipe);
+
+	/* create the pipe_crc object for this pipe */
+	igt_pipe_crc_free(data->pipe_crc);
+	data->pipe_crc = igt_pipe_crc_new(data->gfx_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
+
+	mode = igt_output_get_mode(output);
+	w = mode->hdisplay;
+	h = mode->vdisplay;
+
+	/* recreate all fbs if incompatible */
+	if (data->xrgb_fb.width != w || data->xrgb_fb.height != h) {
+		cairo_t *cr;
+
+		igt_remove_fb(data->gfx_fd, &data->xrgb_fb);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_0);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_cov_0);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_7e);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_fc);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_cov_7e);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_cov_fc);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_100);
+		igt_remove_fb(data->gfx_fd, &data->black_fb);
+		igt_remove_fb(data->gfx_fd, &data->gray_fb);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->xrgb_fb);
+		draw_gradient(&data->xrgb_fb, w, h, 1.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_cov_0);
+		draw_gradient_coverage(&data->argb_fb_cov_0, w, h, 0);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_0);
+
+		cr = igt_get_cairo_ctx(data->gfx_fd, &data->argb_fb_0);
+		igt_paint_color_alpha(cr, 0, 0, w, h, 0., 0., 0., 1.0);
+		igt_put_cairo_ctx(data->gfx_fd, &data->argb_fb_0, cr);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_7e);
+		draw_squares(&data->argb_fb_7e, w, h, 126. / 255.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_cov_7e);
+		draw_squares_coverage(&data->argb_fb_cov_7e, w, h, 0x7e);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_fc);
+		draw_squares(&data->argb_fb_fc, w, h, 252. / 255.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_cov_fc);
+		draw_squares_coverage(&data->argb_fb_cov_fc, w, h, 0xfc);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_100);
+		draw_gradient(&data->argb_fb_100, w, h, 1.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->black_fb);
+
+		igt_create_color_fb(data->gfx_fd, w, h,
+				    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+				    .5, .5, .5, &data->gray_fb);
+	}
+
+	igt_plane_set_fb(primary, &data->black_fb);
+	/* reset alpha property to default */
+	reset_alpha(display, pipe);
+}
+
+static void basic_alpha(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+	int i;
+
+	/* Testcase 1: alpha = 0.0, plane should be transparant. */
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_start(data->pipe_crc);
+	igt_pipe_crc_get_single(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_0);
+
+	/* transparant fb should be transparant, no matter what.. */
+	for (i = 7; i < 256; i += 8) {
+		igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, i | (i << 8));
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+		igt_assert_crc_equal(&ref_crc, &crc);
+	}
+
+	/* And test alpha = 0, should give same CRC, but doesn't on some i915 platforms. */
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+
+	igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+	igt_pipe_crc_stop(data->pipe_crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+}

tests/kms_plane_alpha_blend.c line 281

Quoted 10 lines
tests/kms_plane_alpha_blend.c new file +10 -0
+
+static void argb_opaque(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+
+	/* alpha = 1.0, plane should be fully opaque, test with an opaque fb */
+	igt_plane_set_fb(plane, &data->xrgb_fb);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);

Could probably speed up the test quite a bit with crc_get_current()?

Quoted 11 lines
tests/kms_plane_alpha_blend.c new file +11 -0
+
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void argb_transparant(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;

tests/kms_plane_alpha_blend.c line 302

Quoted 10 lines
tests/kms_plane_alpha_blend.c new file +10 -0
+	igt_crc_t ref_crc, crc;
+
+	/* alpha = 1.0, plane should be fully opaque, test with a transparant fb */
+	igt_plane_set_fb(plane, NULL);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);

Might make it a bit easier to parse these if you didn't rely on the default state of the props and instead just set them explicitly.

In general this a bit repetitive. I wonder if some kind of declarative approach might increase the signal to noise ratio a bit.

To me it looks like the weak point of this test is that it mostly relies on comparins the different blend modes with each other. I guess there are enough ways to combine those to get decent assurances that they aren't just misbehaving in ways that make the crcs match by accident. Still, comparing against software rendered results would probably be how I'd have tried to approach this. That would also eliminate the dependency on having all the blend modes supported in the hardware.

Looks decent enough anyway, so

Quoted 283 lines
tests/kms_plane_alpha_blend.c new file +269 -0
+
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void constant_alpha_min(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+
+	igt_plane_set_fb(plane, NULL);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "None");
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0);
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void constant_alpha_mid(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+
+	if (plane->type != DRM_PLANE_TYPE_PRIMARY)
+		igt_plane_set_fb(igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY), &data->gray_fb);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "None");
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0x7fff);
+	igt_plane_set_fb(plane, &data->xrgb_fb);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_cov_0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void constant_alpha_max(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+
+	if (plane->type != DRM_PLANE_TYPE_PRIMARY)
+		igt_plane_set_fb(igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY), &data->gray_fb);
+
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "None");
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_cov_0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+
+	igt_plane_set_fb(plane, &data->xrgb_fb);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+
+	igt_plane_set_fb(plane, NULL);
+}
+
+static void alpha_7efc(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc = {}, crc = {};
+	int i;
+
+	if (plane->type != DRM_PLANE_TYPE_PRIMARY)
+		igt_plane_set_fb(igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY), &data->gray_fb);
+
+	igt_pipe_crc_start(data->pipe_crc);
+
+	/* for coverage, plane alpha and fb alpha should be swappable, so swap fb and alpha */
+	for (i = 0; i < 256; i += 8) {
+		igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, ((i/2) << 8) | (i/2));
+		igt_plane_set_fb(plane, &data->argb_fb_fc);
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &ref_crc);
+
+		igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, (i << 8) | i);
+		igt_plane_set_fb(plane, &data->argb_fb_7e);
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+		igt_assert_crc_equal(&ref_crc, &crc);
+	}
+}
+
+static void coverage_7efc(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc = {}, crc = {};
+	int i;
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "Coverage");
+	igt_pipe_crc_start(data->pipe_crc);
+
+	/* for coverage, plane alpha and fb alpha should be swappable, so swap fb and alpha */
+	for (i = 0; i < 256; i += 8) {
+		igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, ((i/2) << 8) | (i/2));
+		igt_plane_set_fb(plane, &data->argb_fb_cov_fc);
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &ref_crc);
+
+		igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, (i << 8) | i);
+		igt_plane_set_fb(plane, &data->argb_fb_cov_7e);
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+		igt_assert_crc_equal(&ref_crc, &crc);
+	}
+}
+
+static void coverage_premult_constant(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc = {}, crc = {};
+
+	/* Set a background color on the primary fb for testing */
+	if (plane->type != DRM_PLANE_TYPE_PRIMARY)
+		igt_plane_set_fb(igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY), &data->gray_fb);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "Coverage");
+	igt_plane_set_fb(plane, &data->argb_fb_cov_7e);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_start(data->pipe_crc);
+	igt_pipe_crc_get_single(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "Pre-multiplied");
+	igt_plane_set_fb(plane, &data->argb_fb_7e);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "None");
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0x7e7e);
+	igt_plane_set_fb(plane, &data->argb_fb_cov_7e);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void run_test_on_pipe_planes(data_t *data, enum pipe pipe, bool blend,
+				    bool must_multiply,
+				    void(*test)(data_t *, enum pipe, igt_plane_t *))
+{
+	igt_display_t *display = &data->display;
+	igt_output_t *output = igt_get_single_output_for_pipe(display, pipe);
+	igt_plane_t *plane;
+	bool found = false;
+	bool multiply = false;
+
+	for_each_plane_on_pipe(display, pipe, plane) {
+		if (!igt_plane_has_prop(plane, IGT_PLANE_ALPHA))
+			continue;
+
+		if (blend && !igt_plane_has_prop(plane, IGT_PLANE_PIXEL_BLEND_MODE))
+			continue;
+
+		prepare_crtc(data, output, pipe);
+
+		/* reset plane alpha properties between each plane */
+		reset_alpha(display, pipe);
+
+		found = true;
+		if (must_multiply && !has_multiplied_alpha(data, plane))
+			continue;
+		multiply = true;
+
+		igt_info("Testing plane %u\n", plane->index);
+		test(data, pipe, plane);
+		igt_plane_set_fb(plane, NULL);
+	}
+
+	igt_require_f(found, "No planes with %s property found\n",
+		      blend ? "pixel blending mode" : "alpha");
+	igt_require_f(multiply, "Multiplied (plane x pixel) alpha not available\n");
+}
+
+static void run_subtests(data_t *data, enum pipe pipe)
+{
+	igt_fixture {
+		bool found = false;
+		igt_plane_t *plane;
+
+		igt_display_require_output_on_pipe(&data->display, pipe);
+		for_each_plane_on_pipe(&data->display, pipe, plane) {
+			if (!igt_plane_has_prop(plane, IGT_PLANE_ALPHA))
+				continue;
+
+			found = true;
+			break;
+		}
+
+		igt_require_f(found, "Found no plane on pipe %s with alpha blending supported\n",
+			      kmstest_pipe_name(pipe));
+	}
+
+	igt_subtest_f("pipe-%s-alpha-basic", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, false, true, basic_alpha);
+
+	igt_subtest_f("pipe-%s-alpha-7efc", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, false, true, alpha_7efc);
+
+	igt_subtest_f("pipe-%s-coverage-7efc", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, true, true, coverage_7efc);
+
+	igt_subtest_f("pipe-%s-coverage-vs-premult-vs-constant", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, true, false, coverage_premult_constant);
+
+	igt_subtest_f("pipe-%s-alpha-transparant-fb", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, false, false, argb_transparant);
+
+	igt_subtest_f("pipe-%s-alpha-opaque-fb", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, false, false, argb_opaque);
+
+	igt_subtest_f("pipe-%s-constant-alpha-min", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, true, false, constant_alpha_min);
+
+	igt_subtest_f("pipe-%s-constant-alpha-mid", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, true, false, constant_alpha_mid);
+
+	igt_subtest_f("pipe-%s-constant-alpha-max", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, true, false, constant_alpha_max);
+}
+
+igt_main
+{
+	data_t data = {};
+	enum pipe pipe;
+
+	igt_fixture {
+		igt_skip_on_simulation();
+
+		data.gfx_fd = drm_open_driver(DRIVER_ANY);
+		igt_require_pipe_crc(data.gfx_fd);
+		igt_display_init(&data.display, data.gfx_fd);
+		igt_require(data.display.is_atomic);
+	}
+
+	for_each_pipe_static(pipe)
+		igt_subtest_group
+			run_subtests(&data, pipe);
+
+	igt_fixture
+		igt_display_fini(&data.display);
+}
tests/meson.build +1 -0
index 14154686676a..83638d768069 100644
@@ -169,6 +169,7 @@ test_progs = [
 	'kms_pipe_b_c_ivb',
 	'kms_pipe_crc_basic',
 	'kms_plane',
+	'kms_plane_alpha_blend',
 	'kms_plane_lowres',
 	'kms_plane_multiple',
 	'kms_plane_scaling',
Signature · 1 line
2.19.0
Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#2 lore raw

Op 01-10-18 om 20:19 schreef Ville Syrjälä:

Quoted 393 lines · Maarten Lankhorst
Quoted 133 lines

Add a few tests to test various blending modes.

Some of the tests will skip if pixel mode alpha cannot be enabled with plane alpha at the same time. This is for mali-dp. I didn't test on that platform, but tested with the same check on i915.

The tests won't pass i915 on pre-gen11 hw. i915 has small rounding errors with 0xff and 0x00 alpha, which gives CRC mismatches.

Changes since v1:
- Send the correct version, with the skips for mali-dp in place.

---
 lib/igt_kms.c                 |   2 +
 lib/igt_kms.h                 |   2 +
 tests/Makefile.sources        |   1 +
 tests/kms_plane_alpha_blend.c | 571 ++++++++++++++++++++++++++++++++++
 tests/meson.build             |   1 +
 5 files changed, 577 insertions(+)
 create mode 100644 tests/kms_plane_alpha_blend.c
lib/igt_kms.c +2 -0
index 4563bfd9d25b..e88e96149957 100644
@@ -175,6 +175,8 @@ const char * const igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
 	[IGT_PLANE_IN_FORMATS] = "IN_FORMATS",
 	[IGT_PLANE_COLOR_ENCODING] = "COLOR_ENCODING",
 	[IGT_PLANE_COLOR_RANGE] = "COLOR_RANGE",
+	[IGT_PLANE_PIXEL_BLEND_MODE] = "pixel blend mode",
+	[IGT_PLANE_ALPHA] = "alpha",
 };
 
 const char * const igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
lib/igt_kms.h +2 -0
index 3862efa28be0..3af336f43020 100644
@@ -266,6 +266,8 @@ enum igt_atomic_plane_properties {
        IGT_PLANE_IN_FORMATS,
        IGT_PLANE_COLOR_ENCODING,
        IGT_PLANE_COLOR_RANGE,
+       IGT_PLANE_PIXEL_BLEND_MODE,
+       IGT_PLANE_ALPHA,
        IGT_NUM_PLANE_PROPS
 };
 
tests/Makefile.sources +1 -0
index 109c5397de85..e6f7a364b4b3 100644
@@ -194,6 +194,7 @@ TESTS_progs = \
 	kms_pipe_b_c_ivb \
 	kms_pipe_crc_basic \
 	kms_plane \
+	kms_plane_alpha_blend \
 	kms_plane_lowres \
 	kms_plane_multiple \
 	kms_plane_scaling \
tests/kms_plane_alpha_blend.c new file +67 -0
new file mode 100644
index 000000000000..81c8cb916a63
@@ -0,0 +1,571 @@
+/*
+ * Copyright © 2018 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *   Maarten Lankhorst <[email protected]>
+ */
+
+#include "igt.h"
+
+IGT_TEST_DESCRIPTION("Test plane alpha and blending mode properties");
+
+typedef struct {
+	int gfx_fd;
+	igt_display_t display;
+	struct igt_fb xrgb_fb, argb_fb_0, argb_fb_cov_0, argb_fb_7e, argb_fb_cov_7e, argb_fb_fc, argb_fb_cov_fc, argb_fb_100, black_fb, gray_fb;
+	igt_crc_t ref_crc;
+	igt_pipe_crc_t *pipe_crc;
+} data_t;
+
+static void __draw_gradient(struct igt_fb *fb, int w, int h, double a, cairo_t *cr)
+{
+	cairo_pattern_t *pat;
+
+	pat = cairo_pattern_create_linear(0, 0, w, h);
+	cairo_pattern_add_color_stop_rgba(pat, 0.00, 0.00, 0.00, 0.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 0.25, 1.00, 1.00, 0.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 0.50, 0.00, 1.00, 1.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 0.75, 1.00, 0.00, 1.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 1.00, 1.00, 1.00, 1.00, 1.);
+
+	cairo_rectangle(cr, 0, 0, w, h);
+	cairo_set_source(cr, pat);
+	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+	cairo_paint_with_alpha(cr, a);
+	cairo_pattern_destroy(pat);
+}
+
+static void draw_gradient(struct igt_fb *fb, int w, int h, double a)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+
+	__draw_gradient(fb, w, h, a, cr);
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void draw_gradient_coverage(struct igt_fb *fb, int w, int h, uint8_t a)
+{

tests/kms_plane_alpha_blend.c line 77

Quoted 10 lines
tests/kms_plane_alpha_blend.c new file +10 -0
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+	uint8_t *data = cairo_image_surface_get_data(fb->cairo_surface);
+	uint32_t stride = fb->strides[0];
+	int i;
+
+	__draw_gradient(fb, w, h, 1., cr);
+
+	for (; h--; data += stride)
+		for (i = 0; i < w; i++)
+			data[i * 4 + 3] = a;

Hrm. I guess no way to make cairo paint non-premultiplied. It's also interesting that when you specify a source/pattern color you apparently give in non-premultiplied form even though surface source would be in premultiplied form. Cairo seems a bit inconsistent here.

Quoted 51 lines
tests/kms_plane_alpha_blend.c new file +51 -0
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void draw_squares(struct igt_fb *fb, int w, int h, double a)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+
+	igt_paint_color_alpha(cr, 0, 0,         w / 2, h / 2, 1., 0., 0., a);
+	igt_paint_color_alpha(cr, w / 2, 0,     w / 2, h / 2, 0., 1., 0., a);
+	igt_paint_color_alpha(cr, 0, h / 2,     w / 2, h / 2, 0., 0., 1., a);
+	igt_paint_color_alpha(cr, w / 2, h / 2, w / 4, h / 2, 1., 1., 1., a);
+	igt_paint_color_alpha(cr, 3 * w / 4, h / 2, w / 4, h / 2, 0., 0., 0., a);
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void draw_squares_coverage(struct igt_fb *fb, int w, int h, uint8_t as)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+	int i, j;
+	uint32_t *data = (void *)cairo_image_surface_get_data(fb->cairo_surface);
+	uint32_t stride = fb->strides[0] / 4;
+	uint32_t a = as << 24;
+
+	for (j = 0; j < h / 2; j++) {
+		for (i = 0; i < w / 2; i++)
+			data[j * stride + i] = a | 0xff0000;
+
+		for (; i < w; i++)
+			data[j * stride + i] = a | 0xff00;
+	}
+
+	for (j = h / 2; j < h; j++) {
+		for (i = 0; i < w / 2; i++)
+			data[j * stride + i] = a | 0xff;
+
+		for (; i < 3 * w / 4; i++)
+			data[j * stride + i] = a | 0xffffff;
+
+		for (; i < w; i++)
+			data[j * stride + i] = a;
+	}
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void reset_alpha(igt_display_t *display, enum pipe pipe)
+{
+	igt_plane_t *plane;
+

tests/kms_plane_alpha_blend.c line 138

Quoted 10 lines
tests/kms_plane_alpha_blend.c new file +10 -0
+	for_each_plane_on_pipe(display, pipe, plane) {
+		if (igt_plane_has_prop(plane, IGT_PLANE_ALPHA))
+			igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0xffff);
+
+		if (igt_plane_has_prop(plane, IGT_PLANE_PIXEL_BLEND_MODE))
+			igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "Pre-multiplied");
+	}
+}
+
+static bool has_multiplied_alpha(data_t *data, igt_plane_t *plane)

What's this "multiplied alpha"? Is that the constant alpha prop? Why can't we just look for the prop?

Quoted 133 lines
tests/kms_plane_alpha_blend.c new file +133 -0
+{
+	int ret;
+
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0x8080);
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	ret = igt_display_try_commit_atomic(&data->display,
+		DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0xffff);
+	igt_plane_set_fb(plane, NULL);
+
+	return ret == 0;
+}
+
+static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe)
+{
+	drmModeModeInfo *mode;
+	igt_display_t *display = &data->display;
+	int w, h;
+	igt_plane_t *primary = igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY);
+
+	igt_display_reset(display);
+	igt_output_set_pipe(output, pipe);
+
+	/* create the pipe_crc object for this pipe */
+	igt_pipe_crc_free(data->pipe_crc);
+	data->pipe_crc = igt_pipe_crc_new(data->gfx_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
+
+	mode = igt_output_get_mode(output);
+	w = mode->hdisplay;
+	h = mode->vdisplay;
+
+	/* recreate all fbs if incompatible */
+	if (data->xrgb_fb.width != w || data->xrgb_fb.height != h) {
+		cairo_t *cr;
+
+		igt_remove_fb(data->gfx_fd, &data->xrgb_fb);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_0);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_cov_0);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_7e);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_fc);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_cov_7e);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_cov_fc);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_100);
+		igt_remove_fb(data->gfx_fd, &data->black_fb);
+		igt_remove_fb(data->gfx_fd, &data->gray_fb);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->xrgb_fb);
+		draw_gradient(&data->xrgb_fb, w, h, 1.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_cov_0);
+		draw_gradient_coverage(&data->argb_fb_cov_0, w, h, 0);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_0);
+
+		cr = igt_get_cairo_ctx(data->gfx_fd, &data->argb_fb_0);
+		igt_paint_color_alpha(cr, 0, 0, w, h, 0., 0., 0., 1.0);
+		igt_put_cairo_ctx(data->gfx_fd, &data->argb_fb_0, cr);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_7e);
+		draw_squares(&data->argb_fb_7e, w, h, 126. / 255.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_cov_7e);
+		draw_squares_coverage(&data->argb_fb_cov_7e, w, h, 0x7e);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_fc);
+		draw_squares(&data->argb_fb_fc, w, h, 252. / 255.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_cov_fc);
+		draw_squares_coverage(&data->argb_fb_cov_fc, w, h, 0xfc);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_100);
+		draw_gradient(&data->argb_fb_100, w, h, 1.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->black_fb);
+
+		igt_create_color_fb(data->gfx_fd, w, h,
+				    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+				    .5, .5, .5, &data->gray_fb);
+	}
+
+	igt_plane_set_fb(primary, &data->black_fb);
+	/* reset alpha property to default */
+	reset_alpha(display, pipe);
+}
+
+static void basic_alpha(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+	int i;
+
+	/* Testcase 1: alpha = 0.0, plane should be transparant. */
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_start(data->pipe_crc);
+	igt_pipe_crc_get_single(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_0);
+
+	/* transparant fb should be transparant, no matter what.. */
+	for (i = 7; i < 256; i += 8) {
+		igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, i | (i << 8));
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+		igt_assert_crc_equal(&ref_crc, &crc);
+	}
+
+	/* And test alpha = 0, should give same CRC, but doesn't on some i915 platforms. */
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+
+	igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+	igt_pipe_crc_stop(data->pipe_crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+}

tests/kms_plane_alpha_blend.c line 281

Quoted 10 lines
tests/kms_plane_alpha_blend.c new file +10 -0
+
+static void argb_opaque(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+
+	/* alpha = 1.0, plane should be fully opaque, test with an opaque fb */
+	igt_plane_set_fb(plane, &data->xrgb_fb);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);

Could probably speed up the test quite a bit with crc_get_current()?

Quoted 11 lines
tests/kms_plane_alpha_blend.c new file +11 -0
+
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void argb_transparant(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;

tests/kms_plane_alpha_blend.c line 302

Quoted 10 lines
tests/kms_plane_alpha_blend.c new file +10 -0
+	igt_crc_t ref_crc, crc;
+
+	/* alpha = 1.0, plane should be fully opaque, test with a transparant fb */
+	igt_plane_set_fb(plane, NULL);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);

Might make it a bit easier to parse these if you didn't rely on the default state of the props and instead just set them explicitly.

In general this a bit repetitive. I wonder if some kind of declarative approach might increase the signal to noise ratio a bit.

To me it looks like the weak point of this test is that it mostly relies on comparins the different blend modes with each other. I guess there are enough ways to combine those to get decent assurances that they aren't just misbehaving in ways that make the crcs match by accident. Still, comparing against software rendered results would probably be how I'd have tried to approach this. That would also eliminate the dependency on having all the blend modes supported in the hardware.

Quoted 2 lines

Looks decent enough anyway, so

This is deliberate. HW might round in different ways then sw. So to compare hw rendering against sw, would assume a specific way of rounding.
Some tests compare preblended 0xfc vs 0x7e. This way at least we know hw will probably round in the same way when sw does things in a certain way. Even if we don't know the exact rounding. Because 0xfc * 0x7e should be same as 0x7e * 0xfc.

~Maarten
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#3 lore raw
Quoted 394 lines · Maarten Lankhorst

Op 01-10-18 om 20:19 schreef Ville Syrjälä:

Quoted 393 lines · Maarten Lankhorst
Quoted 133 lines

Add a few tests to test various blending modes.

Some of the tests will skip if pixel mode alpha cannot be enabled with plane alpha at the same time. This is for mali-dp. I didn't test on that platform, but tested with the same check on i915.

The tests won't pass i915 on pre-gen11 hw. i915 has small rounding errors with 0xff and 0x00 alpha, which gives CRC mismatches.

Changes since v1:
- Send the correct version, with the skips for mali-dp in place.

---
 lib/igt_kms.c                 |   2 +
 lib/igt_kms.h                 |   2 +
 tests/Makefile.sources        |   1 +
 tests/kms_plane_alpha_blend.c | 571 ++++++++++++++++++++++++++++++++++
 tests/meson.build             |   1 +
 5 files changed, 577 insertions(+)
 create mode 100644 tests/kms_plane_alpha_blend.c
lib/igt_kms.c +2 -0
index 4563bfd9d25b..e88e96149957 100644
@@ -175,6 +175,8 @@ const char * const igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
 	[IGT_PLANE_IN_FORMATS] = "IN_FORMATS",
 	[IGT_PLANE_COLOR_ENCODING] = "COLOR_ENCODING",
 	[IGT_PLANE_COLOR_RANGE] = "COLOR_RANGE",
+	[IGT_PLANE_PIXEL_BLEND_MODE] = "pixel blend mode",
+	[IGT_PLANE_ALPHA] = "alpha",
 };
 
 const char * const igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
lib/igt_kms.h +2 -0
index 3862efa28be0..3af336f43020 100644
@@ -266,6 +266,8 @@ enum igt_atomic_plane_properties {
        IGT_PLANE_IN_FORMATS,
        IGT_PLANE_COLOR_ENCODING,
        IGT_PLANE_COLOR_RANGE,
+       IGT_PLANE_PIXEL_BLEND_MODE,
+       IGT_PLANE_ALPHA,
        IGT_NUM_PLANE_PROPS
 };
 
tests/Makefile.sources +1 -0
index 109c5397de85..e6f7a364b4b3 100644
@@ -194,6 +194,7 @@ TESTS_progs = \
 	kms_pipe_b_c_ivb \
 	kms_pipe_crc_basic \
 	kms_plane \
+	kms_plane_alpha_blend \
 	kms_plane_lowres \
 	kms_plane_multiple \
 	kms_plane_scaling \
tests/kms_plane_alpha_blend.c new file +67 -0
new file mode 100644
index 000000000000..81c8cb916a63
@@ -0,0 +1,571 @@
+/*
+ * Copyright © 2018 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *   Maarten Lankhorst <[email protected]>
+ */
+
+#include "igt.h"
+
+IGT_TEST_DESCRIPTION("Test plane alpha and blending mode properties");
+
+typedef struct {
+	int gfx_fd;
+	igt_display_t display;
+	struct igt_fb xrgb_fb, argb_fb_0, argb_fb_cov_0, argb_fb_7e, argb_fb_cov_7e, argb_fb_fc, argb_fb_cov_fc, argb_fb_100, black_fb, gray_fb;
+	igt_crc_t ref_crc;
+	igt_pipe_crc_t *pipe_crc;
+} data_t;
+
+static void __draw_gradient(struct igt_fb *fb, int w, int h, double a, cairo_t *cr)
+{
+	cairo_pattern_t *pat;
+
+	pat = cairo_pattern_create_linear(0, 0, w, h);
+	cairo_pattern_add_color_stop_rgba(pat, 0.00, 0.00, 0.00, 0.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 0.25, 1.00, 1.00, 0.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 0.50, 0.00, 1.00, 1.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 0.75, 1.00, 0.00, 1.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 1.00, 1.00, 1.00, 1.00, 1.);
+
+	cairo_rectangle(cr, 0, 0, w, h);
+	cairo_set_source(cr, pat);
+	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+	cairo_paint_with_alpha(cr, a);
+	cairo_pattern_destroy(pat);
+}
+
+static void draw_gradient(struct igt_fb *fb, int w, int h, double a)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+
+	__draw_gradient(fb, w, h, a, cr);
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void draw_gradient_coverage(struct igt_fb *fb, int w, int h, uint8_t a)
+{

tests/kms_plane_alpha_blend.c line 77

Quoted 10 lines
tests/kms_plane_alpha_blend.c new file +10 -0
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+	uint8_t *data = cairo_image_surface_get_data(fb->cairo_surface);
+	uint32_t stride = fb->strides[0];
+	int i;
+
+	__draw_gradient(fb, w, h, 1., cr);
+
+	for (; h--; data += stride)
+		for (i = 0; i < w; i++)
+			data[i * 4 + 3] = a;

Hrm. I guess no way to make cairo paint non-premultiplied. It's also interesting that when you specify a source/pattern color you apparently give in non-premultiplied form even though surface source would be in premultiplied form. Cairo seems a bit inconsistent here.

Quoted 51 lines
tests/kms_plane_alpha_blend.c new file +51 -0
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void draw_squares(struct igt_fb *fb, int w, int h, double a)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+
+	igt_paint_color_alpha(cr, 0, 0,         w / 2, h / 2, 1., 0., 0., a);
+	igt_paint_color_alpha(cr, w / 2, 0,     w / 2, h / 2, 0., 1., 0., a);
+	igt_paint_color_alpha(cr, 0, h / 2,     w / 2, h / 2, 0., 0., 1., a);
+	igt_paint_color_alpha(cr, w / 2, h / 2, w / 4, h / 2, 1., 1., 1., a);
+	igt_paint_color_alpha(cr, 3 * w / 4, h / 2, w / 4, h / 2, 0., 0., 0., a);
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void draw_squares_coverage(struct igt_fb *fb, int w, int h, uint8_t as)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+	int i, j;
+	uint32_t *data = (void *)cairo_image_surface_get_data(fb->cairo_surface);
+	uint32_t stride = fb->strides[0] / 4;
+	uint32_t a = as << 24;
+
+	for (j = 0; j < h / 2; j++) {
+		for (i = 0; i < w / 2; i++)
+			data[j * stride + i] = a | 0xff0000;
+
+		for (; i < w; i++)
+			data[j * stride + i] = a | 0xff00;
+	}
+
+	for (j = h / 2; j < h; j++) {
+		for (i = 0; i < w / 2; i++)
+			data[j * stride + i] = a | 0xff;
+
+		for (; i < 3 * w / 4; i++)
+			data[j * stride + i] = a | 0xffffff;
+
+		for (; i < w; i++)
+			data[j * stride + i] = a;
+	}
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void reset_alpha(igt_display_t *display, enum pipe pipe)
+{
+	igt_plane_t *plane;
+

tests/kms_plane_alpha_blend.c line 138

Quoted 10 lines
tests/kms_plane_alpha_blend.c new file +10 -0
+	for_each_plane_on_pipe(display, pipe, plane) {
+		if (igt_plane_has_prop(plane, IGT_PLANE_ALPHA))
+			igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0xffff);
+
+		if (igt_plane_has_prop(plane, IGT_PLANE_PIXEL_BLEND_MODE))
+			igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "Pre-multiplied");
+	}
+}
+
+static bool has_multiplied_alpha(data_t *data, igt_plane_t *plane)

What's this "multiplied alpha"? Is that the constant alpha prop? Why can't we just look for the prop?

Quoted 133 lines
tests/kms_plane_alpha_blend.c new file +133 -0
+{
+	int ret;
+
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0x8080);
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	ret = igt_display_try_commit_atomic(&data->display,
+		DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0xffff);
+	igt_plane_set_fb(plane, NULL);
+
+	return ret == 0;
+}
+
+static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe)
+{
+	drmModeModeInfo *mode;
+	igt_display_t *display = &data->display;
+	int w, h;
+	igt_plane_t *primary = igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY);
+
+	igt_display_reset(display);
+	igt_output_set_pipe(output, pipe);
+
+	/* create the pipe_crc object for this pipe */
+	igt_pipe_crc_free(data->pipe_crc);
+	data->pipe_crc = igt_pipe_crc_new(data->gfx_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
+
+	mode = igt_output_get_mode(output);
+	w = mode->hdisplay;
+	h = mode->vdisplay;
+
+	/* recreate all fbs if incompatible */
+	if (data->xrgb_fb.width != w || data->xrgb_fb.height != h) {
+		cairo_t *cr;
+
+		igt_remove_fb(data->gfx_fd, &data->xrgb_fb);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_0);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_cov_0);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_7e);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_fc);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_cov_7e);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_cov_fc);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_100);
+		igt_remove_fb(data->gfx_fd, &data->black_fb);
+		igt_remove_fb(data->gfx_fd, &data->gray_fb);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->xrgb_fb);
+		draw_gradient(&data->xrgb_fb, w, h, 1.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_cov_0);
+		draw_gradient_coverage(&data->argb_fb_cov_0, w, h, 0);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_0);
+
+		cr = igt_get_cairo_ctx(data->gfx_fd, &data->argb_fb_0);
+		igt_paint_color_alpha(cr, 0, 0, w, h, 0., 0., 0., 1.0);
+		igt_put_cairo_ctx(data->gfx_fd, &data->argb_fb_0, cr);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_7e);
+		draw_squares(&data->argb_fb_7e, w, h, 126. / 255.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_cov_7e);
+		draw_squares_coverage(&data->argb_fb_cov_7e, w, h, 0x7e);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_fc);
+		draw_squares(&data->argb_fb_fc, w, h, 252. / 255.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_cov_fc);
+		draw_squares_coverage(&data->argb_fb_cov_fc, w, h, 0xfc);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_100);
+		draw_gradient(&data->argb_fb_100, w, h, 1.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->black_fb);
+
+		igt_create_color_fb(data->gfx_fd, w, h,
+				    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+				    .5, .5, .5, &data->gray_fb);
+	}
+
+	igt_plane_set_fb(primary, &data->black_fb);
+	/* reset alpha property to default */
+	reset_alpha(display, pipe);
+}
+
+static void basic_alpha(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+	int i;
+
+	/* Testcase 1: alpha = 0.0, plane should be transparant. */
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_start(data->pipe_crc);
+	igt_pipe_crc_get_single(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_0);
+
+	/* transparant fb should be transparant, no matter what.. */
+	for (i = 7; i < 256; i += 8) {
+		igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, i | (i << 8));
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+		igt_assert_crc_equal(&ref_crc, &crc);
+	}
+
+	/* And test alpha = 0, should give same CRC, but doesn't on some i915 platforms. */
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+
+	igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+	igt_pipe_crc_stop(data->pipe_crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+}

tests/kms_plane_alpha_blend.c line 281

Quoted 10 lines
tests/kms_plane_alpha_blend.c new file +10 -0
+
+static void argb_opaque(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+
+	/* alpha = 1.0, plane should be fully opaque, test with an opaque fb */
+	igt_plane_set_fb(plane, &data->xrgb_fb);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);

Could probably speed up the test quite a bit with crc_get_current()?

Quoted 11 lines
tests/kms_plane_alpha_blend.c new file +11 -0
+
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void argb_transparant(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;

tests/kms_plane_alpha_blend.c line 302

Quoted 10 lines
tests/kms_plane_alpha_blend.c new file +10 -0
+	igt_crc_t ref_crc, crc;
+
+	/* alpha = 1.0, plane should be fully opaque, test with a transparant fb */
+	igt_plane_set_fb(plane, NULL);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);

Might make it a bit easier to parse these if you didn't rely on the default state of the props and instead just set them explicitly.

In general this a bit repetitive. I wonder if some kind of declarative approach might increase the signal to noise ratio a bit.

To me it looks like the weak point of this test is that it mostly relies on comparins the different blend modes with each other. I guess there are enough ways to combine those to get decent assurances that they aren't just misbehaving in ways that make the crcs match by accident. Still, comparing against software rendered results would probably be how I'd have tried to approach this. That would also eliminate the dependency on having all the blend modes supported in the hardware.

Quoted 4 lines
Quoted 2 lines

Looks decent enough anyway, so

This is deliberate. HW might round in different ways then sw. So to compare hw rendering against sw, would assume a specific way of rounding.

I would expect we should be able to get close enough with certain alpha values. And there's always the "let's throw away some low bits with the lut" trick.

Quoted 3 lines

Some tests compare preblended 0xfc vs 0x7e. This way at least we know hw will probably round in the same way when sw does things in a certain way. Even if we don't know the exact rounding. Because 0xfc * 0x7e should be same as 0x7e * 0xfc.

Assuming the hw expands the per-pixel and constant alphas the same way. Not sure I'd want to take that bet.

Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#4 lore raw

[igt-dev] ✓ Fi.CI.BAT: success for tests: Add kms plane alpha blending test, v2.

In reply to Maarten Lankhorst
== Series Details ==

== Series Details ==

Series: tests: Add kms plane alpha blending test, v2.
URL : https://patchwork.freedesktop.org/series/50400/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4905 -> IGTPW_1887 =

== Summary - SUCCESS ==

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/50400/revisions/1/mbox/

== Known issues ==

Here are the changes found in IGTPW_1887 that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@gem_exec_suspend@basic-s3:
      fi-kbl-soraka:      NOTRUN -> INCOMPLETE (fdo#107774, fdo#107556)

    igt@kms_chamelium@common-hpd-after-suspend:
      fi-kbl-7500u:       NOTRUN -> DMESG-WARN (fdo#102505, fdo#105079, fdo#105602)

    igt@kms_frontbuffer_tracking@basic:
      fi-hsw-peppy:       NOTRUN -> DMESG-WARN (fdo#102614)

    igt@pm_rpm@module-reload:
      fi-hsw-peppy:       NOTRUN -> DMESG-WARN (fdo#107603, fdo#106386)

    
    ==== Possible fixes ====

    igt@drv_module_reload@basic-reload:
      fi-glk-j4005:       DMESG-WARN (fdo#106725, fdo#106248) -> PASS

    igt@gem_exec_suspend@basic-s3:
      fi-cfl-8109u:       DMESG-WARN (fdo#107345) -> PASS

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
      fi-cfl-8109u:       INCOMPLETE (fdo#106070) -> PASS

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-byt-clapper:     FAIL (fdo#103191, fdo#107362) -> PASS

    igt@kms_psr@primary_page_flip:
      fi-icl-u:           FAIL (fdo#107336) -> PASS

    igt@pm_rpm@module-reload:
      fi-glk-j4005:       DMESG-WARN (fdo#107726) -> PASS

fdo#102505 https://bugs.freedesktop.org/show_bug.cgi?id=102505
fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614
fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fdo#105079 https://bugs.freedesktop.org/show_bug.cgi?id=105079
fdo#105602 https://bugs.freedesktop.org/show_bug.cgi?id=105602
fdo#106070 https://bugs.freedesktop.org/show_bug.cgi?id=106070
fdo#106248 https://bugs.freedesktop.org/show_bug.cgi?id=106248
fdo#106386 https://bugs.freedesktop.org/show_bug.cgi?id=106386
fdo#106725 https://bugs.freedesktop.org/show_bug.cgi?id=106725
fdo#107336 https://bugs.freedesktop.org/show_bug.cgi?id=107336
fdo#107345 https://bugs.freedesktop.org/show_bug.cgi?id=107345
fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362
fdo#107556 https://bugs.freedesktop.org/show_bug.cgi?id=107556
fdo#107603 https://bugs.freedesktop.org/show_bug.cgi?id=107603
fdo#107726 https://bugs.freedesktop.org/show_bug.cgi?id=107726
fdo#107774 https://bugs.freedesktop.org/show_bug.cgi?id=107774

== Participating hosts (40 -> 46) ==

Additional (13): fi-kbl-soraka fi-bdw-5557u fi-hsw-peppy fi-bdw-gvtdvm fi-skl-6260u fi-ilk-650 fi-kbl-7500u fi-kbl-guc fi-kbl-x1275 fi-gdg-551 fi-elk-e7500 fi-ivb-3520m fi-skl-caroline
Missing (7): fi-ilk-m540 fi-hsw-4200u fi-icl-u2 fi-bsw-cyan fi-ctg-p8600 fi-ivb-3770 fi-pnv-d510

== Build changes ==

* IGT: IGT_4657 -> IGTPW_1887

CI_DRM_4905: 4d5d563418cb731acc0e628c936e77c1172ccbdb @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_1887: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1887/
IGT_4657: bdc8989328f57ec2e63a88c89a45440567c69eeb @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Testlist changes ==

+igt@kms_plane_alpha_blend@pipe-a-alpha-7efc +igt@kms_plane_alpha_blend@pipe-a-alpha-basic +igt@kms_plane_alpha_blend@pipe-a-alpha-opaque-fb +igt@kms_plane_alpha_blend@pipe-a-alpha-transparant-fb +igt@kms_plane_alpha_blend@pipe-a-constant-alpha-max +igt@kms_plane_alpha_blend@pipe-a-constant-alpha-mid +igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min +igt@kms_plane_alpha_blend@pipe-a-coverage-7efc +igt@kms_plane_alpha_blend@pipe-a-coverage-vs-premult-vs-constant +igt@kms_plane_alpha_blend@pipe-b-alpha-7efc +igt@kms_plane_alpha_blend@pipe-b-alpha-basic +igt@kms_plane_alpha_blend@pipe-b-alpha-opaque-fb +igt@kms_plane_alpha_blend@pipe-b-alpha-transparant-fb +igt@kms_plane_alpha_blend@pipe-b-constant-alpha-max +igt@kms_plane_alpha_blend@pipe-b-constant-alpha-mid +igt@kms_plane_alpha_blend@pipe-b-constant-alpha-min +igt@kms_plane_alpha_blend@pipe-b-coverage-7efc +igt@kms_plane_alpha_blend@pipe-b-coverage-vs-premult-vs-constant +igt@kms_plane_alpha_blend@pipe-c-alpha-7efc +igt@kms_plane_alpha_blend@pipe-c-alpha-basic +igt@kms_plane_alpha_blend@pipe-c-alpha-opaque-fb +igt@kms_plane_alpha_blend@pipe-c-alpha-transparant-fb +igt@kms_plane_alpha_blend@pipe-c-constant-alpha-max +igt@kms_plane_alpha_blend@pipe-c-constant-alpha-mid +igt@kms_plane_alpha_blend@pipe-c-constant-alpha-min +igt@kms_plane_alpha_blend@pipe-c-coverage-7efc +igt@kms_plane_alpha_blend@pipe-c-coverage-vs-premult-vs-constant +igt@kms_plane_alpha_blend@pipe-d-alpha-7efc +igt@kms_plane_alpha_blend@pipe-d-alpha-basic +igt@kms_plane_alpha_blend@pipe-d-alpha-opaque-fb +igt@kms_plane_alpha_blend@pipe-d-alpha-transparant-fb +igt@kms_plane_alpha_blend@pipe-d-constant-alpha-max +igt@kms_plane_alpha_blend@pipe-d-constant-alpha-mid +igt@kms_plane_alpha_blend@pipe-d-constant-alpha-min +igt@kms_plane_alpha_blend@pipe-d-coverage-7efc +igt@kms_plane_alpha_blend@pipe-d-coverage-vs-premult-vs-constant +igt@kms_plane_alpha_blend@pipe-e-alpha-7efc +igt@kms_plane_alpha_blend@pipe-e-alpha-basic +igt@kms_plane_alpha_blend@pipe-e-alpha-opaque-fb +igt@kms_plane_alpha_blend@pipe-e-alpha-transparant-fb +igt@kms_plane_alpha_blend@pipe-e-constant-alpha-max +igt@kms_plane_alpha_blend@pipe-e-constant-alpha-mid +igt@kms_plane_alpha_blend@pipe-e-constant-alpha-min +igt@kms_plane_alpha_blend@pipe-e-coverage-7efc +igt@kms_plane_alpha_blend@pipe-e-coverage-vs-premult-vs-constant +igt@kms_plane_alpha_blend@pipe-f-alpha-7efc +igt@kms_plane_alpha_blend@pipe-f-alpha-basic +igt@kms_plane_alpha_blend@pipe-f-alpha-opaque-fb +igt@kms_plane_alpha_blend@pipe-f-alpha-transparant-fb +igt@kms_plane_alpha_blend@pipe-f-constant-alpha-max +igt@kms_plane_alpha_blend@pipe-f-constant-alpha-mid +igt@kms_plane_alpha_blend@pipe-f-constant-alpha-min +igt@kms_plane_alpha_blend@pipe-f-coverage-7efc +igt@kms_plane_alpha_blend@pipe-f-coverage-vs-premult-vs-constant

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1887/issues.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#5 lore raw

[igt-dev] ✓ Fi.CI.IGT: success for tests: Add kms plane alpha blending test, v2.

In reply to Maarten Lankhorst
== Series Details ==

== Series Details ==

Series: tests: Add kms plane alpha blending test, v2.
URL : https://patchwork.freedesktop.org/series/50400/
State : success

== Summary ==

= CI Bug Log - changes from IGT_4657_full -> IGTPW_1887_full =

== Summary - WARNING ==

Minor unknown changes coming with IGTPW_1887_full need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in IGTPW_1887_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://patchwork.freedesktop.org/api/1.0/series/50400/revisions/1/mbox/

== Possible new issues ==

Here are the unknown changes that may have been introduced in IGTPW_1887_full:

=== IGT changes ===

    ==== Warnings ====

    igt@kms_frontbuffer_tracking@fbc-1p-indfb-fliptrack:
      shard-snb:          SKIP -> PASS +1

    igt@pm_rc6_residency@rc6-accuracy:
      shard-kbl:          PASS -> SKIP

== Known issues ==

Here are the changes found in IGTPW_1887_full that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@kms_busy@extended-modeset-hang-newfb-render-c:
      shard-hsw:          PASS -> DMESG-WARN (fdo#107956)

    igt@kms_busy@extended-pageflip-hang-newfb-render-b:
      shard-apl:          PASS -> DMESG-WARN (fdo#107956)

    igt@kms_draw_crc@fill-fb:
      shard-glk:          PASS -> FAIL (fdo#103184)

    igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-move:
      shard-glk:          PASS -> DMESG-FAIL (fdo#106538)

    igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-cur-indfb-move:
      shard-glk:          PASS -> FAIL (fdo#103167) +1

    igt@kms_rotation_crc@sprite-rotation-180:
      shard-snb:          PASS -> FAIL (fdo#103925)

    igt@kms_setmode@basic:
      shard-hsw:          PASS -> FAIL (fdo#99912)

    igt@kms_vblank@pipe-a-ts-continuation-dpms-suspend:
      shard-kbl:          PASS -> INCOMPLETE (fdo#103665)

    
    ==== Possible fixes ====

    igt@gem_ctx_isolation@rcs0-s3:
      shard-kbl:          INCOMPLETE (fdo#103665) -> PASS

    igt@gem_exec_await@wide-contexts:
      shard-kbl:          FAIL (fdo#106680) -> PASS

    igt@gem_ppgtt@blt-vs-render-ctxn:
      shard-kbl:          INCOMPLETE (fdo#103665, fdo#106023) -> PASS

    igt@kms_flip@flip-vs-expired-vblank-interruptible:
      shard-glk:          FAIL (fdo#105363, fdo#102887) -> PASS

    igt@kms_frontbuffer_tracking@fbc-1p-primscrn-indfb-pgflip-blt:
      shard-snb:          INCOMPLETE (fdo#105411) -> PASS

fdo#102887 https://bugs.freedesktop.org/show_bug.cgi?id=102887
fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
fdo#103184 https://bugs.freedesktop.org/show_bug.cgi?id=103184
fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925
fdo#105363 https://bugs.freedesktop.org/show_bug.cgi?id=105363
fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
fdo#106023 https://bugs.freedesktop.org/show_bug.cgi?id=106023
fdo#106538 https://bugs.freedesktop.org/show_bug.cgi?id=106538
fdo#106680 https://bugs.freedesktop.org/show_bug.cgi?id=106680
fdo#107956 https://bugs.freedesktop.org/show_bug.cgi?id=107956
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912

== Participating hosts (6 -> 5) ==

Missing (1): shard-skl

== Build changes ==

* IGT: IGT_4657 -> IGTPW_1887
* Linux: CI_DRM_4904 -> CI_DRM_4905

CI_DRM_4904: 17de1f39d3f99bdd07cbf00c162a6cd9b3cf944e @ git://anongit.freedesktop.org/gfx-ci/linux
CI_DRM_4905: 4d5d563418cb731acc0e628c936e77c1172ccbdb @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_1887: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1887/
IGT_4657: bdc8989328f57ec2e63a88c89a45440567c69eeb @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1887/shards.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev