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 compute compute_shader GLSL 17#version 430 18layout(local_size_x=4,local_size_y=1) in; 19uniform layout(set=0, binding=0) samplerBuffer texelsIn; 20uniform layout(set=0, binding=1, rgba32f) imageBuffer texelsOut_0[2]; 21uniform layout(set=0, binding=2, rgba32f) imageBuffer texelsOut_1[2]; 22 23void main () 24{ 25 vec4 color = texelFetch(texelsIn, int(gl_GlobalInvocationID)); 26 imageStore(texelsOut_0[0], int(gl_GlobalInvocationID), color); 27 imageStore(texelsOut_0[1], int(gl_GlobalInvocationID), color * 2.0); 28 if (int(gl_GlobalInvocationID) < 2) { 29 imageStore(texelsOut_1[0], int(gl_GlobalInvocationID), color * 3.0); 30 } 31 else { 32 imageStore(texelsOut_1[1], int(gl_GlobalInvocationID), color * 4.0); 33 } 34} 35END 36 37BUFFER texel_buffer_in DATA_TYPE R8G8B8A8_UNORM DATA 38255 0 0 255 39 0 255 0 255 40 0 0 255 255 41 0 255 255 255 42END 43 44BUFFER texel_buffer_out0 DATA_TYPE R32G32B32A32_SFLOAT SIZE 4 FILL 0 45BUFFER texel_buffer_out1 DATA_TYPE R32G32B32A32_SFLOAT SIZE 4 FILL 0 46BUFFER texel_buffer_out2 DATA_TYPE R32G32B32A32_SFLOAT SIZE 4 FILL 0 47 48BUFFER ref0 DATA_TYPE R32G32B32A32_SFLOAT DATA 491.0 0.0 0.0 1.0 500.0 1.0 0.0 1.0 510.0 0.0 1.0 1.0 520.0 1.0 1.0 1.0 53END 54 55BUFFER ref1 DATA_TYPE R32G32B32A32_SFLOAT DATA 562.0 0.0 0.0 2.0 570.0 2.0 0.0 2.0 580.0 0.0 2.0 2.0 590.0 2.0 2.0 2.0 60END 61 62BUFFER ref2 DATA_TYPE R32G32B32A32_SFLOAT DATA 633.0 0.0 0.0 3.0 640.0 3.0 0.0 3.0 650.0 0.0 4.0 4.0 660.0 4.0 4.0 4.0 67END 68 69PIPELINE compute pipeline 70 ATTACH compute_shader 71 BIND BUFFER texel_buffer_in AS uniform_texel_buffer DESCRIPTOR_SET 0 BINDING 0 72 BIND BUFFER_ARRAY texel_buffer_out0 texel_buffer_out1 AS storage_texel_buffer DESCRIPTOR_SET 0 BINDING 1 73 BIND BUFFER_ARRAY texel_buffer_out2 texel_buffer_out2 AS storage_texel_buffer DESCRIPTOR_SET 0 BINDING 2 74END 75 76RUN pipeline 1 1 1 77 78EXPECT texel_buffer_out0 EQ_BUFFER ref0 79EXPECT texel_buffer_out1 EQ_BUFFER ref1 80EXPECT texel_buffer_out2 EQ_BUFFER ref2 81