Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the situation where the texture inside the FBO is destroyed when WebGPU switches scenes. #17547

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions cocos/rendering/custom/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,9 @@ class DeviceRenderPass implements RecordingInterface {
this._deviceQueues.clear();
let framebuffer: Framebuffer | null = null;
const colTextures: Texture[] = [];
let depTexture = this._framebuffer ? this._framebuffer.depthStencilTexture : null;
const currFramebuffer = this._framebuffer;
const currFBDepthTex = currFramebuffer.depthStencilTexture;
let depTexture = currFramebuffer ? currFBDepthTex : null;
for (const cv of this._rasterInfo.pass.computeViews) {
this._applyRenderLayout(cv);
}
Expand All @@ -1052,8 +1054,8 @@ class DeviceRenderPass implements RecordingInterface {
}

const resGraph = context.resourceGraph;
const currentWidth = this._framebuffer ? this._framebuffer.width : 0;
const currentHeight = this._framebuffer ? this._framebuffer.height : 0;
const currentWidth = currFramebuffer ? currFramebuffer.width : 0;
const currentHeight = currFramebuffer ? currFramebuffer.height : 0;

let width = 0;
let height = 0;
Expand All @@ -1067,8 +1069,18 @@ class DeviceRenderPass implements RecordingInterface {
height = resDesc.height;
break;
}
const needRebuild = (width !== currentWidth) || (height !== currentHeight) || this.framebuffer.needRebuild;

// The texture inside the fbo was destroyed?
let isInsideTexDestroy = false;
for (const colTex of currFramebuffer.colorTextures) {
if (colTex?.getTextureHandle() === 0) {
isInsideTexDestroy = true;
break;
}
}
if (currFBDepthTex && !isInsideTexDestroy) {
isInsideTexDestroy = currFBDepthTex.getTextureHandle() === 0;
}
const needRebuild = (width !== currentWidth) || (height !== currentHeight) || currFramebuffer.needRebuild || isInsideTexDestroy;
for (const [resName, rasterV] of this._rasterInfo.pass.rasterViews) {
let deviceTex = context.deviceTextures.get(resName)!;
const currTex = deviceTex;
Expand Down
Loading