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