From patchwork Fri Nov 25 09:35:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Varad Gautam X-Patchwork-Id: 84082 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp46704qgi; Fri, 25 Nov 2016 01:35:42 -0800 (PST) X-Received: by 10.84.206.37 with SMTP id f34mr15326248ple.35.1480066542029; Fri, 25 Nov 2016 01:35:42 -0800 (PST) Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id a8si15241905ple.281.2016.11.25.01.35.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Nov 2016 01:35:42 -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 9A7CC6EAF4; Fri, 25 Nov 2016 09:35:41 +0000 (UTC) X-Original-To: piglit@lists.freedesktop.org Delivered-To: piglit@lists.freedesktop.org Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 796516EAF4 for ; Fri, 25 Nov 2016 09:35:39 +0000 (UTC) Received: by mail-pf0-x243.google.com with SMTP id c4so2821910pfb.3 for ; Fri, 25 Nov 2016 01:35:39 -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; bh=laVZTbSiMvqi87LhvVx34gNpARnnnXvxmvbQ4mNFjpc=; b=mBbyiZ6weTIJZUZ6ScFG1GzvtvYldASBHj7c0iTR5P/a0GimEKRrCl04OpkgNQOxGX +w1w+vo+rdpPGyTvQZVLf1YT0pFv0CA2RTFKp2rt5/K6B+2xkx7AGqJgf95tu5ub4xz5 dQU1LMZj2RCMjGlf0lDvFomAzkfC82QuUC47tarupYLS0UME4ImnemMD3qvPum/vGitN f0Kz4WjE7W327lEkJ2uN9ENDJXNg3GvWaQahSk6UEjC9W7VCbhoswLg/8Mu0q5Gf1hPT jcfDbvQwLb4pNXDKyqSwaWc95IH+h5NH6h4xXrOE5ySZNee3N/s6cla3WGRBlzrrtMBr ISGA== 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; bh=laVZTbSiMvqi87LhvVx34gNpARnnnXvxmvbQ4mNFjpc=; b=C/wPcXQtmdYcrCj6SnyspFCJYZBGBHBXkTBvlYA2t7yGe6advioLlQvttFacU/OCmW eR4IkmtWYhgZdykl2YbtKeEWNhux8o0vZgA3xCm6V2mXS2jwbb84CAvnPwBRi0wfyMJD vX8+fMiXX2bFTkeVD+dNjU4RxxNsGr/Cvip73rL2JhD7uCFBHWME6pHgvzSXEZS6xtci 8+vLH8AQTMmfLdcqnayy7orQp0kElZ6KN1w7HIibLwvsO6p0/iISfAuL6HZrpAolQiCK eD9rmlcSuUzsNxilrCbOSpqVw6ZW/lNu9r98nryY3e7OZ3+cL32kLSUowpyPNFSyjnWW BX5Q== X-Gm-Message-State: AKaTC02vQ3lAujhGtlivHSNpEZvWyYX957Gpem8IgLTm4DT3KVmq5RL/oQUnY3ySOH/WoQ== X-Received: by 10.84.215.194 with SMTP id g2mr15552932plj.16.1480066538297; Fri, 25 Nov 2016 01:35:38 -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.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 Nov 2016 01:35:37 -0800 (PST) From: Varad Gautam To: piglit@lists.freedesktop.org Date: Fri, 25 Nov 2016 15:05:15 +0530 Message-Id: <1480066519-20283-3-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> Cc: Varad Gautam Subject: [Piglit] [PATCH 2/6] sample_common: allow importing dmabufs 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: , MIME-Version: 1.0 Errors-To: piglit-bounces@lists.freedesktop.org Sender: "Piglit" From: Varad Gautam EGL_EXT_image_dma_buf_import_modifiers allows creating EGLImages from dmabufs with drm_fourcc.h format modifiers. support this in piglit. Signed-off-by: Varad Gautam --- tests/spec/ext_image_dma_buf_import/refcount.c | 6 ++- .../spec/ext_image_dma_buf_import/sample_common.c | 59 +++++++++++++++------- .../spec/ext_image_dma_buf_import/sample_common.h | 8 ++- tests/spec/ext_image_dma_buf_import/sample_rgb.c | 2 +- tests/spec/ext_image_dma_buf_import/sample_yuv.c | 2 +- 5 files changed, 54 insertions(+), 23 deletions(-) diff --git a/tests/spec/ext_image_dma_buf_import/refcount.c b/tests/spec/ext_image_dma_buf_import/refcount.c index 7ea200e..f125928 100644 --- a/tests/spec/ext_image_dma_buf_import/refcount.c +++ b/tests/spec/ext_image_dma_buf_import/refcount.c @@ -70,11 +70,13 @@ piglit_display(void) if (res != PIGLIT_PASS) return res; - res = egl_image_for_dma_buf_fd(buf, dup(buf->fd), fourcc, &img1); + res = egl_image_for_dma_buf_fd(buf, dup(buf->fd), fourcc, + NULL, 0, &img1); if (res != PIGLIT_PASS) return res; - res = egl_image_for_dma_buf_fd(buf, dup(buf->fd), fourcc, &img2); + res = egl_image_for_dma_buf_fd(buf, dup(buf->fd), fourcc, + NULL, 0, &img2); if (res != PIGLIT_PASS) return res; diff --git a/tests/spec/ext_image_dma_buf_import/sample_common.c b/tests/spec/ext_image_dma_buf_import/sample_common.c index 2f586c7..bff4f6e 100644 --- a/tests/spec/ext_image_dma_buf_import/sample_common.c +++ b/tests/spec/ext_image_dma_buf_import/sample_common.c @@ -107,10 +107,13 @@ sample_tex(GLuint tex, unsigned x, unsigned y, unsigned w, unsigned h) } enum piglit_result -egl_image_for_dma_buf_fd(struct piglit_dma_buf *buf, int fd, int fourcc, EGLImageKHR *out_img) +egl_image_for_dma_buf_fd(struct piglit_dma_buf *buf, int fd, int fourcc, + uint64_t *modifiers, int num_modifiers, + EGLImageKHR *out_img) { EGLint error; EGLImageKHR img; + int i = 0; EGLint attr_packed[] = { EGL_WIDTH, buf->w, EGL_HEIGHT, buf->h, @@ -121,18 +124,36 @@ egl_image_for_dma_buf_fd(struct piglit_dma_buf *buf, int fd, int fourcc, EGLImag EGL_NONE }; - EGLint attr_nv12[] = { - EGL_WIDTH, buf->w, - EGL_HEIGHT, buf->h, - EGL_LINUX_DRM_FOURCC_EXT, fourcc, - EGL_DMA_BUF_PLANE0_FD_EXT, fd, - EGL_DMA_BUF_PLANE0_OFFSET_EXT, buf->offset[0], - EGL_DMA_BUF_PLANE0_PITCH_EXT, buf->stride[0], - EGL_DMA_BUF_PLANE1_FD_EXT, fd, - EGL_DMA_BUF_PLANE1_OFFSET_EXT, buf->offset[1], - EGL_DMA_BUF_PLANE1_PITCH_EXT, buf->stride[1], - EGL_NONE - }; + EGLint attr_nv12[30]; + attr_nv12[i++] = EGL_WIDTH; + attr_nv12[i++] = buf->w; + attr_nv12[i++] = EGL_HEIGHT; + attr_nv12[i++] = buf->h; + attr_nv12[i++] = EGL_LINUX_DRM_FOURCC_EXT; + attr_nv12[i++] = fourcc; + attr_nv12[i++] = EGL_DMA_BUF_PLANE0_FD_EXT; + attr_nv12[i++] = fd; + attr_nv12[i++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT; + attr_nv12[i++] = buf->offset[0]; + attr_nv12[i++] = EGL_DMA_BUF_PLANE0_PITCH_EXT; + attr_nv12[i++] = buf->stride[0]; + attr_nv12[i++] = EGL_DMA_BUF_PLANE1_FD_EXT; + attr_nv12[i++] = fd; + attr_nv12[i++] = EGL_DMA_BUF_PLANE1_OFFSET_EXT; + attr_nv12[i++] = buf->offset[1]; + attr_nv12[i++] = EGL_DMA_BUF_PLANE1_PITCH_EXT; + attr_nv12[i++] = buf->stride[1]; + if (modifiers && num_modifiers == 2) { + attr_nv12[i++] = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT; + attr_nv12[i++] = (EGLint) modifiers[0]; + attr_nv12[i++] = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT; + attr_nv12[i++] = modifiers[0] >> 32; + attr_nv12[i++] = EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT; + attr_nv12[i++] = (EGLint) modifiers[1]; + attr_nv12[i++] = EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT; + attr_nv12[i++] = modifiers[1] >> 32; + } + attr_nv12[i] = EGL_NONE; EGLint attr_yuv420[] = { EGL_WIDTH, buf->w, @@ -192,7 +213,8 @@ egl_image_for_dma_buf_fd(struct piglit_dma_buf *buf, int fd, int fourcc, EGLImag } static enum piglit_result -sample_buffer(struct piglit_dma_buf *buf, int fourcc) +sample_buffer(struct piglit_dma_buf *buf, int fourcc, + uint64_t *modifiers, int num_modifiers) { enum piglit_result res; EGLImageKHR img; @@ -200,7 +222,8 @@ sample_buffer(struct piglit_dma_buf *buf, int fourcc) int w = buf->w; int h = buf->h; - res = egl_image_for_dma_buf_fd(buf, buf->fd, fourcc, &img); + res = egl_image_for_dma_buf_fd(buf, buf->fd, fourcc, modifiers, + num_modifiers, &img); /* Release the creator side of the buffer. */ piglit_destroy_dma_buf(buf); @@ -228,7 +251,9 @@ destroy: enum piglit_result dma_buf_create_and_sample_32bpp(unsigned w, unsigned h, - int fourcc, const unsigned char *src) + int fourcc, uint64_t *modifiers, + int num_modifiers, + const unsigned char *src) { struct piglit_dma_buf *buf; enum piglit_result res; @@ -237,5 +262,5 @@ dma_buf_create_and_sample_32bpp(unsigned w, unsigned h, if (res != PIGLIT_PASS) return res; - return sample_buffer(buf, fourcc); + return sample_buffer(buf, fourcc, modifiers, num_modifiers); } diff --git a/tests/spec/ext_image_dma_buf_import/sample_common.h b/tests/spec/ext_image_dma_buf_import/sample_common.h index 36a5bb5..15e0fff 100644 --- a/tests/spec/ext_image_dma_buf_import/sample_common.h +++ b/tests/spec/ext_image_dma_buf_import/sample_common.h @@ -33,10 +33,14 @@ */ enum piglit_result dma_buf_create_and_sample_32bpp(unsigned w, unsigned h, - int fourcc, const unsigned char *src); + int fourcc, uint64_t *modifiers, + int num_modifiers, + const unsigned char *src); enum piglit_result -egl_image_for_dma_buf_fd(struct piglit_dma_buf *buf, int fd, int fourcc, EGLImageKHR *out_img); +egl_image_for_dma_buf_fd(struct piglit_dma_buf *buf, int fd, int fourcc, + uint64_t *modifiers, int num_modifiers, + EGLImageKHR *out_img); enum piglit_result texture_for_egl_image(EGLImageKHR img, GLuint *out_tex); diff --git a/tests/spec/ext_image_dma_buf_import/sample_rgb.c b/tests/spec/ext_image_dma_buf_import/sample_rgb.c index b659717..10f4ed1 100644 --- a/tests/spec/ext_image_dma_buf_import/sample_rgb.c +++ b/tests/spec/ext_image_dma_buf_import/sample_rgb.c @@ -59,7 +59,7 @@ piglit_display(void) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - res = dma_buf_create_and_sample_32bpp(2, 2, fourcc, src); + res = dma_buf_create_and_sample_32bpp(2, 2, fourcc, NULL, 0, src); if (res != PIGLIT_PASS) return res; diff --git a/tests/spec/ext_image_dma_buf_import/sample_yuv.c b/tests/spec/ext_image_dma_buf_import/sample_yuv.c index a314bc5..856cf04 100644 --- a/tests/spec/ext_image_dma_buf_import/sample_yuv.c +++ b/tests/spec/ext_image_dma_buf_import/sample_yuv.c @@ -120,7 +120,7 @@ piglit_display(void) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - res = dma_buf_create_and_sample_32bpp(4, 4, fourcc, t); + res = dma_buf_create_and_sample_32bpp(4, 4, fourcc, NULL, 0, t); if (res != PIGLIT_PASS) return res;