-- v4: vkd3d-shader/dxil: Implement DX intrinsic MakeDouble. tests/hlsl: Add tests for asdouble().
From: Conor McCarthy cmccarthy@codeweavers.com
--- tests/hlsl/cast-64-bit.shader_test | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
diff --git a/tests/hlsl/cast-64-bit.shader_test b/tests/hlsl/cast-64-bit.shader_test index 1e33d8112..41a1af4d7 100644 --- a/tests/hlsl/cast-64-bit.shader_test +++ b/tests/hlsl/cast-64-bit.shader_test @@ -36,6 +36,37 @@ todo(sm<6) draw quad probe all rgbaui (0, 0xc0120000, 0x80000000, 0x40210000)
+[pixel shader todo] +uniform uint4 u; + +float4 main() : sv_target +{ + // Low bits, high bits + double2 d = asdouble(u.xz, u.yw); + return float4(d, 0, 0); +} + +[test] +uniform 0 uint4 0xc000000 0x40020000 0x80000000 0xc04be000 +todo draw quad +probe all rgba (2.25, -55.75001526, 0.0, 0.0) 1 + + +[pixel shader todo] +uniform uint2 u; + +float4 main() : sv_target +{ + double d = asdouble(u.x, u.y); + return float4(d, 0, 0, 0); +} + +[test] +uniform 0 uint4 0x80000000 0xc04be000 0 0 +todo draw quad +probe all rgba (-55.75001526, 0.0, 0.0, 0.0) 1 + + [require] shader model >= 6.0 int64
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/dxil.c | 28 ++++++++++++++++++++++++++++ tests/hlsl/cast-64-bit.shader_test | 4 ++-- 2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 0787ee139..c2c12aecb 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -410,6 +410,7 @@ enum dx_intrinsic_opcode DX_GROUP_ID = 94, DX_THREAD_ID_IN_GROUP = 95, DX_FLATTENED_THREAD_ID_IN_GROUP = 96, + DX_MAKE_DOUBLE = 101, DX_SPLIT_DOUBLE = 102, DX_LEGACY_F32TOF16 = 130, DX_LEGACY_F16TOF32 = 131, @@ -2372,6 +2373,12 @@ static void src_param_init_scalar(struct vkd3d_shader_src_param *param, unsigned param->modifiers = VKD3DSPSM_NONE; }
+static void src_param_init_vector(struct vkd3d_shader_src_param *param, unsigned int component_count) +{ + param->swizzle = VKD3D_SHADER_NO_SWIZZLE & ((1ull << VKD3D_SHADER_SWIZZLE_SHIFT(component_count)) - 1); + param->modifiers = VKD3DSPSM_NONE; +} + static void src_param_init_from_value(struct vkd3d_shader_src_param *param, const struct sm6_value *src) { src_param_init(param); @@ -4699,6 +4706,26 @@ static void sm6_parser_emit_dx_load_input(struct sm6_parser *sm6, enum dx_intrin instruction_dst_param_init_ssa_scalar(ins, sm6); }
+static void sm6_parser_emit_dx_make_double(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 reg; + + if (!sm6_parser_emit_composite_construct(sm6, &operands[0], 2, state, ®)) + return; + + ins = state->ins; + vsir_instruction_init(ins, &sm6->p.location, VKD3DSIH_MOV); + if (!(src_params = instruction_src_params_alloc(ins, 1, sm6))) + return; + src_params[0].reg = reg; + src_param_init_vector(&src_params[0], 2); + + instruction_dst_param_init_ssa_scalar(ins, sm6); +} + static void sm6_parser_emit_dx_raw_buffer_load(struct sm6_parser *sm6, enum dx_intrinsic_opcode op, const struct sm6_value **operands, struct function_emission_state *state) { @@ -5356,6 +5383,7 @@ static const struct sm6_dx_opcode_info sm6_dx_op_table[] = [DX_LEGACY_F32TOF16 ] = {"i", "f", sm6_parser_emit_dx_unary}, [DX_LOAD_INPUT ] = {"o", "ii8i", sm6_parser_emit_dx_load_input}, [DX_LOG ] = {"g", "R", sm6_parser_emit_dx_unary}, + [DX_MAKE_DOUBLE ] = {"d", "ii", sm6_parser_emit_dx_make_double}, [DX_RAW_BUFFER_LOAD ] = {"o", "Hii8i", sm6_parser_emit_dx_raw_buffer_load}, [DX_RAW_BUFFER_STORE ] = {"v", "Hiioooocc", sm6_parser_emit_dx_raw_buffer_store}, [DX_ROUND_NE ] = {"g", "R", sm6_parser_emit_dx_unary}, diff --git a/tests/hlsl/cast-64-bit.shader_test b/tests/hlsl/cast-64-bit.shader_test index 41a1af4d7..f488570e0 100644 --- a/tests/hlsl/cast-64-bit.shader_test +++ b/tests/hlsl/cast-64-bit.shader_test @@ -48,7 +48,7 @@ float4 main() : sv_target
[test] uniform 0 uint4 0xc000000 0x40020000 0x80000000 0xc04be000 -todo draw quad +todo(sm<6) draw quad probe all rgba (2.25, -55.75001526, 0.0, 0.0) 1
@@ -63,7 +63,7 @@ float4 main() : sv_target
[test] uniform 0 uint4 0x80000000 0xc04be000 0 0 -todo draw quad +todo(sm<6) draw quad probe all rgba (-55.75001526, 0.0, 0.0, 0.0) 1
This merge request was approved by Henri Verbeet.