Fix cross-platform rendering and optimize frame performance
Correct selection orientation, game-entry lifecycle, mounted NPCs, labels and skill panels. Add the native GPU scene path, resident geometry, bounded texture and Python caches, and collision broad phase. Pin the independently maintained Metin2 SDK through a submodule and document reproducible setup. Include rendering regressions and macOS packaging improvements. Validation: client Debug build and 12 targeted client tests passed; SDK build and all 14 SDK tests passed.
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
# 进入游戏后只剩深色背景和残缺面板
|
||||
|
||||
调查日期:2026-10-10。对应用户 22:59:30 跨平台截图和 22:58:05 Windows 截图。
|
||||
|
||||
## 已复现的初始化阻塞
|
||||
|
||||
在当前 `dist/AVA2.app/Contents/MacOS` 工作目录运行发布包的同一个可执行文件,使用原版游戏阶段和模拟角色数据,游戏界面创建过程中报错:
|
||||
|
||||
```text
|
||||
InventoryWindow.LoadWindow.LoadObject
|
||||
RuntimeError: Failed to load image (filename: rework_inv/new_equipment_bg.tga)
|
||||
```
|
||||
|
||||
调用链为 `networkModule.SetGamePhase` → `game.GameWindow.__init__` → `interfaceModule.Interface.MakeInterface` → `__MakeWindows` → `uiInventory.InventoryWindow.__LoadWindow` → `InventoryWindowEx.py` → 图片加载。
|
||||
|
||||
此纹理确实存在:
|
||||
|
||||
- AVA2 原资源:`../AVA2/1. Client DEV/pack_maker/patch_design_wa/rework_inv/new_equipment_bg.tga`。
|
||||
- `patch_design_wa_create.xml` 中的虚拟路径是 `rework_inv/new_equipment_bg.tga`。
|
||||
- 跨平台项目根目录的 `rework_inv/new_equipment_bg.tga` 也存在,大小 79522 字节。
|
||||
- 发布包的 Resources、MacOS 相对目录和 `asset_manifest.json` 均没有 `rework_inv`。
|
||||
|
||||
`tools/pack_assets.py` 按固定目录列表打包,遗漏 `rework_inv`。`tools/package_macos.sh` 的相对资源链接同样是固定列表。打包清单的完整性校验只确认“列出的文件是否完整”,没有确认“原版游戏所需文件是否全部列出”。
|
||||
|
||||
`GameWindow(self)` 必须构造成功,才会传入 `SetPhaseWindow` 并成为当前游戏窗口。背包加载失败会调用原版 `exception.Abort`(记录异常、调用 `app.Abort`、`sys.exit`),使这一过程提前中止。此前创建的部分 UI 可以留下残缺面板。主循环根据实际 Python 窗口判断是否进入 game;地形和角色的主绘制分支依赖这个阶段,故界面构造失败也可能阻止世界显示。用户截图的精确实时阶段没有从进程中读取,不能仅凭图片确定其最后停留在哪个回调。
|
||||
|
||||
## 资源目录对照运行
|
||||
|
||||
同一个发布包可执行文件,参数为 `--phase game --preview-data --frames 20`,改在完整 `build/dev/test-rundir` 资源目录下启动后,原版游戏 UI 能完成创建,并输出包含地形、角色、背包和底部任务栏的截图。这排除了“完全没有游戏世界渲染实现”的解释,也验证了资源可见性是当前发布包的明确阻塞因素。
|
||||
|
||||
该实验是本地预览,未连接服务器;模拟位置、装备、镜头和场景与用户 Windows 截图不同,不能视为真实账号端到端通过。
|
||||
|
||||
## 其他已发现的问题和验证边界
|
||||
|
||||
- 发布包没有 `map/` 目录。`CPythonBackground::LoadMap` 查找相对的 `map/<name>`、`Maps/<name>`、`<name>` 和开发测试路径,没有完整的发布资源目录支持。补齐 UI 后仍需用真实地图坐标验证加载。
|
||||
- 完整资源运行仍报告部分树木纹理找不到,例如 `CompositeMapN2.dds`、`TreeWillowOakLeaves01SU.dds`、`CompositeMap.dds`。这些日志证明还存在场景纹理解析问题,尚未确定各文件的最终解析规则。
|
||||
- 上一份选角调查确认的图片池状态泄漏也会影响游戏 UI 的图片复用;其修复尚未应用。
|
||||
- `ava2.python_view` 的 game 测试使用 `runtime/login_view.py` 的简化 `SetGamePhase`,只是设置字符串状态,不会构造原版 `game.GameWindow`;因此不能发现本次背包资源异常。
|
||||
|
||||
修复方向:按原版 pack manifest 的虚拟路径构建完整运行资源根目录,并让脚本、图片、地图和纹理使用同一根目录;增加发布包原版 GameWindow 创建与加载→游戏阶段回归验证;随后处理图片池重置和世界纹理差异。
|
||||
|
||||
本次只调查并保留证据,没有修改生产代码或重新打包。日志和完整资源对照截图保存在忽略目录 `build/verification/game-investigation/`:`packaged.log`、`full-assets.log`、`full-assets.png`。
|
||||
|
||||
|
||||
## 2026-10-10 后续修复与真实账号验证
|
||||
|
||||
已实施以上调查中的资源打包和图片池修复,并用用户指定账号连接现有服务器测试,未改动服务器或 AVA2 参考目录。凭据仅通过测试进程环境提供。
|
||||
|
||||
真实加载流程还确认并修复了以下问题:
|
||||
|
||||
- `chr.Destroy()` 删除选角实例时清空了网络主角色 VID,导致镜头无法找到服务器上的角色;销毁后恢复网络流保存的主角色标识。
|
||||
- 131×131 的高度原始数据包含边界样本,地形块此前没有放到地图区块的位置。区块原点现在按 `block * 25600 - cellScale` 设置;地图物件的负 Y 转换到游戏的正地图 Y,同时把原生 Z 轴旋转转换为引擎 Y 轴旋转。
|
||||
- 新增角色包中的高度可能为 0,而地形高度约 17771;第一帧镜头避障把角色误当成地下物件,距离从 1550 收缩到 194。绘制和镜头检查前先按地形放置实际主角色。
|
||||
- SDL 的二维几何接口没有深度缓冲,之前却按近到远绘制不透明场景,远处地形覆盖角色。改为远到近,并保持地形混合层次。
|
||||
- 盔甲 DDS 的透明度通道包含高光信息。上传纹理时把低透明度像素的 RGB 清零、随后强制透明混合,造成角色身体消失或变黑。现在保留 RGB,并按材质是否透明决定混合模式。
|
||||
- 地表使用原始 tile.raw 的纹理分布和邻域混合,替代每个区块只选择一种主要纹理;小地图恢复采样实际 minimap.dds 地形,并在其上绘制原有角色标记。
|
||||
- 桌面使用原版任务栏,触控 HUD 仅在 Android 启用;实际服务器游戏不再运行预览角色的模拟移动/战斗更新。
|
||||
- 完整包由 pack 虚拟路径与 Windows 客户端散装界面图片共同生成。脚本根目录纳入清单,包内链接保持在包内,避免掩盖缺失文件的开发目录链接。
|
||||
|
||||
开发运行目录中的真实登录、选角、loading、game 流程已通过,主角色坐标 `(43303, 17771, 70856)`,镜头距离保持 1550。9 项相关回归测试通过;Android 核心编译通过。
|
||||
|
||||
精确 Windows 高光/光照、SDL 几何接口在复杂相交场景中的完整深度处理、相邻地形块流式加载,以及少数原始引用缺失的特效/植被纹理仍有差异。生成的验证截图和日志位于 `build/verification/game-fixed/`。
|
||||
|
||||
最终独立 macOS 包已用同一账号完成真实 loading → game;原版 GameWindow 的包内资源构造测试通过。包内外部符号链接为 0,真实登录退出后的严格签名验证通过。运行配置改为包外用户数据目录,最终截图为 `build/verification/game-fixed/packaged-game.png`。
|
||||
|
||||
## 2026-10-11 技能、操作和头顶显示修复
|
||||
|
||||
- 技能面板空白来自 `playerLoad.RegisterSkill` 空实现。按 AVA2 自己的 `PythonPlayerSettingsModule.h` 恢复职业/分支、第九技能、坐骑、辅助、语言和公会槽位,并在主角色加载时提前注册,保留加载阶段已收到的技能等级。
|
||||
- 属性派生值更新按 AVA2 原版触发条件重新计算,避免全量初始点数覆盖客户端计算结果。此项有回归覆盖;本次真实账号主要验证技能页,不代表所有属性数值已逐项与 Windows 核对。
|
||||
- 名字为黑色像素字:原生启动流程漏掉 `introLoading.__main__()` 的颜色/称号初始化,并使用 SDL 调试字体。恢复原版初始化,头顶文字改用界面的 FreeType 字体和真实文字宽度,保持 Retina 渲染比例。
|
||||
- 等级落在脚下:网络角色的 TextTail 默认高度仅 10,且停留在包中的 Z=0。登记时加入角色高度,每帧跟随实际渲染角色,并保持名字居中、等级和称号在左侧。
|
||||
- GM 标识的黄色线条和偏移来自矩形顶点、半尺寸/缩放、循环粒子上限、重力额外乘 9.8、发射向量强制归一化,以及附着粒子没有跟随角色。按 AVA2 `EffectLib` 行为修正;最终真实截图显示标识在头顶。
|
||||
- 键盘移动接口原为无操作,鼠标状态没有驱动真实角色。接通原版 Python 输入到服务器拥有的角色,支持相对镜头的方向键/WASD、地面点击/按住移动、右键镜头和镜头按键,发送移动和停止包。界面消费的滚轮优先留给界面,原生 F9 不再意外切换调试渲染器。
|
||||
- 游戏更新不再固定 33 毫秒;按实际帧间隔更新(上限 250 毫秒),失去窗口焦点释放按键。地图加载回调可能在帧内替换地形,使用前重新获取指针,避免访问已销毁地图。
|
||||
|
||||
验证:`ava2.player_panel`、`ava2.game_scene`、`ava2.game_entry` 3/3 通过,覆盖技能等级保留、派生属性、方向/对向/斜向输入、镜头按键释放、原版颜色初始化、粒子几何/上浮/附着。指定账号真实登录到 game,技能图标和等级有效;按键移动测试距离 1020,松开后位移 0。最终独立包再次登录并截图成功,证据在 `build/verification/input-label-fixed/`。没有保存账号密码或修改 AVA2/服务器。复杂场景帧率、完整战斗交互和精确 Windows 光照一致性没有在本次验证中完成。
|
||||
|
||||
## 2026-10-11 二次登录黑屏与倒退行走回归
|
||||
|
||||
- 根因一:`net.SetPhaseWindow` 的两处 C++ 强引用延迟了旧 `LoadingWindow` 的销毁。安装新加载窗口时,旧窗口析构中的 `SetPhaseWindow(LOAD,0)` 清除了新窗口,主角色的 `LoadData` 无法触发。现在先释放两处旧引用,再安装新窗口;测试用带析构回调的旧窗口和真实主角色包确认新回调仍然有效。
|
||||
- 同类问题还出现在 `player.SetGameWindow`:旧 GameWindow 析构调用 `SetGameWindow(0)`,可能覆盖新回调;数字 0 原来还被当作 Python 回调对象持有。现在归一化 0/None,并在新回调安装前完成旧对象销毁。连续 GameWindow 重建与快捷栏刷新通过。
|
||||
- 倒退行走:模型与骨骼世界矩阵额外加了 180 度,而位移方向未加。移除额外旋转;从真实战士 GR2 脚部/脚趾骨骼计算正面方向,验证绘制方向与运动方向一致。
|
||||
- 移动包时间:原生游戏时钟没有承接由 LoginSession 处理的初始服务器握手,可能发送本机 uptime。现在每个连接在加载交接时同步握手时间及已过间隔;原生收到没有对应握手的 HANDSHAKE_OK 时保留已同步时间。此处是已确认的时钟缺陷;没有读取服务器日志,因此不把用户报告的每一次退出都归因于服务器时间检查。
|
||||
- 原版 Python 可能 `exit(0)` 提前结束测试,game_entry 现在也要求最终完成标记,避免将未完成的构造流程误判为成功。
|
||||
|
||||
验证:5/5 相关 CTests 通过。指定账号在同一个客户端进程完成 game → login → selection → loading → game;第二次技能页、场景和角色正常显示,按键移动后继续运行 100 次游戏更新,连接仍有效,测试进程正常退出。没有改动原 AVA2 或服务器。日志与截图:`build/verification/relogin-facing-fixed/`。发布包与压缩包更新;这些实测覆盖一次连续重登和有限时长在线,不等同于长时间稳定性验证。
|
||||
|
||||
## 2026-10-11: selection facing, NPC outfits, and measured frame cost
|
||||
|
||||
The selection regression came from removing the universal 180-degree model rotation to correct locomotion. The original Windows `chr.SetRotation` adds 180 degrees at the script API boundary; restoring that conversion fixes selection without changing network locomotion. Script position getters now also invert the reflected showcase Y coordinate consistently. The live selection screenshot shows the warrior's face again, and the GR2 toe-direction regression still confirms that gameplay mesh forward agrees with movement.
|
||||
|
||||
The eight teacher NPCs (61000–61007) share `old_master_M` as their base entry in `npclist.txt`. Windows replaces this through `locale/common/npc_wear.txt`, including races 0–7 and outfits 34100/34101. The bundled Python pack mount previously searched only `Resources/root`; the configuration exists in sibling `Resources/locale/common`. Pack reads now search the script mount first, then the bundle asset mount identified by its manifest, preserving case-insensitive lookup and traversal rejection. The NPC query also uses the background's current warp map, matching the Windows query instead of an unassigned string. Live logs confirm eight distinct requested race/model combinations, and `scene-final.png` shows the configured outfits.
|
||||
|
||||
`app.SetCamera` previously updated the Python-side camera without updating the host orbit camera, while `app.GetCamera` returned stale values after input. A consumed setting request now updates the host camera and host feedback updates the Python values. The live scene probe verifies a requested 180-degree view and an active connection.
|
||||
|
||||
The delivered binary had been built as Debug (`-g`, no optimization). A macOS `sample` also found per-frame rebuilding of static map-object geometry. Static object draw commands are now cached for their lifetime and released with the map; this trades some retained geometry memory for reduced construction work. Packaging now explicitly configures RelWithDebInfo (`-O2`) in `build/release`, retaining symbols for crash diagnosis.
|
||||
|
||||
Measured on this machine, the authorized test account at approximately (441,716), 2048x1536 output, same 1550-distance/15-degree/180-degree NPC camera:
|
||||
|
||||
| Build | Representative stable total frame cost | Approximate rate |
|
||||
| --- | --- | --- |
|
||||
| Debug, corrected NPC assets and static cache | 239–241 ms | 4.2 FPS |
|
||||
| RelWithDebInfo, corrected NPC assets and static cache | 25.0–25.2 ms | 40 FPS |
|
||||
|
||||
The optimized default camera measured 21–22 ms (45–47 FPS). These are short live samples, not a guaranteed rate across maps; initial asset loading and screenshot capture frames are excluded. Windows screenshot parity still has gaps in mounted NPCs, foliage, sky/environment, and depth handling; SDL geometry currently uses painter ordering rather than a hardware depth buffer. The old screenshot's camera, location, and aspect ratio also differ from the reference, so it cannot establish pixel parity by itself.
|
||||
|
||||
Evidence: `build/verification/npc-performance/{baseline.sample,debug-comparison.log,scene-final.log,select-final.png,scene-final.png,targeted-final-tests.log}`. Regression checks cover bundle pack mounting and NPC map precedence, presentation versus movement orientation, camera setter/feedback, select rendering, and entering the game twice.
|
||||
|
||||
Final targeted verification: eight relevant tests passed (pack mount, player panel/camera, select render, game scene, game entry, GR2 render, chr API, background). The broader `ava2.python` suite still fails a pre-existing missing-icon fixture assumption against the populated asset root; isolating that fixture reveals an older formula-status expectation (100.5 versus 90.5 after derived-status recalculation). Those unrelated fixture/status expectations were not changed for this rendering patch. The final facing implementation restores the Windows script boundary conversion rather than introducing an actor-wide rendering offset.
|
||||
|
||||
### 2026-10-11 Hardware depth, frame pacing and mounted NPCs
|
||||
|
||||
- Added a native SDL_GPU scene pass with persistent vertex/index buffers, depth testing/writes, alpha testing, D3D-style culling and perspective-correct texture interpolation. Metal is verified on this host; the Vulkan SPIR-V shaders compile but Vulkan runtime is not verified. CPU model transforms, lighting and fog remain CPU work.
|
||||
- Upload decoded textures on the scene GPU queue before sampling. Borrowing SDL_Renderer textures produced a blank first frame because their queued uploads were not submitted until Present. Composite the scene with premultiplied alpha so the original selection background survives.
|
||||
- Cache tinted text masks (512 entries / 16 MiB) instead of creating/destroying textures for every label. Cull static objects by conservative world bounds before copying mesh commands. Keep collision geometry intact. Disable GPU validation in normal release builds; AVA2_GPU_DEBUG enables it for diagnostics.
|
||||
- Move the 60 Hz deadline wait immediately before presentation and use SDL_DelayPrecise. The frame CSV distinguishes active CPU work, geometry assembly, raster encoding and presentation intervals; loading and screenshots are excluded from steady-state statistics.
|
||||
- Port the reference sky's vertical cube gradients, environment cloud scale/height/alpha and lens-flare enable conditions. This removes the invented cloud/flare appearance in C1.
|
||||
- Render mount actors and attach riders through the animated saddle bone. Convert native Z-up bone matrices before world attachment. Register the reference horse wait/walk/run/dead motions for all eight PC races, and resolve the active motion mode at playback time: riders no longer stand on mounts, and an armor rebuild preserves the riding pose. A real GR2 leg-pose regression checks riding, armor rebuild and dismount restoration.
|
||||
- Validation: 10 targeted Debug CTests pass, including native Metal depth/alpha/culling/perspective/first-texture/background pixels, font renderer lifetime, conservative frustum rejection, sky configuration and mounted animation. Live selection, NPC/mount scene, movement/orbit and same-process re-login were exercised with the authorized account. No credentials are stored in source or documentation.
|
||||
- Remaining Windows parity gaps: SpeedTree still generates approximate foliage rather than decoding the original SPT geometry; outdoor rendering still lacks full adjacent-tile streaming; original specular/sphere-map shading is not complete. Performance evidence covers the measured local Metal scene, not every map or long-running session. Existing unrelated broad-Python-suite fixture/formula failures remain unchanged.
|
||||
|
||||
- Final signed-bundle measurement: 2,400 game updates (~40 s), 2,359 steady-state samples after the first 40 updates; average 60.000 FPS, presentation interval P95 16.723 ms / P99 16.765 ms, active CPU work P95 10.424 ms / P99 11.313 ms. Two intervals exceeded 20 ms (maximum 23.478 ms); this is not a claim of zero dropped frames. Full camera orbit, short W movement and connection checks at updates 1,190 and 2,390 passed. Evidence: `build/verification/gpu-depth/final-stress.csv`, `final-stress-summary.json`, `final-stress.png`, `riding-tests.log`. Signed app: `dist/AVA2.app`; release archive updated from that bundle.
|
||||
- Final packaged re-login probe also passed after the riding fix: second GameWindow and skill page rendered, movement completed, and the connection remained live for the following 100 updates (`build/verification/gpu-depth/final-relogin.log`).
|
||||
@@ -0,0 +1,176 @@
|
||||
# 跨平台客户端性能调查(2026-10-11)
|
||||
|
||||
## 结论与测量范围
|
||||
|
||||
目前最值得优化的是 CPU 端渲染准备和角色网格生成,而不是继续调整限帧或优先重写 UI。代码检查发现的主要成本包括:重复生成/复制网格、CPU 顶点变换和蒙皮、全体角色渲染、反复求骨骼姿态、切换动作时同步加载动画。
|
||||
|
||||
本次只调查并记录,不修改客户端运行逻辑、资源包或服务器。
|
||||
|
||||
使用当前签名的 RelWithDebInfo/Metal 客户端,在已授权账号所在的 NPC/坐骑场景做两次固定视角运行:一次 8 秒 macOS `sample` 调用栈采样,一次不采样的 1,200 帧对照。不移动账号。剔除前 40 个游戏更新,保留 1,159 帧:
|
||||
|
||||
| 对照指标 | 实测 |
|
||||
| --- | --- |
|
||||
| 平均 FPS | 60.000 |
|
||||
| 平均有效 CPU 帧耗时(不含限帧等待) | 7.117 ms |
|
||||
| 场景组装平均 / P99 | 2.920 / 3.295 ms |
|
||||
| 渲染准备与提交平均 / P99 | 3.173 / 3.410 ms |
|
||||
| Present 平均 / 最大 | 0.153 / 11.351 ms |
|
||||
| 可见帧间隔 P99 / 最大 | 17.698 / 27.938 ms |
|
||||
| 超过 20 ms 的间隔 | 1 |
|
||||
|
||||
采样中的主线程共有 4,953 个样本,其中 2,871 个位于主动限帧等待。排除该等待后:渲染准备 969 个(约 46.5%),角色绘制生成 721 个(约 34.6%),背景组装 123 个(约 5.9%),UI 更新、绘制和脚本回调 190 个(约 9.1%)。这是调用栈样本占比,不是精确 CPU/GPU 时间。
|
||||
|
||||
采样运行第 80 帧出现 521 ms 停顿,与启动采样的时间接近;不采样对照没有复现同类场景组装停顿。其原因未确认,不把它作为某段客户端代码耗时 500 ms 的证据。对照仍有一次 Present 波动,需要 GPU 时间和系统调度证据才能解释。
|
||||
|
||||
`raster_ms` 包含 CPU 变换、命令编码和提交,不等于 GPU 执行时间。现有证据不能证明 GPU 已经满载。采样进程物理内存约 1.3 GB,也不能据此认定存在泄漏。
|
||||
|
||||
## 优先优化项
|
||||
|
||||
### 1. 避免每帧搬运和重复处理网格(P1,实测热点)
|
||||
|
||||
`src/eter_render/Gr2ModelRenderer.cpp:830` 每个顶点仍在 CPU 做世界/视图/投影变换、法线归一化、光照和雾。原 SDL 几何回退使用的屏幕坐标也在硬件路径计算,但硬件分支只消费裁剪坐标。
|
||||
|
||||
`:919` 又把变换后的顶点从临时数组拷入硬件顶点数组,`:920` 和 `:922` 两次遍历索引(合法性检查与追加)。`HardwareScene.cpp:150` 进一步复制到传输缓冲,每帧上传完整顶点和索引。
|
||||
|
||||
静态物体虽已缓存几何,但 `MapObjectManager.cpp:363` 将缓存的 Render3DDraw 深拷贝到每帧列表;静态顶点、法线、UV、索引仍跟随 CPU/GPU 数据流反复搬运。调用栈直接显示顶点整理和变换循环占据大量样本。
|
||||
|
||||
建议顺序:
|
||||
|
||||
1. 硬件路径跳过回退专用屏幕坐标计算;静态索引在资源加载时验证;复用帧数组容量。
|
||||
2. 将不可变几何与逐帧矩阵/材质参数分开,命令只引用几何,避免深拷贝。
|
||||
3. 静态建筑、地形的顶点/索引常驻 GPU;着色器接收矩阵、光照和雾参数。
|
||||
4. 动态角色先只更新蒙皮数据,最终再迁移 GPU 蒙皮。
|
||||
|
||||
具体节省毫秒数必须在实现后测量,不能把本项的约 3 ms 当前总耗时当成全部可消除的成本。GPU 改写必须保持现有坐标、深度、雾、Alpha 和材质行为。
|
||||
|
||||
### 2. 角色先裁剪再蒙皮,复用骨骼姿态(P1,实测热点)
|
||||
|
||||
`NetworkActorManager.cpp:896` 只跳过隐藏角色,没有根据视锥裁剪角色及坐骑。SDK `gr2_model_instance.cpp:427` 为每个角色求姿态、分配数组并逐顶点 CPU 蒙皮,之后附件也会生成网格。相机背后的角色仍消耗这些成本。
|
||||
|
||||
SDK `GetBoneWorldTransform` 每次查询一个骨骼也会创建数组并重新求整个骨架姿态。骑乘更新查询鞍座,绘制时再查一次;装备、特效和其他挂点查询可能继续重复。`gr2_skeleton.cpp:sample_pose` 每次创建骨骼名字到索引的哈希映射和临时矩阵数组。
|
||||
|
||||
建议:使用保守动画包围盒/球在生成网格前裁剪;角色和挂件共享“本模型、本动画、本时间”的姿态缓存;预计算骨骼索引和动画轨道绑定。进一步加入距离 LOD 和远处动画更新频率。网络、移动、战斗逻辑继续每帧正常更新,不能通过停止不可见角色逻辑来节省耗时。模型或动画切换必须使缓存失效。
|
||||
|
||||
这是人多、怪多的地图最需要处理的扩展性问题。当前场景收益不代表百人场景收益,需补密集角色基准。
|
||||
|
||||
### 3. 动画/模型资源共享与预热(P1,代码确认,瞬时收益待测)
|
||||
|
||||
`ActorInstance.cpp:275` 播放动作调用 LoadExternalAnimation;SDK `gr2_model_instance.cpp:71` 每次读取并解析 GR2,没有已解析动画缓存。切换 Wait/Run、攻击动作时可能再次发生同步读取和解析。`ActorInstance.cpp:33` 也为每个装备实例直接加载模型,底层实例独占解析后的 File。
|
||||
|
||||
建议按规范化资源路径共享不可变的已解析模型/动画,角色实例仅保留播放时间、部件和姿态。预热当前角色及附近 NPC 的常用动作;未命中资源的读取和解析可放到受控工作队列,GPU 创建/提交仍走正确线程。保持 Python 2 回调和现有加载顺序语义。
|
||||
|
||||
优先测量持续走停、连续攻击和装备切换的 P99/最大帧耗时;静止场景采样无法量化这些交互尖峰。可同时减少重复解析占用的内存。
|
||||
|
||||
### 4. 地形 patch 缓存、材质合批及实例绘制(P2,代码确认)
|
||||
|
||||
`TerrainHeightmap.cpp:625` 每帧重新构建可见 patch。`:711` 多层纹理混合会复制同一组顶点,并重算 tile 权重、alpha 和索引。已存在视锥四叉树和两档距离 LOD,但没有 patch/LOD 几何缓存。
|
||||
|
||||
建议以地图、patch、step、纹理版本为键缓存不可变几何;只更新可见集合。相同建筑/树木用共享网格与实例矩阵;相同状态的相邻批次减少重复 pipeline/纹理绑定。当前硬件分支仍按旧 SDL 回退的远到近规则对不透明物体排序;可与回退分开,利用深度缓冲按材质/近到远组织。
|
||||
|
||||
不透明物体可重新组织;水、粒子等透明物体仍须保持正确顺序。地形混合层不能随意重排,不能为了合批删除 Windows 已有的纹理层。补密集树木和多层地形场景再量化收益。
|
||||
|
||||
### 5. GPU 时间、提交波动和资源内存预算(P2,需要补证据)
|
||||
|
||||
HardwareScene 持有整帧动态缓冲和 GPU 纹理缓存;软件纹理缓存还保留 RGBA 数据。减少静态网格上传、清理不再使用的地图纹理,有望降低带宽和内存压力。此处是资源生命周期优化,不是已经证实的泄漏。
|
||||
|
||||
需要补 CPU/GPU 分段时间、上传字节数、常驻纹理/模型字节数、每帧 draw 数及多次换图后的内存变化。尤其要区分偶发 Present 等待、驱动提交与 CPU 资源解析。不能仅用 SDL_SubmitGPUCommandBuffer 返回耗时判断 GPU 工作量。
|
||||
|
||||
### 6. Python/UI 与碰撞(P3,次要)
|
||||
|
||||
主循环 `main.cpp:2234` 每帧通过 PyRun_SimpleString 编译同一段 OnUpdate/OnRender 调度代码,可缓存 code object 或直接调用回调,并继续正确处理阶段窗口切换。
|
||||
|
||||
UI 更新、渲染树还有每帧遍历成本,可让稳定属性/文本按数据变更刷新;不应直接降低整套 UI 更新频率而破坏交互。当前它们约占非限帧样本 9%,优先级低于渲染和角色。
|
||||
|
||||
`MapObjectManager.cpp:308` 的移动碰撞遍历全部对象;可用网格/BVH 做宽阶段筛选。静止对照没有证明它是热点,应先在连续移动和复杂建筑地图测量。不要以减少碰撞检查精度换帧率。
|
||||
|
||||
## 建议实施与验收顺序
|
||||
|
||||
1. 先做角色视锥裁剪、每帧骨骼姿态复用、硬件路径去除无用计算;属于较集中、易核对的改动。
|
||||
2. 加入已解析动画缓存,实测走停/攻击/装备切换尖峰。
|
||||
3. 重构几何引用,静态网格常驻 GPU,再迁移顶点变换和蒙皮。
|
||||
4. 地形缓存、树木/建筑实例化和安全材质合批。
|
||||
5. 用更细分 CPU/GPU 计时确认余下热点,再决定 UI 或碰撞优化。
|
||||
|
||||
每步以同机同分辨率、同场景前后对照验证平均、P95/P99/最大帧耗时,而不只看 60 FPS 上限。至少覆盖固定视角、相机旋转、持续移动/攻击、密集 NPC、骑乘、重新登录;每步保留渲染和协议回归。
|
||||
|
||||
## 原始证据
|
||||
|
||||
- `build/verification/performance-audit/cpu-sample.txt`:8 秒主线程调用栈。
|
||||
- `build/verification/performance-audit/frames.csv`:有采样运行,存在测量干扰可能。
|
||||
- `build/verification/performance-audit/control-frames.csv`、`control-summary.json`:无采样对照。
|
||||
- `build/verification/performance-audit/client.log`、`control.log`:运行日志。
|
||||
|
||||
## 本轮已实施优化
|
||||
|
||||
- 在共享 SDK `sdk/gr2` 中缓存不可变的解析后 GR2 文件,模型和动画共用缓存,实例播放状态和附件仍独立。以规范化路径、文件大小、修改时间判断资源版本;失败加载不缓存。强引用保留上限 64 项 / 128 MiB 源文件字节(并非解析后总内存预算),活跃实例保留自己的共享所有权。
|
||||
- 同一模型、动画和时间只求一次骨骼姿态,挂点查询、网格和附件复用结果;预先绑定轨道名字到骨骼索引,重复使用矩阵数组。动画切换显式失效。测试与原始 sample_pose 的腿部矩阵对照,检查时间推进、动画切换和实例隔离。
|
||||
- 角色/坐骑使用带动画与附件余量的保守包围盒,在生成网格前裁剪。主角色始终保留;没有矩阵时保留原行为。网络和移动更新不因裁剪停止。
|
||||
- 建筑 draw 命令引用不可变几何,避免每帧深拷贝;地形按 patch 与细节步长缓存同类命令。高度、tile、纹理或世界原点更新使缓存失效。软件与 GPU 路径均从同一 Mesh 引用读取几何;材质和变换仍为逐命令状态。
|
||||
- 原生 GPU 路径不再计算仅供 SDL 回退使用的屏幕坐标。
|
||||
- 实机正常退出曾暴露小地图图片引用晚于资源管理器销毁的问题。PythonRuntime 显式销毁小地图;主循环在 SDL renderer 仍存活时释放 Python/UI 资源,修复该退出崩溃。
|
||||
|
||||
固定视角、同账号同场景、1,200 帧对照(剔除前 40 帧):有效 CPU 平均耗时从 7.117 ms 降到 5.423 ms,减少 23.8%;场景组装从 2.920 ms 降到 1.838 ms,减少 37.1%。优化后平均 60.000 FPS,间隔 P99 16.792 ms,最大 17.041 ms,1,159 个稳态样本没有超过 20 ms 的间隔。这是一次本机场景对照,不是所有地图的性能保证。
|
||||
|
||||
11 项相关 Debug CTests 通过:增加了解析资源复用/同路径更新失效、骨骼缓存正确性、骑乘与装备重建、视锥拒绝不求姿态、地形与静态几何复用/失效、GPU 共享几何像素与独立材质状态检查。证据在 `build/verification/performance-audit/optimized-summary.json`、`optimized-frames.csv`、`optimized-final-tests.log`、`optimized.png`。
|
||||
|
||||
进一步的静态缓冲常驻 GPU、GPU 顶点变换/蒙皮、实例绘制、完整资源内存预算、UI 调度和碰撞空间索引仍未实施。本轮先处理已证实热点,保留现有透明排序、材质和协议行为。
|
||||
|
||||
- Final signed-bundle validation: 2,400-frame camera-orbit/short movement probe passed both connection checks; 2,359 steady-state samples averaged 60.000 FPS, interval P99 16.811 ms, active mean 5.669 ms, with two >20 ms intervals (max 22.489 ms). Same-process re-login rendered the second game/skill window, completed movement, remained connected for 100 further updates and exited cleanly. Evidence: `optimized-orbit-summary.json`, `optimized-orbit.log`, `optimized-relogin.log` under build/verification/performance-audit. Signed `dist/AVA2.app` and its archive updated.
|
||||
|
||||
## 2026-10-11 静态缓冲、GPU 蒙皮与实例绘制
|
||||
|
||||
本轮完成了上一轮保留的三项主要渲染优化:
|
||||
|
||||
- 原生 Metal/Vulkan 顶点着色器处理世界/视图/投影变换、法线变换、光照和雾。显式使用行向量,保持旧 D3D/CPU 矩阵语义;旧预变换输入仍可用于像素对照。SDL uniform/storage 资源布局参照官方 SDL_CreateGPUShader 和 SDL_PushGPUVertexUniformData 文档。
|
||||
- 建筑、地形 patch 和角色的不可变顶点/索引存入常驻 GPU 缓冲。每帧更新矩阵、材质和骨骼 palette,动态水面/树木风动画/部分效果仍使用动态缓冲。常驻网格按实际 GPU 缓冲字节计算 256 MiB 的软保留预算,超限时释放至少两帧未使用的条目;活跃工作集可以超过预算以避免反复上传。资源版本以不可变几何所有权区分,转换缓存同时检查源对象所有权,防止地址复用错误。
|
||||
- SDK 输出原始顶点、权重和 palette 并缓存网格模板,由顶点着色器执行蒙皮。头发/盔甲部件保留各自 inverse bind pose 重映射;骨骼挂点和坐骑鞍座继续由已缓存的 CPU 骨骼姿态提供。零权重或无效绑定保持原始顶点,最多支持 128 个 palette 骨骼;更大 palette 自动使用 CPU 蒙皮。软件渲染/F6 切换保留 CPU 路径,AVA2_CPU_SKINNING 可用于对照。
|
||||
- 相同建筑模型共享几何。不透明绘制按网格/材质组织,通过实例矩阵 storage buffer 合并相邻兼容命令。骨骼 palette 不同的角色、透明/加法混合命令继续单独绘制。当前 NPC 场景 182 批合为 181 个实际 draw,密集重复建筑场景的收益需另测;没有把这一场景的主要收益归因于实例绘制。
|
||||
|
||||
### 实测与限制
|
||||
|
||||
同账号、同位置、同视角,原签名程序与新签名程序依次运行 1,200 个游戏更新,剔除前 40 帧,分别保留 1,159 帧:
|
||||
|
||||
| 指标 | 修改前 | 修改后 |
|
||||
| --- | --- | --- |
|
||||
| 有效 CPU 工作平均 | 5.976 ms | 3.491 ms(-41.6%) |
|
||||
| 场景组装平均 | 1.957 ms | 1.058 ms |
|
||||
| 渲染准备/提交平均 | 2.918 ms | 0.807 ms(-72.3%) |
|
||||
| Present 平均 | 0.132 ms | 0.290 ms |
|
||||
| 帧间隔 P99 | 16.832 ms | 17.038 ms |
|
||||
| 平均 FPS | 60.000 | 60.001 |
|
||||
| 超过 20 ms 的稳态间隔 | 0 | 0 |
|
||||
|
||||
CPU 余量明显增加,但这次固定视角样本的帧间隔 P99 并没有改善,不能只据平均 CPU 耗时宣称所有顿挫已消失。渲染准备/提交时间也不等于 GPU 硬件执行时间,需要后续 GPU 时间戳或图形捕获。
|
||||
|
||||
最终签名包的 2,400 帧旋转/短行走测试:平均 60.000 FPS,CPU 平均 3.588 ms,帧间隔 P99 17.020 ms;2,359 个稳态样本有一次 >20 ms(最大 25.284 ms)。连接检查在第 1,190 和 2,390 更新通过。同进程重新登录显示第二个游戏/技能窗口,移动后再保持 100 更新连接,并正常退出。
|
||||
|
||||
固定视角的常驻网格约 20.3 MB,累计上传次数在稳态保持 169 不变;旋转后已见网格约 91.1 MB,累计上传 710 次,返回原视角不再上传这些网格。固定视角每帧动态顶点/索引约 0.97 MB(不含实例/骨骼 uniform 和纹理上传)。
|
||||
|
||||
11 项相关 Debug CTests 全部通过。新增验证覆盖:GPU 两骨骼加权旋转像素与 CPU 参考、逐顶点/法线 CPU-GPU 蒙皮等价(含头发和武器)、常驻缓冲跨帧不重传、实例矩阵/材质隔离、非零 firstInstance、透明命令不合并、相同建筑网格共享与独立 world 变换。现有深度、Alpha、透视、选择、骑乘、背景和重登录测试保留。
|
||||
|
||||
已验证 Metal;Vulkan SPIR-V 重新生成并编译通过,但没有 Vulkan 运行验证。早期两次自动登录超时,随后登录成功;未把未确认原因归因于渲染,也未修改协议或账号凭据。
|
||||
|
||||
证据:`build/verification/gpu-resident/` 的 baseline-current-scene/resident-current-scene/resident-orbit CSV、summary、日志和截图,以及 final-tests.log。已更新签名 app 与压缩包。
|
||||
|
||||
进一步优化项仍包括:真正的树木实例化/风动画着色器、GPU 时间测量、全部模型/纹理的内存预算、Python 调度缓存、碰撞空间索引,以及更密集角色/建筑和多次换图的长时间基准。原始 SpeedTree/SPT、跨 tile 地形和 specular 渲染差异不属于本轮实现。
|
||||
|
||||
## 2026-10-11 纹理预算、Python 调度缓存与碰撞索引
|
||||
|
||||
- 3D 解码图片缓存默认 64 MiB / 256 项;原生 GPU 和 SDL 回退纹理缓存默认 256 MiB。缓存淘汰只发生在安全的帧边界。GPU 当前帧正在引用的纹理及软件渲染当前工作集受保护,因此 GPU/软件路径预算是软上限;原生 GPU 路径在已上传纹理命中时绕过 CPU 解码缓存,允许安全释放上传后的 RGBA 副本。GPU 预算按 RGBA 逻辑图片字节计算,不代表驱动实际 VRAM,也没有管理 UI 图片池、全部模型或整进程内存。
|
||||
- 超预算时按最近使用淘汰不活跃纹理;重新使用会重载。纹理集合未超预算时跳过淘汰候选集合构建,避免在正常热路径新增分配。
|
||||
- PythonRuntime 缓存编译后的代码对象(最多 64 项 / 128 KiB 源文本,超过 16 KiB 的单段不保留)。每次仍在当前 __main__ 字典执行,窗口/回调切换不会固定旧对象;语法/运行错误保留原错误路径。销毁及构造失败清理在 Py_Finalize 前释放代码对象。没有缓存每次运行结果,也没有降低 UI 更新频率或写入账号凭据。
|
||||
- 建筑碰撞采用 512 单位空间网格宽阶段;保留原半径过滤、OBB 判定和法线。过大的对象及非正常/大范围查询回退到完整候选列表;候选按原对象顺序排序去重,保留重叠物体的首个命中法线。新增对象或 ClearObjects 后索引失效重建。
|
||||
|
||||
### 验证结果
|
||||
|
||||
11 项相关 Debug CTests 通过,新增检查包括:脚本代码复用后调用新的回调、运行错误与 LRU 容量;GPU 纹理淘汰/重载及当前帧保护;CPU 解码缓存释放后命中 GPU 不再解码、切回软件路径重载并保留活跃图片;500 组碰撞位置/半径/法线与原完整遍历对照,覆盖负坐标、旋转、重叠、过大对象/查询和 ClearObjects 后再加载。122 对象的局部查询候选少于总数四分之一。最后的 GPU 预算热路径调整另外通过 hardware_scene 测试。
|
||||
|
||||
同场景各 1,200 帧、剔除前 40 帧的对照:修改前平均有效 CPU 3.758 ms,初版 3.690 ms,最终打包版本 3.722 ms。差异较小,不能据此宣称有可靠的帧耗时提升;本轮主要是减少重复工作和限制资源保留。最终 1,159 个稳态样本平均 59.999 FPS,帧间隔 P99 17.225 ms,有一次 >20 ms(最大 22.213 ms)。
|
||||
|
||||
40 秒旋转/短移动测试平均 60.000 FPS,间隔 P99 17.239 ms,2,359 个稳态样本没有 >20 ms 间隔。最后小范围预算热路径修改后又完成固定视角及同进程重登录复测:第二个游戏和技能窗口显示、移动及随后 100 更新连接检查、正常退出均通过。仍不是所有地图/长会话的稳定性保证。
|
||||
|
||||
旋转场景实机资源统计:解码缓存 66,250,792 字节(64 MiB 以下),GPU 图片逻辑字节 92,465,196;稳态解码 118 次、上传 119 次(含白纹理)保持不变。Python 代码缓存 9 项、约 3.5 KiB,编译次数在稳态保持 9。GM 账号的该次移动没有提供有效碰撞候选负载数据,碰撞性能收益尚未在非 GM 复杂移动场景量化;正确性主要由完整遍历对照测试支持。
|
||||
|
||||
证据:`build/verification/resource-ui-collision/` 中 baseline/optimized/orbit/final CSV、summary、资源/编译日志、verification-tests.log、budget-hotpath-test.log 和 final-relogin.log。已更新签名 app 和压缩包。原始 AVA2/服务器/协议保持未修改。
|
||||
|
||||
后续需要实际 GPU 时间、非 GM 移动与密集场景的性能样本、多地图长会话内存测试,以及 UI 图片池/全模型的统一资源生命周期。完整 SpeedTree/SPT、跨 tile 地形和 specular 的渲染差异仍另行处理。
|
||||
@@ -772,3 +772,124 @@ Validation:
|
||||
- macOS arm64 `ava2_client`: builds cleanly and runs 60fps game phase.
|
||||
|
||||
|
||||
|
||||
### 2026-10-09: native login input and stale macOS bundle verification
|
||||
- Reproduced non-responsive account/password text and Tab in the existing `dist/AVA2.app`; its executable predated the current development build and input-event wiring.
|
||||
- Retained the working SDL text-input / IME / focus implementation already present in the workspace and rebuilt/repackaged the macOS app and distribution archive.
|
||||
- Replaced direct login text assignment in `ava2.window_tree` with mouse focus for both fields, IME text insertion, Tab focus switching, and password backspace assertions.
|
||||
- Validation: `ava2.window_tree` passed; native rebuilt app visibly accepted account text, Tab switched to password, password masking and backspace worked. No live authentication was attempted and no server changes were made.
|
||||
- Outstanding: live server authentication and non-ASCII IME composition are outside this verification.
|
||||
|
||||
### 2026-10-10: character selection rendering against the AVA2 Windows reference
|
||||
- Preserved existing workspace fixes for transparent UI boards and character composition. Rebuilt screenshots confirm that the roster and description panels no longer appear as solid white rectangles.
|
||||
- Corrected `app.SetCamera` native Y to engine Z conversion and used the Windows camera's right-handed screen orientation. The previous view exposed back-facing geometry through the model: faces, hair and clothing now render from the correct side. `SetCenterPosition` also converts native height/depth consistently.
|
||||
- Applied the `prototype.RunApp` hair/armor/weapon initialization before creating the first phase window. Armor item vnums now resolve through item-proto to MSM shapes instead of falling back to novice clothes.
|
||||
- `chr.Update` preserves explicit intro heights outside the game phase. `chr.Deform` no longer advances animation/movement a second time, preventing residual map heights from moving intro models outside the screen.
|
||||
- Added optional FreeType UI fonts with shared text measurement/rendering metrics, 2x glyph rasterization for Retina, proportional cursor/alignment positions, and preserved zero-alpha text. SDKs without FreeType retain a smaller, consistently measured fallback. Platform fonts are located at runtime; no proprietary font assets were copied.
|
||||
- Removed per-draw diagnostic output, restricted the phase hint banner to explicit preview mode, and repaired the existing 3D test's vertex/index counting (which had been replaced by a hair debug dump).
|
||||
- Added `ava2.select_render`: four original races, item-to-shape conversion, camera direction/winding, head/feet containment, unchanged height during intro updates, no animation tick during deformation, panel pixels, proportional text width, and transparent text pixels. Optional screenshot output covers all four slots with Jinno scenery; packaged-app verification uses the Shinsoo preview roster.
|
||||
- Validation: macOS build and Android arm64 `main` build passed; selection/window-tree/3D/event/Python-view checks passed. The full suite passed 42/44; `ava2.python` still fails on the existing `chr.GetPixelPosition` native-Y/engine-Z round-trip mismatch, and `ava2.chr` on `SetDirection`/`GetRotation`, outside these changes. The baseline checker reports pre-existing edits to interfacemodule/intrologin/serverinfo/ui; AVA2 reference files were not modified.
|
||||
- Rebuilt `dist/AVA2.app` and its distribution archive. The macOS packager now bundles and relocates SDL3, FreeType and dependent dylibs recursively; signature verification and launching the packaged executable with a selection screenshot passed. Screenshots are under `build/verification/selection/` and are generated artifacts.
|
||||
- Outstanding: live-account selection is not verified; preview roster/equipment and empire differ from the supplied Windows screenshot. Android currently uses the fallback font because this NDK configuration has no FreeType library; on-device rendering remains unverified. Exact Windows spot/point lighting and specular parity remain open.
|
||||
|
||||
### 2026-10-10: investigation of repeated selection title, flag and borders
|
||||
- Reproduced the user's 22:58:52 screenshot by loading the original login UI, releasing its phase/account callback references and windows, then creating selection with a mock roster. No live authentication was performed.
|
||||
- Confirmed that image-instance `Destroy()` omits `Initialize()` in both the base and expanded classes, unlike Windows. The pool reuses objects without reconstruction, leaking login rendering rectangles into selection: Warrior title right fraction 32.3125, Jinno flag 10, and corner images with inherited horizontal/vertical extensions. SDL then tiles these images across the screen.
|
||||
- A temporary restoration of both reset calls removed the inherited rectangles and repeated strips in the same reproduction; the four-race selection checks passed. Temporary source changes were restored after investigation; the distribution bundle remains unchanged.
|
||||
- Report: `docs/SELECT-RENDER-INVESTIGATION.md`; generated before/after screenshots, logs, reproduction source and proposed patch are under `build/verification/pool-investigation/`.
|
||||
- Outstanding: apply and validate the lifecycle fix, add object-pool and login-to-selection regression coverage with image-bound checks, and test returning to login and selecting again. Previous direct-selection tests did not exercise this path and their existing assertions do not detect repeated textures.
|
||||
|
||||
### 2026-10-10: investigation of blank game entry in the packaged app
|
||||
- Reproduced original GameWindow construction failure in the current distribution: `InventoryWindowEx.py` cannot load `rework_inv/new_equipment_bg.tga`. The image exists in the AVA2 pack manifest and project root, but the fixed packaging directory list omits it from both Resources and the asset manifest.
|
||||
- Ran the same packaged executable against the complete test resource root: original game UI, terrain and characters were drawn. This was an offline preview, not a live-account entry verification. Several tree/effect textures still failed to resolve.
|
||||
- Also confirmed the package omits `map/`; the map loader relies on relative map directories and development paths. Existing Python-view game tests use a simplified phase callback and do not construct original GameWindow.
|
||||
- Report: `docs/GAME-RENDER-INVESTIGATION.md`; generated logs and comparison screenshot are under `build/verification/game-investigation/`. No production code or distribution bundle was changed for this investigation.
|
||||
- Outstanding: complete packaging from virtual pack paths, unify resource-root resolution for maps/images/scripts, validate original loading-to-game with the packaged app, apply the image-pool reset, and then assess remaining scene/camera/texture parity against Windows.
|
||||
|
||||
|
||||
### 2026-10-10: game entry rendering fixes and live package verification
|
||||
- Applied base/expanded image-instance pool resets; a render comparison poisons and reuses a pooled title instance, verifying that rectangles, scale, rotation, color, flip and mode reset.
|
||||
- Assets are assembled from AVA2 virtual pack paths plus loose image/audio/model resources beside the Windows client. Required missing pack entries fail packaging. The adapted Python root is included in the manifest with case-sensitive module names preserved; no development directory symlinks remain in the full macOS bundle.
|
||||
- Fixed resource-root lookup for maps, properties, terrain textures, model textures and SpeedTree files. Terrain blocks use their local block position and raw-height border offset. Native areadata coordinates/rotation axes convert to the game renderer's axes.
|
||||
- Preserved the stream's main VID after `chr.Destroy()`, bound the game camera to the real network actor, and grounded newly received actors before camera collision checks. Default game camera is RH, distance 1550, pitch 27, and views the actor from behind.
|
||||
- SDL scene drawing now orders geometry back to front; opaque DDS materials preserve RGB in the alpha/specular mask and avoid forced transparency. Terrain samples/blends native tile masks. The original minimap displays native minimap.dds tiles under the existing marks. Desktop hides the Android touch HUD. Preview movement/combat/render helpers no longer overwrite live actor state.
|
||||
- Full macOS app tested with the user-provided live account through login → selection → loading → game without preview data. The server main actor stayed at local `(43303, 17771, 70856)`, and camera distance remained 1550. Original GameWindow also constructed successfully using only packaged resources. Runtime config/chat files now use an external user-data directory (default SDL preferences directory); strict codesign verification remained valid after the live login and exit. Credentials were not saved to generated user files.
|
||||
- Verification: 9/9 relevant CTests pass (Python view, window tree, selection, game scene, original game entry, packaging, 3D rendering, minimap and background); native-area conversion/loose-assets follow-up tests pass. Android `main` target builds. Evidence: `build/verification/game-fixed/packaged-game.png`, logs and `verification.txt`. Updated deliverables: `dist/AVA2.app` and `dist/AVA2-macOS-arm64.tar.gz`.
|
||||
- Outstanding: exact Windows specular/lighting and complex intersecting-scene depth parity, neighboring terrain-block streaming, and a few effect/vegetation texture references remain. Android was compile-tested, not device-tested. Prior unrelated Python/chr parity failures remain outside this change.
|
||||
|
||||
### 2026-10-11 Game input, skill page and overhead labels
|
||||
|
||||
- Implemented AVA2-specific skill registration before loading-stage skill packets; received skill grades/levels now appear in the original skill page. Derived status recalculation follows the AVA2 point update switch.
|
||||
- Restored original name/title color initialization, FreeType overhead fonts with Retina scaling, character-height registration and actual owner positions; name stays centered while level/title extend left. Corrected GM particle half sizes/quad/live count, attached positions, gravity units and scripted direction magnitude.
|
||||
- Connected original Python keyboard/mouse controls to the live actor and movement/stop packets; added held camera keys, focus-loss releases and UI-first wheel handling. Replaced fixed game update delta and reacquired map pointers after loading callbacks.
|
||||
- Validation: 3/3 targeted CTests; packaged real-account login, nonempty skills/icons/grades, movement then zero movement on release, final overhead screenshot. Evidence: `build/verification/input-label-fixed/final.png` and logs. Updated `dist/AVA2.app` and release archive. No credentials saved.
|
||||
- Limits: complex-scene frame rate, full combat interaction and exact Windows visual parity remain unverified.
|
||||
|
||||
### 2026-10-11 Re-login lifecycle and movement facing regression
|
||||
|
||||
- Dispose both phase-window owners before registering a successor, preventing old LoadingWindow destructors from clearing the new loading callback. Apply the same ordering to player game-window callbacks and treat Python integer 0 as a cleared owner.
|
||||
- Remove actor render/bone yaw +180 offset; verify facing from the real warrior GR2 toe/foot axis against movement. Transfer initial game-server handshake milliseconds from LoginSession to native game time, once per connection, and retain bootstrap time on an unmatched native HANDSHAKE_OK.
|
||||
- Five targeted CTests pass, including destructor reentrancy, a real main-character packet callback, full GameWindow reconstruction, bootstrap clock and model facing. Game-entry test now requires its completion marker.
|
||||
- Packaged same-process live re-login passed; second scene/skill page rendered, movement followed by 100 game updates retained the connection. Evidence: `build/verification/relogin-facing-fixed/`. Updated app and release archive. Server and original AVA2 remain unchanged; no credentials saved. Limited-duration verification does not establish long-running stability.
|
||||
|
||||
### 2026-10-11 selection / NPC / performance follow-up
|
||||
|
||||
- Restored the original script API `chr.SetRotation` 180-degree conversion, fixing selection while retaining the corrected network locomotion axis. Corrected script position coordinate round trips.
|
||||
- Mounted manifest-backed bundle asset packs alongside the Python script root. This restores `locale/common/npc_wear.txt`, and live race 61000–61007 NPCs now use their configured eight PC models/outfits. NPC map-specific lookup reads the actual current map.
|
||||
- Connected Python camera settings and host camera feedback. Added regression coverage for pack mount priority, traversal rejection, NPC map precedence, camera synchronization, and GR2 presentation facing.
|
||||
- Cached static building geometry and switched macOS packaging from Debug to an explicit RelWithDebInfo build. Same NPC scene measured about 240 ms/frame in Debug versus 25 ms/frame in the optimized build, approximately 4 to 40 FPS on this host.
|
||||
- Remaining visual/performance gaps: sustained 60 FPS, mounted NPC rendering, foliage and sky parity, and hardware depth-buffer rendering. Short live samples do not establish full Windows pixel parity or long-session stability.
|
||||
|
||||
- Final validation: 8 relevant regression tests pass, live selection/NPC camera probes pass, and relogin probe remains connected after the second game entry. The broad Python suite retains unrelated missing-icon fixture / derived-status expectation failures, documented in GAME-RENDER-INVESTIGATION.md. Signed app and archive contain the optimized executable.
|
||||
|
||||
### 2026-10-11 Hardware depth, frame pacing and mounted NPCs
|
||||
|
||||
- Added a native SDL_GPU scene pass with persistent vertex/index buffers, depth testing/writes, alpha testing, D3D-style culling and perspective-correct texture interpolation. Metal is verified on this host; the Vulkan SPIR-V shaders compile but Vulkan runtime is not verified. CPU model transforms, lighting and fog remain CPU work.
|
||||
- Upload decoded textures on the scene GPU queue before sampling. Borrowing SDL_Renderer textures produced a blank first frame because their queued uploads were not submitted until Present. Composite the scene with premultiplied alpha so the original selection background survives.
|
||||
- Cache tinted text masks (512 entries / 16 MiB) instead of creating/destroying textures for every label. Cull static objects by conservative world bounds before copying mesh commands. Keep collision geometry intact. Disable GPU validation in normal release builds; AVA2_GPU_DEBUG enables it for diagnostics.
|
||||
- Move the 60 Hz deadline wait immediately before presentation and use SDL_DelayPrecise. The frame CSV distinguishes active CPU work, geometry assembly, raster encoding and presentation intervals; loading and screenshots are excluded from steady-state statistics.
|
||||
- Port the reference sky's vertical cube gradients, environment cloud scale/height/alpha and lens-flare enable conditions. This removes the invented cloud/flare appearance in C1.
|
||||
- Render mount actors and attach riders through the animated saddle bone. Convert native Z-up bone matrices before world attachment. Register the reference horse wait/walk/run/dead motions for all eight PC races, and resolve the active motion mode at playback time: riders no longer stand on mounts, and an armor rebuild preserves the riding pose. A real GR2 leg-pose regression checks riding, armor rebuild and dismount restoration.
|
||||
- Validation: 10 targeted Debug CTests pass, including native Metal depth/alpha/culling/perspective/first-texture/background pixels, font renderer lifetime, conservative frustum rejection, sky configuration and mounted animation. Live selection, NPC/mount scene, movement/orbit and same-process re-login were exercised with the authorized account. No credentials are stored in source or documentation.
|
||||
- Remaining Windows parity gaps: SpeedTree still generates approximate foliage rather than decoding the original SPT geometry; outdoor rendering still lacks full adjacent-tile streaming; original specular/sphere-map shading is not complete. Performance evidence covers the measured local Metal scene, not every map or long-running session. Existing unrelated broad-Python-suite fixture/formula failures remain unchanged.
|
||||
|
||||
- Final signed-bundle measurement: 2,400 game updates (~40 s), 2,359 steady-state samples after the first 40 updates; average 60.000 FPS, presentation interval P95 16.723 ms / P99 16.765 ms, active CPU work P95 10.424 ms / P99 11.313 ms. Two intervals exceeded 20 ms (maximum 23.478 ms); this is not a claim of zero dropped frames. Full camera orbit, short W movement and connection checks at updates 1,190 and 2,390 passed. Evidence: `build/verification/gpu-depth/final-stress.csv`, `final-stress-summary.json`, `final-stress.png`, `riding-tests.log`. Signed app: `dist/AVA2.app`; release archive updated from that bundle.
|
||||
- Final packaged re-login probe also passed after the riding fix: second GameWindow and skill page rendered, movement completed, and the connection remained live for the following 100 updates (`build/verification/gpu-depth/final-relogin.log`).
|
||||
|
||||
### 2026-10-11 Follow-up performance audit (investigation only)
|
||||
|
||||
- Captured an 8-second main-thread sample and a separate 1,200-frame unprofiled control on the signed Metal build. Control averages 60.000 FPS / 7.117 ms active CPU; P99 presentation interval 17.698 ms with one interval above 20 ms. Sampling run had an unconfirmed 521 ms pause near sampler startup; do not use it as a proven client-code spike.
|
||||
- Excluding cap-wait samples, rendering preparation and actor draw generation account for approximately 81% of main-thread samples. Prioritize actor culling/pose reuse, removal of redundant hardware-path work, immutable geometry references and resident GPU buffers. Animation switching currently reads/parses GR2 synchronously; caching needs movement/combat measurements. Terrain caching, instancing, resource budgets and UI/collision follow later.
|
||||
- Detailed evidence and implementation priorities: docs/PERFORMANCE-AUDIT-2026-10-11.md. No client runtime behavior, asset bundle or server changed during this audit.
|
||||
|
||||
### 2026-10-11 Performance optimizations: parsed assets, poses and geometry
|
||||
|
||||
- Added shared immutable parsed GR2 model/animation caching in ../sdk/gr2 (64 retained entries / 128 MiB source bytes, path/mtime/size invalidation), per-instance pose reuse and pre-bound track indices. Mutable playback/attachments remain independent. CPU pose equivalence and cache invalidation tests pass.
|
||||
- Cull non-main network actors/mounts before mesh generation using conservative bounds; keep all network/locomotion updates active. Static building commands reference immutable mesh streams; terrain patch/LOD geometry is cached and invalidated on map data/origin changes. Both software and native GPU raster paths consume geometry references.
|
||||
- Skip fallback-only screen coordinate calculations in the hardware path. Fixed a discovered exit-time minimap image reference lifetime by destroying UI/Python resources before SDL renderer/resources.
|
||||
- Same-scene stationary control: active CPU average 7.117 -> 5.423 ms (-23.8%), scene assembly 2.920 -> 1.838 ms (-37.1%); 60.000 FPS, interval P99 16.792 ms, no >20 ms interval in 1,159 steady-state frames. Eleven targeted Debug CTests pass, including original-vs-cached pose matrices, resource update invalidation, terrain reuse and hardware shared-geometry pixels/material overrides.
|
||||
- Further static resident GPU buffers, GPU transforms/skinning, instancing, memory budgets and lower-priority UI/collision changes remain follow-up work. Details and measured evidence: docs/PERFORMANCE-AUDIT-2026-10-11.md / build/verification/performance-audit/.
|
||||
|
||||
- Final signed-bundle validation: 2,400-frame camera-orbit/short movement probe passed both connection checks; 2,359 steady-state samples averaged 60.000 FPS, interval P99 16.811 ms, active mean 5.669 ms, with two >20 ms intervals (max 22.489 ms). Same-process re-login rendered the second game/skill window, completed movement, remained connected for 100 further updates and exited cleanly. Evidence: `optimized-orbit-summary.json`, `optimized-orbit.log`, `optimized-relogin.log` under build/verification/performance-audit. Signed `dist/AVA2.app` and its archive updated.
|
||||
|
||||
### 2026-10-11 Resident meshes, GPU skinning and opaque instancing
|
||||
|
||||
- Move vertex transforms, fixed-function lighting/fog and skeletal weighted transforms into Metal/Vulkan shaders. SDK raw mesh templates preserve part inverse-bind remapping, rigid/zero-weight handling and attachments; CPU bone pose still drives saddle/effects. Palettes above 128 bones and software/F6 paths retain CPU skinning. GPU geometry conversion cache validates source ownership, not just an address.
|
||||
- Resident vertex/index buffers cover immutable building, terrain and character streams, with an inactive-entry 256 MiB soft GPU retention budget. Dynamic water, tree wind and effects remain streamed. Deduplicate building mesh streams and instance compatible adjacent opaque commands through per-instance transforms/material data; transparent and skinned-palette commands remain independent.
|
||||
- Same-location signed before/after comparison: active CPU 5.976 -> 3.491 ms (-41.6%), render preparation/submit 2.918 -> 0.807 ms (-72.3%). Both cap at ~60 FPS; interval P99 16.832 -> 17.038 ms, so do not claim improved pacing from reduced CPU work. 40-second orbit averages 60.000 FPS, P99 17.020 ms with one >20 ms sample; same-process relogin/skill window/movement/connection and clean exit pass.
|
||||
- Eleven targeted Debug tests pass, including real mesh/normal skin equivalence, GPU weighted-rotation pixel comparison, resident upload reuse, instance material/matrix isolation, nonzero firstInstance and transparent exclusion. Metal verified; Vulkan shaders compile but runtime unverified. Signed app/archive updated. No original AVA2/server or credentials modified.
|
||||
- Evidence and remaining lower-priority work: docs/PERFORMANCE-AUDIT-2026-10-11.md and build/verification/gpu-resident/.
|
||||
|
||||
### 2026-10-11 Texture budgets, compiled dispatch and collision broad phase
|
||||
|
||||
- Bound decoded 3D images (64 MiB / 256 retained entries) and native/SDL textures (256 MiB soft budgets), protect in-flight/current working sets, and reuse uploaded native textures without requiring decoded RGBA residency. GPU bytes are logical image payload, not measured driver VRAM; UI images and whole-process memory remain outside this budget. Skip eviction bookkeeping below GPU budget.
|
||||
- Cache Python 2 compiled statements with bounded source retention and release before interpreter finalization. Eval still resolves current globals/callbacks; no UI throttling, frozen phase-window references or credentials written. Add frame-profile-only resource/compilation counters.
|
||||
- Add collision spatial grid candidates while preserving original OBB/radius checks, insertion-order first-hit normals, oversized-query/object fallback and index invalidation on changes.
|
||||
- Eleven targeted Debug regressions pass; add LRU/error/callback-rebind tests, texture eviction/reload/current-frame/software-transition pixel tests, and 500 exact collision hit/normal comparisons. Latest GPU hot-path tweak passes hardware_scene separately. Final signed re-login/skill-window/movement/connection/clean exit probes pass.
|
||||
- Same-scene active CPU averages 3.758 ms before, 3.722 ms final: too small to claim a reliable speedup. Final ~60 FPS, P99 interval 17.225 ms with one >20 ms sample. Forty-second orbit ~60 FPS / P99 17.239 ms with no >20 ms sample; decode/upload/compile counts stabilize and decoded retention stays below 64 MiB. GM live collision workload was not representative; non-GM/dense/multimap and actual GPU timing remain follow-up validation.
|
||||
- Signed app/archive updated; detailed limits/evidence in docs/PERFORMANCE-AUDIT-2026-10-11.md and build/verification/resource-ui-collision/.
|
||||
|
||||
### Reproducible SDK dependency (2026-10-11)
|
||||
|
||||
- Publish the shared SDK independently and pin its revision through the `sdk` Git submodule. Client builds default to this checkout; `AVA2_SDK_ROOT` supports an explicit development override. Source snapshots, tests and SDK provenance remain in the SDK repository, rather than duplicated client source.
|
||||
- Build products, unpacked game assets, local resource links, runtime state and account credentials are excluded from both commits. Embedded SPIR-V C++ shader code accompanies its GLSL source and regeneration tool as required renderer source.
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
# 选角标题、国旗和边框重复的原因
|
||||
|
||||
调查日期:2026-10-10。对应用户 22:58:52 截图。
|
||||
|
||||
## 已确认的根因
|
||||
|
||||
移植版图片实例的销毁过程遗漏了状态初始化:
|
||||
|
||||
- `src/eter_image/GrpImageInstance.h` 的 `Destroy()` 只清除图片引用,没有调用 `Initialize()`,缩放、颜色/透明度、位置和翻转状态可能被保留。
|
||||
- `src/eter_image/GrpExpandedImageInstance.h` 的 `Destroy()` 只调用基类销毁,没有调用派生类 `Initialize()`,平铺范围、旋转和混合模式等状态可能被保留。
|
||||
- `shared/common/DynamicPool.h` 的 `Alloc()` 直接返回空闲对象,不重新运行构造函数。它依赖对象在归还时重置状态。
|
||||
|
||||
登录 UI 的边框使用正的 `SetRenderingRect` 扩展值来平铺纹理。对象释放并在选角 UI 中复用后,这些值被新图片继承。`GrpImageInstance.cpp` 的扩展图片渲染会据此扩大目标矩形,并调用 `SDL_RenderTextureTiled`,于是标题、国旗和角落纹理被重复绘制。
|
||||
|
||||
Windows 参考实现中,基类和扩展图片类的 `Destroy()` 都会调用各自的 `Initialize()`。移植版遗漏了这两个调用。
|
||||
|
||||
## 验证证据
|
||||
|
||||
使用原版 Python 登录 UI 和模拟角色数据,在本地测试中关闭登录 UI、释放登录阶段回调引用、执行 Python GC 和窗口管理器 Update,再创建选角 UI。没有进行服务器认证。
|
||||
|
||||
复用日志记录到:
|
||||
|
||||
```text
|
||||
locale/en/ui/select/name_warrior.sub rect=(0,0,32.3125,0)
|
||||
locale/en/ui/select/empire/empireflag_c.sub rect=(0,0,10,0)
|
||||
thinboard_corner_lefttop_gold.tga rect=(0,0,0,22)
|
||||
thinboard_corner_righttop_gold.tga rect=(0,0,20.4375,0)
|
||||
```
|
||||
|
||||
生成截图复现了用户图中的横向 Warrior 标题、国旗横条,以及横向/纵向重复的边框。重复数量受窗口尺寸、裁剪和对象复用顺序影响。
|
||||
|
||||
临时在两个 `Destroy()` 中恢复 `Initialize()`,以同一复现流程运行后,这些继承的扩展值和重复条带消失,四角色选角检查通过。实验结束后,临时源代码修改和诊断日志均已撤回;本次没有更新发布包。
|
||||
|
||||
证据保存在忽略的生成目录 `build/verification/pool-investigation/`:`before/slot0.png`、`after/slot0.png`、`before.log`、`after.log`、`login_select_repro.cpp` 和 `proposed-reset.patch`。
|
||||
|
||||
## 修复及验证建议
|
||||
|
||||
恢复基类、派生类销毁时的初始化。应保留 UI 边框正常使用的平铺功能。
|
||||
|
||||
先前测试直接进入选角,未覆盖登录图片对象回收。现有选角测试的白块、模型和字体断言也没有检测重复纹理,因此复现图异常时仍会通过。后续应增加对象复用状态断言、登录到选角的转换,以及标题/国旗绘制范围检查,并覆盖返回登录后再次选角。
|
||||
Reference in New Issue
Block a user