231 lines
7.5 KiB
Plaintext
231 lines
7.5 KiB
Plaintext
#!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 the GraphicsFuzz project.
|
|
|
|
# Short description: A fragment shader that covers a specific inst combine add sub code path
|
|
|
|
# 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
|
|
# #define _int_1 _GLF_uniform_int_values[0]
|
|
# #define _int_0 _GLF_uniform_int_values[1]
|
|
# #define _float_1_0 _GLF_uniform_float_values[0]
|
|
# #define _float_4_0 _GLF_uniform_float_values[1]
|
|
# #define _float_3_0 _GLF_uniform_float_values[2]
|
|
# #define _float_2_0 _GLF_uniform_float_values[3]
|
|
# #define _float_0_0 _GLF_uniform_float_values[4]
|
|
#
|
|
# precision highp float;
|
|
# precision highp int;
|
|
#
|
|
# // Contents of _GLF_uniform_float_values: [1.0, 4.0, 3.0, 2.0, 0.0]
|
|
# layout(set = 0, binding = 0) uniform buf0
|
|
# {
|
|
# float _GLF_uniform_float_values[5];
|
|
# };
|
|
#
|
|
# // Contents of _GLF_uniform_int_values: [1, 0]
|
|
# layout(set = 0, binding = 1) uniform buf1
|
|
# {
|
|
# int _GLF_uniform_int_values[2];
|
|
# };
|
|
#
|
|
# layout(location = 0) out vec4 _GLF_color;
|
|
#
|
|
# void main()
|
|
# {
|
|
# // mix() selects 2.0.
|
|
# float a = mix(-_float_1_0, 2.0, _float_0_0 < _float_1_0);
|
|
# mat2 m = mat2(1.0, a, 3.0, 4.0);
|
|
# float ref = _float_1_0 * _float_4_0 - (_float_2_0)*_float_3_0;
|
|
#
|
|
# if (determinant(m) == ref)
|
|
# {
|
|
# _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; 8
|
|
; Bound: 90
|
|
; 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 %8 "a"
|
|
OpName %12 "buf0"
|
|
OpMemberName %12 0 "_GLF_uniform_float_values"
|
|
OpName %14 ""
|
|
OpName %33 "m"
|
|
OpName %42 "ref"
|
|
OpName %65 "_GLF_color"
|
|
OpName %68 "buf1"
|
|
OpMemberName %68 0 "_GLF_uniform_int_values"
|
|
OpName %70 ""
|
|
OpDecorate %11 ArrayStride 16
|
|
OpMemberDecorate %12 0 Offset 0
|
|
OpDecorate %12 Block
|
|
OpDecorate %14 DescriptorSet 0
|
|
OpDecorate %14 Binding 0
|
|
OpDecorate %65 Location 0
|
|
OpDecorate %67 ArrayStride 16
|
|
OpMemberDecorate %68 0 Offset 0
|
|
OpDecorate %68 Block
|
|
OpDecorate %70 DescriptorSet 0
|
|
OpDecorate %70 Binding 1
|
|
%2 = OpTypeVoid
|
|
%3 = OpTypeFunction %2
|
|
%6 = OpTypeFloat 32
|
|
%7 = OpTypePointer Function %6
|
|
%9 = OpTypeInt 32 0
|
|
%10 = OpConstant %9 5
|
|
%11 = OpTypeArray %6 %10
|
|
%12 = OpTypeStruct %11
|
|
%13 = OpTypePointer Uniform %12
|
|
%14 = OpVariable %13 Uniform
|
|
%15 = OpTypeInt 32 1
|
|
%16 = OpConstant %15 0
|
|
%17 = OpTypePointer Uniform %6
|
|
%21 = OpConstant %6 2
|
|
%22 = OpConstant %15 4
|
|
%27 = OpTypeBool
|
|
%30 = OpTypeVector %6 2
|
|
%31 = OpTypeMatrix %30 2
|
|
%32 = OpTypePointer Function %31
|
|
%34 = OpConstant %6 1
|
|
%36 = OpConstant %6 3
|
|
%37 = OpConstant %6 4
|
|
%38 = OpConstant %6 0
|
|
%45 = OpConstant %15 1
|
|
%49 = OpConstant %15 3
|
|
%52 = OpConstant %15 2
|
|
%63 = OpTypeVector %6 4
|
|
%64 = OpTypePointer Output %63
|
|
%65 = OpVariable %64 Output
|
|
%66 = OpConstant %9 2
|
|
%67 = OpTypeArray %15 %66
|
|
%68 = OpTypeStruct %67
|
|
%69 = OpTypePointer Uniform %68
|
|
%70 = OpVariable %69 Uniform
|
|
%71 = OpTypePointer Uniform %15
|
|
%4 = OpFunction %2 None %3
|
|
%5 = OpLabel
|
|
%8 = OpVariable %7 Function
|
|
%33 = OpVariable %32 Function
|
|
%42 = OpVariable %7 Function
|
|
%18 = OpAccessChain %17 %14 %16 %16
|
|
%19 = OpLoad %6 %18
|
|
%20 = OpFNegate %6 %19
|
|
%23 = OpAccessChain %17 %14 %16 %22
|
|
%24 = OpLoad %6 %23
|
|
%25 = OpAccessChain %17 %14 %16 %16
|
|
%26 = OpLoad %6 %25
|
|
%28 = OpFOrdLessThan %27 %24 %26
|
|
%29 = OpSelect %6 %28 %21 %20
|
|
OpStore %8 %29
|
|
%35 = OpLoad %6 %8
|
|
%39 = OpCompositeConstruct %30 %34 %35
|
|
%40 = OpCompositeConstruct %30 %36 %37
|
|
%41 = OpCompositeConstruct %31 %39 %40
|
|
OpStore %33 %41
|
|
%43 = OpAccessChain %17 %14 %16 %16
|
|
%44 = OpLoad %6 %43
|
|
%46 = OpAccessChain %17 %14 %16 %45
|
|
%47 = OpLoad %6 %46
|
|
%48 = OpFMul %6 %44 %47
|
|
%50 = OpAccessChain %17 %14 %16 %49
|
|
%51 = OpLoad %6 %50
|
|
%53 = OpAccessChain %17 %14 %16 %52
|
|
%54 = OpLoad %6 %53
|
|
%55 = OpFMul %6 %51 %54
|
|
%56 = OpFSub %6 %48 %55
|
|
OpStore %42 %56
|
|
%57 = OpLoad %31 %33
|
|
%58 = OpExtInst %6 %1 Determinant %57
|
|
%59 = OpLoad %6 %42
|
|
%60 = OpFOrdEqual %27 %58 %59
|
|
OpSelectionMerge %62 None
|
|
OpBranchConditional %60 %61 %85
|
|
%61 = OpLabel
|
|
%72 = OpAccessChain %71 %70 %16 %16
|
|
%73 = OpLoad %15 %72
|
|
%74 = OpConvertSToF %6 %73
|
|
%75 = OpAccessChain %71 %70 %16 %45
|
|
%76 = OpLoad %15 %75
|
|
%77 = OpConvertSToF %6 %76
|
|
%78 = OpAccessChain %71 %70 %16 %45
|
|
%79 = OpLoad %15 %78
|
|
%80 = OpConvertSToF %6 %79
|
|
%81 = OpAccessChain %71 %70 %16 %16
|
|
%82 = OpLoad %15 %81
|
|
%83 = OpConvertSToF %6 %82
|
|
%84 = OpCompositeConstruct %63 %74 %77 %80 %83
|
|
OpStore %65 %84
|
|
OpBranch %62
|
|
%85 = OpLabel
|
|
%86 = OpAccessChain %71 %70 %16 %45
|
|
%87 = OpLoad %15 %86
|
|
%88 = OpConvertSToF %6 %87
|
|
%89 = OpCompositeConstruct %63 %88 %88 %88 %88
|
|
OpStore %65 %89
|
|
OpBranch %62
|
|
%62 = OpLabel
|
|
OpReturn
|
|
OpFunctionEnd
|
|
END
|
|
|
|
# uniforms for variant
|
|
|
|
# _GLF_uniform_int_values
|
|
BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
|
|
1 0
|
|
END
|
|
# _GLF_uniform_float_values
|
|
BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
|
|
1.0 4.0 3.0 2.0 0.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__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 256 256
|
|
|
|
EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
|