From: Joshua Ashton joshua@froggi.es Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d-shader/dxbc.c | 12 +++++++ libs/vkd3d-shader/spirv.c | 43 ++++++++++++++++++++++++ libs/vkd3d-shader/trace.c | 6 ++++ libs/vkd3d-shader/vkd3d_shader_private.h | 6 ++++ 4 files changed, 67 insertions(+)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 1a79da6d..e63493fa 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -320,12 +320,18 @@ enum vkd3d_sm4_opcode VKD3D_SM5_OP_DNE = 0xc6, VKD3D_SM5_OP_DMOV = 0xc7, VKD3D_SM5_OP_DMOVC = 0xc8, + VKD3D_SM5_OP_DTOF = 0xc9, + VKD3D_SM5_OP_FTOD = 0xca, VKD3D_SM5_OP_EVAL_SAMPLE_INDEX = 0xcc, VKD3D_SM5_OP_EVAL_CENTROID = 0xcd, VKD3D_SM5_OP_DCL_GS_INSTANCES = 0xce, VKD3D_SM5_OP_DDIV = 0xd2, VKD3D_SM5_OP_DFMA = 0xd3, VKD3D_SM5_OP_DRCP = 0xd4, + VKD3D_SM5_OP_DTOI = 0xd6, + VKD3D_SM5_OP_DTOU = 0xd7, + VKD3D_SM5_OP_ITOD = 0xd8, + VKD3D_SM5_OP_UTOD = 0xd9, };
enum vkd3d_sm4_instruction_modifier @@ -1259,9 +1265,15 @@ static const struct vkd3d_sm4_opcode_info opcode_table[] = {VKD3D_SM5_OP_DNE, VKD3DSIH_DNE, "u", "dd"}, {VKD3D_SM5_OP_DMOV, VKD3DSIH_DMOV, "d", "d"}, {VKD3D_SM5_OP_DMOVC, VKD3DSIH_DMOVC, "d", "udd"}, + {VKD3D_SM5_OP_DTOF, VKD3DSIH_DTOF, "f", "d"}, + {VKD3D_SM5_OP_FTOD, VKD3DSIH_FTOD, "d", "f"}, {VKD3D_SM5_OP_DDIV, VKD3DSIH_DDIV, "d", "dd"}, {VKD3D_SM5_OP_DFMA, VKD3DSIH_DFMA, "d", "ddd"}, {VKD3D_SM5_OP_DRCP, VKD3DSIH_DRCP, "d", "d"}, + {VKD3D_SM5_OP_DTOI, VKD3DSIH_DTOI, "i", "d"}, + {VKD3D_SM5_OP_DTOU, VKD3DSIH_DTOU, "u", "d"}, + {VKD3D_SM5_OP_ITOD, VKD3DSIH_ITOD, "d", "i"}, + {VKD3D_SM5_OP_UTOD, VKD3DSIH_UTOD, "d", "u"}, };
static const enum vkd3d_shader_register_type register_type_table[] = diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 6be1fda5..a44437ec 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -9102,6 +9102,41 @@ static void vkd3d_dxbc_compiler_emit_cut_stream(struct vkd3d_dxbc_compiler *comp vkd3d_spirv_build_op_end_primitive(builder); }
+static void vkd3d_dxbc_compiler_emit_double_conversion(struct vkd3d_dxbc_compiler *compiler, + const struct vkd3d_shader_instruction *instruction) +{ + struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; + const struct vkd3d_shader_dst_param *dst = instruction->dst; + const struct vkd3d_shader_src_param *src = instruction->src; + uint32_t src_id, val_id, type_id; + DWORD src_mask; + SpvOp op; + + switch (instruction->handler_idx) + { + case VKD3DSIH_DTOF: + case VKD3DSIH_FTOD: op = SpvOpFConvert; break; + case VKD3DSIH_DTOI: op = SpvOpConvertFToS; break; + case VKD3DSIH_DTOU: op = SpvOpConvertFToU; break; + case VKD3DSIH_ITOD: op = SpvOpConvertSToF; break; + case VKD3DSIH_UTOD: op = SpvOpConvertUToF; break; + default: + ERR("Unexpected instruction %#x.\n", instruction->handler_idx); + return; + } + + src_mask = vkd3d_dxbc_compiler_cross_type_src_mask(src->reg.data_type, dst->reg.data_type, dst->write_mask); + src_id = vkd3d_dxbc_compiler_emit_load_src(compiler, src, src_mask); + + type_id = vkd3d_spirv_get_type_id(builder, vkd3d_component_type_from_data_type(dst->reg.data_type), + vkd3d_write_mask_component_count_typed(dst->write_mask, dst->reg.data_type)); + + val_id = vkd3d_spirv_build_op_trv(builder, &builder->function_stream, + op, type_id, &src_id, 1); + + vkd3d_dxbc_compiler_emit_store_dst(compiler, dst, val_id); +} + static void vkd3d_dxbc_compiler_emit_hull_shader_inputs(struct vkd3d_dxbc_compiler *compiler) { const struct vkd3d_shader_signature *signature = compiler->input_signature; @@ -9510,6 +9545,14 @@ int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, case VKD3DSIH_CUT_STREAM: vkd3d_dxbc_compiler_emit_cut_stream(compiler, instruction); break; + case VKD3DSIH_DTOF: + case VKD3DSIH_FTOD: + case VKD3DSIH_DTOI: + case VKD3DSIH_DTOU: + case VKD3DSIH_ITOD: + case VKD3DSIH_UTOD: + vkd3d_dxbc_compiler_emit_double_conversion(compiler, instruction); + break; case VKD3DSIH_DCL_HS_MAX_TESSFACTOR: case VKD3DSIH_HS_DECLS: case VKD3DSIH_NOP: diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index c3e2d9b6..a11083ef 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -278,9 +278,15 @@ static const char * const shader_opcode_names[] = /* VKD3DSIH_DNE */ "dne", /* VKD3DSIH_DMOV */ "dmov", /* VKD3DSIH_DMOVC */ "dmovc", + /* VKD3DSIH_DTOF */ "dtof", + /* VKD3DSIH_FTOD */ "ftod", /* VKD3DSIH_DDIV */ "ddiv", /* VKD3DSIH_DFMA */ "dfma", /* VKD3DSIH_DRCP */ "drcp", + /* VKD3DSIH_DTOI */ "dtoi", + /* VKD3DSIH_DTOU */ "dtou", + /* VKD3DSIH_ITOD */ "itod", + /* VKD3DSIH_UTOD */ "utod", };
static const struct diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index ec1c6847..86860b9d 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -364,9 +364,15 @@ enum vkd3d_shader_opcode VKD3DSIH_DNE, VKD3DSIH_DMOV, VKD3DSIH_DMOVC, + VKD3DSIH_DTOF, + VKD3DSIH_FTOD, VKD3DSIH_DDIV, VKD3DSIH_DFMA, VKD3DSIH_DRCP, + VKD3DSIH_DTOI, + VKD3DSIH_DTOU, + VKD3DSIH_ITOD, + VKD3DSIH_UTOD,
VKD3DSIH_INVALID, };