From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d-shader/spirv.c | 13 ++++++++-----
tests/d3d12.c | 25 +++++++++++++++++++++++++
2 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index 9c51df14316e..41c49acd9270 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -4760,12 +4760,13 @@ static void vkd3d_dxbc_compiler_emit_f16tof32(struct vkd3d_dxbc_compiler *compil
static void vkd3d_dxbc_compiler_emit_f32tof16(struct vkd3d_dxbc_compiler *compiler,
const struct vkd3d_shader_instruction *instruction)
{
- uint32_t instr_set_id, type_id, scalar_type_id, src_id, zero_id, constituents[2], result_id;
+ uint32_t instr_set_id, type_id, scalar_type_id, src_id, zero_id, constituents[2];
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 components[VKD3D_VEC4_SIZE];
+ unsigned int i, j;
DWORD write_mask;
- unsigned int i;
instr_set_id = vkd3d_spirv_get_glsl_std450_instr_set(builder);
type_id = vkd3d_spirv_get_type_id(builder, VKD3D_TYPE_FLOAT, 2);
@@ -4773,7 +4774,7 @@ static void vkd3d_dxbc_compiler_emit_f32tof16(struct vkd3d_dxbc_compiler *compil
zero_id = vkd3d_dxbc_compiler_get_constant_float(compiler, 0.0f);
/* FIXME: Consider a single PackHalf2x16 intruction per 2 components. */
- for (i = 0; i < VKD3D_VEC4_SIZE; ++i)
+ for (i = 0, j = 0; i < VKD3D_VEC4_SIZE; ++i)
{
if (!(write_mask = dst->write_mask & (VKD3DSP_WRITEMASK_0 << i)))
continue;
@@ -4783,10 +4784,12 @@ static void vkd3d_dxbc_compiler_emit_f32tof16(struct vkd3d_dxbc_compiler *compil
constituents[1] = zero_id;
src_id = vkd3d_spirv_build_op_composite_construct(builder,
type_id, constituents, ARRAY_SIZE(constituents));
- result_id = vkd3d_spirv_build_op_ext_inst(builder, scalar_type_id,
+ components[j++] = vkd3d_spirv_build_op_ext_inst(builder, scalar_type_id,
instr_set_id, GLSLstd450PackHalf2x16, &src_id, 1);
- vkd3d_dxbc_compiler_emit_store_reg(compiler, &dst->reg, write_mask, result_id);
}
+
+ vkd3d_dxbc_compiler_emit_store_dst_components(compiler,
+ dst, vkd3d_component_type_from_data_type(dst->reg.data_type), components);
}
static void vkd3d_dxbc_compiler_emit_comparison_instruction(struct vkd3d_dxbc_compiler *compiler,
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 0ef382f46103..a63e122f7232 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -6608,6 +6608,29 @@ static void test_shader_instructions(void)
0x06000082, 0x001020f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x0100003e,
};
static const D3D12_SHADER_BYTECODE ps_f32tof16 = {ps_f32tof16_code, sizeof(ps_f32tof16_code)};
+ static const DWORD ps_f32tof16_2_code[] =
+ {
+#if 0
+ ps_5_0
+ dcl_globalFlags refactoringAllowed
+ dcl_constantbuffer cb0[1], immediateIndexed
+ dcl_output o0.xyzw
+ dcl_temps 1
+ mov r0.xyzw, cb0[0].xyzw
+ f32tof16 r0.xyzw, r0.wzyx
+ mov o0.xyzw, r0.xyzw
+ ret
+#endif
+ 0x43425844, 0x607c82d2, 0x940cc7c2, 0xe9de23c6, 0x696beb90, 0x00000001, 0x000000ec, 0x00000003,
+ 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000074, 0x00000050, 0x0000001d,
+ 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
+ 0x02000068, 0x00000001, 0x06000036, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000,
+ 0x05000082, 0x001000f2, 0x00000000, 0x001001b6, 0x00000000, 0x05000036, 0x001020f2, 0x00000000,
+ 0x00100e46, 0x00000000, 0x0100003e,
+ };
+ static const D3D12_SHADER_BYTECODE ps_f32tof16_2 = {ps_f32tof16_2_code, sizeof(ps_f32tof16_2_code)};
static const DWORD ps_imad_code[] =
{
#if 0
@@ -7355,6 +7378,8 @@ static void test_shader_instructions(void)
{&ps_f32tof16, {.f = {{0.0f, 1.0f, -1.0f, 666.0f}}}, {{0, 0x3c00, 0xbc00, 0x6134}}},
+ {&ps_f32tof16_2, {.f = {{0.0f, 1.0f, -1.0f, 666.0f}}}, {{0x6134, 0xbc00, 0x3c00, 0}}},
+
{&ps_imad, {{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}}, {{ 0, 0, 0, 0}}},
{&ps_imad, {{{0, 0, 0, 0}, {0, 0, 0, 0}, {1, 2, 0, 0}}}, {{ 1, 2, 0, 0}}},
{&ps_imad, {{{2, 3, 4, 5}, {5, 5, 5, 5}, {0, 0, 0, 0}}}, {{10, 15, 20, 25}}},
--
2.18.1