* [igt-dev] [PATCH i-g-t] tests/amdgpu: Add color tests for amdgpu @ 2019-05-27 17:19 Nicholas Kazlauskas 2019-05-27 18:08 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork ` (2 more replies) 0 siblings, 3 replies; 10+ messages in thread From: Nicholas Kazlauskas @ 2019-05-27 17:19 UTC (permalink / raw) To: igt-dev The DRM color management pipeline doesn't directly map to AMD hardware so creative solutions to implementing CRTC regamma, CTM and gamma were needed for both DCE and DCN. A few mistakes were made in the process that weren't caught by kms_color@ tests: - Can't get linear degamma output without setting a custom degamma - Can't specify a non-linear degamma that produces correct output - Can't specify a correct gamma when a linear degamma is used These are caused by using implicit sRGB degamma then sRGB gamma when no matrices are set. This produces visually correct output when using a CTM with no matrices set, but it's also technically the incorrect output according to the DRM API documentation. These tests help verify that AMDGPU follows the DRM spec when it comes to setting linear/bypass gamma and regamma LUT. The existing kms_color@ tests are written correctly already, so anything that looks shared in these is really just to verify that we're no longer doing any strange test specific workarounds outside of the spec or documentation. Cc: Leo Li <sunpeng.li@amd.com> Cc: Harry Wentland <harry.wentland@amd.com> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com> --- tests/Makefile.sources | 1 + tests/amdgpu/amd_color.c | 405 +++++++++++++++++++++++++++++++++++++++ tests/amdgpu/meson.build | 1 + 3 files changed, 407 insertions(+) create mode 100644 tests/amdgpu/amd_color.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 2d5c929e..ef3c03f2 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -6,6 +6,7 @@ NOUVEAU_TESTS = \ AMDGPU_TESTS = \ amdgpu/amd_basic \ + amdgpu/amd_color \ amdgpu/amd_cs_nop \ amdgpu/amd_prime \ amdgpu/amd_abm \ diff --git a/tests/amdgpu/amd_color.c b/tests/amdgpu/amd_color.c new file mode 100644 index 00000000..0bbee43d --- /dev/null +++ b/tests/amdgpu/amd_color.c @@ -0,0 +1,405 @@ +/* + * Copyright 2019 Advanced Micro Devices, Inc. + * + * 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. + */ + +#include "igt.h" + +/* (De)gamma LUT. */ +typedef struct lut { + struct drm_color_lut *data; + uint32_t size; +} lut_t; + +/* RGB color. */ +typedef struct color { + double r; + double g; + double b; +} color_t; + +/* Common test data. */ +typedef struct data { + igt_display_t display; + igt_plane_t *primary; + igt_output_t *output; + igt_pipe_t *pipe; + igt_pipe_crc_t *pipe_crc; + drmModeModeInfo *mode; + enum pipe pipe_id; + int fd; + int w; + int h; + uint32_t regamma_lut_size; + uint32_t degamma_lut_size; +} data_t; + +static void lut_init(lut_t *lut, uint32_t size) +{ + igt_assert(size > 0); + + lut->size = size; + lut->data = malloc(size * sizeof(struct drm_color_lut)); + igt_assert(lut); +} + +/* Generates the linear gamma LUT. */ +static void lut_gen_linear(lut_t *lut, uint16_t mask) +{ + uint32_t n = lut->size - 1; + uint32_t i; + + for (i = 0; i < lut->size; ++i) { + uint32_t v = (i * 0xffff / n) & mask; + + lut->data[i].red = v; + lut->data[i].blue = v; + lut->data[i].green = v; + } +} + +/* Generates the sRGB degamma LUT. */ +static void lut_gen_degamma_srgb(lut_t *lut, uint16_t mask) +{ + double range = lut->size - 1; + uint32_t i; + + for (i = 0; i < lut->size; ++i) { + double u, coeff; + uint32_t v; + + u = i / range; + coeff = u <= 0.040449936 ? (u / 12.92) + : (pow((u + 0.055) / 1.055, 2.4)); + v = (uint32_t)(coeff * 0xffff) & mask; + + lut->data[i].red = v; + lut->data[i].blue = v; + lut->data[i].green = v; + } +} + +/* Generates the sRGB gamma LUT. */ +static void lut_gen_regamma_srgb(lut_t *lut, uint16_t mask) +{ + double range = lut->size - 1; + uint32_t i; + + for (i = 0; i < lut->size; ++i) { + double u, coeff; + uint32_t v; + + u = i / range; + coeff = u <= 0.00313080 ? (12.92 * u) + : (1.055 * pow(u, 1.0 / 2.4) - 0.055); + v = (uint32_t)(coeff * 0xffff) & mask; + + lut->data[i].red = v; + lut->data[i].blue = v; + lut->data[i].green = v; + } +} + +static void lut_free(lut_t *lut) +{ + if (lut->data) { + free(lut->data); + lut->data = NULL; + } + + lut->size = 0; +} + +/* Fills a FB with the solid color given. */ +static void draw_color(igt_fb_t *fb, double r, double g, double b) +{ + cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb); + + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); + igt_paint_color(cr, 0, 0, fb->width, fb->height, r, g, b); + igt_put_cairo_ctx(fb->fd, fb, cr); +} + +/* Generates the gamma test pattern. */ +static void draw_gamma_test(igt_fb_t *fb) +{ + cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb); + int gh = fb->height / 4; + + igt_paint_color_gradient(cr, 0, 0, fb->width, gh, 1, 1, 1); + igt_paint_color_gradient(cr, 0, gh, fb->width, gh, 1, 0, 0); + igt_paint_color_gradient(cr, 0, gh * 2, fb->width, gh, 0, 1, 0); + igt_paint_color_gradient(cr, 0, gh * 3, fb->width, gh, 0, 0, 1); + + igt_put_cairo_ctx(fb->fd, fb, cr); +} + +/* Sets the degamma LUT. */ +static void set_degamma_lut(data_t *data, lut_t const *lut) +{ + size_t size = lut ? sizeof(lut->data[0]) * lut->size : 0; + const void *ptr = lut ? lut->data : NULL; + + igt_pipe_obj_replace_prop_blob(data->pipe, IGT_CRTC_DEGAMMA_LUT, ptr, + size); +} + +/* Sets the regamma LUT. */ +static void set_regamma_lut(data_t *data, lut_t const *lut) +{ + size_t size = lut ? sizeof(lut->data[0]) * lut->size : 0; + const void *ptr = lut ? lut->data : NULL; + + igt_pipe_obj_replace_prop_blob(data->pipe, IGT_CRTC_GAMMA_LUT, ptr, + size); +} + +/* Common test setup. */ +static void test_init(data_t *data) +{ + igt_display_t *display = &data->display; + + /* It doesn't matter which pipe we choose on amdpgu. */ + data->pipe_id = PIPE_A; + data->pipe = &data->display.pipes[data->pipe_id]; + + igt_display_reset(display); + + data->output = igt_get_single_output_for_pipe(display, data->pipe_id); + igt_require(data->output); + + data->mode = igt_output_get_mode(data->output); + igt_assert(data->mode); + + data->primary = + igt_pipe_get_plane_type(data->pipe, DRM_PLANE_TYPE_PRIMARY); + + data->pipe_crc = igt_pipe_crc_new(data->fd, data->pipe_id, + INTEL_PIPE_CRC_SOURCE_AUTO); + + igt_output_set_pipe(data->output, data->pipe_id); + + data->degamma_lut_size = + igt_pipe_obj_get_prop(data->pipe, IGT_CRTC_DEGAMMA_LUT_SIZE); + igt_assert_lt(0, data->degamma_lut_size); + + data->regamma_lut_size = + igt_pipe_obj_get_prop(data->pipe, IGT_CRTC_GAMMA_LUT_SIZE); + igt_assert_lt(0, data->regamma_lut_size); + + data->w = data->mode->hdisplay; + data->h = data->mode->vdisplay; +} + +/* Common test cleanup. */ +static void test_fini(data_t *data) +{ + igt_pipe_crc_free(data->pipe_crc); + igt_display_reset(&data->display); +} + +/* + * Older versions of amdgpu would put the pipe into bypass mode for degamma + * when passed a linear sRGB matrix but would still use an sRGB regamma + * matrix if not passed any. The whole pipe should be in linear bypass mode + * when all the matrices are NULL - CRCs for a linear degamma matrix and + * a NULL one should match. + */ +static void test_crtc_linear_degamma(data_t *data) +{ + igt_display_t *display = &data->display; + igt_crc_t ref_crc, new_crc; + igt_fb_t afb; + lut_t lut_linear; + + test_init(data); + + lut_init(&lut_linear, data->degamma_lut_size); + lut_gen_linear(&lut_linear, 0xffff); + + igt_create_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888, 0, &afb); + draw_gamma_test(&afb); + + /* Draw the reference image. */ + igt_plane_set_fb(data->primary, &afb); + set_regamma_lut(data, NULL); + set_degamma_lut(data, NULL); + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); + + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); + + /* Apply a linear degamma. The result should remain the same. */ + set_degamma_lut(data, &lut_linear); + igt_display_commit_atomic(display, 0, NULL); + + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); + igt_assert_crc_equal(&ref_crc, &new_crc); + + test_fini(data); + igt_remove_fb(data->fd, &afb); + lut_free(&lut_linear); +} + +/* + * Older versions of amdgpu would apply the CRTC regamma on top of a custom + * sRGB regamma matrix with incorrect calculations or rounding errors. + * If we put the pipe into bypass or use the hardware defined sRGB regamma + * on the plane then we can and should get the correct CRTC when passing a + * liner regamma matrix to DRM. + */ +static void test_crtc_linear_regamma(data_t *data) +{ + igt_display_t *display = &data->display; + igt_crc_t ref_crc, new_crc; + igt_fb_t afb; + lut_t lut_linear; + + test_init(data); + + lut_init(&lut_linear, data->regamma_lut_size); + lut_gen_linear(&lut_linear, 0xffff); + + igt_create_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888, 0, &afb); + draw_gamma_test(&afb); + + /* Draw the reference image. */ + igt_plane_set_fb(data->primary, &afb); + set_regamma_lut(data, NULL); + set_degamma_lut(data, NULL); + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); + + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); + + /* Apply a linear degamma. The result should remain the same. */ + set_regamma_lut(data, &lut_linear); + igt_display_commit_atomic(display, 0, NULL); + + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); + igt_assert_crc_equal(&ref_crc, &new_crc); + + test_fini(data); + igt_remove_fb(data->fd, &afb); + lut_free(&lut_linear); +} + +/* + * Tests LUT accuracy. CRTC regamma and CRTC degamma should produce a visually + * correct image when used. Hardware limitations on degamma prevent this from + * being CRC level accurate across a full test gradient but most values should + * still match. + * + * This test can't pass on DCE because it doesn't support non-linear degamma. + */ +static void test_crtc_lut_accuracy(data_t *data) +{ + /* + * Channels are independent, so we can verify multiple colors at the + * same time for improved performance. + */ + static const color_t colors[] = { + { 1.00, 1.00, 1.00 }, + { 0.90, 0.85, 0.75 }, /* 0.95 fails */ + { 0.70, 0.65, 0.60 }, + { 0.55, 0.50, 0.45 }, + { 0.40, 0.35, 0.30 }, + { 0.25, 0.20, 0.15 }, + { 0.10, 0.04, 0.02 }, /* 0.05 fails */ + { 0.00, 0.00, 0.00 }, + }; + igt_display_t *display = &data->display; + igt_crc_t ref_crc, new_crc; + igt_fb_t afb; + lut_t lut_degamma, lut_regamma; + int i, w, h; + + test_init(data); + + lut_init(&lut_degamma, data->degamma_lut_size); + lut_gen_degamma_srgb(&lut_degamma, 0xffff); + + lut_init(&lut_regamma, data->regamma_lut_size); + lut_gen_regamma_srgb(&lut_regamma, 0xffff); + + /* Don't draw across the whole screen to improve perf. */ + w = 64; + h = 64; + + igt_create_fb(data->fd, w, h, DRM_FORMAT_XRGB8888, 0, &afb); + igt_plane_set_fb(data->primary, &afb); + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); + + /* Test colors. */ + for (i = 0; i < ARRAY_SIZE(colors); ++i) { + color_t col = colors[i]; + + igt_info("Testing color (%.2f, %.2f, %.2f) ...\n", col.r, col.g, + col.b); + + draw_color(&afb, col.r, col.g, col.b); + + set_regamma_lut(data, NULL); + set_degamma_lut(data, NULL); + igt_display_commit_atomic(display, 0, NULL); + + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); + + set_degamma_lut(data, &lut_degamma); + set_regamma_lut(data, &lut_regamma); + igt_display_commit_atomic(display, 0, NULL); + + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); + + igt_assert_crc_equal(&ref_crc, &new_crc); + } + + test_fini(data); + igt_remove_fb(data->fd, &afb); + lut_free(&lut_regamma); + lut_free(&lut_degamma); +} + +igt_main +{ + data_t data; + + igt_skip_on_simulation(); + + memset(&data, 0, sizeof(data)); + + igt_fixture + { + data.fd = drm_open_driver_master(DRIVER_AMDGPU); + + kmstest_set_vt_graphics_mode(); + + igt_display_require(&data.display, data.fd); + igt_require(data.display.is_atomic); + igt_display_require_output(&data.display); + } + + igt_subtest("crtc-linear-degamma") test_crtc_linear_degamma(&data); + igt_subtest("crtc-linear-regamma") test_crtc_linear_regamma(&data); + igt_subtest("crtc-lut-accuracy") test_crtc_lut_accuracy(&data); + + igt_fixture + { + igt_display_fini(&data.display); + } +} diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build index 1afece86..42086374 100644 --- a/tests/amdgpu/meson.build +++ b/tests/amdgpu/meson.build @@ -4,6 +4,7 @@ amdgpu_deps = test_deps if libdrm_amdgpu.found() amdgpu_progs += [ 'amd_abm', 'amd_basic', + 'amd_color', 'amd_cs_nop', 'amd_prime', ] -- 2.17.1 _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [igt-dev] ✓ Fi.CI.BAT: success for tests/amdgpu: Add color tests for amdgpu 2019-05-27 17:19 [igt-dev] [PATCH i-g-t] tests/amdgpu: Add color tests for amdgpu Nicholas Kazlauskas @ 2019-05-27 18:08 ` Patchwork 2019-05-28 5:45 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork 2019-05-29 18:43 ` [igt-dev] [PATCH i-g-t] " Li, Sun peng (Leo) 2 siblings, 0 replies; 10+ messages in thread From: Patchwork @ 2019-05-27 18:08 UTC (permalink / raw) To: Nicholas Kazlauskas; +Cc: igt-dev == Series Details == Series: tests/amdgpu: Add color tests for amdgpu URL : https://patchwork.freedesktop.org/series/61215/ State : success == Summary == CI Bug Log - changes from CI_DRM_6149 -> IGTPW_3065 ==================================================== Summary ------- **SUCCESS** No regressions found. External URL: https://patchwork.freedesktop.org/api/1.0/series/61215/revisions/1/mbox/ Known issues ------------ Here are the changes found in IGTPW_3065 that come from known issues: ### IGT changes ### #### Possible fixes #### * igt@gem_basic@create-fd-close: - {fi-icl-dsi}: [DMESG-WARN][1] ([fdo#106107]) -> [PASS][2] [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/fi-icl-dsi/igt@gem_basic@create-fd-close.html [2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/fi-icl-dsi/igt@gem_basic@create-fd-close.html - fi-cml-u2: [INCOMPLETE][3] ([fdo#110566]) -> [PASS][4] [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/fi-cml-u2/igt@gem_basic@create-fd-close.html [4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/fi-cml-u2/igt@gem_basic@create-fd-close.html * igt@gem_exec_suspend@basic-s3: - fi-blb-e6850: [INCOMPLETE][5] ([fdo#107718]) -> [PASS][6] [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/fi-blb-e6850/igt@gem_exec_suspend@basic-s3.html [6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/fi-blb-e6850/igt@gem_exec_suspend@basic-s3.html * igt@i915_pm_rpm@module-reload: - fi-skl-6770hq: [FAIL][7] ([fdo#108511]) -> [PASS][8] [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/fi-skl-6770hq/igt@i915_pm_rpm@module-reload.html [8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/fi-skl-6770hq/igt@i915_pm_rpm@module-reload.html * igt@i915_selftest@live_contexts: - fi-bdw-gvtdvm: [DMESG-FAIL][9] ([fdo#110235]) -> [PASS][10] [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/fi-bdw-gvtdvm/igt@i915_selftest@live_contexts.html [10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/fi-bdw-gvtdvm/igt@i915_selftest@live_contexts.html * {igt@i915_selftest@live_reset}: - fi-skl-iommu: [INCOMPLETE][11] ([fdo#108602]) -> [PASS][12] [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/fi-skl-iommu/igt@i915_selftest@live_reset.html [12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/fi-skl-iommu/igt@i915_selftest@live_reset.html {name}: This element is suppressed. This means it is ignored when computing the status of the difference (SUCCESS, WARNING, or FAILURE). [fdo#106107]: https://bugs.freedesktop.org/show_bug.cgi?id=106107 [fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718 [fdo#108511]: https://bugs.freedesktop.org/show_bug.cgi?id=108511 [fdo#108602]: https://bugs.freedesktop.org/show_bug.cgi?id=108602 [fdo#110235]: https://bugs.freedesktop.org/show_bug.cgi?id=110235 [fdo#110566]: https://bugs.freedesktop.org/show_bug.cgi?id=110566 Participating hosts (52 -> 45) ------------------------------ Additional (2): fi-icl-u2 fi-bdw-5557u Missing (9): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-icl-u3 fi-byt-clapper fi-bdw-samus Build changes ------------- * IGT: IGT_5017 -> IGTPW_3065 CI_DRM_6149: e8f06c34fa3c76fa94010485e07b89935fa8b9b5 @ git://anongit.freedesktop.org/gfx-ci/linux IGTPW_3065: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/ IGT_5017: 2892adce93fb8eea3d764dc0f766a202d9dcef37 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools == Testlist changes == +igt@amdgpu/amd_color@crtc-linear-degamma +igt@amdgpu/amd_color@crtc-linear-regamma +igt@amdgpu/amd_color@crtc-lut-accuracy == Logs == For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/ _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 10+ messages in thread
* [igt-dev] ✓ Fi.CI.IGT: success for tests/amdgpu: Add color tests for amdgpu 2019-05-27 17:19 [igt-dev] [PATCH i-g-t] tests/amdgpu: Add color tests for amdgpu Nicholas Kazlauskas 2019-05-27 18:08 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork @ 2019-05-28 5:45 ` Patchwork 2019-05-29 18:43 ` [igt-dev] [PATCH i-g-t] " Li, Sun peng (Leo) 2 siblings, 0 replies; 10+ messages in thread From: Patchwork @ 2019-05-28 5:45 UTC (permalink / raw) To: Nicholas Kazlauskas; +Cc: igt-dev == Series Details == Series: tests/amdgpu: Add color tests for amdgpu URL : https://patchwork.freedesktop.org/series/61215/ State : success == Summary == CI Bug Log - changes from CI_DRM_6149_full -> IGTPW_3065_full ==================================================== Summary ------- **SUCCESS** No regressions found. External URL: https://patchwork.freedesktop.org/api/1.0/series/61215/revisions/1/mbox/ Known issues ------------ Here are the changes found in IGTPW_3065_full that come from known issues: ### IGT changes ### #### Issues hit #### * igt@gem_ctx_switch@basic-default: - shard-iclb: [PASS][1] -> [INCOMPLETE][2] ([fdo#107713] / [fdo#108569]) [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-iclb1/igt@gem_ctx_switch@basic-default.html [2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-iclb8/igt@gem_ctx_switch@basic-default.html * igt@gem_workarounds@suspend-resume-context: - shard-apl: [PASS][3] -> [DMESG-WARN][4] ([fdo#108566]) +2 similar issues [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-apl8/igt@gem_workarounds@suspend-resume-context.html [4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-apl2/igt@gem_workarounds@suspend-resume-context.html * igt@kms_cursor_crc@pipe-a-cursor-128x128-sliding: - shard-kbl: [PASS][5] -> [FAIL][6] ([fdo#103232]) [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-kbl3/igt@kms_cursor_crc@pipe-a-cursor-128x128-sliding.html [6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-kbl3/igt@kms_cursor_crc@pipe-a-cursor-128x128-sliding.html * igt@kms_flip@2x-flip-vs-dpms-off-vs-modeset: - shard-hsw: [PASS][7] -> [SKIP][8] ([fdo#109271]) +17 similar issues [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-hsw7/igt@kms_flip@2x-flip-vs-dpms-off-vs-modeset.html [8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-hsw1/igt@kms_flip@2x-flip-vs-dpms-off-vs-modeset.html * igt@kms_flip@2x-flip-vs-expired-vblank-interruptible: - shard-glk: [PASS][9] -> [FAIL][10] ([fdo#105363]) [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-glk1/igt@kms_flip@2x-flip-vs-expired-vblank-interruptible.html [10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-glk2/igt@kms_flip@2x-flip-vs-expired-vblank-interruptible.html * igt@kms_flip@flip-vs-expired-vblank: - shard-glk: [PASS][11] -> [FAIL][12] ([fdo#102887] / [fdo#105363]) [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-glk5/igt@kms_flip@flip-vs-expired-vblank.html [12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-glk1/igt@kms_flip@flip-vs-expired-vblank.html * igt@kms_flip@flip-vs-suspend-interruptible: - shard-hsw: [PASS][13] -> [INCOMPLETE][14] ([fdo#103540]) [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-hsw1/igt@kms_flip@flip-vs-suspend-interruptible.html [14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-hsw2/igt@kms_flip@flip-vs-suspend-interruptible.html * igt@kms_flip_tiling@flip-to-x-tiled: - shard-iclb: [PASS][15] -> [FAIL][16] ([fdo#108134]) [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-iclb2/igt@kms_flip_tiling@flip-to-x-tiled.html [16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-iclb6/igt@kms_flip_tiling@flip-to-x-tiled.html * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-move: - shard-iclb: [PASS][17] -> [FAIL][18] ([fdo#103167]) +7 similar issues [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-iclb8/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-move.html [18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-iclb4/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-move.html * igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b: - shard-kbl: [PASS][19] -> [INCOMPLETE][20] ([fdo#103665]) [19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-kbl3/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b.html [20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-kbl4/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b.html * igt@kms_psr@psr2_sprite_mmap_gtt: - shard-iclb: [PASS][21] -> [SKIP][22] ([fdo#109441]) [21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-iclb2/igt@kms_psr@psr2_sprite_mmap_gtt.html [22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-iclb3/igt@kms_psr@psr2_sprite_mmap_gtt.html * igt@kms_vblank@pipe-c-ts-continuation-suspend: - shard-kbl: [PASS][23] -> [DMESG-WARN][24] ([fdo#108566]) +2 similar issues [23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-kbl4/igt@kms_vblank@pipe-c-ts-continuation-suspend.html [24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-kbl1/igt@kms_vblank@pipe-c-ts-continuation-suspend.html * igt@perf_pmu@rc6-runtime-pm-long: - shard-kbl: [PASS][25] -> [FAIL][26] ([fdo#105010]) [25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-kbl3/igt@perf_pmu@rc6-runtime-pm-long.html [26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-kbl2/igt@perf_pmu@rc6-runtime-pm-long.html #### Possible fixes #### * igt@gem_exec_big@single: - shard-glk: [INCOMPLETE][27] ([fdo#103359] / [k.org#198133]) -> [PASS][28] [27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-glk8/igt@gem_exec_big@single.html [28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-glk2/igt@gem_exec_big@single.html * igt@gem_tiled_swapping@non-threaded: - shard-glk: [DMESG-WARN][29] ([fdo#108686]) -> [PASS][30] [29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-glk8/igt@gem_tiled_swapping@non-threaded.html [30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-glk4/igt@gem_tiled_swapping@non-threaded.html * igt@i915_pm_rpm@legacy-planes: - shard-iclb: [INCOMPLETE][31] ([fdo#107713] / [fdo#108840] / [fdo#109960]) -> [PASS][32] [31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-iclb2/igt@i915_pm_rpm@legacy-planes.html [32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-iclb5/igt@i915_pm_rpm@legacy-planes.html * igt@kms_flip@2x-flip-vs-expired-vblank-interruptible: - shard-hsw: [SKIP][33] ([fdo#109271]) -> [PASS][34] +23 similar issues [33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-hsw1/igt@kms_flip@2x-flip-vs-expired-vblank-interruptible.html [34]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-hsw2/igt@kms_flip@2x-flip-vs-expired-vblank-interruptible.html * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-pwrite: - shard-apl: [FAIL][35] ([fdo#103167]) -> [PASS][36] [35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-apl2/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-pwrite.html [36]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-apl7/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-pwrite.html - shard-kbl: [FAIL][37] ([fdo#103167]) -> [PASS][38] [37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-kbl6/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-pwrite.html [38]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-kbl3/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-pwrite.html * igt@kms_frontbuffer_tracking@fbc-2p-primscrn-cur-indfb-draw-render: - shard-glk: [FAIL][39] ([fdo#103167]) -> [PASS][40] [39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-glk6/igt@kms_frontbuffer_tracking@fbc-2p-primscrn-cur-indfb-draw-render.html [40]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-glk5/igt@kms_frontbuffer_tracking@fbc-2p-primscrn-cur-indfb-draw-render.html * igt@kms_frontbuffer_tracking@fbcpsr-1p-shrfb-fliptrack: - shard-iclb: [FAIL][41] ([fdo#103167]) -> [PASS][42] +1 similar issue [41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-iclb1/igt@kms_frontbuffer_tracking@fbcpsr-1p-shrfb-fliptrack.html [42]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-iclb5/igt@kms_frontbuffer_tracking@fbcpsr-1p-shrfb-fliptrack.html * igt@kms_plane_alpha_blend@pipe-c-alpha-transparant-fb: - shard-iclb: [INCOMPLETE][43] ([fdo#107713]) -> [PASS][44] +1 similar issue [43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-iclb7/igt@kms_plane_alpha_blend@pipe-c-alpha-transparant-fb.html [44]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-iclb6/igt@kms_plane_alpha_blend@pipe-c-alpha-transparant-fb.html * igt@kms_psr2_su@frontbuffer: - shard-iclb: [SKIP][45] ([fdo#109642]) -> [PASS][46] [45]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-iclb3/igt@kms_psr2_su@frontbuffer.html [46]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-iclb2/igt@kms_psr2_su@frontbuffer.html * igt@kms_psr@no_drrs: - shard-iclb: [FAIL][47] ([fdo#108341]) -> [PASS][48] [47]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-iclb1/igt@kms_psr@no_drrs.html [48]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-iclb4/igt@kms_psr@no_drrs.html * igt@kms_psr@psr2_cursor_render: - shard-iclb: [SKIP][49] ([fdo#109441]) -> [PASS][50] +1 similar issue [49]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-iclb7/igt@kms_psr@psr2_cursor_render.html [50]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-iclb2/igt@kms_psr@psr2_cursor_render.html * igt@kms_vblank@pipe-c-ts-continuation-suspend: - shard-apl: [DMESG-WARN][51] ([fdo#108566]) -> [PASS][52] +7 similar issues [51]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-apl7/igt@kms_vblank@pipe-c-ts-continuation-suspend.html [52]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-apl4/igt@kms_vblank@pipe-c-ts-continuation-suspend.html #### Warnings #### * igt@gem_mmap_gtt@forked-big-copy: - shard-iclb: [TIMEOUT][53] ([fdo#109673]) -> [INCOMPLETE][54] ([fdo#107713] / [fdo#109100]) [53]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-iclb8/igt@gem_mmap_gtt@forked-big-copy.html [54]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-iclb8/igt@gem_mmap_gtt@forked-big-copy.html * igt@gem_mmap_gtt@forked-big-copy-xy: - shard-iclb: [INCOMPLETE][55] ([fdo#107713] / [fdo#109100]) -> [TIMEOUT][56] ([fdo#109673]) [55]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-iclb3/igt@gem_mmap_gtt@forked-big-copy-xy.html [56]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-iclb4/igt@gem_mmap_gtt@forked-big-copy-xy.html * igt@gem_userptr_blits@process-exit-gtt-busy: - shard-apl: [INCOMPLETE][57] ([fdo#103927]) -> [SKIP][58] ([fdo#109271]) [57]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6149/shard-apl3/igt@gem_userptr_blits@process-exit-gtt-busy.html [58]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/shard-apl5/igt@gem_userptr_blits@process-exit-gtt-busy.html [fdo#102887]: https://bugs.freedesktop.org/show_bug.cgi?id=102887 [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167 [fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232 [fdo#103359]: https://bugs.freedesktop.org/show_bug.cgi?id=103359 [fdo#103540]: https://bugs.freedesktop.org/show_bug.cgi?id=103540 [fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665 [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927 [fdo#105010]: https://bugs.freedesktop.org/show_bug.cgi?id=105010 [fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363 [fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713 [fdo#108134]: https://bugs.freedesktop.org/show_bug.cgi?id=108134 [fdo#108341]: https://bugs.freedesktop.org/show_bug.cgi?id=108341 [fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566 [fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569 [fdo#108686]: https://bugs.freedesktop.org/show_bug.cgi?id=108686 [fdo#108840]: https://bugs.freedesktop.org/show_bug.cgi?id=108840 [fdo#109100]: https://bugs.freedesktop.org/show_bug.cgi?id=109100 [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271 [fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441 [fdo#109642]: https://bugs.freedesktop.org/show_bug.cgi?id=109642 [fdo#109673]: https://bugs.freedesktop.org/show_bug.cgi?id=109673 [fdo#109960]: https://bugs.freedesktop.org/show_bug.cgi?id=109960 [k.org#198133]: https://bugzilla.kernel.org/show_bug.cgi?id=198133 Participating hosts (10 -> 6) ------------------------------ Missing (4): pig-skl-6260u shard-skl pig-hsw-4770r pig-glk-j5005 Build changes ------------- * IGT: IGT_5017 -> IGTPW_3065 * Piglit: piglit_4509 -> None CI_DRM_6149: e8f06c34fa3c76fa94010485e07b89935fa8b9b5 @ git://anongit.freedesktop.org/gfx-ci/linux IGTPW_3065: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/ IGT_5017: 2892adce93fb8eea3d764dc0f766a202d9dcef37 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit == Logs == For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3065/ _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] tests/amdgpu: Add color tests for amdgpu 2019-05-27 17:19 [igt-dev] [PATCH i-g-t] tests/amdgpu: Add color tests for amdgpu Nicholas Kazlauskas 2019-05-27 18:08 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork 2019-05-28 5:45 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork @ 2019-05-29 18:43 ` Li, Sun peng (Leo) 2019-07-11 17:15 ` Daniel Vetter 2 siblings, 1 reply; 10+ messages in thread From: Li, Sun peng (Leo) @ 2019-05-29 18:43 UTC (permalink / raw) To: Kazlauskas, Nicholas, igt-dev On 2019-05-27 1:19 p.m., Nicholas Kazlauskas wrote: > The DRM color management pipeline doesn't directly map to AMD hardware > so creative solutions to implementing CRTC regamma, CTM and gamma were > needed for both DCE and DCN. A few mistakes were made in the process > that weren't caught by kms_color@ tests: > > - Can't get linear degamma output without setting a custom degamma > - Can't specify a non-linear degamma that produces correct output > - Can't specify a correct gamma when a linear degamma is used > > These are caused by using implicit sRGB degamma then sRGB gamma when no > matrices are set. This produces visually correct output when using a > CTM with no matrices set, but it's also technically the incorrect > output according to the DRM API documentation. > > These tests help verify that AMDGPU follows the DRM spec when it comes > to setting linear/bypass gamma and regamma LUT. > > The existing kms_color@ tests are written correctly already, so > anything that looks shared in these is really just to verify that we're > no longer doing any strange test specific workarounds outside of the > spec or documentation. > > Cc: Leo Li <sunpeng.li@amd.com> > Cc: Harry Wentland <harry.wentland@amd.com> > Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com> LGTM, thanks for the test! Reviewed-by: Leo Li <sunpeng.li@amd.com> > --- > tests/Makefile.sources | 1 + > tests/amdgpu/amd_color.c | 405 +++++++++++++++++++++++++++++++++++++++ > tests/amdgpu/meson.build | 1 + > 3 files changed, 407 insertions(+) > create mode 100644 tests/amdgpu/amd_color.c > > diff --git a/tests/Makefile.sources b/tests/Makefile.sources > index 2d5c929e..ef3c03f2 100644 > --- a/tests/Makefile.sources > +++ b/tests/Makefile.sources > @@ -6,6 +6,7 @@ NOUVEAU_TESTS = \ > > AMDGPU_TESTS = \ > amdgpu/amd_basic \ > + amdgpu/amd_color \ > amdgpu/amd_cs_nop \ > amdgpu/amd_prime \ > amdgpu/amd_abm \ > diff --git a/tests/amdgpu/amd_color.c b/tests/amdgpu/amd_color.c > new file mode 100644 > index 00000000..0bbee43d > --- /dev/null > +++ b/tests/amdgpu/amd_color.c > @@ -0,0 +1,405 @@ > +/* > + * Copyright 2019 Advanced Micro Devices, Inc. > + * > + * 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. > + */ > + > +#include "igt.h" > + > +/* (De)gamma LUT. */ > +typedef struct lut { > + struct drm_color_lut *data; > + uint32_t size; > +} lut_t; > + > +/* RGB color. */ > +typedef struct color { > + double r; > + double g; > + double b; > +} color_t; > + > +/* Common test data. */ > +typedef struct data { > + igt_display_t display; > + igt_plane_t *primary; > + igt_output_t *output; > + igt_pipe_t *pipe; > + igt_pipe_crc_t *pipe_crc; > + drmModeModeInfo *mode; > + enum pipe pipe_id; > + int fd; > + int w; > + int h; > + uint32_t regamma_lut_size; > + uint32_t degamma_lut_size; > +} data_t; > + > +static void lut_init(lut_t *lut, uint32_t size) > +{ > + igt_assert(size > 0); > + > + lut->size = size; > + lut->data = malloc(size * sizeof(struct drm_color_lut)); > + igt_assert(lut); > +} > + > +/* Generates the linear gamma LUT. */ > +static void lut_gen_linear(lut_t *lut, uint16_t mask) > +{ > + uint32_t n = lut->size - 1; > + uint32_t i; > + > + for (i = 0; i < lut->size; ++i) { > + uint32_t v = (i * 0xffff / n) & mask; > + > + lut->data[i].red = v; > + lut->data[i].blue = v; > + lut->data[i].green = v; > + } > +} > + > +/* Generates the sRGB degamma LUT. */ > +static void lut_gen_degamma_srgb(lut_t *lut, uint16_t mask) > +{ > + double range = lut->size - 1; > + uint32_t i; > + > + for (i = 0; i < lut->size; ++i) { > + double u, coeff; > + uint32_t v; > + > + u = i / range; > + coeff = u <= 0.040449936 ? (u / 12.92) > + : (pow((u + 0.055) / 1.055, 2.4)); > + v = (uint32_t)(coeff * 0xffff) & mask; > + > + lut->data[i].red = v; > + lut->data[i].blue = v; > + lut->data[i].green = v; > + } > +} > + > +/* Generates the sRGB gamma LUT. */ > +static void lut_gen_regamma_srgb(lut_t *lut, uint16_t mask) > +{ > + double range = lut->size - 1; > + uint32_t i; > + > + for (i = 0; i < lut->size; ++i) { > + double u, coeff; > + uint32_t v; > + > + u = i / range; > + coeff = u <= 0.00313080 ? (12.92 * u) > + : (1.055 * pow(u, 1.0 / 2.4) - 0.055); > + v = (uint32_t)(coeff * 0xffff) & mask; > + > + lut->data[i].red = v; > + lut->data[i].blue = v; > + lut->data[i].green = v; > + } > +} > + > +static void lut_free(lut_t *lut) > +{ > + if (lut->data) { > + free(lut->data); > + lut->data = NULL; > + } > + > + lut->size = 0; > +} > + > +/* Fills a FB with the solid color given. */ > +static void draw_color(igt_fb_t *fb, double r, double g, double b) > +{ > + cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb); > + > + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); > + igt_paint_color(cr, 0, 0, fb->width, fb->height, r, g, b); > + igt_put_cairo_ctx(fb->fd, fb, cr); > +} > + > +/* Generates the gamma test pattern. */ > +static void draw_gamma_test(igt_fb_t *fb) > +{ > + cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb); > + int gh = fb->height / 4; > + > + igt_paint_color_gradient(cr, 0, 0, fb->width, gh, 1, 1, 1); > + igt_paint_color_gradient(cr, 0, gh, fb->width, gh, 1, 0, 0); > + igt_paint_color_gradient(cr, 0, gh * 2, fb->width, gh, 0, 1, 0); > + igt_paint_color_gradient(cr, 0, gh * 3, fb->width, gh, 0, 0, 1); > + > + igt_put_cairo_ctx(fb->fd, fb, cr); > +} > + > +/* Sets the degamma LUT. */ > +static void set_degamma_lut(data_t *data, lut_t const *lut) > +{ > + size_t size = lut ? sizeof(lut->data[0]) * lut->size : 0; > + const void *ptr = lut ? lut->data : NULL; > + > + igt_pipe_obj_replace_prop_blob(data->pipe, IGT_CRTC_DEGAMMA_LUT, ptr, > + size); > +} > + > +/* Sets the regamma LUT. */ > +static void set_regamma_lut(data_t *data, lut_t const *lut) > +{ > + size_t size = lut ? sizeof(lut->data[0]) * lut->size : 0; > + const void *ptr = lut ? lut->data : NULL; > + > + igt_pipe_obj_replace_prop_blob(data->pipe, IGT_CRTC_GAMMA_LUT, ptr, > + size); > +} > + > +/* Common test setup. */ > +static void test_init(data_t *data) > +{ > + igt_display_t *display = &data->display; > + > + /* It doesn't matter which pipe we choose on amdpgu. */ > + data->pipe_id = PIPE_A; > + data->pipe = &data->display.pipes[data->pipe_id]; > + > + igt_display_reset(display); > + > + data->output = igt_get_single_output_for_pipe(display, data->pipe_id); > + igt_require(data->output); > + > + data->mode = igt_output_get_mode(data->output); > + igt_assert(data->mode); > + > + data->primary = > + igt_pipe_get_plane_type(data->pipe, DRM_PLANE_TYPE_PRIMARY); > + > + data->pipe_crc = igt_pipe_crc_new(data->fd, data->pipe_id, > + INTEL_PIPE_CRC_SOURCE_AUTO); > + > + igt_output_set_pipe(data->output, data->pipe_id); > + > + data->degamma_lut_size = > + igt_pipe_obj_get_prop(data->pipe, IGT_CRTC_DEGAMMA_LUT_SIZE); > + igt_assert_lt(0, data->degamma_lut_size); > + > + data->regamma_lut_size = > + igt_pipe_obj_get_prop(data->pipe, IGT_CRTC_GAMMA_LUT_SIZE); > + igt_assert_lt(0, data->regamma_lut_size); > + > + data->w = data->mode->hdisplay; > + data->h = data->mode->vdisplay; > +} > + > +/* Common test cleanup. */ > +static void test_fini(data_t *data) > +{ > + igt_pipe_crc_free(data->pipe_crc); > + igt_display_reset(&data->display); > +} > + > +/* > + * Older versions of amdgpu would put the pipe into bypass mode for degamma > + * when passed a linear sRGB matrix but would still use an sRGB regamma > + * matrix if not passed any. The whole pipe should be in linear bypass mode > + * when all the matrices are NULL - CRCs for a linear degamma matrix and > + * a NULL one should match. > + */ > +static void test_crtc_linear_degamma(data_t *data) > +{ > + igt_display_t *display = &data->display; > + igt_crc_t ref_crc, new_crc; > + igt_fb_t afb; > + lut_t lut_linear; > + > + test_init(data); > + > + lut_init(&lut_linear, data->degamma_lut_size); > + lut_gen_linear(&lut_linear, 0xffff); > + > + igt_create_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888, 0, &afb); > + draw_gamma_test(&afb); > + > + /* Draw the reference image. */ > + igt_plane_set_fb(data->primary, &afb); > + set_regamma_lut(data, NULL); > + set_degamma_lut(data, NULL); > + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); > + > + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); > + > + /* Apply a linear degamma. The result should remain the same. */ > + set_degamma_lut(data, &lut_linear); > + igt_display_commit_atomic(display, 0, NULL); > + > + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); > + igt_assert_crc_equal(&ref_crc, &new_crc); > + > + test_fini(data); > + igt_remove_fb(data->fd, &afb); > + lut_free(&lut_linear); > +} > + > +/* > + * Older versions of amdgpu would apply the CRTC regamma on top of a custom > + * sRGB regamma matrix with incorrect calculations or rounding errors. > + * If we put the pipe into bypass or use the hardware defined sRGB regamma > + * on the plane then we can and should get the correct CRTC when passing a > + * liner regamma matrix to DRM. > + */ > +static void test_crtc_linear_regamma(data_t *data) > +{ > + igt_display_t *display = &data->display; > + igt_crc_t ref_crc, new_crc; > + igt_fb_t afb; > + lut_t lut_linear; > + > + test_init(data); > + > + lut_init(&lut_linear, data->regamma_lut_size); > + lut_gen_linear(&lut_linear, 0xffff); > + > + igt_create_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888, 0, &afb); > + draw_gamma_test(&afb); > + > + /* Draw the reference image. */ > + igt_plane_set_fb(data->primary, &afb); > + set_regamma_lut(data, NULL); > + set_degamma_lut(data, NULL); > + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); > + > + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); > + > + /* Apply a linear degamma. The result should remain the same. */ > + set_regamma_lut(data, &lut_linear); > + igt_display_commit_atomic(display, 0, NULL); > + > + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); > + igt_assert_crc_equal(&ref_crc, &new_crc); > + > + test_fini(data); > + igt_remove_fb(data->fd, &afb); > + lut_free(&lut_linear); > +} > + > +/* > + * Tests LUT accuracy. CRTC regamma and CRTC degamma should produce a visually > + * correct image when used. Hardware limitations on degamma prevent this from > + * being CRC level accurate across a full test gradient but most values should > + * still match. > + * > + * This test can't pass on DCE because it doesn't support non-linear degamma. > + */ > +static void test_crtc_lut_accuracy(data_t *data) > +{ > + /* > + * Channels are independent, so we can verify multiple colors at the > + * same time for improved performance. > + */ > + static const color_t colors[] = { > + { 1.00, 1.00, 1.00 }, > + { 0.90, 0.85, 0.75 }, /* 0.95 fails */ > + { 0.70, 0.65, 0.60 }, > + { 0.55, 0.50, 0.45 }, > + { 0.40, 0.35, 0.30 }, > + { 0.25, 0.20, 0.15 }, > + { 0.10, 0.04, 0.02 }, /* 0.05 fails */ > + { 0.00, 0.00, 0.00 }, > + }; > + igt_display_t *display = &data->display; > + igt_crc_t ref_crc, new_crc; > + igt_fb_t afb; > + lut_t lut_degamma, lut_regamma; > + int i, w, h; > + > + test_init(data); > + > + lut_init(&lut_degamma, data->degamma_lut_size); > + lut_gen_degamma_srgb(&lut_degamma, 0xffff); > + > + lut_init(&lut_regamma, data->regamma_lut_size); > + lut_gen_regamma_srgb(&lut_regamma, 0xffff); > + > + /* Don't draw across the whole screen to improve perf. */ > + w = 64; > + h = 64; > + > + igt_create_fb(data->fd, w, h, DRM_FORMAT_XRGB8888, 0, &afb); > + igt_plane_set_fb(data->primary, &afb); > + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); > + > + /* Test colors. */ > + for (i = 0; i < ARRAY_SIZE(colors); ++i) { > + color_t col = colors[i]; > + > + igt_info("Testing color (%.2f, %.2f, %.2f) ...\n", col.r, col.g, > + col.b); > + > + draw_color(&afb, col.r, col.g, col.b); > + > + set_regamma_lut(data, NULL); > + set_degamma_lut(data, NULL); > + igt_display_commit_atomic(display, 0, NULL); > + > + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); > + > + set_degamma_lut(data, &lut_degamma); > + set_regamma_lut(data, &lut_regamma); > + igt_display_commit_atomic(display, 0, NULL); > + > + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); > + > + igt_assert_crc_equal(&ref_crc, &new_crc); > + } > + > + test_fini(data); > + igt_remove_fb(data->fd, &afb); > + lut_free(&lut_regamma); > + lut_free(&lut_degamma); > +} > + > +igt_main > +{ > + data_t data; > + > + igt_skip_on_simulation(); > + > + memset(&data, 0, sizeof(data)); > + > + igt_fixture > + { > + data.fd = drm_open_driver_master(DRIVER_AMDGPU); > + > + kmstest_set_vt_graphics_mode(); > + > + igt_display_require(&data.display, data.fd); > + igt_require(data.display.is_atomic); > + igt_display_require_output(&data.display); > + } > + > + igt_subtest("crtc-linear-degamma") test_crtc_linear_degamma(&data); > + igt_subtest("crtc-linear-regamma") test_crtc_linear_regamma(&data); > + igt_subtest("crtc-lut-accuracy") test_crtc_lut_accuracy(&data); > + > + igt_fixture > + { > + igt_display_fini(&data.display); > + } > +} > diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build > index 1afece86..42086374 100644 > --- a/tests/amdgpu/meson.build > +++ b/tests/amdgpu/meson.build > @@ -4,6 +4,7 @@ amdgpu_deps = test_deps > if libdrm_amdgpu.found() > amdgpu_progs += [ 'amd_abm', > 'amd_basic', > + 'amd_color', > 'amd_cs_nop', > 'amd_prime', > ] > _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] tests/amdgpu: Add color tests for amdgpu 2019-05-29 18:43 ` [igt-dev] [PATCH i-g-t] " Li, Sun peng (Leo) @ 2019-07-11 17:15 ` Daniel Vetter 2019-07-11 17:19 ` Kazlauskas, Nicholas 0 siblings, 1 reply; 10+ messages in thread From: Daniel Vetter @ 2019-07-11 17:15 UTC (permalink / raw) To: Li, Sun peng (Leo), Wentland, Harry; +Cc: igt-dev On Wed, May 29, 2019 at 8:43 PM Li, Sun peng (Leo) <Sunpeng.Li@amd.com> wrote: > > > > On 2019-05-27 1:19 p.m., Nicholas Kazlauskas wrote: > > The DRM color management pipeline doesn't directly map to AMD hardware > > so creative solutions to implementing CRTC regamma, CTM and gamma were > > needed for both DCE and DCN. A few mistakes were made in the process > > that weren't caught by kms_color@ tests: > > > > - Can't get linear degamma output without setting a custom degamma > > - Can't specify a non-linear degamma that produces correct output > > - Can't specify a correct gamma when a linear degamma is used > > > > These are caused by using implicit sRGB degamma then sRGB gamma when no > > matrices are set. This produces visually correct output when using a > > CTM with no matrices set, but it's also technically the incorrect > > output according to the DRM API documentation. > > > > These tests help verify that AMDGPU follows the DRM spec when it comes > > to setting linear/bypass gamma and regamma LUT. > > > > The existing kms_color@ tests are written correctly already, so > > anything that looks shared in these is really just to verify that we're > > no longer doing any strange test specific workarounds outside of the > > spec or documentation. > > > > Cc: Leo Li <sunpeng.li@amd.com> > > Cc: Harry Wentland <harry.wentland@amd.com> > > Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com> > > LGTM, thanks for the test! > > Reviewed-by: Leo Li <sunpeng.li@amd.com> btw why is this not a new subtest for kms_color? From a quick look it's all generic. The specific testscase for amdpgpu (like amd_bypass.c) all make sense, since they use specific crc tap points and check hw implementation details. But this looks like a generic issue with the color correction kms spec ... Also adding Harry. -Daniel > > > --- > > tests/Makefile.sources | 1 + > > tests/amdgpu/amd_color.c | 405 +++++++++++++++++++++++++++++++++++++++ > > tests/amdgpu/meson.build | 1 + > > 3 files changed, 407 insertions(+) > > create mode 100644 tests/amdgpu/amd_color.c > > > > diff --git a/tests/Makefile.sources b/tests/Makefile.sources > > index 2d5c929e..ef3c03f2 100644 > > --- a/tests/Makefile.sources > > +++ b/tests/Makefile.sources > > @@ -6,6 +6,7 @@ NOUVEAU_TESTS = \ > > > > AMDGPU_TESTS = \ > > amdgpu/amd_basic \ > > + amdgpu/amd_color \ > > amdgpu/amd_cs_nop \ > > amdgpu/amd_prime \ > > amdgpu/amd_abm \ > > diff --git a/tests/amdgpu/amd_color.c b/tests/amdgpu/amd_color.c > > new file mode 100644 > > index 00000000..0bbee43d > > --- /dev/null > > +++ b/tests/amdgpu/amd_color.c > > @@ -0,0 +1,405 @@ > > +/* > > + * Copyright 2019 Advanced Micro Devices, Inc. > > + * > > + * 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. > > + */ > > + > > +#include "igt.h" > > + > > +/* (De)gamma LUT. */ > > +typedef struct lut { > > + struct drm_color_lut *data; > > + uint32_t size; > > +} lut_t; > > + > > +/* RGB color. */ > > +typedef struct color { > > + double r; > > + double g; > > + double b; > > +} color_t; > > + > > +/* Common test data. */ > > +typedef struct data { > > + igt_display_t display; > > + igt_plane_t *primary; > > + igt_output_t *output; > > + igt_pipe_t *pipe; > > + igt_pipe_crc_t *pipe_crc; > > + drmModeModeInfo *mode; > > + enum pipe pipe_id; > > + int fd; > > + int w; > > + int h; > > + uint32_t regamma_lut_size; > > + uint32_t degamma_lut_size; > > +} data_t; > > + > > +static void lut_init(lut_t *lut, uint32_t size) > > +{ > > + igt_assert(size > 0); > > + > > + lut->size = size; > > + lut->data = malloc(size * sizeof(struct drm_color_lut)); > > + igt_assert(lut); > > +} > > + > > +/* Generates the linear gamma LUT. */ > > +static void lut_gen_linear(lut_t *lut, uint16_t mask) > > +{ > > + uint32_t n = lut->size - 1; > > + uint32_t i; > > + > > + for (i = 0; i < lut->size; ++i) { > > + uint32_t v = (i * 0xffff / n) & mask; > > + > > + lut->data[i].red = v; > > + lut->data[i].blue = v; > > + lut->data[i].green = v; > > + } > > +} > > + > > +/* Generates the sRGB degamma LUT. */ > > +static void lut_gen_degamma_srgb(lut_t *lut, uint16_t mask) > > +{ > > + double range = lut->size - 1; > > + uint32_t i; > > + > > + for (i = 0; i < lut->size; ++i) { > > + double u, coeff; > > + uint32_t v; > > + > > + u = i / range; > > + coeff = u <= 0.040449936 ? (u / 12.92) > > + : (pow((u + 0.055) / 1.055, 2.4)); > > + v = (uint32_t)(coeff * 0xffff) & mask; > > + > > + lut->data[i].red = v; > > + lut->data[i].blue = v; > > + lut->data[i].green = v; > > + } > > +} > > + > > +/* Generates the sRGB gamma LUT. */ > > +static void lut_gen_regamma_srgb(lut_t *lut, uint16_t mask) > > +{ > > + double range = lut->size - 1; > > + uint32_t i; > > + > > + for (i = 0; i < lut->size; ++i) { > > + double u, coeff; > > + uint32_t v; > > + > > + u = i / range; > > + coeff = u <= 0.00313080 ? (12.92 * u) > > + : (1.055 * pow(u, 1.0 / 2.4) - 0.055); > > + v = (uint32_t)(coeff * 0xffff) & mask; > > + > > + lut->data[i].red = v; > > + lut->data[i].blue = v; > > + lut->data[i].green = v; > > + } > > +} > > + > > +static void lut_free(lut_t *lut) > > +{ > > + if (lut->data) { > > + free(lut->data); > > + lut->data = NULL; > > + } > > + > > + lut->size = 0; > > +} > > + > > +/* Fills a FB with the solid color given. */ > > +static void draw_color(igt_fb_t *fb, double r, double g, double b) > > +{ > > + cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb); > > + > > + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); > > + igt_paint_color(cr, 0, 0, fb->width, fb->height, r, g, b); > > + igt_put_cairo_ctx(fb->fd, fb, cr); > > +} > > + > > +/* Generates the gamma test pattern. */ > > +static void draw_gamma_test(igt_fb_t *fb) > > +{ > > + cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb); > > + int gh = fb->height / 4; > > + > > + igt_paint_color_gradient(cr, 0, 0, fb->width, gh, 1, 1, 1); > > + igt_paint_color_gradient(cr, 0, gh, fb->width, gh, 1, 0, 0); > > + igt_paint_color_gradient(cr, 0, gh * 2, fb->width, gh, 0, 1, 0); > > + igt_paint_color_gradient(cr, 0, gh * 3, fb->width, gh, 0, 0, 1); > > + > > + igt_put_cairo_ctx(fb->fd, fb, cr); > > +} > > + > > +/* Sets the degamma LUT. */ > > +static void set_degamma_lut(data_t *data, lut_t const *lut) > > +{ > > + size_t size = lut ? sizeof(lut->data[0]) * lut->size : 0; > > + const void *ptr = lut ? lut->data : NULL; > > + > > + igt_pipe_obj_replace_prop_blob(data->pipe, IGT_CRTC_DEGAMMA_LUT, ptr, > > + size); > > +} > > + > > +/* Sets the regamma LUT. */ > > +static void set_regamma_lut(data_t *data, lut_t const *lut) > > +{ > > + size_t size = lut ? sizeof(lut->data[0]) * lut->size : 0; > > + const void *ptr = lut ? lut->data : NULL; > > + > > + igt_pipe_obj_replace_prop_blob(data->pipe, IGT_CRTC_GAMMA_LUT, ptr, > > + size); > > +} > > + > > +/* Common test setup. */ > > +static void test_init(data_t *data) > > +{ > > + igt_display_t *display = &data->display; > > + > > + /* It doesn't matter which pipe we choose on amdpgu. */ > > + data->pipe_id = PIPE_A; > > + data->pipe = &data->display.pipes[data->pipe_id]; > > + > > + igt_display_reset(display); > > + > > + data->output = igt_get_single_output_for_pipe(display, data->pipe_id); > > + igt_require(data->output); > > + > > + data->mode = igt_output_get_mode(data->output); > > + igt_assert(data->mode); > > + > > + data->primary = > > + igt_pipe_get_plane_type(data->pipe, DRM_PLANE_TYPE_PRIMARY); > > + > > + data->pipe_crc = igt_pipe_crc_new(data->fd, data->pipe_id, > > + INTEL_PIPE_CRC_SOURCE_AUTO); > > + > > + igt_output_set_pipe(data->output, data->pipe_id); > > + > > + data->degamma_lut_size = > > + igt_pipe_obj_get_prop(data->pipe, IGT_CRTC_DEGAMMA_LUT_SIZE); > > + igt_assert_lt(0, data->degamma_lut_size); > > + > > + data->regamma_lut_size = > > + igt_pipe_obj_get_prop(data->pipe, IGT_CRTC_GAMMA_LUT_SIZE); > > + igt_assert_lt(0, data->regamma_lut_size); > > + > > + data->w = data->mode->hdisplay; > > + data->h = data->mode->vdisplay; > > +} > > + > > +/* Common test cleanup. */ > > +static void test_fini(data_t *data) > > +{ > > + igt_pipe_crc_free(data->pipe_crc); > > + igt_display_reset(&data->display); > > +} > > + > > +/* > > + * Older versions of amdgpu would put the pipe into bypass mode for degamma > > + * when passed a linear sRGB matrix but would still use an sRGB regamma > > + * matrix if not passed any. The whole pipe should be in linear bypass mode > > + * when all the matrices are NULL - CRCs for a linear degamma matrix and > > + * a NULL one should match. > > + */ > > +static void test_crtc_linear_degamma(data_t *data) > > +{ > > + igt_display_t *display = &data->display; > > + igt_crc_t ref_crc, new_crc; > > + igt_fb_t afb; > > + lut_t lut_linear; > > + > > + test_init(data); > > + > > + lut_init(&lut_linear, data->degamma_lut_size); > > + lut_gen_linear(&lut_linear, 0xffff); > > + > > + igt_create_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888, 0, &afb); > > + draw_gamma_test(&afb); > > + > > + /* Draw the reference image. */ > > + igt_plane_set_fb(data->primary, &afb); > > + set_regamma_lut(data, NULL); > > + set_degamma_lut(data, NULL); > > + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); > > + > > + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); > > + > > + /* Apply a linear degamma. The result should remain the same. */ > > + set_degamma_lut(data, &lut_linear); > > + igt_display_commit_atomic(display, 0, NULL); > > + > > + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); > > + igt_assert_crc_equal(&ref_crc, &new_crc); > > + > > + test_fini(data); > > + igt_remove_fb(data->fd, &afb); > > + lut_free(&lut_linear); > > +} > > + > > +/* > > + * Older versions of amdgpu would apply the CRTC regamma on top of a custom > > + * sRGB regamma matrix with incorrect calculations or rounding errors. > > + * If we put the pipe into bypass or use the hardware defined sRGB regamma > > + * on the plane then we can and should get the correct CRTC when passing a > > + * liner regamma matrix to DRM. > > + */ > > +static void test_crtc_linear_regamma(data_t *data) > > +{ > > + igt_display_t *display = &data->display; > > + igt_crc_t ref_crc, new_crc; > > + igt_fb_t afb; > > + lut_t lut_linear; > > + > > + test_init(data); > > + > > + lut_init(&lut_linear, data->regamma_lut_size); > > + lut_gen_linear(&lut_linear, 0xffff); > > + > > + igt_create_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888, 0, &afb); > > + draw_gamma_test(&afb); > > + > > + /* Draw the reference image. */ > > + igt_plane_set_fb(data->primary, &afb); > > + set_regamma_lut(data, NULL); > > + set_degamma_lut(data, NULL); > > + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); > > + > > + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); > > + > > + /* Apply a linear degamma. The result should remain the same. */ > > + set_regamma_lut(data, &lut_linear); > > + igt_display_commit_atomic(display, 0, NULL); > > + > > + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); > > + igt_assert_crc_equal(&ref_crc, &new_crc); > > + > > + test_fini(data); > > + igt_remove_fb(data->fd, &afb); > > + lut_free(&lut_linear); > > +} > > + > > +/* > > + * Tests LUT accuracy. CRTC regamma and CRTC degamma should produce a visually > > + * correct image when used. Hardware limitations on degamma prevent this from > > + * being CRC level accurate across a full test gradient but most values should > > + * still match. > > + * > > + * This test can't pass on DCE because it doesn't support non-linear degamma. > > + */ > > +static void test_crtc_lut_accuracy(data_t *data) > > +{ > > + /* > > + * Channels are independent, so we can verify multiple colors at the > > + * same time for improved performance. > > + */ > > + static const color_t colors[] = { > > + { 1.00, 1.00, 1.00 }, > > + { 0.90, 0.85, 0.75 }, /* 0.95 fails */ > > + { 0.70, 0.65, 0.60 }, > > + { 0.55, 0.50, 0.45 }, > > + { 0.40, 0.35, 0.30 }, > > + { 0.25, 0.20, 0.15 }, > > + { 0.10, 0.04, 0.02 }, /* 0.05 fails */ > > + { 0.00, 0.00, 0.00 }, > > + }; > > + igt_display_t *display = &data->display; > > + igt_crc_t ref_crc, new_crc; > > + igt_fb_t afb; > > + lut_t lut_degamma, lut_regamma; > > + int i, w, h; > > + > > + test_init(data); > > + > > + lut_init(&lut_degamma, data->degamma_lut_size); > > + lut_gen_degamma_srgb(&lut_degamma, 0xffff); > > + > > + lut_init(&lut_regamma, data->regamma_lut_size); > > + lut_gen_regamma_srgb(&lut_regamma, 0xffff); > > + > > + /* Don't draw across the whole screen to improve perf. */ > > + w = 64; > > + h = 64; > > + > > + igt_create_fb(data->fd, w, h, DRM_FORMAT_XRGB8888, 0, &afb); > > + igt_plane_set_fb(data->primary, &afb); > > + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); > > + > > + /* Test colors. */ > > + for (i = 0; i < ARRAY_SIZE(colors); ++i) { > > + color_t col = colors[i]; > > + > > + igt_info("Testing color (%.2f, %.2f, %.2f) ...\n", col.r, col.g, > > + col.b); > > + > > + draw_color(&afb, col.r, col.g, col.b); > > + > > + set_regamma_lut(data, NULL); > > + set_degamma_lut(data, NULL); > > + igt_display_commit_atomic(display, 0, NULL); > > + > > + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); > > + > > + set_degamma_lut(data, &lut_degamma); > > + set_regamma_lut(data, &lut_regamma); > > + igt_display_commit_atomic(display, 0, NULL); > > + > > + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); > > + > > + igt_assert_crc_equal(&ref_crc, &new_crc); > > + } > > + > > + test_fini(data); > > + igt_remove_fb(data->fd, &afb); > > + lut_free(&lut_regamma); > > + lut_free(&lut_degamma); > > +} > > + > > +igt_main > > +{ > > + data_t data; > > + > > + igt_skip_on_simulation(); > > + > > + memset(&data, 0, sizeof(data)); > > + > > + igt_fixture > > + { > > + data.fd = drm_open_driver_master(DRIVER_AMDGPU); > > + > > + kmstest_set_vt_graphics_mode(); > > + > > + igt_display_require(&data.display, data.fd); > > + igt_require(data.display.is_atomic); > > + igt_display_require_output(&data.display); > > + } > > + > > + igt_subtest("crtc-linear-degamma") test_crtc_linear_degamma(&data); > > + igt_subtest("crtc-linear-regamma") test_crtc_linear_regamma(&data); > > + igt_subtest("crtc-lut-accuracy") test_crtc_lut_accuracy(&data); > > + > > + igt_fixture > > + { > > + igt_display_fini(&data.display); > > + } > > +} > > diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build > > index 1afece86..42086374 100644 > > --- a/tests/amdgpu/meson.build > > +++ b/tests/amdgpu/meson.build > > @@ -4,6 +4,7 @@ amdgpu_deps = test_deps > > if libdrm_amdgpu.found() > > amdgpu_progs += [ 'amd_abm', > > 'amd_basic', > > + 'amd_color', > > 'amd_cs_nop', > > 'amd_prime', > > ] > > > _______________________________________________ > igt-dev mailing list > igt-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/igt-dev -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] tests/amdgpu: Add color tests for amdgpu 2019-07-11 17:15 ` Daniel Vetter @ 2019-07-11 17:19 ` Kazlauskas, Nicholas 2019-07-11 17:30 ` Daniel Vetter 0 siblings, 1 reply; 10+ messages in thread From: Kazlauskas, Nicholas @ 2019-07-11 17:19 UTC (permalink / raw) To: Daniel Vetter, Li, Sun peng (Leo), Wentland, Harry; +Cc: igt-dev On 7/11/19 1:15 PM, Daniel Vetter wrote: > On Wed, May 29, 2019 at 8:43 PM Li, Sun peng (Leo) <Sunpeng.Li@amd.com> wrote: >> >> >> >> On 2019-05-27 1:19 p.m., Nicholas Kazlauskas wrote: >>> The DRM color management pipeline doesn't directly map to AMD hardware >>> so creative solutions to implementing CRTC regamma, CTM and gamma were >>> needed for both DCE and DCN. A few mistakes were made in the process >>> that weren't caught by kms_color@ tests: >>> >>> - Can't get linear degamma output without setting a custom degamma >>> - Can't specify a non-linear degamma that produces correct output >>> - Can't specify a correct gamma when a linear degamma is used >>> >>> These are caused by using implicit sRGB degamma then sRGB gamma when no >>> matrices are set. This produces visually correct output when using a >>> CTM with no matrices set, but it's also technically the incorrect >>> output according to the DRM API documentation. >>> >>> These tests help verify that AMDGPU follows the DRM spec when it comes >>> to setting linear/bypass gamma and regamma LUT. >>> >>> The existing kms_color@ tests are written correctly already, so >>> anything that looks shared in these is really just to verify that we're >>> no longer doing any strange test specific workarounds outside of the >>> spec or documentation. >>> >>> Cc: Leo Li <sunpeng.li@amd.com> >>> Cc: Harry Wentland <harry.wentland@amd.com> >>> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com> >> >> LGTM, thanks for the test! >> >> Reviewed-by: Leo Li <sunpeng.li@amd.com> > > btw why is this not a new subtest for kms_color? From a quick look > it's all generic. The specific testscase for amdpgpu (like > amd_bypass.c) all make sense, since they use specific crc tap points > and check hw implementation details. But this looks like a generic > issue with the color correction kms spec ... Also adding Harry. > -Daniel The test_crtc_lut_accuracy test is specific to our DCN hardware in terms of what we expect and that it requires a independent per channel CRC. The other two tests could probably be added to kms_color with the expectation that a linear LUT is going to be the same as not setting any LUT at all on the hardware. I don't think there's any issue here with the kms spec, it's clearly defined - we were previously breaking the spec by not actually using bypass for a NULL LUT. Nicholas Kazlauskas > >> >>> --- >>> tests/Makefile.sources | 1 + >>> tests/amdgpu/amd_color.c | 405 +++++++++++++++++++++++++++++++++++++++ >>> tests/amdgpu/meson.build | 1 + >>> 3 files changed, 407 insertions(+) >>> create mode 100644 tests/amdgpu/amd_color.c >>> >>> diff --git a/tests/Makefile.sources b/tests/Makefile.sources >>> index 2d5c929e..ef3c03f2 100644 >>> --- a/tests/Makefile.sources >>> +++ b/tests/Makefile.sources >>> @@ -6,6 +6,7 @@ NOUVEAU_TESTS = \ >>> >>> AMDGPU_TESTS = \ >>> amdgpu/amd_basic \ >>> + amdgpu/amd_color \ >>> amdgpu/amd_cs_nop \ >>> amdgpu/amd_prime \ >>> amdgpu/amd_abm \ >>> diff --git a/tests/amdgpu/amd_color.c b/tests/amdgpu/amd_color.c >>> new file mode 100644 >>> index 00000000..0bbee43d >>> --- /dev/null >>> +++ b/tests/amdgpu/amd_color.c >>> @@ -0,0 +1,405 @@ >>> +/* >>> + * Copyright 2019 Advanced Micro Devices, Inc. >>> + * >>> + * 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. >>> + */ >>> + >>> +#include "igt.h" >>> + >>> +/* (De)gamma LUT. */ >>> +typedef struct lut { >>> + struct drm_color_lut *data; >>> + uint32_t size; >>> +} lut_t; >>> + >>> +/* RGB color. */ >>> +typedef struct color { >>> + double r; >>> + double g; >>> + double b; >>> +} color_t; >>> + >>> +/* Common test data. */ >>> +typedef struct data { >>> + igt_display_t display; >>> + igt_plane_t *primary; >>> + igt_output_t *output; >>> + igt_pipe_t *pipe; >>> + igt_pipe_crc_t *pipe_crc; >>> + drmModeModeInfo *mode; >>> + enum pipe pipe_id; >>> + int fd; >>> + int w; >>> + int h; >>> + uint32_t regamma_lut_size; >>> + uint32_t degamma_lut_size; >>> +} data_t; >>> + >>> +static void lut_init(lut_t *lut, uint32_t size) >>> +{ >>> + igt_assert(size > 0); >>> + >>> + lut->size = size; >>> + lut->data = malloc(size * sizeof(struct drm_color_lut)); >>> + igt_assert(lut); >>> +} >>> + >>> +/* Generates the linear gamma LUT. */ >>> +static void lut_gen_linear(lut_t *lut, uint16_t mask) >>> +{ >>> + uint32_t n = lut->size - 1; >>> + uint32_t i; >>> + >>> + for (i = 0; i < lut->size; ++i) { >>> + uint32_t v = (i * 0xffff / n) & mask; >>> + >>> + lut->data[i].red = v; >>> + lut->data[i].blue = v; >>> + lut->data[i].green = v; >>> + } >>> +} >>> + >>> +/* Generates the sRGB degamma LUT. */ >>> +static void lut_gen_degamma_srgb(lut_t *lut, uint16_t mask) >>> +{ >>> + double range = lut->size - 1; >>> + uint32_t i; >>> + >>> + for (i = 0; i < lut->size; ++i) { >>> + double u, coeff; >>> + uint32_t v; >>> + >>> + u = i / range; >>> + coeff = u <= 0.040449936 ? (u / 12.92) >>> + : (pow((u + 0.055) / 1.055, 2.4)); >>> + v = (uint32_t)(coeff * 0xffff) & mask; >>> + >>> + lut->data[i].red = v; >>> + lut->data[i].blue = v; >>> + lut->data[i].green = v; >>> + } >>> +} >>> + >>> +/* Generates the sRGB gamma LUT. */ >>> +static void lut_gen_regamma_srgb(lut_t *lut, uint16_t mask) >>> +{ >>> + double range = lut->size - 1; >>> + uint32_t i; >>> + >>> + for (i = 0; i < lut->size; ++i) { >>> + double u, coeff; >>> + uint32_t v; >>> + >>> + u = i / range; >>> + coeff = u <= 0.00313080 ? (12.92 * u) >>> + : (1.055 * pow(u, 1.0 / 2.4) - 0.055); >>> + v = (uint32_t)(coeff * 0xffff) & mask; >>> + >>> + lut->data[i].red = v; >>> + lut->data[i].blue = v; >>> + lut->data[i].green = v; >>> + } >>> +} >>> + >>> +static void lut_free(lut_t *lut) >>> +{ >>> + if (lut->data) { >>> + free(lut->data); >>> + lut->data = NULL; >>> + } >>> + >>> + lut->size = 0; >>> +} >>> + >>> +/* Fills a FB with the solid color given. */ >>> +static void draw_color(igt_fb_t *fb, double r, double g, double b) >>> +{ >>> + cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb); >>> + >>> + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); >>> + igt_paint_color(cr, 0, 0, fb->width, fb->height, r, g, b); >>> + igt_put_cairo_ctx(fb->fd, fb, cr); >>> +} >>> + >>> +/* Generates the gamma test pattern. */ >>> +static void draw_gamma_test(igt_fb_t *fb) >>> +{ >>> + cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb); >>> + int gh = fb->height / 4; >>> + >>> + igt_paint_color_gradient(cr, 0, 0, fb->width, gh, 1, 1, 1); >>> + igt_paint_color_gradient(cr, 0, gh, fb->width, gh, 1, 0, 0); >>> + igt_paint_color_gradient(cr, 0, gh * 2, fb->width, gh, 0, 1, 0); >>> + igt_paint_color_gradient(cr, 0, gh * 3, fb->width, gh, 0, 0, 1); >>> + >>> + igt_put_cairo_ctx(fb->fd, fb, cr); >>> +} >>> + >>> +/* Sets the degamma LUT. */ >>> +static void set_degamma_lut(data_t *data, lut_t const *lut) >>> +{ >>> + size_t size = lut ? sizeof(lut->data[0]) * lut->size : 0; >>> + const void *ptr = lut ? lut->data : NULL; >>> + >>> + igt_pipe_obj_replace_prop_blob(data->pipe, IGT_CRTC_DEGAMMA_LUT, ptr, >>> + size); >>> +} >>> + >>> +/* Sets the regamma LUT. */ >>> +static void set_regamma_lut(data_t *data, lut_t const *lut) >>> +{ >>> + size_t size = lut ? sizeof(lut->data[0]) * lut->size : 0; >>> + const void *ptr = lut ? lut->data : NULL; >>> + >>> + igt_pipe_obj_replace_prop_blob(data->pipe, IGT_CRTC_GAMMA_LUT, ptr, >>> + size); >>> +} >>> + >>> +/* Common test setup. */ >>> +static void test_init(data_t *data) >>> +{ >>> + igt_display_t *display = &data->display; >>> + >>> + /* It doesn't matter which pipe we choose on amdpgu. */ >>> + data->pipe_id = PIPE_A; >>> + data->pipe = &data->display.pipes[data->pipe_id]; >>> + >>> + igt_display_reset(display); >>> + >>> + data->output = igt_get_single_output_for_pipe(display, data->pipe_id); >>> + igt_require(data->output); >>> + >>> + data->mode = igt_output_get_mode(data->output); >>> + igt_assert(data->mode); >>> + >>> + data->primary = >>> + igt_pipe_get_plane_type(data->pipe, DRM_PLANE_TYPE_PRIMARY); >>> + >>> + data->pipe_crc = igt_pipe_crc_new(data->fd, data->pipe_id, >>> + INTEL_PIPE_CRC_SOURCE_AUTO); >>> + >>> + igt_output_set_pipe(data->output, data->pipe_id); >>> + >>> + data->degamma_lut_size = >>> + igt_pipe_obj_get_prop(data->pipe, IGT_CRTC_DEGAMMA_LUT_SIZE); >>> + igt_assert_lt(0, data->degamma_lut_size); >>> + >>> + data->regamma_lut_size = >>> + igt_pipe_obj_get_prop(data->pipe, IGT_CRTC_GAMMA_LUT_SIZE); >>> + igt_assert_lt(0, data->regamma_lut_size); >>> + >>> + data->w = data->mode->hdisplay; >>> + data->h = data->mode->vdisplay; >>> +} >>> + >>> +/* Common test cleanup. */ >>> +static void test_fini(data_t *data) >>> +{ >>> + igt_pipe_crc_free(data->pipe_crc); >>> + igt_display_reset(&data->display); >>> +} >>> + >>> +/* >>> + * Older versions of amdgpu would put the pipe into bypass mode for degamma >>> + * when passed a linear sRGB matrix but would still use an sRGB regamma >>> + * matrix if not passed any. The whole pipe should be in linear bypass mode >>> + * when all the matrices are NULL - CRCs for a linear degamma matrix and >>> + * a NULL one should match. >>> + */ >>> +static void test_crtc_linear_degamma(data_t *data) >>> +{ >>> + igt_display_t *display = &data->display; >>> + igt_crc_t ref_crc, new_crc; >>> + igt_fb_t afb; >>> + lut_t lut_linear; >>> + >>> + test_init(data); >>> + >>> + lut_init(&lut_linear, data->degamma_lut_size); >>> + lut_gen_linear(&lut_linear, 0xffff); >>> + >>> + igt_create_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888, 0, &afb); >>> + draw_gamma_test(&afb); >>> + >>> + /* Draw the reference image. */ >>> + igt_plane_set_fb(data->primary, &afb); >>> + set_regamma_lut(data, NULL); >>> + set_degamma_lut(data, NULL); >>> + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); >>> + >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); >>> + >>> + /* Apply a linear degamma. The result should remain the same. */ >>> + set_degamma_lut(data, &lut_linear); >>> + igt_display_commit_atomic(display, 0, NULL); >>> + >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); >>> + igt_assert_crc_equal(&ref_crc, &new_crc); >>> + >>> + test_fini(data); >>> + igt_remove_fb(data->fd, &afb); >>> + lut_free(&lut_linear); >>> +} >>> + >>> +/* >>> + * Older versions of amdgpu would apply the CRTC regamma on top of a custom >>> + * sRGB regamma matrix with incorrect calculations or rounding errors. >>> + * If we put the pipe into bypass or use the hardware defined sRGB regamma >>> + * on the plane then we can and should get the correct CRTC when passing a >>> + * liner regamma matrix to DRM. >>> + */ >>> +static void test_crtc_linear_regamma(data_t *data) >>> +{ >>> + igt_display_t *display = &data->display; >>> + igt_crc_t ref_crc, new_crc; >>> + igt_fb_t afb; >>> + lut_t lut_linear; >>> + >>> + test_init(data); >>> + >>> + lut_init(&lut_linear, data->regamma_lut_size); >>> + lut_gen_linear(&lut_linear, 0xffff); >>> + >>> + igt_create_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888, 0, &afb); >>> + draw_gamma_test(&afb); >>> + >>> + /* Draw the reference image. */ >>> + igt_plane_set_fb(data->primary, &afb); >>> + set_regamma_lut(data, NULL); >>> + set_degamma_lut(data, NULL); >>> + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); >>> + >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); >>> + >>> + /* Apply a linear degamma. The result should remain the same. */ >>> + set_regamma_lut(data, &lut_linear); >>> + igt_display_commit_atomic(display, 0, NULL); >>> + >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); >>> + igt_assert_crc_equal(&ref_crc, &new_crc); >>> + >>> + test_fini(data); >>> + igt_remove_fb(data->fd, &afb); >>> + lut_free(&lut_linear); >>> +} >>> + >>> +/* >>> + * Tests LUT accuracy. CRTC regamma and CRTC degamma should produce a visually >>> + * correct image when used. Hardware limitations on degamma prevent this from >>> + * being CRC level accurate across a full test gradient but most values should >>> + * still match. >>> + * >>> + * This test can't pass on DCE because it doesn't support non-linear degamma. >>> + */ >>> +static void test_crtc_lut_accuracy(data_t *data) >>> +{ >>> + /* >>> + * Channels are independent, so we can verify multiple colors at the >>> + * same time for improved performance. >>> + */ >>> + static const color_t colors[] = { >>> + { 1.00, 1.00, 1.00 }, >>> + { 0.90, 0.85, 0.75 }, /* 0.95 fails */ >>> + { 0.70, 0.65, 0.60 }, >>> + { 0.55, 0.50, 0.45 }, >>> + { 0.40, 0.35, 0.30 }, >>> + { 0.25, 0.20, 0.15 }, >>> + { 0.10, 0.04, 0.02 }, /* 0.05 fails */ >>> + { 0.00, 0.00, 0.00 }, >>> + }; >>> + igt_display_t *display = &data->display; >>> + igt_crc_t ref_crc, new_crc; >>> + igt_fb_t afb; >>> + lut_t lut_degamma, lut_regamma; >>> + int i, w, h; >>> + >>> + test_init(data); >>> + >>> + lut_init(&lut_degamma, data->degamma_lut_size); >>> + lut_gen_degamma_srgb(&lut_degamma, 0xffff); >>> + >>> + lut_init(&lut_regamma, data->regamma_lut_size); >>> + lut_gen_regamma_srgb(&lut_regamma, 0xffff); >>> + >>> + /* Don't draw across the whole screen to improve perf. */ >>> + w = 64; >>> + h = 64; >>> + >>> + igt_create_fb(data->fd, w, h, DRM_FORMAT_XRGB8888, 0, &afb); >>> + igt_plane_set_fb(data->primary, &afb); >>> + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); >>> + >>> + /* Test colors. */ >>> + for (i = 0; i < ARRAY_SIZE(colors); ++i) { >>> + color_t col = colors[i]; >>> + >>> + igt_info("Testing color (%.2f, %.2f, %.2f) ...\n", col.r, col.g, >>> + col.b); >>> + >>> + draw_color(&afb, col.r, col.g, col.b); >>> + >>> + set_regamma_lut(data, NULL); >>> + set_degamma_lut(data, NULL); >>> + igt_display_commit_atomic(display, 0, NULL); >>> + >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); >>> + >>> + set_degamma_lut(data, &lut_degamma); >>> + set_regamma_lut(data, &lut_regamma); >>> + igt_display_commit_atomic(display, 0, NULL); >>> + >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); >>> + >>> + igt_assert_crc_equal(&ref_crc, &new_crc); >>> + } >>> + >>> + test_fini(data); >>> + igt_remove_fb(data->fd, &afb); >>> + lut_free(&lut_regamma); >>> + lut_free(&lut_degamma); >>> +} >>> + >>> +igt_main >>> +{ >>> + data_t data; >>> + >>> + igt_skip_on_simulation(); >>> + >>> + memset(&data, 0, sizeof(data)); >>> + >>> + igt_fixture >>> + { >>> + data.fd = drm_open_driver_master(DRIVER_AMDGPU); >>> + >>> + kmstest_set_vt_graphics_mode(); >>> + >>> + igt_display_require(&data.display, data.fd); >>> + igt_require(data.display.is_atomic); >>> + igt_display_require_output(&data.display); >>> + } >>> + >>> + igt_subtest("crtc-linear-degamma") test_crtc_linear_degamma(&data); >>> + igt_subtest("crtc-linear-regamma") test_crtc_linear_regamma(&data); >>> + igt_subtest("crtc-lut-accuracy") test_crtc_lut_accuracy(&data); >>> + >>> + igt_fixture >>> + { >>> + igt_display_fini(&data.display); >>> + } >>> +} >>> diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build >>> index 1afece86..42086374 100644 >>> --- a/tests/amdgpu/meson.build >>> +++ b/tests/amdgpu/meson.build >>> @@ -4,6 +4,7 @@ amdgpu_deps = test_deps >>> if libdrm_amdgpu.found() >>> amdgpu_progs += [ 'amd_abm', >>> 'amd_basic', >>> + 'amd_color', >>> 'amd_cs_nop', >>> 'amd_prime', >>> ] >>> >> _______________________________________________ >> igt-dev mailing list >> igt-dev@lists.freedesktop.org >> https://lists.freedesktop.org/mailman/listinfo/igt-dev > > > _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] tests/amdgpu: Add color tests for amdgpu 2019-07-11 17:19 ` Kazlauskas, Nicholas @ 2019-07-11 17:30 ` Daniel Vetter 2019-07-11 17:34 ` Kazlauskas, Nicholas 2019-07-11 17:46 ` Ville Syrjälä 0 siblings, 2 replies; 10+ messages in thread From: Daniel Vetter @ 2019-07-11 17:30 UTC (permalink / raw) To: Kazlauskas, Nicholas; +Cc: igt-dev On Thu, Jul 11, 2019 at 7:19 PM Kazlauskas, Nicholas <Nicholas.Kazlauskas@amd.com> wrote: > > On 7/11/19 1:15 PM, Daniel Vetter wrote: > > On Wed, May 29, 2019 at 8:43 PM Li, Sun peng (Leo) <Sunpeng.Li@amd.com> wrote: > >> > >> > >> > >> On 2019-05-27 1:19 p.m., Nicholas Kazlauskas wrote: > >>> The DRM color management pipeline doesn't directly map to AMD hardware > >>> so creative solutions to implementing CRTC regamma, CTM and gamma were > >>> needed for both DCE and DCN. A few mistakes were made in the process > >>> that weren't caught by kms_color@ tests: > >>> > >>> - Can't get linear degamma output without setting a custom degamma > >>> - Can't specify a non-linear degamma that produces correct output > >>> - Can't specify a correct gamma when a linear degamma is used > >>> > >>> These are caused by using implicit sRGB degamma then sRGB gamma when no > >>> matrices are set. This produces visually correct output when using a > >>> CTM with no matrices set, but it's also technically the incorrect > >>> output according to the DRM API documentation. > >>> > >>> These tests help verify that AMDGPU follows the DRM spec when it comes > >>> to setting linear/bypass gamma and regamma LUT. > >>> > >>> The existing kms_color@ tests are written correctly already, so > >>> anything that looks shared in these is really just to verify that we're > >>> no longer doing any strange test specific workarounds outside of the > >>> spec or documentation. > >>> > >>> Cc: Leo Li <sunpeng.li@amd.com> > >>> Cc: Harry Wentland <harry.wentland@amd.com> > >>> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com> > >> > >> LGTM, thanks for the test! > >> > >> Reviewed-by: Leo Li <sunpeng.li@amd.com> > > > > btw why is this not a new subtest for kms_color? From a quick look > > it's all generic. The specific testscase for amdpgpu (like > > amd_bypass.c) all make sense, since they use specific crc tap points > > and check hw implementation details. But this looks like a generic > > issue with the color correction kms spec ... Also adding Harry. > > -Daniel > > The test_crtc_lut_accuracy test is specific to our DCN hardware in terms > of what we expect and that it requires a independent per channel CRC. > > The other two tests could probably be added to kms_color with the > expectation that a linear LUT is going to be the same as not setting any > LUT at all on the hardware. > > I don't think there's any issue here with the kms spec, it's clearly > defined - we were previously breaking the spec by not actually using > bypass for a NULL LUT. I mean: you found a gap between the spec and the kms_color test coverage. I think it's worth fixing this, since if you hit this one, then probably someone else hits this too with their hw/driver combo. And the long term goal with igt is that at least for kms, it would be a conformance test suite. Would be great if you could port these two tests to kms_color (the one that makes specific assumptions about DCN hw obviously can't be ported). And yeah the assumption, at least for RGB formats is that "no gamm" == "linear gamma", and having a testcase for this explicitly sounds like a great idea. -Daniel > Nicholas Kazlauskas > > > > >> > >>> --- > >>> tests/Makefile.sources | 1 + > >>> tests/amdgpu/amd_color.c | 405 +++++++++++++++++++++++++++++++++++++++ > >>> tests/amdgpu/meson.build | 1 + > >>> 3 files changed, 407 insertions(+) > >>> create mode 100644 tests/amdgpu/amd_color.c > >>> > >>> diff --git a/tests/Makefile.sources b/tests/Makefile.sources > >>> index 2d5c929e..ef3c03f2 100644 > >>> --- a/tests/Makefile.sources > >>> +++ b/tests/Makefile.sources > >>> @@ -6,6 +6,7 @@ NOUVEAU_TESTS = \ > >>> > >>> AMDGPU_TESTS = \ > >>> amdgpu/amd_basic \ > >>> + amdgpu/amd_color \ > >>> amdgpu/amd_cs_nop \ > >>> amdgpu/amd_prime \ > >>> amdgpu/amd_abm \ > >>> diff --git a/tests/amdgpu/amd_color.c b/tests/amdgpu/amd_color.c > >>> new file mode 100644 > >>> index 00000000..0bbee43d > >>> --- /dev/null > >>> +++ b/tests/amdgpu/amd_color.c > >>> @@ -0,0 +1,405 @@ > >>> +/* > >>> + * Copyright 2019 Advanced Micro Devices, Inc. > >>> + * > >>> + * 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. > >>> + */ > >>> + > >>> +#include "igt.h" > >>> + > >>> +/* (De)gamma LUT. */ > >>> +typedef struct lut { > >>> + struct drm_color_lut *data; > >>> + uint32_t size; > >>> +} lut_t; > >>> + > >>> +/* RGB color. */ > >>> +typedef struct color { > >>> + double r; > >>> + double g; > >>> + double b; > >>> +} color_t; > >>> + > >>> +/* Common test data. */ > >>> +typedef struct data { > >>> + igt_display_t display; > >>> + igt_plane_t *primary; > >>> + igt_output_t *output; > >>> + igt_pipe_t *pipe; > >>> + igt_pipe_crc_t *pipe_crc; > >>> + drmModeModeInfo *mode; > >>> + enum pipe pipe_id; > >>> + int fd; > >>> + int w; > >>> + int h; > >>> + uint32_t regamma_lut_size; > >>> + uint32_t degamma_lut_size; > >>> +} data_t; > >>> + > >>> +static void lut_init(lut_t *lut, uint32_t size) > >>> +{ > >>> + igt_assert(size > 0); > >>> + > >>> + lut->size = size; > >>> + lut->data = malloc(size * sizeof(struct drm_color_lut)); > >>> + igt_assert(lut); > >>> +} > >>> + > >>> +/* Generates the linear gamma LUT. */ > >>> +static void lut_gen_linear(lut_t *lut, uint16_t mask) > >>> +{ > >>> + uint32_t n = lut->size - 1; > >>> + uint32_t i; > >>> + > >>> + for (i = 0; i < lut->size; ++i) { > >>> + uint32_t v = (i * 0xffff / n) & mask; > >>> + > >>> + lut->data[i].red = v; > >>> + lut->data[i].blue = v; > >>> + lut->data[i].green = v; > >>> + } > >>> +} > >>> + > >>> +/* Generates the sRGB degamma LUT. */ > >>> +static void lut_gen_degamma_srgb(lut_t *lut, uint16_t mask) > >>> +{ > >>> + double range = lut->size - 1; > >>> + uint32_t i; > >>> + > >>> + for (i = 0; i < lut->size; ++i) { > >>> + double u, coeff; > >>> + uint32_t v; > >>> + > >>> + u = i / range; > >>> + coeff = u <= 0.040449936 ? (u / 12.92) > >>> + : (pow((u + 0.055) / 1.055, 2.4)); > >>> + v = (uint32_t)(coeff * 0xffff) & mask; > >>> + > >>> + lut->data[i].red = v; > >>> + lut->data[i].blue = v; > >>> + lut->data[i].green = v; > >>> + } > >>> +} > >>> + > >>> +/* Generates the sRGB gamma LUT. */ > >>> +static void lut_gen_regamma_srgb(lut_t *lut, uint16_t mask) > >>> +{ > >>> + double range = lut->size - 1; > >>> + uint32_t i; > >>> + > >>> + for (i = 0; i < lut->size; ++i) { > >>> + double u, coeff; > >>> + uint32_t v; > >>> + > >>> + u = i / range; > >>> + coeff = u <= 0.00313080 ? (12.92 * u) > >>> + : (1.055 * pow(u, 1.0 / 2.4) - 0.055); > >>> + v = (uint32_t)(coeff * 0xffff) & mask; > >>> + > >>> + lut->data[i].red = v; > >>> + lut->data[i].blue = v; > >>> + lut->data[i].green = v; > >>> + } > >>> +} > >>> + > >>> +static void lut_free(lut_t *lut) > >>> +{ > >>> + if (lut->data) { > >>> + free(lut->data); > >>> + lut->data = NULL; > >>> + } > >>> + > >>> + lut->size = 0; > >>> +} > >>> + > >>> +/* Fills a FB with the solid color given. */ > >>> +static void draw_color(igt_fb_t *fb, double r, double g, double b) > >>> +{ > >>> + cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb); > >>> + > >>> + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); > >>> + igt_paint_color(cr, 0, 0, fb->width, fb->height, r, g, b); > >>> + igt_put_cairo_ctx(fb->fd, fb, cr); > >>> +} > >>> + > >>> +/* Generates the gamma test pattern. */ > >>> +static void draw_gamma_test(igt_fb_t *fb) > >>> +{ > >>> + cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb); > >>> + int gh = fb->height / 4; > >>> + > >>> + igt_paint_color_gradient(cr, 0, 0, fb->width, gh, 1, 1, 1); > >>> + igt_paint_color_gradient(cr, 0, gh, fb->width, gh, 1, 0, 0); > >>> + igt_paint_color_gradient(cr, 0, gh * 2, fb->width, gh, 0, 1, 0); > >>> + igt_paint_color_gradient(cr, 0, gh * 3, fb->width, gh, 0, 0, 1); > >>> + > >>> + igt_put_cairo_ctx(fb->fd, fb, cr); > >>> +} > >>> + > >>> +/* Sets the degamma LUT. */ > >>> +static void set_degamma_lut(data_t *data, lut_t const *lut) > >>> +{ > >>> + size_t size = lut ? sizeof(lut->data[0]) * lut->size : 0; > >>> + const void *ptr = lut ? lut->data : NULL; > >>> + > >>> + igt_pipe_obj_replace_prop_blob(data->pipe, IGT_CRTC_DEGAMMA_LUT, ptr, > >>> + size); > >>> +} > >>> + > >>> +/* Sets the regamma LUT. */ > >>> +static void set_regamma_lut(data_t *data, lut_t const *lut) > >>> +{ > >>> + size_t size = lut ? sizeof(lut->data[0]) * lut->size : 0; > >>> + const void *ptr = lut ? lut->data : NULL; > >>> + > >>> + igt_pipe_obj_replace_prop_blob(data->pipe, IGT_CRTC_GAMMA_LUT, ptr, > >>> + size); > >>> +} > >>> + > >>> +/* Common test setup. */ > >>> +static void test_init(data_t *data) > >>> +{ > >>> + igt_display_t *display = &data->display; > >>> + > >>> + /* It doesn't matter which pipe we choose on amdpgu. */ > >>> + data->pipe_id = PIPE_A; > >>> + data->pipe = &data->display.pipes[data->pipe_id]; > >>> + > >>> + igt_display_reset(display); > >>> + > >>> + data->output = igt_get_single_output_for_pipe(display, data->pipe_id); > >>> + igt_require(data->output); > >>> + > >>> + data->mode = igt_output_get_mode(data->output); > >>> + igt_assert(data->mode); > >>> + > >>> + data->primary = > >>> + igt_pipe_get_plane_type(data->pipe, DRM_PLANE_TYPE_PRIMARY); > >>> + > >>> + data->pipe_crc = igt_pipe_crc_new(data->fd, data->pipe_id, > >>> + INTEL_PIPE_CRC_SOURCE_AUTO); > >>> + > >>> + igt_output_set_pipe(data->output, data->pipe_id); > >>> + > >>> + data->degamma_lut_size = > >>> + igt_pipe_obj_get_prop(data->pipe, IGT_CRTC_DEGAMMA_LUT_SIZE); > >>> + igt_assert_lt(0, data->degamma_lut_size); > >>> + > >>> + data->regamma_lut_size = > >>> + igt_pipe_obj_get_prop(data->pipe, IGT_CRTC_GAMMA_LUT_SIZE); > >>> + igt_assert_lt(0, data->regamma_lut_size); > >>> + > >>> + data->w = data->mode->hdisplay; > >>> + data->h = data->mode->vdisplay; > >>> +} > >>> + > >>> +/* Common test cleanup. */ > >>> +static void test_fini(data_t *data) > >>> +{ > >>> + igt_pipe_crc_free(data->pipe_crc); > >>> + igt_display_reset(&data->display); > >>> +} > >>> + > >>> +/* > >>> + * Older versions of amdgpu would put the pipe into bypass mode for degamma > >>> + * when passed a linear sRGB matrix but would still use an sRGB regamma > >>> + * matrix if not passed any. The whole pipe should be in linear bypass mode > >>> + * when all the matrices are NULL - CRCs for a linear degamma matrix and > >>> + * a NULL one should match. > >>> + */ > >>> +static void test_crtc_linear_degamma(data_t *data) > >>> +{ > >>> + igt_display_t *display = &data->display; > >>> + igt_crc_t ref_crc, new_crc; > >>> + igt_fb_t afb; > >>> + lut_t lut_linear; > >>> + > >>> + test_init(data); > >>> + > >>> + lut_init(&lut_linear, data->degamma_lut_size); > >>> + lut_gen_linear(&lut_linear, 0xffff); > >>> + > >>> + igt_create_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888, 0, &afb); > >>> + draw_gamma_test(&afb); > >>> + > >>> + /* Draw the reference image. */ > >>> + igt_plane_set_fb(data->primary, &afb); > >>> + set_regamma_lut(data, NULL); > >>> + set_degamma_lut(data, NULL); > >>> + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); > >>> + > >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); > >>> + > >>> + /* Apply a linear degamma. The result should remain the same. */ > >>> + set_degamma_lut(data, &lut_linear); > >>> + igt_display_commit_atomic(display, 0, NULL); > >>> + > >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); > >>> + igt_assert_crc_equal(&ref_crc, &new_crc); > >>> + > >>> + test_fini(data); > >>> + igt_remove_fb(data->fd, &afb); > >>> + lut_free(&lut_linear); > >>> +} > >>> + > >>> +/* > >>> + * Older versions of amdgpu would apply the CRTC regamma on top of a custom > >>> + * sRGB regamma matrix with incorrect calculations or rounding errors. > >>> + * If we put the pipe into bypass or use the hardware defined sRGB regamma > >>> + * on the plane then we can and should get the correct CRTC when passing a > >>> + * liner regamma matrix to DRM. > >>> + */ > >>> +static void test_crtc_linear_regamma(data_t *data) > >>> +{ > >>> + igt_display_t *display = &data->display; > >>> + igt_crc_t ref_crc, new_crc; > >>> + igt_fb_t afb; > >>> + lut_t lut_linear; > >>> + > >>> + test_init(data); > >>> + > >>> + lut_init(&lut_linear, data->regamma_lut_size); > >>> + lut_gen_linear(&lut_linear, 0xffff); > >>> + > >>> + igt_create_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888, 0, &afb); > >>> + draw_gamma_test(&afb); > >>> + > >>> + /* Draw the reference image. */ > >>> + igt_plane_set_fb(data->primary, &afb); > >>> + set_regamma_lut(data, NULL); > >>> + set_degamma_lut(data, NULL); > >>> + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); > >>> + > >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); > >>> + > >>> + /* Apply a linear degamma. The result should remain the same. */ > >>> + set_regamma_lut(data, &lut_linear); > >>> + igt_display_commit_atomic(display, 0, NULL); > >>> + > >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); > >>> + igt_assert_crc_equal(&ref_crc, &new_crc); > >>> + > >>> + test_fini(data); > >>> + igt_remove_fb(data->fd, &afb); > >>> + lut_free(&lut_linear); > >>> +} > >>> + > >>> +/* > >>> + * Tests LUT accuracy. CRTC regamma and CRTC degamma should produce a visually > >>> + * correct image when used. Hardware limitations on degamma prevent this from > >>> + * being CRC level accurate across a full test gradient but most values should > >>> + * still match. > >>> + * > >>> + * This test can't pass on DCE because it doesn't support non-linear degamma. > >>> + */ > >>> +static void test_crtc_lut_accuracy(data_t *data) > >>> +{ > >>> + /* > >>> + * Channels are independent, so we can verify multiple colors at the > >>> + * same time for improved performance. > >>> + */ > >>> + static const color_t colors[] = { > >>> + { 1.00, 1.00, 1.00 }, > >>> + { 0.90, 0.85, 0.75 }, /* 0.95 fails */ > >>> + { 0.70, 0.65, 0.60 }, > >>> + { 0.55, 0.50, 0.45 }, > >>> + { 0.40, 0.35, 0.30 }, > >>> + { 0.25, 0.20, 0.15 }, > >>> + { 0.10, 0.04, 0.02 }, /* 0.05 fails */ > >>> + { 0.00, 0.00, 0.00 }, > >>> + }; > >>> + igt_display_t *display = &data->display; > >>> + igt_crc_t ref_crc, new_crc; > >>> + igt_fb_t afb; > >>> + lut_t lut_degamma, lut_regamma; > >>> + int i, w, h; > >>> + > >>> + test_init(data); > >>> + > >>> + lut_init(&lut_degamma, data->degamma_lut_size); > >>> + lut_gen_degamma_srgb(&lut_degamma, 0xffff); > >>> + > >>> + lut_init(&lut_regamma, data->regamma_lut_size); > >>> + lut_gen_regamma_srgb(&lut_regamma, 0xffff); > >>> + > >>> + /* Don't draw across the whole screen to improve perf. */ > >>> + w = 64; > >>> + h = 64; > >>> + > >>> + igt_create_fb(data->fd, w, h, DRM_FORMAT_XRGB8888, 0, &afb); > >>> + igt_plane_set_fb(data->primary, &afb); > >>> + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); > >>> + > >>> + /* Test colors. */ > >>> + for (i = 0; i < ARRAY_SIZE(colors); ++i) { > >>> + color_t col = colors[i]; > >>> + > >>> + igt_info("Testing color (%.2f, %.2f, %.2f) ...\n", col.r, col.g, > >>> + col.b); > >>> + > >>> + draw_color(&afb, col.r, col.g, col.b); > >>> + > >>> + set_regamma_lut(data, NULL); > >>> + set_degamma_lut(data, NULL); > >>> + igt_display_commit_atomic(display, 0, NULL); > >>> + > >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); > >>> + > >>> + set_degamma_lut(data, &lut_degamma); > >>> + set_regamma_lut(data, &lut_regamma); > >>> + igt_display_commit_atomic(display, 0, NULL); > >>> + > >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); > >>> + > >>> + igt_assert_crc_equal(&ref_crc, &new_crc); > >>> + } > >>> + > >>> + test_fini(data); > >>> + igt_remove_fb(data->fd, &afb); > >>> + lut_free(&lut_regamma); > >>> + lut_free(&lut_degamma); > >>> +} > >>> + > >>> +igt_main > >>> +{ > >>> + data_t data; > >>> + > >>> + igt_skip_on_simulation(); > >>> + > >>> + memset(&data, 0, sizeof(data)); > >>> + > >>> + igt_fixture > >>> + { > >>> + data.fd = drm_open_driver_master(DRIVER_AMDGPU); > >>> + > >>> + kmstest_set_vt_graphics_mode(); > >>> + > >>> + igt_display_require(&data.display, data.fd); > >>> + igt_require(data.display.is_atomic); > >>> + igt_display_require_output(&data.display); > >>> + } > >>> + > >>> + igt_subtest("crtc-linear-degamma") test_crtc_linear_degamma(&data); > >>> + igt_subtest("crtc-linear-regamma") test_crtc_linear_regamma(&data); > >>> + igt_subtest("crtc-lut-accuracy") test_crtc_lut_accuracy(&data); > >>> + > >>> + igt_fixture > >>> + { > >>> + igt_display_fini(&data.display); > >>> + } > >>> +} > >>> diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build > >>> index 1afece86..42086374 100644 > >>> --- a/tests/amdgpu/meson.build > >>> +++ b/tests/amdgpu/meson.build > >>> @@ -4,6 +4,7 @@ amdgpu_deps = test_deps > >>> if libdrm_amdgpu.found() > >>> amdgpu_progs += [ 'amd_abm', > >>> 'amd_basic', > >>> + 'amd_color', > >>> 'amd_cs_nop', > >>> 'amd_prime', > >>> ] > >>> > >> _______________________________________________ > >> igt-dev mailing list > >> igt-dev@lists.freedesktop.org > >> https://lists.freedesktop.org/mailman/listinfo/igt-dev > > > > > > > -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] tests/amdgpu: Add color tests for amdgpu 2019-07-11 17:30 ` Daniel Vetter @ 2019-07-11 17:34 ` Kazlauskas, Nicholas 2019-07-11 17:46 ` Ville Syrjälä 1 sibling, 0 replies; 10+ messages in thread From: Kazlauskas, Nicholas @ 2019-07-11 17:34 UTC (permalink / raw) To: Daniel Vetter; +Cc: igt-dev On 7/11/19 1:30 PM, Daniel Vetter wrote: > On Thu, Jul 11, 2019 at 7:19 PM Kazlauskas, Nicholas > <Nicholas.Kazlauskas@amd.com> wrote: >> >> On 7/11/19 1:15 PM, Daniel Vetter wrote: >>> On Wed, May 29, 2019 at 8:43 PM Li, Sun peng (Leo) <Sunpeng.Li@amd.com> wrote: >>>> >>>> >>>> >>>> On 2019-05-27 1:19 p.m., Nicholas Kazlauskas wrote: >>>>> The DRM color management pipeline doesn't directly map to AMD hardware >>>>> so creative solutions to implementing CRTC regamma, CTM and gamma were >>>>> needed for both DCE and DCN. A few mistakes were made in the process >>>>> that weren't caught by kms_color@ tests: >>>>> >>>>> - Can't get linear degamma output without setting a custom degamma >>>>> - Can't specify a non-linear degamma that produces correct output >>>>> - Can't specify a correct gamma when a linear degamma is used >>>>> >>>>> These are caused by using implicit sRGB degamma then sRGB gamma when no >>>>> matrices are set. This produces visually correct output when using a >>>>> CTM with no matrices set, but it's also technically the incorrect >>>>> output according to the DRM API documentation. >>>>> >>>>> These tests help verify that AMDGPU follows the DRM spec when it comes >>>>> to setting linear/bypass gamma and regamma LUT. >>>>> >>>>> The existing kms_color@ tests are written correctly already, so >>>>> anything that looks shared in these is really just to verify that we're >>>>> no longer doing any strange test specific workarounds outside of the >>>>> spec or documentation. >>>>> >>>>> Cc: Leo Li <sunpeng.li@amd.com> >>>>> Cc: Harry Wentland <harry.wentland@amd.com> >>>>> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com> >>>> >>>> LGTM, thanks for the test! >>>> >>>> Reviewed-by: Leo Li <sunpeng.li@amd.com> >>> >>> btw why is this not a new subtest for kms_color? From a quick look >>> it's all generic. The specific testscase for amdpgpu (like >>> amd_bypass.c) all make sense, since they use specific crc tap points >>> and check hw implementation details. But this looks like a generic >>> issue with the color correction kms spec ... Also adding Harry. >>> -Daniel >> >> The test_crtc_lut_accuracy test is specific to our DCN hardware in terms >> of what we expect and that it requires a independent per channel CRC. >> >> The other two tests could probably be added to kms_color with the >> expectation that a linear LUT is going to be the same as not setting any >> LUT at all on the hardware. >> >> I don't think there's any issue here with the kms spec, it's clearly >> defined - we were previously breaking the spec by not actually using >> bypass for a NULL LUT. > > I mean: you found a gap between the spec and the kms_color test > coverage. I think it's worth fixing this, since if you hit this one, > then probably someone else hits this too with their hw/driver combo. > And the long term goal with igt is that at least for kms, it would be > a conformance test suite. Would be great if you could port these two > tests to kms_color (the one that makes specific assumptions about DCN > hw obviously can't be ported). And yeah the assumption, at least for > RGB formats is that "no gamm" == "linear gamma", and having a testcase > for this explicitly sounds like a great idea. > -Daniel I think that's fair then. I'll try and make some patches to pull these out into kms_color when I get a chance then, thanks! Nicholas Kazlauskas > >> Nicholas Kazlauskas >> >>> >>>> >>>>> --- >>>>> tests/Makefile.sources | 1 + >>>>> tests/amdgpu/amd_color.c | 405 +++++++++++++++++++++++++++++++++++++++ >>>>> tests/amdgpu/meson.build | 1 + >>>>> 3 files changed, 407 insertions(+) >>>>> create mode 100644 tests/amdgpu/amd_color.c >>>>> >>>>> diff --git a/tests/Makefile.sources b/tests/Makefile.sources >>>>> index 2d5c929e..ef3c03f2 100644 >>>>> --- a/tests/Makefile.sources >>>>> +++ b/tests/Makefile.sources >>>>> @@ -6,6 +6,7 @@ NOUVEAU_TESTS = \ >>>>> >>>>> AMDGPU_TESTS = \ >>>>> amdgpu/amd_basic \ >>>>> + amdgpu/amd_color \ >>>>> amdgpu/amd_cs_nop \ >>>>> amdgpu/amd_prime \ >>>>> amdgpu/amd_abm \ >>>>> diff --git a/tests/amdgpu/amd_color.c b/tests/amdgpu/amd_color.c >>>>> new file mode 100644 >>>>> index 00000000..0bbee43d >>>>> --- /dev/null >>>>> +++ b/tests/amdgpu/amd_color.c >>>>> @@ -0,0 +1,405 @@ >>>>> +/* >>>>> + * Copyright 2019 Advanced Micro Devices, Inc. >>>>> + * >>>>> + * 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. >>>>> + */ >>>>> + >>>>> +#include "igt.h" >>>>> + >>>>> +/* (De)gamma LUT. */ >>>>> +typedef struct lut { >>>>> + struct drm_color_lut *data; >>>>> + uint32_t size; >>>>> +} lut_t; >>>>> + >>>>> +/* RGB color. */ >>>>> +typedef struct color { >>>>> + double r; >>>>> + double g; >>>>> + double b; >>>>> +} color_t; >>>>> + >>>>> +/* Common test data. */ >>>>> +typedef struct data { >>>>> + igt_display_t display; >>>>> + igt_plane_t *primary; >>>>> + igt_output_t *output; >>>>> + igt_pipe_t *pipe; >>>>> + igt_pipe_crc_t *pipe_crc; >>>>> + drmModeModeInfo *mode; >>>>> + enum pipe pipe_id; >>>>> + int fd; >>>>> + int w; >>>>> + int h; >>>>> + uint32_t regamma_lut_size; >>>>> + uint32_t degamma_lut_size; >>>>> +} data_t; >>>>> + >>>>> +static void lut_init(lut_t *lut, uint32_t size) >>>>> +{ >>>>> + igt_assert(size > 0); >>>>> + >>>>> + lut->size = size; >>>>> + lut->data = malloc(size * sizeof(struct drm_color_lut)); >>>>> + igt_assert(lut); >>>>> +} >>>>> + >>>>> +/* Generates the linear gamma LUT. */ >>>>> +static void lut_gen_linear(lut_t *lut, uint16_t mask) >>>>> +{ >>>>> + uint32_t n = lut->size - 1; >>>>> + uint32_t i; >>>>> + >>>>> + for (i = 0; i < lut->size; ++i) { >>>>> + uint32_t v = (i * 0xffff / n) & mask; >>>>> + >>>>> + lut->data[i].red = v; >>>>> + lut->data[i].blue = v; >>>>> + lut->data[i].green = v; >>>>> + } >>>>> +} >>>>> + >>>>> +/* Generates the sRGB degamma LUT. */ >>>>> +static void lut_gen_degamma_srgb(lut_t *lut, uint16_t mask) >>>>> +{ >>>>> + double range = lut->size - 1; >>>>> + uint32_t i; >>>>> + >>>>> + for (i = 0; i < lut->size; ++i) { >>>>> + double u, coeff; >>>>> + uint32_t v; >>>>> + >>>>> + u = i / range; >>>>> + coeff = u <= 0.040449936 ? (u / 12.92) >>>>> + : (pow((u + 0.055) / 1.055, 2.4)); >>>>> + v = (uint32_t)(coeff * 0xffff) & mask; >>>>> + >>>>> + lut->data[i].red = v; >>>>> + lut->data[i].blue = v; >>>>> + lut->data[i].green = v; >>>>> + } >>>>> +} >>>>> + >>>>> +/* Generates the sRGB gamma LUT. */ >>>>> +static void lut_gen_regamma_srgb(lut_t *lut, uint16_t mask) >>>>> +{ >>>>> + double range = lut->size - 1; >>>>> + uint32_t i; >>>>> + >>>>> + for (i = 0; i < lut->size; ++i) { >>>>> + double u, coeff; >>>>> + uint32_t v; >>>>> + >>>>> + u = i / range; >>>>> + coeff = u <= 0.00313080 ? (12.92 * u) >>>>> + : (1.055 * pow(u, 1.0 / 2.4) - 0.055); >>>>> + v = (uint32_t)(coeff * 0xffff) & mask; >>>>> + >>>>> + lut->data[i].red = v; >>>>> + lut->data[i].blue = v; >>>>> + lut->data[i].green = v; >>>>> + } >>>>> +} >>>>> + >>>>> +static void lut_free(lut_t *lut) >>>>> +{ >>>>> + if (lut->data) { >>>>> + free(lut->data); >>>>> + lut->data = NULL; >>>>> + } >>>>> + >>>>> + lut->size = 0; >>>>> +} >>>>> + >>>>> +/* Fills a FB with the solid color given. */ >>>>> +static void draw_color(igt_fb_t *fb, double r, double g, double b) >>>>> +{ >>>>> + cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb); >>>>> + >>>>> + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); >>>>> + igt_paint_color(cr, 0, 0, fb->width, fb->height, r, g, b); >>>>> + igt_put_cairo_ctx(fb->fd, fb, cr); >>>>> +} >>>>> + >>>>> +/* Generates the gamma test pattern. */ >>>>> +static void draw_gamma_test(igt_fb_t *fb) >>>>> +{ >>>>> + cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb); >>>>> + int gh = fb->height / 4; >>>>> + >>>>> + igt_paint_color_gradient(cr, 0, 0, fb->width, gh, 1, 1, 1); >>>>> + igt_paint_color_gradient(cr, 0, gh, fb->width, gh, 1, 0, 0); >>>>> + igt_paint_color_gradient(cr, 0, gh * 2, fb->width, gh, 0, 1, 0); >>>>> + igt_paint_color_gradient(cr, 0, gh * 3, fb->width, gh, 0, 0, 1); >>>>> + >>>>> + igt_put_cairo_ctx(fb->fd, fb, cr); >>>>> +} >>>>> + >>>>> +/* Sets the degamma LUT. */ >>>>> +static void set_degamma_lut(data_t *data, lut_t const *lut) >>>>> +{ >>>>> + size_t size = lut ? sizeof(lut->data[0]) * lut->size : 0; >>>>> + const void *ptr = lut ? lut->data : NULL; >>>>> + >>>>> + igt_pipe_obj_replace_prop_blob(data->pipe, IGT_CRTC_DEGAMMA_LUT, ptr, >>>>> + size); >>>>> +} >>>>> + >>>>> +/* Sets the regamma LUT. */ >>>>> +static void set_regamma_lut(data_t *data, lut_t const *lut) >>>>> +{ >>>>> + size_t size = lut ? sizeof(lut->data[0]) * lut->size : 0; >>>>> + const void *ptr = lut ? lut->data : NULL; >>>>> + >>>>> + igt_pipe_obj_replace_prop_blob(data->pipe, IGT_CRTC_GAMMA_LUT, ptr, >>>>> + size); >>>>> +} >>>>> + >>>>> +/* Common test setup. */ >>>>> +static void test_init(data_t *data) >>>>> +{ >>>>> + igt_display_t *display = &data->display; >>>>> + >>>>> + /* It doesn't matter which pipe we choose on amdpgu. */ >>>>> + data->pipe_id = PIPE_A; >>>>> + data->pipe = &data->display.pipes[data->pipe_id]; >>>>> + >>>>> + igt_display_reset(display); >>>>> + >>>>> + data->output = igt_get_single_output_for_pipe(display, data->pipe_id); >>>>> + igt_require(data->output); >>>>> + >>>>> + data->mode = igt_output_get_mode(data->output); >>>>> + igt_assert(data->mode); >>>>> + >>>>> + data->primary = >>>>> + igt_pipe_get_plane_type(data->pipe, DRM_PLANE_TYPE_PRIMARY); >>>>> + >>>>> + data->pipe_crc = igt_pipe_crc_new(data->fd, data->pipe_id, >>>>> + INTEL_PIPE_CRC_SOURCE_AUTO); >>>>> + >>>>> + igt_output_set_pipe(data->output, data->pipe_id); >>>>> + >>>>> + data->degamma_lut_size = >>>>> + igt_pipe_obj_get_prop(data->pipe, IGT_CRTC_DEGAMMA_LUT_SIZE); >>>>> + igt_assert_lt(0, data->degamma_lut_size); >>>>> + >>>>> + data->regamma_lut_size = >>>>> + igt_pipe_obj_get_prop(data->pipe, IGT_CRTC_GAMMA_LUT_SIZE); >>>>> + igt_assert_lt(0, data->regamma_lut_size); >>>>> + >>>>> + data->w = data->mode->hdisplay; >>>>> + data->h = data->mode->vdisplay; >>>>> +} >>>>> + >>>>> +/* Common test cleanup. */ >>>>> +static void test_fini(data_t *data) >>>>> +{ >>>>> + igt_pipe_crc_free(data->pipe_crc); >>>>> + igt_display_reset(&data->display); >>>>> +} >>>>> + >>>>> +/* >>>>> + * Older versions of amdgpu would put the pipe into bypass mode for degamma >>>>> + * when passed a linear sRGB matrix but would still use an sRGB regamma >>>>> + * matrix if not passed any. The whole pipe should be in linear bypass mode >>>>> + * when all the matrices are NULL - CRCs for a linear degamma matrix and >>>>> + * a NULL one should match. >>>>> + */ >>>>> +static void test_crtc_linear_degamma(data_t *data) >>>>> +{ >>>>> + igt_display_t *display = &data->display; >>>>> + igt_crc_t ref_crc, new_crc; >>>>> + igt_fb_t afb; >>>>> + lut_t lut_linear; >>>>> + >>>>> + test_init(data); >>>>> + >>>>> + lut_init(&lut_linear, data->degamma_lut_size); >>>>> + lut_gen_linear(&lut_linear, 0xffff); >>>>> + >>>>> + igt_create_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888, 0, &afb); >>>>> + draw_gamma_test(&afb); >>>>> + >>>>> + /* Draw the reference image. */ >>>>> + igt_plane_set_fb(data->primary, &afb); >>>>> + set_regamma_lut(data, NULL); >>>>> + set_degamma_lut(data, NULL); >>>>> + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); >>>>> + >>>>> + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); >>>>> + >>>>> + /* Apply a linear degamma. The result should remain the same. */ >>>>> + set_degamma_lut(data, &lut_linear); >>>>> + igt_display_commit_atomic(display, 0, NULL); >>>>> + >>>>> + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); >>>>> + igt_assert_crc_equal(&ref_crc, &new_crc); >>>>> + >>>>> + test_fini(data); >>>>> + igt_remove_fb(data->fd, &afb); >>>>> + lut_free(&lut_linear); >>>>> +} >>>>> + >>>>> +/* >>>>> + * Older versions of amdgpu would apply the CRTC regamma on top of a custom >>>>> + * sRGB regamma matrix with incorrect calculations or rounding errors. >>>>> + * If we put the pipe into bypass or use the hardware defined sRGB regamma >>>>> + * on the plane then we can and should get the correct CRTC when passing a >>>>> + * liner regamma matrix to DRM. >>>>> + */ >>>>> +static void test_crtc_linear_regamma(data_t *data) >>>>> +{ >>>>> + igt_display_t *display = &data->display; >>>>> + igt_crc_t ref_crc, new_crc; >>>>> + igt_fb_t afb; >>>>> + lut_t lut_linear; >>>>> + >>>>> + test_init(data); >>>>> + >>>>> + lut_init(&lut_linear, data->regamma_lut_size); >>>>> + lut_gen_linear(&lut_linear, 0xffff); >>>>> + >>>>> + igt_create_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888, 0, &afb); >>>>> + draw_gamma_test(&afb); >>>>> + >>>>> + /* Draw the reference image. */ >>>>> + igt_plane_set_fb(data->primary, &afb); >>>>> + set_regamma_lut(data, NULL); >>>>> + set_degamma_lut(data, NULL); >>>>> + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); >>>>> + >>>>> + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); >>>>> + >>>>> + /* Apply a linear degamma. The result should remain the same. */ >>>>> + set_regamma_lut(data, &lut_linear); >>>>> + igt_display_commit_atomic(display, 0, NULL); >>>>> + >>>>> + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); >>>>> + igt_assert_crc_equal(&ref_crc, &new_crc); >>>>> + >>>>> + test_fini(data); >>>>> + igt_remove_fb(data->fd, &afb); >>>>> + lut_free(&lut_linear); >>>>> +} >>>>> + >>>>> +/* >>>>> + * Tests LUT accuracy. CRTC regamma and CRTC degamma should produce a visually >>>>> + * correct image when used. Hardware limitations on degamma prevent this from >>>>> + * being CRC level accurate across a full test gradient but most values should >>>>> + * still match. >>>>> + * >>>>> + * This test can't pass on DCE because it doesn't support non-linear degamma. >>>>> + */ >>>>> +static void test_crtc_lut_accuracy(data_t *data) >>>>> +{ >>>>> + /* >>>>> + * Channels are independent, so we can verify multiple colors at the >>>>> + * same time for improved performance. >>>>> + */ >>>>> + static const color_t colors[] = { >>>>> + { 1.00, 1.00, 1.00 }, >>>>> + { 0.90, 0.85, 0.75 }, /* 0.95 fails */ >>>>> + { 0.70, 0.65, 0.60 }, >>>>> + { 0.55, 0.50, 0.45 }, >>>>> + { 0.40, 0.35, 0.30 }, >>>>> + { 0.25, 0.20, 0.15 }, >>>>> + { 0.10, 0.04, 0.02 }, /* 0.05 fails */ >>>>> + { 0.00, 0.00, 0.00 }, >>>>> + }; >>>>> + igt_display_t *display = &data->display; >>>>> + igt_crc_t ref_crc, new_crc; >>>>> + igt_fb_t afb; >>>>> + lut_t lut_degamma, lut_regamma; >>>>> + int i, w, h; >>>>> + >>>>> + test_init(data); >>>>> + >>>>> + lut_init(&lut_degamma, data->degamma_lut_size); >>>>> + lut_gen_degamma_srgb(&lut_degamma, 0xffff); >>>>> + >>>>> + lut_init(&lut_regamma, data->regamma_lut_size); >>>>> + lut_gen_regamma_srgb(&lut_regamma, 0xffff); >>>>> + >>>>> + /* Don't draw across the whole screen to improve perf. */ >>>>> + w = 64; >>>>> + h = 64; >>>>> + >>>>> + igt_create_fb(data->fd, w, h, DRM_FORMAT_XRGB8888, 0, &afb); >>>>> + igt_plane_set_fb(data->primary, &afb); >>>>> + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); >>>>> + >>>>> + /* Test colors. */ >>>>> + for (i = 0; i < ARRAY_SIZE(colors); ++i) { >>>>> + color_t col = colors[i]; >>>>> + >>>>> + igt_info("Testing color (%.2f, %.2f, %.2f) ...\n", col.r, col.g, >>>>> + col.b); >>>>> + >>>>> + draw_color(&afb, col.r, col.g, col.b); >>>>> + >>>>> + set_regamma_lut(data, NULL); >>>>> + set_degamma_lut(data, NULL); >>>>> + igt_display_commit_atomic(display, 0, NULL); >>>>> + >>>>> + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); >>>>> + >>>>> + set_degamma_lut(data, &lut_degamma); >>>>> + set_regamma_lut(data, &lut_regamma); >>>>> + igt_display_commit_atomic(display, 0, NULL); >>>>> + >>>>> + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); >>>>> + >>>>> + igt_assert_crc_equal(&ref_crc, &new_crc); >>>>> + } >>>>> + >>>>> + test_fini(data); >>>>> + igt_remove_fb(data->fd, &afb); >>>>> + lut_free(&lut_regamma); >>>>> + lut_free(&lut_degamma); >>>>> +} >>>>> + >>>>> +igt_main >>>>> +{ >>>>> + data_t data; >>>>> + >>>>> + igt_skip_on_simulation(); >>>>> + >>>>> + memset(&data, 0, sizeof(data)); >>>>> + >>>>> + igt_fixture >>>>> + { >>>>> + data.fd = drm_open_driver_master(DRIVER_AMDGPU); >>>>> + >>>>> + kmstest_set_vt_graphics_mode(); >>>>> + >>>>> + igt_display_require(&data.display, data.fd); >>>>> + igt_require(data.display.is_atomic); >>>>> + igt_display_require_output(&data.display); >>>>> + } >>>>> + >>>>> + igt_subtest("crtc-linear-degamma") test_crtc_linear_degamma(&data); >>>>> + igt_subtest("crtc-linear-regamma") test_crtc_linear_regamma(&data); >>>>> + igt_subtest("crtc-lut-accuracy") test_crtc_lut_accuracy(&data); >>>>> + >>>>> + igt_fixture >>>>> + { >>>>> + igt_display_fini(&data.display); >>>>> + } >>>>> +} >>>>> diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build >>>>> index 1afece86..42086374 100644 >>>>> --- a/tests/amdgpu/meson.build >>>>> +++ b/tests/amdgpu/meson.build >>>>> @@ -4,6 +4,7 @@ amdgpu_deps = test_deps >>>>> if libdrm_amdgpu.found() >>>>> amdgpu_progs += [ 'amd_abm', >>>>> 'amd_basic', >>>>> + 'amd_color', >>>>> 'amd_cs_nop', >>>>> 'amd_prime', >>>>> ] >>>>> >>>> _______________________________________________ >>>> igt-dev mailing list >>>> igt-dev@lists.freedesktop.org >>>> https://lists.freedesktop.org/mailman/listinfo/igt-dev >>> >>> >>> >> > > _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] tests/amdgpu: Add color tests for amdgpu 2019-07-11 17:30 ` Daniel Vetter 2019-07-11 17:34 ` Kazlauskas, Nicholas @ 2019-07-11 17:46 ` Ville Syrjälä 2019-07-11 18:58 ` Daniel Vetter 1 sibling, 1 reply; 10+ messages in thread From: Ville Syrjälä @ 2019-07-11 17:46 UTC (permalink / raw) To: Daniel Vetter; +Cc: igt-dev On Thu, Jul 11, 2019 at 07:30:39PM +0200, Daniel Vetter wrote: > On Thu, Jul 11, 2019 at 7:19 PM Kazlauskas, Nicholas > <Nicholas.Kazlauskas@amd.com> wrote: > > > > On 7/11/19 1:15 PM, Daniel Vetter wrote: > > > On Wed, May 29, 2019 at 8:43 PM Li, Sun peng (Leo) <Sunpeng.Li@amd.com> wrote: > > >> > > >> > > >> > > >> On 2019-05-27 1:19 p.m., Nicholas Kazlauskas wrote: > > >>> The DRM color management pipeline doesn't directly map to AMD hardware > > >>> so creative solutions to implementing CRTC regamma, CTM and gamma were > > >>> needed for both DCE and DCN. A few mistakes were made in the process > > >>> that weren't caught by kms_color@ tests: > > >>> > > >>> - Can't get linear degamma output without setting a custom degamma > > >>> - Can't specify a non-linear degamma that produces correct output > > >>> - Can't specify a correct gamma when a linear degamma is used > > >>> > > >>> These are caused by using implicit sRGB degamma then sRGB gamma when no > > >>> matrices are set. This produces visually correct output when using a > > >>> CTM with no matrices set, but it's also technically the incorrect > > >>> output according to the DRM API documentation. > > >>> > > >>> These tests help verify that AMDGPU follows the DRM spec when it comes > > >>> to setting linear/bypass gamma and regamma LUT. > > >>> > > >>> The existing kms_color@ tests are written correctly already, so > > >>> anything that looks shared in these is really just to verify that we're > > >>> no longer doing any strange test specific workarounds outside of the > > >>> spec or documentation. > > >>> > > >>> Cc: Leo Li <sunpeng.li@amd.com> > > >>> Cc: Harry Wentland <harry.wentland@amd.com> > > >>> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com> > > >> > > >> LGTM, thanks for the test! > > >> > > >> Reviewed-by: Leo Li <sunpeng.li@amd.com> > > > > > > btw why is this not a new subtest for kms_color? From a quick look > > > it's all generic. The specific testscase for amdpgpu (like > > > amd_bypass.c) all make sense, since they use specific crc tap points > > > and check hw implementation details. But this looks like a generic > > > issue with the color correction kms spec ... Also adding Harry. > > > -Daniel > > > > The test_crtc_lut_accuracy test is specific to our DCN hardware in terms > > of what we expect and that it requires a independent per channel CRC. > > > > The other two tests could probably be added to kms_color with the > > expectation that a linear LUT is going to be the same as not setting any > > LUT at all on the hardware. > > > > I don't think there's any issue here with the kms spec, it's clearly > > defined - we were previously breaking the spec by not actually using > > bypass for a NULL LUT. > > I mean: you found a gap between the spec and the kms_color test > coverage. I think it's worth fixing this, since if you hit this one, > then probably someone else hits this too with their hw/driver combo. > And the long term goal with igt is that at least for kms, it would be > a conformance test suite. Would be great if you could port these two > tests to kms_color (the one that makes specific assumptions about DCN > hw obviously can't be ported). And yeah the assumption, at least for > RGB formats is that "no gamm" == "linear gamma", and having a testcase > for this explicitly sounds like a great idea. No gamma != linear gamma. On our hw the gamma LUT usually has lower precision. > -Daniel > > > Nicholas Kazlauskas > > > > > > > >> > > >>> --- > > >>> tests/Makefile.sources | 1 + > > >>> tests/amdgpu/amd_color.c | 405 +++++++++++++++++++++++++++++++++++++++ > > >>> tests/amdgpu/meson.build | 1 + > > >>> 3 files changed, 407 insertions(+) > > >>> create mode 100644 tests/amdgpu/amd_color.c > > >>> > > >>> diff --git a/tests/Makefile.sources b/tests/Makefile.sources > > >>> index 2d5c929e..ef3c03f2 100644 > > >>> --- a/tests/Makefile.sources > > >>> +++ b/tests/Makefile.sources > > >>> @@ -6,6 +6,7 @@ NOUVEAU_TESTS = \ > > >>> > > >>> AMDGPU_TESTS = \ > > >>> amdgpu/amd_basic \ > > >>> + amdgpu/amd_color \ > > >>> amdgpu/amd_cs_nop \ > > >>> amdgpu/amd_prime \ > > >>> amdgpu/amd_abm \ > > >>> diff --git a/tests/amdgpu/amd_color.c b/tests/amdgpu/amd_color.c > > >>> new file mode 100644 > > >>> index 00000000..0bbee43d > > >>> --- /dev/null > > >>> +++ b/tests/amdgpu/amd_color.c > > >>> @@ -0,0 +1,405 @@ > > >>> +/* > > >>> + * Copyright 2019 Advanced Micro Devices, Inc. > > >>> + * > > >>> + * 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. > > >>> + */ > > >>> + > > >>> +#include "igt.h" > > >>> + > > >>> +/* (De)gamma LUT. */ > > >>> +typedef struct lut { > > >>> + struct drm_color_lut *data; > > >>> + uint32_t size; > > >>> +} lut_t; > > >>> + > > >>> +/* RGB color. */ > > >>> +typedef struct color { > > >>> + double r; > > >>> + double g; > > >>> + double b; > > >>> +} color_t; > > >>> + > > >>> +/* Common test data. */ > > >>> +typedef struct data { > > >>> + igt_display_t display; > > >>> + igt_plane_t *primary; > > >>> + igt_output_t *output; > > >>> + igt_pipe_t *pipe; > > >>> + igt_pipe_crc_t *pipe_crc; > > >>> + drmModeModeInfo *mode; > > >>> + enum pipe pipe_id; > > >>> + int fd; > > >>> + int w; > > >>> + int h; > > >>> + uint32_t regamma_lut_size; > > >>> + uint32_t degamma_lut_size; > > >>> +} data_t; > > >>> + > > >>> +static void lut_init(lut_t *lut, uint32_t size) > > >>> +{ > > >>> + igt_assert(size > 0); > > >>> + > > >>> + lut->size = size; > > >>> + lut->data = malloc(size * sizeof(struct drm_color_lut)); > > >>> + igt_assert(lut); > > >>> +} > > >>> + > > >>> +/* Generates the linear gamma LUT. */ > > >>> +static void lut_gen_linear(lut_t *lut, uint16_t mask) > > >>> +{ > > >>> + uint32_t n = lut->size - 1; > > >>> + uint32_t i; > > >>> + > > >>> + for (i = 0; i < lut->size; ++i) { > > >>> + uint32_t v = (i * 0xffff / n) & mask; > > >>> + > > >>> + lut->data[i].red = v; > > >>> + lut->data[i].blue = v; > > >>> + lut->data[i].green = v; > > >>> + } > > >>> +} > > >>> + > > >>> +/* Generates the sRGB degamma LUT. */ > > >>> +static void lut_gen_degamma_srgb(lut_t *lut, uint16_t mask) > > >>> +{ > > >>> + double range = lut->size - 1; > > >>> + uint32_t i; > > >>> + > > >>> + for (i = 0; i < lut->size; ++i) { > > >>> + double u, coeff; > > >>> + uint32_t v; > > >>> + > > >>> + u = i / range; > > >>> + coeff = u <= 0.040449936 ? (u / 12.92) > > >>> + : (pow((u + 0.055) / 1.055, 2.4)); > > >>> + v = (uint32_t)(coeff * 0xffff) & mask; > > >>> + > > >>> + lut->data[i].red = v; > > >>> + lut->data[i].blue = v; > > >>> + lut->data[i].green = v; > > >>> + } > > >>> +} > > >>> + > > >>> +/* Generates the sRGB gamma LUT. */ > > >>> +static void lut_gen_regamma_srgb(lut_t *lut, uint16_t mask) > > >>> +{ > > >>> + double range = lut->size - 1; > > >>> + uint32_t i; > > >>> + > > >>> + for (i = 0; i < lut->size; ++i) { > > >>> + double u, coeff; > > >>> + uint32_t v; > > >>> + > > >>> + u = i / range; > > >>> + coeff = u <= 0.00313080 ? (12.92 * u) > > >>> + : (1.055 * pow(u, 1.0 / 2.4) - 0.055); > > >>> + v = (uint32_t)(coeff * 0xffff) & mask; > > >>> + > > >>> + lut->data[i].red = v; > > >>> + lut->data[i].blue = v; > > >>> + lut->data[i].green = v; > > >>> + } > > >>> +} > > >>> + > > >>> +static void lut_free(lut_t *lut) > > >>> +{ > > >>> + if (lut->data) { > > >>> + free(lut->data); > > >>> + lut->data = NULL; > > >>> + } > > >>> + > > >>> + lut->size = 0; > > >>> +} > > >>> + > > >>> +/* Fills a FB with the solid color given. */ > > >>> +static void draw_color(igt_fb_t *fb, double r, double g, double b) > > >>> +{ > > >>> + cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb); > > >>> + > > >>> + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); > > >>> + igt_paint_color(cr, 0, 0, fb->width, fb->height, r, g, b); > > >>> + igt_put_cairo_ctx(fb->fd, fb, cr); > > >>> +} > > >>> + > > >>> +/* Generates the gamma test pattern. */ > > >>> +static void draw_gamma_test(igt_fb_t *fb) > > >>> +{ > > >>> + cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb); > > >>> + int gh = fb->height / 4; > > >>> + > > >>> + igt_paint_color_gradient(cr, 0, 0, fb->width, gh, 1, 1, 1); > > >>> + igt_paint_color_gradient(cr, 0, gh, fb->width, gh, 1, 0, 0); > > >>> + igt_paint_color_gradient(cr, 0, gh * 2, fb->width, gh, 0, 1, 0); > > >>> + igt_paint_color_gradient(cr, 0, gh * 3, fb->width, gh, 0, 0, 1); > > >>> + > > >>> + igt_put_cairo_ctx(fb->fd, fb, cr); > > >>> +} > > >>> + > > >>> +/* Sets the degamma LUT. */ > > >>> +static void set_degamma_lut(data_t *data, lut_t const *lut) > > >>> +{ > > >>> + size_t size = lut ? sizeof(lut->data[0]) * lut->size : 0; > > >>> + const void *ptr = lut ? lut->data : NULL; > > >>> + > > >>> + igt_pipe_obj_replace_prop_blob(data->pipe, IGT_CRTC_DEGAMMA_LUT, ptr, > > >>> + size); > > >>> +} > > >>> + > > >>> +/* Sets the regamma LUT. */ > > >>> +static void set_regamma_lut(data_t *data, lut_t const *lut) > > >>> +{ > > >>> + size_t size = lut ? sizeof(lut->data[0]) * lut->size : 0; > > >>> + const void *ptr = lut ? lut->data : NULL; > > >>> + > > >>> + igt_pipe_obj_replace_prop_blob(data->pipe, IGT_CRTC_GAMMA_LUT, ptr, > > >>> + size); > > >>> +} > > >>> + > > >>> +/* Common test setup. */ > > >>> +static void test_init(data_t *data) > > >>> +{ > > >>> + igt_display_t *display = &data->display; > > >>> + > > >>> + /* It doesn't matter which pipe we choose on amdpgu. */ > > >>> + data->pipe_id = PIPE_A; > > >>> + data->pipe = &data->display.pipes[data->pipe_id]; > > >>> + > > >>> + igt_display_reset(display); > > >>> + > > >>> + data->output = igt_get_single_output_for_pipe(display, data->pipe_id); > > >>> + igt_require(data->output); > > >>> + > > >>> + data->mode = igt_output_get_mode(data->output); > > >>> + igt_assert(data->mode); > > >>> + > > >>> + data->primary = > > >>> + igt_pipe_get_plane_type(data->pipe, DRM_PLANE_TYPE_PRIMARY); > > >>> + > > >>> + data->pipe_crc = igt_pipe_crc_new(data->fd, data->pipe_id, > > >>> + INTEL_PIPE_CRC_SOURCE_AUTO); > > >>> + > > >>> + igt_output_set_pipe(data->output, data->pipe_id); > > >>> + > > >>> + data->degamma_lut_size = > > >>> + igt_pipe_obj_get_prop(data->pipe, IGT_CRTC_DEGAMMA_LUT_SIZE); > > >>> + igt_assert_lt(0, data->degamma_lut_size); > > >>> + > > >>> + data->regamma_lut_size = > > >>> + igt_pipe_obj_get_prop(data->pipe, IGT_CRTC_GAMMA_LUT_SIZE); > > >>> + igt_assert_lt(0, data->regamma_lut_size); > > >>> + > > >>> + data->w = data->mode->hdisplay; > > >>> + data->h = data->mode->vdisplay; > > >>> +} > > >>> + > > >>> +/* Common test cleanup. */ > > >>> +static void test_fini(data_t *data) > > >>> +{ > > >>> + igt_pipe_crc_free(data->pipe_crc); > > >>> + igt_display_reset(&data->display); > > >>> +} > > >>> + > > >>> +/* > > >>> + * Older versions of amdgpu would put the pipe into bypass mode for degamma > > >>> + * when passed a linear sRGB matrix but would still use an sRGB regamma > > >>> + * matrix if not passed any. The whole pipe should be in linear bypass mode > > >>> + * when all the matrices are NULL - CRCs for a linear degamma matrix and > > >>> + * a NULL one should match. > > >>> + */ > > >>> +static void test_crtc_linear_degamma(data_t *data) > > >>> +{ > > >>> + igt_display_t *display = &data->display; > > >>> + igt_crc_t ref_crc, new_crc; > > >>> + igt_fb_t afb; > > >>> + lut_t lut_linear; > > >>> + > > >>> + test_init(data); > > >>> + > > >>> + lut_init(&lut_linear, data->degamma_lut_size); > > >>> + lut_gen_linear(&lut_linear, 0xffff); > > >>> + > > >>> + igt_create_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888, 0, &afb); > > >>> + draw_gamma_test(&afb); > > >>> + > > >>> + /* Draw the reference image. */ > > >>> + igt_plane_set_fb(data->primary, &afb); > > >>> + set_regamma_lut(data, NULL); > > >>> + set_degamma_lut(data, NULL); > > >>> + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); > > >>> + > > >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); > > >>> + > > >>> + /* Apply a linear degamma. The result should remain the same. */ > > >>> + set_degamma_lut(data, &lut_linear); > > >>> + igt_display_commit_atomic(display, 0, NULL); > > >>> + > > >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); > > >>> + igt_assert_crc_equal(&ref_crc, &new_crc); > > >>> + > > >>> + test_fini(data); > > >>> + igt_remove_fb(data->fd, &afb); > > >>> + lut_free(&lut_linear); > > >>> +} > > >>> + > > >>> +/* > > >>> + * Older versions of amdgpu would apply the CRTC regamma on top of a custom > > >>> + * sRGB regamma matrix with incorrect calculations or rounding errors. > > >>> + * If we put the pipe into bypass or use the hardware defined sRGB regamma > > >>> + * on the plane then we can and should get the correct CRTC when passing a > > >>> + * liner regamma matrix to DRM. > > >>> + */ > > >>> +static void test_crtc_linear_regamma(data_t *data) > > >>> +{ > > >>> + igt_display_t *display = &data->display; > > >>> + igt_crc_t ref_crc, new_crc; > > >>> + igt_fb_t afb; > > >>> + lut_t lut_linear; > > >>> + > > >>> + test_init(data); > > >>> + > > >>> + lut_init(&lut_linear, data->regamma_lut_size); > > >>> + lut_gen_linear(&lut_linear, 0xffff); > > >>> + > > >>> + igt_create_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888, 0, &afb); > > >>> + draw_gamma_test(&afb); > > >>> + > > >>> + /* Draw the reference image. */ > > >>> + igt_plane_set_fb(data->primary, &afb); > > >>> + set_regamma_lut(data, NULL); > > >>> + set_degamma_lut(data, NULL); > > >>> + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); > > >>> + > > >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); > > >>> + > > >>> + /* Apply a linear degamma. The result should remain the same. */ > > >>> + set_regamma_lut(data, &lut_linear); > > >>> + igt_display_commit_atomic(display, 0, NULL); > > >>> + > > >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); > > >>> + igt_assert_crc_equal(&ref_crc, &new_crc); > > >>> + > > >>> + test_fini(data); > > >>> + igt_remove_fb(data->fd, &afb); > > >>> + lut_free(&lut_linear); > > >>> +} > > >>> + > > >>> +/* > > >>> + * Tests LUT accuracy. CRTC regamma and CRTC degamma should produce a visually > > >>> + * correct image when used. Hardware limitations on degamma prevent this from > > >>> + * being CRC level accurate across a full test gradient but most values should > > >>> + * still match. > > >>> + * > > >>> + * This test can't pass on DCE because it doesn't support non-linear degamma. > > >>> + */ > > >>> +static void test_crtc_lut_accuracy(data_t *data) > > >>> +{ > > >>> + /* > > >>> + * Channels are independent, so we can verify multiple colors at the > > >>> + * same time for improved performance. > > >>> + */ > > >>> + static const color_t colors[] = { > > >>> + { 1.00, 1.00, 1.00 }, > > >>> + { 0.90, 0.85, 0.75 }, /* 0.95 fails */ > > >>> + { 0.70, 0.65, 0.60 }, > > >>> + { 0.55, 0.50, 0.45 }, > > >>> + { 0.40, 0.35, 0.30 }, > > >>> + { 0.25, 0.20, 0.15 }, > > >>> + { 0.10, 0.04, 0.02 }, /* 0.05 fails */ > > >>> + { 0.00, 0.00, 0.00 }, > > >>> + }; > > >>> + igt_display_t *display = &data->display; > > >>> + igt_crc_t ref_crc, new_crc; > > >>> + igt_fb_t afb; > > >>> + lut_t lut_degamma, lut_regamma; > > >>> + int i, w, h; > > >>> + > > >>> + test_init(data); > > >>> + > > >>> + lut_init(&lut_degamma, data->degamma_lut_size); > > >>> + lut_gen_degamma_srgb(&lut_degamma, 0xffff); > > >>> + > > >>> + lut_init(&lut_regamma, data->regamma_lut_size); > > >>> + lut_gen_regamma_srgb(&lut_regamma, 0xffff); > > >>> + > > >>> + /* Don't draw across the whole screen to improve perf. */ > > >>> + w = 64; > > >>> + h = 64; > > >>> + > > >>> + igt_create_fb(data->fd, w, h, DRM_FORMAT_XRGB8888, 0, &afb); > > >>> + igt_plane_set_fb(data->primary, &afb); > > >>> + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); > > >>> + > > >>> + /* Test colors. */ > > >>> + for (i = 0; i < ARRAY_SIZE(colors); ++i) { > > >>> + color_t col = colors[i]; > > >>> + > > >>> + igt_info("Testing color (%.2f, %.2f, %.2f) ...\n", col.r, col.g, > > >>> + col.b); > > >>> + > > >>> + draw_color(&afb, col.r, col.g, col.b); > > >>> + > > >>> + set_regamma_lut(data, NULL); > > >>> + set_degamma_lut(data, NULL); > > >>> + igt_display_commit_atomic(display, 0, NULL); > > >>> + > > >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); > > >>> + > > >>> + set_degamma_lut(data, &lut_degamma); > > >>> + set_regamma_lut(data, &lut_regamma); > > >>> + igt_display_commit_atomic(display, 0, NULL); > > >>> + > > >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); > > >>> + > > >>> + igt_assert_crc_equal(&ref_crc, &new_crc); > > >>> + } > > >>> + > > >>> + test_fini(data); > > >>> + igt_remove_fb(data->fd, &afb); > > >>> + lut_free(&lut_regamma); > > >>> + lut_free(&lut_degamma); > > >>> +} > > >>> + > > >>> +igt_main > > >>> +{ > > >>> + data_t data; > > >>> + > > >>> + igt_skip_on_simulation(); > > >>> + > > >>> + memset(&data, 0, sizeof(data)); > > >>> + > > >>> + igt_fixture > > >>> + { > > >>> + data.fd = drm_open_driver_master(DRIVER_AMDGPU); > > >>> + > > >>> + kmstest_set_vt_graphics_mode(); > > >>> + > > >>> + igt_display_require(&data.display, data.fd); > > >>> + igt_require(data.display.is_atomic); > > >>> + igt_display_require_output(&data.display); > > >>> + } > > >>> + > > >>> + igt_subtest("crtc-linear-degamma") test_crtc_linear_degamma(&data); > > >>> + igt_subtest("crtc-linear-regamma") test_crtc_linear_regamma(&data); > > >>> + igt_subtest("crtc-lut-accuracy") test_crtc_lut_accuracy(&data); > > >>> + > > >>> + igt_fixture > > >>> + { > > >>> + igt_display_fini(&data.display); > > >>> + } > > >>> +} > > >>> diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build > > >>> index 1afece86..42086374 100644 > > >>> --- a/tests/amdgpu/meson.build > > >>> +++ b/tests/amdgpu/meson.build > > >>> @@ -4,6 +4,7 @@ amdgpu_deps = test_deps > > >>> if libdrm_amdgpu.found() > > >>> amdgpu_progs += [ 'amd_abm', > > >>> 'amd_basic', > > >>> + 'amd_color', > > >>> 'amd_cs_nop', > > >>> 'amd_prime', > > >>> ] > > >>> > > >> _______________________________________________ > > >> igt-dev mailing list > > >> igt-dev@lists.freedesktop.org > > >> https://lists.freedesktop.org/mailman/listinfo/igt-dev > > > > > > > > > > > > > > -- > Daniel Vetter > Software Engineer, Intel Corporation > +41 (0) 79 365 57 48 - http://blog.ffwll.ch > _______________________________________________ > igt-dev mailing list > igt-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/igt-dev -- Ville Syrjälä Intel _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] tests/amdgpu: Add color tests for amdgpu 2019-07-11 17:46 ` Ville Syrjälä @ 2019-07-11 18:58 ` Daniel Vetter 0 siblings, 0 replies; 10+ messages in thread From: Daniel Vetter @ 2019-07-11 18:58 UTC (permalink / raw) To: Ville Syrjälä; +Cc: igt-dev On Thu, Jul 11, 2019 at 7:47 PM Ville Syrjälä <ville.syrjala@linux.intel.com> wrote: > > On Thu, Jul 11, 2019 at 07:30:39PM +0200, Daniel Vetter wrote: > > On Thu, Jul 11, 2019 at 7:19 PM Kazlauskas, Nicholas > > <Nicholas.Kazlauskas@amd.com> wrote: > > > > > > On 7/11/19 1:15 PM, Daniel Vetter wrote: > > > > On Wed, May 29, 2019 at 8:43 PM Li, Sun peng (Leo) <Sunpeng.Li@amd.com> wrote: > > > >> > > > >> > > > >> > > > >> On 2019-05-27 1:19 p.m., Nicholas Kazlauskas wrote: > > > >>> The DRM color management pipeline doesn't directly map to AMD hardware > > > >>> so creative solutions to implementing CRTC regamma, CTM and gamma were > > > >>> needed for both DCE and DCN. A few mistakes were made in the process > > > >>> that weren't caught by kms_color@ tests: > > > >>> > > > >>> - Can't get linear degamma output without setting a custom degamma > > > >>> - Can't specify a non-linear degamma that produces correct output > > > >>> - Can't specify a correct gamma when a linear degamma is used > > > >>> > > > >>> These are caused by using implicit sRGB degamma then sRGB gamma when no > > > >>> matrices are set. This produces visually correct output when using a > > > >>> CTM with no matrices set, but it's also technically the incorrect > > > >>> output according to the DRM API documentation. > > > >>> > > > >>> These tests help verify that AMDGPU follows the DRM spec when it comes > > > >>> to setting linear/bypass gamma and regamma LUT. > > > >>> > > > >>> The existing kms_color@ tests are written correctly already, so > > > >>> anything that looks shared in these is really just to verify that we're > > > >>> no longer doing any strange test specific workarounds outside of the > > > >>> spec or documentation. > > > >>> > > > >>> Cc: Leo Li <sunpeng.li@amd.com> > > > >>> Cc: Harry Wentland <harry.wentland@amd.com> > > > >>> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com> > > > >> > > > >> LGTM, thanks for the test! > > > >> > > > >> Reviewed-by: Leo Li <sunpeng.li@amd.com> > > > > > > > > btw why is this not a new subtest for kms_color? From a quick look > > > > it's all generic. The specific testscase for amdpgpu (like > > > > amd_bypass.c) all make sense, since they use specific crc tap points > > > > and check hw implementation details. But this looks like a generic > > > > issue with the color correction kms spec ... Also adding Harry. > > > > -Daniel > > > > > > The test_crtc_lut_accuracy test is specific to our DCN hardware in terms > > > of what we expect and that it requires a independent per channel CRC. > > > > > > The other two tests could probably be added to kms_color with the > > > expectation that a linear LUT is going to be the same as not setting any > > > LUT at all on the hardware. > > > > > > I don't think there's any issue here with the kms spec, it's clearly > > > defined - we were previously breaking the spec by not actually using > > > bypass for a NULL LUT. > > > > I mean: you found a gap between the spec and the kms_color test > > coverage. I think it's worth fixing this, since if you hit this one, > > then probably someone else hits this too with their hw/driver combo. > > And the long term goal with igt is that at least for kms, it would be > > a conformance test suite. Would be great if you could port these two > > tests to kms_color (the one that makes specific assumptions about DCN > > hw obviously can't be ported). And yeah the assumption, at least for > > RGB formats is that "no gamm" == "linear gamma", and having a testcase > > for this explicitly sounds like a great idea. > > No gamma != linear gamma. On our hw the gamma LUT usually has lower > precision. Yeah we'll have to add an exception to our CI for that. Not the first thing really where intel hw cuts a few corners (*cough* alpha blending *cough*). But if igt is as a generally useful test suite, then stuff like this should be in there imo. -Daniel > > -Daniel > > > > > Nicholas Kazlauskas > > > > > > > > > > >> > > > >>> --- > > > >>> tests/Makefile.sources | 1 + > > > >>> tests/amdgpu/amd_color.c | 405 +++++++++++++++++++++++++++++++++++++++ > > > >>> tests/amdgpu/meson.build | 1 + > > > >>> 3 files changed, 407 insertions(+) > > > >>> create mode 100644 tests/amdgpu/amd_color.c > > > >>> > > > >>> diff --git a/tests/Makefile.sources b/tests/Makefile.sources > > > >>> index 2d5c929e..ef3c03f2 100644 > > > >>> --- a/tests/Makefile.sources > > > >>> +++ b/tests/Makefile.sources > > > >>> @@ -6,6 +6,7 @@ NOUVEAU_TESTS = \ > > > >>> > > > >>> AMDGPU_TESTS = \ > > > >>> amdgpu/amd_basic \ > > > >>> + amdgpu/amd_color \ > > > >>> amdgpu/amd_cs_nop \ > > > >>> amdgpu/amd_prime \ > > > >>> amdgpu/amd_abm \ > > > >>> diff --git a/tests/amdgpu/amd_color.c b/tests/amdgpu/amd_color.c > > > >>> new file mode 100644 > > > >>> index 00000000..0bbee43d > > > >>> --- /dev/null > > > >>> +++ b/tests/amdgpu/amd_color.c > > > >>> @@ -0,0 +1,405 @@ > > > >>> +/* > > > >>> + * Copyright 2019 Advanced Micro Devices, Inc. > > > >>> + * > > > >>> + * 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. > > > >>> + */ > > > >>> + > > > >>> +#include "igt.h" > > > >>> + > > > >>> +/* (De)gamma LUT. */ > > > >>> +typedef struct lut { > > > >>> + struct drm_color_lut *data; > > > >>> + uint32_t size; > > > >>> +} lut_t; > > > >>> + > > > >>> +/* RGB color. */ > > > >>> +typedef struct color { > > > >>> + double r; > > > >>> + double g; > > > >>> + double b; > > > >>> +} color_t; > > > >>> + > > > >>> +/* Common test data. */ > > > >>> +typedef struct data { > > > >>> + igt_display_t display; > > > >>> + igt_plane_t *primary; > > > >>> + igt_output_t *output; > > > >>> + igt_pipe_t *pipe; > > > >>> + igt_pipe_crc_t *pipe_crc; > > > >>> + drmModeModeInfo *mode; > > > >>> + enum pipe pipe_id; > > > >>> + int fd; > > > >>> + int w; > > > >>> + int h; > > > >>> + uint32_t regamma_lut_size; > > > >>> + uint32_t degamma_lut_size; > > > >>> +} data_t; > > > >>> + > > > >>> +static void lut_init(lut_t *lut, uint32_t size) > > > >>> +{ > > > >>> + igt_assert(size > 0); > > > >>> + > > > >>> + lut->size = size; > > > >>> + lut->data = malloc(size * sizeof(struct drm_color_lut)); > > > >>> + igt_assert(lut); > > > >>> +} > > > >>> + > > > >>> +/* Generates the linear gamma LUT. */ > > > >>> +static void lut_gen_linear(lut_t *lut, uint16_t mask) > > > >>> +{ > > > >>> + uint32_t n = lut->size - 1; > > > >>> + uint32_t i; > > > >>> + > > > >>> + for (i = 0; i < lut->size; ++i) { > > > >>> + uint32_t v = (i * 0xffff / n) & mask; > > > >>> + > > > >>> + lut->data[i].red = v; > > > >>> + lut->data[i].blue = v; > > > >>> + lut->data[i].green = v; > > > >>> + } > > > >>> +} > > > >>> + > > > >>> +/* Generates the sRGB degamma LUT. */ > > > >>> +static void lut_gen_degamma_srgb(lut_t *lut, uint16_t mask) > > > >>> +{ > > > >>> + double range = lut->size - 1; > > > >>> + uint32_t i; > > > >>> + > > > >>> + for (i = 0; i < lut->size; ++i) { > > > >>> + double u, coeff; > > > >>> + uint32_t v; > > > >>> + > > > >>> + u = i / range; > > > >>> + coeff = u <= 0.040449936 ? (u / 12.92) > > > >>> + : (pow((u + 0.055) / 1.055, 2.4)); > > > >>> + v = (uint32_t)(coeff * 0xffff) & mask; > > > >>> + > > > >>> + lut->data[i].red = v; > > > >>> + lut->data[i].blue = v; > > > >>> + lut->data[i].green = v; > > > >>> + } > > > >>> +} > > > >>> + > > > >>> +/* Generates the sRGB gamma LUT. */ > > > >>> +static void lut_gen_regamma_srgb(lut_t *lut, uint16_t mask) > > > >>> +{ > > > >>> + double range = lut->size - 1; > > > >>> + uint32_t i; > > > >>> + > > > >>> + for (i = 0; i < lut->size; ++i) { > > > >>> + double u, coeff; > > > >>> + uint32_t v; > > > >>> + > > > >>> + u = i / range; > > > >>> + coeff = u <= 0.00313080 ? (12.92 * u) > > > >>> + : (1.055 * pow(u, 1.0 / 2.4) - 0.055); > > > >>> + v = (uint32_t)(coeff * 0xffff) & mask; > > > >>> + > > > >>> + lut->data[i].red = v; > > > >>> + lut->data[i].blue = v; > > > >>> + lut->data[i].green = v; > > > >>> + } > > > >>> +} > > > >>> + > > > >>> +static void lut_free(lut_t *lut) > > > >>> +{ > > > >>> + if (lut->data) { > > > >>> + free(lut->data); > > > >>> + lut->data = NULL; > > > >>> + } > > > >>> + > > > >>> + lut->size = 0; > > > >>> +} > > > >>> + > > > >>> +/* Fills a FB with the solid color given. */ > > > >>> +static void draw_color(igt_fb_t *fb, double r, double g, double b) > > > >>> +{ > > > >>> + cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb); > > > >>> + > > > >>> + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); > > > >>> + igt_paint_color(cr, 0, 0, fb->width, fb->height, r, g, b); > > > >>> + igt_put_cairo_ctx(fb->fd, fb, cr); > > > >>> +} > > > >>> + > > > >>> +/* Generates the gamma test pattern. */ > > > >>> +static void draw_gamma_test(igt_fb_t *fb) > > > >>> +{ > > > >>> + cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb); > > > >>> + int gh = fb->height / 4; > > > >>> + > > > >>> + igt_paint_color_gradient(cr, 0, 0, fb->width, gh, 1, 1, 1); > > > >>> + igt_paint_color_gradient(cr, 0, gh, fb->width, gh, 1, 0, 0); > > > >>> + igt_paint_color_gradient(cr, 0, gh * 2, fb->width, gh, 0, 1, 0); > > > >>> + igt_paint_color_gradient(cr, 0, gh * 3, fb->width, gh, 0, 0, 1); > > > >>> + > > > >>> + igt_put_cairo_ctx(fb->fd, fb, cr); > > > >>> +} > > > >>> + > > > >>> +/* Sets the degamma LUT. */ > > > >>> +static void set_degamma_lut(data_t *data, lut_t const *lut) > > > >>> +{ > > > >>> + size_t size = lut ? sizeof(lut->data[0]) * lut->size : 0; > > > >>> + const void *ptr = lut ? lut->data : NULL; > > > >>> + > > > >>> + igt_pipe_obj_replace_prop_blob(data->pipe, IGT_CRTC_DEGAMMA_LUT, ptr, > > > >>> + size); > > > >>> +} > > > >>> + > > > >>> +/* Sets the regamma LUT. */ > > > >>> +static void set_regamma_lut(data_t *data, lut_t const *lut) > > > >>> +{ > > > >>> + size_t size = lut ? sizeof(lut->data[0]) * lut->size : 0; > > > >>> + const void *ptr = lut ? lut->data : NULL; > > > >>> + > > > >>> + igt_pipe_obj_replace_prop_blob(data->pipe, IGT_CRTC_GAMMA_LUT, ptr, > > > >>> + size); > > > >>> +} > > > >>> + > > > >>> +/* Common test setup. */ > > > >>> +static void test_init(data_t *data) > > > >>> +{ > > > >>> + igt_display_t *display = &data->display; > > > >>> + > > > >>> + /* It doesn't matter which pipe we choose on amdpgu. */ > > > >>> + data->pipe_id = PIPE_A; > > > >>> + data->pipe = &data->display.pipes[data->pipe_id]; > > > >>> + > > > >>> + igt_display_reset(display); > > > >>> + > > > >>> + data->output = igt_get_single_output_for_pipe(display, data->pipe_id); > > > >>> + igt_require(data->output); > > > >>> + > > > >>> + data->mode = igt_output_get_mode(data->output); > > > >>> + igt_assert(data->mode); > > > >>> + > > > >>> + data->primary = > > > >>> + igt_pipe_get_plane_type(data->pipe, DRM_PLANE_TYPE_PRIMARY); > > > >>> + > > > >>> + data->pipe_crc = igt_pipe_crc_new(data->fd, data->pipe_id, > > > >>> + INTEL_PIPE_CRC_SOURCE_AUTO); > > > >>> + > > > >>> + igt_output_set_pipe(data->output, data->pipe_id); > > > >>> + > > > >>> + data->degamma_lut_size = > > > >>> + igt_pipe_obj_get_prop(data->pipe, IGT_CRTC_DEGAMMA_LUT_SIZE); > > > >>> + igt_assert_lt(0, data->degamma_lut_size); > > > >>> + > > > >>> + data->regamma_lut_size = > > > >>> + igt_pipe_obj_get_prop(data->pipe, IGT_CRTC_GAMMA_LUT_SIZE); > > > >>> + igt_assert_lt(0, data->regamma_lut_size); > > > >>> + > > > >>> + data->w = data->mode->hdisplay; > > > >>> + data->h = data->mode->vdisplay; > > > >>> +} > > > >>> + > > > >>> +/* Common test cleanup. */ > > > >>> +static void test_fini(data_t *data) > > > >>> +{ > > > >>> + igt_pipe_crc_free(data->pipe_crc); > > > >>> + igt_display_reset(&data->display); > > > >>> +} > > > >>> + > > > >>> +/* > > > >>> + * Older versions of amdgpu would put the pipe into bypass mode for degamma > > > >>> + * when passed a linear sRGB matrix but would still use an sRGB regamma > > > >>> + * matrix if not passed any. The whole pipe should be in linear bypass mode > > > >>> + * when all the matrices are NULL - CRCs for a linear degamma matrix and > > > >>> + * a NULL one should match. > > > >>> + */ > > > >>> +static void test_crtc_linear_degamma(data_t *data) > > > >>> +{ > > > >>> + igt_display_t *display = &data->display; > > > >>> + igt_crc_t ref_crc, new_crc; > > > >>> + igt_fb_t afb; > > > >>> + lut_t lut_linear; > > > >>> + > > > >>> + test_init(data); > > > >>> + > > > >>> + lut_init(&lut_linear, data->degamma_lut_size); > > > >>> + lut_gen_linear(&lut_linear, 0xffff); > > > >>> + > > > >>> + igt_create_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888, 0, &afb); > > > >>> + draw_gamma_test(&afb); > > > >>> + > > > >>> + /* Draw the reference image. */ > > > >>> + igt_plane_set_fb(data->primary, &afb); > > > >>> + set_regamma_lut(data, NULL); > > > >>> + set_degamma_lut(data, NULL); > > > >>> + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); > > > >>> + > > > >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); > > > >>> + > > > >>> + /* Apply a linear degamma. The result should remain the same. */ > > > >>> + set_degamma_lut(data, &lut_linear); > > > >>> + igt_display_commit_atomic(display, 0, NULL); > > > >>> + > > > >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); > > > >>> + igt_assert_crc_equal(&ref_crc, &new_crc); > > > >>> + > > > >>> + test_fini(data); > > > >>> + igt_remove_fb(data->fd, &afb); > > > >>> + lut_free(&lut_linear); > > > >>> +} > > > >>> + > > > >>> +/* > > > >>> + * Older versions of amdgpu would apply the CRTC regamma on top of a custom > > > >>> + * sRGB regamma matrix with incorrect calculations or rounding errors. > > > >>> + * If we put the pipe into bypass or use the hardware defined sRGB regamma > > > >>> + * on the plane then we can and should get the correct CRTC when passing a > > > >>> + * liner regamma matrix to DRM. > > > >>> + */ > > > >>> +static void test_crtc_linear_regamma(data_t *data) > > > >>> +{ > > > >>> + igt_display_t *display = &data->display; > > > >>> + igt_crc_t ref_crc, new_crc; > > > >>> + igt_fb_t afb; > > > >>> + lut_t lut_linear; > > > >>> + > > > >>> + test_init(data); > > > >>> + > > > >>> + lut_init(&lut_linear, data->regamma_lut_size); > > > >>> + lut_gen_linear(&lut_linear, 0xffff); > > > >>> + > > > >>> + igt_create_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888, 0, &afb); > > > >>> + draw_gamma_test(&afb); > > > >>> + > > > >>> + /* Draw the reference image. */ > > > >>> + igt_plane_set_fb(data->primary, &afb); > > > >>> + set_regamma_lut(data, NULL); > > > >>> + set_degamma_lut(data, NULL); > > > >>> + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); > > > >>> + > > > >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); > > > >>> + > > > >>> + /* Apply a linear degamma. The result should remain the same. */ > > > >>> + set_regamma_lut(data, &lut_linear); > > > >>> + igt_display_commit_atomic(display, 0, NULL); > > > >>> + > > > >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); > > > >>> + igt_assert_crc_equal(&ref_crc, &new_crc); > > > >>> + > > > >>> + test_fini(data); > > > >>> + igt_remove_fb(data->fd, &afb); > > > >>> + lut_free(&lut_linear); > > > >>> +} > > > >>> + > > > >>> +/* > > > >>> + * Tests LUT accuracy. CRTC regamma and CRTC degamma should produce a visually > > > >>> + * correct image when used. Hardware limitations on degamma prevent this from > > > >>> + * being CRC level accurate across a full test gradient but most values should > > > >>> + * still match. > > > >>> + * > > > >>> + * This test can't pass on DCE because it doesn't support non-linear degamma. > > > >>> + */ > > > >>> +static void test_crtc_lut_accuracy(data_t *data) > > > >>> +{ > > > >>> + /* > > > >>> + * Channels are independent, so we can verify multiple colors at the > > > >>> + * same time for improved performance. > > > >>> + */ > > > >>> + static const color_t colors[] = { > > > >>> + { 1.00, 1.00, 1.00 }, > > > >>> + { 0.90, 0.85, 0.75 }, /* 0.95 fails */ > > > >>> + { 0.70, 0.65, 0.60 }, > > > >>> + { 0.55, 0.50, 0.45 }, > > > >>> + { 0.40, 0.35, 0.30 }, > > > >>> + { 0.25, 0.20, 0.15 }, > > > >>> + { 0.10, 0.04, 0.02 }, /* 0.05 fails */ > > > >>> + { 0.00, 0.00, 0.00 }, > > > >>> + }; > > > >>> + igt_display_t *display = &data->display; > > > >>> + igt_crc_t ref_crc, new_crc; > > > >>> + igt_fb_t afb; > > > >>> + lut_t lut_degamma, lut_regamma; > > > >>> + int i, w, h; > > > >>> + > > > >>> + test_init(data); > > > >>> + > > > >>> + lut_init(&lut_degamma, data->degamma_lut_size); > > > >>> + lut_gen_degamma_srgb(&lut_degamma, 0xffff); > > > >>> + > > > >>> + lut_init(&lut_regamma, data->regamma_lut_size); > > > >>> + lut_gen_regamma_srgb(&lut_regamma, 0xffff); > > > >>> + > > > >>> + /* Don't draw across the whole screen to improve perf. */ > > > >>> + w = 64; > > > >>> + h = 64; > > > >>> + > > > >>> + igt_create_fb(data->fd, w, h, DRM_FORMAT_XRGB8888, 0, &afb); > > > >>> + igt_plane_set_fb(data->primary, &afb); > > > >>> + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); > > > >>> + > > > >>> + /* Test colors. */ > > > >>> + for (i = 0; i < ARRAY_SIZE(colors); ++i) { > > > >>> + color_t col = colors[i]; > > > >>> + > > > >>> + igt_info("Testing color (%.2f, %.2f, %.2f) ...\n", col.r, col.g, > > > >>> + col.b); > > > >>> + > > > >>> + draw_color(&afb, col.r, col.g, col.b); > > > >>> + > > > >>> + set_regamma_lut(data, NULL); > > > >>> + set_degamma_lut(data, NULL); > > > >>> + igt_display_commit_atomic(display, 0, NULL); > > > >>> + > > > >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc); > > > >>> + > > > >>> + set_degamma_lut(data, &lut_degamma); > > > >>> + set_regamma_lut(data, &lut_regamma); > > > >>> + igt_display_commit_atomic(display, 0, NULL); > > > >>> + > > > >>> + igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc); > > > >>> + > > > >>> + igt_assert_crc_equal(&ref_crc, &new_crc); > > > >>> + } > > > >>> + > > > >>> + test_fini(data); > > > >>> + igt_remove_fb(data->fd, &afb); > > > >>> + lut_free(&lut_regamma); > > > >>> + lut_free(&lut_degamma); > > > >>> +} > > > >>> + > > > >>> +igt_main > > > >>> +{ > > > >>> + data_t data; > > > >>> + > > > >>> + igt_skip_on_simulation(); > > > >>> + > > > >>> + memset(&data, 0, sizeof(data)); > > > >>> + > > > >>> + igt_fixture > > > >>> + { > > > >>> + data.fd = drm_open_driver_master(DRIVER_AMDGPU); > > > >>> + > > > >>> + kmstest_set_vt_graphics_mode(); > > > >>> + > > > >>> + igt_display_require(&data.display, data.fd); > > > >>> + igt_require(data.display.is_atomic); > > > >>> + igt_display_require_output(&data.display); > > > >>> + } > > > >>> + > > > >>> + igt_subtest("crtc-linear-degamma") test_crtc_linear_degamma(&data); > > > >>> + igt_subtest("crtc-linear-regamma") test_crtc_linear_regamma(&data); > > > >>> + igt_subtest("crtc-lut-accuracy") test_crtc_lut_accuracy(&data); > > > >>> + > > > >>> + igt_fixture > > > >>> + { > > > >>> + igt_display_fini(&data.display); > > > >>> + } > > > >>> +} > > > >>> diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build > > > >>> index 1afece86..42086374 100644 > > > >>> --- a/tests/amdgpu/meson.build > > > >>> +++ b/tests/amdgpu/meson.build > > > >>> @@ -4,6 +4,7 @@ amdgpu_deps = test_deps > > > >>> if libdrm_amdgpu.found() > > > >>> amdgpu_progs += [ 'amd_abm', > > > >>> 'amd_basic', > > > >>> + 'amd_color', > > > >>> 'amd_cs_nop', > > > >>> 'amd_prime', > > > >>> ] > > > >>> > > > >> _______________________________________________ > > > >> igt-dev mailing list > > > >> igt-dev@lists.freedesktop.org > > > >> https://lists.freedesktop.org/mailman/listinfo/igt-dev > > > > > > > > > > > > > > > > > > > > > -- > > Daniel Vetter > > Software Engineer, Intel Corporation > > +41 (0) 79 365 57 48 - http://blog.ffwll.ch > > _______________________________________________ > > igt-dev mailing list > > igt-dev@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/igt-dev > > -- > Ville Syrjälä > Intel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-07-11 18:58 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-05-27 17:19 [igt-dev] [PATCH i-g-t] tests/amdgpu: Add color tests for amdgpu Nicholas Kazlauskas 2019-05-27 18:08 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork 2019-05-28 5:45 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork 2019-05-29 18:43 ` [igt-dev] [PATCH i-g-t] " Li, Sun peng (Leo) 2019-07-11 17:15 ` Daniel Vetter 2019-07-11 17:19 ` Kazlauskas, Nicholas 2019-07-11 17:30 ` Daniel Vetter 2019-07-11 17:34 ` Kazlauskas, Nicholas 2019-07-11 17:46 ` Ville Syrjälä 2019-07-11 18:58 ` Daniel Vetter
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.