From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Subject: [igt-dev] [PATCH i-g-t v4 1/8] lib/intel_bufops: Add bufops reference and adapt stride requirement
Date: Tue, 19 May 2020 10:11:27 +0200 [thread overview]
Message-ID: <20200519081134.24589-2-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20200519081134.24589-1-zbigniew.kempczynski@intel.com>
Add bufops reference to intel_buf to allow acquire drm fd against which
buffer was created.
Change stride limitation for intel_buf for non-tiled buffers.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
lib/intel_bufops.c | 55 +++++++++++++++++++++++++++++++++++++---------
lib/intel_bufops.h | 7 ++++--
2 files changed, 50 insertions(+), 12 deletions(-)
diff --git a/lib/intel_bufops.c b/lib/intel_bufops.c
index 804b2a0a..0337b638 100644
--- a/lib/intel_bufops.c
+++ b/lib/intel_bufops.c
@@ -52,7 +52,7 @@
* struct intel_buf ibuf;
* ...
* bops = buf_ops_create(fd);
- * intel_buf_init(bops, &ibuf, 512, 512, 32, I915_TILING_X, false);
+ * intel_buf_init(bops, &ibuf, 512, 512, 32, 64, I915_TILING_X, false);
* ...
* linear_to_intel_buf(bops, &ibuf, linear);
* ...
@@ -673,19 +673,24 @@ void linear_to_intel_buf(struct buf_ops *bops, struct intel_buf *buf,
static void __intel_buf_init(struct buf_ops *bops,
uint32_t handle,
struct intel_buf *buf,
- int width, int height, int bpp,
+ int width, int height, int bpp, int alignment,
uint32_t req_tiling, uint32_t compression)
{
uint32_t tiling = req_tiling;
uint32_t size;
+ uint32_t devid;
+ int tile_width;
igt_assert(bops);
igt_assert(buf);
igt_assert(width > 0 && height > 0);
igt_assert(bpp == 8 || bpp == 16 || bpp == 32);
+ igt_assert(alignment % 4 == 0);
memset(buf, 0, sizeof(*buf));
+ buf->bops = bops;
+
if (compression) {
int aux_width, aux_height;
@@ -721,7 +726,22 @@ static void __intel_buf_init(struct buf_ops *bops,
size = buf->aux.offset + aux_width * aux_height;
} else {
- buf->stride = ALIGN(width * (bpp / 8), 128);
+ if (buf->tiling) {
+ devid = intel_get_drm_devid(bops->fd);
+
+ if (bops->intel_gen < 3)
+ tile_width = 128;
+ else if (IS_915GM(devid) || IS_915G(devid) ||
+ buf->tiling == I915_TILING_X)
+ tile_width = 512;
+ else
+ tile_width = 128;
+
+ buf->stride = ALIGN(width * (bpp / 8), tile_width);
+ } else {
+ buf->stride = ALIGN(width * (bpp / 8), alignment ?: 4);
+ }
+
buf->size = buf->stride * height;
buf->tiling = tiling;
buf->bpp = bpp;
@@ -744,6 +764,7 @@ static void __intel_buf_init(struct buf_ops *bops,
* @width: surface width
* @height: surface height
* @bpp: bits-per-pixel (8 / 16 / 32)
+ * @alignment: alignment of the stride for linear surfaces
* @tiling: surface tiling
* @compression: surface compression type
*
@@ -754,11 +775,11 @@ static void __intel_buf_init(struct buf_ops *bops,
*/
void intel_buf_init(struct buf_ops *bops,
struct intel_buf *buf,
- int width, int height, int bpp,
+ int width, int height, int bpp, int alignment,
uint32_t tiling, uint32_t compression)
{
- __intel_buf_init(bops, 0, buf, width, height, bpp, tiling,
- compression);
+ __intel_buf_init(bops, 0, buf, width, height, bpp, alignment,
+ tiling, compression);
}
/**
@@ -784,6 +805,7 @@ void intel_buf_close(struct buf_ops *bops, struct intel_buf *buf)
* @width: surface width
* @height: surface height
* @bpp: bits-per-pixel (8 / 16 / 32)
+ * @alignment: alignment of the stride for linear surfaces
* @tiling: surface tiling
* @compression: surface compression type
*
@@ -797,11 +819,11 @@ void intel_buf_close(struct buf_ops *bops, struct intel_buf *buf)
void intel_buf_init_using_handle(struct buf_ops *bops,
uint32_t handle,
struct intel_buf *buf,
- int width, int height, int bpp,
+ int width, int height, int bpp, int alignment,
uint32_t req_tiling, uint32_t compression)
{
- __intel_buf_init(bops, handle, buf, width, height, bpp, req_tiling,
- compression);
+ __intel_buf_init(bops, handle, buf, width, height, bpp, alignment,
+ req_tiling, compression);
}
#define DEFAULT_BUFOPS(__gen_start, __gen_end) \
@@ -908,7 +930,7 @@ static void idempotency_selftest(struct buf_ops *bops, uint32_t tiling)
bool_str(software_tiling),
bool_str(!software_tiling),
tiling_str(tiling));
- intel_buf_init(bops, &buf, width, height, bpp, tiling, false);
+ intel_buf_init(bops, &buf, width, height, bpp, 0, tiling, false);
buf_ops_set_software_tiling(bops, tiling, software_tiling);
linear_to_intel_buf(bops, &buf, (uint32_t *) linear_in);
@@ -1038,6 +1060,19 @@ void buf_ops_destroy(struct buf_ops *bops)
free(bops);
}
+/**
+ * buf_ops_getfd
+ * @bops: pointer to buf_ops
+ *
+ * Returns: drm fd
+ */
+int buf_ops_getfd(struct buf_ops *bops)
+{
+ igt_assert(bops);
+
+ return bops->fd;
+}
+
/**
* buf_ops_set_software_tiling
* @bops: pointer to buf_ops
diff --git a/lib/intel_bufops.h b/lib/intel_bufops.h
index f3d6aed8..3a4fae4e 100644
--- a/lib/intel_bufops.h
+++ b/lib/intel_bufops.h
@@ -2,10 +2,12 @@
#define __INTEL_BUFOPS_H__
#include <stdint.h>
+#include "igt_aux.h"
struct buf_ops;
struct intel_buf {
+ struct buf_ops *bops;
uint32_t handle;
uint32_t stride;
uint32_t tiling;
@@ -58,6 +60,7 @@ intel_buf_aux_height(int gen, const struct intel_buf *buf)
struct buf_ops *buf_ops_create(int fd);
void buf_ops_destroy(struct buf_ops *bops);
+int buf_ops_getfd(struct buf_ops *bops);
bool buf_ops_set_software_tiling(struct buf_ops *bops,
uint32_t tiling,
@@ -73,14 +76,14 @@ bool buf_ops_has_hw_fence(struct buf_ops *bops, uint32_t tiling);
bool buf_ops_has_tiling_support(struct buf_ops *bops, uint32_t tiling);
void intel_buf_init(struct buf_ops *bops, struct intel_buf *buf,
- int width, int height, int bpp,
+ int width, int height, int bpp, int alignment,
uint32_t tiling, uint32_t compression);
void intel_buf_close(struct buf_ops *bops, struct intel_buf *buf);
void intel_buf_init_using_handle(struct buf_ops *bops,
uint32_t handle,
struct intel_buf *buf,
- int width, int height, int bpp,
+ int width, int height, int bpp, int alignment,
uint32_t req_tiling, uint32_t compression);
#endif
--
2.26.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2020-05-19 8:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-19 8:11 [igt-dev] [PATCH i-g-t v4 0/8] Make gpgpu fill tests libdrm independent Zbigniew Kempczyński
2020-05-19 8:11 ` Zbigniew Kempczyński [this message]
2020-05-19 8:11 ` [igt-dev] [PATCH i-g-t v4 2/8] lib/rendercopy_bufmgr: Pass alignment during buffer initialization Zbigniew Kempczyński
2020-05-19 8:11 ` [igt-dev] [PATCH i-g-t v4 3/8] lib/intel_batchbuffer: Introduce intel_bb Zbigniew Kempczyński
2020-05-19 8:11 ` [igt-dev] [PATCH i-g-t v4 4/8] lib/gpu_cmds: Add gpgpu pipeline functions based on intel_bb Zbigniew Kempczyński
2020-05-19 8:11 ` [igt-dev] [PATCH i-g-t v4 5/8] lib/gpgpu_fill: libdrm-free gpgpu pipeline creation Zbigniew Kempczyński
2020-05-19 8:11 ` [igt-dev] [PATCH i-g-t v4 6/8] lib/intel_batchbuffer: Introduce temporary igt_fillfunc_v2_t Zbigniew Kempczyński
2020-05-19 8:11 ` [igt-dev] [PATCH i-g-t v4 7/8] tests/gem_gpgpu_fill: Remove libdrm dependency Zbigniew Kempczyński
2020-05-19 8:11 ` [igt-dev] [PATCH i-g-t v4 8/8] HAX: run gpgpu_fill in BAT only Zbigniew Kempczyński
2020-05-19 8:46 ` [igt-dev] ✗ Fi.CI.BAT: failure for Make gpgpu fill tests libdrm independent (rev4) Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200519081134.24589-2-zbigniew.kempczynski@intel.com \
--to=zbigniew.kempczynski@intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox