From 3debca7dc66efd55c3a32582c5a0286f0d208ff2 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Fri, 13 Feb 2026 20:56:57 -0800 Subject: [PATCH] anv: Enable cooperativeMatrixPerElementOperations Reviewed-by: Ian Romanick Reviewed-by: Dave Airlie Part-of: --- src/intel/vulkan/anv_physical_device.c | 4 ++++ src/intel/vulkan/anv_shader_compile.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/intel/vulkan/anv_physical_device.c b/src/intel/vulkan/anv_physical_device.c index 2a21de76630..9378ca7f9a7 100644 --- a/src/intel/vulkan/anv_physical_device.c +++ b/src/intel/vulkan/anv_physical_device.c @@ -148,6 +148,7 @@ get_device_extensions(const struct anv_physical_device *device, .KHR_calibrated_timestamps = device->has_reg_timestamp, .KHR_compute_shader_derivatives = true, .KHR_cooperative_matrix = device->has_cooperative_matrix, + .NV_cooperative_matrix2 = device->has_cooperative_matrix, .KHR_copy_commands2 = true, .KHR_create_renderpass2 = true, .KHR_dedicated_allocation = true, @@ -883,6 +884,9 @@ get_features(const struct anv_physical_device *pdevice, /* VK_KHR_cooperative_matrix */ .cooperativeMatrix = pdevice->has_cooperative_matrix, + /* VK_NV_cooperative_matrix2 */ + .cooperativeMatrixPerElementOperations = pdevice->has_cooperative_matrix, + /* VK_KHR_shader_maximal_reconvergence */ .shaderMaximalReconvergence = true, diff --git a/src/intel/vulkan/anv_shader_compile.c b/src/intel/vulkan/anv_shader_compile.c index 15e0a72789d..8e99f55ad25 100644 --- a/src/intel/vulkan/anv_shader_compile.c +++ b/src/intel/vulkan/anv_shader_compile.c @@ -1404,6 +1404,21 @@ anv_shader_lower_nir(struct anv_device *device, nir->info.cs.has_cooperative_matrix) { anv_fixup_subgroup_size(device, nir); NIR_PASS(_, nir, brw_nir_lower_cmat, nir->info.api_subgroup_size); + + /* Lowering of nir_instr_type_cmat_call will produce new + * nir_instr_type_call instructions that need to be inlined. + */ + bool inlined = false; + NIR_PASS(_, nir, nir_opt_dce); + NIR_PASS(inlined, nir, nir_inline_functions); + nir_remove_non_entrypoints(nir); + if (inlined) { + NIR_PASS(_, nir, nir_opt_copy_prop_vars); + NIR_PASS(_, nir, nir_opt_copy_prop); + } + NIR_PASS(_, nir, nir_opt_deref); + NIR_PASS(_, nir, nir_opt_dce); + NIR_PASS(_, nir, nir_lower_indirect_derefs_to_if_else_trees, nir_var_function_temp, 16); }