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

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2021-02-17 12:21:09 +01:00 committed by Alexandre Julliard
parent 401b51f888
commit 8ff88d4544

View File

@ -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, static void shader_dump_src_param(struct vkd3d_d3d_asm_compiler *compiler,
const struct vkd3d_shader_src_param *param); 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, static void shader_print_subscript(struct vkd3d_d3d_asm_compiler *compiler,
unsigned int offset, const struct vkd3d_shader_src_param *rel_addr) 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) switch (reg->data_type)
{ {
case VKD3D_DATA_FLOAT: case VKD3D_DATA_FLOAT:
shader_addline(buffer, "%.8e", reg->u.immconst_float[0]); shader_print_float_literal(compiler, "", reg->u.immconst_float[0], "");
break; break;
case VKD3D_DATA_INT: case VKD3D_DATA_INT:
shader_addline(buffer, "%d", reg->u.immconst_uint[0]); 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) switch (reg->data_type)
{ {
case VKD3D_DATA_FLOAT: case VKD3D_DATA_FLOAT:
shader_addline(buffer, "%.8e, %.8e, %.8e, %.8e", shader_print_float_literal(compiler, "", reg->u.immconst_float[0], "");
reg->u.immconst_float[0], reg->u.immconst_float[1], shader_print_float_literal(compiler, ", ", reg->u.immconst_float[1], "");
reg->u.immconst_float[2], reg->u.immconst_float[3]); shader_print_float_literal(compiler, ", ", reg->u.immconst_float[2], "");
shader_print_float_literal(compiler, ", ", reg->u.immconst_float[3], "");
break; break;
case VKD3D_DATA_INT: case VKD3D_DATA_INT:
shader_addline(buffer, "%d, %d, %d, %d", shader_addline(buffer, "%d, %d, %d, %d",
@ -1401,7 +1408,7 @@ static void shader_dump_instruction(struct vkd3d_d3d_asm_compiler *compiler,
break; break;
case VKD3DSIH_DCL_HS_MAX_TESSFACTOR: 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; break;
case VKD3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER: case VKD3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER:
@ -1557,11 +1564,13 @@ static void shader_dump_instruction(struct vkd3d_d3d_asm_compiler *compiler,
break; break;
case VKD3DSIH_DEF: case VKD3DSIH_DEF:
vkd3d_string_buffer_printf(buffer, " %sc%u%s = %.8e, %.8e, %.8e, %.8e", vkd3d_string_buffer_printf(buffer, " %sc%u%s", compiler->colours.reg,
compiler->colours.reg, shader_get_float_offset(ins->dst[0].reg.type, shader_get_float_offset(ins->dst[0].reg.type, ins->dst[0].reg.idx[0].offset),
ins->dst[0].reg.idx[0].offset), compiler->colours.reset, compiler->colours.reset);
ins->src[0].reg.u.immconst_float[0], ins->src[0].reg.u.immconst_float[1], shader_print_float_literal(compiler, " = ", ins->src[0].reg.u.immconst_float[0], "");
ins->src[0].reg.u.immconst_float[2], ins->src[0].reg.u.immconst_float[3]); 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; break;
case VKD3DSIH_DEFI: case VKD3DSIH_DEFI: