1#!amber 2 3# Copyright 2020 Google LLC 4# 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 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 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. 16 17 18# A test for a coverage-gap found by the GraphicsFuzz project. 19 20# Short description: A fragment shader that covers a specific bitwise operator cobmining code path 21 22# The test passes because the shader always writes red. 23 24SHADER vertex variant_vertex_shader PASSTHROUGH 25 26# variant_fragment_shader is derived from the following GLSL: 27# #version 310 es 28# #define _int_1 _GLF_uniform_int_values[0] 29# #define _int_0 _GLF_uniform_int_values[1] 30# 31# precision highp float; 32# 33# // Contents of _GLF_uniform_int_values: [1, 0] 34# layout(set = 0, binding = 0) uniform buf0 35# { 36# int _GLF_uniform_int_values[2]; 37# }; 38# 39# // Contents of v1: [0.0, 1.0] 40# layout(set = 0, binding = 1) uniform buf1 41# { 42# vec2 v1; 43# }; 44# 45# layout(location = 0) out vec4 _GLF_color; 46# 47# void main() 48# { 49# bool b = true; 50# 51# // Always true. 52# if (v1.x > v1.y) 53# { 54# // Always false. 55# if (v1.x < v1.y) 56# { 57# b = false; 58# } 59# } 60# if (b) 61# { 62# _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1); 63# } 64# else 65# { 66# _GLF_color = vec4(_int_0); 67# } 68# } 69SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 70; SPIR-V 71; Version: 1.0 72; Generator: Khronos Glslang Reference Front End; 8 73; Bound: 67 74; Schema: 0 75 OpCapability Shader 76 %1 = OpExtInstImport "GLSL.std.450" 77 OpMemoryModel Logical GLSL450 78 OpEntryPoint Fragment %4 "main" %41 79 OpExecutionMode %4 OriginUpperLeft 80 OpSource ESSL 310 81 OpName %4 "main" 82 OpName %8 "b" 83 OpName %12 "buf1" 84 OpMemberName %12 0 "v1" 85 OpName %14 "" 86 OpName %41 "_GLF_color" 87 OpName %44 "buf0" 88 OpMemberName %44 0 "_GLF_uniform_int_values" 89 OpName %46 "" 90 OpMemberDecorate %12 0 Offset 0 91 OpDecorate %12 Block 92 OpDecorate %14 DescriptorSet 0 93 OpDecorate %14 Binding 1 94 OpDecorate %41 Location 0 95 OpDecorate %43 ArrayStride 16 96 OpMemberDecorate %44 0 RelaxedPrecision 97 OpMemberDecorate %44 0 Offset 0 98 OpDecorate %44 Block 99 OpDecorate %46 DescriptorSet 0 100 OpDecorate %46 Binding 0 101 OpDecorate %49 RelaxedPrecision 102 OpDecorate %53 RelaxedPrecision 103 OpDecorate %56 RelaxedPrecision 104 OpDecorate %59 RelaxedPrecision 105 OpDecorate %64 RelaxedPrecision 106 %2 = OpTypeVoid 107 %3 = OpTypeFunction %2 108 %6 = OpTypeBool 109 %7 = OpTypePointer Function %6 110 %9 = OpConstantTrue %6 111 %10 = OpTypeFloat 32 112 %11 = OpTypeVector %10 2 113 %12 = OpTypeStruct %11 114 %13 = OpTypePointer Uniform %12 115 %14 = OpVariable %13 Uniform 116 %15 = OpTypeInt 32 1 117 %16 = OpConstant %15 0 118 %17 = OpTypeInt 32 0 119 %18 = OpConstant %17 0 120 %19 = OpTypePointer Uniform %10 121 %22 = OpConstant %17 1 122 %35 = OpConstantFalse %6 123 %39 = OpTypeVector %10 4 124 %40 = OpTypePointer Output %39 125 %41 = OpVariable %40 Output 126 %42 = OpConstant %17 2 127 %43 = OpTypeArray %15 %42 128 %44 = OpTypeStruct %43 129 %45 = OpTypePointer Uniform %44 130 %46 = OpVariable %45 Uniform 131 %47 = OpTypePointer Uniform %15 132 %51 = OpConstant %15 1 133 %4 = OpFunction %2 None %3 134 %5 = OpLabel 135 %8 = OpVariable %7 Function 136 OpStore %8 %9 137 %20 = OpAccessChain %19 %14 %16 %18 138 %21 = OpLoad %10 %20 139 %23 = OpAccessChain %19 %14 %16 %22 140 %24 = OpLoad %10 %23 141 %25 = OpFOrdGreaterThan %6 %21 %24 142 OpSelectionMerge %27 None 143 OpBranchConditional %25 %26 %27 144 %26 = OpLabel 145 %28 = OpAccessChain %19 %14 %16 %18 146 %29 = OpLoad %10 %28 147 %30 = OpAccessChain %19 %14 %16 %22 148 %31 = OpLoad %10 %30 149 %32 = OpFOrdLessThan %6 %29 %31 150 OpSelectionMerge %34 None 151 OpBranchConditional %32 %33 %34 152 %33 = OpLabel 153 OpStore %8 %35 154 OpBranch %34 155 %34 = OpLabel 156 OpBranch %27 157 %27 = OpLabel 158 %36 = OpLoad %6 %8 159 OpSelectionMerge %38 None 160 OpBranchConditional %36 %37 %62 161 %37 = OpLabel 162 %48 = OpAccessChain %47 %46 %16 %16 163 %49 = OpLoad %15 %48 164 %50 = OpConvertSToF %10 %49 165 %52 = OpAccessChain %47 %46 %16 %51 166 %53 = OpLoad %15 %52 167 %54 = OpConvertSToF %10 %53 168 %55 = OpAccessChain %47 %46 %16 %51 169 %56 = OpLoad %15 %55 170 %57 = OpConvertSToF %10 %56 171 %58 = OpAccessChain %47 %46 %16 %16 172 %59 = OpLoad %15 %58 173 %60 = OpConvertSToF %10 %59 174 %61 = OpCompositeConstruct %39 %50 %54 %57 %60 175 OpStore %41 %61 176 OpBranch %38 177 %62 = OpLabel 178 %63 = OpAccessChain %47 %46 %16 %51 179 %64 = OpLoad %15 %63 180 %65 = OpConvertSToF %10 %64 181 %66 = OpCompositeConstruct %39 %65 %65 %65 %65 182 OpStore %41 %66 183 OpBranch %38 184 %38 = OpLabel 185 OpReturn 186 OpFunctionEnd 187END 188 189# uniforms for variant 190 191# v1 192BUFFER variant_v1 DATA_TYPE vec2<float> STD140 DATA 193 0.0 1.0 194END 195# _GLF_uniform_int_values 196BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 197 1 0 198END 199 200BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 201 202PIPELINE graphics variant_pipeline 203 ATTACH variant_vertex_shader 204 ATTACH variant_fragment_shader 205 FRAMEBUFFER_SIZE 256 256 206 BIND BUFFER variant_framebuffer AS color LOCATION 0 207 BIND BUFFER variant_v1 AS uniform DESCRIPTOR_SET 0 BINDING 1 208 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0 209END 210CLEAR_COLOR variant_pipeline 0 0 0 255 211 212CLEAR variant_pipeline 213RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 214 215EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 216