From f038109934acebf795187296f61eca5a70b98292 Mon Sep 17 00:00:00 2001 From: GengineJS <476393671@qq.com> Date: Thu, 7 Nov 2024 14:15:10 +0800 Subject: [PATCH 1/6] Fixed the ubo update mechanism (#17820) --- cocos/rendering/custom/executor.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/cocos/rendering/custom/executor.ts b/cocos/rendering/custom/executor.ts index 930a8cc54f4..b85c42724d6 100644 --- a/cocos/rendering/custom/executor.ts +++ b/cocos/rendering/custom/executor.ts @@ -368,7 +368,6 @@ class BlitDesc { constructor (blit: Blit) { this._blit = blit; } - /** * @zh * 创建四边形输入汇集器。 @@ -426,7 +425,7 @@ class BlitDesc { this._lightBufferData.set(_vec4Array, idx * elementLen + fieldLen * 2); if (isSpot) { - // cc_lightDir + // cc_lightDir Vec3.toArray(_vec4Array, (light as SpotLight).direction); this._lightBufferData.set(_vec4Array, idx * elementLen + fieldLen * 3); } @@ -496,6 +495,7 @@ class DeviceComputeQueue implements RecordingInterface { private _renderPhase: RenderPhaseData | null = null; private _descSetData: DescriptorSetData | null = null; private _layoutID = -1; + private _isUpdateUBO = false; private _isUploadInstance = false; private _isUploadBatched = false; private _queueId = -1; @@ -521,12 +521,15 @@ class DeviceComputeQueue implements RecordingInterface { get renderPhase (): RenderPhaseData | null { return this._renderPhase; } set queueId (val) { this._queueId = val; } get queueId (): number { return this._queueId; } + set isUpdateUBO (update: boolean) { this._isUpdateUBO = update; } + get isUpdateUBO (): boolean { return this._isUpdateUBO; } set isUploadInstance (value: boolean) { this._isUploadInstance = value; } get isUploadInstance (): boolean { return this._isUploadInstance; } set isUploadBatched (value: boolean) { this._isUploadBatched = value; } get isUploadBatched (): boolean { return this._isUploadBatched; } reset (): void { + this._isUpdateUBO = false; this._isUploadInstance = false; this._isUploadBatched = false; } @@ -553,6 +556,7 @@ class DeviceRenderQueue implements RecordingInterface { private _viewport: Viewport | null = null; private _scissor: Rect | null = null; private _layoutID = -1; + private _isUpdateUBO = false; private _isUploadInstance = false; private _isUploadBatched = false; get phaseID (): number { return this._phaseID; } @@ -574,6 +578,8 @@ class DeviceRenderQueue implements RecordingInterface { private _queueId = -1; set queueId (val) { this._queueId = val; } get queueId (): number { return this._queueId; } + set isUpdateUBO (update: boolean) { this._isUpdateUBO = update; } + get isUpdateUBO (): boolean { return this._isUpdateUBO; } set isUploadInstance (value: boolean) { this._isUploadInstance = value; } get isUploadInstance (): boolean { return this._isUploadInstance; } set isUploadBatched (value: boolean) { this._isUploadBatched = value; } @@ -606,6 +612,7 @@ class DeviceRenderQueue implements RecordingInterface { } reset (): void { this._renderScenes.length = 0; + this._isUpdateUBO = false; this._isUploadInstance = false; this._isUploadBatched = false; this._blitDesc?.reset(); @@ -665,7 +672,7 @@ class RenderPassLayoutInfo { const gfxBuf = deviceBuf?.buffer; if (!gfxTex && !gfxBuf) { - throw new Error(`Could not find texture with resource name ${this._inputName}`); + throw Error(`Could not find texture with resource name ${this._inputName}`); } this._resID = context.resourceGraph.vertex(this._inputName); @@ -1211,6 +1218,7 @@ class DeviceRenderScene implements RecordingInterface { } protected _updateRenderData (): void { + if (this._currentQueue.isUpdateUBO) return; const devicePass = this._currentQueue.devicePass; const rasterId = devicePass.rasterID; const passRenderData = context.renderGraph.getData(rasterId); @@ -1221,7 +1229,10 @@ class DeviceRenderScene implements RecordingInterface { const queueId = this._currentQueue.queueId; const queueRenderData = context.renderGraph.getData(queueId)!; this._updateGlobal(queueRenderData, sceneId); + const sceneRenderData = context.renderGraph.getData(sceneId)!; + if (sceneRenderData) this._updateGlobal(sceneRenderData, sceneId); context.passDescriptorSet?.update(); + this._currentQueue.isUpdateUBO = true; } private _applyViewport (): void { From 4020b3204e890f7c8014252a9a7806072494f726 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 7 Nov 2024 14:28:57 +0800 Subject: [PATCH 2/6] update description (#17823) --- cocos/core/memop/recycle-pool.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/core/memop/recycle-pool.ts b/cocos/core/memop/recycle-pool.ts index 1b15e284fa6..0ff73643ce6 100644 --- a/cocos/core/memop/recycle-pool.ts +++ b/cocos/core/memop/recycle-pool.ts @@ -99,8 +99,8 @@ export class RecyclePool extends ScalableContainer { } /** - * @en Expand the array size to 2 times the original size, and fills with new created elements. - * @zh 扩充对象池容量,会自动扩充尺寸到原来的 2 倍,并填充新的元素。 + * @en Adds a new element. If the capacity is insufficient, it will automatically expand to twice its original size. + * @zh 添加一个新元素,如果容量不足,会自动扩充尺寸到原来的 2 倍。 */ public add (): T { if (this._count$ >= this._data$.length) { From c914c67870c80c1915786876c17b5592ba841f62 Mon Sep 17 00:00:00 2001 From: hyde zhou Date: Thu, 7 Nov 2024 17:31:35 +0800 Subject: [PATCH 3/6] update builtin types (#17822) --- .../builtin-pipeline-types.ts | 15 +++++++++------ .../effects/pipeline/post-process/dof1.effect | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/editor/assets/default_renderpipeline/builtin-pipeline-types.ts b/editor/assets/default_renderpipeline/builtin-pipeline-types.ts index 9301cb4432e..acfcb4724a3 100644 --- a/editor/assets/default_renderpipeline/builtin-pipeline-types.ts +++ b/editor/assets/default_renderpipeline/builtin-pipeline-types.ts @@ -28,7 +28,7 @@ * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= */ /* eslint-disable max-len */ -import { Material, Texture2D, gfx, Vec3 } from 'cc'; +import { Material, Texture2D, Vec3, gfx } from 'cc'; const { SampleCount } = gfx; @@ -100,9 +100,9 @@ export interface DepthOfField { enabled: boolean; /* false */ /* refcount */ material: Material | null; minRange: number; /* 0 */ - maxRange: number; /* 0 */ + maxRange: number; /* 50 */ blurRadius: number; /* 1 */ - intensity: number; + intensity: number; /* 1 */ focusPos: Vec3; [name: string]: unknown; } @@ -114,7 +114,7 @@ export function makeDepthOfField(): DepthOfField { minRange: 0, maxRange: 50, blurRadius: 1, - intensity: 0.2, + intensity: 1, focusPos: new Vec3(0, 0, 0), }; } @@ -130,13 +130,16 @@ export function fillRequiredDepthOfField(value: DepthOfField): void { value.minRange = 0; } if (value.maxRange === undefined) { - value.maxRange = 0; + value.maxRange = 50; } if (value.blurRadius === undefined) { value.blurRadius = 1; } + if (value.intensity === undefined) { + value.intensity = 1; + } if (value.focusPos === undefined) { - value.focusPos = new Vec3(); + value.focusPos = new Vec3(0, 0, 0); } } diff --git a/editor/assets/effects/pipeline/post-process/dof1.effect b/editor/assets/effects/pipeline/post-process/dof1.effect index 6ca5c5bc40f..f69b89b5e89 100644 --- a/editor/assets/effects/pipeline/post-process/dof1.effect +++ b/editor/assets/effects/pipeline/post-process/dof1.effect @@ -61,7 +61,7 @@ void main() { outColor += blur(screenTex, v_uv + offsets.zy); outColor += blur(screenTex, v_uv + offsets.xw); outColor += blur(screenTex, v_uv + offsets.zw); - fragColor = outColor * blurParams.w; + fragColor = outColor * blurParams.w * 0.25; } }% From 8904950c7027ea7a61ba75a65edd9e0f92a091d9 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Nov 2024 12:36:49 +0800 Subject: [PATCH 4/6] [v3.8.5] Fix that bytedance platform adapter code hacked cc.ImageAsset.data. (#17825) --- cocos/asset/assets/image-asset.ts | 4 ++-- .../platforms/bytedance/wrapper/engine/ImageAsset.js | 7 ------- .../minigame/platforms/bytedance/wrapper/engine/index.js | 1 - 3 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 platforms/minigame/platforms/bytedance/wrapper/engine/ImageAsset.js diff --git a/cocos/asset/assets/image-asset.ts b/cocos/asset/assets/image-asset.ts index f20151cda14..f708938c465 100644 --- a/cocos/asset/assets/image-asset.ts +++ b/cocos/asset/assets/image-asset.ts @@ -24,7 +24,7 @@ // @ts-check import { ccclass, override } from 'cc.decorator'; -import { EDITOR, ALIPAY, XIAOMI, JSB, TEST, BAIDU, TAOBAO, TAOBAO_MINIGAME, WECHAT_MINI_PROGRAM } from 'internal:constants'; +import { EDITOR, ALIPAY, XIAOMI, JSB, TEST, BAIDU, TAOBAO, TAOBAO_MINIGAME, WECHAT_MINI_PROGRAM, BYTEDANCE } from 'internal:constants'; import { Device, Format, FormatFeatureBit, deviceManager } from '../../gfx'; import { Asset } from './asset'; import { PixelFormat } from './asset-enum'; @@ -163,7 +163,7 @@ function fetchImageSource (imageSource: ImageSource): HTMLCanvasElement | HTMLIm // 返回该图像源是否是平台提供的图像对象。 function isNativeImage (imageSource: ImageSource): imageSource is (HTMLImageElement | HTMLCanvasElement | ImageBitmap) { - if (ALIPAY || TAOBAO || TAOBAO_MINIGAME || XIAOMI || BAIDU || WECHAT_MINI_PROGRAM) { + if (ALIPAY || TAOBAO || TAOBAO_MINIGAME || XIAOMI || BAIDU || WECHAT_MINI_PROGRAM || BYTEDANCE) { // We're unable to grab the constructors of Alipay native image or canvas object. return !('_data' in imageSource); } diff --git a/platforms/minigame/platforms/bytedance/wrapper/engine/ImageAsset.js b/platforms/minigame/platforms/bytedance/wrapper/engine/ImageAsset.js deleted file mode 100644 index 78efdb19729..00000000000 --- a/platforms/minigame/platforms/bytedance/wrapper/engine/ImageAsset.js +++ /dev/null @@ -1,7 +0,0 @@ -if (cc.ImageAsset) { - Object.defineProperty(cc.ImageAsset.prototype, 'data', { - get () { - return (this._nativeData && this._nativeData._data) || this._nativeData; - }, - }); -} \ No newline at end of file diff --git a/platforms/minigame/platforms/bytedance/wrapper/engine/index.js b/platforms/minigame/platforms/bytedance/wrapper/engine/index.js index 26624d377e0..df2d40fbc2b 100644 --- a/platforms/minigame/platforms/bytedance/wrapper/engine/index.js +++ b/platforms/minigame/platforms/bytedance/wrapper/engine/index.js @@ -2,4 +2,3 @@ require('../fs-utils'); require('../../../../common/engine/index'); require('./VideoPlayer'); require('./Label'); -require('./ImageAsset'); From e4bf2e13aecfaf1675e23d98d3700e05bf330071 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 8 Nov 2024 14:05:08 +0800 Subject: [PATCH 5/6] simplify codes (#17801) --- cocos/ui/scroll-view.ts | 96 +++++++---------------------------------- 1 file changed, 15 insertions(+), 81 deletions(-) diff --git a/cocos/ui/scroll-view.ts b/cocos/ui/scroll-view.ts index 6b8b8a80e47..385a93bc4fd 100644 --- a/cocos/ui/scroll-view.ts +++ b/cocos/ui/scroll-view.ts @@ -500,14 +500,7 @@ export class ScrollView extends ViewGroup { * ``` */ public scrollToBottom (timeInSecond?: number, attenuated = true): void { - assignMoveDeltaOption(0, 0, false, true); - const moveDelta = this._calculateMovePercentDelta(_moveDeltaOptions); - - if (timeInSecond) { - this._startAutoScroll(moveDelta, timeInSecond, attenuated); - } else { - this._moveContent(moveDelta, true); - } + this._doScroll(0, 0, false, true, timeInSecond, attenuated); } /** @@ -527,14 +520,7 @@ export class ScrollView extends ViewGroup { * ``` */ public scrollToTop (timeInSecond?: number, attenuated = true): void { - assignMoveDeltaOption(0, 1, false, true); - const moveDelta = this._calculateMovePercentDelta(_moveDeltaOptions); - - if (timeInSecond) { - this._startAutoScroll(moveDelta, timeInSecond, attenuated); - } else { - this._moveContent(moveDelta); - } + this._doScroll(0, 1, false, true, timeInSecond, attenuated); } /** @@ -554,14 +540,7 @@ export class ScrollView extends ViewGroup { * ``` */ public scrollToLeft (timeInSecond?: number, attenuated = true): void { - assignMoveDeltaOption(0, 0, true, false); - const moveDelta = this._calculateMovePercentDelta(_moveDeltaOptions); - - if (timeInSecond) { - this._startAutoScroll(moveDelta, timeInSecond, attenuated); - } else { - this._moveContent(moveDelta); - } + this._doScroll(0, 0, true, false, timeInSecond, attenuated); } /** @@ -581,14 +560,7 @@ export class ScrollView extends ViewGroup { * ``` */ public scrollToRight (timeInSecond?: number, attenuated = true): void { - assignMoveDeltaOption(1, 0, true, false); - const moveDelta = this._calculateMovePercentDelta(_moveDeltaOptions); - - if (timeInSecond) { - this._startAutoScroll(moveDelta, timeInSecond, attenuated); - } else { - this._moveContent(moveDelta); - } + this._doScroll(1, 0, true, false, timeInSecond, attenuated); } /** @@ -608,14 +580,7 @@ export class ScrollView extends ViewGroup { * ``` */ public scrollToTopLeft (timeInSecond?: number, attenuated = true): void { - assignMoveDeltaOption(0, 1, true, true); - const moveDelta = this._calculateMovePercentDelta(_moveDeltaOptions); - - if (timeInSecond) { - this._startAutoScroll(moveDelta, timeInSecond, attenuated); - } else { - this._moveContent(moveDelta); - } + this._doScroll(0, 1, true, true, timeInSecond, attenuated); } /** @@ -635,14 +600,7 @@ export class ScrollView extends ViewGroup { * ``` */ public scrollToTopRight (timeInSecond?: number, attenuated = true): void { - assignMoveDeltaOption(1, 1, true, true); - const moveDelta = this._calculateMovePercentDelta(_moveDeltaOptions); - - if (timeInSecond) { - this._startAutoScroll(moveDelta, timeInSecond, attenuated); - } else { - this._moveContent(moveDelta); - } + this._doScroll(1, 1, true, true, timeInSecond, attenuated); } /** @@ -662,14 +620,7 @@ export class ScrollView extends ViewGroup { * ``` */ public scrollToBottomLeft (timeInSecond?: number, attenuated = true): void { - assignMoveDeltaOption(0, 0, true, true); - const moveDelta = this._calculateMovePercentDelta(_moveDeltaOptions); - - if (timeInSecond) { - this._startAutoScroll(moveDelta, timeInSecond, attenuated); - } else { - this._moveContent(moveDelta); - } + this._doScroll(0, 0, true, true, timeInSecond, attenuated); } /** @@ -689,14 +640,7 @@ export class ScrollView extends ViewGroup { * ``` */ public scrollToBottomRight (timeInSecond?: number, attenuated = true): void { - assignMoveDeltaOption(1, 0, true, true); - const moveDelta = this._calculateMovePercentDelta(_moveDeltaOptions); - - if (timeInSecond) { - this._startAutoScroll(moveDelta, timeInSecond, attenuated); - } else { - this._moveContent(moveDelta); - } + this._doScroll(1, 0, true, true, timeInSecond, attenuated); } /** @@ -796,14 +740,7 @@ export class ScrollView extends ViewGroup { * ``` */ public scrollToPercentHorizontal (percent: number, timeInSecond: number, attenuated: boolean): void { - assignMoveDeltaOption(percent, 0, true, false); - const moveDelta = this._calculateMovePercentDelta(_moveDeltaOptions); - - if (timeInSecond) { - this._startAutoScroll(moveDelta, timeInSecond, attenuated); - } else { - this._moveContent(moveDelta); - } + this._doScroll(percent, 0, true, false, timeInSecond, attenuated); } /** @@ -829,14 +766,7 @@ export class ScrollView extends ViewGroup { * ``` */ public scrollTo (anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void { - assignMoveDeltaOption(anchor.x, anchor.y, true, true); - const moveDelta = this._calculateMovePercentDelta(_moveDeltaOptions); - - if (timeInSecond) { - this._startAutoScroll(moveDelta, timeInSecond, attenuated); - } else { - this._moveContent(moveDelta); - } + this._doScroll(anchor.x, anchor.y, true, true, timeInSecond, attenuated); } /** @@ -857,7 +787,11 @@ export class ScrollView extends ViewGroup { * ``` */ public scrollToPercentVertical (percent: number, timeInSecond?: number, attenuated?: boolean): void { - assignMoveDeltaOption(0, percent, false, true); + this._doScroll(0, percent, false, true, timeInSecond, attenuated); + } + + private _doScroll (x: number, y: number, applyToHorizontal: boolean, applyToVertical: boolean, timeInSecond?: number, attenuated = true): void { + assignMoveDeltaOption(x, y, applyToHorizontal, applyToVertical); const moveDelta = this._calculateMovePercentDelta(_moveDeltaOptions); if (timeInSecond) { From dd7ff2046505d23754e0428b7e0308bb88849ba8 Mon Sep 17 00:00:00 2001 From: bofeng-song Date: Fri, 8 Nov 2024 15:01:30 +0800 Subject: [PATCH 6/6] Fix test-case can not run normally due to access private field (#17826) --- cocos/asset/asset-manager/downloader.ts | 7 +++++++ .../platforms/xiaomi/wrapper/engine/download-ttf.js | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cocos/asset/asset-manager/downloader.ts b/cocos/asset/asset-manager/downloader.ts index 0f7283bdc91..37cdb97dc3e 100644 --- a/cocos/asset/asset-manager/downloader.ts +++ b/cocos/asset/asset-manager/downloader.ts @@ -347,6 +347,13 @@ export class Downloader { this.remoteBundles = remoteBundles; } + /** + * @engineInternal + */ + public get handlers (): Record { + return this._downloaders$; + } + /** * @en * Register custom handler if you want to change default behavior or extend downloader to download other format file. diff --git a/platforms/minigame/platforms/xiaomi/wrapper/engine/download-ttf.js b/platforms/minigame/platforms/xiaomi/wrapper/engine/download-ttf.js index 84aeb9a4cc2..8c7c3d064c8 100644 --- a/platforms/minigame/platforms/xiaomi/wrapper/engine/download-ttf.js +++ b/platforms/minigame/platforms/xiaomi/wrapper/engine/download-ttf.js @@ -1,5 +1,5 @@ const downloader = cc.assetManager.downloader; -const originalDownloadTTF = downloader._downloaders['.ttf']; +const originalDownloadTTF = downloader.handlers['.ttf']; function downloadTTF (url, options, onComplete) { // can't use cached ttf on Xiaomi platform