blob: 66614f22cb8b2af983b0edfce7a36e37c1ed1bf6 [file] [log] [blame]
#!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 a specific tail duplicator code path
# 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_0 _GLF_uniform_int_values[0]
# #define _int_4 _GLF_uniform_int_values[1]
# #define _float_0_0 _GLF_uniform_float_values[0]
#
# precision highp float;
#
# precision highp int;
#
# // Contents of _GLF_uniform_int_values: 0
# layout(set = 0, binding = 0) uniform buf0
# {
# int _GLF_uniform_int_values[2];
# };
#
# // Contents of _GLF_uniform_float_values: 0.0
# layout(set = 0, binding = 1) uniform buf1
# {
# float _GLF_uniform_float_values[1];
# };
#
# layout(location = 0) out vec4 _GLF_color;
#
# void main()
# {
# vec4 color = vec4(1.0);
#
# for (int i = _int_0; i < _int_4; i++)
# {
# switch (i)
# {
# case 1:
# // Never entered.
# for (int j = _int_0; i > i; j++)
# {
# for (int k = _int_0; k < i; k++)
# {
# color[k] = _float_0_0;
# }
# }
#
# color[i] = _float_0_0;
# break;
#
# case 2:
# color[i] = _float_0_0;
# break;
# }
# }
#
# _GLF_color = color;
# }
SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 8
; Bound: 93
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %91
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 310
OpName %4 "main"
OpName %9 "color"
OpName %14 "i"
OpName %18 "buf0"
OpMemberName %18 0 "_GLF_uniform_int_values"
OpName %20 ""
OpName %40 "j"
OpName %51 "k"
OpName %65 "buf1"
OpMemberName %65 0 "_GLF_uniform_float_values"
OpName %67 ""
OpName %91 "_GLF_color"
OpDecorate %17 ArrayStride 16
OpMemberDecorate %18 0 Offset 0
OpDecorate %18 Block
OpDecorate %20 DescriptorSet 0
OpDecorate %20 Binding 0
OpDecorate %64 ArrayStride 16
OpMemberDecorate %65 0 Offset 0
OpDecorate %65 Block
OpDecorate %67 DescriptorSet 0
OpDecorate %67 Binding 1
OpDecorate %91 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeFloat 32
%7 = OpTypeVector %6 4
%8 = OpTypePointer Function %7
%10 = OpConstant %6 1
%11 = OpConstantComposite %7 %10 %10 %10 %10
%12 = OpTypeInt 32 1
%13 = OpTypePointer Function %12
%15 = OpTypeInt 32 0
%16 = OpConstant %15 2
%17 = OpTypeArray %12 %16
%18 = OpTypeStruct %17
%19 = OpTypePointer Uniform %18
%20 = OpVariable %19 Uniform
%21 = OpConstant %12 0
%22 = OpTypePointer Uniform %12
%31 = OpConstant %12 1
%34 = OpTypeBool
%63 = OpConstant %15 1
%64 = OpTypeArray %6 %63
%65 = OpTypeStruct %64
%66 = OpTypePointer Uniform %65
%67 = OpVariable %66 Uniform
%68 = OpTypePointer Uniform %6
%71 = OpTypePointer Function %6
%90 = OpTypePointer Output %7
%91 = OpVariable %90 Output
%4 = OpFunction %2 None %3
%5 = OpLabel
%9 = OpVariable %8 Function
%14 = OpVariable %13 Function
%40 = OpVariable %13 Function
%51 = OpVariable %13 Function
OpStore %9 %11
%23 = OpAccessChain %22 %20 %21 %21
%24 = OpLoad %12 %23
OpStore %14 %24
OpBranch %25
%25 = OpLabel
OpLoopMerge %27 %28 None
OpBranch %29
%29 = OpLabel
%30 = OpLoad %12 %14
%32 = OpAccessChain %22 %20 %21 %31
%33 = OpLoad %12 %32
%35 = OpSLessThan %34 %30 %33
OpBranchConditional %35 %26 %27
%26 = OpLabel
%36 = OpLoad %12 %14
OpSelectionMerge %39 None
OpSwitch %36 %39 1 %37 2 %38
%37 = OpLabel
%41 = OpAccessChain %22 %20 %21 %21
%42 = OpLoad %12 %41
OpStore %40 %42
OpBranch %43
%43 = OpLabel
OpLoopMerge %45 %46 None
OpBranch %47
%47 = OpLabel
%48 = OpLoad %12 %14
%49 = OpLoad %12 %14
%50 = OpSGreaterThan %34 %48 %49
OpBranchConditional %50 %44 %45
%44 = OpLabel
%52 = OpAccessChain %22 %20 %21 %21
%53 = OpLoad %12 %52
OpStore %51 %53
OpBranch %54
%54 = OpLabel
OpLoopMerge %56 %57 None
OpBranch %58
%58 = OpLabel
%59 = OpLoad %12 %51
%60 = OpLoad %12 %14
%61 = OpSLessThan %34 %59 %60
OpBranchConditional %61 %55 %56
%55 = OpLabel
%62 = OpLoad %12 %51
%69 = OpAccessChain %68 %67 %21 %21
%70 = OpLoad %6 %69
%72 = OpAccessChain %71 %9 %62
OpStore %72 %70
OpBranch %57
%57 = OpLabel
%73 = OpLoad %12 %51
%74 = OpIAdd %12 %73 %31
OpStore %51 %74
OpBranch %54
%56 = OpLabel
OpBranch %46
%46 = OpLabel
%75 = OpLoad %12 %40
%76 = OpIAdd %12 %75 %31
OpStore %40 %76
OpBranch %43
%45 = OpLabel
%77 = OpLoad %12 %14
%78 = OpAccessChain %68 %67 %21 %21
%79 = OpLoad %6 %78
%80 = OpAccessChain %71 %9 %77
OpStore %80 %79
OpBranch %39
%38 = OpLabel
%82 = OpLoad %12 %14
%83 = OpAccessChain %68 %67 %21 %21
%84 = OpLoad %6 %83
%85 = OpAccessChain %71 %9 %82
OpStore %85 %84
OpBranch %39
%39 = OpLabel
OpBranch %28
%28 = OpLabel
%88 = OpLoad %12 %14
%89 = OpIAdd %12 %88 %31
OpStore %14 %89
OpBranch %25
%27 = OpLabel
%92 = OpLoad %7 %9
OpStore %91 %92
OpReturn
OpFunctionEnd
END
# uniforms for variant
# _GLF_uniform_int_values
BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
0 4
END
# _GLF_uniform_float_values
BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
0.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 0
BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
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