From 60f9352c563b4ecfeaef5c69f947e933374d1d76 Mon Sep 17 00:00:00 2001 From: MagicX <96930078+MagicXHouse@users.noreply.github.com> Date: Mon, 14 Sep 2026 14:10:33 +0800 Subject: [PATCH 1/5] fix(mesh): hoose index format by max index value in createMesh (#336) * Changed the GeometryRenderer and DebugRenderer from using intrusive calls to registering callbacks (custom pipeline). * Changed the GeometryRenderer and DebugRenderer from using intrusive calls to registering callbacks. (old pipeline) * CI error: Function parameter names cannot be omitted. * Move the devil string to macro * fix(mesh): hoose index format by max index value in createMesh --- cocos/3d/misc/create-mesh.ts | 9 +++++++-- native/cocos/3d/misc/CreateMesh.cpp | 13 +++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/cocos/3d/misc/create-mesh.ts b/cocos/3d/misc/create-mesh.ts index c6b14742a8..fcbad3f39b 100644 --- a/cocos/3d/misc/create-mesh.ts +++ b/cocos/3d/misc/create-mesh.ts @@ -172,13 +172,18 @@ export function createMesh (geometry: IGeometry, out?: Mesh, options?: ICreateMe // Fill index buffer. let indexBuffer: ArrayBuffer | null = null; let idxCount = 0; - const idxStride = 2; + let idxStride = 2; + let indexFormat = Format.R16UI; if (geometry.indices) { const { indices } = geometry; idxCount = indices.length; + if (indices.some((i) => i > 0xFFFF)) { + idxStride = 4; + indexFormat = Format.R32UI; + } indexBuffer = new ArrayBuffer(idxStride * idxCount); const indexBufferView = new DataView(indexBuffer); - writeBuffer(indexBufferView, indices, Format.R16UI); + writeBuffer(indexBufferView, indices, indexFormat); } // Create primitive. diff --git a/native/cocos/3d/misc/CreateMesh.cpp b/native/cocos/3d/misc/CreateMesh.cpp index 21626ba833..ccff5acb7a 100644 --- a/native/cocos/3d/misc/CreateMesh.cpp +++ b/native/cocos/3d/misc/CreateMesh.cpp @@ -222,13 +222,22 @@ Mesh::ICreateInfo MeshUtils::createMeshInfo(const IGeometry &geometry, const ccs // Fill index buffer. ArrayBuffer::Ptr indexBuffer; uint32_t idxCount = 0; - const uint32_t idxStride = 2; + uint32_t idxStride = 2; + gfx::Format indexFormat = gfx::Format::R16UI; if (geometry.indices.has_value()) { const ccstd::vector &indices = geometry.indices.value(); + uint32_t maxIndex = 0; + for (uint32_t idx : indices) { + maxIndex = std::max(maxIndex, idx); + } + if (maxIndex > std::numeric_limits::max()) { + idxStride = 4; + indexFormat = gfx::Format::R32UI; + } idxCount = static_cast(indices.size()); indexBuffer = ccnew ArrayBuffer(idxStride * idxCount); DataView indexBufferView(indexBuffer); - writeBuffer(indexBufferView, indices, gfx::Format::R16UI); + writeBuffer(indexBufferView, indices, indexFormat); } // Create primitive. From 6b455561f4d80b22941f6a8f0ca831376555fe46 Mon Sep 17 00:00:00 2001 From: zxx43 Date: Mon, 14 Sep 2026 16:06:30 +0800 Subject: [PATCH 2/5] optimize noise function (#338) * optimize noise function * format --- cocos/particle/noise.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cocos/particle/noise.ts b/cocos/particle/noise.ts index 3b0908b5d7..d0995a165e 100644 --- a/cocos/particle/noise.ts +++ b/cocos/particle/noise.ts @@ -29,7 +29,8 @@ import { Vec2, Vec3 } from '../core/math'; * @zh 此类生成噪声纹理。 */ export class ParticleNoise { - private permutation: number[] = [151, 160, 137, 91, 90, 15, + private static readonly DEFAULT_PERMUTATION: readonly number[] = [ + 151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166, @@ -44,9 +45,19 @@ export class ParticleNoise { 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180, ]; + private static build512 (src: readonly number[] | number[]): Uint8Array { + const p = new Uint8Array(512); + for (let i = 0; i < 256; i++) { p[256 + i] = p[i] = src[i]; } + return p; + } + + private permutation: number[] = ParticleNoise.DEFAULT_PERMUTATION as number[]; + private permutation512: Uint8Array = ParticleNoise.build512(ParticleNoise.DEFAULT_PERMUTATION); + constructor (permutation?: number[]) { if (permutation) { - this.permutation = permutation; + this.permutation = permutation.slice(); + this.permutation512 = ParticleNoise.build512(this.permutation); } } @@ -61,8 +72,7 @@ export class ParticleNoise { * @returns @en Texture pixel generated. @zh 返回生成的噪声纹理值。 */ public noise (x: number, y: number, z: number, min = 0, max = 1): number { - const p: number[] = new Array(512); - for (let i = 0; i < 256; i++) { p[256 + i] = p[i] = this.permutation[i]; } + const p: Uint8Array = this.permutation512; const X = Math.floor(x) & 255; // FIND UNIT CUBE THAT const Y = Math.floor(y) & 255; // CONTAINS POINT. From 2ce7b89be5e262e505a3222a9b2905e18fedef10 Mon Sep 17 00:00:00 2001 From: Cocos Robot <48829427+cocos-robot@users.noreply.github.com> Date: Mon, 14 Sep 2026 17:02:34 +0800 Subject: [PATCH 3/5] [ci skip][AUTO]: Automated clang-format update: ffc817b76ff51d7106a92df0dc8083ef78f63cde (#336) (#337) Co-authored-by: cocos-robot --- .../renderer/pipeline/custom/NativeExecutor.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/native/cocos/renderer/pipeline/custom/NativeExecutor.cpp b/native/cocos/renderer/pipeline/custom/NativeExecutor.cpp index f5463596b5..e79c5f7def 100644 --- a/native/cocos/renderer/pipeline/custom/NativeExecutor.cpp +++ b/native/cocos/renderer/pipeline/custom/NativeExecutor.cpp @@ -698,15 +698,15 @@ struct RenderGraphVisitor : boost::dfs_visitor<> { ctx.cmdBuff, ctx.currentPass, ctx.subpassIndex, sceneData.flags); #if CC_USE_GEOMETRY_RENDERER - const auto& renderData = get(RenderGraph::DataTag{}, ctx.g, sceneID); - if (!renderData.custom.empty()) { - const auto& commands = ctx.ppl->custom.renderCommands; - auto iter = commands.find(renderData.custom); - if (iter != commands.end()) { - ctx.customContext.currentRenderPass = ctx.currentPass; - iter->second->beginRenderCommand(ctx.customContext, sceneID); + const auto& renderData = get(RenderGraph::DataTag{}, ctx.g, sceneID); + if (!renderData.custom.empty()) { + const auto& commands = ctx.ppl->custom.renderCommands; + auto iter = commands.find(renderData.custom); + if (iter != commands.end()) { + ctx.customContext.currentRenderPass = ctx.currentPass; + iter->second->beginRenderCommand(ctx.customContext, sceneID); + } } - } #endif if (any(sceneData.flags & SceneFlags::REFLECTION_PROBE)) { From fffd9a514a83f93034e288c0b99308826f65c573 Mon Sep 17 00:00:00 2001 From: hyde zhou Date: Mon, 14 Sep 2026 17:55:42 +0800 Subject: [PATCH 5/5] bump version to 4.0.0-alpha.34 (#339) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index b5b11ef79d..aa54f61e6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cocos-creator", - "version": "4.0.0-alpha.33", + "version": "4.0.0-alpha.34", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cocos-creator", - "version": "4.0.0-alpha.33", + "version": "4.0.0-alpha.34", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index d1ca9f06cf..ab5d19d392 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cocos-creator", - "version": "4.0.0-alpha.33", + "version": "4.0.0-alpha.34", "description": "Cocos Creator is a cross-platform 2D & 3D game engine written in C++ and TypeScript, licensed under MIT.", "homepage": "http://www.cocos.com", "license": "MIT",