From 3edeb1e191980f1293f12a5515843b5f97fc249c Mon Sep 17 00:00:00 2001 From: Sagar Ghuge Date: Mon, 18 Aug 2025 18:50:07 -0700 Subject: [PATCH] brw/rt: Move nir_build_vec3_mat_mult_col_major helper to header Signed-off-by: Sagar Ghuge Reviewed-by: Lionel Landwerlin Part-of: --- .../brw/brw_nir_lower_rt_intrinsics.c | 22 ++----------------- src/intel/compiler/brw/brw_nir_rt.h | 18 +++++++++++++++ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/intel/compiler/brw/brw_nir_lower_rt_intrinsics.c b/src/intel/compiler/brw/brw_nir_lower_rt_intrinsics.c index 422d13808f6..e6aa645f831 100644 --- a/src/intel/compiler/brw/brw_nir_lower_rt_intrinsics.c +++ b/src/intel/compiler/brw/brw_nir_lower_rt_intrinsics.c @@ -24,24 +24,6 @@ #include "brw_nir_rt.h" #include "brw_nir_rt_builder.h" -static nir_def * -nir_build_vec3_mat_mult_col_major(nir_builder *b, nir_def *vec, - nir_def *matrix[], bool translation) -{ - nir_def *result_components[3] = { - nir_channel(b, matrix[3], 0), - nir_channel(b, matrix[3], 1), - nir_channel(b, matrix[3], 2), - }; - for (unsigned i = 0; i < 3; ++i) { - for (unsigned j = 0; j < 3; ++j) { - nir_def *v = nir_fmul(b, nir_channels(b, vec, 1 << j), nir_channels(b, matrix[j], 1 << i)); - result_components[i] = (translation || j) ? nir_fadd(b, result_components[i], v) : v; - } - } - return nir_vec(b, result_components, 3); -} - static nir_def * build_leaf_is_procedural(nir_builder *b, struct brw_nir_rt_mem_hit_defs *hit) { @@ -193,7 +175,7 @@ lower_rt_intrinsics_impl(nir_function_impl *impl, brw_nir_rt_load_bvh_instance_leaf(b, &leaf, hit_in.inst_leaf_ptr, devinfo); - sysval = nir_build_vec3_mat_mult_col_major( + sysval = brw_nir_build_vec3_mat_mult_col_major( b, world_ray_in.orig, leaf.world_to_object, true); } else { sysval = object_ray_in.orig; @@ -206,7 +188,7 @@ lower_rt_intrinsics_impl(nir_function_impl *impl, brw_nir_rt_load_bvh_instance_leaf(b, &leaf, hit_in.inst_leaf_ptr, devinfo); - sysval = nir_build_vec3_mat_mult_col_major( + sysval = brw_nir_build_vec3_mat_mult_col_major( b, world_ray_in.dir, leaf.world_to_object, false); } else { sysval = object_ray_in.dir; diff --git a/src/intel/compiler/brw/brw_nir_rt.h b/src/intel/compiler/brw/brw_nir_rt.h index 324811e3bf7..cd465a7a6c4 100644 --- a/src/intel/compiler/brw/brw_nir_rt.h +++ b/src/intel/compiler/brw/brw_nir_rt.h @@ -84,6 +84,24 @@ nir_shader * brw_nir_create_null_ahs_shader(const struct brw_compiler *compiler, void *mem_ctx); +static inline nir_def * +brw_nir_build_vec3_mat_mult_col_major(nir_builder *b, nir_def *vec, + nir_def *matrix[], bool translation) +{ + nir_def *result_components[3] = { + nir_channel(b, matrix[3], 0), + nir_channel(b, matrix[3], 1), + nir_channel(b, matrix[3], 2), + }; + for (unsigned i = 0; i < 3; ++i) { + for (unsigned j = 0; j < 3; ++j) { + nir_def *v = nir_fmul(b, nir_channels(b, vec, 1 << j), nir_channels(b, matrix[j], 1 << i)); + result_components[i] = (translation || j) ? nir_fadd(b, result_components[i], v) : v; + } + } + return nir_vec(b, result_components, 3); +} + #ifdef __cplusplus } #endif