import '../../../../../globals.js';
// Copyright 2024, University of Colorado Boulder
import { TwoPassInitialRenderableFaceWGSL, wgsl } from '../../../imports.js';
/**
 * ConcreteType for a TwoPassInitialRenderableFace
 *
 * TODO auto create?
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
const dwords = 3;
const TwoPassInitialRenderableFaceType = {
    name: 'TwoPassInitialRenderableFace',
    bytesPerElement: dwords * 4,
    // TODO: do we need to implement these?
    equals: () => false,
    equalsWGSL: () => wgsl `false`,
    encode(value, encoder) {
        encoder.pushU32(value.renderProgramIndex |
            (value.needsCentroid ? 0x10000000 : 0) |
            (value.needsFace ? 0x20000000 : 0) |
            (value.isConstant ? 0x40000000 : 0) |
            (value.isFullArea ? 0x80000000 : 0));
        encoder.pushU32(value.edgesIndex);
        encoder.pushU32(value.numEdges);
    },
    decode(encoder, offset) {
        const bits = encoder.fullU32Array[offset + 0];
        // TODO: factor out constants
        return {
            renderProgramIndex: bits & 0x00ffffff,
            needsCentroid: !!(bits & 0x10000000),
            needsFace: !!(bits & 0x20000000),
            isConstant: !!(bits & 0x40000000),
            isFullArea: !!(bits & 0x80000000),
            edgesIndex: encoder.fullU32Array[offset + 1],
            numEdges: encoder.fullU32Array[offset + 2]
        };
    },
    valueType: TwoPassInitialRenderableFaceWGSL,
    writeU32s(storeStatement, value) {
        return wgsl `
       ${storeStatement(wgsl `0u`, wgsl `${value}.bits`)}
       ${storeStatement(wgsl `1u`, wgsl `${value}.edges_index`)}
       ${storeStatement(wgsl `2u`, wgsl `${value}.num_edges`)}
    `;
    },
    wgslAlign: 4 * Math.ceil(dwords / 4) * 4, // possibly wrong?
    wgslSize: 4 * dwords,
    generateRandom: (fullSize = false) => {
        throw new Error('unimplemented');
    },
    toDebugString: (value) => 'TwoPassInitialRenderableFace'
};
export default TwoPassInitialRenderableFaceType;
//# sourceMappingURL=TwoPassInitialRenderableFaceType.js.map