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_0 _GLF_uniform_int_values[0] 29# #define _int_1 _GLF_uniform_int_values[1] 30# 31# precision highp int; 32# precision highp float; 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# layout(location = 0) out vec4 _GLF_color; 40# 41# void main() 42# { 43# int a = -7563; 44# 45# // Always true. 46# if(_int_1 / a == _int_0) 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: 51 60; Schema: 0 61 OpCapability Shader 62 %1 = OpExtInstImport "GLSL.std.450" 63 OpMemoryModel Logical GLSL450 64 OpEntryPoint Fragment %4 "main" %32 65 OpExecutionMode %4 OriginUpperLeft 66 OpSource ESSL 320 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 %32 "_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 %32 Location 0 79 %2 = OpTypeVoid 80 %3 = OpTypeFunction %2 81 %6 = OpTypeInt 32 1 82 %7 = OpTypePointer Function %6 83 %9 = OpConstant %6 -7563 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 = OpConstant %6 1 92 %18 = OpTypePointer Uniform %6 93 %25 = OpTypeBool 94 %29 = OpTypeFloat 32 95 %30 = OpTypeVector %29 4 96 %31 = OpTypePointer Output %30 97 %32 = OpVariable %31 Output 98 %4 = OpFunction %2 None %3 99 %5 = OpLabel 100 %8 = OpVariable %7 Function 101 OpStore %8 %9 102 %19 = OpAccessChain %18 %15 %16 %17 103 %20 = OpLoad %6 %19 104 %21 = OpLoad %6 %8 105 %22 = OpSDiv %6 %20 %21 106 %23 = OpAccessChain %18 %15 %16 %16 107 %24 = OpLoad %6 %23 108 %26 = OpIEqual %25 %22 %24 109 OpSelectionMerge %28 None 110 OpBranchConditional %26 %27 %46 111 %27 = OpLabel 112 %33 = OpAccessChain %18 %15 %16 %17 113 %34 = OpLoad %6 %33 114 %35 = OpConvertSToF %29 %34 115 %36 = OpAccessChain %18 %15 %16 %16 116 %37 = OpLoad %6 %36 117 %38 = OpConvertSToF %29 %37 118 %39 = OpAccessChain %18 %15 %16 %16 119 %40 = OpLoad %6 %39 120 %41 = OpConvertSToF %29 %40 121 %42 = OpAccessChain %18 %15 %16 %17 122 %43 = OpLoad %6 %42 123 %44 = OpConvertSToF %29 %43 124 %45 = OpCompositeConstruct %30 %35 %38 %41 %44 125 OpStore %32 %45 126 OpBranch %28 127 %46 = OpLabel 128 %47 = OpAccessChain %18 %15 %16 %16 129 %48 = OpLoad %6 %47 130 %49 = OpConvertSToF %29 %48 131 %50 = OpCompositeConstruct %30 %49 %49 %49 %49 132 OpStore %32 %50 133 OpBranch %28 134 %28 = OpLabel 135 OpReturn 136 OpFunctionEnd 137END 138 139# uniforms for variant 140 141# _GLF_uniform_int_values 142BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 143 0 1 144END 145 146BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 147 148PIPELINE graphics variant_pipeline 149 ATTACH variant_vertex_shader 150 ATTACH variant_fragment_shader 151 FRAMEBUFFER_SIZE 256 256 152 BIND BUFFER variant_framebuffer AS color LOCATION 0 153 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0 154END 155CLEAR_COLOR variant_pipeline 0 0 0 255 156 157CLEAR variant_pipeline 158RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 159 160EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 161