From patchwork Tue Nov 5 02:23:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Keith Packard X-Patchwork-Id: 3138751 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 813109F432 for ; Tue, 5 Nov 2013 02:24:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 74D9F205E5 for ; Tue, 5 Nov 2013 02:24:03 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 50BED2060A for ; Tue, 5 Nov 2013 02:24:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C6A35EF52F; Mon, 4 Nov 2013 18:23:56 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from keithp.com (home.keithp.com [63.227.221.253]) by gabe.freedesktop.org (Postfix) with ESMTP id C55E1EF532 for ; Mon, 4 Nov 2013 18:23:42 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by keithp.com (Postfix) with ESMTP id 7EEB81488003; Mon, 4 Nov 2013 18:23:42 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at keithp.com Received: from keithp.com ([127.0.0.1]) by localhost (keithp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 8j-C07zqHOa8; Mon, 4 Nov 2013 18:23:38 -0800 (PST) Received: by keithp.com (Postfix, from userid 1033) id B95CB1488007; Mon, 4 Nov 2013 18:23:31 -0800 (PST) Received: from miki.keithp.com (localhost [127.0.0.1]) by keithp.com (Postfix) with ESMTP id F24DB148C005; Mon, 4 Nov 2013 18:23:30 -0800 (PST) Received: by miki.keithp.com (Postfix, from userid 1001) id B2F7D2355; Mon, 4 Nov 2013 18:23:29 -0800 (PST) From: Keith Packard To: mesa3d-dev@lists.freedesktop.org Subject: [PATCH 3/8] dri/intel: Add explicit size parameter to intel_region_alloc_for_fd Date: Mon, 4 Nov 2013 18:23:23 -0800 Message-Id: <1383618208-21310-4-git-send-email-keithp@keithp.com> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1383618208-21310-1-git-send-email-keithp@keithp.com> References: <1383618208-21310-1-git-send-email-keithp@keithp.com> Cc: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of assuming that the size will be height * pitch, have the caller pass in the size explicitly. Signed-off-by: Keith Packard Reviewed-by: Kristian Høgsberg --- src/mesa/drivers/dri/i915/intel_regions.c | 4 ++-- src/mesa/drivers/dri/i915/intel_regions.h | 2 +- src/mesa/drivers/dri/i915/intel_screen.c | 2 +- src/mesa/drivers/dri/i965/intel_regions.c | 4 ++-- src/mesa/drivers/dri/i965/intel_regions.h | 1 + src/mesa/drivers/dri/i965/intel_screen.c | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/mesa/drivers/dri/i915/intel_regions.c b/src/mesa/drivers/dri/i915/intel_regions.c index 44f7030..9f5b89e 100644 --- a/src/mesa/drivers/dri/i915/intel_regions.c +++ b/src/mesa/drivers/dri/i915/intel_regions.c @@ -209,6 +209,7 @@ struct intel_region * intel_region_alloc_for_fd(struct intel_screen *screen, GLuint cpp, GLuint width, GLuint height, GLuint pitch, + GLuint size, int fd, const char *name) { struct intel_region *region; @@ -216,8 +217,7 @@ intel_region_alloc_for_fd(struct intel_screen *screen, int ret; uint32_t bit_6_swizzle, tiling; - buffer = drm_intel_bo_gem_create_from_prime(screen->bufmgr, - fd, height * pitch); + buffer = drm_intel_bo_gem_create_from_prime(screen->bufmgr, fd, size); if (buffer == NULL) return NULL; ret = drm_intel_bo_get_tiling(buffer, &tiling, &bit_6_swizzle); diff --git a/src/mesa/drivers/dri/i915/intel_regions.h b/src/mesa/drivers/dri/i915/intel_regions.h index 5c612a9..6bc4a42 100644 --- a/src/mesa/drivers/dri/i915/intel_regions.h +++ b/src/mesa/drivers/dri/i915/intel_regions.h @@ -91,7 +91,7 @@ struct intel_region * intel_region_alloc_for_fd(struct intel_screen *screen, GLuint cpp, GLuint width, GLuint height, GLuint pitch, - int fd, const char *name); + GLuint size, int fd, const char *name); bool intel_region_flink(struct intel_region *region, uint32_t *name); diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c index 3f54752..085e894 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.c +++ b/src/mesa/drivers/dri/i915/intel_screen.c @@ -653,7 +653,7 @@ intel_create_image_from_fds(__DRIscreen *screen, return NULL; image->region = intel_region_alloc_for_fd(intelScreen, - 1, width, height, + 1, width, height, height * strides[0], strides[0], fds[0], "image"); if (image->region == NULL) { free(image); diff --git a/src/mesa/drivers/dri/i965/intel_regions.c b/src/mesa/drivers/dri/i965/intel_regions.c index a6b80fd..3920f4f 100644 --- a/src/mesa/drivers/dri/i965/intel_regions.c +++ b/src/mesa/drivers/dri/i965/intel_regions.c @@ -209,6 +209,7 @@ struct intel_region * intel_region_alloc_for_fd(struct intel_screen *screen, GLuint cpp, GLuint width, GLuint height, GLuint pitch, + GLuint size, int fd, const char *name) { struct intel_region *region; @@ -216,8 +217,7 @@ intel_region_alloc_for_fd(struct intel_screen *screen, int ret; uint32_t bit_6_swizzle, tiling; - buffer = drm_intel_bo_gem_create_from_prime(screen->bufmgr, - fd, height * pitch); + buffer = drm_intel_bo_gem_create_from_prime(screen->bufmgr, fd, size); if (buffer == NULL) return NULL; ret = drm_intel_bo_get_tiling(buffer, &tiling, &bit_6_swizzle); diff --git a/src/mesa/drivers/dri/i965/intel_regions.h b/src/mesa/drivers/dri/i965/intel_regions.h index f08a113..05dfef3 100644 --- a/src/mesa/drivers/dri/i965/intel_regions.h +++ b/src/mesa/drivers/dri/i965/intel_regions.h @@ -92,6 +92,7 @@ struct intel_region * intel_region_alloc_for_fd(struct intel_screen *screen, GLuint cpp, GLuint width, GLuint height, GLuint pitch, + GLuint size, int fd, const char *name); bool diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index ce8124b..b89b1a5 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -718,7 +718,7 @@ intel_create_image_from_fds(__DRIscreen *screen, return NULL; image->region = intel_region_alloc_for_fd(intelScreen, - 1, width, height, + 1, width, height, height * strides[0], strides[0], fds[0], "image"); if (image->region == NULL) { free(image);