dEQP-VK.graphicsfuzz.frag-coord-func-call-and-ifs
authorPaul Thomson <paulthomson@google.com>
Mon, 6 Apr 2020 15:31:47 +0000 (16:31 +0100)
committerPaul Thomson <paulthomson@google.com>
Thu, 23 Apr 2020 15:27:28 +0000 (16:27 +0100)
Components: Vulkan

New Tests:

dEQP-VK.graphicsfuzz.frag-coord-func-call-and-ifs

Change-Id: Ic28b0c96f8df99096e34b429e99e8b30a5b3a01c

android/cts/master/vk-master-2020-03-01.txt
android/cts/master/vk-master.txt
external/vulkancts/data/vulkan/amber/graphicsfuzz/frag-coord-func-call-and-ifs.amber [new file with mode: 0644]
external/vulkancts/data/vulkan/amber/graphicsfuzz/index.txt
external/vulkancts/mustpass/master/vk-default.txt

index 724debe..42ab5ea 100644 (file)
@@ -191399,6 +191399,7 @@ dEQP-VK.graphicsfuzz.find-msb-from-lsb
 dEQP-VK.graphicsfuzz.for-condition-always-false
 dEQP-VK.graphicsfuzz.for-loop-with-return
 dEQP-VK.graphicsfuzz.for-with-ifs-and-return
+dEQP-VK.graphicsfuzz.frag-coord-func-call-and-ifs
 dEQP-VK.graphicsfuzz.fragcoord-control-flow
 dEQP-VK.graphicsfuzz.fragcoord-control-flow-2
 dEQP-VK.graphicsfuzz.function-with-float-comparison
index 4717693..c98322c 100644 (file)
@@ -587813,6 +587813,7 @@ dEQP-VK.graphicsfuzz.find-msb-from-lsb
 dEQP-VK.graphicsfuzz.for-condition-always-false
 dEQP-VK.graphicsfuzz.for-loop-with-return
 dEQP-VK.graphicsfuzz.for-with-ifs-and-return
+dEQP-VK.graphicsfuzz.frag-coord-func-call-and-ifs
 dEQP-VK.graphicsfuzz.fragcoord-control-flow
 dEQP-VK.graphicsfuzz.fragcoord-control-flow-2
 dEQP-VK.graphicsfuzz.function-with-float-comparison
