import { copyTexture, fetchSampler } from './misc.js';

const debugFrameBuffer = {};
/**
 * Copies texture to an intermidate texture for debugging with inspector
 * @param tex - The texture to debug
 * @param label - Label for the intermidate texture
 * @internal
 */ function debugTexture(tex, label) {
    let fb = debugFrameBuffer[label];
    if (!fb || fb.getWidth() !== tex.width || fb.getHeight() !== tex.height) {
        fb?.getColorAttachments()[0]?.dispose();
        fb?.dispose();
        fb = tex.device.createFrameBuffer([
            tex.device.createTexture2D(tex.format, tex.width, tex.height, {
                mipmapping: false
            })
        ], null);
        fb.getColorAttachments()[0].name = label ?? 'Debug';
        debugFrameBuffer[label] = fb;
    }
    copyTexture(tex, fb, fetchSampler('clamp_nearest_nomip'));
}

export { debugTexture };
//# sourceMappingURL=debug.js.map
