From: Joshua Ashton joshua@froggi.es Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d-shader/dxbc.c | 14 +++++++ libs/vkd3d-shader/spirv.c | 51 +++++++++++++++++++++++- libs/vkd3d-shader/trace.c | 7 ++++ libs/vkd3d-shader/vkd3d_shader_private.h | 7 ++++ 4 files changed, 77 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index d23dfcad..1a79da6d 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -311,13 +311,20 @@ enum vkd3d_sm4_opcode VKD3D_SM5_OP_IMM_ATOMIC_UMIN = 0xbd, VKD3D_SM5_OP_SYNC = 0xbe, VKD3D_SM5_OP_DADD = 0xbf, + VKD3D_SM5_OP_DMAX = 0xc0, + VKD3D_SM5_OP_DMIN = 0xc1, VKD3D_SM5_OP_DMUL = 0xc2, + VKD3D_SM5_OP_DEQ = 0xc3, + VKD3D_SM5_OP_DGE = 0xc4, + VKD3D_SM5_OP_DLT = 0xc5, + VKD3D_SM5_OP_DNE = 0xc6, VKD3D_SM5_OP_DMOV = 0xc7, VKD3D_SM5_OP_DMOVC = 0xc8, 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, };
@@ -1243,10 +1250,17 @@ static const struct vkd3d_sm4_opcode_info opcode_table[] = {VKD3D_SM5_OP_DCL_GS_INSTANCES, VKD3DSIH_DCL_GS_INSTANCES, "", "", shader_sm4_read_declaration_count}, {VKD3D_SM5_OP_DADD, VKD3DSIH_DADD, "d", "dd"}, + {VKD3D_SM5_OP_DMAX, VKD3DSIH_DMAX, "d", "dd"}, + {VKD3D_SM5_OP_DMIN, VKD3DSIH_DMIN, "d", "dd"}, {VKD3D_SM5_OP_DMUL, VKD3DSIH_DMUL, "d", "dd"}, + {VKD3D_SM5_OP_DEQ, VKD3DSIH_DEQ, "u", "dd"}, + {VKD3D_SM5_OP_DGE, VKD3DSIH_DGE, "u", "dd"}, + {VKD3D_SM5_OP_DLT, VKD3DSIH_DLT, "u", "dd"}, + {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_DDIV, VKD3DSIH_DDIV, "d", "dd"}, + {VKD3D_SM5_OP_DFMA, VKD3DSIH_DFMA, "d", "ddd"}, {VKD3D_SM5_OP_DRCP, VKD3DSIH_DRCP, "d", "d"}, };
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index f4cfd80d..6be1fda5 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -6628,8 +6628,11 @@ static enum GLSLstd450 vkd3d_dxbc_compiler_map_ext_glsl_instruction( {VKD3DSIH_IMAX, GLSLstd450SMax}, {VKD3DSIH_IMIN, GLSLstd450SMin}, {VKD3DSIH_LOG, GLSLstd450Log2}, + {VKD3DSIH_DFMA, GLSLstd450Fma}, {VKD3DSIH_MAD, GLSLstd450Fma}, + {VKD3DSIH_DMAX, GLSLstd450NMax}, {VKD3DSIH_MAX, GLSLstd450NMax}, + {VKD3DSIH_DMIN, GLSLstd450NMin}, {VKD3DSIH_MIN, GLSLstd450NMin}, {VKD3DSIH_ROUND_NE, GLSLstd450RoundEven}, {VKD3DSIH_ROUND_NI, GLSLstd450Floor}, @@ -7124,6 +7127,37 @@ static void vkd3d_dxbc_compiler_emit_f32tof16(struct vkd3d_dxbc_compiler *compil dst, vkd3d_component_type_from_data_type(dst->reg.data_type), components); }
+static DWORD vkd3d_dxbc_compiler_cross_type_src_mask(enum vkd3d_data_type src, enum vkd3d_data_type dst, DWORD mask) +{ + unsigned int component_count; + + if (src == dst) + return mask; + + component_count = vkd3d_write_mask_component_count(mask); + + if (src == VKD3D_DATA_DOUBLE) + { + if (component_count >= 2) + return VKD3DSP_WRITEMASK_ALL; + else if (component_count == 1) + return VKD3DSP_WRITEMASK_0 | VKD3DSP_WRITEMASK_1; + else + return 0; + } + else if (dst == VKD3D_DATA_DOUBLE) + { + if (component_count >= 3) + return VKD3DSP_WRITEMASK_0 | VKD3DSP_WRITEMASK_1; + else if (component_count >= 1) + return VKD3DSP_WRITEMASK_0; + else + return 0; + } + + return mask; +} + static void vkd3d_dxbc_compiler_emit_comparison_instruction(struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_instruction *instruction) { @@ -7132,17 +7166,22 @@ static void vkd3d_dxbc_compiler_emit_comparison_instruction(struct vkd3d_dxbc_co const struct vkd3d_shader_src_param *src = instruction->src; uint32_t src0_id, src1_id, type_id, result_id; unsigned int component_count; + DWORD src_mask; SpvOp op;
switch (instruction->handler_idx) { + case VKD3DSIH_DEQ: case VKD3DSIH_EQ: op = SpvOpFOrdEqual; break; + case VKD3DSIH_DGE: case VKD3DSIH_GE: op = SpvOpFOrdGreaterThanEqual; break; case VKD3DSIH_IEQ: op = SpvOpIEqual; break; case VKD3DSIH_IGE: op = SpvOpSGreaterThanEqual; break; case VKD3DSIH_ILT: op = SpvOpSLessThan; break; case VKD3DSIH_INE: op = SpvOpINotEqual; break; + case VKD3DSIH_DLT: case VKD3DSIH_LT: op = SpvOpFOrdLessThan; break; + case VKD3DSIH_DNE: case VKD3DSIH_NE: op = SpvOpFUnordNotEqual; break; case VKD3DSIH_UGE: op = SpvOpUGreaterThanEqual; break; case VKD3DSIH_ULT: op = SpvOpULessThan; break; @@ -7153,8 +7192,9 @@ static void vkd3d_dxbc_compiler_emit_comparison_instruction(struct vkd3d_dxbc_co
component_count = vkd3d_write_mask_component_count(dst->write_mask);
- src0_id = vkd3d_dxbc_compiler_emit_load_src(compiler, &src[0], dst->write_mask); - src1_id = vkd3d_dxbc_compiler_emit_load_src(compiler, &src[1], dst->write_mask); + src_mask = vkd3d_dxbc_compiler_cross_type_src_mask(src->reg.data_type, dst->reg.data_type, dst->write_mask); + src0_id = vkd3d_dxbc_compiler_emit_load_src(compiler, &src[0], src_mask); + src1_id = vkd3d_dxbc_compiler_emit_load_src(compiler, &src[1], src_mask);
type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_BOOL, component_count); result_id = vkd3d_spirv_build_op_tr2(builder, &builder->function_stream, @@ -9291,8 +9331,11 @@ int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, case VKD3DSIH_IMAX: case VKD3DSIH_IMIN: case VKD3DSIH_LOG: + case VKD3DSIH_DFMA: case VKD3DSIH_MAD: + case VKD3DSIH_DMAX: case VKD3DSIH_MAX: + case VKD3DSIH_DMIN: case VKD3DSIH_MIN: case VKD3DSIH_ROUND_NE: case VKD3DSIH_ROUND_NI: @@ -9325,13 +9368,17 @@ int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, case VKD3DSIH_UDIV: vkd3d_dxbc_compiler_emit_udiv(compiler, instruction); break; + case VKD3DSIH_DEQ: case VKD3DSIH_EQ: + case VKD3DSIH_DGE: case VKD3DSIH_GE: case VKD3DSIH_IEQ: case VKD3DSIH_IGE: case VKD3DSIH_ILT: case VKD3DSIH_INE: + case VKD3DSIH_DLT: case VKD3DSIH_LT: + case VKD3DSIH_DNE: case VKD3DSIH_NE: case VKD3DSIH_UGE: case VKD3DSIH_ULT: diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index 3812b573..c3e2d9b6 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -269,10 +269,17 @@ static const char * const shader_opcode_names[] = /* VKD3DSIH_UTOF */ "utof", /* VKD3DSIH_XOR */ "xor", /* VKD3DSIH_DADD */ "dadd", + /* VKD3DSIH_DMAX */ "dmax", + /* VKD3DSIH_DMIN */ "dmin", /* VKD3DSIH_DMUL */ "dmul", + /* VKD3DSIH_DEQ */ "deq", + /* VKD3DSIH_DGE */ "dge", + /* VKD3DSIH_DLT */ "dlt", + /* VKD3DSIH_DNE */ "dne", /* VKD3DSIH_DMOV */ "dmov", /* VKD3DSIH_DMOVC */ "dmovc", /* VKD3DSIH_DDIV */ "ddiv", + /* VKD3DSIH_DFMA */ "dfma", /* VKD3DSIH_DRCP */ "drcp", };
diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index d0fd25ee..ec1c6847 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -355,10 +355,17 @@ enum vkd3d_shader_opcode VKD3DSIH_XOR,
VKD3DSIH_DADD, + VKD3DSIH_DMAX, + VKD3DSIH_DMIN, VKD3DSIH_DMUL, + VKD3DSIH_DEQ, + VKD3DSIH_DGE, + VKD3DSIH_DLT, + VKD3DSIH_DNE, VKD3DSIH_DMOV, VKD3DSIH_DMOVC, VKD3DSIH_DDIV, + VKD3DSIH_DFMA, VKD3DSIH_DRCP,
VKD3DSIH_INVALID,