1#!amber 2# 3# Copyright 2020 The Amber Authors. 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# https://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 17SHADER vertex vert_shader GLSL 18#version 430 19 20layout(location = 0) in vec4 position; 21layout(location = 0) out vec4 frag_color; 22 23layout(set = 0, binding = 0) readonly buffer block1 { 24 vec4 in_color; 25}; 26 27void main() { 28 gl_Position = position; 29 frag_color = in_color; 30} 31END 32 33SHADER fragment frag_shader GLSL 34#version 430 35 36layout(location = 0) in vec4 frag_color; 37layout(location = 0) out vec4 final_color; 38 39void main() { 40 final_color = frag_color; 41} 42END 43 44BUFFER data_buf1 DATA_TYPE float DATA 1.0 0.0 0.0 1.0 END 45BUFFER data_buf2 DATA_TYPE float DATA 0.0 1.0 0.0 1.0 END 46BUFFER data_buf3 DATA_TYPE float DATA 0.0 0.0 1.0 1.0 END 47BUFFER data_buf4 DATA_TYPE float DATA 1.0 0.0 1.0 1.0 END 48BUFFER data_buf5 DATA_TYPE float DATA 1.0 1.0 0.0 1.0 END 49 50BUFFER framebuffer FORMAT B8G8R8A8_UNORM 51BUFFER depthstencil FORMAT D32_SFLOAT_S8_UINT 52 53SAMPLER sampler 54 55PIPELINE graphics pipeline1 56 ATTACH vert_shader 57 ATTACH frag_shader 58 59 FRAMEBUFFER_SIZE 256 256 60 BIND BUFFER framebuffer AS color LOCATION 0 61 BIND BUFFER depthstencil AS depth_stencil 62 BIND BUFFER data_buf1 AS storage DESCRIPTOR_SET 0 BINDING 0 63 64 STENCIL front_and_back 65 TEST on 66 FAIL_OP replace 67 PASS_OP replace 68 DEPTH_FAIL_OP keep 69 COMPARE_OP always 70 COMPARE_MASK 255 71 WRITE_MASK 255 72 REFERENCE 32 73 END 74END 75 76DERIVE_PIPELINE pipeline2 FROM pipeline1 77 BIND BUFFER data_buf2 AS storage DESCRIPTOR_SET 0 BINDING 0 78 79 STENCIL front_and_back 80 TEST on 81 FAIL_OP increment_and_clamp 82 PASS_OP invert 83 DEPTH_FAIL_OP keep 84 COMPARE_OP equal 85 COMPARE_MASK 255 86 WRITE_MASK 255 87 REFERENCE 32 88 END 89END 90 91DERIVE_PIPELINE pipeline3 FROM pipeline1 92 BIND BUFFER data_buf3 AS storage DESCRIPTOR_SET 0 BINDING 0 93 94 STENCIL front_and_back 95 TEST on 96 FAIL_OP keep 97 PASS_OP keep 98 DEPTH_FAIL_OP keep 99 COMPARE_OP equal 100 COMPARE_MASK 255 101 WRITE_MASK 255 102 REFERENCE 32 103 END 104END 105 106DERIVE_PIPELINE pipeline4 FROM pipeline1 107 BIND BUFFER data_buf4 AS storage DESCRIPTOR_SET 0 BINDING 0 108 109 STENCIL front_and_back 110 TEST on 111 FAIL_OP keep 112 PASS_OP keep 113 DEPTH_FAIL_OP keep 114 COMPARE_OP equal 115 COMPARE_MASK 255 116 WRITE_MASK 255 117 REFERENCE 1 118 END 119END 120 121DERIVE_PIPELINE pipeline5 FROM pipeline1 122 BIND BUFFER data_buf5 AS storage DESCRIPTOR_SET 0 BINDING 0 123 124 STENCIL front_and_back 125 TEST on 126 FAIL_OP keep 127 PASS_OP keep 128 DEPTH_FAIL_OP keep 129 COMPARE_OP equal 130 COMPARE_MASK 255 131 WRITE_MASK 255 132 REFERENCE 223 133 END 134END 135 136CLEAR_STENCIL pipeline1 0 137CLEAR_COLOR pipeline1 255 255 255 255 138CLEAR pipeline1 139RUN pipeline1 DRAW_RECT POS 0 0 SIZE 200 200 140RUN pipeline2 DRAW_RECT POS 56 56 SIZE 200 200 141RUN pipeline3 DRAW_RECT POS 0 0 SIZE 256 256 142RUN pipeline4 DRAW_RECT POS 0 0 SIZE 256 256 143RUN pipeline5 DRAW_RECT POS 0 0 SIZE 256 256 144 145EXPECT framebuffer IDX 0 0 SIZE 1 1 EQ_RGBA 0 0 255 255 146EXPECT framebuffer IDX 128 128 SIZE 1 1 EQ_RGBA 255 255 0 255 147EXPECT framebuffer IDX 255 255 SIZE 1 1 EQ_RGBA 255 0 255 255 148EXPECT framebuffer IDX 255 0 SIZE 1 1 EQ_RGBA 255 255 255 255 149EXPECT framebuffer IDX 0 255 SIZE 1 1 EQ_RGBA 255 255 255 255 150