271 lines
7.9 KiB
Plaintext
271 lines
7.9 KiB
Plaintext
#!amber
|
|
|
|
# Copyright 2021 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 specific LLVM code paths
|
|
|
|
# The test passes because the shader always writes red.
|
|
|
|
# Optimized using spirv-opt with the following arguments:
|
|
# '--copy-propagate-arrays'
|
|
# '--eliminate-dead-inserts'
|
|
# '--convert-local-access-chains'
|
|
# '--private-to-local'
|
|
# '--redundancy-elimination'
|
|
# '--eliminate-local-multi-store'
|
|
# '--eliminate-local-single-block'
|
|
# '--eliminate-dead-code-aggressive'
|
|
# '--copy-propagate-arrays'
|
|
# '--eliminate-dead-inserts'
|
|
# '--redundancy-elimination'
|
|
# '--eliminate-local-single-block'
|
|
# '--eliminate-local-single-store'
|
|
# '--eliminate-local-single-store'
|
|
# '--eliminate-dead-code-aggressive'
|
|
# '--inline-entry-points-exhaustive'
|
|
# '--combine-access-chains'
|
|
# '--eliminate-dead-branches'
|
|
# '--merge-return'
|
|
# '--eliminate-local-single-block'
|
|
# '--eliminate-dead-branches'
|
|
# '--reduce-load-size'
|
|
# '--eliminate-dead-inserts'
|
|
# '--copy-propagate-arrays'
|
|
# '--convert-local-access-chains'
|
|
# '--vector-dce'
|
|
# '--redundancy-elimination'
|
|
# '--eliminate-local-multi-store'
|
|
# '--redundancy-elimination'
|
|
# '--eliminate-dead-inserts'
|
|
# '--eliminate-dead-code-aggressive'
|
|
# spirv-opt commit hash: a0370efd589be33d5d9a85cfde2f85841b3755af
|
|
|
|
|
|
|
|
SHADER vertex texgen_vert PASSTHROUGH
|
|
|
|
SHADER fragment texgen_frag GLSL
|
|
#version 430
|
|
precision highp float;
|
|
|
|
layout(location = 0) out vec4 _GLF_color;
|
|
|
|
void main()
|
|
{
|
|
_GLF_color = vec4(
|
|
floor(gl_FragCoord.x) * (1.0 / 255.0),
|
|
(int(gl_FragCoord.x) ^ int(gl_FragCoord.y)) * (1.0 / 255.0),
|
|
floor(gl_FragCoord.y) * (1.0 / 255.0),
|
|
1.0);
|
|
}
|
|
END
|
|
BUFFER default_texture FORMAT B8G8R8A8_UNORM
|
|
|
|
PIPELINE graphics texgen_pipeline
|
|
ATTACH texgen_vert
|
|
ATTACH texgen_frag
|
|
FRAMEBUFFER_SIZE 256 256
|
|
BIND BUFFER default_texture AS color LOCATION 0
|
|
END
|
|
|
|
CLEAR_COLOR texgen_pipeline 0 0 0 255
|
|
CLEAR texgen_pipeline
|
|
RUN texgen_pipeline DRAW_RECT POS 0 0 SIZE 256 256
|
|
|
|
SHADER vertex variant_vertex_shader PASSTHROUGH
|
|
|
|
# variant_fragment_shader is derived from the following GLSL:
|
|
# #version 320 es
|
|
#
|
|
# precision highp float;
|
|
# precision highp int;
|
|
#
|
|
# const int _GLF_global_loop_bound = 10;
|
|
# int _GLF_global_loop_count = 0;
|
|
#
|
|
# struct S
|
|
# {
|
|
# int data;
|
|
# };
|
|
#
|
|
# layout(set = 0, binding = 0) uniform sampler2D tex;
|
|
#
|
|
# layout(location = 0) out vec4 _GLF_color;
|
|
#
|
|
# void main()
|
|
# {
|
|
# int a = 1;
|
|
# int b = 1;
|
|
# vec4 v = vec4(1.0);
|
|
# S s = S(1);
|
|
#
|
|
# // Iterated once.
|
|
# while(v.x + 1.0 > 0.0 && s.data <= 1 && _GLF_global_loop_count < _GLF_global_loop_bound)
|
|
# {
|
|
# _GLF_global_loop_count++;
|
|
#
|
|
# // Always false.
|
|
# if(b++ > 3)
|
|
# {
|
|
# break;
|
|
# }
|
|
#
|
|
# // The sampled value doesn't matter because the loop will exit in any case.
|
|
# v = texture(tex, vec2(1.0));
|
|
#
|
|
# // This will cause the loop to exit.
|
|
# s.data++;
|
|
# }
|
|
#
|
|
# // Always true.
|
|
# if (s.data == 2)
|
|
# _GLF_color = vec4(float(a), 0, 0, 1);
|
|
# else
|
|
# _GLF_color = vec4(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: 96
|
|
; Schema: 0
|
|
OpCapability Shader
|
|
%1 = OpExtInstImport "GLSL.std.450"
|
|
OpMemoryModel Logical GLSL450
|
|
OpEntryPoint Fragment %4 "main" %75
|
|
OpExecutionMode %4 OriginUpperLeft
|
|
OpSource ESSL 320
|
|
OpName %4 "main"
|
|
OpName %20 "S"
|
|
OpMemberName %20 0 "data"
|
|
OpName %60 "tex"
|
|
OpName %75 "_GLF_color"
|
|
OpDecorate %60 RelaxedPrecision
|
|
OpDecorate %60 DescriptorSet 0
|
|
OpDecorate %60 Binding 0
|
|
OpDecorate %61 RelaxedPrecision
|
|
OpDecorate %64 RelaxedPrecision
|
|
OpDecorate %75 Location 0
|
|
%2 = OpTypeVoid
|
|
%3 = OpTypeFunction %2
|
|
%6 = OpTypeInt 32 1
|
|
%9 = OpConstant %6 0
|
|
%12 = OpConstant %6 1
|
|
%14 = OpTypeFloat 32
|
|
%15 = OpTypeVector %14 4
|
|
%18 = OpConstant %14 1
|
|
%19 = OpConstantComposite %15 %18 %18 %18 %18
|
|
%20 = OpTypeStruct %6
|
|
%23 = OpConstantComposite %20 %12
|
|
%29 = OpTypeBool
|
|
%36 = OpConstant %14 0
|
|
%45 = OpConstant %6 10
|
|
%52 = OpConstant %6 3
|
|
%57 = OpTypeImage %14 2D 0 0 0 1 Unknown
|
|
%58 = OpTypeSampledImage %57
|
|
%59 = OpTypePointer UniformConstant %58
|
|
%60 = OpVariable %59 UniformConstant
|
|
%62 = OpTypeVector %14 2
|
|
%63 = OpConstantComposite %62 %18 %18
|
|
%70 = OpConstant %6 2
|
|
%74 = OpTypePointer Output %15
|
|
%75 = OpVariable %74 Output
|
|
%80 = OpConstantComposite %15 %36 %36 %36 %36
|
|
%4 = OpFunction %2 None %3
|
|
%5 = OpLabel
|
|
OpBranch %24
|
|
%24 = OpLabel
|
|
%95 = OpPhi %20 %23 %5 %85 %27
|
|
%94 = OpPhi %15 %19 %5 %64 %27
|
|
%90 = OpPhi %6 %12 %5 %51 %27
|
|
%88 = OpPhi %6 %9 %5 %49 %27
|
|
%93 = OpPhi %6 %12 %5 %93 %27
|
|
OpLoopMerge %26 %27 None
|
|
OpBranch %28
|
|
%28 = OpLabel
|
|
%34 = OpCompositeExtract %14 %94 0
|
|
%35 = OpFAdd %14 %34 %18
|
|
%37 = OpFOrdGreaterThan %29 %35 %36
|
|
OpSelectionMerge %39 None
|
|
OpBranchConditional %37 %38 %39
|
|
%38 = OpLabel
|
|
%41 = OpCompositeExtract %6 %95 0
|
|
%42 = OpSLessThanEqual %29 %41 %12
|
|
OpBranch %39
|
|
%39 = OpLabel
|
|
%43 = OpPhi %29 %37 %28 %42 %38
|
|
%46 = OpSLessThan %29 %88 %45
|
|
%47 = OpLogicalAnd %29 %43 %46
|
|
OpBranchConditional %47 %25 %26
|
|
%25 = OpLabel
|
|
%49 = OpIAdd %6 %88 %12
|
|
%51 = OpIAdd %6 %90 %12
|
|
%53 = OpSGreaterThan %29 %90 %52
|
|
OpSelectionMerge %55 None
|
|
OpBranchConditional %53 %54 %55
|
|
%54 = OpLabel
|
|
OpBranch %26
|
|
%55 = OpLabel
|
|
%61 = OpLoad %58 %60
|
|
%64 = OpImageSampleImplicitLod %15 %61 %63
|
|
%66 = OpCompositeExtract %6 %95 0
|
|
%67 = OpIAdd %6 %66 %12
|
|
%85 = OpCompositeInsert %20 %67 %95 0
|
|
OpBranch %27
|
|
%27 = OpLabel
|
|
OpBranch %24
|
|
%26 = OpLabel
|
|
%69 = OpCompositeExtract %6 %95 0
|
|
%71 = OpIEqual %29 %69 %70
|
|
OpSelectionMerge %73 None
|
|
OpBranchConditional %71 %72 %79
|
|
%72 = OpLabel
|
|
%77 = OpConvertSToF %14 %93
|
|
%78 = OpCompositeConstruct %15 %77 %36 %36 %18
|
|
OpStore %75 %78
|
|
OpBranch %73
|
|
%79 = OpLabel
|
|
OpStore %75 %80
|
|
OpBranch %73
|
|
%73 = OpLabel
|
|
OpReturn
|
|
OpFunctionEnd
|
|
END
|
|
|
|
# uniforms for variant
|
|
|
|
# GLF_live1tex
|
|
SAMPLER variant_GLF_live1tex
|
|
|
|
|
|
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 default_texture AS combined_image_sampler SAMPLER variant_GLF_live1tex 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
|