From c184295aa43f562a352a67e4d95fee303e7dce3f Mon Sep 17 00:00:00 2001 From: hyde zhou Date: Wed, 10 Jul 2024 10:39:30 +0800 Subject: [PATCH] Update pipeline after scene loaded and before rendering (#17345) --- cocos/game/director.ts | 11 ++++++++++- .../assets/default_renderpipeline/builtin-pipeline.ts | 10 +++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cocos/game/director.ts b/cocos/game/director.ts index c7619d2957..2477263d03 100644 --- a/cocos/game/director.ts +++ b/cocos/game/director.ts @@ -739,7 +739,16 @@ export class Director extends EventTarget { // 2. cclegacy.rendering is available // 3. The root node is created and uses custom pipeline if (macro.CUSTOM_PIPELINE_NAME !== '' && cclegacy.rendering && this._root && this._root.usesCustomPipeline) { - this.on(Director.EVENT_BEFORE_RENDER, this.buildRenderPipeline, this); + this.on( + Director.EVENT_BEFORE_RENDER, + this.buildRenderPipeline, + this, + ); + this.on( + Director.EVENT_BEFORE_SCENE_LAUNCH, + cclegacy.rendering.forceResizeAllWindows, + cclegacy.rendering, + ); } } diff --git a/editor/assets/default_renderpipeline/builtin-pipeline.ts b/editor/assets/default_renderpipeline/builtin-pipeline.ts index 59974547b4..48fa002793 100644 --- a/editor/assets/default_renderpipeline/builtin-pipeline.ts +++ b/editor/assets/default_renderpipeline/builtin-pipeline.ts @@ -84,6 +84,7 @@ function getCsmMainLightViewport( class PipelineConfigs { isWeb = false; + isWebGPU = false; isMobile = false; isHDR = false; useFloatOutput = false; @@ -97,16 +98,13 @@ class PipelineConfigs { platform = new Vec4(0, 0, 0, 0); } -function isWebGPU() { - return (cclegacy.WebGPUDevice && cclegacy.director.root.device instanceof cclegacy.WebGPUDevice); -} - function setupPipelineConfigs( ppl: rendering.BasicPipeline, configs: PipelineConfigs, ): void { const sampleFeature = FormatFeatureBit.SAMPLED_TEXTURE | FormatFeatureBit.LINEAR_FILTER; configs.isWeb = !sys.isNative; + configs.isWebGPU = (cclegacy.WebGPUDevice && cclegacy.director.root.device instanceof cclegacy.WebGPUDevice); configs.isMobile = sys.isMobile; configs.isHDR = ppl.pipelineSceneData.isHDR; // Has tone mapping configs.useFloatOutput = ppl.getMacroBool('CC_USE_FLOAT_OUTPUT'); @@ -819,7 +817,9 @@ if (rendering) { for (let level = 0; level !== csmLevel; ++level) { getCsmMainLightViewport(light, width, height, level, this._viewport, this._configs.screenSpaceSignY); const queue = pass.addQueue(QueueHint.NONE, 'shadow-caster'); - isWebGPU() || queue.setViewport(this._viewport); + if (!this._configs.isWebGPU) { // Temporary workaround for WebGPU + queue.setViewport(this._viewport); + } queue .addScene(camera, SceneFlags.OPAQUE | SceneFlags.MASK | SceneFlags.SHADOW_CASTER) .useLightFrustum(light, level);