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