| #!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 specific NIR code paths |
| |
| # The test passes because the shader always writes red. |
| |
| 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 |
| # #define _int_1 _GLF_uniform_int_values[0] |
| # #define _int_0 _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: [1, 0] |
| # 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; |
| # layout(set = 0, binding = 2) uniform sampler2D tex; |
| # |
| # float a = 1.0; |
| # float b = 2.0; |
| # vec4 v = vec4(1.0); |
| # |
| # // Effectively copies b = a. Sampling doesn't matter since |
| # // the same texel has been already sampled. |
| # void func() |
| # { |
| # if(b != a) |
| # { |
| # b = a; |
| # return; |
| # } |
| # v = texture(tex, vec2(0.0)); |
| # } |
| # |
| # void main() |
| # { |
| # v = texture(tex, vec2(0.0)); |
| # // b becomes 1. |
| # func(); |
| # // a becomes 2. |
| # a += v.a; |
| # // b becomes 2. |
| # func(); |
| # |
| # // Iterated once making a = 3. |
| # while((b > 1.0)) |
| # { |
| # b -= _float_1_0; |
| # a += _float_1_0; |
| # } |
| # |
| # if(a == 3.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: 100 |
| ; Schema: 0 |
| OpCapability Shader |
| %1 = OpExtInstImport "GLSL.std.450" |
| OpMemoryModel Logical GLSL450 |
| OpEntryPoint Fragment %4 "main" %74 |
| OpExecutionMode %4 OriginUpperLeft |
| OpSource ESSL 320 |
| OpName %4 "main" |
| OpName %6 "func(" |
| OpName %10 "a" |
| OpName %12 "b" |
| OpName %16 "v" |
| OpName %29 "tex" |
| OpName %54 "buf1" |
| OpMemberName %54 0 "_GLF_uniform_float_values" |
| OpName %56 "" |
| OpName %74 "_GLF_color" |
| OpName %77 "buf0" |
| OpMemberName %77 0 "_GLF_uniform_int_values" |
| OpName %79 "" |
| OpDecorate %29 RelaxedPrecision |
| OpDecorate %29 DescriptorSet 0 |
| OpDecorate %29 Binding 2 |
| OpDecorate %30 RelaxedPrecision |
| OpDecorate %34 RelaxedPrecision |
| OpDecorate %35 RelaxedPrecision |
| OpDecorate %36 RelaxedPrecision |
| OpDecorate %53 ArrayStride 16 |
| OpMemberDecorate %54 0 Offset 0 |
| OpDecorate %54 Block |
| OpDecorate %56 DescriptorSet 0 |
| OpDecorate %56 Binding 1 |
| OpDecorate %74 Location 0 |
| OpDecorate %76 ArrayStride 16 |
| OpMemberDecorate %77 0 Offset 0 |
| OpDecorate %77 Block |
| OpDecorate %79 DescriptorSet 0 |
| OpDecorate %79 Binding 0 |
| %2 = OpTypeVoid |
| %3 = OpTypeFunction %2 |
| %8 = OpTypeFloat 32 |
| %9 = OpTypePointer Private %8 |
| %10 = OpVariable %9 Private |
| %11 = OpConstant %8 1 |
| %12 = OpVariable %9 Private |
| %13 = OpConstant %8 2 |
| %14 = OpTypeVector %8 4 |
| %15 = OpTypePointer Private %14 |
| %16 = OpVariable %15 Private |
| %17 = OpConstantComposite %14 %11 %11 %11 %11 |
| %20 = OpTypeBool |
| %26 = OpTypeImage %8 2D 0 0 0 1 Unknown |
| %27 = OpTypeSampledImage %26 |
| %28 = OpTypePointer UniformConstant %27 |
| %29 = OpVariable %28 UniformConstant |
| %31 = OpTypeVector %8 2 |
| %32 = OpConstant %8 0 |
| %33 = OpConstantComposite %31 %32 %32 |
| %38 = OpTypeInt 32 0 |
| %39 = OpConstant %38 3 |
| %52 = OpConstant %38 1 |
| %53 = OpTypeArray %8 %52 |
| %54 = OpTypeStruct %53 |
| %55 = OpTypePointer Uniform %54 |
| %56 = OpVariable %55 Uniform |
| %57 = OpTypeInt 32 1 |
| %58 = OpConstant %57 0 |
| %59 = OpTypePointer Uniform %8 |
| %69 = OpConstant %8 3 |
| %73 = OpTypePointer Output %14 |
| %74 = OpVariable %73 Output |
| %75 = OpConstant %38 2 |
| %76 = OpTypeArray %57 %75 |
| %77 = OpTypeStruct %76 |
| %78 = OpTypePointer Uniform %77 |
| %79 = OpVariable %78 Uniform |
| %80 = OpTypePointer Uniform %57 |
| %84 = OpConstant %57 1 |
| %4 = OpFunction %2 None %3 |
| %5 = OpLabel |
| OpStore %10 %11 |
| OpStore %12 %13 |
| OpStore %16 %17 |
| %35 = OpLoad %27 %29 |
| %36 = OpImageSampleImplicitLod %14 %35 %33 |
| OpStore %16 %36 |
| %37 = OpFunctionCall %2 %6 |
| %40 = OpAccessChain %9 %16 %39 |
| %41 = OpLoad %8 %40 |
| %42 = OpLoad %8 %10 |
| %43 = OpFAdd %8 %42 %41 |
| OpStore %10 %43 |
| %44 = OpFunctionCall %2 %6 |
| OpBranch %45 |
| %45 = OpLabel |
| OpLoopMerge %47 %48 None |
| OpBranch %49 |
| %49 = OpLabel |
| %50 = OpLoad %8 %12 |
| %51 = OpFOrdGreaterThan %20 %50 %11 |
| OpBranchConditional %51 %46 %47 |
| %46 = OpLabel |
| %60 = OpAccessChain %59 %56 %58 %58 |
| %61 = OpLoad %8 %60 |
| %62 = OpLoad %8 %12 |
| %63 = OpFSub %8 %62 %61 |
| OpStore %12 %63 |
| %64 = OpAccessChain %59 %56 %58 %58 |
| %65 = OpLoad %8 %64 |
| %66 = OpLoad %8 %10 |
| %67 = OpFAdd %8 %66 %65 |
| OpStore %10 %67 |
| OpBranch %48 |
| %48 = OpLabel |
| OpBranch %45 |
| %47 = OpLabel |
| %68 = OpLoad %8 %10 |
| %70 = OpFOrdEqual %20 %68 %69 |
| OpSelectionMerge %72 None |
| OpBranchConditional %70 %71 %95 |
| %71 = OpLabel |
| %81 = OpAccessChain %80 %79 %58 %58 |
| %82 = OpLoad %57 %81 |
| %83 = OpConvertSToF %8 %82 |
| %85 = OpAccessChain %80 %79 %58 %84 |
| %86 = OpLoad %57 %85 |
| %87 = OpConvertSToF %8 %86 |
| %88 = OpAccessChain %80 %79 %58 %84 |
| %89 = OpLoad %57 %88 |
| %90 = OpConvertSToF %8 %89 |
| %91 = OpAccessChain %80 %79 %58 %58 |
| %92 = OpLoad %57 %91 |
| %93 = OpConvertSToF %8 %92 |
| %94 = OpCompositeConstruct %14 %83 %87 %90 %93 |
| OpStore %74 %94 |
| OpBranch %72 |
| %95 = OpLabel |
| %96 = OpAccessChain %80 %79 %58 %84 |
| %97 = OpLoad %57 %96 |
| %98 = OpConvertSToF %8 %97 |
| %99 = OpCompositeConstruct %14 %98 %98 %98 %98 |
| OpStore %74 %99 |
| OpBranch %72 |
| %72 = OpLabel |
| OpReturn |
| OpFunctionEnd |
| %6 = OpFunction %2 None %3 |
| %7 = OpLabel |
| %18 = OpLoad %8 %12 |
| %19 = OpLoad %8 %10 |
| %21 = OpFUnordNotEqual %20 %18 %19 |
| OpSelectionMerge %23 None |
| OpBranchConditional %21 %22 %23 |
| %22 = OpLabel |
| %24 = OpLoad %8 %10 |
| OpStore %12 %24 |
| OpReturn |
| %23 = OpLabel |
| %30 = OpLoad %27 %29 |
| %34 = OpImageSampleImplicitLod %14 %30 %33 |
| OpStore %16 %34 |
| OpReturn |
| OpFunctionEnd |
| END |
| |
| # uniforms for variant |
| |
| # tex |
| SAMPLER variant_tex |
| |
| # _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 |
| 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 default_texture AS combined_image_sampler SAMPLER variant_tex DESCRIPTOR_SET 0 BINDING 2 |
| 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 |