blob: 769350bf3402ff113039906de0a7d72aa60122f3 [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: Covers instruction combine casting, combine shifting and DAG 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 310 es
# #define _int_0 _GLF_uniform_int_values[0]
# #define _int_1 _GLF_uniform_int_values[1]
# #define _int_2 _GLF_uniform_int_values[2]
# #define _float_2_0 _GLF_uniform_float_values[0]
# #define _float_1_0 _GLF_uniform_float_values[1]
# #define _float_0_0 _GLF_uniform_float_values[2]
#
# precision highp float;
#
# precision highp int;
#
# // Contents of _GLF_uniform_float_values: [2.0, 1.0, 0.0]
# layout(set = 0, binding = 0) uniform buf0
# {
# float _GLF_uniform_float_values[3];
# };
#
# // Contents of _GLF_uniform_int_values: [0, 1, 2]
# layout(set = 0, binding = 1) uniform buf1
# {
# int _GLF_uniform_int_values[3];
# };
#
# layout(location = 0) out vec4 _GLF_color;
#
# void main()
# {
# int numbers[3];
# numbers[_int_0] = _int_0;
# numbers[_int_1] = _int_1;
# numbers[_int_2] = _int_2;
#
# vec2 a = vec2(_int_0, numbers[((0.0 < _float_0_0) ? 1 : 2)]);
# float b = dot(a, vec2(_float_1_0, _float_1_0));
#
# if (b == _float_2_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: 94
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %75
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 310
OpName %4 "main"
OpName %11 "numbers"
OpName %13 "buf1"
OpMemberName %13 0 "_GLF_uniform_int_values"
OpName %15 ""
OpName %39 "a"
OpName %45 "buf0"
OpMemberName %45 0 "_GLF_uniform_float_values"
OpName %47 ""
OpName %59 "b"
OpName %75 "_GLF_color"
OpDecorate %12 ArrayStride 16
OpMemberDecorate %13 0 Offset 0
OpDecorate %13 Block
OpDecorate %15 DescriptorSet 0
OpDecorate %15 Binding 1
OpDecorate %44 ArrayStride 16
OpMemberDecorate %45 0 Offset 0
OpDecorate %45 Block
OpDecorate %47 DescriptorSet 0
OpDecorate %47 Binding 0
OpDecorate %75 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeInt 32 1
%7 = OpTypeInt 32 0
%8 = OpConstant %7 3
%9 = OpTypeArray %6 %8
%10 = OpTypePointer Function %9
%12 = OpTypeArray %6 %8
%13 = OpTypeStruct %12
%14 = OpTypePointer Uniform %13
%15 = OpVariable %14 Uniform
%16 = OpConstant %6 0
%17 = OpTypePointer Uniform %6
%22 = OpTypePointer Function %6
%24 = OpConstant %6 1
%30 = OpConstant %6 2
%36 = OpTypeFloat 32
%37 = OpTypeVector %36 2
%38 = OpTypePointer Function %37
%43 = OpConstant %36 0
%44 = OpTypeArray %36 %8
%45 = OpTypeStruct %44
%46 = OpTypePointer Uniform %45
%47 = OpVariable %46 Uniform
%48 = OpTypePointer Uniform %36
%51 = OpTypeBool
%58 = OpTypePointer Function %36
%73 = OpTypeVector %36 4
%74 = OpTypePointer Output %73
%75 = OpVariable %74 Output
%4 = OpFunction %2 None %3
%5 = OpLabel
%11 = OpVariable %10 Function
%39 = OpVariable %38 Function
%59 = OpVariable %58 Function
%18 = OpAccessChain %17 %15 %16 %16
%19 = OpLoad %6 %18
%20 = OpAccessChain %17 %15 %16 %16
%21 = OpLoad %6 %20
%23 = OpAccessChain %22 %11 %19
OpStore %23 %21
%25 = OpAccessChain %17 %15 %16 %24
%26 = OpLoad %6 %25
%27 = OpAccessChain %17 %15 %16 %24
%28 = OpLoad %6 %27
%29 = OpAccessChain %22 %11 %26
OpStore %29 %28
%31 = OpAccessChain %17 %15 %16 %30
%32 = OpLoad %6 %31
%33 = OpAccessChain %17 %15 %16 %30
%34 = OpLoad %6 %33
%35 = OpAccessChain %22 %11 %32
OpStore %35 %34
%40 = OpAccessChain %17 %15 %16 %16
%41 = OpLoad %6 %40
%42 = OpConvertSToF %36 %41
%49 = OpAccessChain %48 %47 %16 %30
%50 = OpLoad %36 %49
%52 = OpFOrdLessThan %51 %43 %50
%53 = OpSelect %6 %52 %24 %30
%54 = OpAccessChain %22 %11 %53
%55 = OpLoad %6 %54
%56 = OpConvertSToF %36 %55
%57 = OpCompositeConstruct %37 %42 %56
OpStore %39 %57
%60 = OpLoad %37 %39
%61 = OpAccessChain %48 %47 %16 %24
%62 = OpLoad %36 %61
%63 = OpAccessChain %48 %47 %16 %24
%64 = OpLoad %36 %63
%65 = OpCompositeConstruct %37 %62 %64
%66 = OpDot %36 %60 %65
OpStore %59 %66
%67 = OpLoad %36 %59
%68 = OpAccessChain %48 %47 %16 %16
%69 = OpLoad %36 %68
%70 = OpFOrdEqual %51 %67 %69
OpSelectionMerge %72 None
OpBranchConditional %70 %71 %89
%71 = OpLabel
%76 = OpAccessChain %17 %15 %16 %24
%77 = OpLoad %6 %76
%78 = OpConvertSToF %36 %77
%79 = OpAccessChain %17 %15 %16 %16
%80 = OpLoad %6 %79
%81 = OpConvertSToF %36 %80
%82 = OpAccessChain %17 %15 %16 %16
%83 = OpLoad %6 %82
%84 = OpConvertSToF %36 %83
%85 = OpAccessChain %17 %15 %16 %24
%86 = OpLoad %6 %85
%87 = OpConvertSToF %36 %86
%88 = OpCompositeConstruct %73 %78 %81 %84 %87
OpStore %75 %88
OpBranch %72
%89 = OpLabel
%90 = OpAccessChain %17 %15 %16 %16
%91 = OpLoad %6 %90
%92 = OpConvertSToF %36 %91
%93 = OpCompositeConstruct %73 %92 %92 %92 %92
OpStore %75 %93
OpBranch %72
%72 = OpLabel
OpReturn
OpFunctionEnd
END
# uniforms for variant
# _GLF_uniform_int_values
BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
0 1 2
END
# _GLF_uniform_float_values
BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
2.0 1.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