import { native_ } from './Constants';
import { GPUAdapter } from './GPUAdapter';
let gpu;
export class GPU {
    constructor() {
        this._wgslLanguageFeatures = new Set();
    }
    get native() {
        if (!gpu) {
            gpu = new global.CanvasModule.GPU();
        }
        return gpu;
    }
    get wgslLanguageFeatures() {
        return this._wgslLanguageFeatures;
    }
    getPreferredCanvasFormat() {
        if (global.isIOS) {
            return 'bgra8unorm';
        }
        return 'rgba8unorm';
    }
    requestAdapter(options = { powerPreference: undefined, isFallbackAdapter: false }) {
        return new Promise((resolve, reject) => {
            this.native.requestAdapter(options, (error, adapter) => {
                if (error) {
                    reject(error);
                }
                else {
                    resolve(GPUAdapter.fromNative(adapter));
                }
            });
        });
    }
}
//# sourceMappingURL=GPU.js.map