Module: Mesa Branch: staging/22.3 Commit: c58c1f3441d9186499bd46b191166e2105dc655c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c58c1f3441d9186499bd46b191166e2105dc655c
Author: Marcin Ĺšlusarz <[email protected]> Date: Mon Oct 24 14:55:38 2022 +0200 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 <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19409> (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 ad79ccb1ee2..37524dc28ec 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -220,7 +220,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)
