mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
fix web pipeline framebuffer resize issue. (#16157)
* fix web pipeline framebuffer resize issue. * fix lint.
This commit is contained in:
@@ -55,9 +55,19 @@ export abstract class Framebuffer extends GFXObject {
|
||||
return this._depthStencilTexture;
|
||||
}
|
||||
|
||||
public get width (): number {
|
||||
return this._width;
|
||||
}
|
||||
|
||||
public get height (): number {
|
||||
return this._height;
|
||||
}
|
||||
|
||||
protected _renderPass: RenderPass | null = null;
|
||||
protected _colorTextures: (Texture | null)[] = [];
|
||||
protected _depthStencilTexture: Texture | null = null;
|
||||
protected _width: number = 0;
|
||||
protected _height: number = 0;
|
||||
|
||||
constructor () {
|
||||
super(ObjectType.FRAMEBUFFER);
|
||||
|
||||
@@ -96,6 +96,8 @@ export class WebGLFramebuffer extends Framebuffer {
|
||||
};
|
||||
|
||||
WebGLCmdFuncCreateFramebuffer(WebGLDeviceManager.instance, this._gpuFramebuffer);
|
||||
this._width = this._gpuFramebuffer.width;
|
||||
this._height = this._gpuFramebuffer.height;
|
||||
}
|
||||
|
||||
public destroy (): void {
|
||||
|
||||
@@ -90,6 +90,8 @@ export class WebGL2Framebuffer extends Framebuffer {
|
||||
};
|
||||
|
||||
WebGL2CmdFuncCreateFramebuffer(WebGL2DeviceManager.instance, this._gpuFramebuffer);
|
||||
this._width = this._gpuFramebuffer.width;
|
||||
this._height = this._gpuFramebuffer.height;
|
||||
}
|
||||
|
||||
public destroy (): void {
|
||||
|
||||
@@ -953,6 +953,25 @@ class DeviceRenderPass {
|
||||
if (this.renderLayout && this.renderLayout.descriptorSet) {
|
||||
this.renderLayout.descriptorSet.update();
|
||||
}
|
||||
|
||||
const resGraph = context.resourceGraph;
|
||||
const currentWidth = this._framebuffer ? this._framebuffer.width : 0;
|
||||
const currentHeight = this._framebuffer ? this._framebuffer.height : 0;
|
||||
|
||||
let width = 0;
|
||||
let height = 0;
|
||||
for (const [resName, rasterV] of this._rasterInfo.pass.rasterViews) {
|
||||
if (rasterV.attachmentType === AttachmentType.SHADING_RATE) {
|
||||
continue;
|
||||
}
|
||||
const resId = resGraph.vertex(resName);
|
||||
const resDesc = resGraph.getDesc(resId);
|
||||
width = resDesc.width;
|
||||
height = resDesc.height;
|
||||
break;
|
||||
}
|
||||
const needRebuild = (width !== currentWidth) || (height !== currentHeight);
|
||||
|
||||
for (const [resName, rasterV] of this._rasterInfo.pass.rasterViews) {
|
||||
let deviceTex = context.deviceTextures.get(resName)!;
|
||||
const currTex = deviceTex;
|
||||
@@ -966,8 +985,7 @@ class DeviceRenderPass {
|
||||
const resDesc = resGraph.getDesc(resId);
|
||||
if (deviceTex.framebuffer && resFbo instanceof Framebuffer && deviceTex.framebuffer !== resFbo) {
|
||||
framebuffer = this._framebuffer = deviceTex.framebuffer = resFbo;
|
||||
} else if (!currTex || (deviceTex.texture
|
||||
&& (deviceTex.texture.width !== resDesc.width || deviceTex.texture.height !== resDesc.height))) {
|
||||
} else if (!currTex || (deviceTex.texture && needRebuild)) {
|
||||
const gfxTex = deviceTex.texture!;
|
||||
if (currTex) gfxTex.resize(resDesc.width, resDesc.height);
|
||||
switch (rasterV.attachmentType) {
|
||||
|
||||
Reference in New Issue
Block a user