diff --git a/external/vulkancts/data/vulkan/amber/graphicsfuzz/frag-coord-func-call-and-ifs.amber b/external/vulkancts/data/vulkan/amber/graphicsfuzz/frag-coord-func-call-and-ifs.amber
new file mode 100644 (file)
index 0000000..455aed9
--- /dev/null
@@ -0,0 +1,350 @@
+#!amber
+
+# Copyright 2020 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 fragment shader with many uses of gl_FragCoord
+
+# The test passes because the shader always write red.
+
+# Optimized using spirv-opt with the following arguments:
+# '--scalar-replacement=100'
+# '--vector-dce'
+# '--combine-access-chains'
+# '--convert-local-access-chains'
+# '--eliminate-dead-code-aggressive'
+# '--private-to-local'
+# '--combine-access-chains'
+# '--reduce-load-size'
+# '--eliminate-dead-inserts'
+# '--combine-access-chains'
+# '--eliminate-local-single-store'
+# '--eliminate-local-single-block'
+# '--inline-entry-points-exhaustive'
+# '--combine-access-chains'
+# spirv-opt commit hash: e95fbfb1f509ad7a7fdfb72ac35fe412d72fc4a4
+
+
+
+SHADER vertex variant_vertex_shader PASSTHROUGH
+
+# variant_fragment_shader is derived from the following GLSL:
+# #version 310 es
+#
+# precision highp float;
+# precision highp int;
+#
+# layout(location = 0) out vec4 _GLF_color;
+#
+# layout(set = 0, binding = 0) uniform buf0 {
+#   // Always (0.0, 1.0).
+#   vec2 injectionSwitch;
+# };
+#
+# // coord is gl_FragCoord.xy.
+# // Always returns 0.
+# int alwaysZero(vec2 coord)
+# {
+#   // injectionSwitch.y is 1.0.
+#   float a = coord.y        < 50.0 ? injectionSwitch.y : 0.0;
+#   float b = gl_FragCoord.y < 50.0 ? 1.0               : 0.0;
+#
+#   // a == b. Thus, the condition is always true.
+#   if (a - b < 1.0)
+#   {
+#     return 0;
+#   }
+#   return 1;
+# }
+#
+# void main()
+# {
+#   int zero = alwaysZero(gl_FragCoord.xy);
+#
+#   // Always false.
+#   if (zero == 1)
+#   {
+#     return;
+#   }
+#
+#   // All conditions below are true.
+#   // So _GLF_color will end up as red: (1.0, 0.0, 0.0, 1.0).
+#    _GLF_color = vec4(0.0, 1.0, 1.0, 1.0);
+#
+#   // Always true.
+#   if (gl_FragCoord.x >= injectionSwitch.x)
+#   {
+#     // Always true.
+#     if (gl_FragCoord.y >= 0.0)
+#     {
+#       // _GLF_color.x = 1.0;
+#       _GLF_color.x = injectionSwitch.y;
+#     }
+#   }
+#
+#   // Always true.
+#   if (gl_FragCoord.y >= 0.0)
+#   {
+#     // _GLF_color.y = 0.0;
+#     _GLF_color.y = injectionSwitch.x;
+#   }
+#
+#   vec2 temp = vec2(gl_FragCoord.xy);
+#
+#   // Always true.
+#   if (temp.y >= 0.0)
+#   {
+#     // _GLF_color.z = 0.0;
+#     _GLF_color.z = injectionSwitch.x;
+#   }
+# }
+SHADER fragment variant_fragment_shader SPIRV-ASM
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 8
+; Bound: 137
+; Schema: 0
+               OpCapability Shader
+          %1 = OpExtInstImport "GLSL.std.450"
+               OpMemoryModel Logical GLSL450
+               OpEntryPoint Fragment %4 "main" %39 %68
+               OpExecutionMode %4 OriginUpperLeft
+               OpSource ESSL 310
+               OpName %4 "main"
+               OpName %12 "alwaysZero(vf2;"
+               OpName %11 "coord"
+               OpName %15 "a"
+               OpName %26 "buf0"
+               OpMemberName %26 0 "injectionSwitch"
+               OpName %28 ""
+               OpName %36 "b"
+               OpName %39 "gl_FragCoord"
+               OpName %57 "zero"
+               OpName %58 "param"
+               OpName %68 "_GLF_color"
+               OpName %95 "temp"
+               OpMemberDecorate %26 0 Offset 0
+               OpDecorate %26 Block
+               OpDecorate %28 DescriptorSet 0
+               OpDecorate %28 Binding 0
+               OpDecorate %39 BuiltIn FragCoord
+               OpDecorate %68 Location 0
+          %2 = OpTypeVoid
+          %3 = OpTypeFunction %2
+          %6 = OpTypeFloat 32
+          %7 = OpTypeVector %6 2
+          %8 = OpTypePointer Function %7
+          %9 = OpTypeInt 32 1
+         %10 = OpTypeFunction %9 %8
+         %14 = OpTypePointer Function %6
+         %16 = OpTypeInt 32 0
+         %17 = OpConstant %16 1
+         %20 = OpConstant %6 50
+         %21 = OpTypeBool
+         %26 = OpTypeStruct %7
+         %27 = OpTypePointer Uniform %26
+         %28 = OpVariable %27 Uniform
+         %29 = OpConstant %9 0
+         %30 = OpTypePointer Uniform %6
+         %34 = OpConstant %6 0
+         %37 = OpTypeVector %6 4
+         %38 = OpTypePointer Input %37
+         %39 = OpVariable %38 Input
+         %40 = OpTypePointer Input %6
+         %44 = OpConstant %6 1
+         %53 = OpConstant %9 1
+         %56 = OpTypePointer Function %9
+         %67 = OpTypePointer Output %37
+         %68 = OpVariable %67 Output
+         %69 = OpConstantComposite %37 %34 %44 %44 %44
+         %70 = OpConstant %16 0
+         %85 = OpTypePointer Output %6
+        %108 = OpConstant %16 2
+        %136 = OpConstantFalse %21
+          %4 = OpFunction %2 None %3
+          %5 = OpLabel
+        %111 = OpVariable %14 Function
+        %112 = OpVariable %14 Function
+        %113 = OpVariable %14 Function
+        %114 = OpVariable %56 Function
+         %57 = OpVariable %56 Function
+         %58 = OpVariable %8 Function
+         %95 = OpVariable %8 Function
+         %59 = OpLoad %37 %39
+         %60 = OpVectorShuffle %7 %59 %59 0 1
+               OpStore %58 %60
+               OpBranch %115
+        %115 = OpLabel
+               OpLoopMerge %116 %117 None
+               OpBranch %118
+        %118 = OpLabel
+        %119 = OpAccessChain %14 %58 %17
+        %120 = OpLoad %6 %119
+        %121 = OpFOrdLessThan %21 %120 %20
+               OpSelectionMerge %122 None
+               OpBranchConditional %121 %123 %124
+        %123 = OpLabel
+        %125 = OpAccessChain %30 %28 %29 %17
+        %126 = OpLoad %6 %125
+               OpStore %112 %126
+               OpBranch %122
+        %124 = OpLabel
+               OpStore %112 %34
+               OpBranch %122
+        %122 = OpLabel
+        %127 = OpLoad %6 %112
+               OpStore %111 %127
+        %128 = OpAccessChain %40 %39 %17
+        %129 = OpLoad %6 %128
+        %130 = OpFOrdLessThan %21 %129 %20
+        %131 = OpSelect %6 %130 %44 %34
+               OpStore %113 %131
+        %132 = OpFSub %6 %127 %131
+        %133 = OpFOrdLessThan %21 %132 %44
+               OpSelectionMerge %134 None
+               OpBranchConditional %133 %135 %134
+        %135 = OpLabel
+               OpStore %114 %29
+               OpBranch %116
+        %134 = OpLabel
+               OpStore %114 %53
+               OpBranch %116
+        %117 = OpLabel
+               OpBranchConditional %136 %115 %116
+        %116 = OpLabel
+         %61 = OpLoad %9 %114
+               OpStore %57 %61
+         %63 = OpIEqual %21 %61 %53
+               OpSelectionMerge %65 None
+               OpBranchConditional %63 %64 %65
+         %64 = OpLabel
+               OpReturn
+         %65 = OpLabel
+               OpStore %68 %69
+         %71 = OpAccessChain %40 %39 %70
+         %72 = OpLoad %6 %71
+         %73 = OpAccessChain %30 %28 %29 %70
+         %74 = OpLoad %6 %73
+         %75 = OpFOrdGreaterThanEqual %21 %72 %74
+               OpSelectionMerge %77 None
+               OpBranchConditional %75 %76 %77
+         %76 = OpLabel
+         %78 = OpAccessChain %40 %39 %17
+         %79 = OpLoad %6 %78
+         %80 = OpFOrdGreaterThanEqual %21 %79 %34
+               OpSelectionMerge %82 None
+               OpBranchConditional %80 %81 %82
+         %81 = OpLabel
+         %83 = OpAccessChain %30 %28 %29 %17
+         %84 = OpLoad %6 %83
+         %86 = OpAccessChain %85 %68 %70
+               OpStore %86 %84
+               OpBranch %82
+         %82 = OpLabel
+               OpBranch %77
+         %77 = OpLabel
+         %87 = OpAccessChain %40 %39 %17
+         %88 = OpLoad %6 %87
+         %89 = OpFOrdGreaterThanEqual %21 %88 %34
+               OpSelectionMerge %91 None
+               OpBranchConditional %89 %90 %91
+         %90 = OpLabel
+         %92 = OpAccessChain %30 %28 %29 %70
+         %93 = OpLoad %6 %92
+         %94 = OpAccessChain %85 %68 %17
+               OpStore %94 %93
+               OpBranch %91
+         %91 = OpLabel
+         %96 = OpLoad %37 %39
+         %97 = OpVectorShuffle %7 %96 %96 0 1
+         %98 = OpCompositeExtract %6 %97 0
+         %99 = OpCompositeExtract %6 %97 1
+        %100 = OpCompositeConstruct %7 %98 %99
+               OpStore %95 %100
+        %102 = OpCompositeExtract %6 %100 1
+        %103 = OpFOrdGreaterThanEqual %21 %102 %34
+               OpSelectionMerge %105 None
+               OpBranchConditional %103 %104 %105
+        %104 = OpLabel
+        %106 = OpAccessChain %30 %28 %29 %70
+        %107 = OpLoad %6 %106
+        %109 = OpAccessChain %85 %68 %108
+               OpStore %109 %107
+               OpBranch %105
+        %105 = OpLabel
+               OpReturn
+               OpFunctionEnd
+         %12 = OpFunction %9 None %10
+         %11 = OpFunctionParameter %8
+         %13 = OpLabel
+         %15 = OpVariable %14 Function
+         %23 = OpVariable %14 Function
+         %36 = OpVariable %14 Function
+         %18 = OpAccessChain %14 %11 %17
+         %19 = OpLoad %6 %18
+         %22 = OpFOrdLessThan %21 %19 %20
+               OpSelectionMerge %25 None
+               OpBranchConditional %22 %24 %33
+         %24 = OpLabel
+         %31 = OpAccessChain %30 %28 %29 %17
+         %32 = OpLoad %6 %31
+               OpStore %23 %32
+               OpBranch %25
+         %33 = OpLabel
+               OpStore %23 %34
+               OpBranch %25
+         %25 = OpLabel
+         %35 = OpLoad %6 %23
+               OpStore %15 %35
+         %41 = OpAccessChain %40 %39 %17
+         %42 = OpLoad %6 %41
+         %43 = OpFOrdLessThan %21 %42 %20
+         %45 = OpSelect %6 %43 %44 %34
+               OpStore %36 %45
+         %48 = OpFSub %6 %35 %45
+         %49 = OpFOrdLessThan %21 %48 %44
+               OpSelectionMerge %51 None
+               OpBranchConditional %49 %50 %51
+         %50 = OpLabel
+               OpReturnValue %29
+         %51 = OpLabel
+               OpReturnValue %53
+               OpFunctionEnd
+END
+
+# uniforms for variant
+
+# injectionSwitch
+BUFFER variant_injectionSwitch DATA_TYPE vec2<float> 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
index 501505c..659165d 100644 (file)
 {      "for-condition-always-false.amber",                             "for-condition-always-false",                   "A fragment shader that uses a for loop with condition always false"                                    },
 {      "for-loop-with-return.amber",                                   "for-loop-with-return",                                 "A fragment shader with a for loop that loops only once"                                                                },
 {      "for-with-ifs-and-return.amber",                                "for-with-ifs-and-return",                              "A fragment shader with two ifs and return/continue inside a for loop"                                  },
