From patchwork Fri Nov 25 09:35:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Varad Gautam X-Patchwork-Id: 84086 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp46894qgi; Fri, 25 Nov 2016 01:36:22 -0800 (PST) X-Received: by 10.99.230.17 with SMTP id g17mr12593512pgh.82.1480066582369; Fri, 25 Nov 2016 01:36:22 -0800 (PST) Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id l21si43813479pfi.276.2016.11.25.01.36.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Nov 2016 01:36:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of piglit-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: best guess record for domain of piglit-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=piglit-bounces@lists.freedesktop.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DB31E6EB99; Fri, 25 Nov 2016 09:35:51 +0000 (UTC) X-Original-To: piglit@lists.freedesktop.org Delivered-To: piglit@lists.freedesktop.org Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id E1C916EBA6 for ; Fri, 25 Nov 2016 09:35:50 +0000 (UTC) Received: by mail-pg0-x242.google.com with SMTP id x23so5161343pgx.3 for ; Fri, 25 Nov 2016 01:35:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KNSlEpnf6iYoh5JA5XempEtnd7YXyqOShC5pU9vSw1U=; b=D3VZadoQQ6F19CX/Shc9ni+FYu2ntPXriQWPlawmanjegX2MVxIPhPC0ozCE633hpg hk9ufciPn5/2smsKYtxRjxIf2uvFa+s8L4LA8PVS+lHis1SOu41srdf3pXA5+gnZQqw+ hHMJnECm4pgZvPGlG0uiGz3Zxvv1NykIpH9BPGQCFujsuHqWEJlu061gV6QQfuQGGYCs F6jz4QSYtAqDQgO+6gqwFjXqfR04kvNWNP36lxTxlChG2Avvbz6WGIfTJzi97UMqhSeU qbDwma51kcLT7AmfCVaGczL/xgmy3tuqHA+sKUBGqvU9mVwi+uX21psYMeJBDoLODz/s OU7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KNSlEpnf6iYoh5JA5XempEtnd7YXyqOShC5pU9vSw1U=; b=cLGn9RwlZv9zQPxQ9Xr0n2dAkWCcOjk7EIdK1pAySJ8tcvQZT46wSjYfzv0Wrdoou0 E+zTmEBroXaSk7ura1C3Sd82raDCg5teFJIQRWOf1Cw3OSE+PVdYitfBDo4iRfTmCaKE gsW3qSihbKCJv1v+h7tA4Cewn1aPKjH2ZPnljyGhZ86ZPess1C1o1OtYMAyNfdUpMSLU 3g09fTUbn7owfIS6KirVFGHmL1hZ1rflyMEb3x/6tul08jxLXPkY4KVlkDXDkWm3c6Eq 0JX0zouQS9yQOgty3qTc9bu4aAHY0RO+9SMPeftJQ94lO3+i/qCLD53Rhpe2GEKHhvYh QjPg== X-Gm-Message-State: AKaTC01flt4wJ6x+PPSUilqf6KaZan5n9Dz2SXmJ4D/d7D4y0Qj2F9SvNpUPQxCG4Kca4Q== X-Received: by 10.84.210.46 with SMTP id z43mr15187126plh.115.1480066550435; Fri, 25 Nov 2016 01:35:50 -0800 (PST) Received: from linux-e1tz.suse ([122.168.223.25]) by smtp.googlemail.com with ESMTPSA id y73sm66241752pfa.68.2016.11.25.01.35.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 Nov 2016 01:35:50 -0800 (PST) From: Varad Gautam To: piglit@lists.freedesktop.org Date: Fri, 25 Nov 2016 15:05:19 +0530 Message-Id: <1480066519-20283-7-git-send-email-varadgautam@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1480066519-20283-1-git-send-email-varadgautam@gmail.com> References: <1480066519-20283-1-git-send-email-varadgautam@gmail.com> MIME-Version: 1.0 Cc: Varad Gautam Subject: [Piglit] [PATCH 6/6] ext_image_dma_buf_import: test sampling correctness with format modifiers X-BeenThere: piglit@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: piglit-bounces@lists.freedesktop.org Sender: "Piglit" From: Varad Gautam add a test that imports and samples DRM_FORMAT_NV12 and DRM_FORMAT_NV12 + DRM_FORMAT_MOD_SAMSUNG_64_32_TILE patterns using EGL_EXT_image_dma_buf_import_modifiers and compares them for equality. Signed-off-by: Varad Gautam --- tests/all.py | 2 + .../ext_image_dma_buf_import/CMakeLists.gles2.txt | 1 + .../sample_yuv_modifiers.c | 197 +++++++++++++++++++++ 3 files changed, 200 insertions(+) create mode 100644 tests/spec/ext_image_dma_buf_import/sample_yuv_modifiers.c diff --git a/tests/all.py b/tests/all.py index da84d34..4999c7a 100644 --- a/tests/all.py +++ b/tests/all.py @@ -3131,6 +3131,8 @@ with profile.test_list.group_manager( 'ext_image_dma_buf_import-sample_yuv420', run_concurrent=False) g(['ext_image_dma_buf_import-sample_yuv', '-fmt=YV12', '-alpha-one'], 'ext_image_dma_buf_import-sample_yvu420', run_concurrent=False) + g(['ext_image_dma_buf_import-sample_yuv_modifiers', '-fmt=NV12MT'], + 'ext_image_dma_buf_import-sample_nv12mt', run_concurrent=False) g(['ext_image_dma_buf_import-transcode-nv12-as-r8-gr88'], 'ext_image_dma_buf_import-transcode-nv12-as-r8-gr88', run_concurrent=False) diff --git a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt index a3729fb..8c03c77 100644 --- a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt +++ b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt @@ -18,6 +18,7 @@ if(PIGLIT_BUILD_DMA_BUF_TESTS) piglit_add_executable(ext_image_dma_buf_import-refcount refcount.c sample_common.c image_common.c) piglit_add_executable(ext_image_dma_buf_import-sample_yuv sample_yuv.c sample_common.c image_common.c) + piglit_add_executable(ext_image_dma_buf_import-sample_yuv_modifiers sample_yuv_modifiers.c sample_common.c image_common.c) piglit_add_executable(ext_image_dma_buf_import-sample_rgb sample_rgb.c sample_common.c image_common.c) piglit_add_executable(ext_image_dma_buf_import-intel_external_sampler_with_dma_only intel_external_sampler_with_dma_only.c image_common.c) piglit_add_executable(ext_image_dma_buf_import-transcode-nv12-as-r8-gr88 transcode-nv12-as-r8-gr88.c image_common.c) diff --git a/tests/spec/ext_image_dma_buf_import/sample_yuv_modifiers.c b/tests/spec/ext_image_dma_buf_import/sample_yuv_modifiers.c new file mode 100644 index 0000000..8fce59a --- /dev/null +++ b/tests/spec/ext_image_dma_buf_import/sample_yuv_modifiers.c @@ -0,0 +1,197 @@ +/* + * Copyright © 2016 Collabora, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "sample_common.h" +#include "image_common.h" +#include "nv12_frame_data.h" + +/* @file sample_yuv_modifiers.c + * + * Create EGL images from multi-planar dma bufs with and without using format + * modifiers and sample them as external textures. + */ + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_es_version = 20; + +PIGLIT_GL_TEST_CONFIG_END + +#define MAX_MODIFIERS 4 + +static int fourcc = -1; +static uint64_t modifiers[MAX_MODIFIERS]; + +enum piglit_result +piglit_display(void) +{ + extern const unsigned nv12[]; + extern const unsigned nv12_64z32[]; + EGLint *formats; + EGLuint64KHR supported_modifiers[MAX_MODIFIERS] = {0}; + EGLint num_formats, num_modifiers; + unsigned char *expected; + const unsigned char *data; + const unsigned width = 128, height = 128; + EGLDisplay egl_dpy = eglGetCurrentDisplay(); + int nr_planes; + enum piglit_result res; + bool pass = true; + unsigned i = 0, j = 0; + + /* query format and modifier support before proceeding */ + pass &= eglQueryDmaBufFormatsEXT(egl_dpy, 0, NULL, &num_formats); + if(!pass) + goto cleanup; + + formats = calloc(1, num_formats * sizeof(EGLint)); + pass &= eglQueryDmaBufFormatsEXT(egl_dpy, num_formats, formats, + &num_formats); + if(!pass) + goto cleanup; + + /* skip if the intended format is not supported on this platform */ + for (i = 0; i < num_formats; i++) { + if (fourcc == formats[i]) + break; + } + free(formats); + if (i == num_formats) + return PIGLIT_SKIP; + + switch (fourcc) { + case DRM_FORMAT_NV12: + data = (unsigned char *) nv12; + nr_planes = 2; + break; + /* add more formats that support modifiers */ + default: + return PIGLIT_SKIP; + } + + pass &= eglQueryDmaBufModifiersEXT(egl_dpy, fourcc, 4, + supported_modifiers, NULL, + &num_modifiers); + if(!pass) + goto cleanup; + + /* skip if the required modifiers are not supported on this platform */ + for (i = 0; i < nr_planes; i++) { + for (j = 0; j < num_modifiers; j++) { + if (modifiers[i] == supported_modifiers[j]) + break; + } + if (j == num_modifiers) + return PIGLIT_SKIP; + } + + /* sample without modifiers to get reference image */ + res = dma_buf_create_and_sample_32bpp(width, height, + fourcc, NULL, 0, data); + if (res != PIGLIT_PASS) + return res; + + expected = calloc(1, width * height * 4 * sizeof(GLubyte)); + + glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, expected); + + switch (fourcc) { + case DRM_FORMAT_NV12: + if (modifiers[0] == DRM_FORMAT_MOD_SAMSUNG_64_32_TILE && + modifiers[1] == DRM_FORMAT_MOD_SAMSUNG_64_32_TILE) + data = (unsigned char *) nv12_64z32; + break; + default: + return PIGLIT_SKIP; + } + + /* sample with modifiers to get test image */ + res = dma_buf_create_and_sample_32bpp(width, height, fourcc, + modifiers, 2, data); + if (res != PIGLIT_PASS) { + pass &= false; + goto cleanup; + } + + /* Lower tolerance in case we're running against a 565 render + * target (gbm). + */ + piglit_set_tolerance_for_bits(5, 6, 5, 8); + + if (!piglit_probe_image_ubyte(0, 0, width, height, GL_RGBA, expected)) + pass &= false; + +cleanup: + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +static void print_usage_and_exit(const char* progname) +{ + printf("Usage: %s -fmt=[NV12MT]\n", progname); + piglit_report_result(PIGLIT_FAIL); +} + +static int parse_modifiers(const char *s) +{ + if (!strcmp(s, "MT")){ + /* NV12MT is DRM_FORMAT_NV12 format with + * DRM_FORMAT_MOD_SAMSUNG_64_32_TILE modifier */ + modifiers[0] = DRM_FORMAT_MOD_SAMSUNG_64_32_TILE; + modifiers[1] = DRM_FORMAT_MOD_SAMSUNG_64_32_TILE; + return 1; + } + + return 0; +} + +static int +parse_format(const char *s) +{ + if (strlen(s) < 4) + return -1; + + return (int)fourcc_code(s[0], s[1], s[2], s[3]); +} + +void +piglit_init(int argc, char **argv) +{ + unsigned i; + EGLDisplay egl_dpy = eglGetCurrentDisplay(); + + piglit_require_egl_extension(egl_dpy, "EGL_EXT_image_dma_buf_import_modifiers"); + piglit_require_extension("GL_OES_EGL_image_external"); + + for (i = 1; i < argc; i++) { + static const char fmt[] = "-fmt="; + if (!strncmp(argv[i], fmt, sizeof(fmt) - 1)) { + fourcc = parse_format(argv[i] + sizeof(fmt) - 1); + if (!parse_modifiers(argv[i] + sizeof(fmt) + 3)) + print_usage_and_exit(argv[0]); + } + else + print_usage_and_exit(argv[0]); + } + if (fourcc == -1) + print_usage_and_exit(argv[0]); +} \ No newline at end of file