=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: vkd3d-shader: Fix f16tof32 instruction.
Alexandre Julliard
julliard at winehq.org
Thu Oct 18 15:02:36 CDT 2018
Module: vkd3d
Branch: master
Commit: dc9fdf5d31f95c94fdb7c1f958d15a7c22ef1a5e
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=dc9fdf5d31f95c94fdb7c1f958d15a7c22ef1a5e
Author: Józef Kucia <jkucia at codeweavers.com>
Date: Thu Oct 18 14:59:43 2018 +0200
vkd3d-shader: Fix f16tof32 instruction.
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
libs/vkd3d-shader/spirv.c | 11 +++++++----
tests/d3d12.c | 28 ++++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index 1d97a98..9c51df1 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -4732,15 +4732,16 @@ static void vkd3d_dxbc_compiler_emit_f16tof32(struct vkd3d_dxbc_compiler *compil
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);
scalar_type_id = vkd3d_spirv_get_type_id(builder, VKD3D_TYPE_FLOAT, 1);
/* FIXME: Consider a single UnpackHalf2x16 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;
@@ -4748,10 +4749,12 @@ static void vkd3d_dxbc_compiler_emit_f16tof32(struct vkd3d_dxbc_compiler *compil
src_id = vkd3d_dxbc_compiler_emit_load_src(compiler, src, write_mask);
result_id = vkd3d_spirv_build_op_ext_inst(builder, type_id,
instr_set_id, GLSLstd450UnpackHalf2x16, &src_id, 1);
- result_id = vkd3d_spirv_build_op_composite_extract1(builder,
+ components[j++] = vkd3d_spirv_build_op_composite_extract1(builder,
scalar_type_id, result_id, 0);
- 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_f32tof16(struct vkd3d_dxbc_compiler *compiler,
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 34c4802..0ef382f 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -6567,6 +6567,29 @@ static void test_shader_instructions(void)
0x0500001c, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e,
};
static const D3D12_SHADER_BYTECODE ps_f16tof32 = {ps_f16tof32_code, sizeof(ps_f16tof32_code)};
+ static const DWORD ps_f16tof32_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
+ f16tof32 r0.xyzw, r0.wzyx
+ ftou o0.xyzw, r0.xyzw
+ ret
+#endif
+ 0x43425844, 0x38472f03, 0x2c49b7dd, 0xc2d76bbf, 0xfc093e1d, 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,
+ 0x05000083, 0x001000f2, 0x00000000, 0x001001b6, 0x00000000, 0x0500001c, 0x001020f2, 0x00000000,
+ 0x00100e46, 0x00000000, 0x0100003e,
+ };
+ static const D3D12_SHADER_BYTECODE ps_f16tof32_2 = {ps_f16tof32_2_code, sizeof(ps_f16tof32_2_code)};
static const DWORD ps_f32tof16_code[] =
{
#if 0
@@ -7325,6 +7348,11 @@ static void test_shader_instructions(void)
{&ps_f16tof32, {{{0x000f0000, 0x000f3c00, 0x000f5640, 0x000f5bd0}}}, {{0, 1, 100, 250}}},
{&ps_f16tof32, {{{0xffff0000, 0xffff3c00, 0xffff5640, 0xffff5bd0}}}, {{0, 1, 100, 250}}},
+ {&ps_f16tof32_2, {{{0x00000000, 0x00003c00, 0x00005640, 0x00005bd0}}}, {{250, 100, 1, 0}}},
+ {&ps_f16tof32_2, {{{0x00010000, 0x00013c00, 0x00015640, 0x00015bd0}}}, {{250, 100, 1, 0}}},
+ {&ps_f16tof32_2, {{{0x000f0000, 0x000f3c00, 0x000f5640, 0x000f5bd0}}}, {{250, 100, 1, 0}}},
+ {&ps_f16tof32_2, {{{0xffff0000, 0xffff3c00, 0xffff5640, 0xffff5bd0}}}, {{250, 100, 1, 0}}},
+
{&ps_f32tof16, {.f = {{0.0f, 1.0f, -1.0f, 666.0f}}}, {{0, 0x3c00, 0xbc00, 0x6134}}},
{&ps_imad, {{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}}, {{ 0, 0, 0, 0}}},
More information about the wine-cvs
mailing list