+{      "frag-coord-func-call-and-ifs.amber",                                                                                                           "frag-coord-func-call-and-ifs",                                                                                                         "A fragment shader with many uses of gl_FragCoord"                                                                      },
 {      "fragcoord-control-flow.amber",                                 "fragcoord-control-flow",                               "A fragment shader that uses FragCoord and somewhat complex control flow"                               },
 {      "fragcoord-control-flow-2.amber",                               "fragcoord-control-flow-2",                             "A fragment shader that uses FragCoord and somewhat complex control flow"                               },
 {      "function-with-float-comparison.amber",                                                                                                         "function-with-float-comparison",                                                                                                       "A fragment shader that compares a float and a coordinate"                                                      },
index 86fa504..9db38e4 100644 (file)
@@ -590083,6 +590083,7 @@ dEQP-VK.graphicsfuzz.find-msb-from-lsb
 dEQP-VK.graphicsfuzz.for-condition-always-false
 dEQP-VK.graphicsfuzz.for-loop-with-return
 dEQP-VK.graphicsfuzz.for-with-ifs-and-return
+dEQP-VK.graphicsfuzz.frag-coord-func-call-and-ifs
 dEQP-VK.graphicsfuzz.fragcoord-control-flow
 dEQP-VK.graphicsfuzz.fragcoord-control-flow-2
 dEQP-VK.graphicsfuzz.function-with-float-comparison