From ac61e0d4b19b060770f8d9f55272ecf8c10ad1ba Mon Sep 17 00:00:00 2001 From: Alastair Donaldson Date: Thu, 31 Oct 2019 11:42:55 +0000 Subject: [PATCH] dEQP-VK.graphicsfuzz.unreachable-switch-case-with-discards Components: Vulkan New Tests: dEQP-VK.graphicsfuzz.unreachable-switch-case-with-discards Change-Id: Ic0bdb602fbcebd460072ca88acb3a8b4b4641bf1 --- android/cts/master/vk-master.txt | 1 + .../data/vulkan/amber/graphicsfuzz/index.txt | 1 + .../unreachable-switch-case-with-discards.amber | 228 +++++++++++++++++++++ .../mustpass/master/vk-default-no-waivers.txt | 1 + external/vulkancts/mustpass/master/vk-default.txt | 1 + 5 files changed, 232 insertions(+) create mode 100644 external/vulkancts/data/vulkan/amber/graphicsfuzz/unreachable-switch-case-with-discards.amber diff --git a/android/cts/master/vk-master.txt b/android/cts/master/vk-master.txt index a5f32a5..0ff6d90 100644 --- a/android/cts/master/vk-master.txt +++ b/android/cts/master/vk-master.txt @@ -559328,6 +559328,7 @@ dEQP-VK.graphicsfuzz.unreachable-discard-statement dEQP-VK.graphicsfuzz.unreachable-loops dEQP-VK.graphicsfuzz.unreachable-loops-in-switch dEQP-VK.graphicsfuzz.unreachable-return-in-loop +dEQP-VK.graphicsfuzz.unreachable-switch-case-with-discards dEQP-VK.graphicsfuzz.while-function-always-false dEQP-VK.graphicsfuzz.while-inside-switch dEQP-VK.graphicsfuzz.write-before-break diff --git a/external/vulkancts/data/vulkan/amber/graphicsfuzz/index.txt b/external/vulkancts/data/vulkan/amber/graphicsfuzz/index.txt index 0fc488c..a06c012 100644 --- a/external/vulkancts/data/vulkan/amber/graphicsfuzz/index.txt +++ b/external/vulkancts/data/vulkan/amber/graphicsfuzz/index.txt @@ -65,6 +65,7 @@ { "unreachable-loops.amber", "unreachable-loops", "Fragment shader that writes red despite unreachable loops" }, { "unreachable-loops-in-switch.amber", "unreachable-loops-in-switch", "A fragment shader with unreachable loops in a switch" }, { "unreachable-return-in-loop.amber", "unreachable-return-in-loop", "A fragment shader with an unreachable return in a loop" }, +{ "unreachable-switch-case-with-discards.amber", "unreachable-switch-case-with-discards","A shader with a switch statement containing unreachable discards" }, { "while-function-always-false.amber", "while-function-always-false", "A fragment shader with an always false while function" }, { "while-inside-switch.amber", "while-inside-switch", "A fragment shader that uses a while loop inside a switch" }, { "write-before-break.amber", "write-before-break", "Fragment shader that writes red before loop break" }, diff --git a/external/vulkancts/data/vulkan/amber/graphicsfuzz/unreachable-switch-case-with-discards.amber b/external/vulkancts/data/vulkan/amber/graphicsfuzz/unreachable-switch-case-with-discards.amber new file mode 100644 index 0000000..2cc1706 --- /dev/null +++ b/external/vulkancts/data/vulkan/amber/graphicsfuzz/unreachable-switch-case-with-discards.amber @@ -0,0 +1,228 @@ +#!amber + +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# A test for a bug found by GraphicsFuzz. + +# Short description: A shader with a switch statement containing unreachable discards + +# The test passes because the shader always writes the color red. + +# Optimized using spirv-opt with the following arguments: +# '-O' +# spirv-opt commit hash: 6b072126595dd8c2448eb1fda616251c5e6d7079 + + + +SHADER vertex variant_vertex_shader PASSTHROUGH + +# variant_fragment_shader is derived from the following GLSL: +# #version 310 es +# precision highp float; +# +# layout(location = 0) out vec4 _GLF_color; +# +# layout(set = 0, binding = 0) uniform buf0 { +# vec2 injectionSwitch; +# }; +# vec3 drawShape(vec2 square) +# { +# switch(int(injectionSwitch.x)) +# { +# case 0: +# return vec3(1.0, 0.0, 0.0); +# case 67: +# do +# { +# if(1.0 < square.x) +# { +# } +# else +# { +# discard; +# } +# discard; +# } +# while(true); +# } +# return vec3(1.0); +# } +# void main() +# { +# vec2 center; +# vec3 color = vec3(0.0); +# for( +# int i = 0; +# i < 1; +# i++ +# ) +# { +# color = drawShape(center); +# if(length(color) <= 0.0) +# { +# continue; +# } +# } +# _GLF_color = vec4(color, 1.0); +# } +SHADER fragment variant_fragment_shader SPIRV-ASM +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 7 +; Bound: 139 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %78 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %14 "buf0" + OpMemberName %14 0 "injectionSwitch" + OpName %16 "" + OpName %78 "_GLF_color" + OpMemberDecorate %14 0 Offset 0 + OpDecorate %14 Block + OpDecorate %16 DescriptorSet 0 + OpDecorate %16 Binding 0 + OpDecorate %75 RelaxedPrecision + OpDecorate %78 Location 0 + OpDecorate %132 RelaxedPrecision + OpDecorate %132 RelaxedPrecision + OpDecorate %132 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 2 + %9 = OpTypeVector %6 3 + %14 = OpTypeStruct %7 + %15 = OpTypePointer Uniform %14 + %16 = OpVariable %15 Uniform + %17 = OpTypeInt 32 1 + %18 = OpConstant %17 0 + %19 = OpTypeInt 32 0 + %20 = OpConstant %19 0 + %21 = OpTypePointer Uniform %6 + %28 = OpConstant %6 1 + %29 = OpConstant %6 0 + %30 = OpConstantComposite %9 %28 %29 %29 + %39 = OpTypeBool + %48 = OpConstantComposite %9 %28 %28 %28 + %53 = OpConstantComposite %9 %29 %29 %29 + %62 = OpConstant %17 1 + %76 = OpTypeVector %6 4 + %77 = OpTypePointer Output %76 + %78 = OpVariable %77 Output + %135 = OpUndef %7 + %4 = OpFunction %2 None %3 + %5 = OpLabel + OpBranch %56 + %56 = OpLabel + %133 = OpPhi %9 %53 %5 %137 %59 + %132 = OpPhi %17 %18 %5 %75 %59 + %63 = OpSLessThan %39 %132 %62 + OpLoopMerge %58 %59 None + OpBranchConditional %63 %57 %58 + %57 = OpLabel + OpBranch %104 + %104 = OpLabel + OpLoopMerge %105 %106 None + OpBranch %107 + %107 = OpLabel + %108 = OpAccessChain %21 %16 %18 %20 + %109 = OpLoad %6 %108 + %110 = OpConvertFToS %17 %109 + OpSelectionMerge %111 None + OpSwitch %110 %111 0 %112 67 %113 + %113 = OpLabel + OpBranch %114 + %114 = OpLabel + OpLoopMerge %115 %116 None + OpBranch %117 + %117 = OpLabel + %119 = OpCompositeExtract %6 %135 0 + %120 = OpFOrdLessThan %39 %28 %119 + OpSelectionMerge %122 None + OpBranchConditional %120 %122 %123 + %123 = OpLabel + %124 = OpFunctionCall %2 %84 + %125 = OpUndef %9 + OpBranch %115 + %122 = OpLabel + %126 = OpFunctionCall %2 %84 + %127 = OpUndef %9 + OpBranch %115 + %116 = OpLabel + OpBranch %114 + %115 = OpLabel + %138 = OpPhi %9 %125 %123 %127 %122 + OpBranch %105 + %112 = OpLabel + OpBranch %105 + %111 = OpLabel + OpBranch %105 + %106 = OpLabel + OpBranch %104 + %105 = OpLabel + %137 = OpPhi %9 %138 %115 %30 %112 %48 %111 + %69 = OpExtInst %6 %1 Length %137 + %70 = OpFOrdLessThanEqual %39 %69 %29 + OpSelectionMerge %72 None + OpBranchConditional %70 %71 %72 + %71 = OpLabel + OpBranch %59 + %72 = OpLabel + OpBranch %59 + %59 = OpLabel + %75 = OpIAdd %17 %132 %62 + OpBranch %56 + %58 = OpLabel + %80 = OpCompositeExtract %6 %133 0 + %81 = OpCompositeExtract %6 %133 1 + %82 = OpCompositeExtract %6 %133 2 + %83 = OpCompositeConstruct %76 %80 %81 %82 %28 + OpStore %78 %83 + OpReturn + OpFunctionEnd + %84 = OpFunction %2 None %3 + %85 = OpLabel + OpKill + OpFunctionEnd +END + +# uniforms for variant + +# injectionSwitch +BUFFER variant_injectionSwitch DATA_TYPE vec2 DATA + 0.0 1.0 +END + +BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM + +PIPELINE graphics variant_pipeline + ATTACH variant_vertex_shader + ATTACH variant_fragment_shader + FRAMEBUFFER_SIZE 256 256 + BIND BUFFER variant_framebuffer AS color LOCATION 0 + BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0 +END +CLEAR_COLOR variant_pipeline 0 0 0 255 + +CLEAR variant_pipeline +RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 + +EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 diff --git a/external/vulkancts/mustpass/master/vk-default-no-waivers.txt b/external/vulkancts/mustpass/master/vk-default-no-waivers.txt index 8f4cf13..07e43be 100644 --- a/external/vulkancts/mustpass/master/vk-default-no-waivers.txt +++ b/external/vulkancts/mustpass/master/vk-default-no-waivers.txt @@ -561671,6 +561671,7 @@ dEQP-VK.graphicsfuzz.unreachable-discard-statement dEQP-VK.graphicsfuzz.unreachable-loops dEQP-VK.graphicsfuzz.unreachable-loops-in-switch dEQP-VK.graphicsfuzz.unreachable-return-in-loop +dEQP-VK.graphicsfuzz.unreachable-switch-case-with-discards dEQP-VK.graphicsfuzz.while-function-always-false dEQP-VK.graphicsfuzz.while-inside-switch dEQP-VK.graphicsfuzz.write-before-break diff --git a/external/vulkancts/mustpass/master/vk-default.txt b/external/vulkancts/mustpass/master/vk-default.txt index 23dce48..7b3c212 100644 --- a/external/vulkancts/mustpass/master/vk-default.txt +++ b/external/vulkancts/mustpass/master/vk-default.txt @@ -561518,6 +561518,7 @@ dEQP-VK.graphicsfuzz.unreachable-discard-statement dEQP-VK.graphicsfuzz.unreachable-loops dEQP-VK.graphicsfuzz.unreachable-loops-in-switch dEQP-VK.graphicsfuzz.unreachable-return-in-loop +dEQP-VK.graphicsfuzz.unreachable-switch-case-with-discards dEQP-VK.graphicsfuzz.while-function-always-false dEQP-VK.graphicsfuzz.while-inside-switch dEQP-VK.graphicsfuzz.write-before-break -- 2.7.4