#!amber # Copyright 2020 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: Covers IR builder, constant fold, inst combine calls and value tracking 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 310 es # #define _int_3 _GLF_uniform_int_values[0] # #define _int_1 _GLF_uniform_int_values[1] # #define _int_0 _GLF_uniform_int_values[2] # #define _int_2 _GLF_uniform_int_values[3] # # precision highp float; # # precision highp int; # # // Contents of _GLF_uniform_int_values: [3, 1, 0, 2] # layout(set = 0, binding = 0) uniform buf0 # { # int _GLF_uniform_int_values[4]; # }; # layout(location = 0) out vec4 _GLF_color; # # void main() # { # int a = 0; # # // Always false. # if (mix(vec2(1), vec2(2), bvec2(true, _int_1 == _int_2)) == vec2(1)) # { # for (int i = _int_1; findMSB(i) < 5; i++) # { # a++; # } # } # else # { # for (int i = _int_1; findMSB(i) < _int_3; i++) # { # a++; # } # } # if (a == 7) # { # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1); # } # else # { # _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; 8 ; Bound: 100 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %4 "main" %80 OpExecutionMode %4 OriginUpperLeft OpSource ESSL 310 OpName %4 "main" OpName %8 "a" OpName %21 "buf0" OpMemberName %21 0 "_GLF_uniform_int_values" OpName %23 "" OpName %39 "i" OpName %56 "i" OpName %80 "_GLF_color" OpDecorate %20 ArrayStride 16 OpMemberDecorate %21 0 Offset 0 OpDecorate %21 Block OpDecorate %23 DescriptorSet 0 OpDecorate %23 Binding 0 OpDecorate %80 Location 0 %2 = OpTypeVoid %3 = OpTypeFunction %2 %6 = OpTypeInt 32 1 %7 = OpTypePointer Function %6 %9 = OpConstant %6 0 %10 = OpTypeFloat 32 %11 = OpTypeVector %10 2 %12 = OpConstant %10 1 %13 = OpConstantComposite %11 %12 %12 %14 = OpConstant %10 2 %15 = OpConstantComposite %11 %14 %14 %16 = OpTypeBool %17 = OpConstantTrue %16 %18 = OpTypeInt 32 0 %19 = OpConstant %18 4 %20 = OpTypeArray %6 %19 %21 = OpTypeStruct %20 %22 = OpTypePointer Uniform %21 %23 = OpVariable %22 Uniform %24 = OpConstant %6 1 %25 = OpTypePointer Uniform %6 %28 = OpConstant %6 3 %32 = OpTypeVector %16 2 %49 = OpConstant %6 5 %74 = OpConstant %6 7 %78 = OpTypeVector %10 4 %79 = OpTypePointer Output %78 %80 = OpVariable %79 Output %84 = OpConstant %6 2 %4 = OpFunction %2 None %3 %5 = OpLabel %8 = OpVariable %7 Function %39 = OpVariable %7 Function %56 = OpVariable %7 Function OpStore %8 %9 %26 = OpAccessChain %25 %23 %9 %24 %27 = OpLoad %6 %26 %29 = OpAccessChain %25 %23 %9 %28 %30 = OpLoad %6 %29 %31 = OpIEqual %16 %27 %30 %33 = OpCompositeConstruct %32 %17 %31 %34 = OpSelect %11 %33 %15 %13 %35 = OpFOrdEqual %32 %34 %13 %36 = OpAll %16 %35 OpSelectionMerge %38 None OpBranchConditional %36 %37 %55 %37 = OpLabel %40 = OpAccessChain %25 %23 %9 %24 %41 = OpLoad %6 %40 OpStore %39 %41 OpBranch %42 %42 = OpLabel OpLoopMerge %44 %45 None OpBranch %46 %46 = OpLabel %47 = OpLoad %6 %39 %48 = OpExtInst %6 %1 FindSMsb %47 %50 = OpSLessThan %16 %48 %49 OpBranchConditional %50 %43 %44 %43 = OpLabel %51 = OpLoad %6 %8 %52 = OpIAdd %6 %51 %24 OpStore %8 %52 OpBranch %45 %45 = OpLabel %53 = OpLoad %6 %39 %54 = OpIAdd %6 %53 %24 OpStore %39 %54 OpBranch %42 %44 = OpLabel OpBranch %38 %55 = OpLabel %57 = OpAccessChain %25 %23 %9 %24 %58 = OpLoad %6 %57 OpStore %56 %58 OpBranch %59 %59 = OpLabel OpLoopMerge %61 %62 None OpBranch %63 %63 = OpLabel %64 = OpLoad %6 %56 %65 = OpExtInst %6 %1 FindSMsb %64 %66 = OpAccessChain %25 %23 %9 %9 %67 = OpLoad %6 %66 %68 = OpSLessThan %16 %65 %67 OpBranchConditional %68 %60 %61 %60 = OpLabel %69 = OpLoad %6 %8 %70 = OpIAdd %6 %69 %24 OpStore %8 %70 OpBranch %62 %62 = OpLabel %71 = OpLoad %6 %56 %72 = OpIAdd %6 %71 %24 OpStore %56 %72 OpBranch %59 %61 = OpLabel OpBranch %38 %38 = OpLabel %73 = OpLoad %6 %8 %75 = OpIEqual %16 %73 %74 OpSelectionMerge %77 None OpBranchConditional %75 %76 %95 %76 = OpLabel %81 = OpAccessChain %25 %23 %9 %24 %82 = OpLoad %6 %81 %83 = OpConvertSToF %10 %82 %85 = OpAccessChain %25 %23 %9 %84 %86 = OpLoad %6 %85 %87 = OpConvertSToF %10 %86 %88 = OpAccessChain %25 %23 %9 %84 %89 = OpLoad %6 %88 %90 = OpConvertSToF %10 %89 %91 = OpAccessChain %25 %23 %9 %24 %92 = OpLoad %6 %91 %93 = OpConvertSToF %10 %92 %94 = OpCompositeConstruct %78 %83 %87 %90 %93 OpStore %80 %94 OpBranch %77 %95 = OpLabel %96 = OpAccessChain %25 %23 %9 %84 %97 = OpLoad %6 %96 %98 = OpConvertSToF %10 %97 %99 = OpCompositeConstruct %78 %98 %98 %98 %98 OpStore %80 %99 OpBranch %77 %77 = OpLabel OpReturn OpFunctionEnd END # uniforms for variant # _GLF_uniform_int_values BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 3 1 0 2 END BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM PIPELINE graphics variant_pipeline ATTACH variant_vertex_shader ATTACH variant_fragment_shader FRAMEBUFFER_SIZE 256 256 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 256 256 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255