});
// src/lib/nano-pow/classes/gl.ts
-var NanoPowGl, gl_default;
+var NanoPowGl;
var init_gl = __esm({
"src/lib/nano-pow/classes/gl.ts"() {
"use strict";
throw new Error("Query reported result but nonce value not found");
}
};
- gl_default = `
- const NanoPowGlFragmentShader = \`${NanoPowGlFragmentShader}\`
- const NanoPowGlVertexShader = \`${NanoPowGlVertexShader}\`
- const PowGl = ${NanoPowGl}
-`;
}
});
// src/lib/nano-pow/classes/gpu.ts
-var NanoPowGpu, gpu_default;
+var NanoPowGpu;
var init_gpu = __esm({
"src/lib/nano-pow/classes/gpu.ts"() {
"use strict";
adapter.requestDevice().then((device) => {
this.#device = device;
this.#device.lost.then((loss) => {
- console.warn(`(${loss.reason}) ${loss.message}. Reinitializing device.`);
+ console.dir(loss);
+ console.warn(loss.reason, loss.message);
+ console.warn(`Device lost. Reinitializing...`);
this.init();
});
this.#uboBuffer = this.#device.createBuffer({
12
);
this.#device.queue.submit([commandEncoder.finish()]);
+ await this.#cpuBuffer.mapAsync(GPUMapMode.READ);
+ await this.#device.queue.onSubmittedWorkDone();
try {
- await this.#cpuBuffer.mapAsync(GPUMapMode.READ);
- await this.#device.queue.onSubmittedWorkDone();
+ const data = new DataView(this.#cpuBuffer.getMappedRange());
+ const nonce = data.getBigUint64(0, true);
+ const found = !!data.getUint32(8);
+ this.#cpuBuffer.unmap();
+ if (found) {
+ const hex2 = nonce.toString(16).padStart(16, "0");
+ return hex2;
+ } else {
+ return await this.search(hash2, threshold);
+ }
} catch (err) {
console.warn(`Error getting data from GPU, retrying. ${err}`);
return await this.search(hash2, threshold);
}
- const data = new DataView(this.#cpuBuffer.getMappedRange());
- const nonce = data.getBigUint64(0, true);
- const found = !!data.getUint32(8);
- this.#cpuBuffer.unmap();
- if (found) {
- const hex2 = nonce.toString(16).padStart(16, "0");
- return hex2;
- } else {
- return await this.search(hash2, threshold);
- }
}
};
- gpu_default = `
- const NanoPowGpuComputeShader = \`${NanoPowGpuComputeShader}\`
- const NanoPowGpu = ${NanoPowGpu}
-`;
}
});