import { to_half_float_uint16 } from "../../../../core/binary/to_half_float_uint16.js";
import { Sampler2D } from "./Sampler2D.js";

/**
 *
 * @param {Sampler2D} input
 * @returns {Sampler2D}
 */
export function sampler2d_to_f16(input) {

    const data = input.data;

    const dest = Sampler2D.uint16(input.itemSize, input.width, input.height);

    const n = data.length;
    for (let i = 0; i < n; i++) {
        dest.data[i] = to_half_float_uint16(data[i]);
    }

    return  dest;
}