blob: cb0f9d52c30b0978a5c7554f395c4c6ae32ce4b9 [file] [log] [blame]
#!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 BRW 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 _int_10 _GLF_uniform_int_values[2]
# #define _float_1_0 _GLF_uniform_float_values[0]
# #define _float_91_0 _GLF_uniform_float_values[1]
#
# precision highp float;
# precision highp int;
#
# // Contents of _GLF_uniform_int_values: [1, 0, 10]
# layout(set = 0, binding = 0) uniform buf0
# {
# int _GLF_uniform_int_values[3];
# };
#
# // Contents of _GLF_uniform_float_values: [1.0, 91.0]
# layout(set = 0, binding = 1) uniform buf1
# {
# float _GLF_uniform_float_values[2];
# };
#
# const int _GLF_global_loop_bound = 100;
# int _GLF_global_loop_count = 0;
#
# // Contents of injectionSwitch: [0.0, 1.0]
# layout(set = 0, binding = 2) uniform buf2
# {
# vec2 injectionSwitch;
# };
#
# layout(location = 0) out vec4 _GLF_color;
#
# void main()
# {
# float f = _float_1_0;
#
# for(int r = _int_0; r < _int_10; r ++)
# {
# _GLF_global_loop_count ++;
# // Derivative of a uniform vector is always zero.
# f += dFdx(injectionSwitch).y;
# }
#
# while(_GLF_global_loop_count < _GLF_global_loop_bound)
# {
# _GLF_global_loop_count ++;
# f += _float_1_0;
# }
#
# // Always true.
# if(f == _float_91_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: 101
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %82
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 320
OpName %4 "main"
OpName %8 "_GLF_global_loop_count"
OpName %12 "f"
OpName %16 "buf1"
OpMemberName %16 0 "_GLF_uniform_float_values"
OpName %18 ""
OpName %23 "r"
OpName %26 "buf0"
OpMemberName %26 0 "_GLF_uniform_int_values"
OpName %28 ""
OpName %47 "buf2"
OpMemberName %47 0 "injectionSwitch"
OpName %49 ""
OpName %82 "_GLF_color"
OpDecorate %15 ArrayStride 16
OpMemberDecorate %16 0 Offset 0
OpDecorate %16 Block
OpDecorate %18 DescriptorSet 0
OpDecorate %18 Binding 1
OpDecorate %25 ArrayStride 16
OpMemberDecorate %26 0 Offset 0
OpDecorate %26 Block
OpDecorate %28 DescriptorSet 0
OpDecorate %28 Binding 0
OpMemberDecorate %47 0 Offset 0
OpDecorate %47 Block
OpDecorate %49 DescriptorSet 0
OpDecorate %49 Binding 2
OpDecorate %82 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeInt 32 1
%7 = OpTypePointer Private %6
%8 = OpVariable %7 Private
%9 = OpConstant %6 0
%10 = OpTypeFloat 32
%11 = OpTypePointer Function %10
%13 = OpTypeInt 32 0
%14 = OpConstant %13 2
%15 = OpTypeArray %10 %14
%16 = OpTypeStruct %15
%17 = OpTypePointer Uniform %16
%18 = OpVariable %17 Uniform
%19 = OpTypePointer Uniform %10
%22 = OpTypePointer Function %6
%24 = OpConstant %13 3
%25 = OpTypeArray %6 %24
%26 = OpTypeStruct %25
%27 = OpTypePointer Uniform %26
%28 = OpVariable %27 Uniform
%29 = OpConstant %6 1
%30 = OpTypePointer Uniform %6
%39 = OpConstant %6 2
%42 = OpTypeBool
%46 = OpTypeVector %10 2
%47 = OpTypeStruct %46
%48 = OpTypePointer Uniform %47
%49 = OpVariable %48 Uniform
%50 = OpTypePointer Uniform %46
%54 = OpConstant %13 1
%66 = OpConstant %6 100
%80 = OpTypeVector %10 4
%81 = OpTypePointer Output %80
%82 = OpVariable %81 Output
%4 = OpFunction %2 None %3
%5 = OpLabel
%12 = OpVariable %11 Function
%23 = OpVariable %22 Function
OpStore %8 %9
%20 = OpAccessChain %19 %18 %9 %9
%21 = OpLoad %10 %20
OpStore %12 %21
%31 = OpAccessChain %30 %28 %9 %29
%32 = OpLoad %6 %31
OpStore %23 %32
OpBranch %33
%33 = OpLabel
OpLoopMerge %35 %36 None
OpBranch %37
%37 = OpLabel
%38 = OpLoad %6 %23
%40 = OpAccessChain %30 %28 %9 %39
%41 = OpLoad %6 %40
%43 = OpSLessThan %42 %38 %41
OpBranchConditional %43 %34 %35
%34 = OpLabel
%44 = OpLoad %6 %8
%45 = OpIAdd %6 %44 %29
OpStore %8 %45
%51 = OpAccessChain %50 %49 %9
%52 = OpLoad %46 %51
%53 = OpDPdx %46 %52
%55 = OpCompositeExtract %10 %53 1
%56 = OpLoad %10 %12
%57 = OpFAdd %10 %56 %55
OpStore %12 %57
OpBranch %36
%36 = OpLabel
%58 = OpLoad %6 %23
%59 = OpIAdd %6 %58 %29
OpStore %23 %59
OpBranch %33
%35 = OpLabel
OpBranch %60
%60 = OpLabel
OpLoopMerge %62 %63 None
OpBranch %64
%64 = OpLabel
%65 = OpLoad %6 %8
%67 = OpSLessThan %42 %65 %66
OpBranchConditional %67 %61 %62
%61 = OpLabel
%68 = OpLoad %6 %8
%69 = OpIAdd %6 %68 %29
OpStore %8 %69
%70 = OpAccessChain %19 %18 %9 %9
%71 = OpLoad %10 %70
%72 = OpLoad %10 %12
%73 = OpFAdd %10 %72 %71
OpStore %12 %73
OpBranch %63
%63 = OpLabel
OpBranch %60
%62 = OpLabel
%74 = OpLoad %10 %12
%75 = OpAccessChain %19 %18 %9 %29
%76 = OpLoad %10 %75
%77 = OpFOrdEqual %42 %74 %76
OpSelectionMerge %79 None
OpBranchConditional %77 %78 %96
%78 = OpLabel
%83 = OpAccessChain %30 %28 %9 %9
%84 = OpLoad %6 %83
%85 = OpConvertSToF %10 %84
%86 = OpAccessChain %30 %28 %9 %29
%87 = OpLoad %6 %86
%88 = OpConvertSToF %10 %87
%89 = OpAccessChain %30 %28 %9 %29
%90 = OpLoad %6 %89
%91 = OpConvertSToF %10 %90
%92 = OpAccessChain %30 %28 %9 %9
%93 = OpLoad %6 %92
%94 = OpConvertSToF %10 %93
%95 = OpCompositeConstruct %80 %85 %88 %91 %94
OpStore %82 %95
OpBranch %79
%96 = OpLabel
%97 = OpAccessChain %30 %28 %9 %29
%98 = OpLoad %6 %97
%99 = OpConvertSToF %10 %98
%100 = OpCompositeConstruct %80 %99 %99 %99 %99
OpStore %82 %100
OpBranch %79
%79 = OpLabel
OpReturn
OpFunctionEnd
END
# uniforms for variant
# injectionSwitch
BUFFER variant_injectionSwitch DATA_TYPE vec2<float> STD140 DATA
0.0 1.0
END
# _GLF_uniform_float_values
BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
1.0 91.0
END
# _GLF_uniform_int_values
BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
1 0 10
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_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 2
BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
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