blob: 7c57b79aee96bb3f10ca7ec06ecde1730f18bc40 [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 GraphicsFuzz.
# Short description: A fragment shader that covers specific simplification and value tracking 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
# precision highp float;
# precision highp int;
#
# layout(location = 0) out vec4 _GLF_color;
# layout(set = 0, binding = 0) uniform buf0
# {
# int two;
# };
#
# int func(int i, int x)
# {
# int r = 2;
#
# // Run until x = 3 (three iterations).
# while(x <= r)
# {
# // Always false.
# if(i == 1)
# return -1;
#
# // Always false.
# if(x < 1)
# r = 1;
#
# // r is always 2.
# // findLSB(2) = 1
# // findMSB(1) = 0
# // --> The while loop is run only once.
# do
# {
# x++;
# }
# while(findMSB(findLSB(r)) > 1);
# }
#
# return x;
# }
#
# void main()
# {
# if(func(two, 1) == 3)
# _GLF_color = vec4(1, 0, 0, 1);
# else
# _GLF_color = vec4(0);
# }
SHADER fragment variant_fragment_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 8
; Bound: 71
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %65
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 310
OpName %4 "main"
OpName %11 "func(i1;i1;"
OpName %9 "i"
OpName %10 "x"
OpName %13 "r"
OpName %48 "buf0"
OpMemberName %48 0 "two"
OpName %50 ""
OpName %52 "param"
OpName %56 "param"
OpName %65 "_GLF_color"
OpMemberDecorate %48 0 Offset 0
OpDecorate %48 Block
OpDecorate %50 DescriptorSet 0
OpDecorate %50 Binding 0
OpDecorate %65 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeInt 32 1
%7 = OpTypePointer Function %6
%8 = OpTypeFunction %6 %7 %7
%14 = OpConstant %6 2
%22 = OpTypeBool
%25 = OpConstant %6 1
%29 = OpConstant %6 -1
%48 = OpTypeStruct %6
%49 = OpTypePointer Uniform %48
%50 = OpVariable %49 Uniform
%51 = OpConstant %6 0
%53 = OpTypePointer Uniform %6
%58 = OpConstant %6 3
%62 = OpTypeFloat 32
%63 = OpTypeVector %62 4
%64 = OpTypePointer Output %63
%65 = OpVariable %64 Output
%66 = OpConstant %62 1
%67 = OpConstant %62 0
%68 = OpConstantComposite %63 %66 %67 %67 %66
%70 = OpConstantComposite %63 %67 %67 %67 %67
%4 = OpFunction %2 None %3
%5 = OpLabel
%52 = OpVariable %7 Function
%56 = OpVariable %7 Function
%54 = OpAccessChain %53 %50 %51
%55 = OpLoad %6 %54
OpStore %52 %55
OpStore %56 %25
%57 = OpFunctionCall %6 %11 %52 %56
%59 = OpIEqual %22 %57 %58
OpSelectionMerge %61 None
OpBranchConditional %59 %60 %69
%60 = OpLabel
OpStore %65 %68
OpBranch %61
%69 = OpLabel
OpStore %65 %70
OpBranch %61
%61 = OpLabel
OpReturn
OpFunctionEnd
%11 = OpFunction %6 None %8
%9 = OpFunctionParameter %7
%10 = OpFunctionParameter %7
%12 = OpLabel
%13 = OpVariable %7 Function
OpStore %13 %14
OpBranch %15
%15 = OpLabel
OpLoopMerge %17 %18 None
OpBranch %19
%19 = OpLabel
%20 = OpLoad %6 %10
%21 = OpLoad %6 %13
%23 = OpSLessThanEqual %22 %20 %21
OpBranchConditional %23 %16 %17
%16 = OpLabel
%24 = OpLoad %6 %9
%26 = OpIEqual %22 %24 %25
OpSelectionMerge %28 None
OpBranchConditional %26 %27 %28
%27 = OpLabel
OpReturnValue %29
%28 = OpLabel
%31 = OpLoad %6 %10
%32 = OpSLessThan %22 %31 %25
OpSelectionMerge %34 None
OpBranchConditional %32 %33 %34
%33 = OpLabel
OpStore %13 %25
OpBranch %34
%34 = OpLabel
OpBranch %35
%35 = OpLabel
OpLoopMerge %37 %38 None
OpBranch %36
%36 = OpLabel
%39 = OpLoad %6 %10
%40 = OpIAdd %6 %39 %25
OpStore %10 %40
OpBranch %38
%38 = OpLabel
%41 = OpLoad %6 %13
%42 = OpExtInst %6 %1 FindILsb %41
%43 = OpExtInst %6 %1 FindSMsb %42
%44 = OpSGreaterThan %22 %43 %25
OpBranchConditional %44 %35 %37
%37 = OpLabel
OpBranch %18
%18 = OpLabel
OpBranch %15
%17 = OpLabel
%45 = OpLoad %6 %10
OpReturnValue %45
OpFunctionEnd
END
# uniforms for variant
# two
BUFFER variant_two DATA_TYPE int32 DATA
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_two 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