3 # Copyright 2020 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 the GraphicsFuzz project.
20 # Short description: Covers specific instruction simplifying and combining code paths
22 # The test passes because the shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # #define _int_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _int_5 _GLF_uniform_int_values[1]
32 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_int_values: [1, 0]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[2];
41 # layout(location = 0) out vec4 _GLF_color;
45 # int a = max(_int_1, max(_int_1, 1));
48 # _GLF_color = vec4(a, _int_0, _int_0, a);
52 # _GLF_color = vec4(a);
55 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
58 ; Generator: Khronos Glslang Reference Front End; 8
62 %1 = OpExtInstImport "GLSL.std.450"
63 OpMemoryModel Logical GLSL450
64 OpEntryPoint Fragment %4 "main" %34
65 OpExecutionMode %4 OriginUpperLeft
70 OpMemberName %12 0 "_GLF_uniform_int_values"
72 OpName %34 "_GLF_color"
73 OpDecorate %11 ArrayStride 16
74 OpMemberDecorate %12 0 Offset 0
76 OpDecorate %14 DescriptorSet 0
77 OpDecorate %14 Binding 0
78 OpDecorate %34 Location 0
80 %3 = OpTypeFunction %2
82 %7 = OpTypePointer Function %6
85 %11 = OpTypeArray %6 %10
86 %12 = OpTypeStruct %11
87 %13 = OpTypePointer Uniform %12
88 %14 = OpVariable %13 Uniform
90 %16 = OpTypePointer Uniform %6
94 %32 = OpTypeVector %31 4
95 %33 = OpTypePointer Output %32
96 %34 = OpVariable %33 Output
97 %4 = OpFunction %2 None %3
99 %8 = OpVariable %7 Function
100 %17 = OpAccessChain %16 %14 %15 %15
102 %19 = OpAccessChain %16 %14 %15 %15
104 %22 = OpExtInst %6 %1 SMax %20 %21
105 %23 = OpExtInst %6 %1 SMax %18 %22
108 %25 = OpAccessChain %16 %14 %15 %15
110 %28 = OpIEqual %27 %24 %26
111 OpSelectionMerge %30 None
112 OpBranchConditional %28 %29 %46
115 %36 = OpConvertSToF %31 %35
116 %37 = OpAccessChain %16 %14 %15 %21
118 %39 = OpConvertSToF %31 %38
119 %40 = OpAccessChain %16 %14 %15 %21
121 %42 = OpConvertSToF %31 %41
123 %44 = OpConvertSToF %31 %43
124 %45 = OpCompositeConstruct %32 %36 %39 %42 %44
129 %48 = OpConvertSToF %31 %47
130 %49 = OpCompositeConstruct %32 %48 %48 %48 %48
138 # uniforms for variant
140 # _GLF_uniform_int_values
141 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
145 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
147 PIPELINE graphics variant_pipeline
148 ATTACH variant_vertex_shader
149 ATTACH variant_fragment_shader
150 FRAMEBUFFER_SIZE 16 16
151 BIND BUFFER variant_framebuffer AS color LOCATION 0
152 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
154 CLEAR_COLOR variant_pipeline 0 0 0 255
156 CLEAR variant_pipeline
157 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
159 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255