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 combine shifts 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_0 _GLF_uniform_int_values[0] 29# #define _int_1 _GLF_uniform_int_values[1] 30# 31# precision highp float; 32# precision highp int; 33# 34# // Contents of _GLF_uniform_int_values: [0, 1] 35# layout(set = 0, binding = 0) uniform buf0 36# { 37# int _GLF_uniform_int_values[2]; 38# }; 39# 40# layout(location = 0) out vec4 _GLF_color; 41# 42# void main() 43# { 44# // Always zero. 45# int i = bitfieldExtract(_int_0, bitCount(0), _int_1); 46# 47# if (i == _int_0) 48# { 49# _GLF_color = vec4(_int_1, i, i, _int_1); 50# } 51# else 52# { 53# _GLF_color = vec4(i); 54# } 55# } 56SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 57; SPIR-V 58; Version: 1.0 59; Generator: Khronos Glslang Reference Front End; 8 60; Bound: 50 61; Schema: 0 62 OpCapability Shader 63 %1 = OpExtInstImport "GLSL.std.450" 64 OpMemoryModel Logical GLSL450 65 OpEntryPoint Fragment %4 "main" %34 66 OpExecutionMode %4 OriginUpperLeft 67 OpSource ESSL 310 68 OpName %4 "main" 69 OpName %8 "i" 70 OpName %12 "buf0" 71 OpMemberName %12 0 "_GLF_uniform_int_values" 72 OpName %14 "" 73 OpName %34 "_GLF_color" 74 OpDecorate %11 ArrayStride 16 75 OpMemberDecorate %12 0 Offset 0 76 OpDecorate %12 Block 77 OpDecorate %14 DescriptorSet 0 78 OpDecorate %14 Binding 0 79 OpDecorate %19 RelaxedPrecision 80 OpDecorate %34 Location 0 81 %2 = OpTypeVoid 82 %3 = OpTypeFunction %2 83 %6 = OpTypeInt 32 1 84 %7 = OpTypePointer Function %6 85 %9 = OpTypeInt 32 0 86 %10 = OpConstant %9 2 87 %11 = OpTypeArray %6 %10 88 %12 = OpTypeStruct %11 89 %13 = OpTypePointer Uniform %12 90 %14 = OpVariable %13 Uniform 91 %15 = OpConstant %6 0 92 %16 = OpTypePointer Uniform %6 93 %20 = OpConstant %6 1 94 %27 = OpTypeBool 95 %31 = OpTypeFloat 32 96 %32 = OpTypeVector %31 4 97 %33 = OpTypePointer Output %32 98 %34 = OpVariable %33 Output 99 %4 = OpFunction %2 None %3 100 %5 = OpLabel 101 %8 = OpVariable %7 Function 102 %17 = OpAccessChain %16 %14 %15 %15 103 %18 = OpLoad %6 %17 104 %19 = OpBitCount %6 %15 105 %21 = OpAccessChain %16 %14 %15 %20 106 %22 = OpLoad %6 %21 107 %23 = OpBitFieldSExtract %6 %18 %19 %22 108 OpStore %8 %23 109 %24 = OpLoad %6 %8 110 %25 = OpAccessChain %16 %14 %15 %15 111 %26 = OpLoad %6 %25 112 %28 = OpIEqual %27 %24 %26 113 OpSelectionMerge %30 None 114 OpBranchConditional %28 %29 %46 115 %29 = OpLabel 116 %35 = OpAccessChain %16 %14 %15 %20 117 %36 = OpLoad %6 %35 118 %37 = OpConvertSToF %31 %36 119 %38 = OpLoad %6 %8 120 %39 = OpConvertSToF %31 %38 121 %40 = OpLoad %6 %8 122 %41 = OpConvertSToF %31 %40 123 %42 = OpAccessChain %16 %14 %15 %20 124 %43 = OpLoad %6 %42 125 %44 = OpConvertSToF %31 %43 126 %45 = OpCompositeConstruct %32 %37 %39 %41 %44 127 OpStore %34 %45 128 OpBranch %30 129 %46 = OpLabel 130 %47 = OpLoad %6 %8 131 %48 = OpConvertSToF %31 %47 132 %49 = OpCompositeConstruct %32 %48 %48 %48 %48 133 OpStore %34 %49 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