blob: 782ac34b4f994f77b8731359d8312e7fdc59c111 [file] [log] [blame]
#!amber
# Copyright 2019 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 a specific propagate array copy path.
# The test passes because shader always writes red.
# Optimized using spirv-opt with the following arguments:
# '--eliminate-dead-branches'
# '--merge-return'
# '--reduce-load-size'
# '--if-conversion'
# '--private-to-local'
# '--if-conversion'
# '--eliminate-dead-branches'
# '--eliminate-local-multi-store'
# '--scalar-replacement=100'
# '--vector-dce'
# '--inline-entry-points-exhaustive'
# '--eliminate-local-single-store'
# '--convert-local-access-chains'
# '--eliminate-dead-branches'
# '--merge-return'
# '--reduce-load-size'
# '--eliminate-dead-branches'
# '--merge-blocks'
# '--redundancy-elimination'
# '--eliminate-dead-branches'
# spirv-opt commit hash: 9215c1b7df0029f27807e8c8d7ec80532ce90a87
SHADER vertex variant_vertex_shader PASSTHROUGH
# variant_fragment_shader is derived from the following GLSL:
# #version 310 es
# precision highp float;
#
# layout(location = 0) out vec4 _GLF_color;
#
# layout(set = 0, binding = 0) uniform buf0
# {
# int zero;
# };
#
# struct Array
# {
# int values[2];
# };
#
# // Function always returns 1 regardless of array contents
# int func(Array a)
# {
# while(true)
# {
# if(a.values[zero] == 1)
# return 1;
#
# break;
# }
# return 1;
# }
# void main()
# {
# Array a;
# // If condition is always true
# if (func(a) == 1)
# _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: 104
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %51
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 310
OpName %4 "main"
OpName %10 "Array"
OpMemberName %10 0 "values"
OpName %14 "func(struct-Array-i1[2]1;"
OpName %13 "a"
OpName %24 "buf0"
OpMemberName %24 0 "zero"
OpName %26 ""
OpName %42 "param"
OpName %51 "_GLF_color"
OpMemberDecorate %10 0 RelaxedPrecision
OpDecorate %14 RelaxedPrecision
OpMemberDecorate %24 0 RelaxedPrecision
OpMemberDecorate %24 0 Offset 0
OpDecorate %24 Block
OpDecorate %26 DescriptorSet 0
OpDecorate %26 Binding 0
OpDecorate %29 RelaxedPrecision
OpDecorate %32 RelaxedPrecision
OpDecorate %51 Location 0
OpDecorate %58 RelaxedPrecision
OpDecorate %73 RelaxedPrecision
OpDecorate %72 RelaxedPrecision
OpDecorate %80 RelaxedPrecision
OpDecorate %81 RelaxedPrecision
OpDecorate %94 RelaxedPrecision
OpDecorate %96 RelaxedPrecision
OpDecorate %100 RelaxedPrecision
OpDecorate %103 RelaxedPrecision
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeInt 32 1
%7 = OpTypeInt 32 0
%8 = OpConstant %7 2
%9 = OpTypeArray %6 %8
%10 = OpTypeStruct %9
%11 = OpTypePointer Function %10
%12 = OpTypeFunction %6 %11
%21 = OpTypeBool
%22 = OpConstantTrue %21
%23 = OpConstant %6 0
%24 = OpTypeStruct %6
%25 = OpTypePointer Uniform %24
%26 = OpVariable %25 Uniform
%27 = OpTypePointer Uniform %6
%30 = OpTypePointer Function %6
%33 = OpConstant %6 1
%48 = OpTypeFloat 32
%49 = OpTypeVector %48 4
%50 = OpTypePointer Output %49
%51 = OpVariable %50 Output
%52 = OpConstant %48 1
%53 = OpConstant %48 0
%54 = OpConstantComposite %49 %52 %53 %53 %52
%56 = OpConstantComposite %49 %53 %53 %53 %53
%63 = OpConstantFalse %21
%64 = OpTypePointer Function %21
%68 = OpUndef %10
%76 = OpUndef %6
%77 = OpUndef %21
%78 = OpConstantNull %9
%4 = OpFunction %2 None %3
%5 = OpLabel
%79 = OpVariable %64 Function %63
%80 = OpVariable %30 Function
%81 = OpVariable %30 Function
%42 = OpVariable %11 Function
OpStore %42 %68
OpStore %79 %63
OpBranch %82
%82 = OpLabel
OpLoopMerge %85 %83 None
OpBranch %87
%87 = OpLabel
OpLoopMerge %90 %88 None
OpBranch %92
%92 = OpLabel
%93 = OpAccessChain %27 %26 %23
%94 = OpLoad %6 %93
%95 = OpAccessChain %30 %42 %23 %94
%96 = OpLoad %6 %95
%97 = OpIEqual %21 %96 %33
OpSelectionMerge %98 None
OpBranchConditional %97 %99 %98
%99 = OpLabel
OpStore %79 %22
OpStore %80 %33
OpBranch %90
%98 = OpLabel
OpBranch %90
%88 = OpLabel
OpBranch %87
%90 = OpLabel
%100 = OpPhi %6 %33 %99 %76 %98
%101 = OpPhi %21 %22 %99 %63 %98
OpSelectionMerge %102 None
OpBranchConditional %101 %85 %102
%102 = OpLabel
OpStore %79 %22
OpStore %80 %33
OpBranch %85
%83 = OpLabel
OpBranch %82
%85 = OpLabel
%103 = OpPhi %6 %100 %90 %33 %102
OpStore %81 %103
%45 = OpIEqual %21 %103 %33
OpSelectionMerge %47 None
OpBranchConditional %45 %46 %55
%55 = OpLabel
OpStore %51 %56
OpBranch %47
%46 = OpLabel
OpStore %51 %54
OpBranch %47
%47 = OpLabel
OpReturn
OpFunctionEnd
%14 = OpFunction %6 None %12
%13 = OpFunctionParameter %11
%15 = OpLabel
%65 = OpVariable %64 Function %63
%58 = OpVariable %30 Function
OpBranch %60
%60 = OpLabel
%71 = OpPhi %21 %63 %15 %77 %62
OpLoopMerge %57 %62 None
OpBranch %61
%61 = OpLabel
OpBranch %16
%16 = OpLabel
%70 = OpPhi %21 %71 %61 %77 %19
OpLoopMerge %18 %19 None
OpBranch %20
%20 = OpLabel
OpBranch %17
%17 = OpLabel
%28 = OpAccessChain %27 %26 %23
%29 = OpLoad %6 %28
%31 = OpAccessChain %30 %13 %23 %29
%32 = OpLoad %6 %31
%34 = OpIEqual %21 %32 %33
OpSelectionMerge %36 None
OpBranchConditional %34 %35 %36
%35 = OpLabel
OpStore %65 %22
OpStore %58 %33
OpBranch %18
%36 = OpLabel
OpBranch %18
%19 = OpLabel
OpBranch %16
%18 = OpLabel
%73 = OpPhi %6 %33 %35 %76 %36
%69 = OpPhi %21 %22 %35 %70 %36
OpSelectionMerge %66 None
OpBranchConditional %69 %57 %66
%66 = OpLabel
OpStore %65 %22
OpStore %58 %33
OpBranch %57
%62 = OpLabel
OpBranch %60
%57 = OpLabel
%72 = OpPhi %6 %73 %18 %33 %66
OpReturnValue %72
OpFunctionEnd
END
# uniforms for variant
# zero
BUFFER variant_zero DATA_TYPE int32 DATA
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_zero 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