Skip to content

修复神庙传送点黑色纹理与技能效果方块 - #3

Merged
ly05010419 merged 2 commits into
ly05010419:mainfrom
huahuahuahuahuahuahuahua:fix/totk-rendering-textures
Oct 18, 2026
Merged

ly05010419 merged 2 commits into
ly05010419:mainfrom
huahuahuahuahuahuahuahua:fix/totk-rendering-textures

Conversation

@huahuahuahuahuahuahuahua

@huahuahuahuahuahuahuahua huahuahuahuahuahuahuahua commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

神庙传送点的蓝色纹理会出现半边黑块;使用究极手/倒转等技能时,背景会暴露规则的分类方块。本 PR 分两个独立 commit 修正 NVN 自动纹理布局和 D16 清除量化,附上真实游戏修复前后截图。截图保存在用户 fork 的独立 Release 附件中,不进入代码提交。

修改内容

  1. 自动块高取整:在选择 GOB 块高前,对 height_in_blocks * 1.5 / 8 按 NVN SDK 的规则截断。160×160 BC3-sRGB 传送点纹理应使用 H2,原来的向上取整会选择 H3,把填充区读成黑色。两种布局的总分配大小均为 57,344 字节,因此单查大小发现不了问题。显式 packaged layout 的优先级保持不变。
  2. D16 深度清除量化:让附件及纹理 load-clear 与片元写深度选择相同的 16 位值。在本机 Apple GPU 上,原始 0.5 load-clear 得到 32767,片元写入得到 32768,EQUAL 分类测试因此留下方块。修复将清除值置于两种转换共同的量化区间,并留出四分之一单位余量。其他深度格式、片元执行的 masked clear 保持原行为。

修复前后:TOTK 1.4.3

测试基于 Apple M4 Pro、macOS Metal 4,以及上游 41e1e0c。两组运行时使用相同的原始 1.4.3 存档副本、相同位置和镜头输入,画质沿用上游设置。两组只共享本机启动必需的地址布局兼容修复,该修复不在本 PR 中;没有加入 2K/阴影增强、手柄修改或 Smoke-Free Hyrule。

两组均关闭全量启动预热、按需编译目标场景着色器。本轮用于画面对照,不作为性能测试;截图中的游戏时间和天气动画略有差异。

神庙传送点

修复前,蓝色纹理左半边被黑色区域覆盖;修复后,蓝色图案完整显示。

修复前 修复后
1.4.3 传送点修复前 1.4.3 传送点修复后

技能分类方块

本轮 1.4.3 实机复测使用倒转:修复前地面和远处背景出现规则矩形块;修复后,技能分类效果连续,矩形块消失。

修复前 修复后
1.4.3 倒转修复前 1.4.3 倒转修复后

验证

  • 上游 Python 测试:38 项通过。
  • 自动纹理布局:40 个独立 SDK 元数据基准通过,包括传送点 BC3 块地址及显式布局覆盖;原实现会在这些基准上失败。
  • 独立 D16 GPU 对照:Metal 3、Metal 4 各 777 个深度值,覆盖全部 256 个技能分类编码、端点、邻近浮点数及确定性随机样本。两套 API 的原清除方式各有 292 个不一致,修正后均为 0。
  • 1.4.3 实机 A/B:原实现复现上述两种错误,加入两个补丁后均消失。此结果仅覆盖目标传送点和倒转场景,不代表全游戏、所有技能或所有 GPU 均已验证。
  • 原始验证基于 TOTK 1.1.2,此前的神庙及究极手截图也保留在文档中,作为历史证据:神庙前/后,究极手前/后。本次新截图明确对应 1.4.3。

提交拆分

  • Fix automatic texture block-height rounding
  • Match D16 load clears to fragment depth quantization

两个 commit 使用 huahua <[email protected]>,均附带 Codex 协作署名。没有提交游戏二进制、解包素材、存档、密钥或本机启动兼容补丁。

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-18T11:44:25.476877Z 927bdb9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Truncate height * 1.5 to whole GOB rows before selecting the automatic
block height. This keeps the 160x160 BC3 shrine warp texture from reading
padding as black texels while preserving explicit packaged layouts.

