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 instruction simplification 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_0 _GLF_uniform_int_values[0] 29# #define _int_1 _GLF_uniform_int_values[1] 30# #define _float_1_0 _GLF_uniform_float_values[0] 31# 32# precision highp float; 33# 34# precision highp int; 35# 36# // Contents of _GLF_uniform_int_values: [0, 1] 37# layout(set = 0, binding = 0) uniform buf0 38# { 39# int _GLF_uniform_int_values[2]; 40# }; 41# 42# // Contents of _GLF_uniform_float_values: 1.0 43# layout(set = 0, binding = 1) uniform buf1 44# { 45# float _GLF_uniform_float_values[1]; 46# }; 47# 48# layout(location = 0) out vec4 _GLF_color; 49# 50# void main() 51# { 52# float a = vec2(_int_0, _int_1)[_int_0 | 1]; 53# if (a == _float_1_0) 54# { 55# _GLF_color = vec4(a, _int_0, _int_0, a); 56# } 57# else 58# { 59# _GLF_color = vec4(a); 60# } 61# } 62SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 63; SPIR-V 64; Version: 1.0 65; Generator: Khronos Glslang Reference Front End; 8 66; Bound: 59 67; Schema: 0 68 OpCapability Shader 69 %1 = OpExtInstImport "GLSL.std.450" 70 OpMemoryModel Logical GLSL450 71 OpEntryPoint Fragment %4 "main" %46 72 OpExecutionMode %4 OriginUpperLeft 73 OpSource ESSL 310 74 OpName %4 "main" 75 OpName %8 "a" 76 OpName %13 "buf0" 77 OpMemberName %13 0 "_GLF_uniform_int_values" 78 OpName %15 "" 79 OpName %34 "buf1" 80 OpMemberName %34 0 "_GLF_uniform_float_values" 81 OpName %36 "" 82 OpName %46 "_GLF_color" 83 OpDecorate %12 ArrayStride 16 84 OpMemberDecorate %13 0 Offset 0 85 OpDecorate %13 Block 86 OpDecorate %15 DescriptorSet 0 87 OpDecorate %15 Binding 0 88 OpDecorate %33 ArrayStride 16 89 OpMemberDecorate %34 0 Offset 0 90 OpDecorate %34 Block 91 OpDecorate %36 DescriptorSet 0 92 OpDecorate %36 Binding 1 93 OpDecorate %46 Location 0 94 %2 = OpTypeVoid 95 %3 = OpTypeFunction %2 96 %6 = OpTypeFloat 32 97 %7 = OpTypePointer Function %6 98 %9 = OpTypeInt 32 1 99 %10 = OpTypeInt 32 0 100 %11 = OpConstant %10 2 101 %12 = OpTypeArray %9 %11 102 %13 = OpTypeStruct %12 103 %14 = OpTypePointer Uniform %13 104 %15 = OpVariable %14 Uniform 105 %16 = OpConstant %9 0 106 %17 = OpTypePointer Uniform %9 107 %21 = OpConstant %9 1 108 %25 = OpTypeVector %6 2 109 %32 = OpConstant %10 1 110 %33 = OpTypeArray %6 %32 111 %34 = OpTypeStruct %33 112 %35 = OpTypePointer Uniform %34 113 %36 = OpVariable %35 Uniform 114 %37 = OpTypePointer Uniform %6 115 %40 = OpTypeBool 116 %44 = OpTypeVector %6 4 117 %45 = OpTypePointer Output %44 118 %46 = OpVariable %45 Output 119 %4 = OpFunction %2 None %3 120 %5 = OpLabel 121 %8 = OpVariable %7 Function 122 %18 = OpAccessChain %17 %15 %16 %16 123 %19 = OpLoad %9 %18 124 %20 = OpConvertSToF %6 %19 125 %22 = OpAccessChain %17 %15 %16 %21 126 %23 = OpLoad %9 %22 127 %24 = OpConvertSToF %6 %23 128 %26 = OpCompositeConstruct %25 %20 %24 129 %27 = OpAccessChain %17 %15 %16 %16 130 %28 = OpLoad %9 %27 131 %29 = OpBitwiseOr %9 %28 %21 132 %30 = OpVectorExtractDynamic %6 %26 %29 133 OpStore %8 %30 134 %31 = OpLoad %6 %8 135 %38 = OpAccessChain %37 %36 %16 %16 136 %39 = OpLoad %6 %38 137 %41 = OpFOrdEqual %40 %31 %39 138 OpSelectionMerge %43 None 139 OpBranchConditional %41 %42 %56 140 %42 = OpLabel 141 %47 = OpLoad %6 %8 142 %48 = OpAccessChain %17 %15 %16 %16 143 %49 = OpLoad %9 %48 144 %50 = OpConvertSToF %6 %49 145 %51 = OpAccessChain %17 %15 %16 %16 146 %52 = OpLoad %9 %51 147 %53 = OpConvertSToF %6 %52 148 %54 = OpLoad %6 %8 149 %55 = OpCompositeConstruct %44 %47 %50 %53 %54 150 OpStore %46 %55 151 OpBranch %43 152 %56 = OpLabel 153 %57 = OpLoad %6 %8 154 %58 = OpCompositeConstruct %44 %57 %57 %57 %57 155 OpStore %46 %58 156 OpBranch %43 157 %43 = OpLabel 158 OpReturn 159 OpFunctionEnd 160END 161 162# uniforms for variant 163 164# _GLF_uniform_float_values 165BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA 166 1.0 167END 168# _GLF_uniform_int_values 169BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 170 0 1 171END 172 173BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 174 175PIPELINE graphics variant_pipeline 176 ATTACH variant_vertex_shader 177 ATTACH variant_fragment_shader 178 FRAMEBUFFER_SIZE 256 256 179 BIND BUFFER variant_framebuffer AS color LOCATION 0 180 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1 181 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0 182END 183CLEAR_COLOR variant_pipeline 0 0 0 255 184 185CLEAR variant_pipeline 186RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 187 188EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 189