| #!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 SPIR-V reader 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 320 es |
| # |
| # #define _int_0 _GLF_uniform_int_values[0] |
| # #define _int_1 _GLF_uniform_int_values[1] |
| # #define _float_1_0 _GLF_uniform_float_values[0] |
| # |
| # precision highp int; |
| # precision highp float; |
| # |
| # // Contents of _GLF_uniform_int_values: [0, 1] |
| # layout(set = 0, binding = 0) uniform buf0 |
| # { |
| # int _GLF_uniform_int_values[2]; |
| # }; |
| # // Contents of _GLF_uniform_float_values: 1.0 |
| # layout(set = 0, binding = 1) uniform buf1 |
| # { |
| # float _GLF_uniform_float_values[1]; |
| # }; |
| # layout(location = 0) out vec4 _GLF_color; |
| # |
| # // Contents of m: [1.0, 5.0, 3.0, 7.0, 9.0, 6.0, 7.0, 8.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0] |
| # layout(push_constant) uniform buf_push |
| # { |
| # mat4 m; |
| # }; |
| # |
| # void main() |
| # { |
| # // Always true. |
| # if(m[_int_0][_int_0] == _float_1_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; 10 |
| ; Bound: 61 |
| ; Schema: 0 |
| OpCapability Shader |
| %1 = OpExtInstImport "GLSL.std.450" |
| OpMemoryModel Logical GLSL450 |
| OpEntryPoint Fragment %4 "main" %41 |
| OpExecutionMode %4 OriginUpperLeft |
| OpSource ESSL 320 |
| OpName %4 "main" |
| OpName %9 "buf_push" |
| OpMemberName %9 0 "m" |
| OpName %11 "" |
| OpName %17 "buf0" |
| OpMemberName %17 0 "_GLF_uniform_int_values" |
| OpName %19 "" |
| OpName %30 "buf1" |
| OpMemberName %30 0 "_GLF_uniform_float_values" |
| OpName %32 "" |
| OpName %41 "_GLF_color" |
| OpMemberDecorate %9 0 ColMajor |
| OpMemberDecorate %9 0 Offset 0 |
| OpMemberDecorate %9 0 MatrixStride 16 |
| OpDecorate %9 Block |
| OpDecorate %16 ArrayStride 16 |
| OpMemberDecorate %17 0 Offset 0 |
| OpDecorate %17 Block |
| OpDecorate %19 DescriptorSet 0 |
| OpDecorate %19 Binding 0 |
| OpDecorate %29 ArrayStride 16 |
| OpMemberDecorate %30 0 Offset 0 |
| OpDecorate %30 Block |
| OpDecorate %32 DescriptorSet 0 |
| OpDecorate %32 Binding 1 |
| OpDecorate %41 Location 0 |
| %2 = OpTypeVoid |
| %3 = OpTypeFunction %2 |
| %6 = OpTypeFloat 32 |
| %7 = OpTypeVector %6 4 |
| %8 = OpTypeMatrix %7 4 |
| %9 = OpTypeStruct %8 |
| %10 = OpTypePointer PushConstant %9 |
| %11 = OpVariable %10 PushConstant |
| %12 = OpTypeInt 32 1 |
| %13 = OpConstant %12 0 |
| %14 = OpTypeInt 32 0 |
| %15 = OpConstant %14 2 |
| %16 = OpTypeArray %12 %15 |
| %17 = OpTypeStruct %16 |
| %18 = OpTypePointer Uniform %17 |
| %19 = OpVariable %18 Uniform |
| %20 = OpTypePointer Uniform %12 |
| %25 = OpTypePointer PushConstant %6 |
| %28 = OpConstant %14 1 |
| %29 = OpTypeArray %6 %28 |
| %30 = OpTypeStruct %29 |
| %31 = OpTypePointer Uniform %30 |
| %32 = OpVariable %31 Uniform |
| %33 = OpTypePointer Uniform %6 |
| %36 = OpTypeBool |
| %40 = OpTypePointer Output %7 |
| %41 = OpVariable %40 Output |
| %42 = OpConstant %12 1 |
| %4 = OpFunction %2 None %3 |
| %5 = OpLabel |
| %21 = OpAccessChain %20 %19 %13 %13 |
| %22 = OpLoad %12 %21 |
| %23 = OpAccessChain %20 %19 %13 %13 |
| %24 = OpLoad %12 %23 |
| %26 = OpAccessChain %25 %11 %13 %22 %24 |
| %27 = OpLoad %6 %26 |
| %34 = OpAccessChain %33 %32 %13 %13 |
| %35 = OpLoad %6 %34 |
| %37 = OpFOrdEqual %36 %27 %35 |
| OpSelectionMerge %39 None |
| OpBranchConditional %37 %38 %56 |
| %38 = OpLabel |
| %43 = OpAccessChain %20 %19 %13 %42 |
| %44 = OpLoad %12 %43 |
| %45 = OpConvertSToF %6 %44 |
| %46 = OpAccessChain %20 %19 %13 %13 |
| %47 = OpLoad %12 %46 |
| %48 = OpConvertSToF %6 %47 |
| %49 = OpAccessChain %20 %19 %13 %13 |
| %50 = OpLoad %12 %49 |
| %51 = OpConvertSToF %6 %50 |
| %52 = OpAccessChain %20 %19 %13 %42 |
| %53 = OpLoad %12 %52 |
| %54 = OpConvertSToF %6 %53 |
| %55 = OpCompositeConstruct %7 %45 %48 %51 %54 |
| OpStore %41 %55 |
| OpBranch %39 |
| %56 = OpLabel |
| %57 = OpAccessChain %20 %19 %13 %13 |
| %58 = OpLoad %12 %57 |
| %59 = OpConvertSToF %6 %58 |
| %60 = OpCompositeConstruct %7 %59 %59 %59 %59 |
| OpStore %41 %60 |
| OpBranch %39 |
| %39 = OpLabel |
| OpReturn |
| OpFunctionEnd |
| END |
| |
| # uniforms for variant |
| |
| # m |
| BUFFER variant_m DATA_TYPE mat4x4<float>[] STD140 DATA |
| 1.0 5.0 3.0 7.0 9.0 6.0 7.0 8.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 |
| END |
| # _GLF_uniform_float_values |
| BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA |
| 1.0 |
| END |
| # _GLF_uniform_int_values |
| BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA |
| 0 1 |
| 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_m AS push_constant |
| BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1 |
| BIND BUFFER variant__GLF_uniform_int_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 |