mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-14 12:29:30 -07:00
WebGPU Renderer now awaits the submitted work in the old device's queue before destroying it
This commit is contained in:
@@ -24,16 +24,16 @@ export default ({ device, cache, canvasFormat, canvasContext }) => {
|
||||
const assets = [loadShader(device, cache, "shaders/wgsl/endPass.wgsl")];
|
||||
|
||||
const loaded = (async () => {
|
||||
const [imageShader] = await Promise.all(assets);
|
||||
const [endShader] = await Promise.all(assets);
|
||||
|
||||
renderPipeline = await device.createRenderPipelineAsync({
|
||||
layout: "auto",
|
||||
vertex: {
|
||||
module: imageShader.module,
|
||||
module: endShader.module,
|
||||
entryPoint: "vertMain",
|
||||
},
|
||||
fragment: {
|
||||
module: imageShader.module,
|
||||
module: endShader.module,
|
||||
entryPoint: "fragMain",
|
||||
targets: [
|
||||
{
|
||||
|
||||
@@ -184,6 +184,7 @@ export default class REGLRenderer extends Renderer {
|
||||
await this.#rebuildingPipeline;
|
||||
this.#renderFunc(performance.now());
|
||||
if (oldDevice != null) {
|
||||
await oldDevice.queue.onSubmittedWorkDone();
|
||||
oldDevice.destroy();
|
||||
}
|
||||
}
|
||||
@@ -202,10 +203,14 @@ export default class REGLRenderer extends Renderer {
|
||||
|
||||
destroy() {
|
||||
if (this.destroyed) return;
|
||||
if (this.#device != null) {
|
||||
this.#device.destroy(); // This also destroys any objects created with the device
|
||||
this.#device = null;
|
||||
const oldDevice = this.#device;
|
||||
if (oldDevice != null) {
|
||||
(async () => {
|
||||
await oldDevice.queue.onSubmittedWorkDone();
|
||||
oldDevice.destroy();
|
||||
});
|
||||
}
|
||||
this.#device = null;
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user