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 | 23 +++++++++++++++++++---- libs/vkd3d-shader/trace.c | 6 ++++++ libs/vkd3d-shader/vkd3d_shader_private.h | 7 +++++++ 4 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 782aed13..d23dfcad 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -310,9 +310,15 @@ enum vkd3d_sm4_opcode VKD3D_SM5_OP_IMM_ATOMIC_UMAX = 0xbc, VKD3D_SM5_OP_IMM_ATOMIC_UMIN = 0xbd, VKD3D_SM5_OP_SYNC = 0xbe, + VKD3D_SM5_OP_DADD = 0xbf, + VKD3D_SM5_OP_DMUL = 0xc2, + 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_DRCP = 0xd4, };
enum vkd3d_sm4_instruction_modifier @@ -1236,6 +1242,12 @@ static const struct vkd3d_sm4_opcode_info opcode_table[] = {VKD3D_SM5_OP_EVAL_CENTROID, VKD3DSIH_EVAL_CENTROID, "f", "f"}, {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_DMUL, VKD3DSIH_DMUL, "d", "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_DRCP, VKD3DSIH_DRCP, "d", "d"}, };
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 c2826445..f4cfd80d 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -6543,10 +6543,12 @@ static SpvOp vkd3d_dxbc_compiler_map_alu_instruction(const struct vkd3d_shader_i } alu_ops[] = { + {VKD3DSIH_DADD, SpvOpFAdd}, {VKD3DSIH_ADD, SpvOpFAdd}, {VKD3DSIH_AND, SpvOpBitwiseAnd}, {VKD3DSIH_BFREV, SpvOpBitReverse}, {VKD3DSIH_COUNTBITS, SpvOpBitCount}, + {VKD3DSIH_DDIV, SpvOpFDiv}, {VKD3DSIH_DIV, SpvOpFDiv}, {VKD3DSIH_FTOI, SpvOpConvertFToS}, {VKD3DSIH_FTOU, SpvOpConvertFToU}, @@ -6555,6 +6557,7 @@ static SpvOp vkd3d_dxbc_compiler_map_alu_instruction(const struct vkd3d_shader_i {VKD3DSIH_ISHL, SpvOpShiftLeftLogical}, {VKD3DSIH_ISHR, SpvOpShiftRightArithmetic}, {VKD3DSIH_ITOF, SpvOpConvertSToF}, + {VKD3DSIH_DMUL, SpvOpFMul}, {VKD3DSIH_MUL, SpvOpFMul}, {VKD3DSIH_NOT, SpvOpNot}, {VKD3DSIH_OR, SpvOpBitwiseOr}, @@ -6758,14 +6761,20 @@ static void vkd3d_dxbc_compiler_emit_movc(struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_dst_param *dst = instruction->dst; const struct vkd3d_shader_src_param *src = instruction->src; uint32_t condition_id, src1_id, src2_id, type_id, val_id; + DWORD condition_mask = dst->write_mask; unsigned int component_count;
- condition_id = vkd3d_dxbc_compiler_emit_load_src(compiler, &src[0], dst->write_mask); + if (instruction->handler_idx == VKD3DSIH_DMOVC) + condition_mask = (condition_mask & VKD3DSP_WRITEMASK_0) | ((condition_mask & VKD3DSP_WRITEMASK_2) >> 1); + + condition_id = vkd3d_dxbc_compiler_emit_load_src(compiler, &src[0], condition_mask); src1_id = vkd3d_dxbc_compiler_emit_load_src(compiler, &src[1], dst->write_mask); src2_id = vkd3d_dxbc_compiler_emit_load_src(compiler, &src[2], dst->write_mask);
component_count = vkd3d_write_mask_component_count(dst->write_mask); type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_FLOAT, component_count); + component_count = vkd3d_write_mask_component_count_typed(dst->write_mask, dst->reg.data_type); + type_id = vkd3d_dxbc_compiler_get_type_id_for_dst(compiler, dst);
condition_id = vkd3d_dxbc_compiler_emit_int_to_bool(compiler, VKD3D_SHADER_CONDITIONAL_OP_NZ, component_count, condition_id); @@ -6850,12 +6859,12 @@ static void vkd3d_dxbc_compiler_emit_rcp(struct vkd3d_dxbc_compiler *compiler, uint32_t type_id, src_id, val_id; unsigned int component_count;
- component_count = vkd3d_write_mask_component_count(dst->write_mask); + component_count = vkd3d_write_mask_component_count_typed(dst->write_mask, dst->reg.data_type); type_id = vkd3d_dxbc_compiler_get_type_id_for_dst(compiler, dst);
src_id = vkd3d_dxbc_compiler_emit_load_src(compiler, src, dst->write_mask); - val_id = vkd3d_spirv_build_op_fdiv(builder, type_id, - vkd3d_dxbc_compiler_get_constant_float_vector(compiler, 1.0f, component_count), src_id); + val_id = vkd3d_spirv_build_op_fdiv(builder, type_id, vkd3d_dxbc_compiler_get_constant_float_vector(compiler, + 1.0f, component_count, src->reg.data_type), src_id); vkd3d_dxbc_compiler_emit_store_dst(compiler, dst, val_id); }
@@ -9240,19 +9249,23 @@ int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, case VKD3DSIH_HS_JOIN_PHASE: vkd3d_dxbc_compiler_enter_shader_phase(compiler, instruction); break; + case VKD3DSIH_DMOV: case VKD3DSIH_MOV: vkd3d_dxbc_compiler_emit_mov(compiler, instruction); break; + case VKD3DSIH_DMOVC: case VKD3DSIH_MOVC: vkd3d_dxbc_compiler_emit_movc(compiler, instruction); break; case VKD3DSIH_SWAPC: vkd3d_dxbc_compiler_emit_swapc(compiler, instruction); break; + case VKD3DSIH_DADD: case VKD3DSIH_ADD: case VKD3DSIH_AND: case VKD3DSIH_BFREV: case VKD3DSIH_COUNTBITS: + case VKD3DSIH_DDIV: case VKD3DSIH_DIV: case VKD3DSIH_FTOI: case VKD3DSIH_FTOU: @@ -9261,6 +9274,7 @@ int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, case VKD3DSIH_ISHL: case VKD3DSIH_ISHR: case VKD3DSIH_ITOF: + case VKD3DSIH_DMUL: case VKD3DSIH_MUL: case VKD3DSIH_NOT: case VKD3DSIH_OR: @@ -9295,6 +9309,7 @@ int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, case VKD3DSIH_DP2: vkd3d_dxbc_compiler_emit_dot(compiler, instruction); break; + case VKD3DSIH_DRCP: case VKD3DSIH_RCP: vkd3d_dxbc_compiler_emit_rcp(compiler, instruction); break; diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index dd12b896..3812b573 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -268,6 +268,12 @@ static const char * const shader_opcode_names[] = /* VKD3DSIH_USHR */ "ushr", /* VKD3DSIH_UTOF */ "utof", /* VKD3DSIH_XOR */ "xor", + /* VKD3DSIH_DADD */ "dadd", + /* VKD3DSIH_DMUL */ "dmul", + /* VKD3DSIH_DMOV */ "dmov", + /* VKD3DSIH_DMOVC */ "dmovc", + /* VKD3DSIH_DDIV */ "ddiv", + /* VKD3DSIH_DRCP */ "drcp", };
static const struct diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index f7a3c60e..d0fd25ee 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -354,6 +354,13 @@ enum vkd3d_shader_opcode VKD3DSIH_UTOF, VKD3DSIH_XOR,
+ VKD3DSIH_DADD, + VKD3DSIH_DMUL, + VKD3DSIH_DMOV, + VKD3DSIH_DMOVC, + VKD3DSIH_DDIV, + VKD3DSIH_DRCP, + VKD3DSIH_INVALID, };