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 27kernel void foo(read_only image2d_t image, sampler_t sampler, global float4* out) { 28 int gid_x = get_global_id(0); 29 int gid_y = get_global_id(1); 30 int linear = 2 * gid_y + gid_x; 31 float2 coord = (float2)(gid_x, gid_y); 32 out[linear] = read_imagef(image, sampler, coord); 33} 34END 35 36IMAGE texture DATA_TYPE vec4<float> DIM_2D WIDTH 2 HEIGHT 2 FILL 0.0 37BUFFER out_buf DATA_TYPE vec4<float> DATA 382.0 2.0 2.0 2.0 392.0 2.0 2.0 2.0 402.0 2.0 2.0 2.0 412.0 2.0 2.0 2.0 42END 43SAMPLER sampler 44 45PIPELINE compute read_pipe 46 ATTACH read_imagef ENTRY_POINT foo 47 BIND BUFFER out_buf KERNEL ARG_NAME out 48 BIND BUFFER texture KERNEL ARG_NAME image 49 BIND SAMPLER sampler KERNEL ARG_NAME sampler 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