| #!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 machine basic block 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_5 _GLF_uniform_int_values[1] |
| # #define _int_4 _GLF_uniform_int_values[2] |
| # #define _int_3 _GLF_uniform_int_values[3] |
| # #define _int_2 _GLF_uniform_int_values[4] |
| # #define _int_0 _GLF_uniform_int_values[5] |
| # #define _float_0_0 _GLF_uniform_float_values[0] |
| # |
| # precision highp int; |
| # precision highp float; |
| # |
| # // 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, 5, 4, 3, 2, 0] |
| # layout(set = 0, binding = 1) uniform buf1 |
| # { |
| # int _GLF_uniform_int_values[6]; |
| # }; |
| # layout(location = 0) out vec4 _GLF_color; |
| # |
| # void main() |
| # { |
| # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1); |
| # |
| # int data[5] = int[5](_int_5, _int_4, _int_3, _int_2, _int_1); |
| # |
| # for (int a = _int_0; a < _int_1; a++) |
| # { |
| # for (int i = _int_0; i < _int_5; i++) |
| # { |
| # for (int j = i; j < _int_5; j++) |
| # { |
| # if (data[i] < data[j]) |
| # { |
| # _GLF_color = vec4(_int_0); |
| # } |
| # } |
| # } |
| # } |
| # |
| # // Always false. |
| # while (gl_FragCoord.x < _float_0_0) |
| # { |
| # for (int i = _int_0; i < _int_1; i++) |
| # { |
| # _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: 146 |
| ; Schema: 0 |
| OpCapability Shader |
| %1 = OpExtInstImport "GLSL.std.450" |
| OpMemoryModel Logical GLSL450 |
| OpEntryPoint Fragment %4 "main" %9 %114 |
| OpExecutionMode %4 OriginUpperLeft |
| OpSource ESSL 310 |
| OpName %4 "main" |
| OpName %9 "_GLF_color" |
| OpName %14 "buf1" |
| OpMemberName %14 0 "_GLF_uniform_int_values" |
| OpName %16 "" |
| OpName %36 "data" |
| OpName %53 "a" |
| OpName %66 "i" |
| OpName %78 "j" |
| OpName %114 "gl_FragCoord" |
| OpName %121 "buf0" |
| OpMemberName %121 0 "_GLF_uniform_float_values" |
| OpName %123 "" |
| OpName %128 "i" |
| OpDecorate %9 Location 0 |
| OpDecorate %13 ArrayStride 16 |
| OpMemberDecorate %14 0 Offset 0 |
| OpDecorate %14 Block |
| OpDecorate %16 DescriptorSet 0 |
| OpDecorate %16 Binding 1 |
| OpDecorate %114 BuiltIn FragCoord |
| OpDecorate %120 ArrayStride 16 |
| OpMemberDecorate %121 0 Offset 0 |
| OpDecorate %121 Block |
| OpDecorate %123 DescriptorSet 0 |
| OpDecorate %123 Binding 0 |
| %2 = OpTypeVoid |
| %3 = OpTypeFunction %2 |
| %6 = OpTypeFloat 32 |
| %7 = OpTypeVector %6 4 |
| %8 = OpTypePointer Output %7 |
| %9 = OpVariable %8 Output |
| %10 = OpTypeInt 32 1 |
| %11 = OpTypeInt 32 0 |
| %12 = OpConstant %11 6 |
| %13 = OpTypeArray %10 %12 |
| %14 = OpTypeStruct %13 |
| %15 = OpTypePointer Uniform %14 |
| %16 = OpVariable %15 Uniform |
| %17 = OpConstant %10 0 |
| %18 = OpTypePointer Uniform %10 |
| %22 = OpConstant %10 5 |
| %33 = OpConstant %11 5 |
| %34 = OpTypeArray %10 %33 |
| %35 = OpTypePointer Function %34 |
| %37 = OpConstant %10 1 |
| %40 = OpConstant %10 2 |
| %43 = OpConstant %10 3 |
| %46 = OpConstant %10 4 |
| %52 = OpTypePointer Function %10 |
| %64 = OpTypeBool |
| %113 = OpTypePointer Input %7 |
| %114 = OpVariable %113 Input |
| %115 = OpConstant %11 0 |
| %116 = OpTypePointer Input %6 |
| %119 = OpConstant %11 1 |
| %120 = OpTypeArray %6 %119 |
| %121 = OpTypeStruct %120 |
| %122 = OpTypePointer Uniform %121 |
| %123 = OpVariable %122 Uniform |
| %124 = OpTypePointer Uniform %6 |
| %4 = OpFunction %2 None %3 |
| %5 = OpLabel |
| %36 = OpVariable %35 Function |
| %53 = OpVariable %52 Function |
| %66 = OpVariable %52 Function |
| %78 = OpVariable %52 Function |
| %128 = OpVariable %52 Function |
| %19 = OpAccessChain %18 %16 %17 %17 |
| %20 = OpLoad %10 %19 |
| %21 = OpConvertSToF %6 %20 |
| %23 = OpAccessChain %18 %16 %17 %22 |
| %24 = OpLoad %10 %23 |
| %25 = OpConvertSToF %6 %24 |
| %26 = OpAccessChain %18 %16 %17 %22 |
| %27 = OpLoad %10 %26 |
| %28 = OpConvertSToF %6 %27 |
| %29 = OpAccessChain %18 %16 %17 %17 |
| %30 = OpLoad %10 %29 |
| %31 = OpConvertSToF %6 %30 |
| %32 = OpCompositeConstruct %7 %21 %25 %28 %31 |
| OpStore %9 %32 |
| %38 = OpAccessChain %18 %16 %17 %37 |
| %39 = OpLoad %10 %38 |
| %41 = OpAccessChain %18 %16 %17 %40 |
| %42 = OpLoad %10 %41 |
| %44 = OpAccessChain %18 %16 %17 %43 |
| %45 = OpLoad %10 %44 |
| %47 = OpAccessChain %18 %16 %17 %46 |
| %48 = OpLoad %10 %47 |
| %49 = OpAccessChain %18 %16 %17 %17 |
| %50 = OpLoad %10 %49 |
| %51 = OpCompositeConstruct %34 %39 %42 %45 %48 %50 |
| OpStore %36 %51 |
| %54 = OpAccessChain %18 %16 %17 %22 |
| %55 = OpLoad %10 %54 |
| OpStore %53 %55 |
| OpBranch %56 |
| %56 = OpLabel |
| OpLoopMerge %58 %59 None |
| OpBranch %60 |
| %60 = OpLabel |
| %61 = OpLoad %10 %53 |
| %62 = OpAccessChain %18 %16 %17 %17 |
| %63 = OpLoad %10 %62 |
| %65 = OpSLessThan %64 %61 %63 |
| OpBranchConditional %65 %57 %58 |
| %57 = OpLabel |
| %67 = OpAccessChain %18 %16 %17 %22 |
| %68 = OpLoad %10 %67 |
| OpStore %66 %68 |
| OpBranch %69 |
| %69 = OpLabel |
| OpLoopMerge %71 %72 None |
| OpBranch %73 |
| %73 = OpLabel |
| %74 = OpLoad %10 %66 |
| %75 = OpAccessChain %18 %16 %17 %37 |
| %76 = OpLoad %10 %75 |
| %77 = OpSLessThan %64 %74 %76 |
| OpBranchConditional %77 %70 %71 |
| %70 = OpLabel |
| %79 = OpLoad %10 %66 |
| OpStore %78 %79 |
| OpBranch %80 |
| %80 = OpLabel |
| OpLoopMerge %82 %83 None |
| OpBranch %84 |
| %84 = OpLabel |
| %85 = OpLoad %10 %78 |
| %86 = OpAccessChain %18 %16 %17 %37 |
| %87 = OpLoad %10 %86 |
| %88 = OpSLessThan %64 %85 %87 |
| OpBranchConditional %88 %81 %82 |
| %81 = OpLabel |
| %89 = OpLoad %10 %66 |
| %90 = OpAccessChain %52 %36 %89 |
| %91 = OpLoad %10 %90 |
| %92 = OpLoad %10 %78 |
| %93 = OpAccessChain %52 %36 %92 |
| %94 = OpLoad %10 %93 |
| %95 = OpSLessThan %64 %91 %94 |
| OpSelectionMerge %97 None |
| OpBranchConditional %95 %96 %97 |
| %96 = OpLabel |
| %98 = OpAccessChain %18 %16 %17 %22 |
| %99 = OpLoad %10 %98 |
| %100 = OpConvertSToF %6 %99 |
| %101 = OpCompositeConstruct %7 %100 %100 %100 %100 |
| OpStore %9 %101 |
| OpBranch %97 |
| %97 = OpLabel |
| OpBranch %83 |
| %83 = OpLabel |
| %102 = OpLoad %10 %78 |
| %103 = OpIAdd %10 %102 %37 |
| OpStore %78 %103 |
| OpBranch %80 |
| %82 = OpLabel |
| OpBranch %72 |
| %72 = OpLabel |
| %104 = OpLoad %10 %66 |
| %105 = OpIAdd %10 %104 %37 |
| OpStore %66 %105 |
| OpBranch %69 |
| %71 = OpLabel |
| OpBranch %59 |
| %59 = OpLabel |
| %106 = OpLoad %10 %53 |
| %107 = OpIAdd %10 %106 %37 |
| OpStore %53 %107 |
| OpBranch %56 |
| %58 = OpLabel |
| OpBranch %108 |
| %108 = OpLabel |
| OpLoopMerge %110 %111 None |
| OpBranch %112 |
| %112 = OpLabel |
| %117 = OpAccessChain %116 %114 %115 |
| %118 = OpLoad %6 %117 |
| %125 = OpAccessChain %124 %123 %17 %17 |
| %126 = OpLoad %6 %125 |
| %127 = OpFOrdLessThan %64 %118 %126 |
| OpBranchConditional %127 %109 %110 |
| %109 = OpLabel |
| %129 = OpAccessChain %18 %16 %17 %22 |
| %130 = OpLoad %10 %129 |
| OpStore %128 %130 |
| OpBranch %131 |
| %131 = OpLabel |
| OpLoopMerge %133 %134 None |
| OpBranch %135 |
| %135 = OpLabel |
| %136 = OpLoad %10 %128 |
| %137 = OpAccessChain %18 %16 %17 %17 |
| %138 = OpLoad %10 %137 |
| %139 = OpSLessThan %64 %136 %138 |
| OpBranchConditional %139 %132 %133 |
| %132 = OpLabel |
| %140 = OpAccessChain %18 %16 %17 %22 |
| %141 = OpLoad %10 %140 |
| %142 = OpConvertSToF %6 %141 |
| %143 = OpCompositeConstruct %7 %142 %142 %142 %142 |
| OpStore %9 %143 |
| OpBranch %134 |
| %134 = OpLabel |
| %144 = OpLoad %10 %128 |
| %145 = OpIAdd %10 %144 %37 |
| OpStore %128 %145 |
| OpBranch %131 |
| %133 = OpLabel |
| OpBranch %111 |
| %111 = OpLabel |
| OpBranch %108 |
| %110 = OpLabel |
| OpReturn |
| OpFunctionEnd |
| END |
| |
| # uniforms for variant |
| |
| # _GLF_uniform_int_values |
| BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA |
| 1 5 4 3 2 0 |
| 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 16 16 |
| 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 16 16 |
| |
| EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255 |