yes
This commit is contained in:
@@ -0,0 +1,157 @@
|
||||
#!amber
|
||||
|
||||
# Copyright 2018 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 bug found by GraphicsFuzz.
|
||||
|
||||
# A fragment shader that uses vector swizzles, struct initializers, and min.
|
||||
# Derived from the following GLSL fragment shader.
|
||||
# We check that the top-left pixel is red. The test passes because the
|
||||
# first if statement checks if the x coordinate is less than 10 and if so writes
|
||||
# red to _GLF_color and then returns.
|
||||
|
||||
# #version 310 es
|
||||
#
|
||||
# precision highp float;
|
||||
# precision highp int;
|
||||
#
|
||||
# struct S {
|
||||
# vec2 s2;
|
||||
# };
|
||||
#
|
||||
# layout(location=0) out vec4 _GLF_color;
|
||||
#
|
||||
# layout(set = 0, binding = 0) uniform buf0 {
|
||||
# vec2 injectionSwitch;
|
||||
# };
|
||||
#
|
||||
# void main()
|
||||
# {
|
||||
# if (gl_FragCoord.x < 10.0) {
|
||||
# _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
# return;
|
||||
# }
|
||||
# vec4 v4 = vec4(injectionSwitch.y);
|
||||
# vec2 p = S(v4.xy).s2;
|
||||
# v4.xy = p;
|
||||
# v4.xy = (min(vec4(1.0), v4)).xy;
|
||||
# _GLF_color = vec4(v4.x, 0.0, 0.0, 1.0);
|
||||
# }
|
||||
|
||||
SHADER vertex variant_vertex_shader PASSTHROUGH
|
||||
|
||||
SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
|
||||
; SPIR-V
|
||||
; Version: 1.0
|
||||
; Generator: Khronos SPIR-V Tools Assembler; 0
|
||||
; Bound: 45
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %2 "main" %3 %4
|
||||
OpExecutionMode %2 OriginUpperLeft
|
||||
OpSource ESSL 310
|
||||
OpName %2 "main"
|
||||
OpName %3 "gl_FragCoord"
|
||||
OpName %4 "_GLF_color"
|
||||
OpName %5 "buf0"
|
||||
OpMemberName %5 0 "injectionSwitch"
|
||||
OpName %6 ""
|
||||
OpDecorate %3 BuiltIn FragCoord
|
||||
OpDecorate %4 Location 0
|
||||
OpMemberDecorate %5 0 Offset 0
|
||||
OpDecorate %5 Block
|
||||
OpDecorate %6 DescriptorSet 0
|
||||
OpDecorate %6 Binding 0
|
||||
%7 = OpTypeVoid
|
||||
%8 = OpTypeFunction %7
|
||||
%9 = OpTypeFloat 32
|
||||
%10 = OpTypeVector %9 4
|
||||
%11 = OpTypePointer Input %10
|
||||
%3 = OpVariable %11 Input
|
||||
%12 = OpTypeInt 32 0
|
||||
%13 = OpConstant %12 0
|
||||
%14 = OpTypePointer Input %9
|
||||
%15 = OpConstant %9 10
|
||||
%16 = OpTypeBool
|
||||
%17 = OpTypePointer Output %10
|
||||
%4 = OpVariable %17 Output
|
||||
%18 = OpConstant %9 1
|
||||
%19 = OpConstant %9 0
|
||||
%20 = OpConstantComposite %10 %18 %19 %19 %18
|
||||
%21 = OpTypeVector %9 2
|
||||
%5 = OpTypeStruct %21
|
||||
%22 = OpTypePointer Uniform %5
|
||||
%6 = OpVariable %22 Uniform
|
||||
%23 = OpTypeInt 32 1
|
||||
%24 = OpConstant %23 0
|
||||
%25 = OpConstant %12 1
|
||||
%26 = OpTypePointer Uniform %9
|
||||
%27 = OpConstantComposite %10 %18 %18 %18 %18
|
||||
%2 = OpFunction %7 None %8
|
||||
%28 = OpLabel
|
||||
OpBranch %29
|
||||
%29 = OpLabel
|
||||
OpLoopMerge %30 %31 None
|
||||
OpBranch %32
|
||||
%32 = OpLabel
|
||||
%33 = OpAccessChain %14 %3 %13
|
||||
%34 = OpLoad %9 %33
|
||||
%35 = OpFOrdLessThan %16 %34 %15
|
||||
OpSelectionMerge %36 None
|
||||
OpBranchConditional %35 %37 %36
|
||||
%37 = OpLabel
|
||||
OpStore %4 %20
|
||||
OpBranch %30
|
||||
%36 = OpLabel
|
||||
%38 = OpAccessChain %26 %6 %24 %25
|
||||
%39 = OpLoad %9 %38
|
||||
%40 = OpCompositeConstruct %10 %39 %39 %39 %39
|
||||
%41 = OpVectorShuffle %10 %40 %40 4 5 2 3
|
||||
%42 = OpExtInst %10 %1 FMin %27 %41
|
||||
%43 = OpCompositeExtract %9 %42 0
|
||||
%44 = OpCompositeConstruct %10 %43 %19 %19 %18
|
||||
OpStore %4 %44
|
||||
OpBranch %30
|
||||
%31 = OpLabel
|
||||
OpBranch %29
|
||||
%30 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
END
|
||||
|
||||
# uniforms for variant
|
||||
|
||||
# injectionSwitch
|
||||
BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
|
||||
0.0 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 variant_injectionSwitch 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 1 1 EQ_RGBA 255 0 0 255
|
||||
Reference in New Issue
Block a user