3 # Copyright 2021 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: A fragment shader that covers specific NIR 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:
29 # #define _int_0 _GLF_uniform_int_values[0]
30 # #define _float_1_0 _GLF_uniform_float_values[0]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_float_values: 1.0
36 # layout(set = 0, binding = 0) uniform buf0
38 # float _GLF_uniform_float_values[1];
40 # // Contents of _GLF_uniform_int_values: 0
41 # layout(set = 0, binding = 1) uniform buf1
43 # int _GLF_uniform_int_values[1];
45 # layout(location = 0) out vec4 _GLF_color;
49 # vec4 v = clamp(cosh(vec4(1.0)), _float_1_0, 1.0);
50 # _GLF_color = vec4(v.x, _int_0, _int_0, v.z);
52 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
55 ; Generator: Khronos Glslang Reference Front End; 10
59 %1 = OpExtInstImport "GLSL.std.450"
60 OpMemoryModel Logical GLSL450
61 OpEntryPoint Fragment %4 "main" %28
62 OpExecutionMode %4 OriginUpperLeft
67 OpMemberName %16 0 "_GLF_uniform_float_values"
69 OpName %28 "_GLF_color"
71 OpMemberName %34 0 "_GLF_uniform_int_values"
73 OpDecorate %15 ArrayStride 16
74 OpMemberDecorate %16 0 Offset 0
76 OpDecorate %18 DescriptorSet 0
77 OpDecorate %18 Binding 0
78 OpDecorate %28 Location 0
79 OpDecorate %33 ArrayStride 16
80 OpMemberDecorate %34 0 Offset 0
82 OpDecorate %36 DescriptorSet 0
83 OpDecorate %36 Binding 1
85 %3 = OpTypeFunction %2
87 %7 = OpTypeVector %6 4
88 %8 = OpTypePointer Function %7
90 %11 = OpConstantComposite %7 %10 %10 %10 %10
92 %14 = OpConstant %13 1
93 %15 = OpTypeArray %6 %14
94 %16 = OpTypeStruct %15
95 %17 = OpTypePointer Uniform %16
96 %18 = OpVariable %17 Uniform
98 %20 = OpConstant %19 0
99 %21 = OpTypePointer Uniform %6
100 %27 = OpTypePointer Output %7
101 %28 = OpVariable %27 Output
102 %29 = OpConstant %13 0
103 %30 = OpTypePointer Function %6
104 %33 = OpTypeArray %19 %14
105 %34 = OpTypeStruct %33
106 %35 = OpTypePointer Uniform %34
107 %36 = OpVariable %35 Uniform
108 %37 = OpTypePointer Uniform %19
109 %44 = OpConstant %13 2
110 %4 = OpFunction %2 None %3
112 %9 = OpVariable %8 Function
113 %12 = OpExtInst %7 %1 Cosh %11
114 %22 = OpAccessChain %21 %18 %20 %20
116 %24 = OpCompositeConstruct %7 %23 %23 %23 %23
117 %25 = OpCompositeConstruct %7 %10 %10 %10 %10
118 %26 = OpExtInst %7 %1 FClamp %12 %24 %25
120 %31 = OpAccessChain %30 %9 %29
122 %38 = OpAccessChain %37 %36 %20 %20
124 %40 = OpConvertSToF %6 %39
125 %41 = OpAccessChain %37 %36 %20 %20
127 %43 = OpConvertSToF %6 %42
128 %45 = OpAccessChain %30 %9 %44
130 %47 = OpCompositeConstruct %7 %32 %40 %43 %46
136 # uniforms for variant
138 # _GLF_uniform_int_values
139 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
142 # _GLF_uniform_float_values
143 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
147 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
149 PIPELINE graphics variant_pipeline
150 ATTACH variant_vertex_shader
151 ATTACH variant_fragment_shader
152 FRAMEBUFFER_SIZE 256 256
153 BIND BUFFER variant_framebuffer AS color LOCATION 0
154 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
155 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
157 CLEAR_COLOR variant_pipeline 0 0 0 255
159 CLEAR variant_pipeline
160 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
162 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255