• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2# Copyright 2020 The Amber Authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     https://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16SHADER vertex vert_shader PASSTHROUGH
17
18SHADER fragment frag_shader GLSL
19#version 430
20layout(location = 0) out vec4 color_out;
21uniform layout(set=0, binding=0) texture2D tex;
22uniform layout(set=0, binding=1) sampler tex_sampler[2];
23void main() {
24  // Sample outside texture to get border color.
25  vec4 black = texture(sampler2D(tex, tex_sampler[0]), vec2(2.0));
26  vec4 white = texture(sampler2D(tex, tex_sampler[1]), vec2(2.0));
27  color_out = vec4(white.x, black.y, white.z, black.w);
28}
29END
30
31IMAGE texture FORMAT R8G8B8A8_UNORM DIM_2D WIDTH 256 HEIGHT 256
32IMAGE framebuffer FORMAT B8G8R8A8_UNORM DIM_2D WIDTH 256 HEIGHT 256
33SAMPLER sampler0 ADDRESS_MODE_U clamp_to_border BORDER_COLOR float_opaque_black
34SAMPLER sampler1 ADDRESS_MODE_U clamp_to_border BORDER_COLOR float_opaque_white
35
36BUFFER position DATA_TYPE vec2<float> DATA
37-0.75 -0.75
38 0.75 -0.75
39 0.75  0.75
40-0.75  0.75
41END
42
43PIPELINE graphics pipeline
44  ATTACH vert_shader
45  ATTACH frag_shader
46  BIND BUFFER texture AS sampled_image DESCRIPTOR_SET 0 BINDING 0
47  BIND SAMPLER_ARRAY sampler0 sampler1 DESCRIPTOR_SET 0 BINDING 1
48  VERTEX_DATA position LOCATION 0
49  BIND BUFFER framebuffer AS color LOCATION 0
50END
51
52CLEAR_COLOR pipeline 0 0 0 255
53CLEAR pipeline
54RUN pipeline DRAW_ARRAY AS TRIANGLE_FAN START_IDX 0 COUNT 4
55
56EXPECT framebuffer IDX 1 1 SIZE 1 1 EQ_RGBA 0 0 0 255
57EXPECT framebuffer IDX 128 128 SIZE 1 1 EQ_RGBA 255 0 255 255
58