diff --git a/tests/d3d12.c b/tests/d3d12.c index 548a1060..f485ec79 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -4153,6 +4153,107 @@ static void test_shader_instructions(void) 0x01000015, 0x01000015, 0x0100003e, }; static const D3D12_SHADER_BYTECODE ps_nested_if = {ps_nested_if_code, sizeof(ps_nested_if_code)}; + static const DWORD ps_loop_break_code[] = + { +#if 0 + float4 src0; + + void main(out float4 dst : SV_Target) + { + float tmp = 0.0f; + for (int i = 0; i < src0.x; ++i) + { + if (i == src0.y) + { + tmp = 1.0f; + break; + } + tmp += 1.0f; + } + + dst = float4(tmp, 0, 0, 0); + } +#endif + 0x43425844, 0xbd9dabbd, 0xe56cab2a, 0xfd37cd76, 0x5dd181c4, 0x00000001, 0x000001c8, 0x00000003, + 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000150, 0x00000050, 0x00000054, + 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, + 0x02000068, 0x00000001, 0x08000036, 0x00100032, 0x00000000, 0x00004002, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x01000030, 0x0500002b, 0x00100042, 0x00000000, 0x0010001a, 0x00000000, + 0x0800001d, 0x00100082, 0x00000000, 0x0010002a, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, + 0x03040003, 0x0010003a, 0x00000000, 0x08000018, 0x00100042, 0x00000000, 0x0010002a, 0x00000000, + 0x0020801a, 0x00000000, 0x00000000, 0x0304001f, 0x0010002a, 0x00000000, 0x05000036, 0x00100012, + 0x00000000, 0x00004001, 0x3f800000, 0x01000002, 0x01000015, 0x07000000, 0x00100012, 0x00000000, + 0x0010000a, 0x00000000, 0x00004001, 0x3f800000, 0x0700001e, 0x00100022, 0x00000000, 0x0010001a, + 0x00000000, 0x00004001, 0x00000001, 0x01000016, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, + 0x00000000, 0x08000036, 0x001020e2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x0100003e, + }; + static const D3D12_SHADER_BYTECODE ps_loop_break = {ps_loop_break_code, sizeof(ps_loop_break_code)}; + static const DWORD ps_breakc_nz_code[] = + { +#if 0 + float4 main() : SV_TARGET + { + uint counter = 0; + + for (uint i = 0; i < 255; ++i) + ++counter; + + if (counter == 255) + return float4(0.0f, 1.0f, 0.0f, 1.0f); + else + return float4(1.0f, 0.0f, 0.0f, 1.0f); + } +#endif + 0x43425844, 0x065ac80a, 0x24369e7e, 0x218d5dc1, 0x3532868c, 0x00000001, 0x00000188, 0x00000003, + 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000110, 0x00000040, 0x00000044, + 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x08000036, 0x00100032, 0x00000000, + 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01000030, 0x07000050, 0x00100042, + 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x000000ff, 0x03040003, 0x0010002a, 0x00000000, + 0x0a00001e, 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x00004002, 0x00000001, 0x00000001, + 0x00000000, 0x00000000, 0x01000016, 0x07000020, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, + 0x00004001, 0x000000ff, 0x0304001f, 0x0010000a, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, + 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000012, 0x08000036, + 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, + 0x01000015, 0x0100003e, + }; + static const D3D12_SHADER_BYTECODE ps_breakc_nz = {ps_breakc_nz_code, sizeof(ps_breakc_nz_code)}; + static const DWORD ps_breakc_z_code[] = + { +#if 0 + float4 main() : SV_TARGET + { + uint counter = 0; + + for (int i = 0, j = 254; i < 255 && j >= 0; ++i, --j) + ++counter; + + if (counter == 255) + return float4(0.0f, 1.0f, 0.0f, 1.0f); + else + return float4(1.0f, 0.0f, 0.0f, 1.0f); + } +#endif + 0x43425844, 0x687406ef, 0x7bdeb7d1, 0xb3282292, 0x934a9101, 0x00000001, 0x000001c0, 0x00000003, + 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000148, 0x00000040, 0x00000052, + 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x08000036, 0x00100072, 0x00000000, + 0x00004002, 0x00000000, 0x00000000, 0x000000fe, 0x00000000, 0x01000030, 0x07000022, 0x00100082, + 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x000000ff, 0x07000021, 0x00100012, 0x00000001, + 0x0010002a, 0x00000000, 0x00004001, 0x00000000, 0x07000001, 0x00100082, 0x00000000, 0x0010003a, + 0x00000000, 0x0010000a, 0x00000001, 0x03000003, 0x0010003a, 0x00000000, 0x0a00001e, 0x00100072, + 0x00000000, 0x00100246, 0x00000000, 0x00004002, 0x00000001, 0x00000001, 0xffffffff, 0x00000000, + 0x01000016, 0x07000020, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x000000ff, + 0x0304001f, 0x0010000a, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, + 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000012, 0x08000036, 0x001020f2, 0x00000000, + 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000015, 0x0100003e, + }; + static const D3D12_SHADER_BYTECODE ps_breakc_z = {ps_breakc_z_code, sizeof(ps_breakc_z_code)}; static const DWORD ps_src_modifiers_code[] = { #if 0 @@ -4712,6 +4813,21 @@ static void test_shader_instructions(void) {&ps_nested_if, {{1.0f, 0.0f, 1.0f}}, {{0.0f, 0.0f, 1.0f, 1.0f}}}, {&ps_nested_if, {{1.0f, 1.0f, 1.0f}}, {{0.0f, 1.0f, 0.0f, 1.0f}}}, + {&ps_loop_break, {{0.0f, 0.0f}}, {{0.0f}}}, + {&ps_loop_break, {{1.0f, 0.0f}}, {{1.0f}}}, + {&ps_loop_break, {{1.0f, 1.0f}}, {{1.0f}}}, + {&ps_loop_break, {{1.0f, 2.0f}}, {{1.0f}}}, + {&ps_loop_break, {{1.0f, 3.0f}}, {{1.0f}}}, + {&ps_loop_break, {{7.0f, 0.0f}}, {{1.0f}}}, + {&ps_loop_break, {{7.0f, 2.0f}}, {{1.0f}}}, + {&ps_loop_break, {{7.0f, 6.0f}}, {{1.0f}}}, + {&ps_loop_break, {{7.0f, 7.0f}}, {{7.0f}}}, + {&ps_loop_break, {{7.0f, 8.0f}}, {{7.0f}}}, + {&ps_loop_break, {{7.0f, 9.0f}}, {{7.0f}}}, + + {&ps_breakc_nz, {}, {{0.0f, 1.0f, 0.0f, 1.0f}}}, + {&ps_breakc_z, {}, {{0.0f, 1.0f, 0.0f, 1.0f}}}, + {&ps_src_modifiers, {{ 1.0f, 1.0f, 1.0f, 2.0f}}, {{-1.0f, 1.0f, -1.0f, -2.0f}}}, {&ps_src_modifiers, {{-1.0f, -1.0f, -1.0f, -2.0f}}, {{ 1.0f, 1.0f, -1.0f, -2.0f}}},