summarylogtreecommitdiffstats
path: root/0005-spirv-convert-e4m3fn.patch
blob: 05985e35c223672b230d2aac4747d920b9a2a459 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
From 49e64e12140c854f37cc559f5f19e0612ec4cd79 Mon Sep 17 00:00:00 2001
From: Georg Lehmann <dadschoorse@gmail.com>
Date: Wed, 9 Apr 2025 13:40:24 +0200
Subject: [PATCH 05/13] spirv: convert e4m3fn

---
 src/compiler/spirv/vtn_alu.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/compiler/spirv/vtn_alu.c b/src/compiler/spirv/vtn_alu.c
index a528b2e1b12..a89d9b2ad9e 100644
--- a/src/compiler/spirv/vtn_alu.c
+++ b/src/compiler/spirv/vtn_alu.c
@@ -697,6 +697,23 @@ vtn_handle_convert(struct vtn_builder *b, SpvOp opcode,
       return nir_f2bf(&b->nb, src_as_float);
    }
 
+   if (glsl_type_is_e4m3fn(glsl_src_type)) {
+      nir_def *src_as_float = nir_e4m3fn2f(&b->nb, src);
+      if (glsl_type_is_float(glsl_dest_type))
+         return src_as_float;
+      return vtn_handle_convert(b, opcode, dest_val, glsl_dest_type,
+                                glsl_float_type(), src_as_float);
+
+   } else if (glsl_type_is_e4m3fn(glsl_dest_type)) {
+      nir_def *src_as_float;
+      if (glsl_type_is_float(glsl_src_type))
+         src_as_float = src;
+      else
+         src_as_float = vtn_handle_convert(b, opcode, dest_val, glsl_float_type(),
+                                           glsl_src_type, src);
+      return nir_f2e4m3fn(&b->nb, src_as_float);
+   }
+
    /* Use bit_size from NIR source instead of from the original src type,
     * to account for mediump_16bit.  See vtn_handle_alu() for details.
     */
-- 
2.49.0