Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- tests/d3d12.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/tests/d3d12.c b/tests/d3d12.c index ae1394b0..2b1830bd 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -9365,6 +9365,31 @@ static void test_shader_instructions(void) 0x00000021, 0x00000000, }; static const struct named_shader ps_dtoi = {"dtoi", ps_dtoi_code, sizeof(ps_dtoi_code)}; + static const DWORD ps_dtof_code[] = + { +#if 0 + double src0; + + void main(out uint4 dst : SV_Target) + { + float2 f = float2(src0, -src0); + dst.x = asuint(f.x); + dst.y = asuint(f.y); + dst.zw = 0; + } +#endif + 0x43425844, 0xa920927f, 0xac06725f, 0x310edf68, 0xec6ab7cd, 0x00000001, 0x00000128, 0x00000004, + 0x00000030, 0x00000040, 0x00000074, 0x00000118, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000009c, 0x00000050, + 0x00000027, 0x0100186a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, + 0x00000000, 0x02000068, 0x00000001, 0x060000c9, 0x00100012, 0x00000000, 0x00208446, 0x00000000, + 0x00000000, 0x070000c9, 0x00100022, 0x00000000, 0x80208446, 0x00000041, 0x00000000, 0x00000000, + 0x05000036, 0x00102032, 0x00000000, 0x00100046, 0x00000000, 0x08000036, 0x001020c2, 0x00000000, + 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0100003e, 0x30494653, 0x00000008, + 0x00000001, 0x00000000, + }; + static const struct named_shader ps_dtof = {"dtof", ps_dtof_code, sizeof(ps_dtof_code)}; static const DWORD ps_utod_code[] = { #if 0 @@ -10004,6 +10029,7 @@ static void test_shader_instructions(void) {&ps_dtou, {.d = {{ -1.0}}}, {{ 0, 1 }}, true, true}, {&ps_dtou, {.d = {{ 1.0}}}, {{ 1, 0 }}, true, true}, {&ps_dtoi, {.d = {{ 1.0}}}, {.i = {1, -1}}, true, true}, + {&ps_dtof, {.d = {{ 1.5}}}, {.f = {1.5f, -1.5f}}, true, true}, {&ps_utod, {.u = {{3, 0xffffffff}}}, {.d = {3.0, 4294967295.0}}, true, true}, {&ps_itod, {.u = {{3, INT_MIN}}}, {.d = {3.0, -2147483648.0}}, true, true}, {&ps_ftod, {.f = {{-2.5f, -2.5f}}}, {.d = {-2.5, 2.5}}, true, true},
Based on a vkd3d-proton patch by Joshua Ashton.
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d-shader/dxbc.c | 1 + libs/vkd3d-shader/sm4.h | 1 + libs/vkd3d-shader/spirv.c | 30 ++++++++++++++++++++++++ libs/vkd3d-shader/trace.c | 1 + libs/vkd3d-shader/vkd3d_shader_private.h | 1 + tests/d3d12.c | 2 +- 6 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index fab19046..0c590563 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -807,6 +807,7 @@ static const struct vkd3d_sm4_opcode_info opcode_table[] = {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_FTOD, VKD3DSIH_FTOD, "d", "f"}, {VKD3D_SM5_OP_EVAL_SAMPLE_INDEX, VKD3DSIH_EVAL_SAMPLE_INDEX, "f", "fi"}, {VKD3D_SM5_OP_EVAL_CENTROID, VKD3DSIH_EVAL_CENTROID, "f", "f"}, {VKD3D_SM5_OP_DCL_GS_INSTANCES, VKD3DSIH_DCL_GS_INSTANCES, "", "", diff --git a/libs/vkd3d-shader/sm4.h b/libs/vkd3d-shader/sm4.h index 335f0161..5f4f22db 100644 --- a/libs/vkd3d-shader/sm4.h +++ b/libs/vkd3d-shader/sm4.h @@ -327,6 +327,7 @@ enum vkd3d_sm4_opcode VKD3D_SM5_OP_DNE = 0xc6, VKD3D_SM5_OP_DMOV = 0xc7, VKD3D_SM5_OP_DMOVC = 0xc8, + VKD3D_SM5_OP_FTOD = 0xca, VKD3D_SM5_OP_EVAL_SAMPLE_INDEX = 0xcc, VKD3D_SM5_OP_EVAL_CENTROID = 0xcd, VKD3D_SM5_OP_DCL_GS_INSTANCES = 0xce, diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 5729ea1a..fef81c7b 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -9322,6 +9322,33 @@ static void vkd3d_dxbc_compiler_emit_cut_stream(struct vkd3d_dxbc_compiler *comp vkd3d_spirv_build_op_end_primitive(builder); }
+static void vkd3d_dxbc_compiler_emit_double_conversion(struct vkd3d_dxbc_compiler *compiler, + const struct vkd3d_shader_instruction *instruction) +{ + struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; + const struct vkd3d_shader_dst_param *dst = instruction->dst; + const struct vkd3d_shader_src_param *src = instruction->src; + uint32_t src_id, val_id, type_id; + SpvOp op; + + switch (instruction->handler_idx) + { + case VKD3DSIH_FTOD: op = SpvOpFConvert; break; + default: + ERR("Unexpected instruction %#x.\n", instruction->handler_idx); + return; + } + + src_id = vkd3d_dxbc_compiler_emit_load_src(compiler, src, dst->write_mask); + + type_id = vkd3d_spirv_get_type_id(builder, vkd3d_component_type_from_data_type(dst->reg.data_type), + vkd3d_write_mask_component_count(dst->write_mask)); + + val_id = vkd3d_spirv_build_op_trv(builder, &builder->function_stream, op, type_id, &src_id, 1); + + vkd3d_dxbc_compiler_emit_store_dst(compiler, dst, val_id); +} + static void vkd3d_dxbc_compiler_emit_hull_shader_inputs(struct vkd3d_dxbc_compiler *compiler) { const struct vkd3d_shader_signature *signature = compiler->input_signature; @@ -9730,6 +9757,9 @@ int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, case VKD3DSIH_CUT_STREAM: vkd3d_dxbc_compiler_emit_cut_stream(compiler, instruction); break; + case VKD3DSIH_FTOD: + vkd3d_dxbc_compiler_emit_double_conversion(compiler, instruction); + break; case VKD3DSIH_DCL_HS_MAX_TESSFACTOR: case VKD3DSIH_HS_DECLS: case VKD3DSIH_NOP: diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index 830a5fc7..8f93e1bd 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -147,6 +147,7 @@ static const char * const shader_opcode_names[] = /* VKD3DSIH_FIRSTBIT_LO */ "firstbit_lo", /* VKD3DSIH_FIRSTBIT_SHI */ "firstbit_shi", /* VKD3DSIH_FRC */ "frc", + /* VKD3DSIH_FTOD */ "ftod", /* VKD3DSIH_FTOI */ "ftoi", /* VKD3DSIH_FTOU */ "ftou", /* VKD3DSIH_GATHER4 */ "gather4", diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 9948045e..7400be51 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -236,6 +236,7 @@ enum vkd3d_shader_opcode VKD3DSIH_FIRSTBIT_LO, VKD3DSIH_FIRSTBIT_SHI, VKD3DSIH_FRC, + VKD3DSIH_FTOD, VKD3DSIH_FTOI, VKD3DSIH_FTOU, VKD3DSIH_GATHER4, diff --git a/tests/d3d12.c b/tests/d3d12.c index 2b1830bd..4c03b81e 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -10032,7 +10032,7 @@ static void test_shader_instructions(void) {&ps_dtof, {.d = {{ 1.5}}}, {.f = {1.5f, -1.5f}}, true, true}, {&ps_utod, {.u = {{3, 0xffffffff}}}, {.d = {3.0, 4294967295.0}}, true, true}, {&ps_itod, {.u = {{3, INT_MIN}}}, {.d = {3.0, -2147483648.0}}, true, true}, - {&ps_ftod, {.f = {{-2.5f, -2.5f}}}, {.d = {-2.5, 2.5}}, true, true}, + {&ps_ftod, {.f = {{-2.5f, -2.5f}}}, {.d = {-2.5, 2.5}}, true}, {&ps_dmul, {.d = {{ 1.5, 3.0}}}, {.d = { 4.5, -4.5}}, true}, {&ps_ddiv, {.d = {{ 2.0, 4.0}}}, {.d = { 0.5, 2.0}}, true}, {&ps_ddiv, {.d = {{ 2.0, -4.0}}}, {.d = {-0.5, -2.0}}, true},
On Wed, 11 Aug 2021 at 05:14, Conor McCarthy cmccarthy@codeweavers.com wrote:
+static void vkd3d_dxbc_compiler_emit_double_conversion(struct vkd3d_dxbc_compiler *compiler,
const struct vkd3d_shader_instruction *instruction)
+{
- struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
- const struct vkd3d_shader_dst_param *dst = instruction->dst;
- const struct vkd3d_shader_src_param *src = instruction->src;
- uint32_t src_id, val_id, type_id;
- SpvOp op;
- switch (instruction->handler_idx)
- {
case VKD3DSIH_FTOD: op = SpvOpFConvert; break;
default:
ERR("Unexpected instruction %#x.\n", instruction->handler_idx);
return;
- }
- src_id = vkd3d_dxbc_compiler_emit_load_src(compiler, src, dst->write_mask);
- type_id = vkd3d_spirv_get_type_id(builder, vkd3d_component_type_from_data_type(dst->reg.data_type),
vkd3d_write_mask_component_count(dst->write_mask));
- val_id = vkd3d_spirv_build_op_trv(builder, &builder->function_stream, op, type_id, &src_id, 1);
- vkd3d_dxbc_compiler_emit_store_dst(compiler, dst, val_id);
+}
This seems suspiciously similar to what vkd3d_dxbc_compiler_emit_alu_instruction() does; any reason we can't use that?
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d-shader/dxbc.c | 1 + libs/vkd3d-shader/sm4.h | 1 + libs/vkd3d-shader/spirv.c | 2 ++ libs/vkd3d-shader/trace.c | 1 + libs/vkd3d-shader/vkd3d_shader_private.h | 1 + tests/d3d12.c | 2 +- 6 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 0c590563..86ba18a2 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -807,6 +807,7 @@ static const struct vkd3d_sm4_opcode_info opcode_table[] = {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_DTOF, VKD3DSIH_DTOF, "f", "d"}, {VKD3D_SM5_OP_FTOD, VKD3DSIH_FTOD, "d", "f"}, {VKD3D_SM5_OP_EVAL_SAMPLE_INDEX, VKD3DSIH_EVAL_SAMPLE_INDEX, "f", "fi"}, {VKD3D_SM5_OP_EVAL_CENTROID, VKD3DSIH_EVAL_CENTROID, "f", "f"}, diff --git a/libs/vkd3d-shader/sm4.h b/libs/vkd3d-shader/sm4.h index 5f4f22db..34b90c85 100644 --- a/libs/vkd3d-shader/sm4.h +++ b/libs/vkd3d-shader/sm4.h @@ -327,6 +327,7 @@ enum vkd3d_sm4_opcode VKD3D_SM5_OP_DNE = 0xc6, VKD3D_SM5_OP_DMOV = 0xc7, VKD3D_SM5_OP_DMOVC = 0xc8, + VKD3D_SM5_OP_DTOF = 0xc9, VKD3D_SM5_OP_FTOD = 0xca, VKD3D_SM5_OP_EVAL_SAMPLE_INDEX = 0xcc, VKD3D_SM5_OP_EVAL_CENTROID = 0xcd, diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index fef81c7b..84df3781 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -9333,6 +9333,7 @@ static void vkd3d_dxbc_compiler_emit_double_conversion(struct vkd3d_dxbc_compile
switch (instruction->handler_idx) { + case VKD3DSIH_DTOF: case VKD3DSIH_FTOD: op = SpvOpFConvert; break; default: ERR("Unexpected instruction %#x.\n", instruction->handler_idx); @@ -9757,6 +9758,7 @@ int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, case VKD3DSIH_CUT_STREAM: vkd3d_dxbc_compiler_emit_cut_stream(compiler, instruction); break; + case VKD3DSIH_DTOF: case VKD3DSIH_FTOD: vkd3d_dxbc_compiler_emit_double_conversion(compiler, instruction); break; diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index 8f93e1bd..eab3882b 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -128,6 +128,7 @@ static const char * const shader_opcode_names[] = /* VKD3DSIH_DSY */ "dsy", /* VKD3DSIH_DSY_COARSE */ "deriv_rty_coarse", /* VKD3DSIH_DSY_FINE */ "deriv_rty_fine", + /* VKD3DSIH_DTOF */ "dtof", /* VKD3DSIH_ELSE */ "else", /* VKD3DSIH_EMIT */ "emit", /* VKD3DSIH_EMIT_STREAM */ "emit_stream", diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 7400be51..8980e641 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -217,6 +217,7 @@ enum vkd3d_shader_opcode VKD3DSIH_DSY, VKD3DSIH_DSY_COARSE, VKD3DSIH_DSY_FINE, + VKD3DSIH_DTOF, VKD3DSIH_ELSE, VKD3DSIH_EMIT, VKD3DSIH_EMIT_STREAM, diff --git a/tests/d3d12.c b/tests/d3d12.c index 4c03b81e..f409ac66 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -10029,7 +10029,7 @@ static void test_shader_instructions(void) {&ps_dtou, {.d = {{ -1.0}}}, {{ 0, 1 }}, true, true}, {&ps_dtou, {.d = {{ 1.0}}}, {{ 1, 0 }}, true, true}, {&ps_dtoi, {.d = {{ 1.0}}}, {.i = {1, -1}}, true, true}, - {&ps_dtof, {.d = {{ 1.5}}}, {.f = {1.5f, -1.5f}}, true, true}, + {&ps_dtof, {.d = {{ 1.5}}}, {.f = {1.5f, -1.5f}}, true}, {&ps_utod, {.u = {{3, 0xffffffff}}}, {.d = {3.0, 4294967295.0}}, true, true}, {&ps_itod, {.u = {{3, INT_MIN}}}, {.d = {3.0, -2147483648.0}}, true, true}, {&ps_ftod, {.f = {{-2.5f, -2.5f}}}, {.d = {-2.5, 2.5}}, true},
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d-shader/dxbc.c | 1 + libs/vkd3d-shader/sm4.h | 1 + libs/vkd3d-shader/spirv.c | 2 ++ libs/vkd3d-shader/trace.c | 1 + libs/vkd3d-shader/vkd3d_shader_private.h | 1 + tests/d3d12.c | 2 +- 6 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 86ba18a2..2b30dd4a 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -816,6 +816,7 @@ static const struct vkd3d_sm4_opcode_info opcode_table[] = {VKD3D_SM5_OP_DDIV, VKD3DSIH_DDIV, "d", "dd"}, {VKD3D_SM5_OP_DFMA, VKD3DSIH_DFMA, "d", "ddd"}, {VKD3D_SM5_OP_DRCP, VKD3DSIH_DRCP, "d", "d"}, + {VKD3D_SM5_OP_DTOI, VKD3DSIH_DTOI, "i", "d"}, };
static const enum vkd3d_shader_register_type register_type_table[] = diff --git a/libs/vkd3d-shader/sm4.h b/libs/vkd3d-shader/sm4.h index 34b90c85..4aefa990 100644 --- a/libs/vkd3d-shader/sm4.h +++ b/libs/vkd3d-shader/sm4.h @@ -335,6 +335,7 @@ enum vkd3d_sm4_opcode VKD3D_SM5_OP_DDIV = 0xd2, VKD3D_SM5_OP_DFMA = 0xd3, VKD3D_SM5_OP_DRCP = 0xd4, + VKD3D_SM5_OP_DTOI = 0xd6, };
enum vkd3d_sm4_instruction_modifier diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 84df3781..a15735f5 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -9335,6 +9335,7 @@ static void vkd3d_dxbc_compiler_emit_double_conversion(struct vkd3d_dxbc_compile { case VKD3DSIH_DTOF: case VKD3DSIH_FTOD: op = SpvOpFConvert; break; + case VKD3DSIH_DTOI: op = SpvOpConvertFToS; break; default: ERR("Unexpected instruction %#x.\n", instruction->handler_idx); return; @@ -9759,6 +9760,7 @@ int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, vkd3d_dxbc_compiler_emit_cut_stream(compiler, instruction); break; case VKD3DSIH_DTOF: + case VKD3DSIH_DTOI: case VKD3DSIH_FTOD: vkd3d_dxbc_compiler_emit_double_conversion(compiler, instruction); break; diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index eab3882b..5c28e00a 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -129,6 +129,7 @@ static const char * const shader_opcode_names[] = /* VKD3DSIH_DSY_COARSE */ "deriv_rty_coarse", /* VKD3DSIH_DSY_FINE */ "deriv_rty_fine", /* VKD3DSIH_DTOF */ "dtof", + /* VKD3DSIH_DTOI */ "dtoi", /* VKD3DSIH_ELSE */ "else", /* VKD3DSIH_EMIT */ "emit", /* VKD3DSIH_EMIT_STREAM */ "emit_stream", diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 8980e641..7f2db6d1 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -218,6 +218,7 @@ enum vkd3d_shader_opcode VKD3DSIH_DSY_COARSE, VKD3DSIH_DSY_FINE, VKD3DSIH_DTOF, + VKD3DSIH_DTOI, VKD3DSIH_ELSE, VKD3DSIH_EMIT, VKD3DSIH_EMIT_STREAM, diff --git a/tests/d3d12.c b/tests/d3d12.c index f409ac66..d68ab75e 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -10028,7 +10028,7 @@ static void test_shader_instructions(void) {&ps_dtou, {.d = {{ INFINITY}}}, {{~0u, 0 }}, true, true}, {&ps_dtou, {.d = {{ -1.0}}}, {{ 0, 1 }}, true, true}, {&ps_dtou, {.d = {{ 1.0}}}, {{ 1, 0 }}, true, true}, - {&ps_dtoi, {.d = {{ 1.0}}}, {.i = {1, -1}}, true, true}, + {&ps_dtoi, {.d = {{ 1.0}}}, {.i = {1, -1}}, true}, {&ps_dtof, {.d = {{ 1.5}}}, {.f = {1.5f, -1.5f}}, true}, {&ps_utod, {.u = {{3, 0xffffffff}}}, {.d = {3.0, 4294967295.0}}, true, true}, {&ps_itod, {.u = {{3, INT_MIN}}}, {.d = {3.0, -2147483648.0}}, true, true},
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d-shader/dxbc.c | 1 + libs/vkd3d-shader/sm4.h | 1 + libs/vkd3d-shader/spirv.c | 2 ++ libs/vkd3d-shader/trace.c | 1 + libs/vkd3d-shader/vkd3d_shader_private.h | 1 + tests/d3d12.c | 12 ++++++------ 6 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 2b30dd4a..2beb2ccb 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -817,6 +817,7 @@ static const struct vkd3d_sm4_opcode_info opcode_table[] = {VKD3D_SM5_OP_DFMA, VKD3DSIH_DFMA, "d", "ddd"}, {VKD3D_SM5_OP_DRCP, VKD3DSIH_DRCP, "d", "d"}, {VKD3D_SM5_OP_DTOI, VKD3DSIH_DTOI, "i", "d"}, + {VKD3D_SM5_OP_DTOU, VKD3DSIH_DTOU, "u", "d"}, };
static const enum vkd3d_shader_register_type register_type_table[] = diff --git a/libs/vkd3d-shader/sm4.h b/libs/vkd3d-shader/sm4.h index 4aefa990..a88447d1 100644 --- a/libs/vkd3d-shader/sm4.h +++ b/libs/vkd3d-shader/sm4.h @@ -336,6 +336,7 @@ enum vkd3d_sm4_opcode VKD3D_SM5_OP_DFMA = 0xd3, VKD3D_SM5_OP_DRCP = 0xd4, VKD3D_SM5_OP_DTOI = 0xd6, + VKD3D_SM5_OP_DTOU = 0xd7, };
enum vkd3d_sm4_instruction_modifier diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index a15735f5..35cc62fd 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -9336,6 +9336,7 @@ static void vkd3d_dxbc_compiler_emit_double_conversion(struct vkd3d_dxbc_compile case VKD3DSIH_DTOF: case VKD3DSIH_FTOD: op = SpvOpFConvert; break; case VKD3DSIH_DTOI: op = SpvOpConvertFToS; break; + case VKD3DSIH_DTOU: op = SpvOpConvertFToU; break; default: ERR("Unexpected instruction %#x.\n", instruction->handler_idx); return; @@ -9761,6 +9762,7 @@ int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, break; case VKD3DSIH_DTOF: case VKD3DSIH_DTOI: + case VKD3DSIH_DTOU: case VKD3DSIH_FTOD: vkd3d_dxbc_compiler_emit_double_conversion(compiler, instruction); break; diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index 5c28e00a..0d5c06b5 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -130,6 +130,7 @@ static const char * const shader_opcode_names[] = /* VKD3DSIH_DSY_FINE */ "deriv_rty_fine", /* VKD3DSIH_DTOF */ "dtof", /* VKD3DSIH_DTOI */ "dtoi", + /* VKD3DSIH_DTOU */ "dtou", /* VKD3DSIH_ELSE */ "else", /* VKD3DSIH_EMIT */ "emit", /* VKD3DSIH_EMIT_STREAM */ "emit_stream", diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 7f2db6d1..fba3764c 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -219,6 +219,7 @@ enum vkd3d_shader_opcode VKD3DSIH_DSY_FINE, VKD3DSIH_DTOF, VKD3DSIH_DTOI, + VKD3DSIH_DTOU, VKD3DSIH_ELSE, VKD3DSIH_EMIT, VKD3DSIH_EMIT_STREAM, diff --git a/tests/d3d12.c b/tests/d3d12.c index d68ab75e..6091d540 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -10022,12 +10022,12 @@ static void test_shader_instructions(void) {&ps_dge, {.d = {{1.5, 1.0}}}, {{0xffffffff}}, true}, {&ps_dlt, {.d = {{0.0, 1.0}}}, {{0xffffffff}}, true}, {&ps_dlt, {.d = {{1.0, 1.0}}}, {{0x00000000}}, true}, - {&ps_dtou, {.d = {{ -NAN}}}, {{ 0, 0 }}, true, true}, - {&ps_dtou, {.d = {{ NAN}}}, {{ 0, 0 }}, true, true}, - {&ps_dtou, {.d = {{-INFINITY}}}, {{ 0, ~0u}}, true, true}, - {&ps_dtou, {.d = {{ INFINITY}}}, {{~0u, 0 }}, true, true}, - {&ps_dtou, {.d = {{ -1.0}}}, {{ 0, 1 }}, true, true}, - {&ps_dtou, {.d = {{ 1.0}}}, {{ 1, 0 }}, true, true}, + {&ps_dtou, {.d = {{ -NAN}}}, {{ 0, 0 }}, true}, + {&ps_dtou, {.d = {{ NAN}}}, {{ 0, 0 }}, true}, + {&ps_dtou, {.d = {{-INFINITY}}}, {{ 0, ~0u}}, true}, + {&ps_dtou, {.d = {{ INFINITY}}}, {{~0u, 0 }}, true}, + {&ps_dtou, {.d = {{ -1.0}}}, {{ 0, 1 }}, true}, + {&ps_dtou, {.d = {{ 1.0}}}, {{ 1, 0 }}, true}, {&ps_dtoi, {.d = {{ 1.0}}}, {.i = {1, -1}}, true}, {&ps_dtof, {.d = {{ 1.5}}}, {.f = {1.5f, -1.5f}}, true}, {&ps_utod, {.u = {{3, 0xffffffff}}}, {.d = {3.0, 4294967295.0}}, true, true},
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d-shader/dxbc.c | 1 + libs/vkd3d-shader/sm4.h | 1 + libs/vkd3d-shader/spirv.c | 2 ++ libs/vkd3d-shader/trace.c | 1 + libs/vkd3d-shader/vkd3d_shader_private.h | 1 + tests/d3d12.c | 2 +- 6 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 2beb2ccb..8762094e 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -818,6 +818,7 @@ static const struct vkd3d_sm4_opcode_info opcode_table[] = {VKD3D_SM5_OP_DRCP, VKD3DSIH_DRCP, "d", "d"}, {VKD3D_SM5_OP_DTOI, VKD3DSIH_DTOI, "i", "d"}, {VKD3D_SM5_OP_DTOU, VKD3DSIH_DTOU, "u", "d"}, + {VKD3D_SM5_OP_ITOD, VKD3DSIH_ITOD, "d", "i"}, };
static const enum vkd3d_shader_register_type register_type_table[] = diff --git a/libs/vkd3d-shader/sm4.h b/libs/vkd3d-shader/sm4.h index a88447d1..c04fa02b 100644 --- a/libs/vkd3d-shader/sm4.h +++ b/libs/vkd3d-shader/sm4.h @@ -337,6 +337,7 @@ enum vkd3d_sm4_opcode VKD3D_SM5_OP_DRCP = 0xd4, VKD3D_SM5_OP_DTOI = 0xd6, VKD3D_SM5_OP_DTOU = 0xd7, + VKD3D_SM5_OP_ITOD = 0xd8, };
enum vkd3d_sm4_instruction_modifier diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 35cc62fd..26d10838 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -9337,6 +9337,7 @@ static void vkd3d_dxbc_compiler_emit_double_conversion(struct vkd3d_dxbc_compile case VKD3DSIH_FTOD: op = SpvOpFConvert; break; case VKD3DSIH_DTOI: op = SpvOpConvertFToS; break; case VKD3DSIH_DTOU: op = SpvOpConvertFToU; break; + case VKD3DSIH_ITOD: op = SpvOpConvertSToF; break; default: ERR("Unexpected instruction %#x.\n", instruction->handler_idx); return; @@ -9764,6 +9765,7 @@ int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, case VKD3DSIH_DTOI: case VKD3DSIH_DTOU: case VKD3DSIH_FTOD: + case VKD3DSIH_ITOD: vkd3d_dxbc_compiler_emit_double_conversion(compiler, instruction); break; case VKD3DSIH_DCL_HS_MAX_TESSFACTOR: diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index 0d5c06b5..0dc18f4e 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -189,6 +189,7 @@ static const char * const shader_opcode_names[] = /* VKD3DSIH_INEG */ "ineg", /* VKD3DSIH_ISHL */ "ishl", /* VKD3DSIH_ISHR */ "ishr", + /* VKD3DSIH_ITOD */ "itod", /* VKD3DSIH_ITOF */ "itof", /* VKD3DSIH_LABEL */ "label", /* VKD3DSIH_LD */ "ld", diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index fba3764c..aa04cb45 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -278,6 +278,7 @@ enum vkd3d_shader_opcode VKD3DSIH_INEG, VKD3DSIH_ISHL, VKD3DSIH_ISHR, + VKD3DSIH_ITOD, VKD3DSIH_ITOF, VKD3DSIH_LABEL, VKD3DSIH_LD, diff --git a/tests/d3d12.c b/tests/d3d12.c index 6091d540..b6a773ec 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -10031,7 +10031,7 @@ static void test_shader_instructions(void) {&ps_dtoi, {.d = {{ 1.0}}}, {.i = {1, -1}}, true}, {&ps_dtof, {.d = {{ 1.5}}}, {.f = {1.5f, -1.5f}}, true}, {&ps_utod, {.u = {{3, 0xffffffff}}}, {.d = {3.0, 4294967295.0}}, true, true}, - {&ps_itod, {.u = {{3, INT_MIN}}}, {.d = {3.0, -2147483648.0}}, true, true}, + {&ps_itod, {.u = {{3, INT_MIN}}}, {.d = {3.0, -2147483648.0}}, true}, {&ps_ftod, {.f = {{-2.5f, -2.5f}}}, {.d = {-2.5, 2.5}}, true}, {&ps_dmul, {.d = {{ 1.5, 3.0}}}, {.d = { 4.5, -4.5}}, true}, {&ps_ddiv, {.d = {{ 2.0, 4.0}}}, {.d = { 0.5, 2.0}}, true},
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d-shader/dxbc.c | 1 + libs/vkd3d-shader/sm4.h | 1 + libs/vkd3d-shader/spirv.c | 2 ++ libs/vkd3d-shader/trace.c | 1 + libs/vkd3d-shader/vkd3d_shader_private.h | 1 + tests/d3d12.c | 2 +- 6 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 8762094e..5dfe9295 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -819,6 +819,7 @@ static const struct vkd3d_sm4_opcode_info opcode_table[] = {VKD3D_SM5_OP_DTOI, VKD3DSIH_DTOI, "i", "d"}, {VKD3D_SM5_OP_DTOU, VKD3DSIH_DTOU, "u", "d"}, {VKD3D_SM5_OP_ITOD, VKD3DSIH_ITOD, "d", "i"}, + {VKD3D_SM5_OP_UTOD, VKD3DSIH_UTOD, "d", "u"}, };
static const enum vkd3d_shader_register_type register_type_table[] = diff --git a/libs/vkd3d-shader/sm4.h b/libs/vkd3d-shader/sm4.h index c04fa02b..5622d6df 100644 --- a/libs/vkd3d-shader/sm4.h +++ b/libs/vkd3d-shader/sm4.h @@ -338,6 +338,7 @@ enum vkd3d_sm4_opcode VKD3D_SM5_OP_DTOI = 0xd6, VKD3D_SM5_OP_DTOU = 0xd7, VKD3D_SM5_OP_ITOD = 0xd8, + VKD3D_SM5_OP_UTOD = 0xd9, };
enum vkd3d_sm4_instruction_modifier diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 26d10838..700258af 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -9338,6 +9338,7 @@ static void vkd3d_dxbc_compiler_emit_double_conversion(struct vkd3d_dxbc_compile case VKD3DSIH_DTOI: op = SpvOpConvertFToS; break; case VKD3DSIH_DTOU: op = SpvOpConvertFToU; break; case VKD3DSIH_ITOD: op = SpvOpConvertSToF; break; + case VKD3DSIH_UTOD: op = SpvOpConvertUToF; break; default: ERR("Unexpected instruction %#x.\n", instruction->handler_idx); return; @@ -9766,6 +9767,7 @@ int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, case VKD3DSIH_DTOU: case VKD3DSIH_FTOD: case VKD3DSIH_ITOD: + case VKD3DSIH_UTOD: vkd3d_dxbc_compiler_emit_double_conversion(compiler, instruction); break; case VKD3DSIH_DCL_HS_MAX_TESSFACTOR: diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index 0dc18f4e..df0ebf05 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -284,6 +284,7 @@ static const char * const shader_opcode_names[] = /* VKD3DSIH_UMIN */ "umin", /* VKD3DSIH_UMUL */ "umul", /* VKD3DSIH_USHR */ "ushr", + /* VKD3DSIH_UTOD */ "utod", /* VKD3DSIH_UTOF */ "utof", /* VKD3DSIH_XOR */ "xor", }; diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index aa04cb45..a9c4e758 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -373,6 +373,7 @@ enum vkd3d_shader_opcode VKD3DSIH_UMIN, VKD3DSIH_UMUL, VKD3DSIH_USHR, + VKD3DSIH_UTOD, VKD3DSIH_UTOF, VKD3DSIH_XOR,
diff --git a/tests/d3d12.c b/tests/d3d12.c index b6a773ec..6bc03b0b 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -10030,7 +10030,7 @@ static void test_shader_instructions(void) {&ps_dtou, {.d = {{ 1.0}}}, {{ 1, 0 }}, true}, {&ps_dtoi, {.d = {{ 1.0}}}, {.i = {1, -1}}, true}, {&ps_dtof, {.d = {{ 1.5}}}, {.f = {1.5f, -1.5f}}, true}, - {&ps_utod, {.u = {{3, 0xffffffff}}}, {.d = {3.0, 4294967295.0}}, true, true}, + {&ps_utod, {.u = {{3, 0xffffffff}}}, {.d = {3.0, 4294967295.0}}, true}, {&ps_itod, {.u = {{3, INT_MIN}}}, {.d = {3.0, -2147483648.0}}, true}, {&ps_ftod, {.f = {{-2.5f, -2.5f}}}, {.d = {-2.5, 2.5}}, true}, {&ps_dmul, {.d = {{ 1.5, 3.0}}}, {.d = { 4.5, -4.5}}, true},