mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 20:18:12 +02:00
spirv: Refactor ALU opcode translation to take bit sizes
Only used by Convert operations, so just pass 0 from callers that
are not Convert and clarify that in the code.
Backport-to: 26.0
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
(cherry picked from commit 1c3c987d5c)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40359>
This commit is contained in:
parent
a66a9280fb
commit
0775d0f1b5
5 changed files with 19 additions and 22 deletions
|
|
@ -3034,7 +3034,7 @@
|
|||
"description": "spirv: Refactor ALU opcode translation to take bit sizes",
|
||||
"nominated": true,
|
||||
"nomination_type": 4,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null,
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -2894,7 +2894,8 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
|
|||
|
||||
bool exact;
|
||||
nir_op op = vtn_nir_alu_op_for_spirv_opcode(b, opcode, &swap, &exact,
|
||||
src_type, dst_type);
|
||||
glsl_get_bit_size(src_type),
|
||||
glsl_get_bit_size(dst_type));
|
||||
|
||||
/* No SPIR-V opcodes handled through this path should set exact.
|
||||
* Since it is ignored, assert on it.
|
||||
|
|
|
|||
|
|
@ -280,12 +280,9 @@ vtn_convert_op_dst_type(SpvOp opcode)
|
|||
nir_op
|
||||
vtn_nir_alu_op_for_spirv_opcode(struct vtn_builder *b,
|
||||
SpvOp opcode, bool *swap, bool *exact,
|
||||
const glsl_type *src_type,
|
||||
const glsl_type *dst_type)
|
||||
unsigned conv_src_bit_size,
|
||||
unsigned conv_dst_bit_size)
|
||||
{
|
||||
const unsigned src_bit_size = glsl_get_bit_size(src_type);
|
||||
const unsigned dst_bit_size = glsl_get_bit_size(dst_type);
|
||||
|
||||
/* Indicates that the first two arguments should be swapped. This is
|
||||
* used for implementing greater-than and less-than-or-equal.
|
||||
*/
|
||||
|
|
@ -382,8 +379,12 @@ vtn_nir_alu_op_for_spirv_opcode(struct vtn_builder *b,
|
|||
case SpvOpConvertUToF:
|
||||
case SpvOpSConvert:
|
||||
case SpvOpFConvert: {
|
||||
nir_alu_type src_type = vtn_convert_op_src_type(opcode) | src_bit_size;
|
||||
nir_alu_type dst_type = vtn_convert_op_dst_type(opcode) | dst_bit_size;
|
||||
vtn_fail_if(conv_src_bit_size == 0,
|
||||
"Need src bit_size to translate from SPIR-V convert opcodes to NIR.");
|
||||
vtn_fail_if(conv_dst_bit_size == 0,
|
||||
"Need dst bit_size to translate from SPIR-V convert opcodes to NIR.");
|
||||
nir_alu_type src_type = vtn_convert_op_src_type(opcode) | conv_src_bit_size;
|
||||
nir_alu_type dst_type = vtn_convert_op_dst_type(opcode) | conv_dst_bit_size;
|
||||
return nir_type_conversion_op(src_type, dst_type, nir_rounding_mode_undef);
|
||||
}
|
||||
|
||||
|
|
@ -909,8 +910,7 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
|
|||
bool swap;
|
||||
bool unused_exact;
|
||||
nir_op op = vtn_nir_alu_op_for_spirv_opcode(b, opcode, &swap,
|
||||
&unused_exact,
|
||||
vtn_src[0]->type, dest_type);
|
||||
&unused_exact, 0, 0);
|
||||
|
||||
if (swap) {
|
||||
nir_def *tmp = src[0];
|
||||
|
|
@ -986,8 +986,7 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
|
|||
case SpvOpShiftRightLogical: {
|
||||
bool swap;
|
||||
bool exact;
|
||||
nir_op op = vtn_nir_alu_op_for_spirv_opcode(b, opcode, &swap, &exact,
|
||||
vtn_src[0]->type, dest_type);
|
||||
nir_op op = vtn_nir_alu_op_for_spirv_opcode(b, opcode, &swap, &exact, 0, 0);
|
||||
|
||||
assert(!exact);
|
||||
|
||||
|
|
@ -1046,7 +1045,8 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
|
|||
bool exact;
|
||||
nir_op op = vtn_nir_alu_op_for_spirv_opcode(b, opcode, &swap,
|
||||
&exact,
|
||||
vtn_src[0]->type, dest_type);
|
||||
glsl_get_bit_size(vtn_src[0]->type),
|
||||
glsl_get_bit_size(dest_type));
|
||||
|
||||
if (swap) {
|
||||
nir_def *tmp = src[0];
|
||||
|
|
|
|||
|
|
@ -320,9 +320,7 @@ vtn_handle_cooperative_alu(struct vtn_builder *b, struct vtn_value *dest_val,
|
|||
nir_deref_instr *src = vtn_get_cmat_deref(b, w[3]);
|
||||
|
||||
bool ignored = false;
|
||||
nir_op op = vtn_nir_alu_op_for_spirv_opcode(b, opcode, &ignored, &ignored,
|
||||
glsl_get_cmat_element(src->type),
|
||||
glsl_get_cmat_element(dst_type->type));
|
||||
nir_op op = vtn_nir_alu_op_for_spirv_opcode(b, opcode, &ignored, &ignored, 0, 0);
|
||||
|
||||
nir_deref_instr *dst = vtn_create_cmat_temporary(b, dst_type->type, "cmat_unary");
|
||||
nir_cmat_unary_op(&b->nb, &dst->def, &src->def,
|
||||
|
|
@ -346,9 +344,7 @@ vtn_handle_cooperative_alu(struct vtn_builder *b, struct vtn_value *dest_val,
|
|||
nir_deref_instr *mat_a = vtn_get_cmat_deref(b, w[3]);
|
||||
nir_deref_instr *mat_b = vtn_get_cmat_deref(b, w[4]);
|
||||
|
||||
nir_op op = vtn_nir_alu_op_for_spirv_opcode(b, opcode, &ignored, &ignored,
|
||||
glsl_get_cmat_element(mat_a->type),
|
||||
glsl_get_cmat_element(dst_type->type));
|
||||
nir_op op = vtn_nir_alu_op_for_spirv_opcode(b, opcode, &ignored, &ignored, 0, 0);
|
||||
|
||||
nir_deref_instr *dst = vtn_create_cmat_temporary(b, dst_type->type, "cmat_binary");
|
||||
nir_cmat_binary_op(&b->nb, &dst->def, &mat_a->def, &mat_b->def,
|
||||
|
|
|
|||
|
|
@ -980,8 +980,8 @@ nir_alu_type vtn_convert_op_dst_type(SpvOp opcode);
|
|||
|
||||
nir_op vtn_nir_alu_op_for_spirv_opcode(struct vtn_builder *b,
|
||||
SpvOp opcode, bool *swap, bool *exact,
|
||||
const glsl_type *src_type,
|
||||
const glsl_type *dst_type);
|
||||
unsigned conv_src_bit_size,
|
||||
unsigned conv_dst_bit_size);
|
||||
|
||||
void vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
|
||||
const uint32_t *w, unsigned count);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue