blob: 6e7ac87b4e3dda61caad5bba2e80578afda15fce [file] [log] [blame]
# 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 struct initializers.
# Derived from the following GLSL fragment shader.
# We check that all pixels are red. The test passes because main does
# some computation and then writes red to _GLF_color.
# #version 310 es
#
# precision highp float;
# precision highp int;
#
# layout(location = 0) out vec4 _GLF_color;
#
# struct S {
# bool b;
# };
#
# S foo()
# {
# if(true)
# {
# return S(true);
# }
# return S(true);
# }
# void main(void)
# {
# foo();
# _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
# }
[vertex shader passthrough]
[fragment shader spirv]
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 7
; Bound: 26
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %_GLF_color
OpExecutionMode %main OriginUpperLeft
OpSource ESSL 310
OpName %main "main"
OpName %S "S"
OpMemberName %S 0 "b"
OpName %foo_ "foo("
OpName %_GLF_color "_GLF_color"
OpDecorate %_GLF_color Location 0
%void = OpTypeVoid
%3 = OpTypeFunction %void
%bool = OpTypeBool
%S = OpTypeStruct %bool
%8 = OpTypeFunction %S
%true = OpConstantTrue %bool
%14 = OpConstantComposite %S %true
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%_GLF_color = OpVariable %_ptr_Output_v4float Output
%float_1 = OpConstant %float 1
%float_0 = OpConstant %float 0
%25 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
%main = OpFunction %void None %3
%5 = OpLabel
%18 = OpFunctionCall %S %foo_
OpStore %_GLF_color %25
OpReturn
OpFunctionEnd
%foo_ = OpFunction %S None %8
%10 = OpLabel
OpSelectionMerge %13 None
OpBranchConditional %true %12 %13
%12 = OpLabel
OpReturnValue %14
%13 = OpLabel
OpReturnValue %14
OpFunctionEnd
[test]
draw rect -1 -1 2 2
probe all rgba 1 0 0 1