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: Fragment shader that uses 'transpose'
22 # The test passes because 'f' is invoked with a vector whose components are less than or equal to 1.0, so that it returns vec3(1.0, 0.0, 0.0), meaning that the output colour red is written
24 # Optimized using spirv-opt with the following arguments:
26 # spirv-opt commit hash: 6b072126595dd8c2448eb1fda616251c5e6d7079
30 SHADER vertex variant_vertex_shader PASSTHROUGH
32 # variant_fragment_shader is derived from the following GLSL:
34 # precision highp float;
36 # layout(location = 0) out vec4 _GLF_color;
45 # return vec3(1.0, 0.0, 0.0);
49 # _GLF_color = vec4(f(vec2(transpose((gl_FragCoord.y < 1.0) ? mat4x3(1.0) : transpose(mat3x4(1.0))))), 1.0);
51 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
54 ; Generator: Khronos Glslang Reference Front End; 7
58 %1 = OpExtInstImport "GLSL.std.450"
59 OpMemoryModel Logical GLSL450
60 OpEntryPoint Fragment %4 "main" %34 %36
61 OpExecutionMode %4 OriginUpperLeft
64 OpName %34 "_GLF_color"
65 OpName %36 "gl_FragCoord"
66 OpDecorate %34 Location 0
67 OpDecorate %36 BuiltIn FragCoord
69 %3 = OpTypeFunction %2
71 %9 = OpTypeVector %6 3
73 %15 = OpConstant %14 1
77 %29 = OpConstantComposite %9 %19 %28 %28
78 %32 = OpTypeVector %6 4
79 %33 = OpTypePointer Output %32
80 %34 = OpVariable %33 Output
81 %35 = OpTypePointer Input %32
82 %36 = OpVariable %35 Input
83 %37 = OpTypePointer Input %6
84 %41 = OpTypeMatrix %9 4
85 %46 = OpConstantComposite %9 %28 %19 %28
86 %47 = OpConstantComposite %9 %28 %28 %19
87 %48 = OpConstantComposite %9 %28 %28 %28
88 %49 = OpConstantComposite %41 %29 %46 %47 %48
89 %51 = OpTypeMatrix %32 3
90 %52 = OpConstantComposite %32 %19 %28 %28 %28
91 %53 = OpConstantComposite %32 %28 %19 %28 %28
92 %54 = OpConstantComposite %32 %28 %28 %19 %28
93 %55 = OpConstantComposite %51 %52 %53 %54
95 %4 = OpFunction %2 None %3
97 %38 = OpAccessChain %37 %36 %15
99 %40 = OpFOrdLessThan %20 %39 %19
100 OpSelectionMerge %45 None
101 OpBranchConditional %40 %44 %50
105 %56 = OpTranspose %41 %55
108 %94 = OpPhi %41 %49 %44 %56 %50
109 %58 = OpTranspose %51 %94
110 %60 = OpCompositeExtract %6 %58 0 1
113 OpLoopMerge %83 %84 None
116 %88 = OpFOrdGreaterThan %20 %60 %19
117 OpSelectionMerge %89 None
118 OpBranchConditional %88 %90 %89
126 %98 = OpPhi %9 %97 %90 %29 %89
127 %64 = OpCompositeExtract %6 %98 0
128 %65 = OpCompositeExtract %6 %98 1
129 %66 = OpCompositeExtract %6 %98 2
130 %67 = OpCompositeConstruct %32 %64 %65 %66 %19
136 # uniforms for variant
139 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
141 PIPELINE graphics variant_pipeline
142 ATTACH variant_vertex_shader
143 ATTACH variant_fragment_shader
144 FRAMEBUFFER_SIZE 256 256
145 BIND BUFFER variant_framebuffer AS color LOCATION 0
147 CLEAR_COLOR variant_pipeline 0 0 0 255
149 CLEAR variant_pipeline
150 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
152 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255