From 985a4ebab3154068592692ae95d7bfbd2a6474cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=9Alusarz?= Date: Mon, 24 Oct 2022 14:55:38 +0200 Subject: [PATCH] nir/lower_task_shader: allow offsetting of the start of payload We need this, because on Intel task payload starts with private header, followed by user-accessible data. Fixes: 37e78803d7b ("intel/compiler: use nir_lower_task_shader pass") Reviewed-by: Caio Oliveira Part-of: (cherry picked from commit f6adfd6278301aa772d3d44fc64ade21c9860574) --- .pick_status.json | 2 +- src/compiler/nir/nir.h | 1 + src/compiler/nir/nir_lower_task_shader.c | 9 ++++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 474293ae776..d43bdb75b79 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -5350,7 +5350,7 @@ "description": "nir/lower_task_shader: allow offsetting of the start of payload", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "37e78803d7b088afde8c79b7cf82ee29d4835651" }, diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 0cf9dfbdc87..42583435556 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -5370,6 +5370,7 @@ bool nir_lower_gs_intrinsics(nir_shader *shader, nir_lower_gs_intrinsics_flags o typedef struct { bool payload_to_shared_for_atomics : 1; bool payload_to_shared_for_small_types : 1; + uint32_t payload_offset_in_bytes; } nir_lower_task_shader_options; bool nir_lower_task_shader(nir_shader *shader, nir_lower_task_shader_options options); diff --git a/src/compiler/nir/nir_lower_task_shader.c b/src/compiler/nir/nir_lower_task_shader.c index c6c0f4391d2..07dec312d07 100644 --- a/src/compiler/nir/nir_lower_task_shader.c +++ b/src/compiler/nir/nir_lower_task_shader.c @@ -38,6 +38,7 @@ typedef struct { bool payload_in_shared; /* Shared memory address where task_payload will be located. */ uint32_t payload_shared_addr; + uint32_t payload_offset_in_bytes; } lower_task_state; static bool @@ -216,7 +217,12 @@ emit_shared_to_payload_copy(nir_builder *b, .memory_modes = nir_var_mem_shared); for (unsigned i = 0; i < copies_per_invocation; ++i) { - unsigned const_off = bytes_per_copy * invocations * i; + /* Payload_size is a size of user-accessible payload, but on some + * hardware (e.g. Intel) payload has a private header, which we have + * to offset (payload_offset_in_bytes). + */ + unsigned const_off = + bytes_per_copy * invocations * i + s->payload_offset_in_bytes; /* Read from shared memory. */ nir_ssa_def *copy = @@ -430,6 +436,7 @@ nir_lower_task_shader(nir_shader *shader, lower_task_state state = { .payload_shared_addr = ALIGN(shader->info.shared_size, 16), .payload_in_shared = payload_in_shared, + .payload_offset_in_bytes = options.payload_offset_in_bytes, }; if (payload_in_shared)