vkd3d-shader/dxil: Implement DX intrinsics Cos and Sin.

This commit is contained in:
Conor McCarthy 2023-06-14 23:11:21 +10:00 committed by Alexandre Julliard
parent d7ffdd7340
commit 2a260b8d56
Notes: Alexandre Julliard 2024-01-25 23:10:02 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/595
2 changed files with 28 additions and 2 deletions

View File

@ -331,6 +331,8 @@ enum dx_intrinsic_opcode
DX_ISNAN = 8,
DX_ISINF = 9,
DX_ISFINITE = 10,
DX_COS = 12,
DX_SIN = 13,
DX_EXP = 21,
DX_FRC = 22,
DX_LOG = 23,
@ -3752,6 +3754,28 @@ static void sm6_parser_emit_dx_buffer_load(struct sm6_parser *sm6, enum dx_intri
instruction_dst_param_init_ssa_vector(ins, VKD3D_VEC4_SIZE, sm6);
}
static void sm6_parser_emit_dx_sincos(struct sm6_parser *sm6, enum dx_intrinsic_opcode op,
const struct sm6_value **operands, struct function_emission_state *state)
{
struct sm6_value *dst = sm6_parser_get_current_value(sm6);
struct vkd3d_shader_instruction *ins = state->ins;
struct vkd3d_shader_dst_param *dst_params;
struct vkd3d_shader_src_param *src_param;
unsigned int index;
vsir_instruction_init(ins, &sm6->p.location, VKD3DSIH_SINCOS);
src_param = instruction_src_params_alloc(ins, 1, sm6);
src_param_init_from_value(src_param, operands[0]);
index = op == DX_COS;
dst_params = instruction_dst_params_alloc(ins, 2, sm6);
dst_param_init(&dst_params[0]);
dst_param_init(&dst_params[1]);
register_init_ssa_scalar(&dst_params[index].reg, dst->type, sm6);
vsir_register_init(&dst_params[index ^ 1].reg, VKD3DSPR_NULL, VKD3D_DATA_UNUSED, 0);
dst->u.reg = dst_params[index].reg;
}
static void sm6_parser_emit_dx_store_output(struct sm6_parser *sm6, enum dx_intrinsic_opcode op,
const struct sm6_value **operands, struct function_emission_state *state)
{
@ -3834,6 +3858,7 @@ static const struct sm6_dx_opcode_info sm6_dx_op_table[] =
[DX_BFREV ] = {"m", "R", sm6_parser_emit_dx_unary},
[DX_BUFFER_LOAD ] = {"o", "Hii", sm6_parser_emit_dx_buffer_load},
[DX_CBUFFER_LOAD_LEGACY ] = {"o", "Hi", sm6_parser_emit_dx_cbuffer_load},
[DX_COS ] = {"g", "R", sm6_parser_emit_dx_sincos},
[DX_COUNT_BITS ] = {"i", "m", sm6_parser_emit_dx_unary},
[DX_CREATE_HANDLE ] = {"H", "ccib", sm6_parser_emit_dx_create_handle},
[DX_DERIV_COARSEX ] = {"e", "R", sm6_parser_emit_dx_unary},
@ -3861,6 +3886,7 @@ static const struct sm6_dx_opcode_info sm6_dx_op_table[] =
[DX_ROUND_PI ] = {"g", "R", sm6_parser_emit_dx_unary},
[DX_ROUND_Z ] = {"g", "R", sm6_parser_emit_dx_unary},
[DX_RSQRT ] = {"g", "R", sm6_parser_emit_dx_unary},
[DX_SIN ] = {"g", "R", sm6_parser_emit_dx_sincos},
[DX_SQRT ] = {"g", "R", sm6_parser_emit_dx_unary},
[DX_STORE_OUTPUT ] = {"v", "ii8o", sm6_parser_emit_dx_store_output},
[DX_UMAX ] = {"m", "RR", sm6_parser_emit_dx_binary},

View File

@ -42,7 +42,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 0.0 0.52359877 2.61799387 3.14159265
todo(sm<4 | sm>=6) draw quad
todo(sm<4) draw quad
probe all rgba (0.0, 500.0, 500.0, 0.0)
@ -56,7 +56,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 0.0 0.78539816 1.57079632 2.35619449
todo(sm<4 | sm>=6) draw quad
todo(sm<4) draw quad
probe all rgba (1000.0, 707.0, -0.0, -707.0)