| #!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 X86 ISel lowering and AP Float 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 _float_0_54 _GLF_uniform_float_values[0] |
| # #define _float_0_55 _GLF_uniform_float_values[1] |
| # |
| # precision highp float; |
| # precision highp int; |
| # |
| # // 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: [0.54, 0.55] |
| # layout(set = 0, binding = 1) uniform buf1 |
| # { |
| # float _GLF_uniform_float_values[2]; |
| # }; |
| # |
| # layout(location = 0) out vec4 _GLF_color; |
| # |
| # void main() |
| # { |
| # // uintbitstofloat(1) gives a very small denormalized value. The cos of this value |
| # // should be very close to 1; perhaps marginally smaller. The cosine of *that* value |
| # // should then be bounded below by 0.54, and might be slightly larger, |
| # // so that 0.55 is a suitable upper bound. |
| # vec2 v1 = cos(cos(intBitsToFloat(ivec2(-1, _int_1)))); |
| # _GLF_color = vec4(v1.x); |
| # |
| # if (v1.y > _float_0_54 && v1.y < _float_0_55) |
| # { |
| # _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; 8 |
| ; Bound: 76 |
| ; Schema: 0 |
| OpCapability Shader |
| %1 = OpExtInstImport "GLSL.std.450" |
| OpMemoryModel Logical GLSL450 |
| OpEntryPoint Fragment %4 "main" %29 |
| OpExecutionMode %4 OriginUpperLeft |
| OpSource ESSL 310 |
| OpName %4 "main" |
| OpName %9 "v1" |
| OpName %15 "buf0" |
| OpMemberName %15 0 "_GLF_uniform_int_values" |
| OpName %17 "" |
| OpName %29 "_GLF_color" |
| OpName %40 "buf1" |
| OpMemberName %40 0 "_GLF_uniform_float_values" |
| OpName %42 "" |
| OpDecorate %14 ArrayStride 16 |
| OpMemberDecorate %15 0 Offset 0 |
| OpDecorate %15 Block |
| OpDecorate %17 DescriptorSet 0 |
| OpDecorate %17 Binding 0 |
| OpDecorate %29 Location 0 |
| OpDecorate %39 ArrayStride 16 |
| OpMemberDecorate %40 0 Offset 0 |
| OpDecorate %40 Block |
| OpDecorate %42 DescriptorSet 0 |
| OpDecorate %42 Binding 1 |
| %2 = OpTypeVoid |
| %3 = OpTypeFunction %2 |
| %6 = OpTypeFloat 32 |
| %7 = OpTypeVector %6 2 |
| %8 = OpTypePointer Function %7 |
| %10 = OpTypeInt 32 1 |
| %11 = OpConstant %10 -1 |
| %12 = OpTypeInt 32 0 |
| %13 = OpConstant %12 2 |
| %14 = OpTypeArray %10 %13 |
| %15 = OpTypeStruct %14 |
| %16 = OpTypePointer Uniform %15 |
| %17 = OpVariable %16 Uniform |
| %18 = OpConstant %10 0 |
| %19 = OpTypePointer Uniform %10 |
| %22 = OpTypeVector %10 2 |
| %27 = OpTypeVector %6 4 |
| %28 = OpTypePointer Output %27 |
| %29 = OpVariable %28 Output |
| %30 = OpConstant %12 0 |
| %31 = OpTypePointer Function %6 |
| %35 = OpTypeBool |
| %36 = OpConstant %12 1 |
| %39 = OpTypeArray %6 %13 |
| %40 = OpTypeStruct %39 |
| %41 = OpTypePointer Uniform %40 |
| %42 = OpVariable %41 Uniform |
| %43 = OpTypePointer Uniform %6 |
| %51 = OpConstant %10 1 |
| %4 = OpFunction %2 None %3 |
| %5 = OpLabel |
| %9 = OpVariable %8 Function |
| %20 = OpAccessChain %19 %17 %18 %18 |
| %21 = OpLoad %10 %20 |
| %23 = OpCompositeConstruct %22 %11 %21 |
| %24 = OpBitcast %7 %23 |
| %25 = OpExtInst %7 %1 Cos %24 |
| %26 = OpExtInst %7 %1 Cos %25 |
| OpStore %9 %26 |
| %32 = OpAccessChain %31 %9 %30 |
| %33 = OpLoad %6 %32 |
| %34 = OpCompositeConstruct %27 %33 %33 %33 %33 |
| OpStore %29 %34 |
| %37 = OpAccessChain %31 %9 %36 |
| %38 = OpLoad %6 %37 |
| %44 = OpAccessChain %43 %42 %18 %18 |
| %45 = OpLoad %6 %44 |
| %46 = OpFOrdGreaterThan %35 %38 %45 |
| OpSelectionMerge %48 None |
| OpBranchConditional %46 %47 %48 |
| %47 = OpLabel |
| %49 = OpAccessChain %31 %9 %36 |
| %50 = OpLoad %6 %49 |
| %52 = OpAccessChain %43 %42 %18 %51 |
| %53 = OpLoad %6 %52 |
| %54 = OpFOrdLessThan %35 %50 %53 |
| OpBranch %48 |
| %48 = OpLabel |
| %55 = OpPhi %35 %46 %5 %54 %47 |
| OpSelectionMerge %57 None |
| OpBranchConditional %55 %56 %71 |
| %56 = OpLabel |
| %58 = OpAccessChain %19 %17 %18 %18 |
| %59 = OpLoad %10 %58 |
| %60 = OpConvertSToF %6 %59 |
| %61 = OpAccessChain %19 %17 %18 %51 |
| %62 = OpLoad %10 %61 |
| %63 = OpConvertSToF %6 %62 |
| %64 = OpAccessChain %19 %17 %18 %51 |
| %65 = OpLoad %10 %64 |
| %66 = OpConvertSToF %6 %65 |
| %67 = OpAccessChain %19 %17 %18 %18 |
| %68 = OpLoad %10 %67 |
| %69 = OpConvertSToF %6 %68 |
| %70 = OpCompositeConstruct %27 %60 %63 %66 %69 |
| OpStore %29 %70 |
| OpBranch %57 |
| %71 = OpLabel |
| %72 = OpAccessChain %19 %17 %18 %51 |
| %73 = OpLoad %10 %72 |
| %74 = OpConvertSToF %6 %73 |
| %75 = OpCompositeConstruct %27 %74 %74 %74 %74 |
| OpStore %29 %75 |
| OpBranch %57 |
| %57 = OpLabel |
| OpReturn |
| OpFunctionEnd |
| END |
| |
| # uniforms for variant |
| |
| # _GLF_uniform_float_values |
| BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA |
| 0.54 0.55 |
| 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 16 16 |
| BIND BUFFER variant_framebuffer AS color LOCATION 0 |
| 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 16 16 |
| |
| EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255 |