tests: Add test for nested switch instructions.

This commit is contained in:
Józef Kucia 2017-08-01 13:55:49 +02:00
parent eb4c98db17
commit 26133bd801

View File

@ -5211,6 +5211,90 @@ static void test_shader_instructions(void)
0x0010000a, 0x00000000, 0x05000036, 0x00102022, 0x00000000, 0x0010000a, 0x00000001, 0x0100003e,
};
static const D3D12_SHADER_BYTECODE ps_udiv = {ps_udiv_code, sizeof(ps_udiv_code)};
static const DWORD ps_nested_switch_code[] =
{
#if 0
uint4 src0;
uint4 src1;
uint4 main() : SV_Target
{
uint4 dst = 0;
switch (src0.x)
{
case ~0u:
dst.x = 1;
break;
case 0:
case 1:
case 2:
if (src1.x)
break;
dst.x = 2;
break;
case 3:
break;
case 4:
if (src1.x)
{
switch (src0.y)
{
case 0:
case 1:
case 2:
case 3:
if (src0.z)
dst += src0.z * (uint4)2;
else if (src0.w)
return (uint4)255;
else
dst.zw = 1;
break;
default:
dst = 1;
break;
}
break;
}
else
{
dst = 128;
break;
}
}
return dst;
}
#endif
0x43425844, 0x46d465cb, 0x5d7ed52f, 0x3573b153, 0x1691c479, 0x00000001, 0x00000334, 0x00000003,
0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000002bc, 0x00000050, 0x000000af,
0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000002, 0x03000065, 0x001020f2, 0x00000000,
0x02000068, 0x00000001, 0x0400004c, 0x0020800a, 0x00000000, 0x00000000, 0x03000006, 0x00004001,
0xffffffff, 0x08000036, 0x001000f2, 0x00000000, 0x00004002, 0x00000001, 0x00000000, 0x00000000,
0x00000000, 0x01000002, 0x03000006, 0x00004001, 0x00000000, 0x03000006, 0x00004001, 0x00000001,
0x03000006, 0x00004001, 0x00000002, 0x0404001f, 0x0020800a, 0x00000000, 0x00000001, 0x08000036,
0x001000f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01000002,
0x01000015, 0x08000036, 0x001000f2, 0x00000000, 0x00004002, 0x00000002, 0x00000000, 0x00000000,
0x00000000, 0x01000002, 0x03000006, 0x00004001, 0x00000003, 0x08000036, 0x001000f2, 0x00000000,
0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01000002, 0x03000006, 0x00004001,
0x00000004, 0x0404001f, 0x0020800a, 0x00000000, 0x00000001, 0x0400004c, 0x0020801a, 0x00000000,
0x00000000, 0x03000006, 0x00004001, 0x00000000, 0x03000006, 0x00004001, 0x00000001, 0x03000006,
0x00004001, 0x00000002, 0x03000006, 0x00004001, 0x00000003, 0x0404001f, 0x0020802a, 0x00000000,
0x00000000, 0x0b000029, 0x001000f2, 0x00000000, 0x00208aa6, 0x00000000, 0x00000000, 0x00004002,
0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x01000012, 0x0404001f, 0x0020803a, 0x00000000,
0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x0100003e, 0x01000015, 0x08000036, 0x001000f2, 0x00000000, 0x00004002, 0x00000000,
0x00000000, 0x00000001, 0x00000001, 0x01000015, 0x01000002, 0x0100000a, 0x08000036, 0x001000f2,
0x00000000, 0x00004002, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x01000002, 0x01000017,
0x01000002, 0x01000012, 0x08000036, 0x001000f2, 0x00000000, 0x00004002, 0x00000080, 0x00000080,
0x00000080, 0x00000080, 0x01000002, 0x01000015, 0x0100000a, 0x08000036, 0x001000f2, 0x00000000,
0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01000002, 0x01000017, 0x05000036,
0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e,
};
static const D3D12_SHADER_BYTECODE ps_nested_switch = {ps_nested_switch_code, sizeof(ps_nested_switch_code)};
static const DWORD ps_movc_code[] =
{
#if 0
@ -5730,6 +5814,39 @@ static void test_shader_instructions(void)
{&ps_udiv, {{{7}, {6}}}, {{ 1u, 1u}}},
{&ps_udiv, {{{7}, {7}}}, {{ 1u, 0u}}},
{&ps_nested_switch, {{{~0u, 0, 0, 0}, {0}}}, {{ 1, 0, 0, 0}}},
{&ps_nested_switch, {{{ 0u, 0, 0, 0}, {0}}}, {{ 2, 0, 0, 0}}},
{&ps_nested_switch, {{{ 1u, 0, 0, 0}, {0}}}, {{ 2, 0, 0, 0}}},
{&ps_nested_switch, {{{ 2u, 0, 0, 0}, {0}}}, {{ 2, 0, 0, 0}}},
{&ps_nested_switch, {{{ 0u, 0, 0, 0}, {1}}}, {{ 0, 0, 0, 0}}},
{&ps_nested_switch, {{{ 1u, 0, 0, 0}, {2}}}, {{ 0, 0, 0, 0}}},
{&ps_nested_switch, {{{ 2u, 0, 0, 0}, {3}}}, {{ 0, 0, 0, 0}}},
{&ps_nested_switch, {{{ 3u, 0, 0, 0}, {0}}}, {{ 0, 0, 0, 0}}},
{&ps_nested_switch, {{{ 3u, 0, 0, 0}, {1}}}, {{ 0, 0, 0, 0}}},
{&ps_nested_switch, {{{ 5u, 1, 2, 3}, {0}}}, {{ 0, 0, 0, 0}}},
{&ps_nested_switch, {{{ 6u, 1, 2, 3}, {1}}}, {{ 0, 0, 0, 0}}},
{&ps_nested_switch, {{{ 4u, 0, 0, 0}, {0}}}, {{128, 128, 128, 128}}},
{&ps_nested_switch, {{{ 4u, 0, 0, 0}, {1}}}, {{ 0, 0, 1, 1}}},
{&ps_nested_switch, {{{ 4u, 1, 0, 0}, {1}}}, {{ 0, 0, 1, 1}}},
{&ps_nested_switch, {{{ 4u, 2, 0, 0}, {1}}}, {{ 0, 0, 1, 1}}},
{&ps_nested_switch, {{{ 4u, 3, 0, 0}, {1}}}, {{ 0, 0, 1, 1}}},
{&ps_nested_switch, {{{ 4u, 0, 0, 1}, {1}}}, {{255, 255, 255, 255}}},
{&ps_nested_switch, {{{ 4u, 1, 0, 1}, {1}}}, {{255, 255, 255, 255}}},
{&ps_nested_switch, {{{ 4u, 2, 0, 1}, {1}}}, {{255, 255, 255, 255}}},
{&ps_nested_switch, {{{ 4u, 3, 0, 1}, {1}}}, {{255, 255, 255, 255}}},
{&ps_nested_switch, {{{ 4u, 0, 1, 1}, {1}}}, {{ 2, 2, 2, 2}}},
{&ps_nested_switch, {{{ 4u, 1, 1, 1}, {1}}}, {{ 2, 2, 2, 2}}},
{&ps_nested_switch, {{{ 4u, 2, 1, 1}, {1}}}, {{ 2, 2, 2, 2}}},
{&ps_nested_switch, {{{ 4u, 3, 1, 1}, {1}}}, {{ 2, 2, 2, 2}}},
{&ps_nested_switch, {{{ 4u, 0, 3, 1}, {1}}}, {{ 6, 6, 6, 6}}},
{&ps_nested_switch, {{{ 4u, 1, 3, 1}, {1}}}, {{ 6, 6, 6, 6}}},
{&ps_nested_switch, {{{ 4u, 2, 3, 1}, {1}}}, {{ 6, 6, 6, 6}}},
{&ps_nested_switch, {{{ 4u, 3, 3, 1}, {1}}}, {{ 6, 6, 6, 6}}},
{&ps_nested_switch, {{{ 4u, 5, 3, 1}, {1}}}, {{ 1, 1, 1, 1}}},
{&ps_nested_switch, {{{ 4u, 6, 3, 1}, {1}}}, {{ 1, 1, 1, 1}}},
{&ps_nested_switch, {{{ 4u, 7, 3, 1}, {1}}}, {{ 1, 1, 1, 1}}},
{&ps_nested_switch, {{{ 4u, 8, 3, 1}, {1}}}, {{ 1, 1, 1, 1}}},
{&ps_movc, {{{0, 0, 0, 0}, {1, 2, 3, 4}, {5, 6, 7, 8}}}, {{5, 6, 7, 8}}},
{&ps_movc, {{{0, 0, 0, 1}, {1, 2, 3, 4}, {5, 6, 7, 8}}}, {{5, 6, 7, 4}}},
{&ps_movc, {{{1, 0, 0, 0}, {1, 2, 3, 4}, {5, 6, 7, 8}}}, {{1, 6, 7, 8}}},