From ef1fb139fd3ca9d7fd06cd95aec63338b6ebd57e Mon Sep 17 00:00:00 2001 From: GengineJS <476393671@qq.com> Date: Fri, 22 Aug 2025 15:06:29 +0800 Subject: [PATCH] Fixed the issue that web offscreen MSAA does not take effect when postprocessing is not enabled (#18925) --- cocos/gfx/base/device.ts | 1 - cocos/gfx/webgl2/webgl2-commands.ts | 5 ----- cocos/rendering/custom/executor.ts | 1 + cocos/rendering/custom/web-pipeline.ts | 1 - editor/assets/default_renderpipeline/builtin-pipeline.ts | 5 ++++- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/cocos/gfx/base/device.ts b/cocos/gfx/base/device.ts index 4ab491a54b..93536a4dee 100644 --- a/cocos/gfx/base/device.ts +++ b/cocos/gfx/base/device.ts @@ -53,7 +53,6 @@ import { Swapchain } from './swapchain'; * @zh GFX 设备。 */ export abstract class Device { - constructor () {} /** diff --git a/cocos/gfx/webgl2/webgl2-commands.ts b/cocos/gfx/webgl2/webgl2-commands.ts index 88fe356bca..5363bae31d 100644 --- a/cocos/gfx/webgl2/webgl2-commands.ts +++ b/cocos/gfx/webgl2/webgl2-commands.ts @@ -3277,11 +3277,6 @@ export function WebGL2CmdFuncBlitTexture ( gl.framebufferRenderbuffer(WebGLConstants.READ_FRAMEBUFFER, srcAttachment, WebGLConstants.RENDERBUFFER, src.glRenderbuffer); } - if (dst.glTexture) { - gl.framebufferTexture2D(WebGLConstants.DRAW_FRAMEBUFFER, dstAttachment, dst.glTarget, dst.glTexture, dstMip); - } else { - gl.framebufferRenderbuffer(WebGLConstants.DRAW_FRAMEBUFFER, dstAttachment, WebGLConstants.RENDERBUFFER, dst.glRenderbuffer); - } const status = gl.checkFramebufferStatus(gl.READ_FRAMEBUFFER); if (status !== gl.FRAMEBUFFER_COMPLETE) { warnID(16318); diff --git a/cocos/rendering/custom/executor.ts b/cocos/rendering/custom/executor.ts index d030ebf0a8..9a7d5193ce 100644 --- a/cocos/rendering/custom/executor.ts +++ b/cocos/rendering/custom/executor.ts @@ -838,6 +838,7 @@ class DeviceRenderPass implements RecordingInterface { depAtt.depthStoreOp = rasterV.storeOp; depAtt.stencilStoreOp = rasterV.storeOp; depAtt.depthLoadOp = rasterV.loadOp; + depAtt.sampleCount = resTex.description!.sampleCount; depAtt.stencilLoadOp = rasterV.loadOp; depAtt.barrier = device.getGeneralBarrier(new GeneralBarrierInfo( rasterV.loadOp === LoadOp.LOAD ? AccessFlagBit.DEPTH_STENCIL_ATTACHMENT_WRITE : AccessFlagBit.NONE, diff --git a/cocos/rendering/custom/web-pipeline.ts b/cocos/rendering/custom/web-pipeline.ts index be12f4242f..8c9f78f054 100644 --- a/cocos/rendering/custom/web-pipeline.ts +++ b/cocos/rendering/custom/web-pipeline.ts @@ -1747,7 +1747,6 @@ export class WebPipeline extends WebSetter implements BasicPipeline { return this.addRenderPassImpl(width, height, layoutName); } addMultisampleRenderPass (width: number, height: number, count: number, quality: number, layoutName = 'default'): BasicMultisampleRenderPassBuilder { - assert(count > 1); const rasterPassBuilder = this.addRenderPassImpl(width, height, layoutName, count, quality) as WebRenderPassBuilder; rasterPassBuilder.addRenderSubpass(); return rasterPassBuilder; diff --git a/editor/assets/default_renderpipeline/builtin-pipeline.ts b/editor/assets/default_renderpipeline/builtin-pipeline.ts index b364679e3c..5fc0a346e2 100644 --- a/editor/assets/default_renderpipeline/builtin-pipeline.ts +++ b/editor/assets/default_renderpipeline/builtin-pipeline.ts @@ -25,7 +25,7 @@ import { assert, cclegacy, clamp, geometry, gfx, Layers, Material, pipeline, PipelineEventProcessor, PipelineEventType, ReflectionProbeManager, renderer, - rendering, sys, Vec2, Vec3, Vec4, warn, + rendering, sys, Vec2, Vec3, Vec4, warn, macro, } from 'cc'; import { DEBUG, EDITOR } from 'cc/env'; @@ -77,6 +77,7 @@ function getCsmMainLightViewport( export class PipelineConfigs { isWeb = false; isWebGL1 = false; + isWebGL2 = false; isWebGPU = false; isMobile = false; isHDR = false; @@ -102,6 +103,7 @@ function setupPipelineConfigs( // Platform configs.isWeb = !sys.isNative; configs.isWebGL1 = device.gfxAPI === gfx.API.WEBGL; + configs.isWebGL2 = device.gfxAPI === gfx.API.WEBGL2; configs.isWebGPU = device.gfxAPI === gfx.API.WEBGPU; configs.isMobile = sys.isMobile; @@ -436,6 +438,7 @@ export class BuiltinForwardPassBuilder implements rendering.PipelinePassBuilder // MSAA cameraConfigs.enableMSAA = cameraConfigs.settings.msaa.enabled + && (!pipelineConfigs.isWebGL2 || (cameraConfigs.remainingPasses > 0 || (!macro.ENABLE_WEBGL_ANTIALIAS && macro.ENABLE_TRANSPARENT_CANVAS))) && !cameraConfigs.enableStoreSceneDepth // Cannot store MS depth, resolve depth is also not cross-platform && !pipelineConfigs.isWebGL1;