Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Subject: [igt-dev] [PATCH i-g-t v3 04/13] lib/gpu_cmds: Fork a gen9_fill_surface_state()
Date: Wed,  4 Oct 2023 08:49:13 -0700	[thread overview]
Message-ID: <20231004154922.3478014-5-lucas.demarchi@intel.com> (raw)
In-Reply-To: <20231004154922.3478014-1-lucas.demarchi@intel.com>

Commit 02c2cf17628b ("lib/[gpu_cmds|intel_bufops]: Enable surface state
mocs setting.") added support for setting the mocs field in the surface
state. However it's not until gen9 that MOCS uses a table, programmed by
the kernel, and only has an index set in the surface state. Previously
it was the specific caching behavior.

As such, it makes no sense to set this field to `I915_MOCS_PTE << 1`: it
will only add garbage to the batch buffer. Solve this by forking a
separate function for gen9 and above, keeping the old behavior for
previous platforms.

Bspec: 12483, 12239, 12236
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
---
 lib/gpu_cmds.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/lib/gpu_cmds.c b/lib/gpu_cmds.c
index 0fd8f8213..83d2302f9 100644
--- a/lib/gpu_cmds.c
+++ b/lib/gpu_cmds.c
@@ -136,6 +136,58 @@ gen8_fill_surface_state(struct intel_bb *ibb,
 	struct gen8_surface_state *ss;
 	uint32_t write_domain, read_domain, offset;
 	uint64_t address;
+
+	if (is_dst) {
+		write_domain = read_domain = I915_GEM_DOMAIN_RENDER;
+	} else {
+		write_domain = 0;
+		read_domain = I915_GEM_DOMAIN_SAMPLER;
+	}
+
+	intel_bb_ptr_align(ibb, 64);
+	offset = intel_bb_offset(ibb);
+	ss = intel_bb_ptr(ibb);
+	intel_bb_ptr_add(ibb, 64);
+
+	ss->ss0.surface_type = SURFACE_2D;
+	ss->ss0.surface_format = format;
+	ss->ss0.render_cache_read_write = 1;
+	ss->ss0.vertical_alignment = 1; /* align 4 */
+	ss->ss0.horizontal_alignment = 1; /* align 4 */
+
+	if (buf->tiling == I915_TILING_X)
+		ss->ss0.tiled_mode = 2;
+	else if (buf->tiling == I915_TILING_Y || buf->tiling == I915_TILING_4)
+		ss->ss0.tiled_mode = 3;
+
+	address = intel_bb_offset_reloc(ibb, buf->handle,
+					read_domain, write_domain,
+					offset + 4 * 8, buf->addr.offset);
+
+	ss->ss8.base_addr = (uint32_t) address;
+	ss->ss9.base_addr_hi = address >> 32;
+
+	ss->ss2.height = intel_buf_height(buf) - 1;
+	ss->ss2.width  = intel_buf_width(buf) - 1;
+	ss->ss3.pitch  = buf->surface[0].stride - 1;
+
+	ss->ss7.shader_chanel_select_r = 4;
+	ss->ss7.shader_chanel_select_g = 5;
+	ss->ss7.shader_chanel_select_b = 6;
+	ss->ss7.shader_chanel_select_a = 7;
+
+	return offset;
+}
+
+static uint32_t
+gen9_fill_surface_state(struct intel_bb *ibb,
+			struct intel_buf *buf,
+			uint32_t format,
+			int is_dst)
+{
+	struct gen8_surface_state *ss;
+	uint32_t write_domain, read_domain, offset;
+	uint64_t address;
 	enum intel_buf_mocs mocs = intel_buf_get_mocs(buf);
 
 	if (is_dst) {
@@ -273,6 +325,9 @@ fill_binding_table(struct intel_bb *ibb, struct intel_buf *buf)
 	if (intel_graphics_ver(devid) >= IP_VER(12, 50))
 		binding_table[0] = xehp_fill_surface_state(ibb, buf,
 							   SURFACEFORMAT_R8_UNORM, 1);
+	else if (intel_graphics_ver(devid) >= IP_VER(9, 0))
+		binding_table[0] = gen9_fill_surface_state(ibb, buf,
+							   SURFACEFORMAT_R8_UNORM, 1);
 	else if (intel_graphics_ver(devid) >= IP_VER(8, 0))
 		binding_table[0] = gen8_fill_surface_state(ibb, buf,
 							   SURFACEFORMAT_R8_UNORM, 1);
-- 
2.40.1

  parent reply	other threads:[~2023-10-04 15:49 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04 15:49 [igt-dev] [PATCH i-g-t v3 00/13] Adapt copy commands for Xe2 Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 01/13] lib/rendercopy: Use common mocs function Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 02/13] lib/gpu_cmds: Remove prefix from gen7_fill_binding_table() Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 03/13] lib/gpu_cmds: Reorder if/else ladder according to IP version Lucas De Marchi
2023-10-04 15:49 ` Lucas De Marchi [this message]
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 05/13] lib/gpu_cmds: Reduce scope of xehp_fill_surface_state() Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 06/13] lib: Fork gen9_media.h Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 07/13] lib/intel_mocs: Stop encoding mocs Lucas De Marchi
2023-10-09 18:54   ` Matt Roper
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 08/13] lib/intel_mocs: Add Xe2 mocs indexes Lucas De Marchi
2023-10-09 18:56   ` Matt Roper
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 09/13] lib/igt_draw: Add Xe2 mocs to XY_FAST_COLOR_BLT Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 10/13] lib/intel_mocs: Remove unused lefotver defines Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 11/13] lib/intel_blt: Support Xe2 in xy-block-copy command Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 12/13] lib/intel_blt: Support xe2 in xy-fast-copy command Lucas De Marchi
2023-10-06 22:38   ` [igt-dev] [PATCH i-g-t v3.1 " Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 13/13] lib/intel_blt: Support xe2 in ctrl-surf-copy command Lucas De Marchi
2023-10-04 18:51 ` [igt-dev] ✗ Fi.CI.BAT: failure for Adapt copy commands for Xe2 (rev4) Patchwork
2023-10-04 19:36 ` [igt-dev] ✓ CI.xeBAT: success " Patchwork
2023-10-04 21:49 ` [igt-dev] ✓ Fi.CI.BAT: success for Adapt copy commands for Xe2 (rev5) Patchwork
2023-10-04 23:52 ` [igt-dev] ✓ CI.xeBAT: " Patchwork
2023-10-05  8:32 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2023-10-06 23:34 ` [igt-dev] ✓ Fi.CI.BAT: success for Adapt copy commands for Xe2 (rev6) Patchwork
2023-10-06 23:34 ` [igt-dev] ✓ CI.xeBAT: " Patchwork
2023-10-07 13:11 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2023-10-10 15:49 ` [igt-dev] [PATCH i-g-t v3 00/13] Adapt copy commands for Xe2 Lucas De Marchi

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=20231004154922.3478014-5-lucas.demarchi@intel.com \
    --to=lucas.demarchi@intel.com \
    --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