yes
This commit is contained in:
@@ -0,0 +1,228 @@
|
||||
#!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 NIR 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_0_4 _GLF_uniform_float_values[0]
|
||||
# #define _float_1_0 _GLF_uniform_float_values[1]
|
||||
# #define _float_256_0 _GLF_uniform_float_values[2]
|
||||
#
|
||||
# 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: [0.4, 1.0, 256.0]
|
||||
# layout(set = 0, binding = 1) uniform buf1
|
||||
# {
|
||||
# float _GLF_uniform_float_values[3];
|
||||
# };
|
||||
# layout(location = 0) out vec4 _GLF_color;
|
||||
#
|
||||
# void main()
|
||||
# {
|
||||
# // Always false.
|
||||
# if(gl_FragCoord.y < _float_0_4)
|
||||
# {
|
||||
# _GLF_color = vec4(_int_0);
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# // gl_FragCoord has the decimal part of 0.5. If we name the integer part
|
||||
# // of gl_FragCoord (X, Y) it can be expressed as (X + 0.5, Y + 0.5).
|
||||
# //
|
||||
# // The value of v is calculated as follows:
|
||||
# // v = ((X + 0.5, Y + 0.5) - (1.0, 0.4)) * 256
|
||||
# // = (X - 1 + 0.5, Y + 0.5 - 0.4) * 256
|
||||
# // = (X - 0.5, Y + 0.1) * 256
|
||||
# // = (X * 256 - 128, Y * 256 + 25.6)
|
||||
# //
|
||||
# // X * 256 is always an even number, and substracting 128 still keeps it even.
|
||||
# // Y * 256 is always and even number, but adding 25.6 (and converting to an integer)
|
||||
# // makes it always odd.
|
||||
# ivec2 v = ivec2((gl_FragCoord.xy - vec2(_float_1_0, _float_0_4)) * _float_256_0);
|
||||
#
|
||||
# // v.x is even and v.y is odd. We substract one from v.y making it even too.
|
||||
# // Doing a bitwise AND with an even number always resuls in zero.
|
||||
# _GLF_color = vec4(_float_1_0, (v.y - _int_1) & _int_1, v.x & _int_1, _float_1_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: 82
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %4 "main" %9 %30
|
||||
OpExecutionMode %4 OriginUpperLeft
|
||||
OpSource ESSL 320
|
||||
OpName %4 "main"
|
||||
OpName %9 "gl_FragCoord"
|
||||
OpName %17 "buf1"
|
||||
OpMemberName %17 0 "_GLF_uniform_float_values"
|
||||
OpName %19 ""
|
||||
OpName %30 "_GLF_color"
|
||||
OpName %33 "buf0"
|
||||
OpMemberName %33 0 "_GLF_uniform_int_values"
|
||||
OpName %35 ""
|
||||
OpName %44 "v"
|
||||
OpDecorate %9 BuiltIn FragCoord
|
||||
OpDecorate %16 ArrayStride 16
|
||||
OpMemberDecorate %17 0 Offset 0
|
||||
OpDecorate %17 Block
|
||||
OpDecorate %19 DescriptorSet 0
|
||||
OpDecorate %19 Binding 1
|
||||
OpDecorate %30 Location 0
|
||||
OpDecorate %32 ArrayStride 16
|
||||
OpMemberDecorate %33 0 Offset 0
|
||||
OpDecorate %33 Block
|
||||
OpDecorate %35 DescriptorSet 0
|
||||
OpDecorate %35 Binding 0
|
||||
%2 = OpTypeVoid
|
||||
%3 = OpTypeFunction %2
|
||||
%6 = OpTypeFloat 32
|
||||
%7 = OpTypeVector %6 4
|
||||
%8 = OpTypePointer Input %7
|
||||
%9 = OpVariable %8 Input
|
||||
%10 = OpTypeInt 32 0
|
||||
%11 = OpConstant %10 1
|
||||
%12 = OpTypePointer Input %6
|
||||
%15 = OpConstant %10 3
|
||||
%16 = OpTypeArray %6 %15
|
||||
%17 = OpTypeStruct %16
|
||||
%18 = OpTypePointer Uniform %17
|
||||
%19 = OpVariable %18 Uniform
|
||||
%20 = OpTypeInt 32 1
|
||||
%21 = OpConstant %20 0
|
||||
%22 = OpTypePointer Uniform %6
|
||||
%25 = OpTypeBool
|
||||
%29 = OpTypePointer Output %7
|
||||
%30 = OpVariable %29 Output
|
||||
%31 = OpConstant %10 2
|
||||
%32 = OpTypeArray %20 %31
|
||||
%33 = OpTypeStruct %32
|
||||
%34 = OpTypePointer Uniform %33
|
||||
%35 = OpVariable %34 Uniform
|
||||
%36 = OpTypePointer Uniform %20
|
||||
%42 = OpTypeVector %20 2
|
||||
%43 = OpTypePointer Function %42
|
||||
%45 = OpTypeVector %6 2
|
||||
%48 = OpConstant %20 1
|
||||
%55 = OpConstant %20 2
|
||||
%62 = OpTypePointer Function %20
|
||||
%72 = OpConstant %10 0
|
||||
%4 = OpFunction %2 None %3
|
||||
%5 = OpLabel
|
||||
%44 = OpVariable %43 Function
|
||||
%13 = OpAccessChain %12 %9 %11
|
||||
%14 = OpLoad %6 %13
|
||||
%23 = OpAccessChain %22 %19 %21 %21
|
||||
%24 = OpLoad %6 %23
|
||||
%26 = OpFOrdLessThan %25 %14 %24
|
||||
OpSelectionMerge %28 None
|
||||
OpBranchConditional %26 %27 %41
|
||||
%27 = OpLabel
|
||||
%37 = OpAccessChain %36 %35 %21 %21
|
||||
%38 = OpLoad %20 %37
|
||||
%39 = OpConvertSToF %6 %38
|
||||
%40 = OpCompositeConstruct %7 %39 %39 %39 %39
|
||||
OpStore %30 %40
|
||||
OpBranch %28
|
||||
%41 = OpLabel
|
||||
%46 = OpLoad %7 %9
|
||||
%47 = OpVectorShuffle %45 %46 %46 0 1
|
||||
%49 = OpAccessChain %22 %19 %21 %48
|
||||
%50 = OpLoad %6 %49
|
||||
%51 = OpAccessChain %22 %19 %21 %21
|
||||
%52 = OpLoad %6 %51
|
||||
%53 = OpCompositeConstruct %45 %50 %52
|
||||
%54 = OpFSub %45 %47 %53
|
||||
%56 = OpAccessChain %22 %19 %21 %55
|
||||
%57 = OpLoad %6 %56
|
||||
%58 = OpVectorTimesScalar %45 %54 %57
|
||||
%59 = OpConvertFToS %42 %58
|
||||
OpStore %44 %59
|
||||
%60 = OpAccessChain %22 %19 %21 %48
|
||||
%61 = OpLoad %6 %60
|
||||
%63 = OpAccessChain %62 %44 %11
|
||||
%64 = OpLoad %20 %63
|
||||
%65 = OpAccessChain %36 %35 %21 %48
|
||||
%66 = OpLoad %20 %65
|
||||
%67 = OpISub %20 %64 %66
|
||||
%68 = OpAccessChain %36 %35 %21 %48
|
||||
%69 = OpLoad %20 %68
|
||||
%70 = OpBitwiseAnd %20 %67 %69
|
||||
%71 = OpConvertSToF %6 %70
|
||||
%73 = OpAccessChain %62 %44 %72
|
||||
%74 = OpLoad %20 %73
|
||||
%75 = OpAccessChain %36 %35 %21 %48
|
||||
%76 = OpLoad %20 %75
|
||||
%77 = OpBitwiseAnd %20 %74 %76
|
||||
%78 = OpConvertSToF %6 %77
|
||||
%79 = OpAccessChain %22 %19 %21 %48
|
||||
%80 = OpLoad %6 %79
|
||||
%81 = OpCompositeConstruct %7 %61 %71 %78 %80
|
||||
OpStore %30 %81
|
||||
OpBranch %28
|
||||
%28 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
END
|
||||
|
||||
# uniforms for variant
|
||||
|
||||
# _GLF_uniform_float_values
|
||||
BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
|
||||
0.4 1.0 256.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__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
|
||||
Reference in New Issue
Block a user