blob: 9685311fc5575963277d0306558427401d2e6fd0 [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 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_0 _GLF_uniform_int_values[0]
# #define _int_1 _GLF_uniform_int_values[1]
#
# precision highp float;
# precision highp int;
#
# // Contents of _GLF_uniform_int_values: [0, 1]
# layout(set = 0, binding = 0) uniform buf0
# {
# int _GLF_uniform_int_values[2];
# };
#
# const int _GLF_global_loop_bound = 100;
# int _GLF_global_loop_count = 0;
#
# layout(location = 0) out vec4 _GLF_color;
#
# void main()
# {
# _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
#
# while (_GLF_global_loop_count < _GLF_global_loop_bound)
# {
# _GLF_global_loop_count++;
#
# // Always false.
# if (!(true || _int_0 == _int_1))
# {
# break;
# }
# }
#
# // This loop will not be iterated since the loop bound
# // has already been reached with the previous loop.
# while (_GLF_global_loop_count < _GLF_global_loop_bound)
# {
# _GLF_global_loop_count++;
# _GLF_color = vec4(_int_0);
# }
#
# // The output color still remains red beacuse the loop above
# // was not executed.
# }
SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 73
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %13
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 320
OpName %4 "main"
OpName %8 "_GLF_global_loop_count"
OpName %13 "_GLF_color"
OpName %17 "buf0"
OpMemberName %17 0 "_GLF_uniform_int_values"
OpName %19 ""
OpDecorate %13 Location 0
OpDecorate %16 ArrayStride 16
OpMemberDecorate %17 0 Offset 0
OpDecorate %17 Block
OpDecorate %19 DescriptorSet 0
OpDecorate %19 Binding 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 = OpTypeVector %10 4
%12 = OpTypePointer Output %11
%13 = OpVariable %12 Output
%14 = OpTypeInt 32 0
%15 = OpConstant %14 2
%16 = OpTypeArray %6 %15
%17 = OpTypeStruct %16
%18 = OpTypePointer Uniform %17
%19 = OpVariable %18 Uniform
%20 = OpConstant %6 1
%21 = OpTypePointer Uniform %6
%41 = OpConstant %6 100
%42 = OpTypeBool
%46 = OpConstantTrue %42
%4 = OpFunction %2 None %3
%5 = OpLabel
OpStore %8 %9
%22 = OpAccessChain %21 %19 %9 %20
%23 = OpLoad %6 %22
%24 = OpConvertSToF %10 %23
%25 = OpAccessChain %21 %19 %9 %9
%26 = OpLoad %6 %25
%27 = OpConvertSToF %10 %26
%28 = OpAccessChain %21 %19 %9 %9
%29 = OpLoad %6 %28
%30 = OpConvertSToF %10 %29
%31 = OpAccessChain %21 %19 %9 %20
%32 = OpLoad %6 %31
%33 = OpConvertSToF %10 %32
%34 = OpCompositeConstruct %11 %24 %27 %30 %33
OpStore %13 %34
OpBranch %35
%35 = OpLabel
OpLoopMerge %37 %38 None
OpBranch %39
%39 = OpLabel
%40 = OpLoad %6 %8
%43 = OpSLessThan %42 %40 %41
OpBranchConditional %43 %36 %37
%36 = OpLabel
%44 = OpLoad %6 %8
%45 = OpIAdd %6 %44 %20
OpStore %8 %45
%47 = OpLogicalNot %42 %46
OpSelectionMerge %49 None
OpBranchConditional %47 %48 %49
%48 = OpLabel
%50 = OpAccessChain %21 %19 %9 %9
%51 = OpLoad %6 %50
%52 = OpAccessChain %21 %19 %9 %20
%53 = OpLoad %6 %52
%54 = OpIEqual %42 %51 %53
OpBranch %49
%49 = OpLabel
%55 = OpPhi %42 %46 %36 %54 %48
%56 = OpLogicalNot %42 %55
OpSelectionMerge %58 None
OpBranchConditional %56 %57 %58
%57 = OpLabel
OpBranch %37
%58 = OpLabel
OpBranch %38
%38 = OpLabel
OpBranch %35
%37 = OpLabel
OpBranch %60
%60 = OpLabel
OpLoopMerge %62 %63 None
OpBranch %64
%64 = OpLabel
%65 = OpLoad %6 %8
%66 = OpSLessThan %42 %65 %41
OpBranchConditional %66 %61 %62
%61 = OpLabel
%67 = OpLoad %6 %8
%68 = OpIAdd %6 %67 %20
OpStore %8 %68
%69 = OpAccessChain %21 %19 %9 %9
%70 = OpLoad %6 %69
%71 = OpConvertSToF %10 %70
%72 = OpCompositeConstruct %11 %71 %71 %71 %71
OpStore %13 %72
OpBranch %63
%63 = OpLabel
OpBranch %60
%62 = OpLabel
OpReturn
OpFunctionEnd
END
# uniforms for variant
# _GLF_uniform_int_values
BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
0 1
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