blob: e2281f9a6b39d18f1259386ce7f5f203ae63abd9 [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 pow.
# 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;
#
# void main()
# {
# vec2 a = vec2(1.0);
# vec4 b = vec4(1.0);
# pow(vec4(a, vec2(1.0)), b);
# _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: 28
; 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 %a "a"
OpName %b "b"
OpName %_GLF_color "_GLF_color"
OpDecorate %_GLF_color Location 0
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v2float = OpTypeVector %float 2
%_ptr_Function_v2float = OpTypePointer Function %v2float
%float_1 = OpConstant %float 1
%11 = OpConstantComposite %v2float %float_1 %float_1
%v4float = OpTypeVector %float 4
%_ptr_Function_v4float = OpTypePointer Function %v4float
%15 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Output_v4float = OpTypePointer Output %v4float
%_GLF_color = OpVariable %_ptr_Output_v4float Output
%float_0 = OpConstant %float 0
%27 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
%main = OpFunction %void None %3
%5 = OpLabel
%a = OpVariable %_ptr_Function_v2float Function
%b = OpVariable %_ptr_Function_v4float Function
OpStore %a %11
OpStore %b %15
%16 = OpLoad %v2float %a
%17 = OpCompositeExtract %float %16 0
%18 = OpCompositeExtract %float %16 1
%19 = OpCompositeExtract %float %11 0
%20 = OpCompositeExtract %float %11 1
%21 = OpCompositeConstruct %v4float %17 %18 %19 %20
%22 = OpLoad %v4float %b
%23 = OpExtInst %v4float %1 Pow %21 %22
OpStore %_GLF_color %27
OpReturn
OpFunctionEnd
[test]
draw rect -1 -1 2 2
probe all rgba 1 0 0 1