mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-20 23:09: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 assets = [loadShader(device, cache, "shaders/wgsl/endPass.wgsl")];
|
||||||
|
|
||||||
const loaded = (async () => {
|
const loaded = (async () => {
|
||||||
const [imageShader] = await Promise.all(assets);
|
const [endShader] = await Promise.all(assets);
|
||||||
|
|
||||||
renderPipeline = await device.createRenderPipelineAsync({
|
renderPipeline = await device.createRenderPipelineAsync({
|
||||||
layout: "auto",
|
layout: "auto",
|
||||||
vertex: {
|
vertex: {
|
||||||
module: imageShader.module,
|
module: endShader.module,
|
||||||
entryPoint: "vertMain",
|
entryPoint: "vertMain",
|
||||||
},
|
},
|
||||||
fragment: {
|
fragment: {
|
||||||
module: imageShader.module,
|
module: endShader.module,
|
||||||
entryPoint: "fragMain",
|
entryPoint: "fragMain",
|
||||||
targets: [
|
targets: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ export default class REGLRenderer extends Renderer {
|
|||||||
await this.#rebuildingPipeline;
|
await this.#rebuildingPipeline;
|
||||||
this.#renderFunc(performance.now());
|
this.#renderFunc(performance.now());
|
||||||
if (oldDevice != null) {
|
if (oldDevice != null) {
|
||||||
|
await oldDevice.queue.onSubmittedWorkDone();
|
||||||
oldDevice.destroy();
|
oldDevice.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -202,10 +203,14 @@ export default class REGLRenderer extends Renderer {
|
|||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
if (this.destroyed) return;
|
if (this.destroyed) return;
|
||||||
if (this.#device != null) {
|
const oldDevice = this.#device;
|
||||||
this.#device.destroy(); // This also destroys any objects created with the device
|
if (oldDevice != null) {
|
||||||
this.#device = null;
|
(async () => {
|
||||||
|
await oldDevice.queue.onSubmittedWorkDone();
|
||||||
|
oldDevice.destroy();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
this.#device = null;
|
||||||
super.destroy();
|
super.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user