static #SEND: bigint = 0xfffffff800000000n
static #RECEIVE: bigint = 0xfffffe0000000000n
+ static #isInitialized: boolean = false
static #busy: boolean = false
static #debug: boolean = false
static #raf: number = 0
/** Finalize configuration */
this.#query = this.#gl.createQuery()
this.#pixels = new Uint32Array(this.size * 4)
- console.log(`NanoPow WebGL initialized at ${this.#gl.drawingBufferWidth}x${this.#gl.drawingBufferHeight}. Maximum nonces checked per frame: ${this.size}`)
} catch (err) {
throw new Error('WebGL initialization failed.', { cause: err })
} finally {
this.#busy = false
}
+ this.#isInitialized = true
+ console.log(`NanoPow WebGL initialized at ${this.#gl.drawingBufferWidth}x${this.#gl.drawingBufferHeight}. Maximum nonces checked per frame: ${this.size}`)
}
/**
}, 100)
})
}
+ if (this.#isInitialized === false) this.init()
this.#busy = true
if (typeof options?.threshold === 'string') {
}, 100)
})
}
+ if (this.#isInitialized === false) this.init()
this.#busy = true
if (typeof options?.threshold === 'string') {
static #RECEIVE: bigint = 0xfffffe0000000000n
// Initialize WebGPU
+ static #isInitialized: boolean = false
static #busy: boolean = false
static #debug: boolean = false
static #device: GPUDevice | null = null
} finally {
this.#busy = false
}
+ this.#isInitialized = true
}
static setup (): void {
}, 100)
})
}
+ if (this.#isInitialized === false) this.init()
this.#busy = true
if (typeof options?.threshold === 'string') {
}, 100)
})
}
+ if (this.#isInitialized === false) this.init()
this.#busy = true
if (typeof options?.threshold === 'string') {
let isGlSupported, isGpuSupported = false
try {
- await NanoPowGpu.init()
- isGpuSupported = true
+ const adapter = await navigator?.gpu?.requestAdapter?.()
+ isGpuSupported = (adapter instanceof GPUAdapter)
} catch (err) {
console.warn('WebGPU is not supported in this environment.\n', err)
isGpuSupported = false
}
try {
- await NanoPowGl.init()
- isGlSupported = true
+ const gl = new OffscreenCanvas(0, 0)?.getContext?.('webgl2')
+ isGlSupported = (gl instanceof WebGL2RenderingContext)
} catch (err) {
console.warn('WebGL is not supported in this environment.\n', err)
isGlSupported = false