6881 Commits

Author SHA1 Message Date
ChiaNing af2b9e9ed9 fix(2d): apply cascaded opacity to retained Graphics draws (#421)
* fix(2d): apply cascaded opacity to retained Graphics draws

Use the per-instance Graphics effect on Web and Native so a parent fade scales the original fill and stroke alpha at draw time. Rebind retained geometry when its material changes and synchronize Graphics color on enable or assignment. Covers the Graphics behavior reported in #14868 and #17917.

* fix(2d): apply Graphics cascade opacity to CPU vertex colors

* fix(2d): preserve wide strokes and reuse Graphics opacity buffers

Reserve stroke vertices using the emitted caps and joins and split at independent subpath boundaries. Reuse Web upload storage across immediate redraws and use the shared draw-info dirty bit to synchronize only changed Native geometry blocks. Release empty caches on the subsequent renderer update or disable.

* fix(2d): handle passless Graphics materials and release empty paint buffers

* fix(2d): scope Graphics opacity updates and trim unused buffers

* fix(2d): limit the Graphics change to cascaded opacity

* fix(2d): preserve Graphics.color behavior during parent opacity fades

* fix(2d): use emitted Graphics counts for native opacity uploads
2026-11-18 18:30:48 +08:00
Cocos Robot 1b0455e10e Merge pull request #426 from cocos-robot/t/bot/genbindings-714bd9d
[ci skip][AUTO]: Automated PR to generate code
2026-11-16 16:59:23 +08:00
hyde zhou 6ccf1cf9a8 Reapply "Feat/plugin support, allow third_party feat(spine) to create plugin f…" (#403) (#424)
This reverts commit 5bcfb9fa04.
2026-11-16 16:33:05 +08:00
Cocos Robot 1df519e248 [ci skip][AUTO]: Automated clang-format update: 81c80668ca (#417) (#423)
Co-authored-by: cocos-robot <cocos-robot@cocos.com>
2026-11-16 16:30:33 +08:00
hyde zhou aaa3a9168b add CUSTOM residency type (#417)
* add CUSTOM residency type

* revert settings
2026-11-16 12:08:06 +08:00
qiuguohua 990e3b09aa fix: handle oversized native callback arguments (#409) 2026-11-12 10:49:03 +08:00
llsansun 111fe1755d Origin/bugfix (#408)
* The final `set skeleton` call destroys and rebuilds the GPU bone resources that were bound in the previous two steps. However, the descriptor set is not rebound. As a result, the draw call for this subModel cannot access the bone matrices, so the entire character fails to render (this is not vertex deformation; the character does not appear at all). The fix should replace the reference in `descriptor.buffer` with the new buffer, mark it dirty, and lazily rebuild the descriptor before the next draw.

* opt

* fix: retain negative scale signs in Node.setWorldScale

* test: retain negative scale signs in Node.setWorldScale

* fix
2026-11-12 09:48:55 +08:00
zxx43 4a0dbc977a fix get angle problem (#399)
* fix get angle problem

* fix eslint

* use new function to get angle

* fix eslint error
2026-11-11 16:04:02 +08:00
hyde zhou 5bcfb9fa04 Revert "Feat/plugin support, allow third_party feat(spine) to create plugin f…" (#403)
This reverts commit a56706c9ad.
2026-11-10 17:04:32 +08:00
Tianze-Chen a56706c9ad Feat/plugin support, allow third_party feat(spine) to create plugin for creator. (#306)
* Add UIMesh component for custom 2D mesh rendering

- Add UIMesh component consuming pre-baked vertex/index/segment data, enabling custom renderers (e.g. spine plugin) to batch through the 2D batcher.
- Export UIMesh from the 2d components index.
- Validate setMeshData input at the boundary (stride, buffer lengths, index values, segment ranges, accessor caps) via engine-standard errorIDs 9010-9017, documented in EngineErrorMap.md.
- Expose StaticVBAccessor per-chunk caps as maxVertexCount/maxIndexCount getters and clamp the 10% reserve to them, so meshes that fit (e.g. 30000 vertices) allocate instead of silently failing.
- Add tests/ui/ui-mesh.test.ts covering the 32767 cap boundary, setMeshData validation, and accessor lifetime.

Also takes over node transform and cascaded opacity: vertices are now always
node-local — UIMesh applies the node's world matrix (unbatched via the
per-draw GPU transform the 2D batcher already maintains for middleware,
batched by baking into the shared chunk copy so draws still merge) and folds
the cascaded UIOpacity into the copied vertex colors itself. The legacy
switches (USE_LOCAL / useLocalData / RenderEntity.setUseLocal) are all derived
internally; consumers never touch them. A JSB staleness poll re-prepares the
native draw infos in the same frame on transform/opacity changes, and a
premultipliedAlpha format declaration drives the opacity fold and the builtin
material's blend factors.

Follow-ups folded in: the opacity fold reads the light color at byte offset 20
(the pos*3f + uv*2f header is 20 bytes), not 16; and UIMesh notifies data
producers through the new onPremultipliedAlphaChanged() hook so subclasses
(e.g. the spine plugin) forward the declared format to their baker instead of
redeclaring the field.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Disable built-in spine by default; minor editor/build fixes

- Default the built-in Spine feature (spine-3.8) to off in feature cropping, so it is only included when enabled in the editor.
- Recognize scale as a valid spine atlas page attribute in the texture inspector.
- Skip incomplete platform dirs when bundling runtime adapters.

Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 7f7922aaf42ff1857f0a6d38970a75d303032f57)

* Export WebAssembly interface under cc.wasm namespace

- Add exports/webassembly.ts re-exporting pal/wasm (instantiateWasm, fetchBuffer, fetchUrl, ensureWasmModuleReady) as the public cc.wasm namespace, so extensions/game code can load their own .wasm files through the engine's platform-adaptive path.
- Expose it as a croppable feature rather than an unconditional export from exports/base.ts: cc.config.json declares a `webassembly` feature and editor/engine-features/render-config.json adds the panel entry (default on, required), so it appears under Project Settings -> Feature Cropping. The label/description are plain text on purpose — i18n:ENGINE.* keys live in the editor package and a custom engine cannot add them.

(cherry picked from commit 92003ab4a21b6ee753cf3ba2ca0f4767658e9cdc)

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* feat(simulator): generic native plugin discovery opt-in

The generic plugin discovery chain (cc_gen_plugin_cmake_hook ->
plugins_parser.js -> Pre-AutoLoadPlulgins.cmake -> find_package ->
plugin_registry) already exists and is what native device builds use; the
simulator never invoked it. Wire it in behind an opt-in cache variable, with
no plugin names or plugin logic in the engine — the plugin set is always just
the scan result:

- templates/cmake/common.cmake: cc_gen_plugin_cmake_hook()'s scan roots
  (CC_PLUGIN_PATH) may now be pre-set by the caller; the native-build
  project-layout defaults are unchanged when nobody pre-defines it
- simulator runtime-src CMakeLists.txt: -DSIMULATOR_PLUGIN_SCAN_DIRS="<dir>
  [;<dir>]" scans those roots for cc_plugin.json through the same chain as
  device builds (CC_PROJECT_DIR points into the build tree so the generated
  hook lands there, satisfying the parser's output-dir invariant); unset
  keeps the stock plugin-less simulator, and a cache variable means plain
  `cmake --build` reuses the configured scan
- simulator Game.cpp: call cc_load_all_plugins() after init, mirroring
  BaseGame::init(), so registered plugins' JSB bindings exist before any
  script runs (no-op when no plugins are linked)
- libsimulator protobuf config.h: skip the <hash_map>/<hash_set> defines on
  MSVC >= 1950 (headers removed); stubs fall back to the std::map emulation
  path

Verified end-to-end: a project extensions/ tree scanned at configure time
produces a simulator exe whose plugins register their JSB bindings at startup
(observed live in the simulator's JS context).

Co-Authored-By: Claude Code <noreply@anthropic.com>

---------

Co-authored-by: Developer <developer@cocos.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Engineer <engineer@cocos.com>
2026-11-04 16:41:54 +08:00
Cocos Robot 022be418f9 [ci skip][AUTO]: Automated clang-format update: 9d12fd846b (#390) (#392)
Co-authored-by: cocos-robot <cocos-robot@cocos.com>
2026-11-04 15:05:56 +08:00
Cocos Robot fcdc4333b7 [ci skip][AUTO]: Automated code generating update: 926ed1a9ad (#322) (#388)
Co-authored-by: cocos-robot <cocos-robot@cocos.com>
2026-10-30 19:30:36 +08:00
MagicX 5e627951a0 fix(render-texture): use GPU max texture size instead of 2048. (#385)
* 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

* perf(pipeline): reduce render queue sort to two packed key compares (native platform).

* fix CI error caused by native/cocos/base/Utils.h

* fix(scene): LOD screen usage distance truncated to int (native platform)

* fix: prevent accessor recursion in SkinnedMeshBatchRenderer.

* fix: destroy index buffer in MeshRenderData.clear() to prevent GPU leak.

* fix: use GPU max texture size for render texture resizing.
2026-10-28 18:00:11 +08:00
ChiaNing 2c632d6dd6 fix(2d): serialize custom font families and restore native font aliases (#382)
* refactor(2d): share font family and descriptor helpers

Extract the existing TTF and CHAR font family selection and font description
construction into shared helpers. Preserve raw family values, the Arial
fallback, and the existing size and style formatting.

* fix(2d): serialize custom font families at CSS boundaries

Quote and escape raw custom font names before Canvas and DOM consumption,
while preserving system family expressions. Keep Web-loaded aliases raw
and share the serialized expression across registration and loading.

Carry CssFontFamily through Label consumers and cover serialization,
TTF/CHAR selection, EditBox styles, and Web FontFaceSet loading in tests.

* fix(2d): preserve font names during scaling and refresh load metrics

Build CHAR draw descriptors from the scaled size and serialized family,
so unit-like substrings in font names are not rewritten by scaling.

Set the font before baseline measurement and read live Canvas metrics
during Web font polling instead of reusing cached fallback widths.
Add regression tests for the actual CHAR draw path and load completion.

* refactor(native): extract canvas font parsing

Move the existing platform-specific parsing into an internal helper and
return the family, size, and style flags to CanvasRenderingContext2D.
Preserve the existing matching rules, conversions, fallbacks, and update order.

Validated 12,650 comparisons with the original setFont implementation
across five platform macro variants.

* fix(native): restore serialized font aliases within legacy policy

Decode a single quoted CSS family into the descriptor used before TS
serialization. Adopt the result only when the existing platform parser
recognizes the complete registered alias; retain legacy fallbacks otherwise.

Cover existing aliases, escaped encodings, platform name restrictions,
style and size policies, and malformed inputs without expanding font support.

* fix(native): preserve size when a quoted font name falls back

Keep a valid requested px size when a well-formed quoted font family is
rejected on Apple or QNX, while retaining the existing fallback font and
style flags. Leave malformed prefixes, lists, and unsafe sizes unchanged.

Preserve the existing size conversion on other native platforms.

* fix(2d): resolve font family types in bundled declarations

* test(2d): cover explicit native font alias compatibility

* fix(2d): resolve font CI lint diagnostics

Allow implicit move of the native font parsing result and wrap EditBox placeholder CSS without changing its output.

Validation: targeted clang-tidy check, ESLint with zero warnings, 13 native parser tests, and 2062 font policy comparisons.
2026-10-27 10:06:11 +08:00
Cocos Robot 5b0b4522c0 [ci skip][AUTO]: Automated code generating update: 363f009a13 (#367) (#375)
Co-authored-by: cocos-robot <cocos-robot@cocos.com>
2026-10-23 11:26:07 +08:00
Tianze-Chen a803406ef1 fix(2d): allocate Graphics GPU buffers on demand (#373)
Every Graphics sub-model pre-allocated a 65536-vertex / 131072-index buffer, which is about 2.25 MiB with the 32-byte graphics vertex, while a rect or ellipse mask only needs a few hundred bytes. The cost accumulates with every mask that draws its own geometry.

Allocate the buffers from the chunk data when the sub-model is created, grow them by powers of two when the geometry outgrows them, and never shrink, so a dynamic graphic no longer re-creates its GPU buffer every frame.

Keep the ceiling at the uint16 addressable limit of 65536 vertices. The assembler does not split a single fill()/stroke() batch, so a batch of exactly 65536 vertices has to fit; capping the buffer at 65535 would upload 32 bytes past its end.

UIModelProxy used to resize the buffers to the exact data size on every upload, which re-created them whenever the geometry changed, and on Metal/Vulkan the old buffer stays alive until the GPU is done with it. It now follows the same grow-only policy and passes the valid size to update() explicitly.

Refs: cocos/cocos4#371

Co-authored-by: Engineer <engineer@cocos.com>
2026-10-23 11:23:29 +08:00
Cocos Robot d0a696cfe6 [ci skip][AUTO]: Automated code generating update: 996f2fe20a (#369) (#370)
Co-authored-by: cocos-robot <cocos-robot@cocos.com>
2026-10-19 14:31:30 +08:00
yangchao 0616a948ef fix(audio): iterator invalidation、exit crash issue。 (#360)
* fix(audio): iterator invalidation when call stopall in finish callback

* fix(audio): prevent callback crashes and cache teardown hangs on Apple platforms

---------

Co-authored-by: yangchao <1162486779@qq.com>
2026-09-24 11:25:09 +08:00
yangchao ee89a99a9b fix(v8): fix iterator invalidation when removing handled promises (#357)
* fix(v8): fix iterator invalidation when removing handled promises

* fix(native): prevent iterator invalidation in callbacks and scheduler
2026-09-23 16:28:56 +08:00
llsansun f620989ce7 The final set skeleton call destroys and rebuilds the GPU bone reso… (#359)
* The final `set skeleton` call destroys and rebuilds the GPU bone resources that were bound in the previous two steps. However, the descriptor set is not rebound. As a result, the draw call for this subModel cannot access the bone matrices, so the entire character fails to render (this is not vertex deformation; the character does not appear at all). The fix should replace the reference in `descriptor.buffer` with the new buffer, mark it dirty, and lazily rebuild the descriptor before the next draw.

* opt
2026-09-23 16:18:03 +08:00
Cocos Robot 82f13c86e9 [ci skip][AUTO]: Automated clang-format update: d67d6ac324 (#341) (#342)
Co-authored-by: cocos-robot <cocos-robot@cocos.com>
2026-09-20 17:22:37 +08:00
zxx43 0fd910220e reset bone.active after updateCache (#340)
* reset bone.active after updateCache

* upload version
2026-09-20 10:13:12 +08:00
MagicX 557b06f7e6 fix(scene): LOD screen usage distance truncated to int (native platform) (#343)
* 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

* perf(pipeline): reduce render queue sort to two packed key compares (native platform).

* fix CI error caused by native/cocos/base/Utils.h

* fix(scene): LOD screen usage distance truncated to int (native platform)
2026-09-17 18:59:26 +08:00
MagicX b46553e615 perf(pipeline): reduce render queue sort to two packed key compares (native platform). (#341)
* 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

* perf(pipeline): reduce render queue sort to two packed key compares (native platform).

* fix CI error caused by native/cocos/base/Utils.h
2026-09-17 09:35:05 +08:00
Cocos Robot 2ce7b89be5 [ci skip][AUTO]: Automated clang-format update: ffc817b76f (#336) (#337)
Co-authored-by: cocos-robot <cocos-robot@cocos.com>
2026-09-14 17:02:34 +08:00
MagicX 60f9352c56 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
2026-09-14 14:10:33 +08:00
MagicXHouse a3c3fcbea5 Changed the GeometryRenderer and DebugRenderer from using intrusive calls to registering callbacks. (#330)
* 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
2026-09-08 19:35:05 +08:00
Ming df98a99bb6 fix(wgpu): correct swapped maxComputeWorkGroupSize/Count capabilities (#327)
Co-authored-by: vanitynie <vanitynie@qq.com>
2026-09-07 19:00:55 +08:00
zxx43 69d3d6033a fix message error (#304) 2026-08-24 11:13:30 +08:00
yangchao 469614cf0b fix ios build problem (#292) 2026-08-23 12:01:54 +08:00
Cocos Robot f81094f226 [ci skip][AUTO]: Automated clang-format update: 6c156997c2 (#293) (#301)
Co-authored-by: cocos-robot <cocos-robot@cocos.com>
2026-08-23 11:07:26 +08:00
troublemaker52025 09b63786f4 fix(legacy): sync instanced buffer batching optimization to native (#293) 2026-08-20 15:56:12 +08:00
MagicXHouse 2b7b438768 Fix: Fixed the issue where custom pipeline profiler were not displaying. (#295) 2026-08-20 11:26:22 +08:00
Cocos Robot 140068ddb1 [ci skip][AUTO]: Automated code generating update: 233020bafe (#287) (#288)
Co-authored-by: cocos-robot <cocos-robot@cocos.com>
2026-08-16 18:22:23 +08:00
hyde zhou 80a9d0619e ignore cocos-version.h (#287) 2026-08-16 18:17:09 +08:00
Cocos Robot a01046e391 [ci skip][AUTO]: Automated clang-format update: 25bf4eb07b (#284) (#285)
Co-authored-by: cocos-robot <cocos-robot@cocos.com>
2026-08-16 17:13:20 +08:00
Cocos Robot 2b6ec3b4f0 [ci skip][AUTO]: Automated code generating update: cdd07414a3 (#278) (#284)
Co-authored-by: cocos-robot <cocos-robot@cocos.com>
2026-08-16 17:07:21 +08:00
Cocos Robot 6060f58d1a [ci skip][AUTO]: Automated clang-format update: 3a76374539 (#277) (#278)
Co-authored-by: cocos-robot <cocos-robot@cocos.com>
2026-08-16 17:01:44 +08:00
hyde zhou 18456b6706 try fixing previous clang format ignore (#277) 2026-08-15 23:32:02 +08:00
hyde zhou 62b55a0c48 Revert "fix: exclude spine 4.2 third-party files from clang-format (#273)" (#275)
This reverts commit 01983b75f2.
2026-08-15 20:17:08 +08:00
Copilot 01983b75f2 fix: exclude spine 4.2 third-party files from clang-format (#273) 2026-08-15 18:34:08 +08:00
jk20012001 2d003cc616 fix punctual lights visibility issue with custom pipeline (#270) (#272) 2026-08-15 15:36:26 +08:00
troublemaker52025 3ab299035a fix(legacy): Mask component stencil test error for native (#266) 2026-08-14 15:49:57 +08:00
hyde zhou 97e402c3dc Merge pull request #255 from cocos/v4.0.0-alpha.29
update version, fix libwebp compile err. (#247)
2026-08-08 17:44:37 +08:00
troublemaker52025 a0a2e97c00 fix(legacy): A2C (Alpha to Coverage) and (antialias or MSAA) are mutually exclusive (#233) 2026-08-07 16:27:27 +08:00
Ming 0a21bb9397 fix(vulkan): fix split barrier events and general barrier submission (#240) 2026-08-07 16:03:46 +08:00
yangchao 4992692780 update version, fix libwebp compile err. (#247) 2026-08-05 16:11:33 +08:00
zxx43 e778833d15 modify success log level from loge to logd 2026-08-05 12:05:12 +08:00
yangchao 2c0e75059f xcode > 14.3 apple silicon use arm64 arch for ios simulation。 (#214) 2026-08-02 17:52:06 +08:00
zxx43 19f4bd5b16 call ClearMaterialCaches when change tint state (#234) 2026-07-31 17:24:28 +08:00