# 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 do-while loop in conditional nest # The test passes because the fragment shader writes a red pixel, and the # do-while loop is not dynamically reachable # Derived from the following GLSL. # Fragment shader GLSL: # #version 310 es # # precision highp float; # # layout(location = 0) out vec4 _GLF_color; # # void main() # { # _GLF_color = vec4(1.0, 0.0, 0.0, 1.0); # if(true) # { # if(gl_FragCoord.x < 0.0) # { # do # { # _GLF_color = vec4(1.0, 0.0, 0.0, 1.0); # } # while(gl_FragCoord.x < 0.0); # } # } # } [require] fbsize 256 256 [vertex shader passthrough] [fragment shader spirv] ; SPIR-V ; Version: 1.0 ; Generator: Khronos Glslang Reference Front End; 7 ; Bound: 34 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %4 "main" %9 %18 OpExecutionMode %4 OriginUpperLeft OpSource ESSL 310 OpName %4 "main" OpName %9 "_GLF_color" OpName %18 "gl_FragCoord" OpDecorate %9 Location 0 OpDecorate %18 BuiltIn FragCoord %2 = OpTypeVoid %3 = OpTypeFunction %2 %6 = OpTypeFloat 32 %7 = OpTypeVector %6 4 %8 = OpTypePointer Output %7 %9 = OpVariable %8 Output %10 = OpConstant %6 1 %11 = OpConstant %6 0 %12 = OpConstantComposite %7 %10 %11 %11 %10 %13 = OpTypeBool %14 = OpConstantTrue %13 %17 = OpTypePointer Input %7 %18 = OpVariable %17 Input %19 = OpTypeInt 32 0 %20 = OpConstant %19 0 %21 = OpTypePointer Input %6 %4 = OpFunction %2 None %3 %5 = OpLabel OpStore %9 %12 OpSelectionMerge %16 None OpBranchConditional %14 %15 %16 %15 = OpLabel %22 = OpAccessChain %21 %18 %20 %23 = OpLoad %6 %22 %24 = OpFOrdLessThan %13 %23 %11 OpSelectionMerge %26 None OpBranchConditional %24 %25 %26 %25 = OpLabel OpBranch %27 %27 = OpLabel OpLoopMerge %29 %30 None OpBranch %28 %28 = OpLabel OpStore %9 %12 OpBranch %30 %30 = OpLabel %31 = OpAccessChain %21 %18 %20 %32 = OpLoad %6 %31 %33 = OpFOrdLessThan %13 %32 %11 OpBranchConditional %33 %27 %29 %29 = OpLabel OpBranch %26 %26 = OpLabel OpBranch %16 %16 = OpLabel OpReturn OpFunctionEnd [test] draw rect -1 -1 2 2 probe rgba (0, 0) (1, 0, 0, 1)