366 lines
11 KiB
Plaintext
366 lines
11 KiB
Plaintext
#!amber
|
|
|
|
# Copyright 2022 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.
|
|
|
|
DEVICE_EXTENSION VK_KHR_shader_terminate_invocation
|
|
|
|
# A test for a coverage-gap found by the GraphicsFuzz project.
|
|
|
|
# Short description: A fragment shader that covers specific LLVM 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_3 _GLF_uniform_int_values[0]
|
|
# #define _int_1 _GLF_uniform_int_values[1]
|
|
# #define _int_0 _GLF_uniform_int_values[2]
|
|
# #define _float_1_0 _GLF_uniform_float_values[0]
|
|
# #define _float_256_0 _GLF_uniform_float_values[1]
|
|
#
|
|
# precision highp float;
|
|
# precision highp int;
|
|
#
|
|
# // Contents of _GLF_uniform_float_values: [1.0, 256.0]
|
|
# layout(set = 0, binding = 0) uniform buf0
|
|
# {
|
|
# float _GLF_uniform_float_values[2];
|
|
# };
|
|
#
|
|
# // Contents of _GLF_uniform_int_values: [3, 1, 0]
|
|
# layout(set = 0, binding = 1) uniform buf1
|
|
# {
|
|
# int _GLF_uniform_int_values[3];
|
|
# };
|
|
#
|
|
# layout(location = 0) out vec4 _GLF_color;
|
|
#
|
|
# void main()
|
|
# {
|
|
# // Always false.
|
|
# if(gl_FragCoord.x < 0.0)
|
|
# {
|
|
# discard;
|
|
# }
|
|
#
|
|
# float a = _float_1_0;
|
|
# float b = _float_1_0;
|
|
# float c = _float_1_0;
|
|
# vec3 v = vec3(_int_0);
|
|
#
|
|
# // Always false.
|
|
# if(gl_FragCoord.y < 0.0)
|
|
# {
|
|
# a++;
|
|
# }
|
|
#
|
|
# // Iterates three times.
|
|
# for(int i = _int_0; i < _int_3; i++)
|
|
# {
|
|
# // Always false.
|
|
# if(gl_FragCoord.x < 0.0)
|
|
# {
|
|
# }
|
|
# else
|
|
# {
|
|
# // Never iterated.
|
|
# while(gl_FragCoord.y < 0.0)
|
|
# {
|
|
# }
|
|
# }
|
|
#
|
|
# // Always false.
|
|
# if(gl_FragCoord.y < 0.0)
|
|
# {
|
|
# }
|
|
# else
|
|
# {
|
|
# // No effect as b is already one.
|
|
# b = 1.0;
|
|
# }
|
|
#
|
|
# // c becomes zero.
|
|
# c *= 1.0 - b;
|
|
# // No effect: 1 * 256 = 1.
|
|
# b *= _float_256_0;
|
|
# // v[i] becomes 1 + 0 = 1.
|
|
# v[i] = a + c;
|
|
# }
|
|
#
|
|
# // Always true.
|
|
# if(v == vec3(_int_1))
|
|
# {
|
|
# _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: 141
|
|
; Schema: 0
|
|
OpCapability Shader
|
|
OpExtension "SPV_KHR_terminate_invocation"
|
|
%1 = OpExtInstImport "GLSL.std.450"
|
|
OpMemoryModel Logical GLSL450
|
|
OpEntryPoint Fragment %4 "main" %9 %122
|
|
OpExecutionMode %4 OriginUpperLeft
|
|
OpSource ESSL 320
|
|
OpName %4 "main"
|
|
OpName %9 "gl_FragCoord"
|
|
OpName %22 "a"
|
|
OpName %25 "buf0"
|
|
OpMemberName %25 0 "_GLF_uniform_float_values"
|
|
OpName %27 ""
|
|
OpName %33 "b"
|
|
OpName %36 "c"
|
|
OpName %41 "v"
|
|
OpName %44 "buf1"
|
|
OpMemberName %44 0 "_GLF_uniform_int_values"
|
|
OpName %46 ""
|
|
OpName %63 "i"
|
|
OpName %122 "_GLF_color"
|
|
OpDecorate %9 BuiltIn FragCoord
|
|
OpDecorate %24 ArrayStride 16
|
|
OpMemberDecorate %25 0 Offset 0
|
|
OpDecorate %25 Block
|
|
OpDecorate %27 DescriptorSet 0
|
|
OpDecorate %27 Binding 0
|
|
OpDecorate %43 ArrayStride 16
|
|
OpMemberDecorate %44 0 Offset 0
|
|
OpDecorate %44 Block
|
|
OpDecorate %46 DescriptorSet 0
|
|
OpDecorate %46 Binding 1
|
|
OpDecorate %122 Location 0
|
|
%2 = OpTypeVoid
|
|
%3 = OpTypeFunction %2
|
|
%6 = OpTypeFloat 32
|
|
%7 = OpTypeVector %6 4
|
|
%8 = OpTypePointer Input %7
|
|
%9 = OpVariable %8 Input
|
|
%10 = OpTypeInt 32 0
|
|
%11 = OpConstant %10 0
|
|
%12 = OpTypePointer Input %6
|
|
%15 = OpConstant %6 0
|
|
%16 = OpTypeBool
|
|
%21 = OpTypePointer Function %6
|
|
%23 = OpConstant %10 2
|
|
%24 = OpTypeArray %6 %23
|
|
%25 = OpTypeStruct %24
|
|
%26 = OpTypePointer Uniform %25
|
|
%27 = OpVariable %26 Uniform
|
|
%28 = OpTypeInt 32 1
|
|
%29 = OpConstant %28 0
|
|
%30 = OpTypePointer Uniform %6
|
|
%39 = OpTypeVector %6 3
|
|
%40 = OpTypePointer Function %39
|
|
%42 = OpConstant %10 3
|
|
%43 = OpTypeArray %28 %42
|
|
%44 = OpTypeStruct %43
|
|
%45 = OpTypePointer Uniform %44
|
|
%46 = OpVariable %45 Uniform
|
|
%47 = OpConstant %28 2
|
|
%48 = OpTypePointer Uniform %28
|
|
%53 = OpConstant %10 1
|
|
%60 = OpConstant %6 1
|
|
%62 = OpTypePointer Function %28
|
|
%99 = OpConstant %28 1
|
|
%116 = OpTypeVector %16 3
|
|
%121 = OpTypePointer Output %7
|
|
%122 = OpVariable %121 Output
|
|
%4 = OpFunction %2 None %3
|
|
%5 = OpLabel
|
|
%22 = OpVariable %21 Function
|
|
%33 = OpVariable %21 Function
|
|
%36 = OpVariable %21 Function
|
|
%41 = OpVariable %40 Function
|
|
%63 = OpVariable %62 Function
|
|
%13 = OpAccessChain %12 %9 %11
|
|
%14 = OpLoad %6 %13
|
|
%17 = OpFOrdLessThan %16 %14 %15
|
|
OpSelectionMerge %19 None
|
|
OpBranchConditional %17 %18 %19
|
|
%18 = OpLabel
|
|
OpTerminateInvocation
|
|
%19 = OpLabel
|
|
%31 = OpAccessChain %30 %27 %29 %29
|
|
%32 = OpLoad %6 %31
|
|
OpStore %22 %32
|
|
%34 = OpAccessChain %30 %27 %29 %29
|
|
%35 = OpLoad %6 %34
|
|
OpStore %33 %35
|
|
%37 = OpAccessChain %30 %27 %29 %29
|
|
%38 = OpLoad %6 %37
|
|
OpStore %36 %38
|
|
%49 = OpAccessChain %48 %46 %29 %47
|
|
%50 = OpLoad %28 %49
|
|
%51 = OpConvertSToF %6 %50
|
|
%52 = OpCompositeConstruct %39 %51 %51 %51
|
|
OpStore %41 %52
|
|
%54 = OpAccessChain %12 %9 %53
|
|
%55 = OpLoad %6 %54
|
|
%56 = OpFOrdLessThan %16 %55 %15
|
|
OpSelectionMerge %58 None
|
|
OpBranchConditional %56 %57 %58
|
|
%57 = OpLabel
|
|
%59 = OpLoad %6 %22
|
|
%61 = OpFAdd %6 %59 %60
|
|
OpStore %22 %61
|
|
OpBranch %58
|
|
%58 = OpLabel
|
|
%64 = OpAccessChain %48 %46 %29 %47
|
|
%65 = OpLoad %28 %64
|
|
OpStore %63 %65
|
|
OpBranch %66
|
|
%66 = OpLabel
|
|
OpLoopMerge %68 %69 None
|
|
OpBranch %70
|
|
%70 = OpLabel
|
|
%71 = OpLoad %28 %63
|
|
%72 = OpAccessChain %48 %46 %29 %29
|
|
%73 = OpLoad %28 %72
|
|
%74 = OpSLessThan %16 %71 %73
|
|
OpBranchConditional %74 %67 %68
|
|
%67 = OpLabel
|
|
%75 = OpAccessChain %12 %9 %11
|
|
%76 = OpLoad %6 %75
|
|
%77 = OpFOrdLessThan %16 %76 %15
|
|
OpSelectionMerge %79 None
|
|
OpBranchConditional %77 %78 %80
|
|
%78 = OpLabel
|
|
OpBranch %79
|
|
%80 = OpLabel
|
|
OpBranch %81
|
|
%81 = OpLabel
|
|
OpLoopMerge %83 %84 None
|
|
OpBranch %85
|
|
%85 = OpLabel
|
|
%86 = OpAccessChain %12 %9 %53
|
|
%87 = OpLoad %6 %86
|
|
%88 = OpFOrdLessThan %16 %87 %15
|
|
OpBranchConditional %88 %82 %83
|
|
%82 = OpLabel
|
|
OpBranch %84
|
|
%84 = OpLabel
|
|
OpBranch %81
|
|
%83 = OpLabel
|
|
OpBranch %79
|
|
%79 = OpLabel
|
|
%89 = OpAccessChain %12 %9 %53
|
|
%90 = OpLoad %6 %89
|
|
%91 = OpFOrdLessThan %16 %90 %15
|
|
OpSelectionMerge %93 None
|
|
OpBranchConditional %91 %92 %94
|
|
%92 = OpLabel
|
|
OpBranch %93
|
|
%94 = OpLabel
|
|
OpStore %33 %60
|
|
OpBranch %93
|
|
%93 = OpLabel
|
|
%95 = OpLoad %6 %33
|
|
%96 = OpFSub %6 %60 %95
|
|
%97 = OpLoad %6 %36
|
|
%98 = OpFMul %6 %97 %96
|
|
OpStore %36 %98
|
|
%100 = OpAccessChain %30 %27 %29 %99
|
|
%101 = OpLoad %6 %100
|
|
%102 = OpLoad %6 %33
|
|
%103 = OpFMul %6 %102 %101
|
|
OpStore %33 %103
|
|
%104 = OpLoad %28 %63
|
|
%105 = OpLoad %6 %22
|
|
%106 = OpLoad %6 %36
|
|
%107 = OpFAdd %6 %105 %106
|
|
%108 = OpAccessChain %21 %41 %104
|
|
OpStore %108 %107
|
|
OpBranch %69
|
|
%69 = OpLabel
|
|
%109 = OpLoad %28 %63
|
|
%110 = OpIAdd %28 %109 %99
|
|
OpStore %63 %110
|
|
OpBranch %66
|
|
%68 = OpLabel
|
|
%111 = OpLoad %39 %41
|
|
%112 = OpAccessChain %48 %46 %29 %99
|
|
%113 = OpLoad %28 %112
|
|
%114 = OpConvertSToF %6 %113
|
|
%115 = OpCompositeConstruct %39 %114 %114 %114
|
|
%117 = OpFOrdEqual %116 %111 %115
|
|
%118 = OpAll %16 %117
|
|
OpSelectionMerge %120 None
|
|
OpBranchConditional %118 %119 %136
|
|
%119 = OpLabel
|
|
%123 = OpAccessChain %48 %46 %29 %99
|
|
%124 = OpLoad %28 %123
|
|
%125 = OpConvertSToF %6 %124
|
|
%126 = OpAccessChain %48 %46 %29 %47
|
|
%127 = OpLoad %28 %126
|
|
%128 = OpConvertSToF %6 %127
|
|
%129 = OpAccessChain %48 %46 %29 %47
|
|
%130 = OpLoad %28 %129
|
|
%131 = OpConvertSToF %6 %130
|
|
%132 = OpAccessChain %48 %46 %29 %99
|
|
%133 = OpLoad %28 %132
|
|
%134 = OpConvertSToF %6 %133
|
|
%135 = OpCompositeConstruct %7 %125 %128 %131 %134
|
|
OpStore %122 %135
|
|
OpBranch %120
|
|
%136 = OpLabel
|
|
%137 = OpAccessChain %48 %46 %29 %47
|
|
%138 = OpLoad %28 %137
|
|
%139 = OpConvertSToF %6 %138
|
|
%140 = OpCompositeConstruct %7 %139 %139 %139 %139
|
|
OpStore %122 %140
|
|
OpBranch %120
|
|
%120 = OpLabel
|
|
OpReturn
|
|
OpFunctionEnd
|
|
END
|
|
|
|
# uniforms for variant
|
|
|
|
# _GLF_uniform_int_values
|
|
BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
|
|
3 1 0
|
|
END
|
|
# _GLF_uniform_float_values
|
|
BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
|
|
1.0 256.0
|
|
END
|
|
|
|
BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
|
|
|
|
PIPELINE graphics variant_pipeline
|
|
ATTACH variant_vertex_shader
|
|
ATTACH variant_fragment_shader
|
|
FRAMEBUFFER_SIZE 32 32
|
|
BIND BUFFER variant_framebuffer AS color LOCATION 0
|
|
BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
|
|
BIND BUFFER variant__GLF_uniform_float_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 32 32
|
|
|
|
EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255
|