Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andrzej Hajda <andrzej.hajda@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Dominik Grzegorzek" <dominik.grzegorzek@intel.com>,
	"Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>,
	"Gwan-gyeong Mun" <gwan-gyeong.mun@intel.com>,
	"Kamil Konieczny" <kamil.konieczny@linux.intel.com>,
	"Christoph Manszewski" <christoph.manszewski@intel.com>,
	"Andrzej Hajda" <andrzej.hajda@intel.com>
Subject: [PATCH v4 3/4] lib/gpgpu_shader: pass surface desription to shaders via inline data
Date: Mon, 25 Nov 2024 08:31:52 +0100	[thread overview]
Message-ID: <20241125-gpgpu_send_rework-v4-3-c16b568a1f3d@intel.com> (raw)
In-Reply-To: <20241125-gpgpu_send_rework-v4-0-c16b568a1f3d@intel.com>

Since newer architectures require stateless load/stores we need to pass
surface description to the shader. Instead of doing it for every call
we can use inline data which is passed by COMPUTE_WALKER and is stored
in GRF register r1.

v4:
  - moved gpgpu_alloc_gpu_addr changes from next patch here (Dominik),
  - pass vm_id to intel_allocator (Dominik).

Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
---
 lib/gpgpu_shader.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/lib/gpgpu_shader.c b/lib/gpgpu_shader.c
index 363435e7efd3..52506705e517 100644
--- a/lib/gpgpu_shader.c
+++ b/lib/gpgpu_shader.c
@@ -148,6 +148,16 @@ __xelp_gpgpu_execfunc(struct intel_bb *ibb,
 		      engine | I915_EXEC_NO_RELOC, false);
 }
 
+static void
+fill_inline_data(uint32_t *inline_data, uint64_t target_offset, struct intel_buf *target)
+{
+	igt_assert(target->surface[0].stride == intel_buf_width(target) * target->bpp/8);
+	*inline_data++ = lower_32_bits(target_offset);
+	*inline_data++ = upper_32_bits(target_offset);
+	*inline_data++ = target->surface[0].stride;
+	*inline_data++ = intel_buf_height(target);
+}
+
 static void
 __xehp_gpgpu_execfunc(struct intel_bb *ibb,
 		      struct intel_buf *target,
@@ -159,6 +169,7 @@ __xehp_gpgpu_execfunc(struct intel_bb *ibb,
 	struct xehp_interface_descriptor_data idd;
 	uint32_t sip_offset;
 	uint64_t engine;
+	uint32_t *inline_data;
 
 	intel_bb_add_intel_buf(ibb, target, true);
 
@@ -186,7 +197,10 @@ __xehp_gpgpu_execfunc(struct intel_bb *ibb,
 	if (sip_offset)
 		emit_sip(ibb, sip_offset);
 
+	/* Inline data is at 31th/32th dword of COMPUTE_WALKER, BSpec: 67028 */
+	inline_data = intel_bb_ptr(ibb) + 4 * (shdr->gen_ver < 2000 ? 31 : 32);
 	xehp_emit_compute_walk(ibb, 0, 0, x_dim * 16, y_dim, &idd, 0x0);
+	fill_inline_data(inline_data, CANONICAL(target->addr.offset), target);
 
 	intel_bb_out(ibb, MI_BATCH_BUFFER_END);
 	intel_bb_ptr_align(ibb, 32);
@@ -196,6 +210,17 @@ __xehp_gpgpu_execfunc(struct intel_bb *ibb,
 		      engine | I915_EXEC_NO_RELOC, false);
 }
 
+static void gpgpu_alloc_gpu_addr(struct intel_bb *ibb, struct intel_buf *target)
+{
+	uint64_t ahnd;
+
+	ahnd = intel_allocator_open_vm_full(ibb->fd, ibb->vm_id, 0, 0, INTEL_ALLOCATOR_SIMPLE,
+					 ALLOC_STRATEGY_LOW_TO_HIGH, 0);
+	target->addr.offset = intel_allocator_alloc(ahnd, target->handle,
+						    target->surface[0].size, 0);
+	intel_allocator_close(ahnd);
+}
+
 /**
  * gpgpu_shader_exec:
  * @ibb: pointer to initialized intel_bb
@@ -221,6 +246,9 @@ void gpgpu_shader_exec(struct intel_bb *ibb,
 	igt_assert(ibb->size >= PAGE_SIZE);
 	igt_assert(ibb->ptr == ibb->batch);
 
+	if (target->addr.offset == INTEL_BUF_INVALID_ADDRESS)
+		gpgpu_alloc_gpu_addr(ibb, target);
+
 	if (shdr->gen_ver >= 1250)
 		__xehp_gpgpu_execfunc(ibb, target, x_dim, y_dim, shdr, sip,
 				      ring, explicit_engine);

-- 
2.34.1


  parent reply	other threads:[~2024-11-25  7:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-25  7:31 [PATCH v4 0/4] lib/gpgpu_shader: simplify load/store shaders and add Xe3 support Andrzej Hajda
2024-11-25  7:31 ` [PATCH v4 1/4] scripts/generate_iga64_codes: add iga64_macros.h to checksum calculation Andrzej Hajda
2024-11-25  7:31 ` [PATCH v4 2/4] lib/gpgpu_shader: simplify load/store shaders Andrzej Hajda
2024-11-25  7:31 ` Andrzej Hajda [this message]
2024-11-25  8:50   ` [PATCH v4 3/4] lib/gpgpu_shader: pass surface desription to shaders via inline data Grzegorzek, Dominik
2024-11-25  7:31 ` [PATCH v4 4/4] lib/gpgpu_shader: add support for Xe3 platforms Andrzej Hajda
2024-11-25 14:08   ` Grzegorzek, Dominik
2024-11-25  9:19 ` ✓ Xe.CI.BAT: success for lib/gpgpu_shader: simplify load/store shaders and add Xe3 support (rev2) Patchwork
2024-11-25  9:29 ` ✗ i915.CI.BAT: failure " Patchwork
2024-11-25 10:40 ` ✗ Xe.CI.Full: " 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=20241125-gpgpu_send_rework-v4-3-c16b568a1f3d@intel.com \
    --to=andrzej.hajda@intel.com \
    --cc=christoph.manszewski@intel.com \
    --cc=dominik.grzegorzek@intel.com \
    --cc=gwan-gyeong.mun@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=zbigniew.kempczynski@intel.com \
    /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