Henri Verbeet : vkd3d-shader: Introduce a helper to print d3d-asm floating-point literals.

Alexandre Julliard julliard at winehq.org
Wed Feb 17 16:23:18 CST 2021


Module: vkd3d
Branch: master
Commit: 8ff88d454416cd027efc505a2b180664838b2675
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=8ff88d454416cd027efc505a2b180664838b2675

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Wed Feb 17 12:21:09 2021 +0100

vkd3d-shader: Introduce a helper to print d3d-asm floating-point literals.

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 libs/vkd3d-shader/trace.c | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c
index b5abe22..b9fc34b 100644
--- a/libs/vkd3d-shader/trace.c
+++ b/libs/vkd3d-shader/trace.c
@@ -702,6 +702,12 @@ static void shader_dump_decl_usage(struct vkd3d_d3d_asm_compiler *compiler,
 static void shader_dump_src_param(struct vkd3d_d3d_asm_compiler *compiler,
         const struct vkd3d_shader_src_param *param);
 
+static void shader_print_float_literal(struct vkd3d_d3d_asm_compiler *compiler,
+        const char *prefix, float f, const char *suffix)
+{
+    vkd3d_string_buffer_printf(&compiler->buffer, "%s%.8e%s", prefix, f, suffix);
+}
+
 static void shader_print_subscript(struct vkd3d_d3d_asm_compiler *compiler,
         unsigned int offset, const struct vkd3d_shader_src_param *rel_addr)
 {
@@ -939,7 +945,7 @@ static void shader_dump_register(struct vkd3d_d3d_asm_compiler *compiler, const
                 switch (reg->data_type)
                 {
                     case VKD3D_DATA_FLOAT:
-                        shader_addline(buffer, "%.8e", reg->u.immconst_float[0]);
+                        shader_print_float_literal(compiler, "", reg->u.immconst_float[0], "");
                         break;
                     case VKD3D_DATA_INT:
                         shader_addline(buffer, "%d", reg->u.immconst_uint[0]);
@@ -959,9 +965,10 @@ static void shader_dump_register(struct vkd3d_d3d_asm_compiler *compiler, const
                 switch (reg->data_type)
                 {
                     case VKD3D_DATA_FLOAT:
-                        shader_addline(buffer, "%.8e, %.8e, %.8e, %.8e",
-                                reg->u.immconst_float[0], reg->u.immconst_float[1],
-                                reg->u.immconst_float[2], reg->u.immconst_float[3]);
+                        shader_print_float_literal(compiler, "", reg->u.immconst_float[0], "");
+                        shader_print_float_literal(compiler, ", ", reg->u.immconst_float[1], "");
+                        shader_print_float_literal(compiler, ", ", reg->u.immconst_float[2], "");
+                        shader_print_float_literal(compiler, ", ", reg->u.immconst_float[3], "");
                         break;
                     case VKD3D_DATA_INT:
                         shader_addline(buffer, "%d, %d, %d, %d",
@@ -1401,7 +1408,7 @@ static void shader_dump_instruction(struct vkd3d_d3d_asm_compiler *compiler,
             break;
 
         case VKD3DSIH_DCL_HS_MAX_TESSFACTOR:
-            vkd3d_string_buffer_printf(buffer, " %.8e", ins->declaration.max_tessellation_factor);
+            shader_print_float_literal(compiler, " ", ins->declaration.max_tessellation_factor, "");
             break;
 
         case VKD3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER:
@@ -1557,11 +1564,13 @@ static void shader_dump_instruction(struct vkd3d_d3d_asm_compiler *compiler,
             break;
 
         case VKD3DSIH_DEF:
-            vkd3d_string_buffer_printf(buffer, " %sc%u%s = %.8e, %.8e, %.8e, %.8e",
-                    compiler->colours.reg, shader_get_float_offset(ins->dst[0].reg.type,
-                    ins->dst[0].reg.idx[0].offset), compiler->colours.reset,
-                    ins->src[0].reg.u.immconst_float[0], ins->src[0].reg.u.immconst_float[1],
-                    ins->src[0].reg.u.immconst_float[2], ins->src[0].reg.u.immconst_float[3]);
+            vkd3d_string_buffer_printf(buffer, " %sc%u%s", compiler->colours.reg,
+                    shader_get_float_offset(ins->dst[0].reg.type, ins->dst[0].reg.idx[0].offset),
+                    compiler->colours.reset);
+            shader_print_float_literal(compiler, " = ", ins->src[0].reg.u.immconst_float[0], "");
+            shader_print_float_literal(compiler, ", ", ins->src[0].reg.u.immconst_float[1], "");
+            shader_print_float_literal(compiler, ", ", ins->src[0].reg.u.immconst_float[2], "");
+            shader_print_float_literal(compiler, ", ", ins->src[0].reg.u.immconst_float[3], "");
             break;
 
         case VKD3DSIH_DEFI:




More information about the wine-cvs mailing list