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