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$PRECISION = "highp" 12$DTYPE = "float" 13 14#define PRECISION ${PRECISION} 15 16#define VEC4_T ${buffer_gvec_type(DTYPE, 4)} 17 18#include "indexing_utils.h" 19 20layout(std430) buffer; 21 22layout(set = 0, binding = 0) buffer PRECISION restrict writeonly Buffer { 23 VEC4_T data[]; 24} 25buffer_in; 26 27layout(set = 0, binding = 1) uniform PRECISION restrict Params { 28 int len; 29} 30params; 31 32 33 34layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in; 35 36layout(constant_id = 3) const float scale = 1; 37layout(constant_id = 4) const float offset = 0; 38 39void main() { 40 const int i = ivec3(gl_GlobalInvocationID).x; 41 42 const int base = 4 * i; 43 if (base < params.len) { 44 buffer_in.data[i] = scale * (VEC4_T(base) + VEC4_T(0, 1, 2, 3)) + offset; 45 } 46} 47