1#!amber 2 3# Copyright 2018 Google LLC 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17# A test for a bug found by GraphicsFuzz. 18 19# A fragment shader that uses pow. 20# Derived from the following GLSL fragment shader. 21# We check that all pixels are red. The test passes because main does 22# some computation and then writes red to _GLF_color. 23 24# #version 310 es 25# 26# precision highp float; 27# precision highp int; 28# 29# layout(location = 0) out vec4 _GLF_color; 30# 31# void main() 32# { 33# vec2 a = vec2(1.0); 34# vec4 b = vec4(1.0); 35# pow(vec4(a, vec2(1.0)), b); 36# _GLF_color = vec4(1.0, 0.0, 0.0, 1.0); 37# } 38 39SHADER vertex variant_vertex_shader PASSTHROUGH 40 41SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 42; SPIR-V 43; Version: 1.0 44; Generator: Khronos SPIR-V Tools Assembler; 0 45; Bound: 28 46; Schema: 0 47 OpCapability Shader 48 %1 = OpExtInstImport "GLSL.std.450" 49 OpMemoryModel Logical GLSL450 50 OpEntryPoint Fragment %2 "main" %3 51 OpExecutionMode %2 OriginUpperLeft 52 OpSource ESSL 310 53 OpName %2 "main" 54 OpName %4 "a" 55 OpName %5 "b" 56 OpName %3 "_GLF_color" 57 OpDecorate %3 Location 0 58 %6 = OpTypeVoid 59 %7 = OpTypeFunction %6 60 %8 = OpTypeFloat 32 61 %9 = OpTypeVector %8 2 62 %10 = OpTypePointer Function %9 63 %11 = OpConstant %8 1 64 %12 = OpConstantComposite %9 %11 %11 65 %13 = OpTypeVector %8 4 66 %14 = OpTypePointer Function %13 67 %15 = OpConstantComposite %13 %11 %11 %11 %11 68 %16 = OpTypePointer Output %13 69 %3 = OpVariable %16 Output 70 %17 = OpConstant %8 0 71 %18 = OpConstantComposite %13 %11 %17 %17 %11 72 %2 = OpFunction %6 None %7 73 %19 = OpLabel 74 %4 = OpVariable %10 Function 75 %5 = OpVariable %14 Function 76 OpStore %4 %12 77 OpStore %5 %15 78 %20 = OpLoad %9 %4 79 %21 = OpCompositeExtract %8 %20 0 80 %22 = OpCompositeExtract %8 %20 1 81 %23 = OpCompositeExtract %8 %12 0 82 %24 = OpCompositeExtract %8 %12 1 83 %25 = OpCompositeConstruct %13 %21 %22 %23 %24 84 %26 = OpLoad %13 %5 85 %27 = OpExtInst %13 %1 Pow %25 %26 86 OpStore %3 %18 87 OpReturn 88 OpFunctionEnd 89END 90 91BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 92 93PIPELINE graphics variant_pipeline 94 ATTACH variant_vertex_shader 95 ATTACH variant_fragment_shader 96 FRAMEBUFFER_SIZE 256 256 97 BIND BUFFER variant_framebuffer AS color LOCATION 0 98END 99CLEAR_COLOR variant_pipeline 0 0 0 255 100 101CLEAR variant_pipeline 102RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 103 104EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 105