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 13#define op(X, Y) ${OPERATOR} 14 15layout(std430) buffer; 16 17// clang-format off 18layout(set = 0, binding = 0, ${IMAGE_FORMAT[DTYPE]}) uniform PRECISION restrict writeonly image3D image_out; 19// clang-format on 20layout(set = 0, binding = 1) uniform PRECISION sampler3D image_in; 21layout(set = 0, binding = 2) uniform PRECISION sampler3D image_other; 22 23layout(set = 0, binding = 3) uniform PRECISION restrict OutExtents { 24 uvec4 data; 25} 26out_extents; 27 28layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in; 29 30void main() { 31 const ivec3 pos = ivec3(gl_GlobalInvocationID); 32 33 if (any(greaterThanEqual(pos, out_extents.data.xyz))) { 34 return; 35 } 36 37 vec4 in_texel = texelFetch(image_in, pos, 0); 38 vec4 other_texel = texelFetch(image_other, pos, 0); 39 40 imageStore(image_out, pos, op(in_texel, other_texel)); 41} 42