| #!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 specific inst combine add sub and inst combine simplify demanded 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_1 _GLF_uniform_int_values[0] |
| # #define _int_0 _GLF_uniform_int_values[1] |
| # #define _int_2 _GLF_uniform_int_values[2] |
| # #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, 0, 2] |
| # layout(set = 0, binding = 1) uniform buf1 |
| # { |
| # int _GLF_uniform_int_values[3]; |
| # }; |
| # |
| # layout(location = 0) out vec4 _GLF_color; |
| # |
| # int f1() |
| # { |
| # int a = 256; |
| # |
| # if (gl_FragCoord.y > _float_0_0) |
| # { |
| # a++; |
| # } |
| # |
| # // i becomes 2. |
| # int i = bitCount(a); |
| # |
| # if (i < _int_1) |
| # { |
| # return _int_1; |
| # } |
| # |
| # // Always returns 2. |
| # return i; |
| # } |
| # |
| # void main() |
| # { |
| # int a = f1(); |
| # |
| # if (a == _int_2) |
| # { |
| # _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; 10 |
| ; Bound: 87 |
| ; Schema: 0 |
| OpCapability Shader |
| %1 = OpExtInstImport "GLSL.std.450" |
| OpMemoryModel Logical GLSL450 |
| OpEntryPoint Fragment %4 "main" %16 %68 |
| OpExecutionMode %4 OriginUpperLeft |
| OpSource ESSL 310 |
| OpName %4 "main" |
| OpName %8 "f1(" |
| OpName %11 "a" |
| OpName %16 "gl_FragCoord" |
| OpName %23 "buf0" |
| OpMemberName %23 0 "_GLF_uniform_float_values" |
| OpName %25 "" |
| OpName %37 "i" |
| OpName %43 "buf1" |
| OpMemberName %43 0 "_GLF_uniform_int_values" |
| OpName %45 "" |
| OpName %58 "a" |
| OpName %68 "_GLF_color" |
| OpDecorate %16 BuiltIn FragCoord |
| OpDecorate %22 ArrayStride 16 |
| OpMemberDecorate %23 0 Offset 0 |
| OpDecorate %23 Block |
| OpDecorate %25 DescriptorSet 0 |
| OpDecorate %25 Binding 0 |
| OpDecorate %42 ArrayStride 16 |
| OpMemberDecorate %43 0 Offset 0 |
| OpDecorate %43 Block |
| OpDecorate %45 DescriptorSet 0 |
| OpDecorate %45 Binding 1 |
| OpDecorate %68 Location 0 |
| %2 = OpTypeVoid |
| %3 = OpTypeFunction %2 |
| %6 = OpTypeInt 32 1 |
| %7 = OpTypeFunction %6 |
| %10 = OpTypePointer Function %6 |
| %12 = OpConstant %6 256 |
| %13 = OpTypeFloat 32 |
| %14 = OpTypeVector %13 4 |
| %15 = OpTypePointer Input %14 |
| %16 = OpVariable %15 Input |
| %17 = OpTypeInt 32 0 |
| %18 = OpConstant %17 1 |
| %19 = OpTypePointer Input %13 |
| %22 = OpTypeArray %13 %18 |
| %23 = OpTypeStruct %22 |
| %24 = OpTypePointer Uniform %23 |
| %25 = OpVariable %24 Uniform |
| %26 = OpConstant %6 0 |
| %27 = OpTypePointer Uniform %13 |
| %30 = OpTypeBool |
| %35 = OpConstant %6 1 |
| %41 = OpConstant %17 3 |
| %42 = OpTypeArray %6 %41 |
| %43 = OpTypeStruct %42 |
| %44 = OpTypePointer Uniform %43 |
| %45 = OpVariable %44 Uniform |
| %46 = OpTypePointer Uniform %6 |
| %61 = OpConstant %6 2 |
| %67 = OpTypePointer Output %14 |
| %68 = OpVariable %67 Output |
| %4 = OpFunction %2 None %3 |
| %5 = OpLabel |
| %58 = OpVariable %10 Function |
| %59 = OpFunctionCall %6 %8 |
| OpStore %58 %59 |
| %60 = OpLoad %6 %58 |
| %62 = OpAccessChain %46 %45 %26 %61 |
| %63 = OpLoad %6 %62 |
| %64 = OpIEqual %30 %60 %63 |
| OpSelectionMerge %66 None |
| OpBranchConditional %64 %65 %82 |
| %65 = OpLabel |
| %69 = OpAccessChain %46 %45 %26 %26 |
| %70 = OpLoad %6 %69 |
| %71 = OpConvertSToF %13 %70 |
| %72 = OpAccessChain %46 %45 %26 %35 |
| %73 = OpLoad %6 %72 |
| %74 = OpConvertSToF %13 %73 |
| %75 = OpAccessChain %46 %45 %26 %35 |
| %76 = OpLoad %6 %75 |
| %77 = OpConvertSToF %13 %76 |
| %78 = OpAccessChain %46 %45 %26 %26 |
| %79 = OpLoad %6 %78 |
| %80 = OpConvertSToF %13 %79 |
| %81 = OpCompositeConstruct %14 %71 %74 %77 %80 |
| OpStore %68 %81 |
| OpBranch %66 |
| %82 = OpLabel |
| %83 = OpAccessChain %46 %45 %26 %35 |
| %84 = OpLoad %6 %83 |
| %85 = OpConvertSToF %13 %84 |
| %86 = OpCompositeConstruct %14 %85 %85 %85 %85 |
| OpStore %68 %86 |
| OpBranch %66 |
| %66 = OpLabel |
| OpReturn |
| OpFunctionEnd |
| %8 = OpFunction %6 None %7 |
| %9 = OpLabel |
| %11 = OpVariable %10 Function |
| %37 = OpVariable %10 Function |
| OpStore %11 %12 |
| %20 = OpAccessChain %19 %16 %18 |
| %21 = OpLoad %13 %20 |
| %28 = OpAccessChain %27 %25 %26 %26 |
| %29 = OpLoad %13 %28 |
| %31 = OpFOrdGreaterThan %30 %21 %29 |
| OpSelectionMerge %33 None |
| OpBranchConditional %31 %32 %33 |
| %32 = OpLabel |
| %34 = OpLoad %6 %11 |
| %36 = OpIAdd %6 %34 %35 |
| OpStore %11 %36 |
| OpBranch %33 |
| %33 = OpLabel |
| %38 = OpLoad %6 %11 |
| %39 = OpBitCount %6 %38 |
| OpStore %37 %39 |
| %40 = OpLoad %6 %37 |
| %47 = OpAccessChain %46 %45 %26 %26 |
| %48 = OpLoad %6 %47 |
| %49 = OpSLessThan %30 %40 %48 |
| OpSelectionMerge %51 None |
| OpBranchConditional %49 %50 %51 |
| %50 = OpLabel |
| %52 = OpAccessChain %46 %45 %26 %26 |
| %53 = OpLoad %6 %52 |
| OpReturnValue %53 |
| %51 = OpLabel |
| %55 = OpLoad %6 %37 |
| OpReturnValue %55 |
| OpFunctionEnd |
| END |
| |
| # uniforms for variant |
| |
| # _GLF_uniform_int_values |
| BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA |
| 1 0 2 |
| 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 |