166 lines
4.6 KiB
Plaintext
166 lines
4.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.
|
|
|
|
DEVICE_EXTENSION VK_KHR_shader_terminate_invocation
|
|
|
|
# A test for a bug found by GraphicsFuzz.
|
|
|
|
# Short description: Calls a function containing a discard
|
|
|
|
# The test passes because main always writes the color red.
|
|
|
|
# Optimized using spirv-opt with the following arguments:
|
|
# '--eliminate-dead-branches'
|
|
# '--merge-return'
|
|
# '--eliminate-dead-branches'
|
|
# '--merge-blocks'
|
|
# '--eliminate-local-single-block'
|
|
# '--eliminate-dead-branches'
|
|
# '--merge-return'
|
|
# '--ccp'
|
|
# '--scalar-replacement=100'
|
|
# '--eliminate-local-single-block'
|
|
# '--simplify-instructions'
|
|
# '--redundancy-elimination'
|
|
# '--eliminate-local-multi-store'
|
|
# '--private-to-local'
|
|
# '--if-conversion'
|
|
# '--private-to-local'
|
|
# spirv-opt commit hash: 18b3b94567a9251a6f8491a6d07c4422abadd22c
|
|
|
|
|
|
|
|
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
|
|
# {
|
|
# float one;
|
|
# };
|
|
#
|
|
# void func()
|
|
# {
|
|
# if (1.0 > one) // Always false
|
|
# {
|
|
# discard;
|
|
# }
|
|
# }
|
|
#
|
|
# void main()
|
|
# {
|
|
# _GLF_color = vec4(0);
|
|
# do
|
|
# {
|
|
# func();
|
|
# } while (false);
|
|
# _GLF_color = vec4(1, 0, 0, 1);
|
|
# }
|
|
SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
|
|
; SPIR-V
|
|
; Version: 1.0
|
|
; Generator: Khronos Glslang Reference Front End; 8
|
|
; Bound: 35
|
|
; Schema: 0
|
|
OpCapability Shader
|
|
OpExtension "SPV_KHR_terminate_invocation"
|
|
%1 = OpExtInstImport "GLSL.std.450"
|
|
OpMemoryModel Logical GLSL450
|
|
OpEntryPoint Fragment %4 "main" %25
|
|
OpExecutionMode %4 OriginUpperLeft
|
|
OpSource ESSL 310
|
|
OpName %4 "main"
|
|
OpName %6 "func("
|
|
OpName %10 "buf0"
|
|
OpMemberName %10 0 "one"
|
|
OpName %12 ""
|
|
OpName %25 "_GLF_color"
|
|
OpMemberDecorate %10 0 Offset 0
|
|
OpDecorate %10 Block
|
|
OpDecorate %12 DescriptorSet 0
|
|
OpDecorate %12 Binding 0
|
|
OpDecorate %25 Location 0
|
|
%2 = OpTypeVoid
|
|
%3 = OpTypeFunction %2
|
|
%8 = OpTypeFloat 32
|
|
%9 = OpConstant %8 1
|
|
%10 = OpTypeStruct %8
|
|
%11 = OpTypePointer Uniform %10
|
|
%12 = OpVariable %11 Uniform
|
|
%13 = OpTypeInt 32 1
|
|
%14 = OpConstant %13 0
|
|
%15 = OpTypePointer Uniform %8
|
|
%18 = OpTypeBool
|
|
%23 = OpTypeVector %8 4
|
|
%24 = OpTypePointer Output %23
|
|
%25 = OpVariable %24 Output
|
|
%26 = OpConstant %8 0
|
|
%27 = OpConstantComposite %23 %26 %26 %26 %26
|
|
%33 = OpConstantFalse %18
|
|
%34 = OpConstantComposite %23 %9 %26 %26 %9
|
|
%4 = OpFunction %2 None %3
|
|
%5 = OpLabel
|
|
OpStore %25 %27
|
|
OpBranch %28
|
|
%28 = OpLabel
|
|
%32 = OpFunctionCall %2 %6
|
|
OpLoopMerge %30 %28 None
|
|
OpBranchConditional %33 %28 %30
|
|
%30 = OpLabel
|
|
OpStore %25 %34
|
|
OpReturn
|
|
OpFunctionEnd
|
|
%6 = OpFunction %2 None %3
|
|
%7 = OpLabel
|
|
%16 = OpAccessChain %15 %12 %14
|
|
%17 = OpLoad %8 %16
|
|
%19 = OpFOrdGreaterThan %18 %9 %17
|
|
OpSelectionMerge %21 None
|
|
OpBranchConditional %19 %20 %21
|
|
%20 = OpLabel
|
|
OpTerminateInvocation
|
|
%21 = OpLabel
|
|
OpReturn
|
|
OpFunctionEnd
|
|
END
|
|
|
|
# uniforms for variant
|
|
|
|
# one
|
|
BUFFER variant_one DATA_TYPE float DATA
|
|
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_one 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
|