#!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: A fragment shader that covers specific NIR 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_1 _GLF_uniform_int_values[0] # #define _int_0 _GLF_uniform_int_values[1] # #define _float_5_0 _GLF_uniform_float_values[0] # #define _float_1_0 _GLF_uniform_float_values[1] # # precision highp int; # precision highp float; # # // Contents of _GLF_uniform_float_values: [5.0, 1.0] # layout(set = 0, binding = 0) uniform buf0 # { # float _GLF_uniform_float_values[2]; # }; # # // Contents of _GLF_uniform_int_values: [1, 0] # layout(set = 0, binding = 1) uniform buf1 # { # int _GLF_uniform_int_values[2]; # }; # # layout(location = 0) out vec4 _GLF_color; # # vec2 func() # { # vec2 v; # v.y = _float_5_0; # int a = 2; # return vec2[3](vec2(_float_1_0), vec2(_float_1_0), v)[a]; # } # # void main() # { # if(func().y == _float_5_0) # { # _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; 10 ; Bound: 82 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %4 "main" %58 OpExecutionMode %4 OriginUpperLeft OpSource ESSL 320 OpName %4 "main" OpName %9 "func(" OpName %12 "v" OpName %16 "buf0" OpMemberName %16 0 "_GLF_uniform_float_values" OpName %18 "" OpName %28 "a" OpName %43 "indexable" OpName %58 "_GLF_color" OpName %60 "buf1" OpMemberName %60 0 "_GLF_uniform_int_values" OpName %62 "" OpDecorate %15 ArrayStride 16 OpMemberDecorate %16 0 Offset 0 OpDecorate %16 Block OpDecorate %18 DescriptorSet 0 OpDecorate %18 Binding 0 OpDecorate %58 Location 0 OpDecorate %59 ArrayStride 16 OpMemberDecorate %60 0 Offset 0 OpDecorate %60 Block OpDecorate %62 DescriptorSet 0 OpDecorate %62 Binding 1 %2 = OpTypeVoid %3 = OpTypeFunction %2 %6 = OpTypeFloat 32 %7 = OpTypeVector %6 2 %8 = OpTypeFunction %7 %11 = OpTypePointer Function %7 %13 = OpTypeInt 32 0 %14 = OpConstant %13 2 %15 = OpTypeArray %6 %14 %16 = OpTypeStruct %15 %17 = OpTypePointer Uniform %16 %18 = OpVariable %17 Uniform %19 = OpTypeInt 32 1 %20 = OpConstant %19 0 %21 = OpTypePointer Uniform %6 %24 = OpConstant %13 1 %25 = OpTypePointer Function %6 %27 = OpTypePointer Function %19 %29 = OpConstant %19 2 %30 = OpConstant %19 1 %38 = OpConstant %13 3 %39 = OpTypeArray %7 %38 %42 = OpTypePointer Function %39 %52 = OpTypeBool %56 = OpTypeVector %6 4 %57 = OpTypePointer Output %56 %58 = OpVariable %57 Output %59 = OpTypeArray %19 %14 %60 = OpTypeStruct %59 %61 = OpTypePointer Uniform %60 %62 = OpVariable %61 Uniform %63 = OpTypePointer Uniform %19 %4 = OpFunction %2 None %3 %5 = OpLabel %48 = OpFunctionCall %7 %9 %49 = OpCompositeExtract %6 %48 1 %50 = OpAccessChain %21 %18 %20 %20 %51 = OpLoad %6 %50 %53 = OpFOrdEqual %52 %49 %51 OpSelectionMerge %55 None OpBranchConditional %53 %54 %77 %54 = OpLabel %64 = OpAccessChain %63 %62 %20 %20 %65 = OpLoad %19 %64 %66 = OpConvertSToF %6 %65 %67 = OpAccessChain %63 %62 %20 %30 %68 = OpLoad %19 %67 %69 = OpConvertSToF %6 %68 %70 = OpAccessChain %63 %62 %20 %30 %71 = OpLoad %19 %70 %72 = OpConvertSToF %6 %71 %73 = OpAccessChain %63 %62 %20 %20 %74 = OpLoad %19 %73 %75 = OpConvertSToF %6 %74 %76 = OpCompositeConstruct %56 %66 %69 %72 %75 OpStore %58 %76 OpBranch %55 %77 = OpLabel %78 = OpAccessChain %63 %62 %20 %30 %79 = OpLoad %19 %78 %80 = OpConvertSToF %6 %79 %81 = OpCompositeConstruct %56 %80 %80 %80 %80 OpStore %58 %81 OpBranch %55 %55 = OpLabel OpReturn OpFunctionEnd %9 = OpFunction %7 None %8 %10 = OpLabel %12 = OpVariable %11 Function %28 = OpVariable %27 Function %43 = OpVariable %42 Function %22 = OpAccessChain %21 %18 %20 %20 %23 = OpLoad %6 %22 %26 = OpAccessChain %25 %12 %24 OpStore %26 %23 OpStore %28 %29 %31 = OpAccessChain %21 %18 %20 %30 %32 = OpLoad %6 %31 %33 = OpCompositeConstruct %7 %32 %32 %34 = OpAccessChain %21 %18 %20 %30 %35 = OpLoad %6 %34 %36 = OpCompositeConstruct %7 %35 %35 %37 = OpLoad %7 %12 %40 = OpCompositeConstruct %39 %33 %36 %37 %41 = OpLoad %19 %28 OpStore %43 %40 %44 = OpAccessChain %11 %43 %41 %45 = OpLoad %7 %44 OpReturnValue %45 OpFunctionEnd END # uniforms for variant # _GLF_uniform_int_values BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 1 0 END # _GLF_uniform_float_values BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA 5.0 1.0 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 1 BIND BUFFER variant__GLF_uniform_float_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