import { native_ } from './Constants';
import { GPURenderBundle } from './GPURenderBundle';
export class GPURenderBundleEncoder {
    get label() {
        return this[native_]?.label ?? '';
    }
    draw(vertexCount, instanceCount = 1, firstVertex = 0, firstInstance = 0) {
        this[native_].draw(vertexCount, instanceCount ?? 1, firstVertex ?? 0, firstInstance ?? 0);
    }
    drawIndexed(indexCount, instanceCount = 1, firstVertex = 0, firstInstance = 0) {
        this[native_].drawIndexed(indexCount, instanceCount ?? 1, firstVertex ?? 0, firstInstance ?? 0);
    }
    drawIndexedIndirect(indirectBuffer, indirectOffset) {
        this[native_].drawIndexedIndirect(indirectBuffer[native_], indirectOffset);
    }
    drawIndirect(indirectBuffer, indirectOffset) {
        this[native_].drawIndirect(indirectBuffer[native_], indirectOffset);
    }
    finish() {
        return GPURenderBundle.fromNative(this[native_].finish());
    }
    insertDebugMarker(markerLabel) {
        this[native_].insertDebugMarker(markerLabel);
    }
    popDebugGroup() {
        this[native_].popDebugGroup();
    }
    pushDebugGroup(groupLabel) {
        this[native_].pushDebugGroup(groupLabel);
    }
    setBindGroup(index, bindGroup, dynamicOffsetsData, dynamicOffsetsDataStart, dynamicOffsetsDataLength) {
        const group = bindGroup?.[native_];
        if (!group) {
            return;
        }
        if (Array.isArray(dynamicOffsetsData)) {
            const data = new Uint32Array(dynamicOffsetsData);
            this[native_].setBindGroup(index, group, data, 0, data.length);
        }
        else if (dynamicOffsetsData instanceof Uint32Array) {
            this[native_].setBindGroup(index, group, dynamicOffsetsData, dynamicOffsetsDataStart, dynamicOffsetsDataLength);
        }
        else {
            this[native_].setBindGroup(index, group);
        }
    }
    setIndexBuffer(buffer, indexFormat, offset, size) {
        this[native_].setIndexBuffer(buffer[native_], indexFormat, offset ?? 0, size ?? buffer.size - (offset ?? 0));
    }
    setPipeline(renderPipeline) {
        this[native_].setPipeline(renderPipeline[native_]);
    }
    setVertexBuffer(slot, buffer, offset, size) {
        this[native_].setVertexBuffer(slot, buffer[native_], offset ?? 0, size ?? buffer.size - (offset ?? 0));
    }
    static fromNative(encoder) {
        if (encoder) {
            const ret = new GPURenderBundleEncoder();
            ret[native_] = encoder;
            return ret;
        }
        return null;
    }
}
//# sourceMappingURL=GPURenderBundleEncoder.js.map