summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmma Anholt <emma@anholt.net>2022-08-25 14:33:38 -0700
committerDylan Baker <dylan.c.baker@intel.com>2022-09-14 15:43:46 -0700
commitde8ec9b17aa3ea725e1954a32d2b78e6dfdfd8a3 (patch)
tree1d36f5120252627cfe6ffed578fed37469643fc2
parent9b94b96829b1bf9b4a4fbe74225ba4647084ba2f (diff)
spirv: Mark phis as mediump instead of directly lowering them to 16 bit.
This reverts commit 6f25d45877a1e1a7ac6250a7d051d33485e0cba7, 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 commit e1588cdf9ecc26c51ae0df3a380e1ac781e41941)
-rw-r--r--.pick_status.json2
-rw-r--r--src/compiler/spirv/vtn_cfg.c40
2 files changed, 9 insertions, 33 deletions
diff --git a/.pick_status.json b/.pick_status.json
index 019c63272c9..6b4e8f7d8b0 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -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"
},
diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c
index 9f1853befbe..4b1d66550b3 100644
--- a/src/compiler/spirv/vtn_cfg.c
+++ b/src/compiler/spirv/vtn_cfg.c
@@ -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);
}