// Copyright 2019 Tencent
// SPDX-License-Identifier: BSD-3-Clause

#version 450

layout (constant_id = 0) const float const_min = 0;
layout (constant_id = 1) const float const_max = 0;

#define shape_constant_id_offset 2
layout (constant_id = shape_constant_id_offset + 0) const uint n = 0;

layout (binding = 0) buffer bottom_top_blob { sfpvec4 bottom_top_blob_data[]; };

layout (push_constant) uniform parameter
{
    uint n;
} p;

void main()
{
    const uint gi = gl_GlobalInvocationID.x;

    if (gi >= psc(n))
    return;

    afpvec4 v = buffer_ld4(bottom_top_blob_data, gi);

    v = clamp(v, afpvec4(const_min), afpvec4(const_max));

    buffer_st4(bottom_top_blob_data, gi, v);
}
