import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
import { assert } from "../../../core/assert.js";

/**
 *
 * @returns {string}
 * @param {BinaryDataType} dt
 * @param {number} channel_count
 */
export function normalized_internal_format(dt, channel_count) {
    assert.isNonNegativeInteger(channel_count, 'channel_count');

    let suffix = '';
    switch (dt) {
        case BinaryDataType.Uint8:
            suffix = '8';
            break;
        case BinaryDataType.Int8:
            suffix = '8_SNORM';
            break;
        case BinaryDataType.Uint16:
            suffix = '16UI';
            break;
        default:
            throw new Error(`Unsupported data type '${dt}'`);
    }

    let prefix = '';

    switch (channel_count) {
        case 1:
            prefix = 'R';
            break;
        case 2:
            prefix = 'RG';
            break;
        case 3:
            prefix = 'RGB';
            break;
        case 4:
            prefix = 'RGBA';
            break;
        default:
            throw new Error(`Unsupported channel count '${channel_count}'`);
    }

    return prefix + suffix;
}
