From 8f16cac492548eb0a024393435b05d240631445d Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Sat, 9 Aug 2025 16:30:41 -0700 Subject: [PATCH] brw: Allow emit instruction with only number of sources The emit will allocate the necessary number of sources but will let the caller fill them in. Change a couple of places to take advantage of that. Reviewed-by: Kenneth Graunke Part-of: --- src/intel/compiler/brw_builder.h | 6 ++++++ src/intel/compiler/brw_compile_fs.cpp | 3 +-- src/intel/compiler/brw_workaround.cpp | 12 ++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/intel/compiler/brw_builder.h b/src/intel/compiler/brw_builder.h index 94e13a60340..4a0d869b1ab 100644 --- a/src/intel/compiler/brw_builder.h +++ b/src/intel/compiler/brw_builder.h @@ -292,6 +292,12 @@ public: return emit(opcode, brw_reg(), NULL, 0); } + brw_inst * + emit(enum opcode opcode, unsigned num_srcs) const + { + return emit(brw_new_inst(*shader, opcode, dispatch_width(), brw_reg(), num_srcs)); + } + /** * Create and insert a nullary instruction into the program. */ diff --git a/src/intel/compiler/brw_compile_fs.cpp b/src/intel/compiler/brw_compile_fs.cpp index b244387fdac..15a16c305e3 100644 --- a/src/intel/compiler/brw_compile_fs.cpp +++ b/src/intel/compiler/brw_compile_fs.cpp @@ -648,8 +648,7 @@ brw_emit_repclear_shader(brw_shader &s) if (i > 0) bld.uniform().MOV(component(header, 2), brw_imm_ud(i)); - write = bld.emit(SHADER_OPCODE_SEND); - write->resize_sources(SEND_NUM_SRCS); + write = bld.emit(SHADER_OPCODE_SEND, SEND_NUM_SRCS); /* We can use a headerless message for the first render target */ write->header_size = i == 0 ? 0 : 2; diff --git a/src/intel/compiler/brw_workaround.cpp b/src/intel/compiler/brw_workaround.cpp index 56fae704171..c486ee105cb 100644 --- a/src/intel/compiler/brw_workaround.cpp +++ b/src/intel/compiler/brw_workaround.cpp @@ -106,13 +106,13 @@ brw_workaround_memory_fence_before_eot(brw_shader &s) const brw_builder ubld = brw_builder(inst).uniform(); brw_reg dst = ubld.vgrf(BRW_TYPE_UD); - brw_inst *dummy_fence = ubld.emit(SHADER_OPCODE_SEND, dst); + brw_inst *dummy_fence = ubld.emit(SHADER_OPCODE_SEND, SEND_NUM_SRCS); - dummy_fence->resize_sources(4); - dummy_fence->src[0] = brw_imm_ud(0); - dummy_fence->src[1] = brw_imm_ud(0); - dummy_fence->src[2] = brw_vec8_grf(0, 0); - dummy_fence->src[3] = brw_reg(); + dummy_fence->src[SEND_SRC_DESC] = brw_imm_ud(0); + dummy_fence->src[SEND_SRC_EX_DESC] = brw_imm_ud(0); + dummy_fence->src[SEND_SRC_PAYLOAD1] = brw_vec8_grf(0, 0); + dummy_fence->src[SEND_SRC_PAYLOAD2] = brw_reg(); + dummy_fence->dst = dst; dummy_fence->mlen = reg_unit(s.devinfo); dummy_fence->ex_mlen = 0; dummy_fence->sfid = BRW_SFID_UGM;