• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2# Copyright 2019 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_mipclear PASSTHROUGH
17
18SHADER vertex vert_shader_tex GLSL
19#version 430
20
21layout(location = 0) in vec3 position_in;
22layout(location = 0) out vec4 color_out;
23layout(set = 0, binding = 0) uniform highp sampler2D tex;
24
25void main() {
26  gl_Position = vec4(position_in, 1.0);
27  color_out = vec4(texture(tex, vec2(0.5)));
28}
29END
30
31SHADER fragment frag_shader GLSL
32#version 430
33
34layout(location = 0) in vec4 color_in;
35layout(location = 0) out vec4 color_out;
36
37void main() {
38  color_out = color_in;
39}
40END
41
42BUFFER texture FORMAT B8G8R8A8_UNORM MIP_LEVELS 2
43BUFFER framebuffer FORMAT B8G8R8A8_UNORM
44SAMPLER sampler MAX_LOD 2.0
45
46PIPELINE graphics mipclear_pipeline0
47  ATTACH vert_shader_mipclear
48  ATTACH frag_shader
49  BIND BUFFER texture AS color LOCATION 0 BASE_MIP_LEVEL 0
50  FRAMEBUFFER_SIZE 512 512
51END
52
53PIPELINE graphics mipclear_pipeline1
54  ATTACH vert_shader_mipclear
55  ATTACH frag_shader
56  BIND BUFFER texture AS color LOCATION 0 BASE_MIP_LEVEL 1
57  FRAMEBUFFER_SIZE 256 256
58END
59
60PIPELINE graphics tex_pipeline
61  ATTACH vert_shader_tex
62  ATTACH frag_shader
63  BIND BUFFER texture AS combined_image_sampler SAMPLER sampler DESCRIPTOR_SET 0 BINDING 0 BASE_MIP_LEVEL 1
64  BIND BUFFER framebuffer AS color LOCATION 0
65  FRAMEBUFFER_SIZE 512 512
66END
67
68CLEAR_COLOR mipclear_pipeline0 255 0 0 255
69CLEAR mipclear_pipeline0
70CLEAR_COLOR mipclear_pipeline1 0 255 0 255
71CLEAR mipclear_pipeline1
72
73CLEAR_COLOR tex_pipeline 0 0 0 255
74CLEAR tex_pipeline
75RUN tex_pipeline DRAW_RECT POS 0 0 SIZE 512 512
76
77# Check corners of the frame buffer: each should have a color from mip level 1
78EXPECT framebuffer IDX 0   511 SIZE 1 1 EQ_RGBA 0 255 0 255
79EXPECT framebuffer IDX 511 0   SIZE 1 1 EQ_RGBA 0 255 0 255
80EXPECT framebuffer IDX 511 511 SIZE 1 1 EQ_RGBA 0 255 0 255
81EXPECT framebuffer IDX 0   0   SIZE 1 1 EQ_RGBA 0 255 0 255
82