spirv: implement CooperativeMatrixConversionsNV

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34793>
This commit is contained in:
Georg Lehmann 2025-04-23 17:41:15 +02:00 committed by Marge Bot
parent 8c4225b99b
commit bdd2c7b9f2
2 changed files with 23 additions and 0 deletions

View file

@ -68,6 +68,7 @@ static const struct spirv_capabilities implemented_capabilities = {
.ComputeDerivativeGroupLinearKHR = true,
.ComputeDerivativeGroupQuadsKHR = true,
.CooperativeMatrixKHR = true,
.CooperativeMatrixConversionsNV = true,
.CullDistance = true,
.DemoteToHelperInvocation = true,
.DenormFlushToZero = true,
@ -6862,6 +6863,8 @@ vtn_handle_body_instruction(struct vtn_builder *b, SpvOp opcode,
case SpvOpCooperativeMatrixStoreKHR:
case SpvOpCooperativeMatrixLengthKHR:
case SpvOpCooperativeMatrixMulAddKHR:
case SpvOpCooperativeMatrixConvertNV:
case SpvOpCooperativeMatrixTransposeNV:
vtn_handle_cooperative_instruction(b, opcode, w, count);
break;

View file

@ -179,6 +179,26 @@ vtn_handle_cooperative_instruction(struct vtn_builder *b, SpvOp opcode,
break;
}
case SpvOpCooperativeMatrixConvertNV: {
struct vtn_type *dst_type = vtn_get_type(b, w[1]);
nir_deref_instr *src = vtn_get_cmat_deref(b, w[3]);
nir_deref_instr *dst = vtn_create_cmat_temporary(b, dst_type->type, "cmat_convert_nv");
nir_cmat_convert(&b->nb, &dst->def, &src->def);
vtn_push_var_ssa(b, w[2], dst->var);
break;
}
case SpvOpCooperativeMatrixTransposeNV: {
struct vtn_type *dst_type = vtn_get_type(b, w[1]);
nir_deref_instr *src = vtn_get_cmat_deref(b, w[3]);
nir_deref_instr *dst = vtn_create_cmat_temporary(b, dst_type->type, "cmat_transpose_nv");
nir_cmat_transpose(&b->nb, &dst->def, &src->def);
vtn_push_var_ssa(b, w[2], dst->var);
break;
}
default:
unreachable("Unexpected opcode for cooperative matrix instruction");
}