• 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 vs PASSTHROUGH
17
18SHADER fragment fs GLSL
19#version 430
20layout(location = 0) out vec4 color_out;
21void main() {
22  color_out = vec4(1.0, 0.0, 0.0, 1.0);
23}
24END
25
26SHADER compute read_imagef OPENCL-C
27const sampler_t sampler = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST;
28kernel void foo(read_only image2d_t image, global float4* out) {
29  int gid_x = get_global_id(0);
30  int gid_y = get_global_id(1);
31  int linear = 2 * gid_y + gid_x;
32  float2 coord = (float2)(gid_x, gid_y);
33  out[linear] = read_imagef(image, sampler, coord);
34}
35END
36
37IMAGE texture DATA_TYPE vec4<float> DIM_2D WIDTH 2 HEIGHT 2 FILL 0.0
38BUFFER out_buf DATA_TYPE vec4<float> DATA
392.0 2.0 2.0 2.0
402.0 2.0 2.0 2.0
412.0 2.0 2.0 2.0
422.0 2.0 2.0 2.0
43END
44SAMPLER sampler
45
46PIPELINE compute read_pipe
47  ATTACH read_imagef ENTRY_POINT foo
48  BIND BUFFER out_buf KERNEL ARG_NAME out
49  BIND BUFFER texture KERNEL ARG_NAME image
50END
51
52PIPELINE graphics fill_red
53  ATTACH vs
54  ATTACH fs
55  FRAMEBUFFER_SIZE 2 2
56  BIND BUFFER texture AS color LOCATION 0
57END
58
59CLEAR_COLOR fill_red 0 0 3 3
60CLEAR fill_red
61RUN fill_red DRAW_RECT POS 0 0 SIZE 2 2
62
63RUN read_pipe 2 2 1
64
65EXPECT out_buf IDX 0  EQ 1.0 0.0 0.0 1.0
66EXPECT out_buf IDX 16 EQ 1.0 0.0 0.0 1.0
67EXPECT out_buf IDX 32 EQ 1.0 0.0 0.0 1.0
68EXPECT out_buf IDX 48 EQ 1.0 0.0 0.0 1.0
69
70