| #!amber |
| |
| # Copyright 2019 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 bug found by GraphicsFuzz. |
| |
| # Short description: A fragment shader with an always false if function |
| |
| # The test passes because main always writes the color red. (Additionally the discard statement is never reached). |
| |
| # Optimized using spirv-opt with the following arguments: |
| # '--eliminate-local-single-block' |
| # '--reduce-load-size' |
| # '--combine-access-chains' |
| # '--eliminate-local-multi-store' |
| # '--reduce-load-size' |
| # '--convert-local-access-chains' |
| # '--eliminate-dead-branches' |
| # '--eliminate-dead-branches' |
| # '--merge-return' |
| # '--copy-propagate-arrays' |
| # '--copy-propagate-arrays' |
| # '--eliminate-dead-inserts' |
| # '--merge-blocks' |
| # '--copy-propagate-arrays' |
| # '--combine-access-chains' |
| # '--simplify-instructions' |
| # '--convert-local-access-chains' |
| # spirv-opt commit hash: 4a00a80c40484a6f6f72f48c9d34943cf8f180d4 |
| |
| |
| |
| SHADER vertex variant_vertex_shader PASSTHROUGH |
| |
| # variant_fragment_shader is derived from the following GLSL: |
| # #version 310 es |
| # |
| # // END OF GENERATED HEADER |
| # precision highp float; |
| # |
| # layout(location = 0) out vec4 _GLF_color; |
| # layout(set = 0, binding = 0) uniform buf0 |
| # { |
| # vec2 injectionSwitch; |
| # }; |
| # |
| # vec3 mand() |
| # { |
| # for ( |
| # int k = 0; |
| # k < 1000; |
| # 1) |
| # { |
| # discard; |
| # } |
| # return vec3(1.0); |
| # } |
| # void main() |
| # { |
| # if (injectionSwitch.x > injectionSwitch.y) |
| # { |
| # for ( |
| # int j = 0; |
| # j < 4; |
| # 1) |
| # { |
| # mand(); |
| # } |
| # } |
| # |
| # _GLF_color = vec4(1.0, 0.0, 0.0, 1.0); |
| # |
| # } |
| SHADER fragment variant_fragment_shader SPIRV-ASM |
| ; SPIR-V |
| ; Version: 1.0 |
| ; Generator: Khronos Glslang Reference Front End; 7 |
| ; Bound: 64 |
| ; Schema: 0 |
| OpCapability Shader |
| %1 = OpExtInstImport "GLSL.std.450" |
| OpMemoryModel Logical GLSL450 |
| OpEntryPoint Fragment %4 "main" %57 |
| OpExecutionMode %4 OriginUpperLeft |
| OpSource ESSL 310 |
| OpName %4 "main" |
| OpName %9 "mand(" |
| OpName %13 "k" |
| OpName %31 "buf0" |
| OpMemberName %31 0 "injectionSwitch" |
| OpName %33 "" |
| OpName %45 "j" |
| OpName %57 "_GLF_color" |
| OpDecorate %13 RelaxedPrecision |
| OpMemberDecorate %31 0 Offset 0 |
| OpDecorate %31 Block |
| OpDecorate %33 DescriptorSet 0 |
| OpDecorate %33 Binding 0 |
| OpDecorate %45 RelaxedPrecision |
| OpDecorate %57 Location 0 |
| OpDecorate %14 RelaxedPrecision |
| %2 = OpTypeVoid |
| %3 = OpTypeFunction %2 |
| %6 = OpTypeFloat 32 |
| %7 = OpTypeVector %6 3 |
| %8 = OpTypeFunction %7 |
| %11 = OpTypeInt 32 1 |
| %12 = OpTypePointer Function %11 |
| %14 = OpConstant %11 0 |
| %21 = OpConstant %11 1000 |
| %22 = OpTypeBool |
| %25 = OpConstant %11 1 |
| %26 = OpConstant %6 1 |
| %27 = OpConstantComposite %7 %26 %26 %26 |
| %30 = OpTypeVector %6 2 |
| %31 = OpTypeStruct %30 |
| %32 = OpTypePointer Uniform %31 |
| %33 = OpVariable %32 Uniform |
| %34 = OpTypeInt 32 0 |
| %35 = OpConstant %34 0 |
| %36 = OpTypePointer Uniform %6 |
| %39 = OpConstant %34 1 |
| %52 = OpConstant %11 4 |
| %55 = OpTypeVector %6 4 |
| %56 = OpTypePointer Output %55 |
| %57 = OpVariable %56 Output |
| %58 = OpConstant %6 0 |
| %59 = OpConstantComposite %55 %26 %58 %58 %26 |
| %62 = OpUndef %11 |
| %63 = OpConstantTrue %22 |
| %4 = OpFunction %2 None %3 |
| %5 = OpLabel |
| %45 = OpVariable %12 Function |
| %37 = OpAccessChain %36 %33 %14 %35 |
| %38 = OpLoad %6 %37 |
| %40 = OpAccessChain %36 %33 %14 %39 |
| %41 = OpLoad %6 %40 |
| %42 = OpFOrdGreaterThan %22 %38 %41 |
| OpSelectionMerge %44 None |
| OpBranchConditional %42 %43 %44 |
| %43 = OpLabel |
| OpStore %45 %14 |
| OpBranch %46 |
| %46 = OpLabel |
| OpLoopMerge %48 %47 None |
| OpBranchConditional %63 %47 %48 |
| %47 = OpLabel |
| %54 = OpFunctionCall %7 %9 |
| OpBranch %46 |
| %48 = OpLabel |
| OpBranch %44 |
| %44 = OpLabel |
| OpStore %57 %59 |
| OpReturn |
| OpFunctionEnd |
| %9 = OpFunction %7 None %8 |
| %10 = OpLabel |
| %13 = OpVariable %12 Function |
| OpStore %13 %14 |
| OpBranch %15 |
| %15 = OpLabel |
| OpLoopMerge %17 %18 None |
| OpBranchConditional %63 %16 %17 |
| %16 = OpLabel |
| OpKill |
| %18 = OpLabel |
| OpBranch %15 |
| %17 = OpLabel |
| OpReturnValue %27 |
| OpFunctionEnd |
| END |
| |
| # uniforms for variant |
| |
| # injectionSwitch |
| BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA |
| 0.0 1.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_injectionSwitch 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 |