Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- tests/d3d12.c | 384 +++++++++++++++++++++++++++++++++++++++ tests/d3d12_test_utils.h | 2 +- 2 files changed, 385 insertions(+), 1 deletion(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c index a84a8e28..c613ff4d 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -41,6 +41,11 @@ struct ivec4 int x, y, z, w; };
+struct dvec2 +{ + double x, y; +}; + static bool compare_uvec4(const struct uvec4* v1, const struct uvec4 *v2) { return v1->x == v2->x && v1->y == v2->y && v1->z == v2->z && v1->w == v2->w; @@ -651,6 +656,21 @@ static bool is_memory_pool_L1_supported(ID3D12Device *device) return !architecture.UMA; }
+static bool is_shader_float64_supported(ID3D12Device *device) +{ + D3D12_FEATURE_DATA_D3D12_OPTIONS options; + HRESULT hr; + + if (FAILED(hr = ID3D12Device_CheckFeatureSupport(device, + D3D12_FEATURE_D3D12_OPTIONS, &options, sizeof(options)))) + { + trace("Failed to check feature support, hr %#x.\n", hr); + return false; + } + + return options.DoublePrecisionFloatShaderOps; +} + #define create_cb_root_signature(a, b, c, e) create_cb_root_signature_(__LINE__, a, b, c, e) static ID3D12RootSignature *create_cb_root_signature_(unsigned int line, ID3D12Device *device, unsigned int reg_idx, D3D12_SHADER_VISIBILITY shader_visibility, @@ -7510,6 +7530,7 @@ static void test_shader_instructions(void) D3D12_SHADER_BYTECODE shader; struct test_context context; ID3D12CommandQueue *queue; + bool test_shader_float64; ID3D12Resource *cb; unsigned int i; HRESULT hr; @@ -9054,6 +9075,322 @@ static void test_shader_instructions(void) 0x00100e46, 0x00000001, 0x0100003e, }; static struct named_shader ps_swapc5 = {"swapc5", ps_swapc5_code, sizeof(ps_swapc5_code)}; + static const DWORD ps_dmov_code[] = + { +#if 0 + double2 src0; + + void main(out uint4 dst : SV_Target) + { + asuint(-src0.y, dst.x, dst.y); + asuint(-src0.x, dst.z, dst.w); + } +#endif + 0x43425844, 0x16bd7e63, 0x6b535ab7, 0xb7f182c2, 0x6f3819a8, 0x00000001, 0x000000f0, 0x00000004, + 0x00000030, 0x00000040, 0x00000074, 0x000000e0, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000064, 0x00000050, + 0x00000019, 0x0100186a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, + 0x00000000, 0x02000068, 0x00000001, 0x070000c7, 0x001000f2, 0x00000000, 0x802084e6, 0x00000041, + 0x00000000, 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e, + 0x30494653, 0x00000008, 0x00000001, 0x00000000, + }; + static struct named_shader ps_dmov = {"dmov", ps_dmov_code, sizeof(ps_dmov_code)}; + static const DWORD ps_dadd_code[] = + { + /* Also test constant double2 vector. */ +#if 0 + double src0; + + void main(out uint4 dst : SV_Target) + { + double2 a = double2(src0 + 1.0000002433080226l, src0 + 2.000000481493771l); + asuint(a.x, dst.x, dst.y); + asuint(a.y, dst.z, dst.w); + } +#endif + 0x43425844, 0x23e20252, 0xf4d2708e, 0x87956944, 0xc61e7052, 0x00000001, 0x00000100, 0x00000004, + 0x00000030, 0x00000040, 0x00000074, 0x000000f0, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000074, 0x00000050, + 0x0000001d, 0x0100186a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, + 0x00000000, 0x02000068, 0x00000001, 0x0b0000bf, 0x001000f2, 0x00000000, 0x00208446, 0x00000000, + 0x00000000, 0x00005002, 0x41500000, 0x3ff00000, 0x40a00000, 0x40000000, 0x05000036, 0x001020f2, + 0x00000000, 0x00100e46, 0x00000000, 0x0100003e, 0x30494653, 0x00000008, 0x00000001, 0x00000000, + }; + static struct named_shader ps_dadd = {"dadd", ps_dadd_code, sizeof(ps_dadd_code)}; + static const DWORD ps_dmin_dmax_code[] = + { +#if 0 + double2 src0; + + void main(out uint4 dst : SV_Target) + { + asuint(min(src0.x, src0.y), dst.x, dst.y); + asuint(max(src0.x, src0.y), dst.z, dst.w); + } +#endif + 0x43425844, 0x6f8b547e, 0x3552757c, 0x92a81fa1, 0x00990b21, 0x00000001, 0x00000130, 0x00000004, + 0x00000030, 0x00000040, 0x00000074, 0x00000120, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000a4, 0x00000050, + 0x00000029, 0x0100186a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, + 0x00000000, 0x02000068, 0x00000001, 0x090000c1, 0x00100032, 0x00000000, 0x00208ee6, 0x00000000, + 0x00000000, 0x00208446, 0x00000000, 0x00000000, 0x05000036, 0x00102032, 0x00000000, 0x00100046, + 0x00000000, 0x090000c0, 0x00100032, 0x00000000, 0x00208ee6, 0x00000000, 0x00000000, 0x00208446, + 0x00000000, 0x00000000, 0x05000036, 0x001020c2, 0x00000000, 0x00100406, 0x00000000, 0x0100003e, + 0x30494653, 0x00000008, 0x00000001, 0x00000000, + }; + static struct named_shader ps_dmin_dmax = {"dmin_dmax", ps_dmin_dmax_code, sizeof(ps_dmin_dmax_code)}; + static const DWORD ps_dmovc_code[] = + { +#if 0 + double2 src0; + + void main(out uint4 dst : SV_Target) + { + double2 a = src0.x > 1.0 ? src0 : double2(4.5, 4.5); + asuint(a.x, dst.x, dst.y); + asuint(a.y, dst.z, dst.w); + } +#endif + 0x43425844, 0xe3bae03a, 0x16178729, 0xc59e7f4a, 0x218fecac, 0x00000001, 0x00000134, 0x00000004, + 0x00000030, 0x00000040, 0x00000074, 0x00000124, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000a8, 0x00000050, + 0x0000002a, 0x0100186a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, + 0x00000000, 0x02000068, 0x00000001, 0x0b0000c5, 0x00100012, 0x00000000, 0x00005002, 0x00000000, + 0x3ff00000, 0x00000000, 0x00000000, 0x00208446, 0x00000000, 0x00000000, 0x0d0000c8, 0x001000f2, + 0x00000000, 0x00100006, 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00005002, 0x00000000, + 0x40120000, 0x00000000, 0x40120000, 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, + 0x0100003e, 0x30494653, 0x00000008, 0x00000001, 0x00000000, + }; + static struct named_shader ps_dmovc = {"dmovc", ps_dmovc_code, sizeof(ps_dmovc_code)}; + static const DWORD ps_dmodifier_code[] = + { + /* Already tested negation in the dmov test. */ +#if 0 + double src0; + + void main(out uint4 dst : SV_Target) + { + asuint(abs(src0), dst.x, dst.y); + asuint(saturate(src0) + 1.5, dst.z, dst.w); + } +#endif + 0x43425844, 0x15bb537e, 0x47ef3ae3, 0xba88acf7, 0x0b3624e0, 0x00000001, 0x00000144, 0x00000004, + 0x00000030, 0x00000040, 0x00000074, 0x00000134, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000b8, 0x00000050, + 0x0000002e, 0x0100186a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, + 0x00000000, 0x02000068, 0x00000001, 0x060020c7, 0x00100032, 0x00000000, 0x00208446, 0x00000000, + 0x00000000, 0x0a0000bf, 0x00100032, 0x00000000, 0x00100446, 0x00000000, 0x00005002, 0x00000000, + 0x3ff80000, 0x00000000, 0x00000000, 0x05000036, 0x001020c2, 0x00000000, 0x00100406, 0x00000000, + 0x070000c7, 0x00100032, 0x00000000, 0x80208446, 0x00000081, 0x00000000, 0x00000000, 0x05000036, + 0x00102032, 0x00000000, 0x00100046, 0x00000000, 0x0100003e, 0x30494653, 0x00000008, 0x00000001, + 0x00000000, + }; + static struct named_shader ps_dmodifier = {"dmodifier", ps_dmodifier_code, sizeof(ps_dmodifier_code)}; + static const DWORD ps_deq_code[] = + { +#if 0 + double2 src0; + + void main(out uint4 dst : SV_Target) + { + dst = (uint4)0; + if (src0.x == src0.y) + dst.x = 0xffffffff; + } +#endif + 0x43425844, 0x24c9cee6, 0xd38c521f, 0xcde7c8b6, 0xc173a8e3, 0x00000001, 0x00000118, 0x00000004, + 0x00000030, 0x00000040, 0x00000074, 0x00000108, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000008c, 0x00000050, + 0x00000023, 0x0100186a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, + 0x00000000, 0x02000068, 0x00000001, 0x090000c3, 0x00100012, 0x00000000, 0x00208ee6, 0x00000000, + 0x00000000, 0x00208446, 0x00000000, 0x00000000, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, + 0x00000000, 0x08000036, 0x001020e2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x0100003e, 0x30494653, 0x00000008, 0x00000001, 0x00000000, + }; + static struct named_shader ps_deq = {"deq", ps_deq_code, sizeof(ps_deq_code)}; + static const DWORD ps_dne_code[] = + { +#if 0 + double2 src0; + + void main(out uint4 dst : SV_Target) + { + dst = (uint4)0; + if (src0.x != src0.y) + dst.x = 0xffffffff; + } +#endif + 0x43425844, 0x99700929, 0x3b743000, 0xdfc89958, 0xfc2b89ab, 0x00000001, 0x00000118, 0x00000004, + 0x00000030, 0x00000040, 0x00000074, 0x00000108, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000008c, 0x00000050, + 0x00000023, 0x0100186a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, + 0x00000000, 0x02000068, 0x00000001, 0x090000c6, 0x00100012, 0x00000000, 0x00208ee6, 0x00000000, + 0x00000000, 0x00208446, 0x00000000, 0x00000000, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, + 0x00000000, 0x08000036, 0x001020e2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x0100003e, 0x30494653, 0x00000008, 0x00000001, 0x00000000, + }; + static struct named_shader ps_dne = {"dne", ps_dne_code, sizeof(ps_dne_code)}; + static const DWORD ps_dtou_code[] = + { +#if 0 + double src0; + + void main(out uint4 dst : SV_Target) + { + dst = uint4(src0, -src0, 0, 0); + } +#endif + 0x43425844, 0x6ca74abd, 0xe970e02d, 0xa65b35db, 0xd2f58586, 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, 0x0102186a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, + 0x00000000, 0x02000068, 0x00000001, 0x060000d7, 0x00100012, 0x00000000, 0x00208446, 0x00000000, + 0x00000000, 0x070000d7, 0x00100022, 0x00000000, 0x80208446, 0x00000041, 0x00000000, 0x00000000, + 0x05000036, 0x00102032, 0x00000000, 0x00100046, 0x00000000, 0x08000036, 0x001020c2, 0x00000000, + 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0100003e, 0x30494653, 0x00000008, + 0x00000021, 0x00000000, + }; + static struct named_shader ps_dtou = {"dtou", ps_dtou_code, sizeof(ps_dtou_code)}; + static const DWORD ps_dtoi_code[] = + { +#if 0 + double src0; + + void main(out uint4 dst : SV_Target) + { + dst = int4(src0, -src0, 0, 0); + } +#endif + 0x43425844, 0x38d82727, 0x8666b36c, 0x91954b7e, 0xf376163a, 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, 0x0102186a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, + 0x00000000, 0x02000068, 0x00000001, 0x060000d6, 0x00100012, 0x00000000, 0x00208446, 0x00000000, + 0x00000000, 0x070000d6, 0x00100022, 0x00000000, 0x80208446, 0x00000041, 0x00000000, 0x00000000, + 0x05000036, 0x00102032, 0x00000000, 0x00100046, 0x00000000, 0x08000036, 0x001020c2, 0x00000000, + 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0100003e, 0x30494653, 0x00000008, + 0x00000021, 0x00000000, + }; + static const struct named_shader ps_dtoi = {"dtoi", ps_dtoi_code, sizeof(ps_dtoi_code)}; + static const DWORD ps_utod_code[] = + { +#if 0 + uint2 src0; + + void main(out uint4 dst : SV_Target) + { + double2 a = src0; + asuint(a.x, dst.x, dst.y); + asuint(a.y, dst.z, dst.w); + } +#endif + 0x43425844, 0x05733379, 0x8683d4b9, 0x718f0111, 0x28153519, 0x00000001, 0x000000ec, 0x00000004, + 0x00000030, 0x00000040, 0x00000074, 0x000000dc, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000060, 0x00000050, + 0x00000018, 0x0102186a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, + 0x00000000, 0x02000068, 0x00000001, 0x060000d9, 0x001000f2, 0x00000000, 0x00208046, 0x00000000, + 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e, 0x30494653, + 0x00000008, 0x00000021, 0x00000000, + }; + static struct named_shader ps_utod = {"utod", ps_utod_code, sizeof(ps_utod_code)}; + static const DWORD ps_itod_code[] = + { +#if 0 + int2 src0; + + void main(out uint4 dst : SV_Target) + { + double2 a = src0; + asuint(a.x, dst.x, dst.y); + asuint(a.y, dst.z, dst.w); + } +#endif + 0x43425844, 0xbf96ef6f, 0x3ca9fd26, 0xd9b5cfc6, 0x4ef98f41, 0x00000001, 0x000000ec, 0x00000004, + 0x00000030, 0x00000040, 0x00000074, 0x000000dc, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000060, 0x00000050, + 0x00000018, 0x0102186a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, + 0x00000000, 0x02000068, 0x00000001, 0x060000d8, 0x001000f2, 0x00000000, 0x00208046, 0x00000000, + 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e, 0x30494653, + 0x00000008, 0x00000021, 0x00000000, + }; + static struct named_shader ps_itod = {"itod", ps_itod_code, sizeof(ps_itod_code)}; + static const DWORD ps_ftod_code[] = + { +#if 0 + float2 src0; + + void main(out uint4 dst : SV_Target) + { + double2 a = double2(src0.x, -src0.y); + asuint(a.x, dst.x, dst.y); + asuint(a.y, dst.z, dst.w); + } +#endif + 0x43425844, 0xef37cacc, 0x9ff35467, 0x0c9af3ed, 0x01e295eb, 0x00000001, 0x00000108, 0x00000004, + 0x00000030, 0x00000040, 0x00000074, 0x000000f8, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000007c, 0x00000050, + 0x0000001f, 0x0100186a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, + 0x00000000, 0x02000068, 0x00000001, 0x060000ca, 0x00100032, 0x00000000, 0x0020800a, 0x00000000, + 0x00000000, 0x070000ca, 0x001000c2, 0x00000000, 0x8020801a, 0x00000041, 0x00000000, 0x00000000, + 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e, 0x30494653, 0x00000008, + 0x00000001, 0x00000000, + }; + static struct named_shader ps_ftod = {"ftod", ps_ftod_code, sizeof(ps_ftod_code)}; + static const DWORD ps_ddiv_code[] = + { +#if 0 + double2 src0; + + void main(out uint4 dst : SV_Target) + { + asuint(src0.x / src0.y, dst.x, dst.y); + asuint(src0.y / src0.x, dst.z, dst.w); + } +#endif + 0x43425844, 0x6570ff79, 0xe1fd64a5, 0xb44313bb, 0xb5fdfa06, 0x00000001, 0x000000f8, 0x00000004, + 0x00000030, 0x00000040, 0x00000074, 0x000000e8, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000006c, 0x00000050, + 0x0000001b, 0x0102186a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, + 0x00000000, 0x02000068, 0x00000001, 0x090000d2, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, + 0x00000000, 0x002084e6, 0x00000000, 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, + 0x00000000, 0x0100003e, 0x30494653, 0x00000008, 0x00000021, 0x00000000, + }; + static const struct named_shader ps_ddiv = {"ddiv", ps_ddiv_code, sizeof(ps_ddiv_code)}; + static const DWORD ps_drcp_code[] = + { +#if 0 + double2 src0; + + void main(out uint4 dst : SV_Target) + { + double2 a = rcp(src0); + asuint(a.x, dst.x, dst.y); + asuint(a.y, dst.z, dst.w); + } +#endif + 0x43425844, 0xdcbd25ba, 0x2d5cccb9, 0x84ed8028, 0x3d62632a, 0x00000001, 0x000000ec, 0x00000004, + 0x00000030, 0x00000040, 0x00000074, 0x000000dc, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000060, 0x00000050, + 0x00000018, 0x0102186a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, + 0x00000000, 0x02000068, 0x00000001, 0x060000d4, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, + 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e, 0x30494653, + 0x00000008, 0x00000021, 0x00000000, + }; + static struct named_shader ps_drcp = {"drcp", ps_drcp_code, sizeof(ps_drcp_code)}; static const struct { const struct named_shader *ps; @@ -9290,13 +9627,22 @@ static void test_shader_instructions(void) struct vec4 src1; struct vec4 src2; } f; + struct + { + struct dvec2 src0; + struct dvec2 src1; + struct dvec2 src2; + } d; } input; union { struct uvec4 u; struct ivec4 i; struct vec4 f; + struct dvec2 d; } output; + bool is_float64; + bool is_todo; bool skip_on_warp; } uint_tests[] = @@ -9526,6 +9872,31 @@ static void test_shader_instructions(void) {&ps_movc, {{{0, 1, 1, 0}, {1, 2, 3, 4}, {5, 6, 7, 8}}}, {{5, 2, 3, 8}}}, {&ps_movc, {{{1, 1, 1, 1}, {1, 2, 3, 4}, {5, 6, 7, 8}}}, {{1, 2, 3, 4}}},
+ {&ps_dmov, {.d = {{2.5 + 1.0e-9, -3.5 - 1.0e-9}}}, {.d = {3.5 + 1.0e-9, -2.5 - 1.0e-9}}, true, true}, + {&ps_dadd, {.d = {{2.5, 0.0}}}, {.d = {2.5 + 1.0000002433080226, 2.5 + 2.000000481493771}}, true, true}, + {&ps_dmin_dmax, {.d = {{-1.0, 1.0}}}, {.d = {-1.0, 1.0}}, true, true}, + {&ps_dmovc, {.d = {{0.5, 0.0}}}, {.d = {4.5, 4.5}}, true, true}, + {&ps_dmovc, {.d = {{1.5, 0.0}}}, {.d = {1.5, 0.0}}, true, true}, + {&ps_dmodifier, {.d = {{1.5, 0.0}}}, {.d = {1.5f, 2.5f}}, true, true}, + {&ps_dmodifier, {.d = {{-1.5, 0.0}}}, {.d = {1.5f, 1.5f}}, true, true}, + {&ps_deq, {.d = {{0.0, 0.0}}}, {{0xffffffff}}, true, true}, + {&ps_deq, {.d = {{1.0, 0.0}}}, {{0x00000000}}, true, true}, + {&ps_dne, {.d = {{0.0, 0.0}}}, {{0x00000000}}, true, true}, + {&ps_dne, {.d = {{1.0, 0.0}}}, {{0xffffffff}}, true, 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_dtoi, {.d = {{ 1.0}}}, {.i = {1, -1}}, 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_ddiv, {.d = {{ 2.0, 4.0}}}, {.d = { 0.5, 2.0}}, true, true}, + {&ps_ddiv, {.d = {{ 2.0, -4.0}}}, {.d = {-0.5, -2.0}}, true, true}, + {&ps_drcp, {.d = {{ 2.0, -0.5}}}, {.d = { 0.5, -2.0}}, true, true}, + { &ps_swapc0, {{{0, 0, 0, 0}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}}}, @@ -9818,6 +10189,7 @@ static void test_shader_instructions(void) return; command_list = context.list; queue = context.queue; + test_shader_float64 = is_shader_float64_supported(context.device);
context.root_signature = create_cb_root_signature(context.device, 0, D3D12_SHADER_VISIBILITY_PIXEL, D3D12_ROOT_SIGNATURE_FLAG_NONE); @@ -9888,6 +10260,12 @@ static void test_shader_instructions(void) continue; }
+ if (uint_tests[i].is_float64 && !test_shader_float64) + { + skip("Skipping shader '%s' float64 test.\n", uint_tests[i].ps->name); + continue; + } + if (current_ps != uint_tests[i].ps) { if (context.pipeline_state) @@ -9895,8 +10273,14 @@ static void test_shader_instructions(void) current_ps = uint_tests[i].ps; shader.pShaderBytecode = current_ps->code; shader.BytecodeLength = current_ps->size; + todo_if(uint_tests[i].is_todo) context.pipeline_state = create_pipeline_state(context.device, context.root_signature, desc.rt_format, NULL, &shader, NULL); + if (!context.pipeline_state) + { + current_ps = NULL; + continue; + } }
update_buffer_data(cb, 0, sizeof(uint_tests[i].input), &uint_tests[i].input); diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h index a1e039de..5fe6f1ef 100644 --- a/tests/d3d12_test_utils.h +++ b/tests/d3d12_test_utils.h @@ -836,7 +836,7 @@ static ID3D12PipelineState *create_pipeline_state_(unsigned int line, ID3D12Devi const D3D12_INPUT_LAYOUT_DESC *input_layout) { D3D12_GRAPHICS_PIPELINE_STATE_DESC pipeline_state_desc; - ID3D12PipelineState *pipeline_state; + ID3D12PipelineState *pipeline_state = NULL; HRESULT hr;
init_pipeline_state_desc(&pipeline_state_desc, root_signature, rt_format, vs, ps, input_layout);
Based on a vkd3d-proton patch by Joshua Ashton.
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d-shader/spirv.c | 6 ++++++ libs/vkd3d-shader/vkd3d_shader_private.h | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 664f05b6..60acd5d7 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -5199,6 +5199,12 @@ static void vkd3d_dxbc_compiler_emit_dcl_global_flags(struct vkd3d_dxbc_compiler flags &= ~VKD3DSGF_FORCE_EARLY_DEPTH_STENCIL; }
+ if (flags & (VKD3DSGF_ENABLE_DOUBLE_PRECISION_FLOAT_OPS | VKD3DSGF_ENABLE_11_1_DOUBLE_EXTENSIONS)) + { + vkd3d_spirv_enable_capability(&compiler->spirv_builder, SpvCapabilityFloat64); + flags &= ~(VKD3DSGF_ENABLE_DOUBLE_PRECISION_FLOAT_OPS | VKD3DSGF_ENABLE_11_1_DOUBLE_EXTENSIONS); + } + if (flags & ~(VKD3DSGF_REFACTORING_ALLOWED | VKD3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS)) FIXME("Unhandled global flags %#x.\n", flags); else diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index f62d2d48..9c5771b4 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -487,10 +487,12 @@ enum vkd3d_shader_interpolation_mode enum vkd3d_shader_global_flags { VKD3DSGF_REFACTORING_ALLOWED = 0x01, + VKD3DSGF_ENABLE_DOUBLE_PRECISION_FLOAT_OPS = 0x02, VKD3DSGF_FORCE_EARLY_DEPTH_STENCIL = 0x04, VKD3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS = 0x08, VKD3DSGF_SKIP_OPTIMIZATION = 0x10, - VKD3DSGF_ENABLE_MINIMUM_PRECISION = 0x20 + VKD3DSGF_ENABLE_MINIMUM_PRECISION = 0x20, + VKD3DSGF_ENABLE_11_1_DOUBLE_EXTENSIONS = 0x40, };
enum vkd3d_shader_sync_flags
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d-shader/trace.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index 0173075f..c21cb3e2 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -368,6 +368,8 @@ static void shader_dump_global_flags(struct vkd3d_d3d_asm_compiler *compiler, ui {VKD3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS, "enableRawAndStructuredBuffers"}, {VKD3DSGF_ENABLE_MINIMUM_PRECISION, "enableMinimumPrecision"}, {VKD3DSGF_SKIP_OPTIMIZATION, "skipOptimization"}, + {VKD3DSGF_ENABLE_DOUBLE_PRECISION_FLOAT_OPS, "enableDoublePrecisionFloatOps"}, + {VKD3DSGF_ENABLE_11_1_DOUBLE_EXTENSIONS, "enable11_1DoubleExtensions"}, };
for (i = 0; i < ARRAY_SIZE(global_flag_info); ++i)
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Based on a vkd3d-proton patch by Joshua Ashton.
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- include/vkd3d_shader.h | 2 ++ libs/vkd3d-shader/spirv.c | 2 ++ libs/vkd3d-shader/vkd3d_shader_private.h | 4 ++++ 3 files changed, 8 insertions(+)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 4593fcec..d9135503 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -1180,6 +1180,8 @@ enum vkd3d_shader_component_type VKD3D_SHADER_COMPONENT_FLOAT = 0x3, /** Boolean. */ VKD3D_SHADER_COMPONENT_BOOL = 0x4, + /** 64-bit IEEE floating-point. */ + VKD3D_SHADER_COMPONENT_DOUBLE = 0x5,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPONENT_TYPE), }; diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 60acd5d7..ee09c223 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -1715,6 +1715,8 @@ static uint32_t vkd3d_spirv_get_type_id(struct vkd3d_spirv_builder *builder, case VKD3D_SHADER_COMPONENT_BOOL: return vkd3d_spirv_get_op_type_bool(builder); break; + case VKD3D_SHADER_COMPONENT_DOUBLE: + return vkd3d_spirv_get_op_type_float(builder, 64); default: FIXME("Unhandled component type %#x.\n", component_type); return 0; diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 9c5771b4..23d8f07b 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -978,6 +978,8 @@ static inline enum vkd3d_shader_component_type vkd3d_component_type_from_data_ty return VKD3D_SHADER_COMPONENT_UINT; case VKD3D_DATA_INT: return VKD3D_SHADER_COMPONENT_INT; + case VKD3D_DATA_DOUBLE: + return VKD3D_SHADER_COMPONENT_DOUBLE; default: FIXME("Unhandled data type %#x.\n", data_type); return VKD3D_SHADER_COMPONENT_UINT; @@ -995,6 +997,8 @@ static inline enum vkd3d_data_type vkd3d_data_type_from_component_type( return VKD3D_DATA_UINT; case VKD3D_SHADER_COMPONENT_INT: return VKD3D_DATA_INT; + case VKD3D_SHADER_COMPONENT_DOUBLE: + return VKD3D_DATA_DOUBLE; default: FIXME("Unhandled component type %#x.\n", component_type); return VKD3D_DATA_FLOAT;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Source modifiers and immediate constants are not supported.
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d-shader/dxbc.c | 7 +++++++ libs/vkd3d-shader/spirv.c | 19 ++++++++++++++----- libs/vkd3d-shader/trace.c | 1 + libs/vkd3d-shader/vkd3d_shader_private.h | 14 ++++++++++++++ tests/d3d12.c | 4 ++-- 5 files changed, 38 insertions(+), 7 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index b81ac976..37b8a4a9 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -310,6 +310,7 @@ enum vkd3d_sm4_opcode VKD3D_SM5_OP_IMM_ATOMIC_UMAX = 0xbc, VKD3D_SM5_OP_IMM_ATOMIC_UMIN = 0xbd, VKD3D_SM5_OP_SYNC = 0xbe, + VKD3D_SM5_OP_DEQ = 0xc3, VKD3D_SM5_OP_EVAL_SAMPLE_INDEX = 0xcc, VKD3D_SM5_OP_EVAL_CENTROID = 0xcd, VKD3D_SM5_OP_DCL_GS_INSTANCES = 0xce, @@ -1018,6 +1019,7 @@ static void shader_sm5_read_sync(struct vkd3d_shader_instruction *ins, * R -> VKD3D_DATA_RESOURCE * S -> VKD3D_DATA_SAMPLER * U -> VKD3D_DATA_UAV + * d -> VKD3D_DATA_DOUBLE */ static const struct vkd3d_sm4_opcode_info opcode_table[] = { @@ -1247,6 +1249,7 @@ static const struct vkd3d_sm4_opcode_info opcode_table[] = {VKD3D_SM5_OP_IMM_ATOMIC_UMIN, VKD3DSIH_IMM_ATOMIC_UMIN, "uU", "iu"}, {VKD3D_SM5_OP_SYNC, VKD3DSIH_SYNC, "", "", shader_sm5_read_sync}, + {VKD3D_SM5_OP_DEQ, VKD3DSIH_DEQ, "u", "dd"}, {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, "", "", @@ -1352,6 +1355,8 @@ static enum vkd3d_data_type map_data_type(char t) return VKD3D_DATA_SAMPLER; case 'U': return VKD3D_DATA_UAV; + case 'd': + return VKD3D_DATA_DOUBLE; default: ERR("Invalid data type '%c'.\n", t); return VKD3D_DATA_FLOAT; @@ -1799,6 +1804,8 @@ static bool shader_sm4_read_dst_param(struct vkd3d_sm4_data *priv, const DWORD * }
dst_param->write_mask = (token & VKD3D_SM4_WRITEMASK_MASK) >> VKD3D_SM4_WRITEMASK_SHIFT; + if (data_type == VKD3D_DATA_DOUBLE) + dst_param->write_mask = vkd3d_write_mask_64_from_32(dst_param->write_mask); /* Scalar registers are declared with no write mask in shader bytecode. */ if (!dst_param->write_mask && shader_sm4_is_scalar_register(&dst_param->reg)) dst_param->write_mask = VKD3DSP_WRITEMASK_0; diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index ee09c223..8b02dbd8 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -3379,6 +3379,7 @@ static uint32_t vkd3d_dxbc_compiler_emit_load_reg(struct vkd3d_dxbc_compiler *co enum vkd3d_shader_component_type component_type; struct vkd3d_shader_register_info reg_info; unsigned int component_count; + unsigned int write_mask32; uint32_t type_id, val_id;
if (reg->type == VKD3DSPR_IMMCONST) @@ -3391,14 +3392,17 @@ static uint32_t vkd3d_dxbc_compiler_emit_load_reg(struct vkd3d_dxbc_compiler *co type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count); return vkd3d_spirv_build_op_undef(builder, &builder->global_stream, type_id); } + assert(reg_info.component_type != VKD3D_SHADER_COMPONENT_DOUBLE); vkd3d_dxbc_compiler_emit_dereference_register(compiler, reg, ®_info);
+ write_mask32 = (reg->data_type == VKD3D_DATA_DOUBLE) ? vkd3d_write_mask_32_from_64(write_mask) : write_mask; + /* Intermediate value (no storage class). */ if (reg_info.storage_class == SpvStorageClassMax) { val_id = reg_info.id; } - else if (component_count == 1) + else if (vkd3d_write_mask_component_count(write_mask32) == 1) { return vkd3d_dxbc_compiler_emit_load_scalar(compiler, reg, swizzle, write_mask, ®_info); } @@ -3410,7 +3414,7 @@ static uint32_t vkd3d_dxbc_compiler_emit_load_reg(struct vkd3d_dxbc_compiler *co }
val_id = vkd3d_dxbc_compiler_emit_swizzle(compiler, - val_id, reg_info.write_mask, reg_info.component_type, swizzle, write_mask); + val_id, reg_info.write_mask, reg_info.component_type, swizzle, write_mask32);
if (component_type != reg_info.component_type) { @@ -3592,6 +3596,7 @@ static void vkd3d_dxbc_compiler_emit_store_reg(struct vkd3d_dxbc_compiler *compi struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; enum vkd3d_shader_component_type component_type; struct vkd3d_shader_register_info reg_info; + unsigned int src_write_mask = write_mask; uint32_t type_id;
assert(reg->type != VKD3DSPR_IMMCONST); @@ -3603,14 +3608,16 @@ static void vkd3d_dxbc_compiler_emit_store_reg(struct vkd3d_dxbc_compiler *compi component_type = vkd3d_component_type_from_data_type(reg->data_type); if (component_type != reg_info.component_type) { - unsigned int component_count = vkd3d_write_mask_component_count(write_mask); - type_id = vkd3d_spirv_get_type_id(builder, reg_info.component_type, component_count); + if (reg->data_type == VKD3D_DATA_DOUBLE) + src_write_mask = vkd3d_write_mask_32_from_64(write_mask); + type_id = vkd3d_spirv_get_type_id(builder, reg_info.component_type, + vkd3d_write_mask_component_count(src_write_mask)); val_id = vkd3d_spirv_build_op_bitcast(builder, type_id, val_id); component_type = reg_info.component_type; }
vkd3d_dxbc_compiler_emit_store(compiler, - reg_info.id, reg_info.write_mask, component_type, reg_info.storage_class, write_mask, val_id); + reg_info.id, reg_info.write_mask, component_type, reg_info.storage_class, src_write_mask, val_id); }
static uint32_t vkd3d_dxbc_compiler_emit_sat(struct vkd3d_dxbc_compiler *compiler, @@ -7233,6 +7240,7 @@ static void vkd3d_dxbc_compiler_emit_comparison_instruction(struct vkd3d_dxbc_co
switch (instruction->handler_idx) { + case VKD3DSIH_DEQ: case VKD3DSIH_EQ: op = SpvOpFOrdEqual; break; case VKD3DSIH_GE: op = SpvOpFOrdGreaterThanEqual; break; case VKD3DSIH_IEQ: op = SpvOpIEqual; break; @@ -9454,6 +9462,7 @@ int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, case VKD3DSIH_UDIV: vkd3d_dxbc_compiler_emit_udiv(compiler, instruction); break; + case VKD3DSIH_DEQ: case VKD3DSIH_EQ: case VKD3DSIH_GE: case VKD3DSIH_IEQ: diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index c21cb3e2..556654ec 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -103,6 +103,7 @@ static const char * const shader_opcode_names[] = /* VKD3DSIH_DEFAULT */ "default", /* VKD3DSIH_DEFB */ "defb", /* VKD3DSIH_DEFI */ "defi", + /* VKD3DSIH_DEQ */ "deq", /* VKD3DSIH_DIV */ "div", /* VKD3DSIH_DP2 */ "dp2", /* VKD3DSIH_DP2ADD */ "dp2add", diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 23d8f07b..5f32d462 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -191,6 +191,7 @@ enum vkd3d_shader_opcode VKD3DSIH_DEFAULT, VKD3DSIH_DEFB, VKD3DSIH_DEFI, + VKD3DSIH_DEQ, VKD3DSIH_DIV, VKD3DSIH_DP2, VKD3DSIH_DP2ADD, @@ -1033,6 +1034,19 @@ static inline unsigned int vkd3d_write_mask_from_component_count(unsigned int co return (VKD3DSP_WRITEMASK_0 << component_count) - 1; }
+static inline unsigned int vkd3d_write_mask_64_from_32(DWORD write_mask32) +{ + unsigned int write_mask64 = write_mask32 | (write_mask32 >> 1); + return (write_mask64 & VKD3DSP_WRITEMASK_0) | ((write_mask64 & VKD3DSP_WRITEMASK_2) >> 1); +} + +static inline unsigned int vkd3d_write_mask_32_from_64(unsigned int write_mask64) +{ + unsigned int write_mask32 = (write_mask64 | (write_mask64 << 1)) + & (VKD3DSP_WRITEMASK_0 | VKD3DSP_WRITEMASK_2); + return write_mask32 | (write_mask32 << 1); +} + static inline unsigned int vkd3d_swizzle_get_component(DWORD swizzle, unsigned int idx) { diff --git a/tests/d3d12.c b/tests/d3d12.c index c613ff4d..6e45858b 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -9879,8 +9879,8 @@ static void test_shader_instructions(void) {&ps_dmovc, {.d = {{1.5, 0.0}}}, {.d = {1.5, 0.0}}, true, true}, {&ps_dmodifier, {.d = {{1.5, 0.0}}}, {.d = {1.5f, 2.5f}}, true, true}, {&ps_dmodifier, {.d = {{-1.5, 0.0}}}, {.d = {1.5f, 1.5f}}, true, true}, - {&ps_deq, {.d = {{0.0, 0.0}}}, {{0xffffffff}}, true, true}, - {&ps_deq, {.d = {{1.0, 0.0}}}, {{0x00000000}}, true, true}, + {&ps_deq, {.d = {{0.0, 0.0}}}, {{0xffffffff}}, true, false}, + {&ps_deq, {.d = {{1.0, 0.0}}}, {{0x00000000}}, true, false}, {&ps_dne, {.d = {{0.0, 0.0}}}, {{0x00000000}}, true, true}, {&ps_dne, {.d = {{1.0, 0.0}}}, {{0xffffffff}}, true, true}, {&ps_dtou, {.d = {{ -NAN}}}, {{ 0, 0 }}, true, true},
On Fri, 9 Jul 2021 at 17:32, Conor McCarthy cmccarthy@codeweavers.com wrote:
@@ -1018,6 +1019,7 @@ static void shader_sm5_read_sync(struct vkd3d_shader_instruction *ins,
- R -> VKD3D_DATA_RESOURCE
- S -> VKD3D_DATA_SAMPLER
- U -> VKD3D_DATA_UAV
*/
- d -> VKD3D_DATA_DOUBLE
It would probably be best to keep these sorted.
@@ -1352,6 +1355,8 @@ static enum vkd3d_data_type map_data_type(char t) return VKD3D_DATA_SAMPLER; case 'U': return VKD3D_DATA_UAV;
case 'd':
return VKD3D_DATA_DOUBLE; default: ERR("Invalid data type '%c'.\n", t); return VKD3D_DATA_FLOAT;
And here.
@@ -1799,6 +1804,8 @@ static bool shader_sm4_read_dst_param(struct vkd3d_sm4_data *priv, const DWORD * }
dst_param->write_mask = (token & VKD3D_SM4_WRITEMASK_MASK) >> VKD3D_SM4_WRITEMASK_SHIFT;
- if (data_type == VKD3D_DATA_DOUBLE)
/* Scalar registers are declared with no write mask in shader bytecode. */ if (!dst_param->write_mask && shader_sm4_is_scalar_register(&dst_param->reg)) dst_param->write_mask = VKD3DSP_WRITEMASK_0;dst_param->write_mask = vkd3d_write_mask_64_from_32(dst_param->write_mask);
Does this need a corresponding change in trace.c? Also, should we do the same for swizzles?
@@ -9879,8 +9879,8 @@ static void test_shader_instructions(void) {&ps_dmovc, {.d = {{1.5, 0.0}}}, {.d = {1.5, 0.0}}, true, true}, {&ps_dmodifier, {.d = {{1.5, 0.0}}}, {.d = {1.5f, 2.5f}}, true, true}, {&ps_dmodifier, {.d = {{-1.5, 0.0}}}, {.d = {1.5f, 1.5f}}, true, true},
{&ps_deq, {.d = {{0.0, 0.0}}}, {{0xffffffff}}, true, true},
{&ps_deq, {.d = {{1.0, 0.0}}}, {{0x00000000}}, true, true},
{&ps_deq, {.d = {{0.0, 0.0}}}, {{0xffffffff}}, true, false},
{&ps_deq, {.d = {{1.0, 0.0}}}, {{0x00000000}}, true, false}, {&ps_dne, {.d = {{0.0, 0.0}}}, {{0x00000000}}, true, true}, {&ps_dne, {.d = {{1.0, 0.0}}}, {{0xffffffff}}, true, true}, {&ps_dtou, {.d = {{ -NAN}}}, {{ 0, 0 }}, true, true},
We can drop final "false" values.
July 14, 2021 12:25 AM, "Henri Verbeet" hverbeet@gmail.com wrote:
dst_param->write_mask = (token & VKD3D_SM4_WRITEMASK_MASK) >> VKD3D_SM4_WRITEMASK_SHIFT;
- if (data_type == VKD3D_DATA_DOUBLE)
- dst_param->write_mask = vkd3d_write_mask_64_from_32(dst_param->write_mask);
/* Scalar registers are declared with no write mask in shader bytecode. */ if (!dst_param->write_mask && shader_sm4_is_scalar_register(&dst_param->reg)) dst_param->write_mask = VKD3DSP_WRITEMASK_0;
Does this need a corresponding change in trace.c? Also, should we do the same for swizzles?
It does need trace changes, but these lines are actually not needed for the DEQ instruction so I'll leave them out of v2.
Swizzle is always expressed in 32-bit chunks so no changes are required there.
On Wed, 14 Jul 2021 at 08:38, Conor McCarthy cmccarthy@codeweavers.com wrote:
July 14, 2021 12:25 AM, "Henri Verbeet" hverbeet@gmail.com wrote:
dst_param->write_mask = (token & VKD3D_SM4_WRITEMASK_MASK) >> VKD3D_SM4_WRITEMASK_SHIFT;
- if (data_type == VKD3D_DATA_DOUBLE)
- dst_param->write_mask = vkd3d_write_mask_64_from_32(dst_param->write_mask);
/* Scalar registers are declared with no write mask in shader bytecode. */ if (!dst_param->write_mask && shader_sm4_is_scalar_register(&dst_param->reg)) dst_param->write_mask = VKD3DSP_WRITEMASK_0;
Does this need a corresponding change in trace.c? Also, should we do the same for swizzles?
It does need trace changes, but these lines are actually not needed for the DEQ instruction so I'll leave them out of v2.
Right, deq only has double source parameters.
Swizzle is always expressed in 32-bit chunks so no changes are required there.
Sure, but I'm wondering if for consistency it would perhaps be a good thing to express swizzles in terms of the register's data type in our internal IR, like we do for write masks.
July 14, 2021 5:38 PM, "Henri Verbeet" hverbeet@gmail.com wrote:
Swizzle is always expressed in 32-bit chunks so no changes are required there.
Sure, but I'm wondering if for consistency it would perhaps be a good thing to express swizzles in terms of the register's data type in our internal IR, like we do for write masks.
I think it would add extra lines of code without simplifying anything elsewhere. Converting write masks in the front end solves back end component count problems, which more than makes up for a few conversions in the back end, but there are no problems with swizzles.