1/* 2 * Copyright (c) Meta Platforms, Inc. and affiliates. 3 * All rights reserved. 4 * 5 * This source code is licensed under the BSD-style license found in the 6 * LICENSE file in the root directory of this source tree. 7 */ 8 9#version 450 core 10 11#define PRECISION ${PRECISION} 12#define VEC4_T ${texel_type(DTYPE)} 13 14layout(std430) buffer; 15 16${layout_declare_sampler(0, "r", "in_tex", DTYPE)} 17${layout_declare_buffer(1, "w", "out_buf", DTYPE, "PRECISION", False)} 18 19layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in; 20 21layout(constant_id = 3) const int niter = 1; 22 23void main() { 24 vec4 sum = vec4(0); 25 int i = 0; 26 for (; i < niter; ++i){ 27 $if DIM == 0: 28 sum += texelFetch(in_tex, ivec3(gl_GlobalInvocationID[0], 0, 0), 0); 29 $elif DIM == 1: 30 sum += texelFetch(in_tex, ivec3(0, gl_GlobalInvocationID[0], 0), 0); 31 $elif DIM == 2: 32 sum += texelFetch(in_tex, ivec3(0, 0, gl_GlobalInvocationID[0]), 0); 33 } 34 35 // This is to ensure no compiler optimizations occur 36 vec4 zero = vec4(i>>31); 37 38 out_buf[0] = sum + zero; 39} 40