3 # Copyright 2019 Google LLC
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 # A test for a coverage-gap found by GraphicsFuzz.
20 # Short description: A fragment shader that covers a specific const folding rule path.
22 # The test passes because shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # precision highp float;
30 # layout(location = 0) out vec4 _GLF_color;
34 # // If condition is always false.
37 # vec4(3000.0, 1.0, 8.0, 4.0),
38 # vec4(2.0, 3.0, determinant(mat2(2.0, 0.0, 0.0, 2.0)), 5.0), // min = (2, 3, 4, 5)
39 # vec4(6.0) // max = (6, 6, 6, 6)
40 # ) != vec4(6, 3, 6, 5)
42 # _GLF_color = vec4(0);
44 # _GLF_color = vec4(1, 0, 0, 1);
46 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
49 ; Generator: Khronos Glslang Reference Front End; 8
53 %1 = OpExtInstImport "GLSL.std.450"
54 OpMemoryModel Logical GLSL450
55 OpEntryPoint Fragment %4 "main" %35
56 OpExecutionMode %4 OriginUpperLeft
59 OpName %35 "_GLF_color"
60 OpDecorate %35 Location 0
62 %3 = OpTypeFunction %2
64 %7 = OpTypeVector %6 4
65 %8 = OpConstant %6 3000
69 %12 = OpConstantComposite %7 %8 %9 %10 %11
72 %15 = OpTypeVector %6 2
73 %16 = OpTypeMatrix %15 2
75 %18 = OpConstantComposite %15 %13 %17
76 %19 = OpConstantComposite %15 %17 %13
77 %20 = OpConstantComposite %16 %18 %19
80 %25 = OpConstantComposite %7 %24 %24 %24 %24
81 %27 = OpConstantComposite %7 %24 %14 %24 %22
83 %29 = OpTypeVector %28 4
84 %34 = OpTypePointer Output %7
85 %35 = OpVariable %34 Output
86 %36 = OpConstantComposite %7 %17 %17 %17 %17
87 %38 = OpConstantComposite %7 %9 %17 %17 %9
88 %4 = OpFunction %2 None %3
90 %21 = OpExtInst %6 %1 Determinant %20
91 %23 = OpCompositeConstruct %7 %13 %14 %21 %22
92 %26 = OpExtInst %7 %1 FClamp %12 %23 %25
93 %30 = OpFOrdNotEqual %29 %26 %27
95 OpSelectionMerge %33 None
96 OpBranchConditional %31 %32 %37
109 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
111 PIPELINE graphics variant_pipeline
112 ATTACH variant_vertex_shader
113 ATTACH variant_fragment_shader
114 FRAMEBUFFER_SIZE 256 256
115 BIND BUFFER variant_framebuffer AS color LOCATION 0
117 CLEAR_COLOR variant_pipeline 0 0 0 255
119 CLEAR variant_pipeline
120 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
122 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255