181 lines
5.3 KiB
Plaintext
181 lines
5.3 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 uninitialized element cast in loop
|
|
|
|
# The test passes because main always writes the color red.
|
|
|
|
# Optimized using spirv-opt with the following arguments:
|
|
# '--inline-entry-points-exhaustive'
|
|
# '--eliminate-local-single-block'
|
|
# '--ccp'
|
|
# '--eliminate-local-multi-store'
|
|
# '--inline-entry-points-exhaustive'
|
|
# '--combine-access-chains'
|
|
# '--combine-access-chains'
|
|
# '--reduce-load-size'
|
|
# '--copy-propagate-arrays'
|
|
# '--reduce-load-size'
|
|
# '--eliminate-local-multi-store'
|
|
# '--scalar-replacement=100'
|
|
# '--convert-local-access-chains'
|
|
# '--scalar-replacement=100'
|
|
# '--vector-dce'
|
|
# '--eliminate-dead-inserts'
|
|
# '--scalar-replacement=100'
|
|
# '--eliminate-dead-inserts'
|
|
# '--simplify-instructions'
|
|
# '--eliminate-dead-branches'
|
|
# '--merge-blocks'
|
|
# '--ccp'
|
|
# '--copy-propagate-arrays'
|
|
# '--combine-access-chains'
|
|
# '--eliminate-local-multi-store'
|
|
# spirv-opt commit hash: 06407250a169c6a03b3765e86619075af1a8c187
|
|
|
|
|
|
|
|
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 { vec2 injectionSwitch; };
|
|
#
|
|
# void main()
|
|
# {
|
|
# while(true)
|
|
# {
|
|
# while(false)
|
|
# break;
|
|
#
|
|
# float uninit[1];
|
|
# float(uninit[0]);
|
|
#
|
|
# if (injectionSwitch.x < injectionSwitch.y) // always true
|
|
# {
|
|
# _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
|
|
# return;
|
|
# }
|
|
# }
|
|
# }
|
|
SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
|
|
; SPIR-V
|
|
; Version: 1.0
|
|
; Generator: Khronos Glslang Reference Front End; 7
|
|
; Bound: 56
|
|
; Schema: 0
|
|
OpCapability Shader
|
|
%1 = OpExtInstImport "GLSL.std.450"
|
|
OpMemoryModel Logical GLSL450
|
|
OpEntryPoint Fragment %4 "main" %46
|
|
OpExecutionMode %4 OriginUpperLeft
|
|
OpSource ESSL 310
|
|
OpName %4 "main"
|
|
OpName %32 "buf0"
|
|
OpMemberName %32 0 "injectionSwitch"
|
|
OpName %34 ""
|
|
OpName %46 "_GLF_color"
|
|
OpMemberDecorate %32 0 Offset 0
|
|
OpDecorate %32 Block
|
|
OpDecorate %34 DescriptorSet 0
|
|
OpDecorate %34 Binding 0
|
|
OpDecorate %46 Location 0
|
|
%2 = OpTypeVoid
|
|
%3 = OpTypeFunction %2
|
|
%11 = OpTypeBool
|
|
%12 = OpConstantTrue %11
|
|
%18 = OpConstantFalse %11
|
|
%20 = OpTypeFloat 32
|
|
%21 = OpTypeInt 32 0
|
|
%22 = OpConstant %21 1
|
|
%23 = OpTypeArray %20 %22
|
|
%24 = OpTypePointer Function %23
|
|
%26 = OpTypeInt 32 1
|
|
%27 = OpConstant %26 0
|
|
%28 = OpTypePointer Function %20
|
|
%31 = OpTypeVector %20 2
|
|
%32 = OpTypeStruct %31
|
|
%33 = OpTypePointer Uniform %32
|
|
%34 = OpVariable %33 Uniform
|
|
%35 = OpConstant %21 0
|
|
%36 = OpTypePointer Uniform %20
|
|
%44 = OpTypeVector %20 4
|
|
%45 = OpTypePointer Output %44
|
|
%46 = OpVariable %45 Output
|
|
%47 = OpConstant %20 1
|
|
%48 = OpConstant %20 0
|
|
%49 = OpConstantComposite %44 %47 %48 %48 %47
|
|
%54 = OpUndef %20
|
|
%4 = OpFunction %2 None %3
|
|
%5 = OpLabel
|
|
%51 = OpVariable %28 Function
|
|
OpBranch %6
|
|
%6 = OpLabel
|
|
%53 = OpPhi %20 %54 %5 %52 %43
|
|
OpLoopMerge %8 %43 None
|
|
OpBranch %13
|
|
%13 = OpLabel
|
|
%52 = OpPhi %20 %53 %6 %54 %16
|
|
%37 = OpAccessChain %36 %34 %27 %35
|
|
%38 = OpLoad %20 %37
|
|
%39 = OpAccessChain %36 %34 %27 %22
|
|
%40 = OpLoad %20 %39
|
|
%41 = OpFOrdLessThan %11 %38 %40
|
|
OpSelectionMerge %55 None
|
|
OpBranchConditional %41 %42 %43
|
|
%16 = OpLabel
|
|
OpBranch %13
|
|
%42 = OpLabel
|
|
OpStore %46 %49
|
|
OpReturn
|
|
%55 = OpLabel
|
|
OpBranch %43
|
|
%43 = OpLabel
|
|
OpBranch %6
|
|
%8 = OpLabel
|
|
OpUnreachable
|
|
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 256 256 EQ_RGBA 255 0 0 255
|