Add 40 independent SDK layout goldens and addressing checks. Document
historical TOTK 1.1.2 and fresh 1.4.3 validation on Apple M4 Pro. Host
screenshots separately as fork release assets referenced by the PR.

Co-authored-by: Codex <[email protected]>
Quantize D16 attachment and texture load-clear values into the same bins
as fragment depth writes. A quarter-unit margin also avoids rounding
below the intended integer during descriptor conversion. Keep other
depth formats and fragment-based masked clears unchanged.

Add a game-data-free Metal 3/4 regression covering 777 depth values,
including all skill classification codes. Document the 1.1.2 Ultrahand
and 1.4.3 Recall checks with separately hosted screenshot evidence.

Co-authored-by: Codex <[email protected]>
oneincase added a commit to oneincase/MacNativeGames that referenced this pull request Oct 18, 2026
…y05010419#3)

Two rendering fixes from ly05010419#3, verified in this tree:

- nvn_tex: NVN truncates height*1.5 to whole GOB rows before choosing the power
  of two; rounding up picked H3 for the 160x160 BC3 shrine-warp texture and the
  padding read as black. Explicit packaged layouts still win.
- nvn_mtl/nvn_depth_clear: D16 clear values now go through the same 16-bit
  quantisation as fragment depth writes (0.5 cleared to 32767 while fragments
  wrote 32768, leaving the equal-test classification squares).

Includes the two standalone probes (texture layout goldens and D16 clear) and
their Makefile targets.
@ly05010419

Copy link
Copy Markdown
Owner

是的 我一直没时间 修复这个bug 非常感谢! @huahuahuahuahuahuahuahua

@ly05010419
ly05010419 merged commit 70729e9 into ly05010419:main Oct 18, 2026
1 check passed
@RVZO6

RVZO6 commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Tested on an M4 Pro Mac (macOS 27.0.1, TOTK 1.4.3), combined with #12 and #13 on top of 41e1e0c.

Results

  • Texture layout: the 40-case SDK-reference regression and the shrine block-address checks pass with this PR; the original code fails the regression. Example: a 160×160 BC3 texture has 40 block rows, which become 60 after the height heuristic. Integer division gives 7 GOB rows and selects H2; the old ceiling division gave 8 and selected H3. Allocation size alone doesn't expose the wrong layout.
  • D16 clear: the depth16 GPU probe tried 777 requested depths on both Metal 3 and Metal 4. The old clear path disagreed with fragment-written depth for 292 values per API; with this PR, none did.
  • Caveat: these are targeted checks. I didn't revisit the shrine scene in-game.

One small fix needed: the probe targets break when RENDER_PROBE_DIR contains a space (my work folder is ~/Games/Switch ROMs/TOTK_build). Make splits target names on spaces, so the rule and the prerequisite stop matching. The patch below escapes spaces in target names only; recipes keep the quoted original path. It also adds a dry-run regression test, which fails without the Makefile change and passes with it.

Patch (git apply)
diff --git a/games/totk/Makefile b/games/totk/Makefile
index 0e41637..0d5fd91 100644
--- a/games/totk/Makefile
+++ b/games/totk/Makefile
@@ -350,16 +350,20 @@ runtime-v143: build/totk-native-v143 build/pso_manifest.tsv
 
 # Keep standalone rendering probe binaries outside the source checkout.
 RENDER_PROBE_DIR ?= $(abspath $(CURDIR)/../../../TOTK_build/rendering-probes)
+# Escape spaces in make's target lists; recipes use the original quoted path.
+render_probe_empty :=
+render_probe_space := $(render_probe_empty) $(render_probe_empty)
+RENDER_PROBE_TARGET_DIR = $(subst $(render_probe_space),\$(render_probe_space),$(RENDER_PROBE_DIR))
 .PHONY: probe-texture-auto-layout
