1#!amber 2 3# Copyright 2019 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 18# A test for a bug found by GraphicsFuzz. 19 20# Short description: Fragment shader that uses 'transpose' 21 22# The test passes because 'f' is invoked with a vector whose components are less than or equal to 1.0, so that it returns vec3(1.0, 0.0, 0.0), meaning that the output colour red is written 23 24# Optimized using spirv-opt with the following arguments: 25# '-O' 26# spirv-opt commit hash: 6b072126595dd8c2448eb1fda616251c5e6d7079 27 28 29 30SHADER vertex variant_vertex_shader PASSTHROUGH 31 32# variant_fragment_shader is derived from the following GLSL: 33# #version 310 es 34# precision highp float; 35# 36# layout(location = 0) out vec4 _GLF_color; 37# 38# vec3 f(vec2 pos) 39# { 40# if(pos.y > 1.0) 41# { 42# vec3 v; 43# return v; 44# } 45# return vec3(1.0, 0.0, 0.0); 46# } 47# void main() 48# { 49# _GLF_color = vec4(f(vec2(transpose((gl_FragCoord.y < 1.0) ? mat4x3(1.0) : transpose(mat3x4(1.0))))), 1.0); 50# } 51SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 52; SPIR-V 53; Version: 1.0 54; Generator: Khronos Glslang Reference Front End; 7 55; Bound: 99 56; Schema: 0 57 OpCapability Shader 58 %1 = OpExtInstImport "GLSL.std.450" 59 OpMemoryModel Logical GLSL450 60 OpEntryPoint Fragment %4 "main" %34 %36 61 OpExecutionMode %4 OriginUpperLeft 62 OpSource ESSL 310 63 OpName %4 "main" 64 OpName %34 "_GLF_color" 65 OpName %36 "gl_FragCoord" 66 OpDecorate %34 Location 0 67 OpDecorate %36 BuiltIn FragCoord 68 %2 = OpTypeVoid 69 %3 = OpTypeFunction %2 70 %6 = OpTypeFloat 32 71 %9 = OpTypeVector %6 3 72 %14 = OpTypeInt 32 0 73 %15 = OpConstant %14 1 74 %19 = OpConstant %6 1 75 %20 = OpTypeBool 76 %28 = OpConstant %6 0 77 %29 = OpConstantComposite %9 %19 %28 %28 78 %32 = OpTypeVector %6 4 79 %33 = OpTypePointer Output %32 80 %34 = OpVariable %33 Output 81 %35 = OpTypePointer Input %32 82 %36 = OpVariable %35 Input 83 %37 = OpTypePointer Input %6 84 %41 = OpTypeMatrix %9 4 85 %46 = OpConstantComposite %9 %28 %19 %28 86 %47 = OpConstantComposite %9 %28 %28 %19 87 %48 = OpConstantComposite %9 %28 %28 %28 88 %49 = OpConstantComposite %41 %29 %46 %47 %48 89 %51 = OpTypeMatrix %32 3 90 %52 = OpConstantComposite %32 %19 %28 %28 %28 91 %53 = OpConstantComposite %32 %28 %19 %28 %28 92 %54 = OpConstantComposite %32 %28 %28 %19 %28 93 %55 = OpConstantComposite %51 %52 %53 %54 94 %97 = OpUndef %9 95 %4 = OpFunction %2 None %3 96 %5 = OpLabel 97 %38 = OpAccessChain %37 %36 %15 98 %39 = OpLoad %6 %38 99 %40 = OpFOrdLessThan %20 %39 %19 100 OpSelectionMerge %45 None 101 OpBranchConditional %40 %44 %50 102 %44 = OpLabel 103 OpBranch %45 104 %50 = OpLabel 105 %56 = OpTranspose %41 %55 106 OpBranch %45 107 %45 = OpLabel 108 %94 = OpPhi %41 %49 %44 %56 %50 109 %58 = OpTranspose %51 %94 110 %60 = OpCompositeExtract %6 %58 0 1 111 OpBranch %82 112 %82 = OpLabel 113 OpLoopMerge %83 %84 None 114 OpBranch %85 115 %85 = OpLabel 116 %88 = OpFOrdGreaterThan %20 %60 %19 117 OpSelectionMerge %89 None 118 OpBranchConditional %88 %90 %89 119 %90 = OpLabel 120 OpBranch %83 121 %89 = OpLabel 122 OpBranch %83 123 %84 = OpLabel 124 OpBranch %82 125 %83 = OpLabel 126 %98 = OpPhi %9 %97 %90 %29 %89 127 %64 = OpCompositeExtract %6 %98 0 128 %65 = OpCompositeExtract %6 %98 1 129 %66 = OpCompositeExtract %6 %98 2 130 %67 = OpCompositeConstruct %32 %64 %65 %66 %19 131 OpStore %34 %67 132 OpReturn 133 OpFunctionEnd 134END 135 136# uniforms for variant 137 138 139BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 140 141PIPELINE graphics variant_pipeline 142 ATTACH variant_vertex_shader 143 ATTACH variant_fragment_shader 144 FRAMEBUFFER_SIZE 256 256 145 BIND BUFFER variant_framebuffer AS color LOCATION 0 146END 147CLEAR_COLOR variant_pipeline 0 0 0 255 148 149CLEAR variant_pipeline 150RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 151 152EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 153