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