-$(RENDER_PROBE_DIR)/texture-auto-layout-probe: tests/texture_auto_layout/probe.c third_party/d2r_gfx/gfx/nvn/nvn_tex.c third_party/d2r_gfx/gfx/nvn/nvn_tex.h third_party/d2r_gfx/gfx/tex/nvn_deswizzle.c
+$(RENDER_PROBE_TARGET_DIR)/texture-auto-layout-probe: tests/texture_auto_layout/probe.c third_party/d2r_gfx/gfx/nvn/nvn_tex.c third_party/d2r_gfx/gfx/nvn/nvn_tex.h third_party/d2r_gfx/gfx/tex/nvn_deswizzle.c
 	@mkdir -p "$(RENDER_PROBE_DIR)"
 	xcrun clang -std=c11 -O2 -Wall -Wextra -Werror -Ithird_party/d2r_gfx/gfx/nvn -Ithird_party/d2r_gfx/gfx/tex tests/texture_auto_layout/probe.c third_party/d2r_gfx/gfx/nvn/nvn_tex.c third_party/d2r_gfx/gfx/tex/nvn_deswizzle.c -o "$@"
-probe-texture-auto-layout: $(RENDER_PROBE_DIR)/texture-auto-layout-probe
+probe-texture-auto-layout: $(RENDER_PROBE_TARGET_DIR)/texture-auto-layout-probe
 	"$(RENDER_PROBE_DIR)/texture-auto-layout-probe"
 
 .PHONY: probe-depth16-clear
-$(RENDER_PROBE_DIR)/depth16-clear-probe: tests/depth16_clear/probe.m third_party/d2r_gfx/gfx/nvn/nvn_depth_clear.h
+$(RENDER_PROBE_TARGET_DIR)/depth16-clear-probe: tests/depth16_clear/probe.m third_party/d2r_gfx/gfx/nvn/nvn_depth_clear.h
 	@mkdir -p "$(RENDER_PROBE_DIR)"
 	xcrun clang -std=c11 -O2 -Wall -Wextra -Werror -fobjc-arc -Ithird_party/d2r_gfx/gfx/nvn tests/depth16_clear/probe.m -framework Metal -framework Foundation -o "$@"
-probe-depth16-clear: $(RENDER_PROBE_DIR)/depth16-clear-probe
+probe-depth16-clear: $(RENDER_PROBE_TARGET_DIR)/depth16-clear-probe
 	$(GAME_SLOT_RUN) "$(RENDER_PROBE_DIR)/depth16-clear-probe"
diff --git a/tests/test_render_probe_paths.py b/tests/test_render_probe_paths.py
new file mode 100644
index 0000000..9ef7811
--- /dev/null
+++ b/tests/test_render_probe_paths.py
@@ -0,0 +1,35 @@
+"""Standalone rendering probes must accept external output paths with spaces."""
+from pathlib import Path
+import shlex
+import shutil
+import subprocess
+import tempfile
+import unittest
+
+
+ROOT = Path(__file__).resolve().parents[1]
+
+
+@unittest.skipUnless(shutil.which('make'), 'requires make')
+class RenderProbePaths(unittest.TestCase):
+    def test_external_output_path_with_spaces(self):
+        with tempfile.TemporaryDirectory() as folder:
+            output = Path(folder) / 'probe output'
+            result = subprocess.run(
+                ['make', '-n', '-C', str(ROOT / 'games/totk'),
+                 f'RENDER_PROBE_DIR={output}',
+                 'probe-texture-auto-layout', 'probe-depth16-clear'],
+                capture_output=True, text=True, check=True)
+            self.assertNotIn('overriding', result.stderr)
+            commands = [shlex.split(line) for line in result.stdout.splitlines()
+                        if line.startswith('xcrun clang ')]
+            self.assertEqual(len(commands), 2)
+            self.assertEqual(
+                [command[command.index('-o') + 1] for command in commands],
+                [str(output / name) for name in
+                 ('texture-auto-layout-probe', 'depth16-clear-probe')])
+            self.assertFalse(output.exists(), 'dry run must not create build output')
+
+
+if __name__ == '__main__':
+    unittest.main()

中文摘要:在 macOS 27.0.1 / 1.4.3 上测试通过。纹理布局回归(40 例)和 D16 GPU 探针(Metal 3/4 各 777 个深度值,旧代码 292 个不一致,修复后为 0)均确认修复有效。唯一问题:RENDER_PROBE_DIR 路径含空格时 Make 目标失效,上面的补丁对目标名中的空格做转义,并附带回归测试。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants