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 uniform value as a return
22 # The test passes because shader always writes color red
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # precision highp float;
30 # precision highp int;
32 # layout(location = 0) out vec4 _GLF_color;
34 # layout(set = 0, binding = 0) uniform buf0
36 # vec2 injectionSwitch;
40 # if (gl_FragCoord.y >= 0.0)
41 # return injectionSwitch.y;
44 # _GLF_color = vec4(1.0, 1.0, 1.0, 1.0);
53 # _GLF_color = vec4(fx(), 0.0, 0.0, 1.0);
62 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
65 ; Generator: Khronos Glslang Reference Front End; 8
69 %1 = OpExtInstImport "GLSL.std.450"
70 OpMemoryModel Logical GLSL450
71 OpEntryPoint Fragment %4 "main" %12 %40
72 OpExecutionMode %4 OriginUpperLeft
76 OpName %12 "gl_FragCoord"
78 OpMemberName %24 0 "injectionSwitch"
80 OpName %40 "_GLF_color"
84 OpDecorate %12 BuiltIn FragCoord
85 OpMemberDecorate %24 0 Offset 0
87 OpDecorate %26 DescriptorSet 0
88 OpDecorate %26 Binding 0
89 OpDecorate %40 Location 0
91 %3 = OpTypeFunction %2
93 %7 = OpTypeFunction %6
94 %10 = OpTypeVector %6 4
95 %11 = OpTypePointer Input %10
96 %12 = OpVariable %11 Input
98 %14 = OpConstant %13 1
99 %15 = OpTypePointer Input %6
100 %18 = OpConstant %6 0
102 %23 = OpTypeVector %6 2
103 %24 = OpTypeStruct %23
104 %25 = OpTypePointer Uniform %24
105 %26 = OpVariable %25 Uniform
107 %28 = OpConstant %27 0
108 %29 = OpTypePointer Uniform %6
109 %38 = OpConstantTrue %19
110 %39 = OpTypePointer Output %10
111 %40 = OpVariable %39 Output
112 %41 = OpConstant %6 1
113 %42 = OpConstantComposite %10 %41 %41 %41 %41
114 %44 = OpTypePointer Function %6
115 %55 = OpConstant %6 2
116 %4 = OpFunction %2 None %3
118 %45 = OpVariable %44 Function
119 %46 = OpVariable %44 Function
120 %57 = OpVariable %44 Function
123 %47 = OpFunctionCall %6 %8
124 %48 = OpCompositeConstruct %10 %47 %18 %18 %41
128 OpLoopMerge %51 %52 None
132 %56 = OpFOrdGreaterThan %19 %54 %55
133 OpBranchConditional %56 %50 %51
135 %58 = OpFunctionCall %6 %8
136 %59 = OpFunctionCall %6 %8
137 %60 = OpFSub %6 %58 %59
149 %8 = OpFunction %6 None %7
151 %16 = OpAccessChain %15 %12 %14
153 %20 = OpFOrdGreaterThanEqual %19 %17 %18
154 OpSelectionMerge %22 None
155 OpBranchConditional %20 %21 %22
157 %30 = OpAccessChain %29 %26 %28 %14
163 OpLoopMerge %35 %36 None
166 OpBranchConditional %38 %34 %35
178 # uniforms for variant
181 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
185 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
187 PIPELINE graphics variant_pipeline
188 ATTACH variant_vertex_shader
189 ATTACH variant_fragment_shader
190 FRAMEBUFFER_SIZE 256 256
191 BIND BUFFER variant_framebuffer AS color LOCATION 0
192 BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
194 CLEAR_COLOR variant_pipeline 0 0 0 255
196 CLEAR variant_pipeline
197 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
199 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255