blob: e73f48d33bad5d908fdbf874d421a299a3a597bb [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 the GraphicsFuzz project.
# Short description: A fragment shader that covers a specific floating point 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_2 _GLF_uniform_int_values[1]
# #define _int_3 _GLF_uniform_int_values[2]
# #define _int_4 _GLF_uniform_int_values[3]
# #define _int_5 _GLF_uniform_int_values[4]
# #define _int_6 _GLF_uniform_int_values[5]
# #define _int_7 _GLF_uniform_int_values[6]
# #define _int_8 _GLF_uniform_int_values[7]
# #define _int_0 _GLF_uniform_int_values[8]
# #define _also_1 _GLF_uniform_int_values[9]
# #define _float_0_0 _GLF_uniform_float_values[0]
#
# precision highp float;
# precision highp int;
#
# // Contents of _GLF_uniform_float_values: 0.0
# layout(set = 0, binding = 0) uniform buf0
# {
# float _GLF_uniform_float_values[1];
# };
#
# // Contents of _GLF_uniform_int_values: [1, 2, 3, 4, 5, 6, 7, 8, 0]
# layout(set = 0, binding = 1) uniform buf1
# {
# int _GLF_uniform_int_values[10];
# };
#
# layout(location = 0) out vec4 _GLF_color;
#
# void main()
# {
# float nan = intBitsToFloat(-1);
#
# // This results in an undefined value, but not in undefined behavior.
# vec4 undefined = mix(vec4(_int_1, _int_2, _int_3, _int_4),
# vec4(_int_5, _int_6, _int_7, _int_8), nan);
#
# if (_int_1 == _also_1 || undefined.x > _float_0_0)
# {
# _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: 105
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %85
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 310
OpName %4 "main"
OpName %8 "nan"
OpName %14 "undefined"
OpName %18 "buf1"
OpMemberName %18 0 "_GLF_uniform_int_values"
OpName %20 ""
OpName %74 "buf0"
OpMemberName %74 0 "_GLF_uniform_float_values"
OpName %76 ""
OpName %85 "_GLF_color"
OpDecorate %17 ArrayStride 16
OpMemberDecorate %18 0 Offset 0
OpDecorate %18 Block
OpDecorate %20 DescriptorSet 0
OpDecorate %20 Binding 1
OpDecorate %73 ArrayStride 16
OpMemberDecorate %74 0 Offset 0
OpDecorate %74 Block
OpDecorate %76 DescriptorSet 0
OpDecorate %76 Binding 0
OpDecorate %85 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeFloat 32
%7 = OpTypePointer Function %6
%9 = OpTypeInt 32 1
%10 = OpConstant %9 -1
%12 = OpTypeVector %6 4
%13 = OpTypePointer Function %12
%15 = OpTypeInt 32 0
%16 = OpConstant %15 10
%17 = OpTypeArray %9 %16
%18 = OpTypeStruct %17
%19 = OpTypePointer Uniform %18
%20 = OpVariable %19 Uniform
%21 = OpConstant %9 0
%22 = OpTypePointer Uniform %9
%26 = OpConstant %9 1
%30 = OpConstant %9 2
%34 = OpConstant %9 3
%39 = OpConstant %9 4
%43 = OpConstant %9 5
%47 = OpConstant %9 6
%51 = OpConstant %9 7
%59 = OpTypeBool
%62 = OpConstant %9 9
%69 = OpConstant %15 0
%72 = OpConstant %15 1
%73 = OpTypeArray %6 %72
%74 = OpTypeStruct %73
%75 = OpTypePointer Uniform %74
%76 = OpVariable %75 Uniform
%77 = OpTypePointer Uniform %6
%84 = OpTypePointer Output %12
%85 = OpVariable %84 Output
%89 = OpConstant %9 8
%4 = OpFunction %2 None %3
%5 = OpLabel
%8 = OpVariable %7 Function
%14 = OpVariable %13 Function
%11 = OpBitcast %6 %10
OpStore %8 %11
%23 = OpAccessChain %22 %20 %21 %21
%24 = OpLoad %9 %23
%25 = OpConvertSToF %6 %24
%27 = OpAccessChain %22 %20 %21 %26
%28 = OpLoad %9 %27
%29 = OpConvertSToF %6 %28
%31 = OpAccessChain %22 %20 %21 %30
%32 = OpLoad %9 %31
%33 = OpConvertSToF %6 %32
%35 = OpAccessChain %22 %20 %21 %34
%36 = OpLoad %9 %35
%37 = OpConvertSToF %6 %36
%38 = OpCompositeConstruct %12 %25 %29 %33 %37
%40 = OpAccessChain %22 %20 %21 %39
%41 = OpLoad %9 %40
%42 = OpConvertSToF %6 %41
%44 = OpAccessChain %22 %20 %21 %43
%45 = OpLoad %9 %44
%46 = OpConvertSToF %6 %45
%48 = OpAccessChain %22 %20 %21 %47
%49 = OpLoad %9 %48
%50 = OpConvertSToF %6 %49
%52 = OpAccessChain %22 %20 %21 %51
%53 = OpLoad %9 %52
%54 = OpConvertSToF %6 %53
%55 = OpCompositeConstruct %12 %42 %46 %50 %54
%56 = OpLoad %6 %8
%57 = OpCompositeConstruct %12 %56 %56 %56 %56
%58 = OpExtInst %12 %1 FMix %38 %55 %57
OpStore %14 %58
%60 = OpAccessChain %22 %20 %21 %21
%61 = OpLoad %9 %60
%63 = OpAccessChain %22 %20 %21 %62
%64 = OpLoad %9 %63
%65 = OpIEqual %59 %61 %64
%66 = OpLogicalNot %59 %65
OpSelectionMerge %68 None
OpBranchConditional %66 %67 %68
%67 = OpLabel
%70 = OpAccessChain %7 %14 %69
%71 = OpLoad %6 %70
%78 = OpAccessChain %77 %76 %21 %21
%79 = OpLoad %6 %78
%80 = OpFOrdGreaterThan %59 %71 %79
OpBranch %68
%68 = OpLabel
%81 = OpPhi %59 %65 %5 %80 %67
OpSelectionMerge %83 None
OpBranchConditional %81 %82 %100
%82 = OpLabel
%86 = OpAccessChain %22 %20 %21 %21
%87 = OpLoad %9 %86
%88 = OpConvertSToF %6 %87
%90 = OpAccessChain %22 %20 %21 %89
%91 = OpLoad %9 %90
%92 = OpConvertSToF %6 %91
%93 = OpAccessChain %22 %20 %21 %89
%94 = OpLoad %9 %93
%95 = OpConvertSToF %6 %94
%96 = OpAccessChain %22 %20 %21 %21
%97 = OpLoad %9 %96
%98 = OpConvertSToF %6 %97
%99 = OpCompositeConstruct %12 %88 %92 %95 %98
OpStore %85 %99
OpBranch %83
%100 = OpLabel
%101 = OpAccessChain %22 %20 %21 %89
%102 = OpLoad %9 %101
%103 = OpConvertSToF %6 %102
%104 = OpCompositeConstruct %12 %103 %103 %103 %103
OpStore %85 %104
OpBranch %83
%83 = OpLabel
OpReturn
OpFunctionEnd
END
# uniforms for variant
# _GLF_uniform_int_values
BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
1 2 3 4 5 6 7 8 0 1
END
# _GLF_uniform_float_values
BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
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