From patchwork Fri Jan 17 17:15:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 11339575 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E97413BD for ; Fri, 17 Jan 2020 17:16:14 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 16D182072B for ; Fri, 17 Jan 2020 17:16:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 16D182072B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=chris-wilson.co.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C98446F641; Fri, 17 Jan 2020 17:16:12 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 64D9A6F64D; Fri, 17 Jan 2020 17:16:06 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 19919961-1500050 for multiple; Fri, 17 Jan 2020 17:15:48 +0000 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Fri, 17 Jan 2020 17:15:42 +0000 Message-Id: <20200117171545.3212625-2-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200117171545.3212625-1-chris@chris-wilson.co.uk> References: <20200117171545.3212625-1-chris@chris-wilson.co.uk> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 2/5] lib/intel_batchbuffer: Add CCS width/height functions for Intel igt_buf X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Zbigniew Kempczyński igt_buf has some fields which can be interpreted differently across vendors (ccs structure). Patch adds functions which are aware of meaning of this field. Signed-off-by: Zbigniew Kempczyński Cc: Chris Wilson Cc: Katarzyna Dec --- lib/intel_batchbuffer.c | 47 +++++++++++++++++++++++++++++++++++++++++ lib/intel_batchbuffer.h | 2 ++ 2 files changed, 49 insertions(+) diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c index 3dc890242..ab907913b 100644 --- a/lib/intel_batchbuffer.c +++ b/lib/intel_batchbuffer.c @@ -43,6 +43,7 @@ #include "ioctl_wrappers.h" #include "media_spin.h" #include "gpgpu_fill.h" +#include "igt_aux.h" #include @@ -529,6 +530,52 @@ unsigned igt_buf_height(const struct igt_buf *buf) return buf->surface[0].size/buf->surface[0].stride; } +/** + * igt_buf_intel_ccs_width: + * @buf: the Intel i-g-t buffer object + * @gen: device generation + * + * Computes the width of ccs buffer when considered as Intel surface data. + * + * Returns: + * The width of the ccs buffer data. + */ +unsigned int igt_buf_intel_ccs_width(int gen, const struct igt_buf *buf) +{ + /* + * GEN12+: The CCS unit size is 64 bytes mapping 4 main surface + * tiles. Thus the width of the CCS unit is 4*32=128 pixels on the + * main surface. + */ + if (gen >= 12) + return DIV_ROUND_UP(igt_buf_width(buf), 128) * 64; + + return DIV_ROUND_UP(igt_buf_width(buf), 1024) * 128; +} + +/** + * igt_buf_intel_ccs_height: + * @buf: the i-g-t buffer object + * @gen: device generation + * + * Computes the height of ccs buffer when considered as Intel surface data. + * + * Returns: + * The height of the ccs buffer data. + */ +unsigned int igt_buf_intel_ccs_height(int gen, const struct igt_buf *buf) +{ + /* + * GEN12+: The CCS unit size is 64 bytes mapping 4 main surface + * tiles. Thus the height of the CCS unit is 32 pixel rows on the main + * surface. + */ + if (gen >= 12) + return DIV_ROUND_UP(igt_buf_height(buf), 32); + + return DIV_ROUND_UP(igt_buf_height(buf), 512) * 32; +} + /* * pitches are in bytes if the surfaces are linear, number of dwords * otherwise diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h index fd7ef03f3..85eb3ffd7 100644 --- a/lib/intel_batchbuffer.h +++ b/lib/intel_batchbuffer.h @@ -262,6 +262,8 @@ static inline bool igt_buf_compressed(const struct igt_buf *buf) unsigned igt_buf_width(const struct igt_buf *buf); unsigned igt_buf_height(const struct igt_buf *buf); +unsigned int igt_buf_intel_ccs_width(int gen, const struct igt_buf *buf); +unsigned int igt_buf_intel_ccs_height(int gen, const struct igt_buf *buf); void igt_blitter_fast_copy(struct intel_batchbuffer *batch, const struct igt_buf *src, unsigned src_delta,