spirv: Mark phis as mediump instead of directly lowering them to 16 bit.
This reverts commit6f25d45877
, replacing it with GLSL_PRECISION_MEDIUM. The previous commit ended up not being the right approach, as it affected only nir vars for spirv phis and not other nir vars, and we want a tool that does both. The new nir_lower_mediump_vars pass can do that for you. No fossil-db change for my angle fossils run on radv. Reviewed-by: Matt Turner <mattst88@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18259> (cherry picked from commite1588cdf9e
)
This commit is contained in:
@@ -6196,7 +6196,7 @@
|
||||
"description": "spirv: Mark phis as mediump instead of directly lowering them to 16 bit.",
|
||||
"nominated": true,
|
||||
"nomination_type": 2,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "6f25d45877a1e1a7ac6250a7d051d33485e0cba7"
|
||||
},
|
||||
|
@@ -921,34 +921,18 @@ vtn_handle_phis_first_pass(struct vtn_builder *b, SpvOp opcode,
|
||||
* algorithm all over again. It's easier if we just let
|
||||
* lower_vars_to_ssa do that for us instead of repeating it here.
|
||||
*/
|
||||
bool relaxed_precision = false;
|
||||
if (b->options->mediump_16bit_alu) {
|
||||
struct vtn_value *phi_val = vtn_untyped_value(b, w[2]);
|
||||
relaxed_precision = vtn_value_is_relaxed_precision(b, phi_val);
|
||||
}
|
||||
struct vtn_type *type = vtn_get_type(b, w[1]);
|
||||
nir_variable *phi_var =
|
||||
nir_local_variable_create(b->nb.impl, type->type, "phi");
|
||||
|
||||
const struct glsl_type *dest_type = vtn_get_type(b, w[1])->type;
|
||||
const struct glsl_type *type = dest_type;
|
||||
if (relaxed_precision) {
|
||||
if (glsl_get_base_type(type) == GLSL_TYPE_FLOAT)
|
||||
type = glsl_float16_type(type);
|
||||
else if (glsl_get_base_type(type) == GLSL_TYPE_INT)
|
||||
type = glsl_int16_type(type);
|
||||
else if (glsl_get_base_type(type) == GLSL_TYPE_UINT)
|
||||
type = glsl_uint16_type(type);
|
||||
}
|
||||
struct vtn_value *phi_val = vtn_untyped_value(b, w[2]);
|
||||
if (vtn_value_is_relaxed_precision(b, phi_val))
|
||||
phi_var->data.precision = GLSL_PRECISION_MEDIUM;
|
||||
|
||||
nir_variable *phi_var = nir_local_variable_create(b->nb.impl, type, "phi");
|
||||
_mesa_hash_table_insert(b->phi_table, w, phi_var);
|
||||
|
||||
struct vtn_ssa_value *dest =
|
||||
vtn_local_load(b, nir_build_deref_var(&b->nb, phi_var), 0);
|
||||
|
||||
if (relaxed_precision) {
|
||||
dest->type = dest_type;
|
||||
vtn_mediump_upconvert_value(b, dest);
|
||||
}
|
||||
vtn_push_ssa_value(b, w[2], dest);
|
||||
vtn_push_ssa_value(b, w[2],
|
||||
vtn_local_load(b, nir_build_deref_var(&b->nb, phi_var), 0));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -969,12 +953,6 @@ vtn_handle_phi_second_pass(struct vtn_builder *b, SpvOp opcode,
|
||||
if (phi_entry == NULL)
|
||||
return true;
|
||||
|
||||
bool relaxed_precision = false;
|
||||
if (b->options->mediump_16bit_alu) {
|
||||
struct vtn_value *phi_val = vtn_untyped_value(b, w[2]);
|
||||
relaxed_precision = vtn_value_is_relaxed_precision(b, phi_val);
|
||||
}
|
||||
|
||||
nir_variable *phi_var = phi_entry->data;
|
||||
|
||||
for (unsigned i = 3; i < count; i += 2) {
|
||||
@@ -988,8 +966,6 @@ vtn_handle_phi_second_pass(struct vtn_builder *b, SpvOp opcode,
|
||||
b->nb.cursor = nir_after_instr(&pred->end_nop->instr);
|
||||
|
||||
struct vtn_ssa_value *src = vtn_ssa_value(b, w[i]);
|
||||
if (relaxed_precision)
|
||||
src = vtn_mediump_downconvert_value(b, src);
|
||||
|
||||
vtn_local_store(b, src, nir_build_deref_var(&b->nb, phi_var), 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user