#!amber # Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # A test for a coverage-gap found by the GraphicsFuzz project. # Short description: A fragment shader that covers specific LLVM code paths # The test passes because the shader always writes red. SHADER vertex variant_vertex_shader PASSTHROUGH # variant_fragment_shader is derived from the following GLSL: # #version 320 es # # #define _int_0 _GLF_uniform_int_values[0] # #define _int_7 _GLF_uniform_int_values[1] # #define _int_9 _GLF_uniform_int_values[2] # #define _int_1 _GLF_uniform_int_values[3] # #define _int_10 _GLF_uniform_int_values[4] # # precision highp float; # precision highp int; # # // Contents of _GLF_uniform_int_values: [0, 7, 9, 1, 10] # layout(set = 0, binding = 0) uniform buf0 # { # int _GLF_uniform_int_values[5]; # }; # # layout(location = 0) out vec4 _GLF_color; # # int arr0[10] = int[10](0, 0, 0, 0, 0, 0, 0, 0, 0, 0), arr1[10] = int[10](1, 2, 3, 4, 5, 6, 7, 8, 9, 10); # # void func(int x, int y) # { # int a = _int_1; # int b = _int_1; # # // Sets arr1[1..5] to zero. # while(x <= y) # { # if(b >= 6) # { # break; # } # # b++; # # arr1[a++] = arr0[_int_1]; # } # # // Same as arr0[x] = arr1[x]. # for(int i = x; i <= x; i ++) # { # arr0[i] = arr1[i]; # } # } # # void main() # { # // Iterates only i = 1. # for(int i = 1; i <= 1; i = 2 * i) # { # // Iterates j = 0, 2, 4, 6, and 8. # for(int j = 0; j < 10; j += 2 * i) # { # func(j, j + i); # } # } # # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1); # # // Check the results and output black if unexpected values are seen. # int ref[10] = int[10](_int_1, _int_0, _int_0, _int_0, _int_0, _int_0, _int_7, _int_0, _int_9, _int_0); # for(int i = _int_0; i < _int_10; i++) # { # if(arr0[i] != ref[i]) # { # _GLF_color = vec4(_int_0); # } # } # } SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 ; SPIR-V ; Version: 1.0 ; Generator: Khronos Glslang Reference Front End; 10 ; Bound: 181 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %4 "main" %117 OpExecutionMode %4 OriginUpperLeft OpSource ESSL 320 OpName %4 "main" OpName %11 "func(i1;i1;" OpName %9 "x" OpName %10 "y" OpName %17 "arr0" OpName %20 "arr1" OpName %32 "a" OpName %35 "buf0" OpMemberName %35 0 "_GLF_uniform_int_values" OpName %37 "" OpName %41 "b" OpName %68 "i" OpName %85 "i" OpName %93 "j" OpName %104 "param" OpName %106 "param" OpName %117 "_GLF_color" OpName %132 "ref" OpName %154 "i" OpDecorate %34 ArrayStride 16 OpMemberDecorate %35 0 Offset 0 OpDecorate %35 Block OpDecorate %37 DescriptorSet 0 OpDecorate %37 Binding 0 OpDecorate %117 Location 0 %2 = OpTypeVoid %3 = OpTypeFunction %2 %6 = OpTypeInt 32 1 %7 = OpTypePointer Function %6 %8 = OpTypeFunction %2 %7 %7 %13 = OpTypeInt 32 0 %14 = OpConstant %13 10 %15 = OpTypeArray %6 %14 %16 = OpTypePointer Private %15 %17 = OpVariable %16 Private %18 = OpConstant %6 0 %19 = OpConstantComposite %15 %18 %18 %18 %18 %18 %18 %18 %18 %18 %18 %20 = OpVariable %16 Private %21 = OpConstant %6 1 %22 = OpConstant %6 2 %23 = OpConstant %6 3 %24 = OpConstant %6 4 %25 = OpConstant %6 5 %26 = OpConstant %6 6 %27 = OpConstant %6 7 %28 = OpConstant %6 8 %29 = OpConstant %6 9 %30 = OpConstant %6 10 %31 = OpConstantComposite %15 %21 %22 %23 %24 %25 %26 %27 %28 %29 %30 %33 = OpConstant %13 5 %34 = OpTypeArray %6 %33 %35 = OpTypeStruct %34 %36 = OpTypePointer Uniform %35 %37 = OpVariable %36 Uniform %38 = OpTypePointer Uniform %6 %51 = OpTypeBool %64 = OpTypePointer Private %6 %114 = OpTypeFloat 32 %115 = OpTypeVector %114 4 %116 = OpTypePointer Output %115 %117 = OpVariable %116 Output %131 = OpTypePointer Function %15 %4 = OpFunction %2 None %3 %5 = OpLabel %85 = OpVariable %7 Function %93 = OpVariable %7 Function %104 = OpVariable %7 Function %106 = OpVariable %7 Function %132 = OpVariable %131 Function %154 = OpVariable %7 Function OpStore %17 %19 OpStore %20 %31 OpStore %85 %21 OpBranch %86 %86 = OpLabel OpLoopMerge %88 %89 None OpBranch %90 %90 = OpLabel %91 = OpLoad %6 %85 %92 = OpSLessThanEqual %51 %91 %21 OpBranchConditional %92 %87 %88 %87 = OpLabel OpStore %93 %18 OpBranch %94 %94 = OpLabel OpLoopMerge %96 %97 None OpBranch %98 %98 = OpLabel %99 = OpLoad %6 %93 %100 = OpSLessThan %51 %99 %30 OpBranchConditional %100 %95 %96 %95 = OpLabel %101 = OpLoad %6 %93 %102 = OpLoad %6 %85 %103 = OpIAdd %6 %101 %102 %105 = OpLoad %6 %93 OpStore %104 %105 OpStore %106 %103 %107 = OpFunctionCall %2 %11 %104 %106 OpBranch %97 %97 = OpLabel %108 = OpLoad %6 %85 %109 = OpIMul %6 %22 %108 %110 = OpLoad %6 %93 %111 = OpIAdd %6 %110 %109 OpStore %93 %111 OpBranch %94 %96 = OpLabel OpBranch %89 %89 = OpLabel %112 = OpLoad %6 %85 %113 = OpIMul %6 %22 %112 OpStore %85 %113 OpBranch %86 %88 = OpLabel %118 = OpAccessChain %38 %37 %18 %23 %119 = OpLoad %6 %118 %120 = OpConvertSToF %114 %119 %121 = OpAccessChain %38 %37 %18 %18 %122 = OpLoad %6 %121 %123 = OpConvertSToF %114 %122 %124 = OpAccessChain %38 %37 %18 %18 %125 = OpLoad %6 %124 %126 = OpConvertSToF %114 %125 %127 = OpAccessChain %38 %37 %18 %23 %128 = OpLoad %6 %127 %129 = OpConvertSToF %114 %128 %130 = OpCompositeConstruct %115 %120 %123 %126 %129 OpStore %117 %130 %133 = OpAccessChain %38 %37 %18 %23 %134 = OpLoad %6 %133 %135 = OpAccessChain %38 %37 %18 %18 %136 = OpLoad %6 %135 %137 = OpAccessChain %38 %37 %18 %18 %138 = OpLoad %6 %137 %139 = OpAccessChain %38 %37 %18 %18 %140 = OpLoad %6 %139 %141 = OpAccessChain %38 %37 %18 %18 %142 = OpLoad %6 %141 %143 = OpAccessChain %38 %37 %18 %18 %144 = OpLoad %6 %143 %145 = OpAccessChain %38 %37 %18 %21 %146 = OpLoad %6 %145 %147 = OpAccessChain %38 %37 %18 %18 %148 = OpLoad %6 %147 %149 = OpAccessChain %38 %37 %18 %22 %150 = OpLoad %6 %149 %151 = OpAccessChain %38 %37 %18 %18 %152 = OpLoad %6 %151 %153 = OpCompositeConstruct %15 %134 %136 %138 %140 %142 %144 %146 %148 %150 %152 OpStore %132 %153 %155 = OpAccessChain %38 %37 %18 %18 %156 = OpLoad %6 %155 OpStore %154 %156 OpBranch %157 %157 = OpLabel OpLoopMerge %159 %160 None OpBranch %161 %161 = OpLabel %162 = OpLoad %6 %154 %163 = OpAccessChain %38 %37 %18 %24 %164 = OpLoad %6 %163 %165 = OpSLessThan %51 %162 %164 OpBranchConditional %165 %158 %159 %158 = OpLabel %166 = OpLoad %6 %154 %167 = OpAccessChain %64 %17 %166 %168 = OpLoad %6 %167 %169 = OpLoad %6 %154 %170 = OpAccessChain %7 %132 %169 %171 = OpLoad %6 %170 %172 = OpINotEqual %51 %168 %171 OpSelectionMerge %174 None OpBranchConditional %172 %173 %174 %173 = OpLabel %175 = OpAccessChain %38 %37 %18 %18 %176 = OpLoad %6 %175 %177 = OpConvertSToF %114 %176 %178 = OpCompositeConstruct %115 %177 %177 %177 %177 OpStore %117 %178 OpBranch %174 %174 = OpLabel OpBranch %160 %160 = OpLabel %179 = OpLoad %6 %154 %180 = OpIAdd %6 %179 %21 OpStore %154 %180 OpBranch %157 %159 = OpLabel OpReturn OpFunctionEnd %11 = OpFunction %2 None %8 %9 = OpFunctionParameter %7 %10 = OpFunctionParameter %7 %12 = OpLabel %32 = OpVariable %7 Function %41 = OpVariable %7 Function %68 = OpVariable %7 Function %39 = OpAccessChain %38 %37 %18 %23 %40 = OpLoad %6 %39 OpStore %32 %40 %42 = OpAccessChain %38 %37 %18 %23 %43 = OpLoad %6 %42 OpStore %41 %43 OpBranch %44 %44 = OpLabel OpLoopMerge %46 %47 None OpBranch %48 %48 = OpLabel %49 = OpLoad %6 %9 %50 = OpLoad %6 %10 %52 = OpSLessThanEqual %51 %49 %50 OpBranchConditional %52 %45 %46 %45 = OpLabel %53 = OpLoad %6 %41 %54 = OpSGreaterThanEqual %51 %53 %26 OpSelectionMerge %56 None OpBranchConditional %54 %55 %56 %55 = OpLabel OpBranch %46 %56 = OpLabel %58 = OpLoad %6 %41 %59 = OpIAdd %6 %58 %21 OpStore %41 %59 %60 = OpLoad %6 %32 %61 = OpIAdd %6 %60 %21 OpStore %32 %61 %62 = OpAccessChain %38 %37 %18 %23 %63 = OpLoad %6 %62 %65 = OpAccessChain %64 %17 %63 %66 = OpLoad %6 %65 %67 = OpAccessChain %64 %20 %60 OpStore %67 %66 OpBranch %47 %47 = OpLabel OpBranch %44 %46 = OpLabel %69 = OpLoad %6 %9 OpStore %68 %69 OpBranch %70 %70 = OpLabel OpLoopMerge %72 %73 None OpBranch %74 %74 = OpLabel %75 = OpLoad %6 %68 %76 = OpLoad %6 %9 %77 = OpSLessThanEqual %51 %75 %76 OpBranchConditional %77 %71 %72 %71 = OpLabel %78 = OpLoad %6 %68 %79 = OpLoad %6 %68 %80 = OpAccessChain %64 %20 %79 %81 = OpLoad %6 %80 %82 = OpAccessChain %64 %17 %78 OpStore %82 %81 OpBranch %73 %73 = OpLabel %83 = OpLoad %6 %68 %84 = OpIAdd %6 %83 %21 OpStore %68 %84 OpBranch %70 %72 = OpLabel OpReturn OpFunctionEnd END # uniforms for variant # _GLF_uniform_int_values BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 0 7 9 1 10 END BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM PIPELINE graphics variant_pipeline ATTACH variant_vertex_shader ATTACH variant_fragment_shader FRAMEBUFFER_SIZE 16 16 BIND BUFFER variant_framebuffer AS color LOCATION 0 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0 END CLEAR_COLOR variant_pipeline 0 0 0 255 CLEAR variant_pipeline RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255