213 lines
6.6 KiB
Plaintext
213 lines
6.6 KiB
Plaintext
#!amber
|
|
|
|
# Copyright 2019 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.
|
|
|
|
# Short description: A fragment shader with two loops and some matrices
|
|
|
|
# The test passes because the fragment shader always writes red; the loops do nothing.
|
|
# The second loop condition is always false.
|
|
|
|
SHADER vertex variant_vertex_shader PASSTHROUGH
|
|
|
|
# variant_fragment_shader is derived from the following GLSL:
|
|
# #version 310 es
|
|
# precision highp float;
|
|
#
|
|
# layout(location = 0) out vec4 _GLF_color;
|
|
#
|
|
# layout(set = 0, binding = 0) uniform buf0
|
|
# {
|
|
# mat4 matrix_a_uni;
|
|
# };
|
|
# void main()
|
|
# {
|
|
# vec4 matrix_b;
|
|
# vec4 matrix_u;
|
|
# for (
|
|
# int x = 4;
|
|
# x >= 1;
|
|
# x--)
|
|
# {
|
|
# matrix_u[x] = 1.0;
|
|
# }
|
|
# for (
|
|
# int b = 4;
|
|
# matrix_a_uni[0][0] < -1.0;
|
|
# b--)
|
|
# {
|
|
# matrix_b[b] = (b > 1 ? min(matrix_b, matrix_b) : matrix_u)[1];
|
|
# }
|
|
# _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
|
|
# }
|
|
SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
|
|
; SPIR-V
|
|
; Version: 1.0
|
|
; Generator: Khronos Glslang Reference Front End; 7
|
|
; Bound: 69
|
|
; Schema: 0
|
|
OpCapability Shader
|
|
%1 = OpExtInstImport "GLSL.std.450"
|
|
OpMemoryModel Logical GLSL450
|
|
OpEntryPoint Fragment %4 "main" %66
|
|
OpExecutionMode %4 OriginUpperLeft
|
|
OpSource ESSL 310
|
|
OpName %4 "main"
|
|
OpName %8 "x"
|
|
OpName %22 "matrix_u"
|
|
OpName %29 "b"
|
|
OpName %36 "buf0"
|
|
OpMemberName %36 0 "matrix_a_uni"
|
|
OpName %38 ""
|
|
OpName %47 "matrix_b"
|
|
OpName %66 "_GLF_color"
|
|
OpDecorate %8 RelaxedPrecision
|
|
OpDecorate %15 RelaxedPrecision
|
|
OpDecorate %23 RelaxedPrecision
|
|
OpDecorate %27 RelaxedPrecision
|
|
OpDecorate %28 RelaxedPrecision
|
|
OpDecorate %29 RelaxedPrecision
|
|
OpMemberDecorate %36 0 ColMajor
|
|
OpMemberDecorate %36 0 Offset 0
|
|
OpMemberDecorate %36 0 MatrixStride 16
|
|
OpDecorate %36 Block
|
|
OpDecorate %38 DescriptorSet 0
|
|
OpDecorate %38 Binding 0
|
|
OpDecorate %48 RelaxedPrecision
|
|
OpDecorate %49 RelaxedPrecision
|
|
OpDecorate %63 RelaxedPrecision
|
|
OpDecorate %64 RelaxedPrecision
|
|
OpDecorate %66 Location 0
|
|
%2 = OpTypeVoid
|
|
%3 = OpTypeFunction %2
|
|
%6 = OpTypeInt 32 1
|
|
%7 = OpTypePointer Function %6
|
|
%9 = OpConstant %6 4
|
|
%16 = OpConstant %6 1
|
|
%17 = OpTypeBool
|
|
%19 = OpTypeFloat 32
|
|
%20 = OpTypeVector %19 4
|
|
%21 = OpTypePointer Function %20
|
|
%24 = OpConstant %19 1
|
|
%25 = OpTypePointer Function %19
|
|
%35 = OpTypeMatrix %20 4
|
|
%36 = OpTypeStruct %35
|
|
%37 = OpTypePointer Uniform %36
|
|
%38 = OpVariable %37 Uniform
|
|
%39 = OpConstant %6 0
|
|
%40 = OpTypeInt 32 0
|
|
%41 = OpConstant %40 0
|
|
%42 = OpTypePointer Uniform %19
|
|
%45 = OpConstant %19 -1
|
|
%59 = OpConstant %40 1
|
|
%65 = OpTypePointer Output %20
|
|
%66 = OpVariable %65 Output
|
|
%67 = OpConstant %19 0
|
|
%68 = OpConstantComposite %20 %24 %67 %67 %24
|
|
%4 = OpFunction %2 None %3
|
|
%5 = OpLabel
|
|
%8 = OpVariable %7 Function
|
|
%22 = OpVariable %21 Function
|
|
%29 = OpVariable %7 Function
|
|
%47 = OpVariable %21 Function
|
|
%51 = OpVariable %21 Function
|
|
OpStore %8 %9
|
|
OpBranch %10
|
|
%10 = OpLabel
|
|
OpLoopMerge %12 %13 None
|
|
OpBranch %14
|
|
%14 = OpLabel
|
|
%15 = OpLoad %6 %8
|
|
%18 = OpSGreaterThanEqual %17 %15 %16
|
|
OpBranchConditional %18 %11 %12
|
|
%11 = OpLabel
|
|
%23 = OpLoad %6 %8
|
|
%26 = OpAccessChain %25 %22 %23
|
|
OpStore %26 %24
|
|
OpBranch %13
|
|
%13 = OpLabel
|
|
%27 = OpLoad %6 %8
|
|
%28 = OpISub %6 %27 %16
|
|
OpStore %8 %28
|
|
OpBranch %10
|
|
%12 = OpLabel
|
|
OpStore %29 %9
|
|
OpBranch %30
|
|
%30 = OpLabel
|
|
OpLoopMerge %32 %33 None
|
|
OpBranch %34
|
|
%34 = OpLabel
|
|
%43 = OpAccessChain %42 %38 %39 %39 %41
|
|
%44 = OpLoad %19 %43
|
|
%46 = OpFOrdLessThan %17 %44 %45
|
|
OpBranchConditional %46 %31 %32
|
|
%31 = OpLabel
|
|
%48 = OpLoad %6 %29
|
|
%49 = OpLoad %6 %29
|
|
%50 = OpSGreaterThan %17 %49 %16
|
|
OpSelectionMerge %53 None
|
|
OpBranchConditional %50 %52 %57
|
|
%52 = OpLabel
|
|
%54 = OpLoad %20 %47
|
|
%55 = OpLoad %20 %47
|
|
%56 = OpExtInst %20 %1 FMin %54 %55
|
|
OpStore %51 %56
|
|
OpBranch %53
|
|
%57 = OpLabel
|
|
%58 = OpLoad %20 %22
|
|
OpStore %51 %58
|
|
OpBranch %53
|
|
%53 = OpLabel
|
|
%60 = OpAccessChain %25 %51 %59
|
|
%61 = OpLoad %19 %60
|
|
%62 = OpAccessChain %25 %47 %48
|
|
OpStore %62 %61
|
|
OpBranch %33
|
|
%33 = OpLabel
|
|
%63 = OpLoad %6 %29
|
|
%64 = OpISub %6 %63 %16
|
|
OpStore %29 %64
|
|
OpBranch %30
|
|
%32 = OpLabel
|
|
OpStore %66 %68
|
|
OpReturn
|
|
OpFunctionEnd
|
|
END
|
|
|
|
# uniforms for variant
|
|
|
|
# matrix_a_uni
|
|
BUFFER variant_matrix_a_uni DATA_TYPE mat4x4<float> 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
|
|
|
|
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_matrix_a_uni 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
|