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 bug found by GraphicsFuzz.
20 # Short description: A fragment shader with two loops and some matrices
22 # The test passes because the fragment shader always writes red; the loops do nothing.
23 # The second loop condition is always false.
25 SHADER vertex variant_vertex_shader PASSTHROUGH
27 # variant_fragment_shader is derived from the following GLSL:
29 # precision highp float;
31 # layout(location = 0) out vec4 _GLF_color;
33 # layout(set = 0, binding = 0) uniform buf0
50 # matrix_a_uni[0][0] < -1.0;
53 # matrix_b[b] = (b > 1 ? min(matrix_b, matrix_b) : matrix_u)[1];
55 # _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
57 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
60 ; Generator: Khronos Glslang Reference Front End; 7
64 %1 = OpExtInstImport "GLSL.std.450"
65 OpMemoryModel Logical GLSL450
66 OpEntryPoint Fragment %4 "main" %66
67 OpExecutionMode %4 OriginUpperLeft
74 OpMemberName %36 0 "matrix_a_uni"
77 OpName %66 "_GLF_color"
78 OpDecorate %8 RelaxedPrecision
79 OpDecorate %15 RelaxedPrecision
80 OpDecorate %23 RelaxedPrecision
81 OpDecorate %27 RelaxedPrecision
82 OpDecorate %28 RelaxedPrecision
83 OpDecorate %29 RelaxedPrecision
84 OpMemberDecorate %36 0 ColMajor
85 OpMemberDecorate %36 0 Offset 0
86 OpMemberDecorate %36 0 MatrixStride 16
88 OpDecorate %38 DescriptorSet 0
89 OpDecorate %38 Binding 0
90 OpDecorate %48 RelaxedPrecision
91 OpDecorate %49 RelaxedPrecision
92 OpDecorate %63 RelaxedPrecision
93 OpDecorate %64 RelaxedPrecision
94 OpDecorate %66 Location 0
96 %3 = OpTypeFunction %2
98 %7 = OpTypePointer Function %6
100 %16 = OpConstant %6 1
103 %20 = OpTypeVector %19 4
104 %21 = OpTypePointer Function %20
105 %24 = OpConstant %19 1
106 %25 = OpTypePointer Function %19
107 %35 = OpTypeMatrix %20 4
108 %36 = OpTypeStruct %35
109 %37 = OpTypePointer Uniform %36
110 %38 = OpVariable %37 Uniform
111 %39 = OpConstant %6 0
113 %41 = OpConstant %40 0
114 %42 = OpTypePointer Uniform %19
115 %45 = OpConstant %19 -1
116 %59 = OpConstant %40 1
117 %65 = OpTypePointer Output %20
118 %66 = OpVariable %65 Output
119 %67 = OpConstant %19 0
120 %68 = OpConstantComposite %20 %24 %67 %67 %24
121 %4 = OpFunction %2 None %3
123 %8 = OpVariable %7 Function
124 %22 = OpVariable %21 Function
125 %29 = OpVariable %7 Function
126 %47 = OpVariable %21 Function
127 %51 = OpVariable %21 Function
131 OpLoopMerge %12 %13 None
135 %18 = OpSGreaterThanEqual %17 %15 %16
136 OpBranchConditional %18 %11 %12
139 %26 = OpAccessChain %25 %22 %23
144 %28 = OpISub %6 %27 %16
151 OpLoopMerge %32 %33 None
154 %43 = OpAccessChain %42 %38 %39 %39 %41
156 %46 = OpFOrdLessThan %17 %44 %45
157 OpBranchConditional %46 %31 %32
161 %50 = OpSGreaterThan %17 %49 %16
162 OpSelectionMerge %53 None
163 OpBranchConditional %50 %52 %57
167 %56 = OpExtInst %20 %1 FMin %54 %55
175 %60 = OpAccessChain %25 %51 %59
177 %62 = OpAccessChain %25 %47 %48
182 %64 = OpISub %6 %63 %16
191 # uniforms for variant
194 BUFFER variant_matrix_a_uni DATA_TYPE mat4x4<float> DATA
195 1.0 5.0 3.0 7.0 9.0 6.0 7.0 8.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0
198 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
200 PIPELINE graphics variant_pipeline
201 ATTACH variant_vertex_shader
202 ATTACH variant_fragment_shader
203 FRAMEBUFFER_SIZE 256 256
204 BIND BUFFER variant_framebuffer AS color LOCATION 0
205 BIND BUFFER variant_matrix_a_uni AS uniform DESCRIPTOR_SET 0 BINDING 0
207 CLEAR_COLOR variant_pipeline 0 0 0 255
209 CLEAR variant_pipeline
210 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
212 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255