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 that assigns vector values
22 # The test passes because shader always writes red.
24 # Optimized using spirv-opt with the following arguments:
25 # '--eliminate-dead-branches'
26 # '--eliminate-dead-inserts'
27 # '--combine-access-chains'
28 # '--eliminate-local-multi-store'
29 # '--simplify-instructions'
30 # '--eliminate-dead-branches'
32 # '--combine-access-chains'
33 # '--eliminate-local-single-store'
34 # '--eliminate-local-multi-store'
35 # '--eliminate-dead-inserts'
37 # '--copy-propagate-arrays'
38 # '--combine-access-chains'
39 # spirv-opt commit hash: e82a428605f6ce0a07337b36f8ba3935c9f165ac
43 SHADER vertex variant_vertex_shader PASSTHROUGH
45 # variant_fragment_shader is derived from the following GLSL:
47 # precision highp float;
49 # layout(location = 0) out vec4 _GLF_color;
56 # vec2 coord = vec2(1.0);
58 # if (int(coord.y) < 180) // Always true
70 # _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
72 # _GLF_color = vec4(0.0, 0.0, 0.0, 1.0);
74 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
77 ; Generator: Khronos Glslang Reference Front End; 8
81 %1 = OpExtInstImport "GLSL.std.450"
82 OpMemoryModel Logical GLSL450
83 OpEntryPoint Fragment %4 "main" %49
84 OpExecutionMode %4 OriginUpperLeft
92 OpName %49 "_GLF_color"
93 OpDecorate %8 RelaxedPrecision
94 OpDecorate %44 RelaxedPrecision
95 OpDecorate %49 Location 0
97 %3 = OpTypeFunction %2
99 %7 = OpTypeFunction %6
101 %11 = OpTypeVector %10 2
102 %12 = OpTypePointer Function %11
103 %14 = OpConstant %10 1
104 %15 = OpConstantComposite %11 %14 %14
106 %17 = OpConstant %16 1
107 %18 = OpTypePointer Function %10
108 %22 = OpConstant %6 180
110 %28 = OpTypeArray %10 %17
111 %29 = OpTypePointer Function %28
112 %31 = OpConstant %6 0
113 %36 = OpTypeVector %10 4
114 %37 = OpTypePointer Function %36
115 %41 = OpConstant %6 1
116 %48 = OpTypePointer Output %36
117 %49 = OpVariable %48 Output
118 %50 = OpConstant %10 0
119 %51 = OpConstantComposite %36 %14 %50 %50 %14
120 %53 = OpConstantComposite %36 %50 %50 %50 %14
121 %4 = OpFunction %2 None %3
123 %44 = OpFunctionCall %6 %8
124 %45 = OpIEqual %23 %44 %41
125 OpSelectionMerge %47 None
126 OpBranchConditional %45 %46 %52
136 %8 = OpFunction %6 None %7
138 %13 = OpVariable %12 Function
139 %27 = OpVariable %18 Function
140 %30 = OpVariable %29 Function
141 %38 = OpVariable %37 Function
143 %19 = OpAccessChain %18 %13 %17
145 %21 = OpConvertFToS %6 %20
146 %24 = OpSLessThan %23 %21 %22
147 OpSelectionMerge %26 None
148 OpBranchConditional %24 %25 %34
150 %32 = OpAccessChain %18 %30 %31
157 %40 = OpCompositeConstruct %36 %33 %33 %33 %33
164 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
166 PIPELINE graphics variant_pipeline
167 ATTACH variant_vertex_shader
168 ATTACH variant_fragment_shader
169 FRAMEBUFFER_SIZE 256 256
170 BIND BUFFER variant_framebuffer AS color LOCATION 0
172 CLEAR_COLOR variant_pipeline 0 0 0 255
174 CLEAR variant_pipeline
175 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
177 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255