From 62e1dff256097eff9665dd68f59f51b7cb2f274d Mon Sep 17 00:00:00 2001 From: "Juan A. Suarez Romero" Date: Thu, 7 Mar 2024 17:50:56 +0100 Subject: [PATCH] v3d: add load_fep_w_v3d intrinsic This intrinsic helps to read the W coordinate stored in the QPU register when initializing the input data for the fragment shaders. Reviewed-by: Iago Toral Quiroga Signed-off-by: Juan A. Suarez Romero Part-of: --- src/broadcom/compiler/nir_to_vir.c | 4 ++++ src/compiler/nir/nir_divergence_analysis.c | 1 + src/compiler/nir/nir_intrinsics.py | 3 +++ src/compiler/nir/nir_opt_preamble.c | 1 + 4 files changed, 9 insertions(+) diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c index cee1cd612a7..26565462501 100644 --- a/src/broadcom/compiler/nir_to_vir.c +++ b/src/broadcom/compiler/nir_to_vir.c @@ -3543,6 +3543,10 @@ ntq_emit_intrinsic(struct v3d_compile *c, nir_intrinsic_instr *instr) vir_emit_tlb_color_read(c, instr); break; + case nir_intrinsic_load_fep_w_v3d: + ntq_store_def(c, &instr->def, 0, vir_MOV(c, c->payload_w)); + break; + case nir_intrinsic_load_input: ntq_emit_load_input(c, instr); break; diff --git a/src/compiler/nir/nir_divergence_analysis.c b/src/compiler/nir/nir_divergence_analysis.c index c01e08ef95b..a03192d2660 100644 --- a/src/compiler/nir/nir_divergence_analysis.c +++ b/src/compiler/nir/nir_divergence_analysis.c @@ -156,6 +156,7 @@ visit_intrinsic(nir_shader *shader, nir_intrinsic_instr *instr, case nir_intrinsic_load_xfb_address: case nir_intrinsic_load_num_vertices: case nir_intrinsic_load_fb_layers_v3d: + case nir_intrinsic_load_fep_w_v3d: case nir_intrinsic_load_tcs_num_patches_amd: case nir_intrinsic_load_patch_vertices_in: case nir_intrinsic_load_ring_tess_factors_amd: diff --git a/src/compiler/nir/nir_intrinsics.py b/src/compiler/nir/nir_intrinsics.py index 38e39d17c5d..7a4a3040d62 100644 --- a/src/compiler/nir/nir_intrinsics.py +++ b/src/compiler/nir/nir_intrinsics.py @@ -1750,6 +1750,9 @@ store("tlb_sample_color_v3d", [1], [BASE, COMPONENT, SRC_TYPE], []) # the target framebuffer intrinsic("load_fb_layers_v3d", dest_comp=1, flags=[CAN_ELIMINATE, CAN_REORDER]) +# V3D-specific intrinsic to load W coordinate from the fragment shader payload +intrinsic("load_fep_w_v3d", dest_comp=1, flags=[CAN_ELIMINATE, CAN_REORDER]) + # Active invocation index within the subgroup. # Equivalent to popcount(ballot(true) & ((1 << subgroup_invocation) - 1)) system_value("active_subgroup_invocation_agx", 1) diff --git a/src/compiler/nir/nir_opt_preamble.c b/src/compiler/nir/nir_opt_preamble.c index 8b9045bdc4a..f35f98ef56a 100644 --- a/src/compiler/nir/nir_opt_preamble.c +++ b/src/compiler/nir/nir_opt_preamble.c @@ -172,6 +172,7 @@ can_move_intrinsic(nir_intrinsic_instr *instr, opt_preamble_ctx *ctx) case nir_intrinsic_load_line_width: case nir_intrinsic_load_aa_line_width: case nir_intrinsic_load_fb_layers_v3d: + case nir_intrinsic_load_fep_w_v3d: case nir_intrinsic_load_tcs_num_patches_amd: case nir_intrinsic_load_sample_positions_pan: case nir_intrinsic_load_pipeline_stat_query_enabled_amd: