diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index c2c12aec..b5a61d99 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -382,6 +382,9 @@ enum dx_intrinsic_opcode DX_UMAD = 49, DX_IBFE = 51, DX_UBFE = 52, + DX_DOT2 = 54, + DX_DOT3 = 55, + DX_DOT4 = 56, DX_CREATE_HANDLE = 57, DX_CBUFFER_LOAD_LEGACY = 59, DX_SAMPLE = 60, @@ -4480,6 +4483,48 @@ static void sm6_parser_emit_dx_discard(struct sm6_parser *sm6, enum dx_intrinsic src_param_init_from_value(src_param, operands[0]); } +static void sm6_parser_emit_dx_dot(struct sm6_parser *sm6, enum dx_intrinsic_opcode op, + const struct sm6_value **operands, struct function_emission_state *state) +{ + struct vkd3d_shader_src_param *src_params; + struct vkd3d_shader_instruction *ins; + struct vkd3d_shader_register regs[2]; + enum vkd3d_shader_opcode handler_idx; + unsigned int component_count; + + switch (op) + { + case DX_DOT2: + handler_idx = VKD3DSIH_DP2; + component_count = 2; + break; + case DX_DOT3: + handler_idx = VKD3DSIH_DP3; + component_count = 3; + break; + case DX_DOT4: + handler_idx = VKD3DSIH_DP4; + component_count = 4; + break; + default: + vkd3d_unreachable(); + } + + if (!sm6_parser_emit_composite_construct(sm6, &operands[0], component_count, state, ®s[0])) + return; + if (!sm6_parser_emit_composite_construct(sm6, &operands[component_count], component_count, state, ®s[1])) + return; + + ins = state->ins; + vsir_instruction_init(ins, &sm6->p.location, handler_idx); + if (!(src_params = instruction_src_params_alloc(ins, 2, sm6))) + return; + src_param_init_vector_from_reg(&src_params[0], ®s[0]); + src_param_init_vector_from_reg(&src_params[1], ®s[1]); + + instruction_dst_param_init_ssa_scalar(ins, sm6); +} + static void sm6_parser_emit_dx_fabs(struct sm6_parser *sm6, enum dx_intrinsic_opcode op, const struct sm6_value **operands, struct function_emission_state *state) { @@ -5356,6 +5401,9 @@ static const struct sm6_dx_opcode_info sm6_dx_op_table[] = [DX_DERIV_FINEX ] = {"e", "R", sm6_parser_emit_dx_unary}, [DX_DERIV_FINEY ] = {"e", "R", sm6_parser_emit_dx_unary}, [DX_DISCARD ] = {"v", "1", sm6_parser_emit_dx_discard}, + [DX_DOT2 ] = {"g", "RRRR", sm6_parser_emit_dx_dot}, + [DX_DOT3 ] = {"g", "RRRRRR", sm6_parser_emit_dx_dot}, + [DX_DOT4 ] = {"g", "RRRRRRRR", sm6_parser_emit_dx_dot}, [DX_EXP ] = {"g", "R", sm6_parser_emit_dx_unary}, [DX_FABS ] = {"g", "R", sm6_parser_emit_dx_fabs}, [DX_FIRST_BIT_HI ] = {"i", "m", sm6_parser_emit_dx_unary}, diff --git a/tests/hlsl/dot.shader_test b/tests/hlsl/dot.shader_test index 87bb82d1..7698c08e 100644 --- a/tests/hlsl/dot.shader_test +++ b/tests/hlsl/dot.shader_test @@ -10,7 +10,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 2.0 3.0 4.0 5.0 uniform 4 float4 10.0 11.0 12.0 13.0 -todo(sm>=6 | glsl) draw quad +todo(glsl) draw quad probe all rgba (166.0, 166.0, 166.0, 166.0) [pixel shader] @@ -25,7 +25,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 2.0 3.0 0.0 0.0 uniform 4 float4 10.0 11.0 12.0 13.0 -todo(sm<4 | sm>=6 | glsl) draw quad +todo(sm<4 | glsl) draw quad probe all rgba (53.0, 53.0, 53.0, 53.0) [pixel shader] @@ -40,7 +40,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 2.0 0.0 0.0 0.0 uniform 4 float4 10.0 11.0 12.0 13.0 -todo(sm>=6 | glsl) draw quad +todo(glsl) draw quad probe all rgba (92.0, 92.0, 92.0, 92.0) [pixel shader] @@ -55,7 +55,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 10.0 11.0 12.0 13.0 uniform 4 float4 2.0 0.0 0.0 0.0 -todo(sm>=6 | glsl) draw quad +todo(glsl) draw quad probe all rgba (92.0, 92.0, 92.0, 92.0) [pixel shader] diff --git a/tests/hlsl/normalize.shader_test b/tests/hlsl/normalize.shader_test index d30e7efa..3f89e280 100644 --- a/tests/hlsl/normalize.shader_test +++ b/tests/hlsl/normalize.shader_test @@ -8,7 +8,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 2.0 3.0 4.0 5.0 -todo(sm>=6 | glsl) draw quad +todo(glsl) draw quad probe all rgba (0.272165537, 0.408248305, 0.544331074, 0.680413842) 2 [pixel shader] @@ -21,7 +21,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 2.0 3.0 4.0 0.0 -todo(sm>=6 | glsl) draw quad +todo(glsl) draw quad probe all rgba (0.371390700, 0.557086051, 0.742781401, 0.0) 1 [pixel shader] @@ -34,7 +34,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 2.0 3.0 0.0 0.0 -todo(sm<4 | sm>=6 | glsl) draw quad +todo(sm<4 | glsl) draw quad probe all rgba (0.554700196, 0.832050323, 0.0, 0.0) 1 [pixel shader] diff --git a/tests/hlsl/reflect.shader_test b/tests/hlsl/reflect.shader_test index 601f26bb..1b3123c8 100644 --- a/tests/hlsl/reflect.shader_test +++ b/tests/hlsl/reflect.shader_test @@ -10,7 +10,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.5 -0.1 0.2 0.3 uniform 4 float4 0.6 0.4 -0.3 1.0 -todo(sm>=6 | glsl) draw quad +todo(glsl) draw quad probe all rgba (-0.1, -0.5, 0.5, -0.7) 4 [pixel shader] @@ -27,7 +27,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.5 0.0 0.0 0.0 uniform 4 float4 0.6 0.4 -0.3 1.0 -todo(sm>=6 | glsl) draw quad +todo(glsl) draw quad probe all rgba (-0.52, -0.18, 1.01, -1.2) 4 [pixel shader] @@ -44,7 +44,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.5 -0.1 0.2 0.3 uniform 4 float4 0.6 0.0 0.0 0.0 -todo(sm>=6 | glsl) draw quad +todo(glsl) draw quad probe all rgba (-0.148, -0.748, -0.448, -0.348) 4 [pixel shader] @@ -79,7 +79,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.5 -0.1 0.0 0.0 uniform 4 float4 0.6 0.4 -0.3 1.0 -todo(sm<4 | sm>=6 | glsl) draw quad +todo(sm<4 | glsl) draw quad probe all rgba (0.188, -0.308, 0.0, 0.0) 4 [pixel shader] @@ -97,5 +97,5 @@ float4 main() : sv_target [test] uniform 0 float4 0.5 -0.1 0.2 0.0 uniform 4 float4 0.6 0.4 0.0 0.0 -todo(sm<4 | sm>=6 | glsl) draw quad +todo(sm<4 | glsl) draw quad probe all rgba (0.188, -0.308, 0.0, 0.0) 4