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