Added test for branching out of switch block using continue.
authorAri Suonpaa <ari.suonpaa@siru.fi>
Wed, 18 Oct 2017 07:07:20 +0000 (10:07 +0300)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Mon, 20 Nov 2017 09:54:21 +0000 (04:54 -0500)
Added a test where a for loop contains a switch block and the
cases break out of selection into enclosing for loop using
continue.

Affects:

dEQP-VK.spirv_assembly.instruction.graphics.loop.switch_continue*

Components: Vulkan

VK-GL-CTS issue: 722

Change-Id: Iad7050d848a1b75b5877c17ae40713ac45222ba7

android/cts/master/vk-master.txt
external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmInstructionTests.cpp
external/vulkancts/mustpass/1.1.0/vk-default.txt

index 666cfbf..194f28f 100755 (executable)
@@ -173546,6 +173546,11 @@ dEQP-VK.spirv_assembly.instruction.graphics.loop.return_tessc
 dEQP-VK.spirv_assembly.instruction.graphics.loop.return_tesse
 dEQP-VK.spirv_assembly.instruction.graphics.loop.return_geom
 dEQP-VK.spirv_assembly.instruction.graphics.loop.return_frag
+dEQP-VK.spirv_assembly.instruction.graphics.loop.switch_continue_vert
+dEQP-VK.spirv_assembly.instruction.graphics.loop.switch_continue_tessc
+dEQP-VK.spirv_assembly.instruction.graphics.loop.switch_continue_tesse
+dEQP-VK.spirv_assembly.instruction.graphics.loop.switch_continue_geom
+dEQP-VK.spirv_assembly.instruction.graphics.loop.switch_continue_frag
 dEQP-VK.spirv_assembly.instruction.graphics.opspecconstantop.iadd_vert
 dEQP-VK.spirv_assembly.instruction.graphics.opspecconstantop.iadd_tessc
 dEQP-VK.spirv_assembly.instruction.graphics.opspecconstantop.iadd_tesse
index b27f4b0..ac5055e 100644 (file)
@@ -7277,6 +7277,70 @@ tcu::TestCaseGroup* createLoopTests(tcu::TestContext& testCtx)
                "OpFunctionEnd\n";
        createTestsForAllStages("return", defaultColors, defaultColors, fragments, testGroup.get());
 
+       // Continue inside a switch block to break to enclosing loop's merge block.
+       // Matches roughly the following GLSL code:
+       // for (; keep_going; keep_going = false)
+       // {
+       //     switch (int(param1.x))
+       //     {
+       //         case 0: continue;
+       //         case 1: continue;
+       //         default: continue;
+       //     }
+       //     dead code: modify return value to invalid result.
+       // }
+       fragments["pre_main"] =
+               "%fp_bool = OpTypePointer Function %bool\n"
+               "%true = OpConstantTrue %bool\n"
+               "%false = OpConstantFalse %bool\n";
+
+       fragments["testfun"] =
+               "%test_code = OpFunction %v4f32 None %v4f32_function\n"
+               "%param1 = OpFunctionParameter %v4f32\n"
+
+               "%entry = OpLabel\n"
+               "%keep_going = OpVariable %fp_bool Function\n"
+               "%val_ptr = OpVariable %fp_f32 Function\n"
+               "%param1_x = OpCompositeExtract %f32 %param1 0\n"
+               "OpStore %keep_going %true\n"
+               "OpBranch %forloop_begin\n"
+
+               "%forloop_begin = OpLabel\n"
+               "OpLoopMerge %forloop_merge %forloop_continue None\n"
+               "OpBranch %forloop\n"
+
+               "%forloop = OpLabel\n"
+               "%for_condition = OpLoad %bool %keep_going\n"
+               "OpBranchConditional %for_condition %forloop_body %forloop_merge\n"
+
+               "%forloop_body = OpLabel\n"
+               "OpStore %val_ptr %param1_x\n"
+               "%param1_x_int = OpConvertFToS %i32 %param1_x\n"
+
+               "OpSelectionMerge %switch_merge None\n"
+               "OpSwitch %param1_x_int %default 0 %case_0 1 %case_1\n"
+               "%case_0 = OpLabel\n"
+               "OpBranch %forloop_continue\n"
+               "%case_1 = OpLabel\n"
+               "OpBranch %forloop_continue\n"
+               "%default = OpLabel\n"
+               "OpBranch %forloop_continue\n"
+               "%switch_merge = OpLabel\n"
+               ";should never get here, so change the return value to invalid result\n"
+               "OpStore %val_ptr %c_f32_1\n"
+               "OpBranch %forloop_continue\n"
+
+               "%forloop_continue = OpLabel\n"
+               "OpStore %keep_going %false\n"
+               "OpBranch %forloop_begin\n"
+               "%forloop_merge = OpLabel\n"
+
+               "%val = OpLoad %f32 %val_ptr\n"
+               "%result = OpVectorInsertDynamic %v4f32 %param1 %val %c_i32_0\n"
+               "OpReturnValue %result\n"
+               "OpFunctionEnd\n";
+       createTestsForAllStages("switch_continue", defaultColors, defaultColors, fragments, testGroup.get());
+
        return testGroup.release();
 }
 
index f05113b..b379a73 100755 (executable)
@@ -173547,6 +173547,11 @@ dEQP-VK.spirv_assembly.instruction.graphics.loop.return_tessc
 dEQP-VK.spirv_assembly.instruction.graphics.loop.return_tesse
 dEQP-VK.spirv_assembly.instruction.graphics.loop.return_geom
 dEQP-VK.spirv_assembly.instruction.graphics.loop.return_frag
+dEQP-VK.spirv_assembly.instruction.graphics.loop.switch_continue_vert
+dEQP-VK.spirv_assembly.instruction.graphics.loop.switch_continue_tessc
+dEQP-VK.spirv_assembly.instruction.graphics.loop.switch_continue_tesse
+dEQP-VK.spirv_assembly.instruction.graphics.loop.switch_continue_geom
+dEQP-VK.spirv_assembly.instruction.graphics.loop.switch_continue_frag
 dEQP-VK.spirv_assembly.instruction.graphics.opspecconstantop.iadd_vert
 dEQP-VK.spirv_assembly.instruction.graphics.opspecconstantop.iadd_tessc
 dEQP-VK.spirv_assembly.instruction.graphics.opspecconstantop.iadd_tesse