Initial public release
This commit is contained in:
@@ -0,0 +1,183 @@
|
||||
# dm/gfx — graphics layer (NVN → Metal)
|
||||
|
||||
中文:[README.zh-CN.md](README.zh-CN.md)
|
||||
|
||||
The Switch version of the game draws with NVN (the Switch's native graphics interface). The graphics layer reimplements this interface on top of Apple's Metal: every NVN call the game makes lands here, is recorded as a command, and is replayed as Metal commands at submit time. The game's shaders are not translated at run time; they are translated offline, once, on a computer, into Metal shader libraries (when the computer has no Apple Metal compiler, the final compile step moves to the phone; see below).
|
||||
|
||||
For the build steps of the whole project see `README.md` and `setup.sh` in the repository root, and for dependencies see `docs/DEPENDENCIES.md`; this page covers only the graphics layer's own matters.
|
||||
|
||||
## How it works
|
||||
|
||||
### Taking over the NVN interface
|
||||
|
||||
- The game's main program imports only one NVN symbol, `nvnBootstrapLoader`; all other NVN functions are obtained through it by name. The host forcibly takes over this import (`nvn/hle_nvn.c`), and not a single instruction of the original graphics driver is executed.
|
||||
- The game fetches the addresses of 523 names in total (`nvn/names.txt`). Each name has a thunk (`nvn/nvn_thunks.S`, a generated file): it first increments that function's call count and then jumps to the implementation.
|
||||
- Of these, the 216 that have call sites in the game's main program (`nvn/nvn_slots.tsv`) all have implementations: 203 are implemented according to NVN semantics, and 13 are empty implementations (`g_nops` in `hle_nvn.c`). The remaining 307 are connected to a red-reporting stub that, when called, prints `【红】NVN 未实现被调用:名字` in the log ("[red] unimplemented NVN function called: name").
|
||||
- Every implementation gets a compile-time signature check against `nvn/nvn_protos.h` (a generated file). The calling conventions of Apple arm64 and the Switch differ for integer parameters narrower than 32 bits, so on the host side `NVNboolean` parameters are always received as `uint32_t` and only the low 8 bits are examined.
|
||||
|
||||
### Two layers: record and replay
|
||||
|
||||
- **Interface layer `nvn/hle_nvn.c`**: host-side objects are stored in place in the memory the game allocates for NVN objects; the layouts are in `nvn/nvn_obj.h`, and each has a static assertion guaranteeing it does not exceed NVN's reserved size. Commands are recorded into the command memory provided by the game, in the record format of `nvn_obj.h`.
|
||||
- **Replay layer `nvn/nvn_mtl.m`**: at submit time it replays the record stream as Metal commands.
|
||||
- Memory pools are created as zero-copy `MTLBuffer`s, with the GPU address equal to the CPU address, so only unified-memory devices are supported.
|
||||
- The visible effects of "GPU completion" (sync objects becoming ready, events writing their value, counters) happen only after the Metal command buffer has actually completed.
|
||||
- Pipeline states and depth-stencil states are cached by state hash; at startup, shaders and pipelines are pre-built in the background according to the warm-up manifest.
|
||||
- The game's packaged textures are in Tegra block-linear layout and are deswizzled before upload (see `tex/README.md`).
|
||||
- Presentation: the game's swapchain texture is drawn to a `CAMetalLayer`, and presentation timing is scheduled by the pacer in `nvn/nvn_pace.h`.
|
||||
|
||||
For which Metal object each NVN object and command lands on, see [nvn_metal_mapping.md](nvn_metal_mapping.md).
|
||||
|
||||
### Shader translation chain
|
||||
|
||||
The game's shaders are GPU machine code for the Tegra X1 (the Maxwell instruction set). The translation from this machine code to Metal Shading Language is not done on the phone; all of it happens offline:
|
||||
|
||||
```
|
||||
Original Switch shader package
|
||||
→ tools/dmsh_xlate produces SPIR-V with Ryujinx's shader translation library (a C# tool)
|
||||
→ spirv-cross converts SPIR-V to Metal Shading Language (MSL)
|
||||
→ xcrun metal / metallib compiles into Metal shader libraries
|
||||
```
|
||||
|
||||
Without Apple's Metal compiler (Windows, Linux, a Mac without Xcode) the last step cannot be done. `tools/nometal_run.py` lets the same chain run its first two steps as usual and puts the translated MSL source into the library files as is; a package made this way compiles the shaders once on the phone, and the system caches the compiled result. This route is used by `dm/tools/d2rm_pack.py`; see `docs/NO_XCODE.md` in the repository root.
|
||||
|
||||
The whole chain is driven by `tools/dmsh_build.py`, and `setup.sh` runs it for you. Key points:
|
||||
|
||||
- **Key**: each shader is keyed by the first 16 hexadecimal digits of the sha256 of its control section (0x880 bytes). At run time the game hands the control section to `nvnProgramSetShaders`, and the replay layer computes the same key to find the library.
|
||||
- **Build outputs**: `<key>_b.metallib` (the shader library), `<key>_b.json` (reflection used by replay: each binding's kind, slot number, index within the argument buffer and so on), `<key>_b.metal` (the MSL source). Some fragment shaders additionally have `<key>_bf.metallib`, a "readable tile" version used for pass merging (see the file header of `tools/dmsh_fetch.py`). `_b_build.json` in the directory records the success or failure of each key in this run.
|
||||
- **`nvn/shader_map.tsv`**: the shader map, one row per shader variant. At run time only its "key → stage (vertex / fragment / compute)" is used.
|
||||
- **`nvn/shader_facts.tsv`**: the answer table for translation queries. The translator needs to know some facts that cannot be read from the machine code (the dimension type of a texture, image formats, the component types of vertex attributes and fragment outputs, a compute shader's thread group size and shared memory byte count), and this table gives the answers by key. The table ships with the repository, and building the shader libraries only reads it; the table is maintained by `tools/dmsh_facts.py`, whose file header has the details.
|
||||
- **Translation chain version and the `b-<V>/` directory**: the version V is a string of 12 hexadecimal digits, obtained by hashing together the contents of the source files involved in the translation chain, the translation options and the tool fingerprints (`tools/dmsh_chain.lock`); `tools/dmsh_chain.py` computes it. Shader libraries are written into `<output directory>/b-<V>/`, and every reflection json also records V. When the host is compiled it takes V from `nvn/dmsh_chain.h`, loads only from `b-<V>/`, and checks the version in each json one by one; on a mismatch it reports red and does not load. So after changing any file on the chain, or changing a tool, the libraries must be rebuilt and the host recompiled.
|
||||
- `dmsh_chain.py`: prints V.
|
||||
- `dmsh_chain.py --check-tools`: checks that the local tools match the lock file.
|
||||
- `dmsh_chain.py --update-lock`: rewrites the lock file according to the local tools.
|
||||
- `dmsh_chain.py --header`: rewrites `nvn/dmsh_chain.h`.
|
||||
- It is normal for the local Xcode or spirv-cross version to differ from the one registered in the repository; `setup.sh` automatically re-registers according to the local tools.
|
||||
- **`nvn/c1_full.tsv`**: the index list for the shaders' built-in constant section (c1), generated by `tools/c1_guard.py` scanning the translated MSL; it lists the shader keys whose "run-time index could not be proven bounded". Its first line records the `b-<V>` it corresponds to. For the shaders on the list the replay layer allocates a separate whole 64 KiB buffer for c1; when the list is missing or its version does not match, it reports red and conservatively treats all shaders this way.
|
||||
- **`nvn/pso_manifest.tsv`**: the warm-up seed manifest, recording the shaders and pipelines used first after startup. The row order is the pre-build order; do not sort it.
|
||||
- **Shaders embedded in the program itself**: the main program additionally contains 4 compute shaders that are not in the shader package; they were hand-written as MSL from the disassembly and are in `nvn/nvn_builtin.h`.
|
||||
|
||||
Binding conventions followed during translation (file header of `tools/maxwell_refs.py`):
|
||||
|
||||
- uniform buffer r is constant section `c[3 + r]` in the machine code;
|
||||
- the handle of separate texture r is at `c[2][0x168 + 8r]`, and the handle of separate sampler r is at `c[2][0x568 + 8r]`;
|
||||
- the address of storage buffer r is at `c[0][base + 16r]`, with base: vertex 0x110, compute 0x310, fragment 0x510;
|
||||
- the window origin is at the top left and the depth range is 0 to 1, the same as Metal, so nothing is flipped during translation.
|
||||
|
||||
## Directory structure
|
||||
|
||||
| Location | Contents |
|
||||
|---|---|
|
||||
| `nvn/hle_nvn.c` | Interface layer: NVN takeover, object implementations, command recording, presentation pacing |
|
||||
| `nvn/nvn_mtl.m`, `nvn/nvn_mtl.h` | Replay layer: Metal device, memory pools, textures, shader loading, pipelines, drawing, presentation |
|
||||
| `nvn/nvn_obj.h` | Host-side object layouts and the command record format, shared by both layers |
|
||||
| `nvn/nvn_entry.S`, `nvn/nvn_thunks.S` | Entries for the unimplemented stub and the timing wrapper, per-function thunks |
|
||||
| `nvn/nvn_tex.c`, `nvn/nvn_tex.h` | Storage size, alignment and per-level offsets of block-linear textures (ported from deko3d) |
|
||||
| `nvn/nvn_dirty.c`, `nvn/nvn_dirty.h` | Tracks dirty pages of game memory with write protection, to decide whether texture contents have changed and need re-uploading |
|
||||
| `nvn/nvn_refl.m`, `nvn/nvn_refl.h` | Converts shader reflection json into fixed-length C arrays, so that drawing only walks arrays |
|
||||
| `nvn/nvn_hmap.h`, `nvn/nvn_cover.h`, `nvn/nvn_pace.h`, `nvn/nvn_pso_skey.h` | Hash table, geometric proof of full-coverage draws, presentation pacer, pipeline manifest key |
|
||||
| `nvn/nvn_builtin.h` | Hand-written MSL for the 4 compute shaders embedded in the main program |
|
||||
| `nvn/include/nvn.h` | NVN interface declarations (third party; for the license see the file header) |
|
||||
| `nvn/*.tsv`, `nvn/names.txt`, `nvn/dmsh_chain.h` | The tables described above and the translation chain version header |
|
||||
| `tex/` | Texture format mapping, deswizzling, BC decompression, see [tex/README.md](tex/README.md) |
|
||||
| `metal/` | A standalone minimal Metal offscreen example, not compiled into the host, see [metal/README.md](metal/README.md) |
|
||||
| `tools/` | Offline tools, see below |
|
||||
| `tests/` | Unit tests |
|
||||
| `hle_vi.c`, `hle_nv.c` | Glue layer for display service and graphics driver initialization: returns host static objects or does nothing |
|
||||
|
||||
The scripts in `tools/`; usage is written in each file's header:
|
||||
|
||||
| Script | Purpose |
|
||||
|---|---|
|
||||
| `dmsh_xlate/` | The shader translation tool (C#), which references the translation library in `dm/third_party/ryujinx` |
|
||||
| `dmsh_build.py` | Drives the whole translation chain to produce the shader libraries; when the environment variable `IOSOUT=directory` is set, it also produces the iOS version |
|
||||
| `dmsh_chain.py`, `dmsh_chain.lock` | Translation chain version and tool fingerprints |
|
||||
| `dmsh_facts.py` | Generation and checking of the answer table `shader_facts.tsv` |
|
||||
| `dmsh_fetch.py` | Generates the "readable tile" versions of fragment shaders |
|
||||
| `c1_guard.py` | Generates `c1_full.tsv` |
|
||||
| `dmsh_dryrun.py` | Dry-run conversion of the whole library, measuring only "can it be converted" |
|
||||
| `shader_map.py`, `maxwell_refs.py` | Generates the shader map; reads resource references from the machine code |
|
||||
| `nvn_slots.py`, `gen_protos.py` | Generate `nvn_slots.tsv` / `names.txt`, and `nvn_protos.h` / the thunks |
|
||||
| `tbdr_budget.py`, `tbdr_load_dead.py`, `tbdr_store_dead.py`, `tbdr_pass_merge.py` | Read the `DM_NVN_PASSDUMP` log and analyze the load / store volume of each render pass's attachments per frame |
|
||||
| `passgpu_top.py` | Reads the `DM_NVN_PASSGPU` output and lists GPU time by pass |
|
||||
| `nometal_run.py` | Runs this translation chain on a machine without Apple's Metal compiler: shaders go into the libraries as source and are compiled on the phone |
|
||||
|
||||
## Building
|
||||
|
||||
The graphics layer has no separate library. `dm/host/Makefile` compiles `dm/gfx/*.c` and the source files under `dm/gfx/nvn/` and `dm/gfx/tex/` into the host `dmhost` by wildcard; the iOS App is built by `dm/ios/run.sh build`, which also copies the map, `pso_manifest.tsv`, `c1_full.tsv` and the `b-<V>/` shader libraries into the App. `tests/` and `metal/` do not go into the host.
|
||||
|
||||
The shader libraries are generated by `setup.sh`:
|
||||
|
||||
- the Mac version is in `$DM_ROOT/build/cache/metal_shader_cache/b-<V>/`;
|
||||
- the iOS version is in `$DM_ROOT/build/ios/dmsh_b/b-<V>/`.
|
||||
|
||||
After changing a file on the translation chain, the order for rebuilding manually is the same as in `setup.sh`: `dmsh_chain.py --header` → `dmsh_build.py` → `c1_guard.py` → recompile the host. `$DM_ROOT` defaults to `~/dm-work`.
|
||||
|
||||
## Tests
|
||||
|
||||
```sh
|
||||
make -C dm/gfx/tests run # graphics layer unit tests
|
||||
make -C dm/gfx/tex/tests run # texture submodule unit tests; the real-data items need texture samples from both the Switch and PC versions, see tex/README.md
|
||||
make -C dm/gfx/metal run # offscreen example self-test, see metal/README.md
|
||||
```
|
||||
|
||||
The tests in `dm/gfx/tests` compile the production code in directly and need a Metal device on the local machine; a few of them run under `MTL_DEBUG_LAYER=1` (the Metal validation layer). Most tests do not read the workspace; the exceptions are `t_refl` and `t_rt_range_ro`, which read the translated shader reflection json under `$DM_ROOT/build/cache/metal_shader_cache`, and `test_tbdr_budget.py`, which creates a temporary directory under `$DM_ROOT/run/gfx`. Main contents:
|
||||
|
||||
| Test | What it checks |
|
||||
|---|---|
|
||||
| `t_nvn` | Interface layer: fetches addresses from `nvnBootstrapLoader` the way the game does, all the way through to presentation |
|
||||
| `t_builtin` | The 4 embedded compute shaders |
|
||||
| `t_refl`, `t_hmap`, `t_cover`, `t_pace`, `t_pso_skey`, `t_dirty_slots` | Reflection parsing, hash table, full-coverage proof, pacer, pipeline manifest key, dirty page tracking |
|
||||
| `t_deswz_gpu` | GPU deswizzling |
|
||||
| `t_present_crop` | Presentation cropping |
|
||||
| `t_mip_extent` | Effective size when rendering to a mip level other than level 0 |
|
||||
| `t_fuse_check`, `t_reorder_chain`, `t_defer_chain`, `t_zskip`, `t_xv`, `t_ub`, `t_pfv`, `t_rt_range`, `t_rt_range_shape`, `t_rt_range_ro`, `t_rt_depth_ro` | Compile the replay layer `nvn_mtl.m` in directly and check the various optimization and diagnostic logic inside the replay layer |
|
||||
| `test_tbdr_budget.py` | The parsing in `tools/tbdr_budget.py` |
|
||||
|
||||
## Common run-time switches
|
||||
|
||||
All are environment variables. The iOS App sets `DM_NVN_SHMAP` and `DM_MSL_DIR` itself at startup.
|
||||
|
||||
Resource locations:
|
||||
|
||||
| Switch | Effect |
|
||||
|---|---|
|
||||
| `DM_NVN_SHMAP=path` | The shader map. The default is `../gfx/nvn/shader_map.tsv` relative to the executable's directory; `c1_full.tsv` and `pso_manifest.tsv` are taken from the same directory |
|
||||
| `DM_MSL_DIR=directory` | The parent directory of the shader libraries; the host loads from `b-<V>/` beneath it. When running the host on a Mac, set it to `$DM_ROOT/build/cache/metal_shader_cache` |
|
||||
| `DM_PSO_MANIFEST=path` or `off` | Use a different warm-up manifest, or turn warm-up off |
|
||||
| `DM_PSO_RECORD=path` | Appends the shaders and pipelines used in this run to a file, for re-recording the warm-up manifest |
|
||||
|
||||
Logging and capture:
|
||||
|
||||
| Switch | Effect |
|
||||
|---|---|
|
||||
| `DM_NVN_LOG=1` | Logs the creation of NVN objects |
|
||||
| `DM_NVN_FRAMES=N` | Prints the call table frame by frame for the first N frames (default 3) |
|
||||
| `DM_NVN_TSV=path` | Writes the per-frame call table and timings as TSV; adding `DM_NVN_TSV_CALLS=0` writes only the timing rows |
|
||||
| `DM_SLOWFRAME=1` | Writes the timing breakdown into the log only for the frames that dropped; the attribution script is `dm/ios/tools/slowframe.py` |
|
||||
| `DM_NVN_SHOT=frame[,frame…]:path` | Saves the swapchain texture as an image at the specified frames; `%d` in the path is replaced by the frame number |
|
||||
| `DM_NVN_SHOT_OUT=WxH` | Makes the screenshot above capture the picture after upscaling to this resolution instead |
|
||||
| `DM_NVN_TEXDUMP=frame:path` | Saves each color render target used in that frame as an image |
|
||||
| `DM_NVN_PASSDUMP=frame` or `start-end` | Writes each render pass's attachments, samples and presentation for these frames to standard error entry by entry, for analysis by `tools/tbdr_*.py`; additionally setting `DM_NVN_PASSDUMP_ALL` logs every draw |
|
||||
| `DM_NVN_PASSGPU=file` | Per-pass GPU time (requires device support for counter sampling at stage boundaries) |
|
||||
| `DM_NVN_PROF=1` | Wraps the implemented NVN functions in a timing wrapper and collects the time each function takes during recording |
|
||||
|
||||
Comparison and testing:
|
||||
|
||||
| Switch | Effect |
|
||||
|---|---|
|
||||
| `DM_NVN_TBDR=0` | Turns off all pass optimizations in the replay layer and takes the plainest path of "all attachments attached, all loaded, all stored", for equivalence comparison |
|
||||
| `DM_NVN_UNWRITTEN_DC=0` | Turns off the single item "attachments not written in this pass are not stored" |
|
||||
| `DM_NVN_FUSE_CHECK=1` | Same-frame check of pass merging; logs the comparison result every time |
|
||||
| `DM_TEST_NO_BC=1` | Forces the decompression path for "the GPU does not support BC compressed textures" on any machine |
|
||||
| `DM_FPS=30` or `60` | Pins the target frame rate |
|
||||
| `DM_PRESENT_HZ=N` | The frequency of presentation pacing (default 60); 0 means no frame limit and is for performance profiling only |
|
||||
|
||||
## Known limitations
|
||||
|
||||
The following paths are not implemented and report red in the log when reached (`RED_ONCE` in `nvn/nvn_mtl.m`):
|
||||
|
||||
- clears in the middle of a render pass, and color clears with a partial mask or partial scissor;
|
||||
- indexed quad primitives, 8-bit indices;
|
||||
- some forms of texture-to-texture copy and texture clear.
|
||||
|
||||
Functions listed in `g_nops`, such as `MultiDraw*IndirectCount`, `DispatchComputeIndirect`, `SetDepthBounds` and `DownsampleTextureView`, are empty implementations: calling them neither reports red nor has any effect.
|
||||
@@ -0,0 +1,183 @@
|
||||
# dm/gfx — 图形层(NVN → Metal)
|
||||
|
||||
English: [README.md](README.md)
|
||||
|
||||
游戏的 Switch 版用 NVN(Switch 的原生图形接口)画图。图形层在苹果的 Metal 上把这套接口重新实现一遍:游戏的每一次 NVN 调用落到这里,录成命令,提交时回放成 Metal 命令。游戏的着色器不在运行时翻译,而是在电脑上一次性离线翻译成 Metal 着色器库(电脑上没有苹果的 Metal 编译器时,最后的编译一步改在手机上做,见下文)。
|
||||
|
||||
整个项目的构建步骤见仓库根目录的 `README.zh-CN.md` 与 `setup.sh`,依赖见 `docs/DEPENDENCIES.zh-CN.md`;这里只讲图形层自己的事。
|
||||
|
||||
## 怎么工作
|
||||
|
||||
### 接管 NVN 接口
|
||||
|
||||
- 游戏主程序只导入一个 NVN 符号 `nvnBootstrapLoader`,其余 NVN 函数都通过它按名字取地址。宿主强制接管这个导入(`nvn/hle_nvn.c`),原版图形驱动一条指令都不执行。
|
||||
- 游戏会取址的名字共 523 个(`nvn/names.txt`)。每个名字对应一个跳板(`nvn/nvn_thunks.S`,生成文件):先给该函数的调用计数加一,再跳到实现。
|
||||
- 其中游戏主程序里有调用点的 216 个(`nvn/nvn_slots.tsv`)都有实现:203 个按 NVN 语义实现,13 个是空实现(`hle_nvn.c` 的 `g_nops`)。其余 307 个接报红桩,被调到时日志里打印 `【红】NVN 未实现被调用:名字`。
|
||||
- 每个实现都按 `nvn/nvn_protos.h`(生成文件)做编译期签名检查。苹果 arm64 与 Switch 的调用约定在小于 32 位的整型参数上不同,所以 `NVNboolean` 参数在宿主侧一律按 `uint32_t` 接、只看低 8 位。
|
||||
|
||||
### 两层:录制与回放
|
||||
|
||||
- **接口层 `nvn/hle_nvn.c`**:宿主侧的对象就地存在游戏给 NVN 对象分配的内存里,布局见 `nvn/nvn_obj.h`,每个都有静态断言保证不超过 NVN 的保留大小。命令按 `nvn_obj.h` 的记录格式录进游戏提供的命令内存。
|
||||
- **回放层 `nvn/nvn_mtl.m`**:提交时把记录流回放成 Metal 命令。
|
||||
- 内存池建成零拷贝的 `MTLBuffer`,GPU 地址等于 CPU 地址,所以只支持统一内存设备。
|
||||
- 「GPU 完成」的可见效果(同步对象就绪、事件写值、计数器)只在 Metal 命令缓冲真正完成之后发生。
|
||||
- 管线状态、深度模板状态按状态哈希缓存;启动时按预热清单在后台预建着色器与管线。
|
||||
- 游戏打包贴图是 Tegra 块线性排布,上传前解排布(见 `tex/README.zh-CN.md`)。
|
||||
- 出图:游戏的交换链贴图画到 `CAMetalLayer`,出图节拍由 `nvn/nvn_pace.h` 的节拍器排。
|
||||
|
||||
各 NVN 对象与命令落到 Metal 的哪个对象,见 [nvn_metal_mapping.zh-CN.md](nvn_metal_mapping.zh-CN.md)。
|
||||
|
||||
### 着色器翻译链
|
||||
|
||||
游戏的着色器是 Tegra X1 的 GPU 机器码(Maxwell 指令集)。从这种机器码到 Metal 着色语言的翻译不在手机上做,全部离线完成:
|
||||
|
||||
```
|
||||
Switch 原版着色器包
|
||||
→ tools/dmsh_xlate 用 Ryujinx 的着色器翻译库出 SPIR-V(C# 工具)
|
||||
→ spirv-cross SPIR-V 转 Metal 着色语言(MSL)
|
||||
→ xcrun metal / metallib 编成 Metal 着色器库
|
||||
```
|
||||
|
||||
没有苹果的 Metal 编译器时(Windows、Linux、没装 Xcode 的 Mac),最后一步做不了。`tools/nometal_run.py` 让同一条链照常跑完前两步,把翻译出的 MSL 源码原样放进库文件;这样做出的包在手机上把着色器编译一次,系统会缓存编好的结果。这条路由 `dm/tools/d2rm_pack.py` 使用,见仓库根目录的 `docs/NO_XCODE.zh-CN.md`。
|
||||
|
||||
整条链由 `tools/dmsh_build.py` 驱动,`setup.sh` 会替你跑。要点:
|
||||
|
||||
- **键**:每个着色器以它的控制段(0x880 字节)的 sha256 前 16 位十六进制为键。运行时游戏把控制段交给 `nvnProgramSetShaders`,回放层算出同一个键去找库。
|
||||
- **产物**:`<键>_b.metallib`(着色器库)、`<键>_b.json`(回放用的反射:各绑定的种类、槽号、在参数缓冲里的序号等)、`<键>_b.metal`(MSL 源)。部分片元着色器另有 `<键>_bf.metallib`,是「可读 tile」版本,供通道合并用(见 `tools/dmsh_fetch.py` 文件头)。目录里的 `_b_build.json` 记本次每个键的成败。
|
||||
- **`nvn/shader_map.tsv`**:着色器映射表,每个着色器变体一行。运行时只用其中「键 → 阶段(顶点 / 片元 / 计算)」。
|
||||
- **`nvn/shader_facts.tsv`**:翻译查询的作答表。翻译器需要知道一些机器码里读不出的事实(贴图的维度类型、图像格式、顶点属性与片元输出的分量类型、计算着色器的线程组大小与共享内存字节数),这张表按键给出答案。表随仓库,出着色器库只读这张表;表由 `tools/dmsh_facts.py` 维护,文件头有说明。
|
||||
- **翻译链版本与 `b-<V>/` 目录**:版本 V 是一串 12 位十六进制,由翻译链涉及的源文件内容、翻译选项和工具指纹(`tools/dmsh_chain.lock`)一起哈希得出,`tools/dmsh_chain.py` 负责计算。着色器库写进 `<输出目录>/b-<V>/`,每个反射 json 里也记着 V。宿主编译时从 `nvn/dmsh_chain.h` 取 V,只从 `b-<V>/` 加载,并逐个核对 json 里的版本;对不上就报红、不加载。所以改了链上任何一个文件、或换了工具,都要重新出库并重编宿主。
|
||||
- `dmsh_chain.py`:打印 V。
|
||||
- `dmsh_chain.py --check-tools`:核对本机工具与锁文件一致。
|
||||
- `dmsh_chain.py --update-lock`:按本机工具重写锁文件。
|
||||
- `dmsh_chain.py --header`:重写 `nvn/dmsh_chain.h`。
|
||||
- 本机的 Xcode 或 spirv-cross 版本与仓库登记的不同是正常的,`setup.sh` 会自动按本机工具重新登记。
|
||||
- **`nvn/c1_full.tsv`**:着色器自带常数段(c1)的下标清单,由 `tools/c1_guard.py` 扫描翻译出的 MSL 生成,列出「运行时下标没能证明有界」的着色器键。首行记着它对应的 `b-<V>`。回放层对清单里的着色器给 c1 单独分配整块 64 KiB 缓冲;清单缺失或版本对不上时报红,并对全部着色器都这样保守处理。
|
||||
- **`nvn/pso_manifest.tsv`**:预热种子清单,记启动后最先用到的着色器与管线,行序就是预建顺序,不要排序。
|
||||
- **程序本体内嵌的着色器**:主程序里另有 4 个计算着色器不在着色器包里,按反汇编手写成 MSL,在 `nvn/nvn_builtin.h`。
|
||||
|
||||
翻译时遵循的绑定约定(`tools/maxwell_refs.py` 文件头):
|
||||
|
||||
- uniform 缓冲 r 在机器码里是常量段 `c[3 + r]`;
|
||||
- 分离贴图 r 的句柄在 `c[2][0x168 + 8r]`,分离采样器 r 的句柄在 `c[2][0x568 + 8r]`;
|
||||
- 存储缓冲 r 的地址在 `c[0][基址 + 16r]`,基址:顶点 0x110、计算 0x310、片元 0x510;
|
||||
- 窗口原点在左上、深度范围 0 到 1,与 Metal 一致,翻译时不翻转。
|
||||
|
||||
## 目录结构
|
||||
|
||||
| 位置 | 内容 |
|
||||
|---|---|
|
||||
| `nvn/hle_nvn.c` | 接口层:接管 NVN、对象实现、命令录制、出图节拍 |
|
||||
| `nvn/nvn_mtl.m`、`nvn/nvn_mtl.h` | 回放层:Metal 设备、内存池、贴图、着色器加载、管线、绘制、出图 |
|
||||
| `nvn/nvn_obj.h` | 宿主侧对象布局与命令记录格式,两层共用 |
|
||||
| `nvn/nvn_entry.S`、`nvn/nvn_thunks.S` | 未实现桩与计时包装的入口、逐函数跳板 |
|
||||
| `nvn/nvn_tex.c`、`nvn/nvn_tex.h` | 块线性贴图的存储尺寸、对齐、各级偏移(移植自 deko3d) |
|
||||
| `nvn/nvn_dirty.c`、`nvn/nvn_dirty.h` | 用写保护跟踪游戏内存的脏页,判断贴图内容是否变了需要重传 |
|
||||
| `nvn/nvn_refl.m`、`nvn/nvn_refl.h` | 着色器反射 json 转成定长 C 数组,绘制时只遍历数组 |
|
||||
| `nvn/nvn_hmap.h`、`nvn/nvn_cover.h`、`nvn/nvn_pace.h`、`nvn/nvn_pso_skey.h` | 哈希表、全覆盖绘制的几何证明、出图节拍器、管线清单键 |
|
||||
| `nvn/nvn_builtin.h` | 主程序内嵌的 4 个计算着色器的手写 MSL |
|
||||
| `nvn/include/nvn.h` | NVN 接口声明(第三方,许可证见文件头) |
|
||||
| `nvn/*.tsv`、`nvn/names.txt`、`nvn/dmsh_chain.h` | 上文讲的各张表与翻译链版本头 |
|
||||
| `tex/` | 贴图格式映射、解排布、BC 解压,见 [tex/README.zh-CN.md](tex/README.zh-CN.md) |
|
||||
| `metal/` | 独立的最小 Metal 离屏示例,不编进宿主,见 [metal/README.zh-CN.md](metal/README.zh-CN.md) |
|
||||
| `tools/` | 离线工具,见下 |
|
||||
| `tests/` | 单元测试 |
|
||||
| `hle_vi.c`、`hle_nv.c` | 显示服务与图形驱动初始化的胶水层:返回宿主静态对象或空操作 |
|
||||
|
||||
`tools/` 里的脚本,用法都写在各自文件头:
|
||||
|
||||
| 脚本 | 用途 |
|
||||
|---|---|
|
||||
| `dmsh_xlate/` | 着色器翻译工具(C#),引用 `dm/third_party/ryujinx` 里的翻译库 |
|
||||
| `dmsh_build.py` | 驱动整条翻译链出着色器库;设环境变量 `IOSOUT=目录` 时同时出 iOS 版 |
|
||||
| `dmsh_chain.py`、`dmsh_chain.lock` | 翻译链版本与工具指纹 |
|
||||
| `dmsh_facts.py` | 作答表 `shader_facts.tsv` 的生成与核对 |
|
||||
| `dmsh_fetch.py` | 生成片元着色器的「可读 tile」版本 |
|
||||
| `c1_guard.py` | 生成 `c1_full.tsv` |
|
||||
| `dmsh_dryrun.py` | 全库干转,只量「能不能转」 |
|
||||
| `shader_map.py`、`maxwell_refs.py` | 生成着色器映射表;从机器码读资源引用 |
|
||||
| `nvn_slots.py`、`gen_protos.py` | 生成 `nvn_slots.tsv` / `names.txt`、`nvn_protos.h` / 跳板 |
|
||||
| `tbdr_budget.py`、`tbdr_load_dead.py`、`tbdr_store_dead.py`、`tbdr_pass_merge.py` | 读 `DM_NVN_PASSDUMP` 的日志,分析每帧各渲染通道附件的读入 / 写回量 |
|
||||
| `passgpu_top.py` | 读 `DM_NVN_PASSGPU` 的输出,按通道列 GPU 时间 |
|
||||
| `nometal_run.py` | 在没有苹果 Metal 编译器的机器上跑这条翻译链:着色器以源码进库,到手机上再编 |
|
||||
|
||||
## 构建
|
||||
|
||||
图形层没有单独的库。`dm/host/Makefile` 按通配把 `dm/gfx/*.c`、`dm/gfx/nvn/` 与 `dm/gfx/tex/` 下的源文件编进宿主 `dmhost`;iOS App 由 `dm/ios/run.sh build` 构建,同时把映射表、`pso_manifest.tsv`、`c1_full.tsv` 和 `b-<V>/` 着色器库拷进 App。`tests/` 与 `metal/` 不进宿主。
|
||||
|
||||
着色器库由 `setup.sh` 生成:
|
||||
|
||||
- Mac 版在 `$DM_ROOT/build/cache/metal_shader_cache/b-<V>/`;
|
||||
- iOS 版在 `$DM_ROOT/build/ios/dmsh_b/b-<V>/`。
|
||||
|
||||
改了翻译链上的文件后,手动重出的顺序与 `setup.sh` 里相同:`dmsh_chain.py --header` → `dmsh_build.py` → `c1_guard.py` → 重编宿主。`$DM_ROOT` 缺省是 `~/dm-work`。
|
||||
|
||||
## 测试
|
||||
|
||||
```sh
|
||||
make -C dm/gfx/tests run # 图形层单测
|
||||
make -C dm/gfx/tex/tests run # 贴图子模块单测;真数据项要 Switch 与 PC 两版的贴图样本,见 tex/README.zh-CN.md
|
||||
make -C dm/gfx/metal run # 离屏示例自测,见 metal/README.zh-CN.md
|
||||
```
|
||||
|
||||
`dm/gfx/tests` 的测试直接编入生产代码,需要本机有 Metal 设备;其中几项在 `MTL_DEBUG_LAYER=1`(Metal 校验层)下运行。多数测试不读工作区;例外是 `t_refl` 与 `t_rt_range_ro` 要读 `$DM_ROOT/build/cache/metal_shader_cache` 下翻译好的着色器反射 json,`test_tbdr_budget.py` 会在 `$DM_ROOT/run/gfx` 下建临时目录。主要内容:
|
||||
|
||||
| 测试 | 核什么 |
|
||||
|---|---|
|
||||
| `t_nvn` | 接口层:照游戏的用法从 `nvnBootstrapLoader` 取址,一路走到出图 |
|
||||
| `t_builtin` | 4 个内嵌计算着色器 |
|
||||
| `t_refl`、`t_hmap`、`t_cover`、`t_pace`、`t_pso_skey`、`t_dirty_slots` | 反射解析、哈希表、全覆盖证明、节拍器、管线清单键、脏页跟踪 |
|
||||
| `t_deswz_gpu` | GPU 解排布 |
|
||||
| `t_present_crop` | 出图裁切 |
|
||||
| `t_mip_extent` | 渲染到非第 0 级 mip 时的有效尺寸 |
|
||||
| `t_fuse_check`、`t_reorder_chain`、`t_defer_chain`、`t_zskip`、`t_xv`、`t_ub`、`t_pfv`、`t_rt_range`、`t_rt_range_shape`、`t_rt_range_ro`、`t_rt_depth_ro` | 直接编入回放层 `nvn_mtl.m`,核回放层内部的各项优化与诊断逻辑 |
|
||||
| `test_tbdr_budget.py` | `tools/tbdr_budget.py` 的解析 |
|
||||
|
||||
## 常用运行时开关
|
||||
|
||||
都是环境变量。iOS App 启动时自己设好 `DM_NVN_SHMAP` 与 `DM_MSL_DIR`。
|
||||
|
||||
资源位置:
|
||||
|
||||
| 开关 | 作用 |
|
||||
|---|---|
|
||||
| `DM_NVN_SHMAP=路径` | 着色器映射表。缺省是可执行文件目录下的 `../gfx/nvn/shader_map.tsv`;`c1_full.tsv` 与 `pso_manifest.tsv` 取同目录 |
|
||||
| `DM_MSL_DIR=目录` | 着色器库的上级目录,宿主从其下的 `b-<V>/` 加载。在 Mac 上跑宿主时设为 `$DM_ROOT/build/cache/metal_shader_cache` |
|
||||
| `DM_PSO_MANIFEST=路径` 或 `off` | 换一份预热清单,或关掉预热 |
|
||||
| `DM_PSO_RECORD=路径` | 把本次运行用到的着色器与管线追加记到文件,用来重录预热清单 |
|
||||
|
||||
日志与抓取:
|
||||
|
||||
| 开关 | 作用 |
|
||||
|---|---|
|
||||
| `DM_NVN_LOG=1` | 记录 NVN 对象的创建 |
|
||||
| `DM_NVN_FRAMES=N` | 前 N 帧逐帧打印调用表(缺省 3) |
|
||||
| `DM_NVN_TSV=路径` | 每帧调用表与计时写成 TSV;再加 `DM_NVN_TSV_CALLS=0` 只写计时行 |
|
||||
| `DM_SLOWFRAME=1` | 只把掉帧那几帧的计时分项写进日志;归因脚本是 `dm/ios/tools/slowframe.py` |
|
||||
| `DM_NVN_SHOT=帧号[,帧号…]:路径` | 在指定帧把交换链贴图存成图片,路径里的 `%d` 换成帧号 |
|
||||
| `DM_NVN_SHOT_OUT=宽x高` | 上面的截图改截放大到该分辨率后的画面 |
|
||||
| `DM_NVN_TEXDUMP=帧号:路径` | 把该帧用过的颜色渲染目标逐张存图 |
|
||||
| `DM_NVN_PASSDUMP=帧号` 或 `起-止` | 把这些帧每个渲染通道的附件、采样、出图逐条写到标准错误,供 `tools/tbdr_*.py` 分析;再设 `DM_NVN_PASSDUMP_ALL` 则每次绘制都记 |
|
||||
| `DM_NVN_PASSGPU=文件` | 逐通道 GPU 时间(需要设备支持阶段边界的计数采样) |
|
||||
| `DM_NVN_PROF=1` | 给已实现的 NVN 函数套计时包装,统计录制期各函数耗时 |
|
||||
|
||||
对照与测试:
|
||||
|
||||
| 开关 | 作用 |
|
||||
|---|---|
|
||||
| `DM_NVN_TBDR=0` | 关掉回放层全部通道优化,走「附件全挂、全读入、全写回」的最朴素路径,用来做等价对照 |
|
||||
| `DM_NVN_UNWRITTEN_DC=0` | 关掉「本通道没写的附件不写回」这一项 |
|
||||
| `DM_NVN_FUSE_CHECK=1` | 通道合并的同帧核对,逐次把比对结果记进日志 |
|
||||
| `DM_TEST_NO_BC=1` | 在任何机器上强制走「显卡不支持 BC 压缩贴图」的解压路径 |
|
||||
| `DM_FPS=30` 或 `60` | 钉住目标帧数 |
|
||||
| `DM_PRESENT_HZ=N` | 出图节拍的频率(缺省 60);0 表示不限帧,只用于性能剖析 |
|
||||
|
||||
## 已知限制
|
||||
|
||||
下面这些路径没有实现,走到会在日志里报红(`nvn/nvn_mtl.m` 里的 `RED_ONCE`):
|
||||
|
||||
- 渲染通道中途的清除、带部分掩码或部分剪裁的清色;
|
||||
- 带索引的四边形图元、8 位索引;
|
||||
- 部分形态的贴图到贴图拷贝与清贴图。
|
||||
|
||||
`MultiDraw*IndirectCount`、`DispatchComputeIndirect`、`SetDepthBounds`、`DownsampleTextureView` 等列在 `g_nops` 里的函数是空实现,调用不报红也不生效。
|
||||
@@ -0,0 +1,19 @@
|
||||
// nv::(NVN 下面的显卡驱动胶水层:建传输内存、连 nvdrv 服务)。NVN 已整块换成宿主空设备,这层无事可做。
|
||||
// 分配器回调记在宿主全局 g_nv_alloc,图形层以后要按游戏的分配器分内存时从这里取。
|
||||
// nv:: (the GPU driver glue layer beneath NVN: creates transfer memory, connects to the nvdrv service). NVN has been replaced wholesale with a host null device, so this layer has nothing to do.
|
||||
// The allocator callbacks are recorded in the host global g_nv_alloc; the graphics layer takes them from here later when it needs to allocate memory with the game's allocator.
|
||||
#include "../host/hle.h"
|
||||
|
||||
typedef void *(*nv_alloc_fn)(unsigned long size, unsigned long align, void *user);
|
||||
typedef void (*nv_free_fn)(void *p, void *user);
|
||||
typedef void *(*nv_realloc_fn)(void *p, unsigned long size, void *user);
|
||||
struct nv_allocator { nv_alloc_fn alloc; nv_free_fn free; nv_realloc_fn realloc; void *user; };
|
||||
struct nv_allocator g_nv_alloc, g_nv_devtools_alloc;
|
||||
|
||||
#define WHY "NVN 已整块换成宿主空设备,驱动胶水层无事可做"
|
||||
HLE_FORCE("_ZN2nv20SetGraphicsAllocatorEPFPvmmS0_EPFvS0_S0_EPFS0_S0_mS0_ES0_", WHY ";分配器记入 g_nv_alloc",
|
||||
void, h_nv_SetAlloc, nv_alloc_fn a, nv_free_fn f, nv_realloc_fn r, void *u) { g_nv_alloc = (struct nv_allocator){a, f, r, u}; }
|
||||
HLE_FORCE("_ZN2nv28SetGraphicsDevtoolsAllocatorEPFPvmmS0_EPFvS0_S0_EPFS0_S0_mS0_ES0_", WHY ";分配器记入 g_nv_devtools_alloc",
|
||||
void, h_nv_SetDevAlloc, nv_alloc_fn a, nv_free_fn f, nv_realloc_fn r, void *u) { g_nv_devtools_alloc = (struct nv_allocator){a, f, r, u}; }
|
||||
HLE_FORCE("_ZN2nv18InitializeGraphicsEPvm", WHY, void, h_nv_Init, void *mem, unsigned long size) { (void)mem; (void)size; }
|
||||
HLE_FORCE("_ZN2nv16FinalizeGraphicsEv", WHY, void, h_nv_Fin, void) {}
|
||||
@@ -0,0 +1,19 @@
|
||||
// nn::vi(显示层):真机经 vi 服务开显示、建图层、取原生窗口句柄;句柄交给 NVN 的窗口 builder。
|
||||
// 宿主:返回宿主静态对象;接 Metal 时原生窗口对应前端的 CAMetalLayer(front_metal_layer())。
|
||||
// nn::vi (display layer): on a real device, the vi service is used to open the display, create a layer and get the native window handle; the handle is passed to NVN's window builder.
|
||||
// Host: returns host static objects; when hooking up Metal, the native window corresponds to the front end's CAMetalLayer (front_metal_layer()).
|
||||
#include "../host/hle.h"
|
||||
|
||||
static struct { uint32_t magic; } g_display = {0x50534944}, g_layer = {0x5259414c};
|
||||
static struct { uint32_t magic; void *layer; } g_native = {0x4e49574e, 0};
|
||||
|
||||
HLE_FORCE("_ZN2nn2vi10InitializeEv", "显示服务初始化;宿主无 vi 服务", void, h_vi_Init, void) {}
|
||||
HLE_FORCE("_ZN2nn2vi18OpenDefaultDisplayEPPNS0_7DisplayE", "开默认显示;宿主给静态对象", Result, h_vi_OpenDisp, void **out) {
|
||||
*out = &g_display; return RES_OK;
|
||||
}
|
||||
HLE_FORCE("_ZN2nn2vi11CreateLayerEPPNS0_5LayerEPNS0_7DisplayE", "建图层;宿主给静态对象", Result, h_vi_CreateLayer, void **out, void *disp) {
|
||||
(void)disp; *out = &g_layer; return RES_OK;
|
||||
}
|
||||
HLE_FORCE("_ZN2nn2vi15GetNativeWindowEPPvPNS0_5LayerE", "原生窗口句柄,交给 NVN 窗口 builder;宿主给静态对象", Result, h_vi_GetNative, void **out, void *layer) {
|
||||
(void)layer; *out = &g_native; return RES_OK;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
test_offscreen
|
||||
*.o
|
||||
@@ -0,0 +1,23 @@
|
||||
CC = clang
|
||||
CFLAGS = -O2 -Wall -Wextra -std=c11
|
||||
OBJCFLAGS = -O2 -Wall -Wextra -fobjc-arc
|
||||
LDLIBS = -framework Metal -framework Foundation
|
||||
|
||||
all: test_offscreen
|
||||
|
||||
mtl_backend.o: mtl_backend.m mtl_backend.h
|
||||
$(CC) $(OBJCFLAGS) -c -o $@ $<
|
||||
|
||||
test_offscreen.o: test_offscreen.c mtl_backend.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
test_offscreen: test_offscreen.o mtl_backend.o
|
||||
$(CC) -o $@ $^ $(LDLIBS)
|
||||
|
||||
run: test_offscreen
|
||||
./test_offscreen
|
||||
|
||||
clean:
|
||||
rm -f test_offscreen *.o
|
||||
|
||||
.PHONY: all run clean
|
||||
@@ -0,0 +1,60 @@
|
||||
# dm/gfx/metal — minimal Metal offscreen example
|
||||
|
||||
中文:[README.zh-CN.md](README.zh-CN.md)
|
||||
|
||||
A standalone small module: it wraps Metal in a pure C interface, renders the picture to an offscreen texture and reads it back to the CPU, without putting anything on screen. It is not compiled into the host (`dm/host/Makefile` does not include this directory); the Metal replay layer the game actually uses is in `../nvn/nvn_mtl.m`. This is kept as a reference that compiles on its own and can be understood in a few dozen lines, and as a small probe for verifying Metal behavior.
|
||||
|
||||
## Interface (`mtl_backend.h`)
|
||||
|
||||
| Interface | Effect |
|
||||
|---|---|
|
||||
| `mtlb_init()` / `mtlb_shutdown(ctx)` | Create / release the context: device, command queue, the current frame's command buffer, pipeline cache |
|
||||
| `mtlb_target(ctx, w, h, fmt)` / `mtlb_target_free(rt)` | Create / release an offscreen render target, with format `MTLB_FMT_BGRA8` or `MTLB_FMT_RGBA8` |
|
||||
| `mtlb_clear(ctx, rt, r, g, b, a)` | Records a render pass into the current frame that clears the target to the given color |
|
||||
| `mtlb_triangle(ctx, rt)` | Records another render pass into the current frame (keeping existing contents) that draws a three-color triangle |
|
||||
| `mtlb_readback(ctx, rt, buf, size)` | Submits the current frame, waits for the GPU to complete, and reads the pixels back into `buf` tightly packed by row (row 0 is the top of the image) |
|
||||
|
||||
Functions return 0 for success and -1 for failure, and the failure reason is printed to standard error. The implementation is in `mtl_backend.m` (Objective-C, ARC).
|
||||
|
||||
Design points:
|
||||
|
||||
- **One command buffer per frame**: it is created only when a pass is first recorded; subsequent clears and triangles are appended to the same command buffer, and it is submitted only at readback.
|
||||
- **Render targets are not global variables**: the context and each target are opaque pointers.
|
||||
- **Storage mode is Shared**: on unified-memory devices a Shared texture can be used directly as a render attachment, and after the GPU completes the CPU reads it directly, with no intermediate buffer needed. On non-unified-memory devices `mtlb_init` reports an error outright.
|
||||
- The triangle's shader is inline MSL, compiled at run time.
|
||||
|
||||
## Building and running
|
||||
|
||||
```sh
|
||||
make -C dm/gfx/metal # produces test_offscreen
|
||||
make -C dm/gfx/metal run # runs the self-test; exit code 0 means all passed
|
||||
make -C dm/gfx/metal clean
|
||||
```
|
||||
|
||||
Only Xcode's command-line tools are needed; no game files are needed. The build products are already listed in this directory's `.gitignore`.
|
||||
|
||||
## Self-test (`test_offscreen.c`)
|
||||
|
||||
All expected values are computed independently in the test, without reading the backend's internal data:
|
||||
|
||||
- the triangle vertices are copied separately in the test;
|
||||
- normalized coordinates are converted to pixels: `px = (x + 1) / 2 · W`, `py = (1 − y) / 2 · H`;
|
||||
- the color at a pixel center is the linear interpolation of the three vertex colors by barycentric coordinates.
|
||||
|
||||
The two tests are each run once for both formats, BGRA8 and RGBA8:
|
||||
|
||||
1. Clear to a solid color and compare pixel by pixel.
|
||||
2. Clear the screen and then draw the triangle: pixels inside the triangle (more than 1 pixel from an edge) are compared with the interpolated value, with the tolerance given by `TOL` in the source; pixels outside are compared with the clear color; the 1-pixel band right along the edges is skipped, since rasterization edge rules are outside the scope of this test.
|
||||
|
||||
Before readback the buffer is first filled with 0x5a, to prevent "passing even though the backend wrote nothing".
|
||||
|
||||
## Probe (`probe/p_nocopy.m`)
|
||||
|
||||
A single-file program with no build target; compile it manually with clang when needed. It verifies one thing that the replay layer's memory pool approach depends on: on a piece of memory that is not page-aligned, after extending its start and end outward to page boundaries, a zero-copy `MTLBuffer` can be created; two such buffers are allowed to overlap; and what the GPU writes can be read by the CPU through the original pointer.
|
||||
|
||||
## Limitations
|
||||
|
||||
- The triangle vertices are hard-coded in `mtl_backend.m`; there is no configurable state such as vertex buffers, shaders or viewports.
|
||||
- `mtlb_readback` waits synchronously for the whole frame to complete and blocks the calling thread.
|
||||
- Only a single color attachment and two 8-bit formats are supported; there is no depth / stencil, multisampling or multiple attachments.
|
||||
- Not thread-safe; only unified-memory devices are supported.
|
||||
@@ -0,0 +1,60 @@
|
||||
# dm/gfx/metal — 最小 Metal 离屏示例
|
||||
|
||||
English: [README.md](README.md)
|
||||
|
||||
一个独立的小模块:用纯 C 接口包住 Metal,把画面渲到离屏纹理再读回 CPU,不上屏。它不编进宿主(`dm/host/Makefile` 不收本目录),游戏实际用的 Metal 回放层在 `../nvn/nvn_mtl.m`。这里留作一个能独立编译、几十行就能看懂的参照,以及验证 Metal 行为的小探针。
|
||||
|
||||
## 接口(`mtl_backend.h`)
|
||||
|
||||
| 接口 | 作用 |
|
||||
|---|---|
|
||||
| `mtlb_init()` / `mtlb_shutdown(ctx)` | 建 / 释放上下文:设备、命令队列、当前帧的命令缓冲、管线缓存 |
|
||||
| `mtlb_target(ctx, w, h, fmt)` / `mtlb_target_free(rt)` | 建 / 释放一个离屏渲染目标,格式为 `MTLB_FMT_BGRA8` 或 `MTLB_FMT_RGBA8` |
|
||||
| `mtlb_clear(ctx, rt, r, g, b, a)` | 往当前帧录一个渲染通道,把目标清成指定颜色 |
|
||||
| `mtlb_triangle(ctx, rt)` | 往当前帧再录一个渲染通道(保留已有内容),画一个三色三角形 |
|
||||
| `mtlb_readback(ctx, rt, buf, size)` | 提交当前帧、等 GPU 完成,把像素按行紧排读回 `buf`(第 0 行是图像顶部) |
|
||||
|
||||
函数返回 0 表示成功、-1 表示失败,失败原因打到标准错误。实现在 `mtl_backend.m`(Objective-C,ARC)。
|
||||
|
||||
设计要点:
|
||||
|
||||
- **一帧一个命令缓冲**:第一次录通道时才创建,之后的清除、三角形都追加进同一个命令缓冲,读回时才提交。
|
||||
- **渲染目标不是全局变量**:上下文与每个目标都是不透明指针。
|
||||
- **存储模式用 Shared**:在统一内存设备上,Shared 纹理可以直接当渲染附件,GPU 完成后 CPU 直接读,不需要中转缓冲。非统一内存设备上 `mtlb_init` 直接报错。
|
||||
- 三角形的着色器是内联的 MSL,运行时编译。
|
||||
|
||||
## 编译与运行
|
||||
|
||||
```sh
|
||||
make -C dm/gfx/metal # 产出 test_offscreen
|
||||
make -C dm/gfx/metal run # 跑自测,退出码 0 表示全过
|
||||
make -C dm/gfx/metal clean
|
||||
```
|
||||
|
||||
只需要 Xcode 的命令行工具,不需要游戏文件。编译产物已列入本目录的 `.gitignore`。
|
||||
|
||||
## 自测(`test_offscreen.c`)
|
||||
|
||||
期望值全部在测试里独立算出,不读后端内部数据:
|
||||
|
||||
- 三角形顶点在测试里另抄一份;
|
||||
- 归一化坐标换算到像素:`px = (x + 1) / 2 · W`,`py = (1 − y) / 2 · H`;
|
||||
- 像素中心的颜色按重心坐标对三个顶点颜色线性插值。
|
||||
|
||||
两个测试对 BGRA8、RGBA8 两种格式各跑一遍:
|
||||
|
||||
1. 清成纯色,逐像素比。
|
||||
2. 清屏后画三角形:三角形内侧(离边超过 1 像素)的像素与插值值比,容差见源码里的 `TOL`;外侧像素与清屏色比;紧贴边的 1 像素带跳过,光栅化的边缘规则不在本测试范围内。
|
||||
|
||||
读回前先把缓冲填成 0x5a,防止「后端什么都没写也判过」。
|
||||
|
||||
## 探针(`probe/p_nocopy.m`)
|
||||
|
||||
单文件程序,没有构建目标,需要时手动用 clang 编译。它验证回放层内存池做法所依赖的一件事:在一段不按页对齐的内存上,把首尾外扩到页边界后可以建成零拷贝的 `MTLBuffer`,两个这样的缓冲允许重叠,GPU 写入的内容 CPU 经原指针能读到。
|
||||
|
||||
## 局限
|
||||
|
||||
- 三角形顶点写死在 `mtl_backend.m`,没有顶点缓冲、着色器、视口等可配置状态。
|
||||
- `mtlb_readback` 同步等整帧完成,会阻塞调用线程。
|
||||
- 只支持单个颜色附件、两种 8 位格式;没有深度 / 模板、多重采样、多附件。
|
||||
- 非线程安全;只支持统一内存设备。
|
||||
@@ -0,0 +1,55 @@
|
||||
/* mtl_backend.h —— 最小 Metal 离屏后端(纯 C 接口,NVN→Metal 后端底座)
|
||||
*
|
||||
* 调用模型:
|
||||
* ctx = mtlb_init();
|
||||
* rt = mtlb_target(ctx, w, h, MTLB_FMT_BGRA8);
|
||||
* mtlb_clear(ctx, rt, ...); // 录一个 pass 进「当前帧」的命令缓冲
|
||||
* mtlb_triangle(ctx, rt); // 再录一个 pass,同一命令缓冲
|
||||
* mtlb_readback(ctx, rt, buf, n);// 提交当前帧、等 GPU 完成、读回像素
|
||||
*
|
||||
* 一帧 = 一个 MTLCommandBuffer,在第一次录 pass 时创建,readback 时提交。
|
||||
* 所有函数返回 0 成功 / -1 失败(失败原因打到 stderr)。非线程安全。
|
||||
* mtl_backend.h - minimal Metal offscreen backend (pure C interface, the base of the NVN→Metal backend)
|
||||
* Call model:
|
||||
* ctx = mtlb_init();
|
||||
* rt = mtlb_target(ctx, w, h, MTLB_FMT_BGRA8);
|
||||
* mtlb_clear(ctx, rt, ...); // record a pass into the "current frame" command buffer
|
||||
* mtlb_triangle(ctx, rt); // record another pass, same command buffer
|
||||
* mtlb_readback(ctx, rt, buf, n);// commit the current frame, wait for the GPU to finish, read back pixels
|
||||
* One frame = one MTLCommandBuffer, created when the first pass is recorded and committed at readback.
|
||||
* All functions return 0 on success / -1 on failure (the failure reason is printed to stderr). Not thread-safe.
|
||||
*/
|
||||
#ifndef MTL_BACKEND_H
|
||||
#define MTL_BACKEND_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct mtlb_ctx mtlb_ctx; /* 设备 + 命令队列 + 当前帧命令缓冲 + 管线缓存 | device + command queue + current-frame command buffer + pipeline cache */
|
||||
typedef struct mtlb_rt mtlb_rt; /* 一个离屏渲染目标 | an offscreen render target */
|
||||
|
||||
typedef enum {
|
||||
MTLB_FMT_BGRA8 = 0, /* 内存字节序 B,G,R,A(unorm) | byte order in memory B,G,R,A (unorm) */
|
||||
MTLB_FMT_RGBA8 = 1, /* 内存字节序 R,G,B,A(unorm) | byte order in memory R,G,B,A (unorm) */
|
||||
} mtlb_fmt;
|
||||
|
||||
mtlb_ctx *mtlb_init(void);
|
||||
void mtlb_shutdown(mtlb_ctx *ctx);
|
||||
|
||||
mtlb_rt *mtlb_target(mtlb_ctx *ctx, uint32_t w, uint32_t h, mtlb_fmt fmt);
|
||||
void mtlb_target_free(mtlb_rt *rt);
|
||||
|
||||
int mtlb_clear(mtlb_ctx *ctx, mtlb_rt *rt, float r, float g, float b, float a);
|
||||
int mtlb_triangle(mtlb_ctx *ctx, mtlb_rt *rt);
|
||||
|
||||
/* buf 至少 w*h*4 字节;按行紧排、第 0 行是图像顶部,字节序同 rt 的格式。 | buf is at least w*h*4 bytes; rows tightly packed, row 0 is the top of the image, byte order same as rt's format. */
|
||||
int mtlb_readback(mtlb_ctx *ctx, mtlb_rt *rt, void *buf, size_t buf_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,210 @@
|
||||
// mtl_backend.m —— mtl_backend.h 的实现(ObjC,-fobjc-arc)
|
||||
//
|
||||
// 渲染目标存储模式取 MTLStorageModeShared:本机是 Apple Silicon 统一内存,
|
||||
// Shared 纹理可直接当渲染附件,GPU 完成后 CPU 用 getBytes 直接读,无需额外的
|
||||
// blit 拷贝与中转缓冲,回读路径最短。代价:Shared 纹理不能做无损帧缓冲压缩,
|
||||
// 将来走性能路线时再换 Private + blit 回读(只影响 mtlb_target / mtlb_readback)。
|
||||
// mtl_backend.m - implementation of mtl_backend.h (ObjC, -fobjc-arc)
|
||||
// Render targets use storage mode MTLStorageModeShared: this machine is Apple Silicon with unified memory,
|
||||
// a Shared texture can be used directly as a render attachment, and once the GPU is done the CPU reads it directly with getBytes, with no extra
|
||||
// blit copy or staging buffer, so the readback path is the shortest. Cost: Shared textures cannot use lossless framebuffer compression;
|
||||
// when taking the performance route later, switch to Private + blit readback (only affects mtlb_target / mtlb_readback).
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Metal/Metal.h>
|
||||
#include <stdio.h>
|
||||
#include "mtl_backend.h"
|
||||
|
||||
// ---- 内部对象(用 ObjC 类承载,ARC 管理 Metal 对象生命周期;对外是不透明 C 指针)----
|
||||
// ---- Internal objects (held in ObjC classes, ARC manages Metal object lifetimes; exposed as opaque C pointers) ----
|
||||
|
||||
@interface MTLBCtx : NSObject
|
||||
@property(nonatomic, strong) id<MTLDevice> dev;
|
||||
@property(nonatomic, strong) id<MTLCommandQueue> queue;
|
||||
@property(nonatomic, strong) id<MTLCommandBuffer> frame; // 当前帧,懒建,readback 时提交 | current frame, created lazily, committed at readback
|
||||
@property(nonatomic, strong) id<MTLLibrary> triLib;
|
||||
@property(nonatomic, strong) NSMutableDictionary<NSNumber *, id<MTLRenderPipelineState>> *triPso; // 按像素格式缓存 | cached by pixel format
|
||||
@end
|
||||
@implementation MTLBCtx
|
||||
@end
|
||||
|
||||
@interface MTLBRt : NSObject
|
||||
@property(nonatomic, strong) id<MTLTexture> tex;
|
||||
@property(nonatomic) uint32_t w, h;
|
||||
@end
|
||||
@implementation MTLBRt
|
||||
@end
|
||||
|
||||
#define CTX(p) ((__bridge MTLBCtx *)(void *)(p))
|
||||
#define RT(p) ((__bridge MTLBRt *)(void *)(p))
|
||||
|
||||
static void err(const char *where, NSError *e) {
|
||||
fprintf(stderr, "[mtlb] %s 失败%s%s\n", where, e ? ":" : "",
|
||||
e ? e.localizedDescription.UTF8String : "");
|
||||
}
|
||||
|
||||
static id<MTLCommandBuffer> frame_cb(MTLBCtx *c) {
|
||||
if (!c.frame) c.frame = [c.queue commandBuffer];
|
||||
return c.frame;
|
||||
}
|
||||
|
||||
// ---- 设备 ----
|
||||
// ---- Device ----
|
||||
|
||||
mtlb_ctx *mtlb_init(void) {
|
||||
@autoreleasepool {
|
||||
id<MTLDevice> dev = MTLCreateSystemDefaultDevice();
|
||||
if (!dev) { err("MTLCreateSystemDefaultDevice", nil); return NULL; }
|
||||
if (!dev.hasUnifiedMemory) { err("需要统一内存设备(Shared 渲染目标)", nil); return NULL; }
|
||||
MTLBCtx *c = [MTLBCtx new];
|
||||
c.dev = dev;
|
||||
c.queue = [dev newCommandQueue];
|
||||
if (!c.queue) { err("newCommandQueue", nil); return NULL; }
|
||||
c.triPso = [NSMutableDictionary dictionary];
|
||||
return (mtlb_ctx *)CFBridgingRetain(c);
|
||||
}
|
||||
}
|
||||
|
||||
void mtlb_shutdown(mtlb_ctx *ctx) {
|
||||
if (!ctx) return;
|
||||
@autoreleasepool {
|
||||
MTLBCtx *c = CTX(ctx);
|
||||
if (c.frame) { [c.frame commit]; [c.frame waitUntilCompleted]; c.frame = nil; }
|
||||
CFBridgingRelease(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 渲染目标 ----
|
||||
// ---- Render targets ----
|
||||
|
||||
static MTLPixelFormat pixfmt(mtlb_fmt f) {
|
||||
switch (f) {
|
||||
case MTLB_FMT_BGRA8: return MTLPixelFormatBGRA8Unorm;
|
||||
case MTLB_FMT_RGBA8: return MTLPixelFormatRGBA8Unorm;
|
||||
}
|
||||
return MTLPixelFormatInvalid;
|
||||
}
|
||||
|
||||
mtlb_rt *mtlb_target(mtlb_ctx *ctx, uint32_t w, uint32_t h, mtlb_fmt fmt) {
|
||||
@autoreleasepool {
|
||||
MTLPixelFormat pf = pixfmt(fmt);
|
||||
if (!ctx || !w || !h || pf == MTLPixelFormatInvalid) { err("mtlb_target 参数", nil); return NULL; }
|
||||
MTLTextureDescriptor *d =
|
||||
[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:pf width:w height:h mipmapped:NO];
|
||||
d.storageMode = MTLStorageModeShared;
|
||||
d.usage = MTLTextureUsageRenderTarget;
|
||||
MTLBRt *r = [MTLBRt new];
|
||||
r.tex = [CTX(ctx).dev newTextureWithDescriptor:d];
|
||||
if (!r.tex) { err("newTextureWithDescriptor", nil); return NULL; }
|
||||
r.w = w; r.h = h;
|
||||
return (mtlb_rt *)CFBridgingRetain(r);
|
||||
}
|
||||
}
|
||||
|
||||
void mtlb_target_free(mtlb_rt *rt) {
|
||||
if (rt) CFBridgingRelease(rt);
|
||||
}
|
||||
|
||||
// ---- pass 录制 ----
|
||||
// ---- Pass recording ----
|
||||
|
||||
static MTLRenderPassDescriptor *pass_desc(MTLBRt *r, MTLLoadAction load, MTLClearColor cc) {
|
||||
MTLRenderPassDescriptor *p = [MTLRenderPassDescriptor renderPassDescriptor];
|
||||
p.colorAttachments[0].texture = r.tex;
|
||||
p.colorAttachments[0].loadAction = load;
|
||||
p.colorAttachments[0].storeAction = MTLStoreActionStore;
|
||||
p.colorAttachments[0].clearColor = cc;
|
||||
return p;
|
||||
}
|
||||
|
||||
int mtlb_clear(mtlb_ctx *ctx, mtlb_rt *rt, float r, float g, float b, float a) {
|
||||
if (!ctx || !rt) return -1;
|
||||
@autoreleasepool {
|
||||
MTLRenderPassDescriptor *p =
|
||||
pass_desc(RT(rt), MTLLoadActionClear, MTLClearColorMake(r, g, b, a));
|
||||
id<MTLRenderCommandEncoder> e = [frame_cb(CTX(ctx)) renderCommandEncoderWithDescriptor:p];
|
||||
if (!e) { err("renderCommandEncoder(clear)", nil); return -1; }
|
||||
[e endEncoding];
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static NSString *const kTriMSL =
|
||||
@"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct V { float4 pos; float4 col; };\n"
|
||||
"struct O { float4 pos [[position]]; float4 col; };\n"
|
||||
"vertex O tri_vs(uint vid [[vertex_id]], constant V *v [[buffer(0)]]) {\n"
|
||||
" O o; o.pos = v[vid].pos; o.col = v[vid].col; return o;\n"
|
||||
"}\n"
|
||||
"fragment float4 tri_fs(O in [[stage_in]]) { return in.col; }\n";
|
||||
|
||||
// 与 kTriMSL 中 struct V 布局一致(两个 float4,32 字节)
|
||||
// Matches the layout of struct V in kTriMSL (two float4, 32 bytes)
|
||||
typedef struct { float pos[4]; float col[4]; } TriVert;
|
||||
|
||||
// 顶点(NDC):上红、左下绿、右下蓝
|
||||
// Vertices (NDC): top red, bottom-left green, bottom-right blue
|
||||
static const TriVert kTri[3] = {
|
||||
{{ 0.0f, 0.5f, 0.0f, 1.0f}, {1, 0, 0, 1}},
|
||||
{{-0.5f, -0.5f, 0.0f, 1.0f}, {0, 1, 0, 1}},
|
||||
{{ 0.5f, -0.5f, 0.0f, 1.0f}, {0, 0, 1, 1}},
|
||||
};
|
||||
|
||||
static id<MTLRenderPipelineState> tri_pso(MTLBCtx *c, MTLPixelFormat pf) {
|
||||
id<MTLRenderPipelineState> pso = c.triPso[@(pf)];
|
||||
if (pso) return pso;
|
||||
NSError *e = nil;
|
||||
if (!c.triLib) {
|
||||
c.triLib = [c.dev newLibraryWithSource:kTriMSL options:nil error:&e];
|
||||
if (!c.triLib) { err("newLibraryWithSource", e); return nil; }
|
||||
}
|
||||
MTLRenderPipelineDescriptor *d = [MTLRenderPipelineDescriptor new];
|
||||
d.vertexFunction = [c.triLib newFunctionWithName:@"tri_vs"];
|
||||
d.fragmentFunction = [c.triLib newFunctionWithName:@"tri_fs"];
|
||||
d.colorAttachments[0].pixelFormat = pf;
|
||||
pso = [c.dev newRenderPipelineStateWithDescriptor:d error:&e];
|
||||
if (!pso) { err("newRenderPipelineState", e); return nil; }
|
||||
c.triPso[@(pf)] = pso;
|
||||
return pso;
|
||||
}
|
||||
|
||||
int mtlb_triangle(mtlb_ctx *ctx, mtlb_rt *rt) {
|
||||
if (!ctx || !rt) return -1;
|
||||
@autoreleasepool {
|
||||
MTLBCtx *c = CTX(ctx);
|
||||
MTLBRt *r = RT(rt);
|
||||
id<MTLRenderPipelineState> pso = tri_pso(c, r.tex.pixelFormat);
|
||||
if (!pso) return -1;
|
||||
MTLRenderPassDescriptor *p = pass_desc(r, MTLLoadActionLoad, MTLClearColorMake(0, 0, 0, 0));
|
||||
id<MTLRenderCommandEncoder> e = [frame_cb(c) renderCommandEncoderWithDescriptor:p];
|
||||
if (!e) { err("renderCommandEncoder(triangle)", nil); return -1; }
|
||||
[e setRenderPipelineState:pso];
|
||||
[e setVertexBytes:kTri length:sizeof kTri atIndex:0];
|
||||
[e drawPrimitives:MTLPrimitiveTypeTriangle vertexStart:0 vertexCount:3];
|
||||
[e endEncoding];
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 提交与回读 ----
|
||||
// ---- Commit and readback ----
|
||||
|
||||
int mtlb_readback(mtlb_ctx *ctx, mtlb_rt *rt, void *buf, size_t buf_size) {
|
||||
if (!ctx || !rt || !buf) return -1;
|
||||
@autoreleasepool {
|
||||
MTLBCtx *c = CTX(ctx);
|
||||
MTLBRt *r = RT(rt);
|
||||
size_t row = (size_t)r.w * 4;
|
||||
if (buf_size < row * r.h) { err("mtlb_readback 缓冲太小", nil); return -1; }
|
||||
if (c.frame) {
|
||||
id<MTLCommandBuffer> cb = c.frame;
|
||||
c.frame = nil;
|
||||
[cb commit];
|
||||
[cb waitUntilCompleted];
|
||||
if (cb.status != MTLCommandBufferStatusCompleted) { err("commandBuffer 执行", cb.error); return -1; }
|
||||
}
|
||||
[r.tex getBytes:buf bytesPerRow:row fromRegion:MTLRegionMake2D(0, 0, r.w, r.h) mipmapLevel:0];
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
p_nocopy
|
||||
@@ -0,0 +1,38 @@
|
||||
// 探针:游戏内存上建零拷贝 MTLBuffer(边界外扩到 16 KiB 页、允许重叠),GPU 写 / CPU 读互通。
|
||||
// Probe: create zero-copy MTLBuffers over game memory (boundaries expanded outward to 16 KiB pages, overlap allowed), with GPU writes / CPU reads visible to each other.
|
||||
#import <Metal/Metal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
int main(void) {
|
||||
id<MTLDevice> dev = MTLCreateSystemDefaultDevice();
|
||||
size_t pg = getpagesize();
|
||||
uint8_t *mem; posix_memalign((void **)&mem, pg, 8 * pg);
|
||||
memset(mem, 0, 8 * pg);
|
||||
// 两个「池」:A = [pg+0x1000, 3pg+0x800)、B = [2pg+0x2000, 5pg),都不按页对齐,且外扩后重叠于第 2–3 页
|
||||
// Two "pools": A = [pg+0x1000, 3pg+0x800), B = [2pg+0x2000, 5pg), neither page-aligned, and after expanding outward they overlap on pages 2–3
|
||||
uint8_t *a0 = mem + pg + 0x1000, *a1 = mem + 3 * pg + 0x800, *b0 = mem + 2 * pg + 0x2000, *b1 = mem + 5 * pg;
|
||||
#define DOWN(p) ((uint8_t *)((uintptr_t)(p) & ~(uintptr_t)(pg - 1)))
|
||||
#define UP(p) ((uint8_t *)(((uintptr_t)(p) + pg - 1) & ~(uintptr_t)(pg - 1)))
|
||||
id<MTLBuffer> A = [dev newBufferWithBytesNoCopy:DOWN(a0) length:UP(a1) - DOWN(a0) options:MTLResourceStorageModeShared deallocator:nil];
|
||||
id<MTLBuffer> B = [dev newBufferWithBytesNoCopy:DOWN(b0) length:UP(b1) - DOWN(b0) options:MTLResourceStorageModeShared deallocator:nil];
|
||||
id<MTLBuffer> bad = [dev newBufferWithBytesNoCopy:a0 length:pg options:MTLResourceStorageModeShared deallocator:nil];
|
||||
printf("页大小 %zu;A %s B %s;未对齐起点建缓冲 %s\n", pg, A ? "成功" : "失败", B ? "成功" : "失败", bad ? "成功(与预期不符)" : "失败(符合预期)");
|
||||
// GPU:从 A 的 a0 处拷 4096 字节到 B 的 b0 处(两块的落点都在重叠页之外/之内各一)
|
||||
// GPU: copy 4096 bytes from a0 in A to b0 in B (of the two blocks' landing points, one is outside and one is inside the overlapping pages)
|
||||
for (int i = 0; i < 4096; i++) a0[i] = (uint8_t)(i * 7 + 3);
|
||||
id<MTLCommandQueue> q = [dev newCommandQueue];
|
||||
id<MTLCommandBuffer> cb = [q commandBuffer];
|
||||
id<MTLBlitCommandEncoder> bl = [cb blitCommandEncoder];
|
||||
[bl copyFromBuffer:A sourceOffset:a0 - DOWN(a0) toBuffer:B destinationOffset:b0 - DOWN(b0) size:4096];
|
||||
// 再在重叠区内:经 B 写、经 A 读——把 B 中 b0+0x1000 起 256 字节填 0xAB
|
||||
// Then within the overlap region: write through B, read through A - fill 256 bytes of B starting at b0+0x1000 with 0xAB
|
||||
[bl fillBuffer:B range:NSMakeRange(b0 - DOWN(b0) + 0x1000, 256) value:0xAB];
|
||||
[bl endEncoding]; [cb commit]; [cb waitUntilCompleted];
|
||||
int ok1 = !memcmp(a0, b0, 4096), ok2 = 1;
|
||||
for (int i = 0; i < 256; i++) ok2 &= b0[0x1000 + i] == 0xAB;
|
||||
uint8_t *viaA = (uint8_t *)A.contents + (b0 + 0x1000 - DOWN(a0));
|
||||
int ok3 = viaA[0] == 0xAB && viaA[255] == 0xAB;
|
||||
printf("GPU 拷贝 A→B 4096 B 全等:期望 1 → 真结果 %d\nGPU 填充经 CPU 原指针读到:期望 1 → 真结果 %d\n同一字节经 A 的 contents 读到:期望 1 → 真结果 %d\n", ok1, ok2, ok3);
|
||||
return !(A && B && !bad && ok1 && ok2 && ok3);
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
/* test_offscreen.c —— mtl_backend 自测
|
||||
*
|
||||
* 期望值全部在本文件里独立算出,不读后端内部数据:
|
||||
* - 三角形顶点(NDC)在下方 TRI 里手抄一份(与 mtl_backend.m 的 kTri 同值);
|
||||
* - NDC→像素:px = (x+1)/2*W,py = (1-y)/2*H(Metal 视口原点在左上,回读第 0 行是顶部);
|
||||
* - 像素中心 (i+0.5, j+0.5) 的颜色 = 三顶点颜色按重心坐标线性插值(w=1,无透视)。
|
||||
* 每个测试对 BGRA8、RGBA8 两种格式各跑一遍。
|
||||
* test_offscreen.c - self-test for mtl_backend
|
||||
* All expected values are computed independently in this file, without reading backend internals:
|
||||
* - the triangle vertices (NDC) are hand-copied into TRI below (same values as kTri in mtl_backend.m);
|
||||
* - NDC→pixel: px = (x+1)/2*W, py = (1-y)/2*H (Metal's viewport origin is top-left, readback row 0 is the top);
|
||||
* - the color at pixel center (i+0.5, j+0.5) = linear interpolation of the three vertex colors by barycentric coordinates (w=1, no perspective).
|
||||
* Each test is run once for each of the two formats BGRA8 and RGBA8.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "mtl_backend.h"
|
||||
|
||||
#define W 256
|
||||
#define H 256
|
||||
#define TOL 2 /* unorm8 量化与光栅插值精度容差(单通道) | Tolerance for unorm8 quantization and raster interpolation precision (per channel) */
|
||||
|
||||
static const float TRI[3][2] = {{0.0f, 0.5f}, {-0.5f, -0.5f}, {0.5f, -0.5f}};
|
||||
static const float TRI_COL[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
|
||||
|
||||
static int fails = 0;
|
||||
|
||||
typedef struct { int r, g, b, a; } px_t;
|
||||
|
||||
static px_t get_px(const uint8_t *buf, mtlb_fmt fmt, int x, int y) {
|
||||
const uint8_t *p = buf + ((size_t)y * W + x) * 4;
|
||||
px_t o;
|
||||
if (fmt == MTLB_FMT_BGRA8) { o.b = p[0]; o.g = p[1]; o.r = p[2]; o.a = p[3]; }
|
||||
else { o.r = p[0]; o.g = p[1]; o.b = p[2]; o.a = p[3]; }
|
||||
return o;
|
||||
}
|
||||
|
||||
static int near(px_t a, px_t b, int tol) {
|
||||
return abs(a.r - b.r) <= tol && abs(a.g - b.g) <= tol && abs(a.b - b.b) <= tol && abs(a.a - b.a) <= tol;
|
||||
}
|
||||
|
||||
static void report(const char *name, px_t want, px_t got, int ok) {
|
||||
printf(" %-34s 期望 (%3d,%3d,%3d,%3d) → 真结果 (%3d,%3d,%3d,%3d) %s\n", name,
|
||||
want.r, want.g, want.b, want.a, got.r, got.g, got.b, got.a, ok ? "过" : "【不符】");
|
||||
if (!ok) fails++;
|
||||
}
|
||||
|
||||
/* 顶点像素坐标 | Vertex pixel coordinates */
|
||||
static void vert_px(int i, double *x, double *y) {
|
||||
*x = (TRI[i][0] + 1.0) * 0.5 * W;
|
||||
*y = (1.0 - TRI[i][1]) * 0.5 * H;
|
||||
}
|
||||
|
||||
/* 点 (x,y) 到三条边的有符号距离(像素,内侧为正)与重心坐标 | Signed distances from point (x,y) to the three edges (in pixels, positive inside) and barycentric coordinates */
|
||||
static void bary(double x, double y, double l[3], double dist[3]) {
|
||||
double vx[3], vy[3];
|
||||
for (int i = 0; i < 3; i++) vert_px(i, &vx[i], &vy[i]);
|
||||
double area = (vx[1] - vx[0]) * (vy[2] - vy[0]) - (vy[1] - vy[0]) * (vx[2] - vx[0]);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
int a = (i + 1) % 3, b = (i + 2) % 3; /* 顶点 i 的对边 | The edge opposite vertex i */
|
||||
double e = (vx[b] - vx[a]) * (y - vy[a]) - (vy[b] - vy[a]) * (x - vx[a]);
|
||||
l[i] = e / area;
|
||||
dist[i] = e / (area > 0 ? 1 : -1) / hypot(vx[b] - vx[a], vy[b] - vy[a]);
|
||||
}
|
||||
}
|
||||
|
||||
static px_t tri_expect(int i, int j) {
|
||||
double l[3], d[3];
|
||||
bary(i + 0.5, j + 0.5, l, d);
|
||||
double c[3] = {0, 0, 0};
|
||||
for (int v = 0; v < 3; v++)
|
||||
for (int k = 0; k < 3; k++) c[k] += l[v] * TRI_COL[v][k];
|
||||
px_t o = {(int)lround(c[0] * 255), (int)lround(c[1] * 255), (int)lround(c[2] * 255), 255};
|
||||
return o;
|
||||
}
|
||||
|
||||
static const char *fmt_name(mtlb_fmt f) { return f == MTLB_FMT_BGRA8 ? "BGRA8" : "RGBA8"; }
|
||||
|
||||
static void test_clear(mtlb_ctx *ctx, mtlb_fmt fmt, uint8_t *buf) {
|
||||
printf("[测试1 清屏纯红 %s %dx%d]\n", fmt_name(fmt), W, H);
|
||||
mtlb_rt *rt = mtlb_target(ctx, W, H, fmt);
|
||||
memset(buf, 0x5a, W * H * 4); /* 先填垃圾,防止「没写也判过」 | Fill with garbage first, to prevent "passes even though nothing was written" */
|
||||
if (!rt || mtlb_clear(ctx, rt, 1, 0, 0, 1) || mtlb_readback(ctx, rt, buf, W * H * 4)) {
|
||||
printf(" 后端调用失败\n"); fails++; mtlb_target_free(rt); return;
|
||||
}
|
||||
px_t want = {255, 0, 0, 255};
|
||||
int bad = 0; px_t first_bad = {0};
|
||||
for (int y = 0; y < H; y++)
|
||||
for (int x = 0; x < W; x++) {
|
||||
px_t g = get_px(buf, fmt, x, y);
|
||||
if (!near(g, want, 0)) { if (!bad) first_bad = g; bad++; }
|
||||
}
|
||||
printf(" 全部 %d 像素逐个比:期望 (255,0,0,255) 全等 → 真结果 不符 %d 个%s\n", W * H, bad,
|
||||
bad ? "【不符】" : " 过");
|
||||
if (bad) { printf(" 首个不符像素 (%d,%d,%d,%d)\n", first_bad.r, first_bad.g, first_bad.b, first_bad.a); fails++; }
|
||||
mtlb_target_free(rt);
|
||||
}
|
||||
|
||||
static void test_triangle(mtlb_ctx *ctx, mtlb_fmt fmt, uint8_t *buf) {
|
||||
printf("[测试2 黑底三色三角形 %s %dx%d,清屏+三角形两个 pass 同一帧]\n", fmt_name(fmt), W, H);
|
||||
mtlb_rt *rt = mtlb_target(ctx, W, H, fmt);
|
||||
memset(buf, 0x5a, W * H * 4);
|
||||
if (!rt || mtlb_clear(ctx, rt, 0, 0, 0, 1) || mtlb_triangle(ctx, rt) ||
|
||||
mtlb_readback(ctx, rt, buf, W * H * 4)) {
|
||||
printf(" 后端调用失败\n"); fails++; mtlb_target_free(rt); return;
|
||||
}
|
||||
px_t clear = {0, 0, 0, 255};
|
||||
|
||||
/* 1) 四个角点 = 清屏色 | 1) The four corner points = clear color */
|
||||
const int corners[4][2] = {{0, 0}, {W - 1, 0}, {0, H - 1}, {W - 1, H - 1}};
|
||||
for (int k = 0; k < 4; k++) {
|
||||
char name[64]; snprintf(name, sizeof name, "角点 (%d,%d) 清屏色", corners[k][0], corners[k][1]);
|
||||
px_t g = get_px(buf, fmt, corners[k][0], corners[k][1]);
|
||||
report(name, clear, g, near(g, clear, 0));
|
||||
}
|
||||
|
||||
/* 2) 重心:NDC (0,-1/6) → 像素 (128, 149.33),取像素 (128,149),不是清屏色且≈插值值 | 2) Centroid: NDC (0,-1/6) → pixel (128, 149.33); take pixel (128,149), which is not the clear color and ≈ the interpolated value */
|
||||
{
|
||||
px_t want = tri_expect(128, 149), g = get_px(buf, fmt, 128, 149);
|
||||
report("重心 (128,149) 非清屏、≈1/3 混色", want, g, !near(g, clear, 0) && near(g, want, TOL));
|
||||
}
|
||||
|
||||
/* 3) 三顶点附近:顶点像素 v0(128,64) v1(64,192) v2(192,192),各向重心内移若干像素取样 | 3) Near the three vertices: vertex pixels v0(128,64) v1(64,192) v2(192,192), each sampled a few pixels inward toward the centroid */
|
||||
const struct { int x, y, ch; const char *name; } vs[3] = {
|
||||
{128, 72, 0, "近上顶点 (128,72) 偏红"},
|
||||
{72, 188, 1, "近左下顶点 (72,188) 偏绿"},
|
||||
{183, 188, 2, "近右下顶点 (183,188) 偏蓝"},
|
||||
};
|
||||
for (int k = 0; k < 3; k++) {
|
||||
px_t want = tri_expect(vs[k].x, vs[k].y), g = get_px(buf, fmt, vs[k].x, vs[k].y);
|
||||
int ch[3] = {g.r, g.g, g.b};
|
||||
int dom = ch[vs[k].ch] >= 200 && ch[(vs[k].ch + 1) % 3] <= 30 && ch[(vs[k].ch + 2) % 3] <= 30;
|
||||
report(vs[k].name, want, g, dom && near(g, want, TOL));
|
||||
}
|
||||
|
||||
/* 4) 全图:离边 >1 像素的内侧像素 ≈ 插值值(±TOL),外侧像素 = 清屏色;边带 ±1 像素跳过 | 4) Whole image: interior pixels more than 1 pixel from an edge ≈ interpolated value (±TOL), exterior pixels = clear color; the ±1 pixel edge band is skipped */
|
||||
int n_in = 0, bad_in = 0, n_out = 0, bad_out = 0, n_edge = 0;
|
||||
for (int y = 0; y < H; y++)
|
||||
for (int x = 0; x < W; x++) {
|
||||
double l[3], d[3];
|
||||
bary(x + 0.5, y + 0.5, l, d);
|
||||
double dmin = fmin(d[0], fmin(d[1], d[2]));
|
||||
px_t g = get_px(buf, fmt, x, y);
|
||||
if (dmin > 1.0) { n_in++; if (!near(g, tri_expect(x, y), TOL)) bad_in++; }
|
||||
else if (dmin < -1.0) { n_out++; if (!near(g, clear, 0)) bad_out++; }
|
||||
else n_edge++;
|
||||
}
|
||||
printf(" 全图内侧 %d 像素:期望 ≈插值(±%d) → 真结果 不符 %d 个%s\n", n_in, TOL, bad_in, bad_in ? "【不符】" : " 过");
|
||||
printf(" 全图外侧 %d 像素:期望 =清屏色 → 真结果 不符 %d 个%s\n", n_out, bad_out, bad_out ? "【不符】" : " 过");
|
||||
printf(" 边带跳过 %d 像素(合计 %d)\n", n_edge, n_in + n_out + n_edge);
|
||||
if (bad_in || bad_out) fails++;
|
||||
mtlb_target_free(rt);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
mtlb_ctx *ctx = mtlb_init();
|
||||
if (!ctx) { printf("mtlb_init 失败\n"); return 1; }
|
||||
uint8_t *buf = malloc(W * H * 4);
|
||||
const mtlb_fmt fmts[2] = {MTLB_FMT_BGRA8, MTLB_FMT_RGBA8};
|
||||
for (int i = 0; i < 2; i++) test_clear(ctx, fmts[i], buf);
|
||||
for (int i = 0; i < 2; i++) test_triangle(ctx, fmts[i], buf);
|
||||
free(buf);
|
||||
mtlb_shutdown(ctx);
|
||||
printf("%s:不符项 %d\n", fails ? "【失败】" : "全部通过", fails);
|
||||
return fails ? 1 : 0;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
# generated
|
||||
|
@@ -0,0 +1,171 @@
|
||||
# chain b-15cf7ca29eaf 2026-10-11T18:59:52+08:00
|
||||
0039367872c795ef
|
||||
012944185b7e261c
|
||||
01c5c7905790325c
|
||||
02475e2646930d3a
|
||||
0375622a8681eac8
|
||||
04d6e9e7022907f0
|
||||
05d419f912a4d1cd
|
||||
08cae9c2da02614a
|
||||
08cf187d05d84d09
|
||||
098bc3555e5bed5c
|
||||
0ae027ac272287d6
|
||||
0d08d8a1dd4cf5d6
|
||||
0ec3cd6738f3dc1c
|
||||
113ea8c683365263
|
||||
1294cbfb03e4e5d3
|
||||
12eb6ea3820b8a7d
|
||||
13ed8b18365bfce6
|
||||
16ca000298d851e8
|
||||
19124dcf41606d36
|
||||
1a52a65aa316e6a7
|
||||
1b3be84bc3d73eae
|
||||
1d0d15f74aaddb79
|
||||
202683f06c64ddef
|
||||
20786a082d2dfbd1
|
||||
22136f1bddcff874
|
||||
22bcee00f21c8c51
|
||||
232c2a3e6b7a9785
|
||||
246a3eb5daa0b7e0
|
||||
251d5ac1566e0b98
|
||||
256a56dd789b8f13
|
||||
2987a35f1911d7cf
|
||||
2bac2c1409557154
|
||||
2c0f19858ba73e3a
|
||||
2d00c13d2bedf438
|
||||
2f226536e8ebf232
|
||||
2f67901cf71cdf8d
|
||||
2fe401a733b4df57
|
||||
31382139e41128f6
|
||||
3164b49655fc21c9
|
||||
33a481418889a348
|
||||
3433b79150ad77fa
|
||||
3443a59816f5b87a
|
||||
35a28eb15010bf03
|
||||
361c9073e0fe932f
|
||||
3d01438bf311171f
|
||||
4074bf3ce3eb29d6
|
||||
407eda22c44a4ec7
|
||||
42061d685b137738
|
||||
429cd03ae61fb580
|
||||
431fe4783acb446b
|
||||
43ea12b5f3a11a78
|
||||
45439dae9ed6f82e
|
||||
470beddd47b0906c
|
||||
4dcb34893421ba50
|
||||
4deea881d1d5d891
|
||||
4e3228f54b273fb2
|
||||
4e33d2b2f5dd5684
|
||||
51f88ad470e16a62
|
||||
529c66d780376d9f
|
||||
544bfa980f0659e9
|
||||
552c7a641540285f
|
||||
5ab0b0b025ca5cc0
|
||||
5ab94c53e4b747ef
|
||||
60a4a32b7ad3dee7
|
||||
6199a47874e7865d
|
||||
62de3a10a1a70d79
|
||||
665f625445409a6e
|
||||
6708b5c15fb88273
|
||||
674c0117f15bf404
|
||||
6d13a23129c5bad1
|
||||
732793a8aa9c657a
|
||||
73fe0fb2e7f64d62
|
||||
742643391ed75757
|
||||
74da3fc1c952496d
|
||||
753571246bbaa1d3
|
||||
76635af22e6159c6
|
||||
7a41b9a2077e0d24
|
||||
7a971e1206ce7487
|
||||
7d00564cf449b5a8
|
||||
7e444c6b56f89cbb
|
||||
7e93dbafe3f1d8e7
|
||||
801be18d3b128861
|
||||
809cc7f4aa9f69a3
|
||||
826ba43379c72b7e
|
||||
8277d2e90a47fc42
|
||||
849c16fe2d7e4e1f
|
||||
864e2245e42231f9
|
||||
87563d5ae6077620
|
||||
8aabc1b86626d679
|
||||
8dc59d664925042f
|
||||
8dc9c3d51257ed16
|
||||
8e988dd02558f480
|
||||
8fbd7b46329cf14a
|
||||
933ac3975cdc62d2
|
||||
93f27d5276a307a2
|
||||
9427806fe45721bf
|
||||
9572fd30da881103
|
||||
959b175c17eb309c
|
||||
96e648c105ae22fa
|
||||
97133b997c557c31
|
||||
97d5e886b87c854a
|
||||
98bc3ef1161e7c8d
|
||||
9b786171fbe436a7
|
||||
a208b59a20da46df
|
||||
a29c4ce687403d4b
|
||||
a459b6a4ab3cfc9b
|
||||
a67ff94f0a782b91
|
||||
a7c7e72459c4c16c
|
||||
ab72d9b095921189
|
||||
ae224dd3406f544e
|
||||
ae8b319daf0ec3b8
|
||||
aeef425c5634876d
|
||||
afec3a532491951d
|
||||
b00c291fb7f30090
|
||||
b1000aa42019a635
|
||||
b1a087a0f2ca9211
|
||||
b1ca63c2a1e4132a
|
||||
b30b665fe5979b98
|
||||
b3c253f94140e753
|
||||
b69b19b0822cb2d4
|
||||
b784727d84409a7b
|
||||
ba496234f181e545
|
||||
babf0582ab85804f
|
||||
bb2859f7c9ab6835
|
||||
bb67dd335b8c3352
|
||||
bbf340d03939e655
|
||||
bbfaff061c9db62e
|
||||
be0232608909161d
|
||||
c2a97f4a818d143a
|
||||
c2b2d86cfd8e1cf1
|
||||
c4ee0e8f60681783
|
||||
c567bd2055e1e949
|
||||
c7e1f4ec7ae7dc48
|
||||
c8ecbf2ebbb6cd77
|
||||
c90edb05cc237d12
|
||||
cd09c05f4836b0df
|
||||
ce57281b7458def8
|
||||
ce7002e02c8ca160
|
||||
cf21eec08d595d65
|
||||
cf47f8b228a1a317
|
||||
d0d66e612d7e400d
|
||||
d273ffd56838049c
|
||||
d2ccd6cb831f3531
|
||||
d3678c2bd7da227d
|
||||
d6852696f83fa1f1
|
||||
d8a6fce93c9dedf6
|
||||
da28aceab3af1a4d
|
||||
e15e2e83a60f318f
|
||||
e26cfc8078dadac7
|
||||
e3e2e357887270d3
|
||||
e53325640ad88cef
|
||||
e90c8e4a82a1dff4
|
||||
e9ba089446aab577
|
||||
ea3d10a786d70c1a
|
||||
ea5d6929abbbb2f4
|
||||
eae5cca89702e8e9
|
||||
ebb63e9042983128
|
||||
ee54f785ad2aeeaf
|
||||
eed4afa7b0f076ab
|
||||
f211068bb6cc859e
|
||||
f31f3bbc05a0490f
|
||||
f3800b3ff760c8c2
|
||||
f89468337d477293
|
||||
f8a3235a063c616b
|
||||
f8cbc9f892e49ad0
|
||||
f9584aa45ac8cd79
|
||||
fafa3ee843dc7541
|
||||
fafc3b53dd48fb45
|
||||
fb531c641fc4dbe4
|
||||
fd100820d5447806
|
||||
|
@@ -0,0 +1,3 @@
|
||||
// 生成文件(dm/gfx/tools/dmsh_chain.py --header):本源码树期望的 B 着色器库翻译链版本(缺省选项);宿主只加载 <库目录>/b-<V>/
|
||||
// Generated file (dm/gfx/tools/dmsh_chain.py --header): the translation chain version of the B shader library expected by this source tree (default options); the host only loads <library dir>/b-<V>/
|
||||
#define DMSH_CHAIN "15cf7ca29eaf"
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,523 @@
|
||||
nvnDeviceBuilderSetDefaults
|
||||
nvnDeviceBuilderSetFlags
|
||||
nvnDeviceBuilderGetFlags
|
||||
nvnDeviceInitialize
|
||||
nvnDeviceFinalize
|
||||
nvnDeviceSetDebugLabel
|
||||
nvnDeviceGetProcAddress
|
||||
nvnDeviceGetInteger
|
||||
nvnDeviceGetCurrentTimestampInNanoseconds
|
||||
nvnDeviceSetIntermediateShaderCache
|
||||
nvnDeviceGetTextureHandle
|
||||
nvnDeviceGetTexelFetchHandle
|
||||
nvnDeviceGetImageHandle
|
||||
nvnDeviceInstallDebugCallback
|
||||
nvnDeviceGenerateDebugDomainId
|
||||
nvnDeviceSetWindowOriginMode
|
||||
nvnDeviceSetDepthMode
|
||||
nvnDeviceRegisterFastClearColor
|
||||
nvnDeviceRegisterFastClearColori
|
||||
nvnDeviceRegisterFastClearColorui
|
||||
nvnDeviceRegisterFastClearDepth
|
||||
nvnDeviceGetWindowOriginMode
|
||||
nvnDeviceGetDepthMode
|
||||
nvnDeviceGetTimestampInNanoseconds
|
||||
nvnDeviceApplyDeferredFinalizes
|
||||
nvnDeviceFinalizeCommandHandle
|
||||
nvnDeviceWalkDebugDatabase
|
||||
nvnDeviceGetSeparateTextureHandle
|
||||
nvnDeviceGetSeparateSamplerHandle
|
||||
nvnDeviceIsExternalDebuggerAttached
|
||||
nvnQueueGetError
|
||||
nvnQueueGetTotalCommandMemoryUsed
|
||||
nvnQueueGetTotalControlMemoryUsed
|
||||
nvnQueueGetTotalComputeMemoryUsed
|
||||
nvnQueueResetMemoryUsageCounts
|
||||
nvnQueueBuilderSetDevice
|
||||
nvnQueueBuilderSetDefaults
|
||||
nvnQueueBuilderSetFlags
|
||||
nvnQueueBuilderSetCommandMemorySize
|
||||
nvnQueueBuilderSetComputeMemorySize
|
||||
nvnQueueBuilderSetControlMemorySize
|
||||
nvnQueueBuilderGetQueueMemorySize
|
||||
nvnQueueBuilderSetQueueMemory
|
||||
nvnQueueBuilderSetCommandFlushThreshold
|
||||
nvnQueueBuilderSetQueuePriority
|
||||
nvnQueueBuilderGetQueuePriority
|
||||
nvnQueueBuilderGetDevice
|
||||
nvnQueueBuilderGetFlags
|
||||
nvnQueueBuilderGetCommandMemorySize
|
||||
nvnQueueBuilderGetComputeMemorySize
|
||||
nvnQueueBuilderGetControlMemorySize
|
||||
nvnQueueBuilderGetCommandFlushThreshold
|
||||
nvnQueueBuilderGetMemorySize
|
||||
nvnQueueBuilderGetMemory
|
||||
nvnQueueInitialize
|
||||
nvnQueueFinalize
|
||||
nvnQueueSetDebugLabel
|
||||
nvnQueueSubmitCommands
|
||||
nvnQueueFlush
|
||||
nvnQueueFinish
|
||||
nvnQueuePresentTexture
|
||||
nvnQueueAcquireTexture
|
||||
nvnWindowBuilderSetDevice
|
||||
nvnWindowBuilderSetDefaults
|
||||
nvnWindowBuilderSetNativeWindow
|
||||
nvnWindowBuilderSetTextures
|
||||
nvnWindowBuilderSetPresentInterval
|
||||
nvnWindowBuilderSetNumActiveTextures
|
||||
nvnWindowBuilderGetDevice
|
||||
nvnWindowBuilderGetNumTextures
|
||||
nvnWindowBuilderGetTexture
|
||||
nvnWindowBuilderGetNativeWindow
|
||||
nvnWindowBuilderGetPresentInterval
|
||||
nvnWindowBuilderGetNumActiveTextures
|
||||
nvnWindowInitialize
|
||||
nvnWindowFinalize
|
||||
nvnWindowSetDebugLabel
|
||||
nvnWindowAcquireTexture
|
||||
nvnWindowGetNativeWindow
|
||||
nvnWindowGetPresentInterval
|
||||
nvnWindowSetPresentInterval
|
||||
nvnWindowSetCrop
|
||||
nvnWindowGetCrop
|
||||
nvnWindowSetNumActiveTextures
|
||||
nvnWindowGetNumActiveTextures
|
||||
nvnWindowGetNumTextures
|
||||
nvnProgramInitialize
|
||||
nvnProgramFinalize
|
||||
nvnProgramSetDebugLabel
|
||||
nvnProgramSetShaders
|
||||
nvnProgramSetShadersExt
|
||||
nvnProgramSetSampleShading
|
||||
nvnMemoryPoolBuilderSetDevice
|
||||
nvnMemoryPoolBuilderSetDefaults
|
||||
nvnMemoryPoolBuilderSetStorage
|
||||
nvnMemoryPoolBuilderSetFlags
|
||||
nvnMemoryPoolBuilderGetDevice
|
||||
nvnMemoryPoolBuilderGetMemory
|
||||
nvnMemoryPoolBuilderGetSize
|
||||
nvnMemoryPoolBuilderGetFlags
|
||||
nvnMemoryPoolInitialize
|
||||
nvnMemoryPoolSetDebugLabel
|
||||
nvnMemoryPoolFinalize
|
||||
nvnMemoryPoolMap
|
||||
nvnMemoryPoolFlushMappedRange
|
||||
nvnMemoryPoolInvalidateMappedRange
|
||||
nvnMemoryPoolGetBufferAddress
|
||||
nvnMemoryPoolMapVirtual
|
||||
nvnMemoryPoolGetSize
|
||||
nvnMemoryPoolGetFlags
|
||||
nvnTexturePoolInitialize
|
||||
nvnTexturePoolSetDebugLabel
|
||||
nvnTexturePoolFinalize
|
||||
nvnTexturePoolRegisterTexture
|
||||
nvnTexturePoolRegisterImage
|
||||
nvnTexturePoolGetMemoryPool
|
||||
nvnTexturePoolGetMemoryOffset
|
||||
nvnTexturePoolGetSize
|
||||
nvnSamplerPoolInitialize
|
||||
nvnSamplerPoolSetDebugLabel
|
||||
nvnSamplerPoolFinalize
|
||||
nvnSamplerPoolRegisterSampler
|
||||
nvnSamplerPoolRegisterSamplerBuilder
|
||||
nvnSamplerPoolGetMemoryPool
|
||||
nvnSamplerPoolGetMemoryOffset
|
||||
nvnSamplerPoolGetSize
|
||||
nvnBufferBuilderSetDevice
|
||||
nvnBufferBuilderSetDefaults
|
||||
nvnBufferBuilderSetStorage
|
||||
nvnBufferBuilderGetDevice
|
||||
nvnBufferBuilderGetMemoryPool
|
||||
nvnBufferBuilderGetMemoryOffset
|
||||
nvnBufferBuilderGetSize
|
||||
nvnBufferInitialize
|
||||
nvnBufferSetDebugLabel
|
||||
nvnBufferFinalize
|
||||
nvnBufferMap
|
||||
nvnBufferGetAddress
|
||||
nvnBufferFlushMappedRange
|
||||
nvnBufferInvalidateMappedRange
|
||||
nvnBufferGetMemoryPool
|
||||
nvnBufferGetMemoryOffset
|
||||
nvnBufferGetSize
|
||||
nvnBufferGetDebugID
|
||||
nvnTextureBuilderSetDevice
|
||||
nvnTextureBuilderSetDefaults
|
||||
nvnTextureBuilderSetFlags
|
||||
nvnTextureBuilderSetTarget
|
||||
nvnTextureBuilderSetWidth
|
||||
nvnTextureBuilderSetHeight
|
||||
nvnTextureBuilderSetDepth
|
||||
nvnTextureBuilderSetSize1D
|
||||
nvnTextureBuilderSetSize2D
|
||||
nvnTextureBuilderSetSize3D
|
||||
nvnTextureBuilderSetLevels
|
||||
nvnTextureBuilderSetFormat
|
||||
nvnTextureBuilderSetSamples
|
||||
nvnTextureBuilderSetSwizzle
|
||||
nvnTextureBuilderSetDepthStencilMode
|
||||
nvnTextureBuilderGetStorageSize
|
||||
nvnTextureBuilderGetStorageAlignment
|
||||
nvnTextureBuilderSetStorage
|
||||
nvnTextureBuilderSetPackagedTextureData
|
||||
nvnTextureBuilderSetPackagedTextureLayout
|
||||
nvnTextureBuilderSetStride
|
||||
nvnTextureBuilderSetGLTextureName
|
||||
nvnTextureBuilderGetStorageClass
|
||||
nvnTextureBuilderGetDevice
|
||||
nvnTextureBuilderGetFlags
|
||||
nvnTextureBuilderGetTarget
|
||||
nvnTextureBuilderGetWidth
|
||||
nvnTextureBuilderGetHeight
|
||||
nvnTextureBuilderGetDepth
|
||||
nvnTextureBuilderGetLevels
|
||||
nvnTextureBuilderGetFormat
|
||||
nvnTextureBuilderGetSamples
|
||||
nvnTextureBuilderGetSwizzle
|
||||
nvnTextureBuilderGetDepthStencilMode
|
||||
nvnTextureBuilderGetPackagedTextureData
|
||||
nvnTextureBuilderGetPackagedTextureLayout
|
||||
nvnTextureBuilderGetStride
|
||||
nvnTextureBuilderGetSparseTileLayout
|
||||
nvnTextureBuilderGetGLTextureName
|
||||
nvnTextureBuilderGetZCullStorageSize
|
||||
nvnTextureBuilderGetMemoryPool
|
||||
nvnTextureBuilderGetMemoryOffset
|
||||
nvnTextureBuilderGetRawStorageClass
|
||||
nvnTextureViewSetDefaults
|
||||
nvnTextureViewSetLevels
|
||||
nvnTextureViewSetLayers
|
||||
nvnTextureViewSetFormat
|
||||
nvnTextureViewSetSwizzle
|
||||
nvnTextureViewSetDepthStencilMode
|
||||
nvnTextureViewSetTarget
|
||||
nvnTextureViewGetLevels
|
||||
nvnTextureViewGetLayers
|
||||
nvnTextureViewGetFormat
|
||||
nvnTextureViewGetSwizzle
|
||||
nvnTextureViewGetDepthStencilMode
|
||||
nvnTextureViewGetTarget
|
||||
nvnTextureViewCompare
|
||||
nvnTextureInitialize
|
||||
nvnTextureGetZCullStorageSize
|
||||
nvnTextureFinalize
|
||||
nvnTextureSetDebugLabel
|
||||
nvnTextureGetStorageClass
|
||||
nvnTextureGetViewOffset
|
||||
nvnTextureGetFlags
|
||||
nvnTextureGetTarget
|
||||
nvnTextureGetWidth
|
||||
nvnTextureGetHeight
|
||||
nvnTextureGetDepth
|
||||
nvnTextureGetLevels
|
||||
nvnTextureGetFormat
|
||||
nvnTextureGetSamples
|
||||
nvnTextureGetSwizzle
|
||||
nvnTextureGetDepthStencilMode
|
||||
nvnTextureGetStride
|
||||
nvnTextureGetTextureAddress
|
||||
nvnTextureGetSparseTileLayout
|
||||
nvnTextureWriteTexels
|
||||
nvnTextureWriteTexelsStrided
|
||||
nvnTextureReadTexels
|
||||
nvnTextureReadTexelsStrided
|
||||
nvnTextureFlushTexels
|
||||
nvnTextureInvalidateTexels
|
||||
nvnTextureGetMemoryPool
|
||||
nvnTextureGetMemoryOffset
|
||||
nvnTextureGetStorageSize
|
||||
nvnTextureCompare
|
||||
nvnTextureGetDebugID
|
||||
nvnTextureGetRawStorageClass
|
||||
nvnSamplerBuilderSetDevice
|
||||
nvnSamplerBuilderSetDefaults
|
||||
nvnSamplerBuilderSetMinMagFilter
|
||||
nvnSamplerBuilderSetWrapMode
|
||||
nvnSamplerBuilderSetLodClamp
|
||||
nvnSamplerBuilderSetLodBias
|
||||
nvnSamplerBuilderSetCompare
|
||||
nvnSamplerBuilderSetBorderColor
|
||||
nvnSamplerBuilderSetBorderColori
|
||||
nvnSamplerBuilderSetBorderColorui
|
||||
nvnSamplerBuilderSetMaxAnisotropy
|
||||
nvnSamplerBuilderSetReductionFilter
|
||||
nvnSamplerBuilderSetLodSnap
|
||||
nvnSamplerBuilderGetDevice
|
||||
nvnSamplerBuilderGetMinMagFilter
|
||||
nvnSamplerBuilderGetWrapMode
|
||||
nvnSamplerBuilderGetLodClamp
|
||||
nvnSamplerBuilderGetLodBias
|
||||
nvnSamplerBuilderGetCompare
|
||||
nvnSamplerBuilderGetBorderColor
|
||||
nvnSamplerBuilderGetBorderColori
|
||||
nvnSamplerBuilderGetBorderColorui
|
||||
nvnSamplerBuilderGetMaxAnisotropy
|
||||
nvnSamplerBuilderGetReductionFilter
|
||||
nvnSamplerBuilderGetLodSnap
|
||||
nvnSamplerInitialize
|
||||
nvnSamplerFinalize
|
||||
nvnSamplerSetDebugLabel
|
||||
nvnSamplerGetMinMagFilter
|
||||
nvnSamplerGetWrapMode
|
||||
nvnSamplerGetLodClamp
|
||||
nvnSamplerGetLodBias
|
||||
nvnSamplerGetCompare
|
||||
nvnSamplerGetBorderColor
|
||||
nvnSamplerGetBorderColori
|
||||
nvnSamplerGetBorderColorui
|
||||
nvnSamplerGetMaxAnisotropy
|
||||
nvnSamplerGetReductionFilter
|
||||
nvnSamplerCompare
|
||||
nvnSamplerGetDebugID
|
||||
nvnBlendStateSetDefaults
|
||||
nvnBlendStateSetBlendTarget
|
||||
nvnBlendStateSetBlendFunc
|
||||
nvnBlendStateSetBlendEquation
|
||||
nvnBlendStateSetAdvancedMode
|
||||
nvnBlendStateSetAdvancedOverlap
|
||||
nvnBlendStateSetAdvancedPremultipliedSrc
|
||||
nvnBlendStateSetAdvancedNormalizedDst
|
||||
nvnBlendStateGetBlendTarget
|
||||
nvnBlendStateGetBlendFunc
|
||||
nvnBlendStateGetBlendEquation
|
||||
nvnBlendStateGetAdvancedMode
|
||||
nvnBlendStateGetAdvancedOverlap
|
||||
nvnBlendStateGetAdvancedPremultipliedSrc
|
||||
nvnBlendStateGetAdvancedNormalizedDst
|
||||
nvnColorStateSetDefaults
|
||||
nvnColorStateSetBlendEnable
|
||||
nvnColorStateSetLogicOp
|
||||
nvnColorStateSetAlphaTest
|
||||
nvnColorStateGetBlendEnable
|
||||
nvnColorStateGetLogicOp
|
||||
nvnColorStateGetAlphaTest
|
||||
nvnChannelMaskStateSetDefaults
|
||||
nvnChannelMaskStateSetChannelMask
|
||||
nvnChannelMaskStateGetChannelMask
|
||||
nvnMultisampleStateSetDefaults
|
||||
nvnMultisampleStateSetMultisampleEnable
|
||||
nvnMultisampleStateSetSamples
|
||||
nvnMultisampleStateSetAlphaToCoverageEnable
|
||||
nvnMultisampleStateSetAlphaToCoverageDither
|
||||
nvnMultisampleStateGetMultisampleEnable
|
||||
nvnMultisampleStateGetSamples
|
||||
nvnMultisampleStateGetAlphaToCoverageEnable
|
||||
nvnMultisampleStateGetAlphaToCoverageDither
|
||||
nvnMultisampleStateSetRasterSamples
|
||||
nvnMultisampleStateGetRasterSamples
|
||||
nvnMultisampleStateSetCoverageModulationMode
|
||||
nvnMultisampleStateGetCoverageModulationMode
|
||||
nvnMultisampleStateSetCoverageToColorEnable
|
||||
nvnMultisampleStateGetCoverageToColorEnable
|
||||
nvnMultisampleStateSetCoverageToColorOutput
|
||||
nvnMultisampleStateGetCoverageToColorOutput
|
||||
nvnMultisampleStateSetSampleLocationsEnable
|
||||
nvnMultisampleStateGetSampleLocationsEnable
|
||||
nvnMultisampleStateGetSampleLocationsGrid
|
||||
nvnMultisampleStateSetSampleLocationsGridEnable
|
||||
nvnMultisampleStateGetSampleLocationsGridEnable
|
||||
nvnMultisampleStateSetSampleLocations
|
||||
nvnPolygonStateSetDefaults
|
||||
nvnPolygonStateSetCullFace
|
||||
nvnPolygonStateSetFrontFace
|
||||
nvnPolygonStateSetPolygonMode
|
||||
nvnPolygonStateSetPolygonOffsetEnables
|
||||
nvnPolygonStateGetCullFace
|
||||
nvnPolygonStateGetFrontFace
|
||||
nvnPolygonStateGetPolygonMode
|
||||
nvnPolygonStateGetPolygonOffsetEnables
|
||||
nvnDepthStencilStateSetDefaults
|
||||
nvnDepthStencilStateSetDepthTestEnable
|
||||
nvnDepthStencilStateSetDepthWriteEnable
|
||||
nvnDepthStencilStateSetDepthFunc
|
||||
nvnDepthStencilStateSetStencilTestEnable
|
||||
nvnDepthStencilStateSetStencilFunc
|
||||
nvnDepthStencilStateSetStencilOp
|
||||
nvnDepthStencilStateGetDepthTestEnable
|
||||
nvnDepthStencilStateGetDepthWriteEnable
|
||||
nvnDepthStencilStateGetDepthFunc
|
||||
nvnDepthStencilStateGetStencilTestEnable
|
||||
nvnDepthStencilStateGetStencilFunc
|
||||
nvnDepthStencilStateGetStencilOp
|
||||
nvnVertexAttribStateSetDefaults
|
||||
nvnVertexAttribStateSetFormat
|
||||
nvnVertexAttribStateSetStreamIndex
|
||||
nvnVertexAttribStateGetFormat
|
||||
nvnVertexAttribStateGetStreamIndex
|
||||
nvnVertexStreamStateSetDefaults
|
||||
nvnVertexStreamStateSetStride
|
||||
nvnVertexStreamStateSetDivisor
|
||||
nvnVertexStreamStateGetStride
|
||||
nvnVertexStreamStateGetDivisor
|
||||
nvnCommandBufferInitialize
|
||||
nvnCommandBufferFinalize
|
||||
nvnCommandBufferSetDebugLabel
|
||||
nvnCommandBufferSetMemoryCallback
|
||||
nvnCommandBufferSetMemoryCallbackData
|
||||
nvnCommandBufferSetCommandMemoryCallbackEnabled
|
||||
nvnCommandBufferAddCommandMemory
|
||||
nvnCommandBufferAddControlMemory
|
||||
nvnCommandBufferGetCommandMemorySize
|
||||
nvnCommandBufferGetCommandMemoryUsed
|
||||
nvnCommandBufferGetCommandMemoryFree
|
||||
nvnCommandBufferGetControlMemorySize
|
||||
nvnCommandBufferGetControlMemoryUsed
|
||||
nvnCommandBufferGetControlMemoryFree
|
||||
nvnCommandBufferBeginRecording
|
||||
nvnCommandBufferEndRecording
|
||||
nvnCommandBufferCallCommands
|
||||
nvnCommandBufferCopyCommands
|
||||
nvnCommandBufferBindBlendState
|
||||
nvnCommandBufferBindChannelMaskState
|
||||
nvnCommandBufferBindColorState
|
||||
nvnCommandBufferBindMultisampleState
|
||||
nvnCommandBufferBindPolygonState
|
||||
nvnCommandBufferBindDepthStencilState
|
||||
nvnCommandBufferBindVertexAttribState
|
||||
nvnCommandBufferBindVertexStreamState
|
||||
nvnCommandBufferBindProgram
|
||||
nvnCommandBufferBindVertexBuffer
|
||||
nvnCommandBufferBindVertexBuffers
|
||||
nvnCommandBufferBindUniformBuffer
|
||||
nvnCommandBufferBindUniformBuffers
|
||||
nvnCommandBufferBindTransformFeedbackBuffer
|
||||
nvnCommandBufferBindTransformFeedbackBuffers
|
||||
nvnCommandBufferBindStorageBuffer
|
||||
nvnCommandBufferBindStorageBuffers
|
||||
nvnCommandBufferBindTexture
|
||||
nvnCommandBufferBindTextures
|
||||
nvnCommandBufferBindImage
|
||||
nvnCommandBufferBindImages
|
||||
nvnCommandBufferSetPatchSize
|
||||
nvnCommandBufferSetInnerTessellationLevels
|
||||
nvnCommandBufferSetOuterTessellationLevels
|
||||
nvnCommandBufferSetPrimitiveRestart
|
||||
nvnCommandBufferBeginTransformFeedback
|
||||
nvnCommandBufferEndTransformFeedback
|
||||
nvnCommandBufferPauseTransformFeedback
|
||||
nvnCommandBufferResumeTransformFeedback
|
||||
nvnCommandBufferDrawTransformFeedback
|
||||
nvnCommandBufferDrawArrays
|
||||
nvnCommandBufferDrawElements
|
||||
nvnCommandBufferDrawElementsBaseVertex
|
||||
nvnCommandBufferDrawArraysInstanced
|
||||
nvnCommandBufferDrawElementsInstanced
|
||||
nvnCommandBufferDrawArraysIndirect
|
||||
nvnCommandBufferDrawElementsIndirect
|
||||
nvnCommandBufferMultiDrawArraysIndirectCount
|
||||
nvnCommandBufferMultiDrawElementsIndirectCount
|
||||
nvnCommandBufferClearColor
|
||||
nvnCommandBufferClearColori
|
||||
nvnCommandBufferClearColorui
|
||||
nvnCommandBufferClearDepthStencil
|
||||
nvnCommandBufferDispatchCompute
|
||||
nvnCommandBufferDispatchComputeIndirect
|
||||
nvnCommandBufferSetViewport
|
||||
nvnCommandBufferSetViewports
|
||||
nvnCommandBufferSetViewportSwizzles
|
||||
nvnCommandBufferSetScissor
|
||||
nvnCommandBufferSetScissors
|
||||
nvnCommandBufferSetDepthRange
|
||||
nvnCommandBufferSetDepthBounds
|
||||
nvnCommandBufferSetDepthRanges
|
||||
nvnCommandBufferSetTiledCacheAction
|
||||
nvnCommandBufferSetTiledCacheTileSize
|
||||
nvnCommandBufferBindSeparateTexture
|
||||
nvnCommandBufferBindSeparateSampler
|
||||
nvnCommandBufferBindSeparateTextures
|
||||
nvnCommandBufferBindSeparateSamplers
|
||||
nvnCommandBufferSetStencilValueMask
|
||||
nvnCommandBufferSetStencilMask
|
||||
nvnCommandBufferSetStencilRef
|
||||
nvnCommandBufferSetBlendColor
|
||||
nvnCommandBufferSetPointSize
|
||||
nvnCommandBufferSetLineWidth
|
||||
nvnCommandBufferSetPolygonOffsetClamp
|
||||
nvnCommandBufferSetAlphaRef
|
||||
nvnCommandBufferSetSampleMask
|
||||
nvnCommandBufferSetRasterizerDiscard
|
||||
nvnCommandBufferSetDepthClamp
|
||||
nvnCommandBufferSetConservativeRasterEnable
|
||||
nvnCommandBufferSetConservativeRasterDilate
|
||||
nvnCommandBufferSetSubpixelPrecisionBias
|
||||
nvnCommandBufferCopyBufferToTexture
|
||||
nvnCommandBufferCopyTextureToBuffer
|
||||
nvnCommandBufferCopyTextureToTexture
|
||||
nvnCommandBufferCopyBufferToBuffer
|
||||
nvnCommandBufferClearBuffer
|
||||
nvnCommandBufferClearTexture
|
||||
nvnCommandBufferClearTexturei
|
||||
nvnCommandBufferClearTextureui
|
||||
nvnCommandBufferUpdateUniformBuffer
|
||||
nvnCommandBufferReportCounter
|
||||
nvnCommandBufferResetCounter
|
||||
nvnCommandBufferReportValue
|
||||
nvnCommandBufferSetRenderEnable
|
||||
nvnCommandBufferSetRenderEnableConditional
|
||||
nvnCommandBufferSetRenderTargets
|
||||
nvnCommandBufferDiscardColor
|
||||
nvnCommandBufferDiscardDepthStencil
|
||||
nvnCommandBufferDownsample
|
||||
nvnCommandBufferTiledDownsample
|
||||
nvnCommandBufferDownsampleTextureView
|
||||
nvnCommandBufferTiledDownsampleTextureView
|
||||
nvnCommandBufferBarrier
|
||||
nvnCommandBufferWaitSync
|
||||
nvnCommandBufferFenceSync
|
||||
nvnCommandBufferSetTexturePool
|
||||
nvnCommandBufferSetSamplerPool
|
||||
nvnCommandBufferSetShaderScratchMemory
|
||||
nvnCommandBufferSaveZCullData
|
||||
nvnCommandBufferRestoreZCullData
|
||||
nvnCommandBufferSetCopyRowStride
|
||||
nvnCommandBufferSetCopyImageStride
|
||||
nvnCommandBufferGetCopyRowStride
|
||||
nvnCommandBufferGetCopyImageStride
|
||||
nvnCommandBufferDrawTexture
|
||||
nvnProgramSetSubroutineLinkage
|
||||
nvnCommandBufferSetProgramSubroutines
|
||||
nvnCommandBufferBindCoverageModulationTable
|
||||
nvnCommandBufferResolveDepthBuffer
|
||||
nvnCommandBufferSetColorReductionEnable
|
||||
nvnCommandBufferSetColorReductionThresholds
|
||||
nvnCommandBufferPushDebugGroupStatic
|
||||
nvnCommandBufferPushDebugGroupDynamic
|
||||
nvnCommandBufferPushDebugGroup
|
||||
nvnCommandBufferPopDebugGroup
|
||||
nvnCommandBufferPopDebugGroupId
|
||||
nvnCommandBufferInsertDebugMarkerStatic
|
||||
nvnCommandBufferInsertDebugMarkerDynamic
|
||||
nvnCommandBufferInsertDebugMarker
|
||||
nvnCommandBufferGetMemoryCallback
|
||||
nvnCommandBufferGetMemoryCallbackData
|
||||
nvnCommandBufferIsRecording
|
||||
nvnSyncInitialize
|
||||
nvnSyncFinalize
|
||||
nvnSyncSetDebugLabel
|
||||
nvnQueueFenceSync
|
||||
nvnSyncWait
|
||||
nvnQueueWaitSync
|
||||
nvnSyncInitializeFromFencedGLSync
|
||||
nvnSyncCreateGLSync
|
||||
nvnEventBuilderSetDefaults
|
||||
nvnEventBuilderSetStorage
|
||||
nvnEventBuilderGetStorage
|
||||
nvnEventBuilderGetMemoryPool
|
||||
nvnEventBuilderGetMemoryOffset
|
||||
nvnEventInitialize
|
||||
nvnEventFinalize
|
||||
nvnEventGetValue
|
||||
nvnEventSignal
|
||||
nvnEventGetMemoryPool
|
||||
nvnEventGetMemoryOffset
|
||||
nvnCommandBufferWaitEvent
|
||||
nvnCommandBufferSignalEvent
|
||||
nvnCommandBufferSetStencilCullCriteria
|
||||
nvnCommandBufferInsertCheckpointStatic
|
||||
nvnCommandBufferInsertCheckpointDynamic
|
||||
nvnDeviceSetAutomaticCheckpointsEnable
|
||||
nvnDeviceSetAutomaticCheckpointsSamplingInterval
|
||||
nvnDeviceSetAutomaticCheckpointsByDebugGroup
|
||||
nvnDeviceSetCheckpointCallStacksEnable
|
||||
nvnDeviceSetCheckpointMaxCallStacksDepth
|
||||
@@ -0,0 +1,45 @@
|
||||
// main 程序本体内嵌的 4 个 Maxwell 计算着色器(PC 版无对应)→ 手写 MSL,逐条按 envydis 反汇编等价。
|
||||
// 出处:main 原映像 .rodata 控制段 @0x1df10e8 / 0x1df1a94 / 0x1df2440 / 0x1df2dec(envydis -m gm107)。
|
||||
// 共同骨架(Maxwell 原文):
|
||||
// id = (ctaid.x << 5) + tid.x // 线程组 32×1×1
|
||||
// if (id >= c3[0x0]) exit // 元素个数 = uniform 缓冲 0 的第 0 个字(u32 比较)
|
||||
// src = ssbo0(c0[0x310]),dst = ssbo1(c0[0x320]),地址 = 基址 + 32 位偏移
|
||||
// 各核差别(NVN 计数器报告 16 字节 = {计数 u64, 时间戳 u64}):
|
||||
// q_val0 dst[id] = *(u64*)(src + (id<<4)) 取计数
|
||||
// q_val8 dst[id] = *(u64*)(src + (id<<4) + 8) 取时间戳
|
||||
// q_dlt0 dst[id] = *(u64*)(src + (id<<5) + 16) - *(u64*)(src + (id<<5)) 前后两报告的计数差
|
||||
// q_dlt8 dst[id] = *(u64*)(src + (id<<5) + 24) - *(u64*)(src + (id<<5) + 8) 前后两报告的时间戳差
|
||||
// The 4 Maxwell compute shaders embedded in the main program itself (no counterpart in the PC version) -> hand-written MSL, equivalent instruction by instruction to the envydis disassembly.
|
||||
// Source: control segments in the .rodata of the original main image @0x1df10e8 / 0x1df1a94 / 0x1df2440 / 0x1df2dec (envydis -m gm107).
|
||||
// Common skeleton (original Maxwell):
|
||||
// id = (ctaid.x << 5) + tid.x // thread group 32x1x1
|
||||
// if (id >= c3[0x0]) exit // element count = word 0 of uniform buffer 0 (u32 compare)
|
||||
// src = ssbo0 (c0[0x310]), dst = ssbo1 (c0[0x320]), address = base + 32-bit offset
|
||||
// Differences between kernels (an NVN counter report is 16 bytes = {count u64, timestamp u64}):
|
||||
// q_val0 dst[id] = *(u64*)(src + (id<<4)) take the count
|
||||
// q_val8 dst[id] = *(u64*)(src + (id<<4) + 8) take the timestamp
|
||||
// q_dlt0 dst[id] = *(u64*)(src + (id<<5) + 16) - *(u64*)(src + (id<<5)) count difference between two consecutive reports
|
||||
// q_dlt8 dst[id] = *(u64*)(src + (id<<5) + 24) - *(u64*)(src + (id<<5) + 8) timestamp difference between two consecutive reports
|
||||
#pragma once
|
||||
|
||||
static const char *const k_nvn_builtin_msl =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"#define HEAD uint id = (cta.x << 5) + tid.x; if (id >= n[0]) return;\n"
|
||||
"#define LD(o) (*(device const ulong *)(src + (o)))\n"
|
||||
"#define ARGS constant uint *n [[buffer(0)]], device const uchar *src [[buffer(1)]], device uchar *dst [[buffer(2)]], "
|
||||
"uint3 cta [[threadgroup_position_in_grid]], uint3 tid [[thread_position_in_threadgroup]]\n"
|
||||
"#define ST(v) (*(device ulong *)(dst + (id << 3)) = (v))\n"
|
||||
"kernel void q_val0(ARGS) { HEAD ST(LD(id << 4)); }\n"
|
||||
"kernel void q_val8(ARGS) { HEAD ST(LD((id << 4) + 8u)); }\n"
|
||||
"kernel void q_dlt0(ARGS) { HEAD uint b = id << 5; ST(LD(b + 16u) - LD(b)); }\n"
|
||||
"kernel void q_dlt8(ARGS) { HEAD uint b = (id << 5) + 16u; ST(LD(b + 8u) - LD(b - 8u)); }\n";
|
||||
|
||||
// Switch 控制段哈希(sha256(控制段 0x880 字节) 前 16 位)→ 内核名
|
||||
// Switch control segment hash (first 16 hex digits of sha256(0x880 bytes of the control segment)) -> kernel name
|
||||
static const struct { const char *ctl; const char *fn; } k_nvn_builtin_map[] = {
|
||||
{"d0f769bb916bbba9", "q_val0"},
|
||||
{"16479cc6d75c2b28", "q_val8"},
|
||||
{"0687e2ef95133577", "q_dlt0"},
|
||||
{"4df5909e6dabee05", "q_dlt8"},
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
// 由 gen_protos.py 生成
|
||||
// Generated by gen_protos.py
|
||||
#pragma once
|
||||
#define NVN_NFUNC 523
|
||||
@@ -0,0 +1,45 @@
|
||||
// 全覆盖首绘的几何证明(纯函数,单测 tests/t_cover.c):这次绘制是否把附件该级整块的每个像素都画到。
|
||||
// 成立条件(全部满足):剪裁覆盖整块;视口恰为 (0, 0, W, H)(NDC [-1,1]² 即整块);某个未被剔除的三角形在 NDC 里包住四角(闭包含,
|
||||
// 像素中心都在正方形内部,四角在闭三角形内即整块在内);各顶点 w = 1、z ∈ [0,1](不被透视除法与深度裁剪改变)。
|
||||
// 朝向:NDC(y 向上)里逆时针为正;条带奇数个三角形顶点序反转。认不出的一律不成立。
|
||||
// Geometric proof of a full-coverage first draw (pure function, unit test tests/t_cover.c): whether this draw touches every pixel of the whole block of that attachment level.
|
||||
// Conditions (all must hold): the scissor covers the whole block; the viewport is exactly (0, 0, W, H) (NDC [-1,1]^2 is the whole block); some non-culled triangle encloses the four corners in NDC (closed containment:
|
||||
// pixel centers are all inside the square, so the four corners being in the closed triangle means the whole block is inside); every vertex has w = 1 and z in [0,1] (unchanged by perspective divide and depth clipping).
|
||||
// Winding: in NDC (y up) counter-clockwise is front; odd-numbered triangles of a strip have reversed vertex order. Anything unrecognized does not hold.
|
||||
#pragma once
|
||||
#include <math.h>
|
||||
|
||||
enum { NVN_COVER_TRIANGLES = 4, NVN_COVER_TRIANGLE_STRIP = 5 }; // NVNdrawPrimitive
|
||||
enum { NVN_COVER_CULL_NONE = 0, NVN_COVER_CULL_FRONT = 1, NVN_COVER_CULL_BACK = 2, NVN_COVER_CULL_BOTH = 3 }; // NVNface
|
||||
|
||||
static inline int nvn_cover(const float (*v)[4], int n, int prim, int cull, int front_ccw,
|
||||
int has_vp, const float vp[4], int has_sc, const int sc[4], long W, long H) {
|
||||
if (W <= 0 || H <= 0 || n < 3) return 0;
|
||||
if (has_sc && !(sc[0] <= 0 && sc[1] <= 0 && (long)sc[0] + sc[2] >= W && (long)sc[1] + sc[3] >= H)) return 0;
|
||||
if (has_vp && !(vp[0] == 0 && vp[1] == 0 && vp[2] == (float)W && vp[3] == (float)H)) return 0;
|
||||
if (prim != NVN_COVER_TRIANGLES && prim != NVN_COVER_TRIANGLE_STRIP) return 0;
|
||||
if (cull == NVN_COVER_CULL_BOTH) return 0;
|
||||
for (int k = 0; k < n; k++)
|
||||
if (v[k][3] != 1.0f || !(v[k][2] >= 0.0f && v[k][2] <= 1.0f) || !isfinite(v[k][0]) || !isfinite(v[k][1])) return 0;
|
||||
static const double C[4][2] = {{-1, -1}, {1, -1}, {-1, 1}, {1, 1}};
|
||||
int ntri = prim == NVN_COVER_TRIANGLES ? n / 3 : n - 2;
|
||||
for (int k = 0; k < ntri; k++) {
|
||||
int i0 = prim == NVN_COVER_TRIANGLES ? 3 * k : k, i1 = i0 + 1, i2 = i0 + 2;
|
||||
if (prim == NVN_COVER_TRIANGLE_STRIP && (k & 1)) { int x = i1; i1 = i2; i2 = x; }
|
||||
double A[2] = {v[i0][0], v[i0][1]}, B[2] = {v[i1][0], v[i1][1]}, D[2] = {v[i2][0], v[i2][1]};
|
||||
double d = (B[0] - A[0]) * (D[1] - A[1]) - (B[1] - A[1]) * (D[0] - A[0]);
|
||||
if (d == 0) continue;
|
||||
int front = front_ccw ? d > 0 : d < 0;
|
||||
if ((cull == NVN_COVER_CULL_BACK && !front) || (cull == NVN_COVER_CULL_FRONT && front)) continue;
|
||||
int in = 1;
|
||||
for (int c = 0; c < 4 && in; c++) {
|
||||
const double *p = C[c];
|
||||
double e0 = (B[0] - A[0]) * (p[1] - A[1]) - (B[1] - A[1]) * (p[0] - A[0]);
|
||||
double e1 = (D[0] - B[0]) * (p[1] - B[1]) - (D[1] - B[1]) * (p[0] - B[0]);
|
||||
double e2 = (A[0] - D[0]) * (p[1] - D[1]) - (A[1] - D[1]) * (p[0] - D[0]);
|
||||
in = d > 0 ? (e0 >= 0 && e1 >= 0 && e2 >= 0) : (e0 <= 0 && e1 <= 0 && e2 <= 0);
|
||||
}
|
||||
if (in) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
// 客体内存写保护脏页跟踪:预排布贴图(CPU 写、GPU 读)的池页上传后设只读,游戏一写即缺页 → 标脏、解保护;
|
||||
// 使用前查覆盖页的写代号,比上传时新就重传。NVN 语义:贴图描述符指向池内存,GPU 每次读的是当前内容
|
||||
// (实测游戏会把流式素材写进仍被采样的贴图存储,不重新登记)。
|
||||
// 信号处理约束:缺页路径只用原子操作与 mprotect,不分配、不加锁。
|
||||
// Write-protect dirty-page tracking for guest memory: pool pages of packaged textures (CPU writes, GPU reads) are set read-only after upload, and as soon as the game writes it faults -> mark dirty, unprotect;
|
||||
// before use, check the write generation of the covered pages and re-upload if newer than at upload time. NVN semantics: a texture descriptor points to pool memory, and the GPU reads the current content every time
|
||||
// (measured: the game writes streamed assets into texture storage that is still being sampled, without re-registering).
|
||||
// Signal handler constraint: the page-fault path uses only atomic operations and mprotect, no allocation, no locks.
|
||||
#include "nvn_dirty.h"
|
||||
#include "../../host/dm.h"
|
||||
#include <stdatomic.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <mach/mach_time.h>
|
||||
|
||||
enum { PG_NONE = 0, PG_PROT = 1, PG_BUSY = 2 }; // BUSY:正在解除保护(另一线程同时缺页时自旋等它) | BUSY: being unprotected (another thread faulting at the same time spins waiting for it)
|
||||
// 跟踪区间 = 各内存池(MemoryPoolInitialize 登记)。池销毁后复用 live=0 的槽,信号处理里无锁扫描。
|
||||
// Tracked ranges = the memory pools (registered by MemoryPoolInitialize). After a pool is destroyed its live=0 slot is reused; the signal handler scans without locks.
|
||||
#define MAX_RANGE 4096 // 原为 256:内存池多于它时超出的池不跟踪,里面的贴图每次取用都当成脏的重传(暗黑实测峰值见内存读数行的「内存池」;塞尔达约 300 个,踩过)。扫描只到已用的槽数,容量大不增加开销 | was 256: with more memory pools than that the excess pools are untracked and their textures are treated as dirty and re-uploaded on every use (for Diablo's measured peak see "memory pools" in the memory readout line; Zelda has about 300 and hit this). The scan only covers slots in use, so a larger capacity costs nothing
|
||||
typedef struct { uintptr_t base, end; _Atomic uint8_t *state; _Atomic uint64_t *gen; size_t cap; _Atomic int live; } range_t;
|
||||
static range_t g_r[MAX_RANGE];
|
||||
static _Atomic int g_nr;
|
||||
static uintptr_t g_pg, g_shift;
|
||||
static _Atomic uint64_t g_now = 1;
|
||||
static _Atomic uint64_t g_faults, g_preps;
|
||||
static _Atomic uint64_t g_adds_total;
|
||||
static _Atomic int g_live, g_live_peak; // 在册的池数与峰值(内存读数行用) | number of registered pools and peak (for the memory readout line)
|
||||
void nvn_dirty_stat(int *live, int *peak, int *cap) { *live = atomic_load(&g_live); *peak = atomic_load(&g_live_peak); *cap = MAX_RANGE; }
|
||||
static _Atomic int g_overflow_logged;
|
||||
static pthread_mutex_t g_slot_mu = PTHREAD_MUTEX_INITIALIZER; // 建池 / 销池(客体线程,可能并发)互斥选槽;缺页处理路径不碰它 | Pool creation / destruction (guest threads, possibly concurrent) pick slots under a mutex; the page-fault handling path does not touch it
|
||||
static _Atomic uint64_t g_mp_calls, g_mp_pages, g_mp_ticks; // 本模块的 mprotect:调用次数、覆盖页数、耗时(mach 时基,缺页路径里也安全) | This module's mprotect: call count, pages covered, time spent (mach timebase, safe in the page-fault path too)
|
||||
static void mp(uintptr_t a, size_t len, int prot) {
|
||||
uint64_t t = mach_absolute_time(); mprotect((void *)a, len, prot);
|
||||
atomic_fetch_add(&g_mp_ticks, mach_absolute_time() - t); atomic_fetch_add(&g_mp_calls, 1); atomic_fetch_add(&g_mp_pages, len >> g_shift);
|
||||
}
|
||||
|
||||
static range_t *find(uintptr_t a) {
|
||||
int n = atomic_load(&g_nr);
|
||||
for (int i = 0; i < n; i++) if (atomic_load_explicit(&g_r[i].live, memory_order_acquire) && a >= g_r[i].base && a < g_r[i].end) return &g_r[i];
|
||||
return NULL;
|
||||
}
|
||||
static void unprotect_page(range_t *r, uintptr_t p) { // 调用方已把状态从 PROT 改成 BUSY | The caller has already changed the state from PROT to BUSY
|
||||
mp(r->base + (p << g_shift), g_pg, PROT_READ | PROT_WRITE);
|
||||
atomic_store(&r->gen[p], atomic_fetch_add(&g_now, 1) + 1);
|
||||
atomic_store(&r->state[p], PG_NONE);
|
||||
}
|
||||
static int on_fault(void *addr, int is_write, void *uc) {
|
||||
(void)uc;
|
||||
range_t *r = is_write ? find((uintptr_t)addr) : NULL;
|
||||
if (!r) return 0;
|
||||
uintptr_t p = ((uintptr_t)addr - r->base) >> g_shift;
|
||||
uint8_t st = PG_PROT;
|
||||
if (atomic_compare_exchange_strong(&r->state[p], &st, PG_BUSY)) { unprotect_page(r, p); atomic_fetch_add(&g_faults, 1); return 1; }
|
||||
if (st == PG_BUSY) { while (atomic_load(&r->state[p]) == PG_BUSY) {} return 1; } // 别的线程正在解:等它解完重执行 | Another thread is unprotecting it: wait for it to finish and re-execute
|
||||
return atomic_load(&r->gen[p]) != 0; // 刚被别的线程解掉(本次缺页发生在解之前):重执行;从未保护过的页不是我们的 | Just unprotected by another thread (this fault happened before the unprotect): re-execute; pages that were never protected are not ours
|
||||
}
|
||||
static void prep_write(void *addr, size_t len) {
|
||||
uintptr_t a = (uintptr_t)addr, e = a + len;
|
||||
while (len && a < e) {
|
||||
range_t *r = find(a);
|
||||
if (!r) { a = (a + g_pg) & ~(g_pg - 1); continue; }
|
||||
uintptr_t stop = e < r->end ? e : r->end;
|
||||
for (uintptr_t p = (a - r->base) >> g_shift, q = (stop - 1 - r->base) >> g_shift; p <= q; p++) {
|
||||
uint8_t st = PG_PROT;
|
||||
if (atomic_compare_exchange_strong(&r->state[p], &st, PG_BUSY)) { unprotect_page(r, p); atomic_fetch_add(&g_preps, 1); }
|
||||
else while (atomic_load(&r->state[p]) == PG_BUSY) {}
|
||||
}
|
||||
a = stop;
|
||||
}
|
||||
}
|
||||
|
||||
void nvn_dirty_add_range(const void *mem, size_t size) {
|
||||
static int inited;
|
||||
if (!inited) { inited = 1; g_pg = (uintptr_t)getpagesize(); g_shift = __builtin_ctzl(g_pg); dm_fault_hook_register(on_fault); dm_guest_write_prep_register(prep_write); }
|
||||
atomic_fetch_add(&g_adds_total, 1);
|
||||
pthread_mutex_lock(&g_slot_mu);
|
||||
int n = atomic_load(&g_nr);
|
||||
int slot = -1;
|
||||
for (int i = 0; i < n; i++) if (!atomic_load_explicit(&g_r[i].live, memory_order_acquire)) { slot = i; break; }
|
||||
if (slot < 0) {
|
||||
if (n >= MAX_RANGE) {
|
||||
int expected = 0;
|
||||
if (atomic_compare_exchange_strong(&g_overflow_logged, &expected, 1)) LOG("【红】脏页跟踪区间已满(%d),池 %p 不跟踪", MAX_RANGE, mem);
|
||||
pthread_mutex_unlock(&g_slot_mu); return;
|
||||
}
|
||||
slot = n;
|
||||
}
|
||||
{ int lv = atomic_fetch_add(&g_live, 1) + 1, pk = atomic_load(&g_live_peak); while (lv > pk && !atomic_compare_exchange_weak(&g_live_peak, &pk, lv)) {} }
|
||||
range_t *r = &g_r[slot];
|
||||
uintptr_t base = (uintptr_t)mem & ~(g_pg - 1), end = ((uintptr_t)mem + size + g_pg - 1) & ~(g_pg - 1);
|
||||
size_t np = (end - base) >> g_shift;
|
||||
_Atomic uint8_t *state = r->state;
|
||||
_Atomic uint64_t *gen = r->gen;
|
||||
if (r->cap < np) {
|
||||
state = calloc(np, 1); gen = calloc(np, sizeof *gen);
|
||||
if (!state || !gen) die("脏页表分配失败(%zu 页)", np);
|
||||
// 旧数组不 free:信号处理里可能仍有极短暂的陈旧读者,泄漏量 = 每页 9 字节。
|
||||
// The old array is not freed: the signal handler may still have a very brief stale reader; leak = 9 bytes per page.
|
||||
r->cap = np;
|
||||
} else {
|
||||
memset((void *)state, 0, np); memset((void *)gen, 0, np * sizeof *gen);
|
||||
}
|
||||
r->base = base; r->end = end; r->state = state; r->gen = gen;
|
||||
if (slot == n) atomic_store(&g_nr, n + 1);
|
||||
atomic_store_explicit(&r->live, 1, memory_order_release);
|
||||
pthread_mutex_unlock(&g_slot_mu);
|
||||
}
|
||||
// 池销毁:先把仍受保护的页还原成可写(池内存归还游戏后可能另作他用),再标失效
|
||||
// Pool destruction: first restore still-protected pages to writable (the pool memory may be reused for something else once returned to the game), then mark invalid
|
||||
void nvn_dirty_remove_range(const void *mem) {
|
||||
pthread_mutex_lock(&g_slot_mu);
|
||||
range_t *r = find((uintptr_t)mem);
|
||||
if (r) { prep_write((void *)r->base, r->end - r->base); atomic_store_explicit(&r->live, 0, memory_order_release); atomic_fetch_sub(&g_live, 1); }
|
||||
pthread_mutex_unlock(&g_slot_mu);
|
||||
}
|
||||
int nvn_dirty_tracked(const void *addr, size_t len) {
|
||||
range_t *r = find((uintptr_t)addr); return r && (uintptr_t)addr + len <= r->end;
|
||||
}
|
||||
// 设只读:先置状态再 mprotect(反过来会有「页已只读、状态仍为 0」的窗口,那时的合法写入会被当成崩溃)
|
||||
// Set read-only: set the state first, then mprotect (the reverse leaves a window of "page already read-only, state still 0", during which a legitimate write would be treated as a crash)
|
||||
void nvn_dirty_protect(const void *addr, size_t len) {
|
||||
if (!len || !nvn_dirty_tracked(addr, len)) return;
|
||||
range_t *r = find((uintptr_t)addr);
|
||||
uintptr_t a = (uintptr_t)addr, p = (a - r->base) >> g_shift, q = (a + len - 1 - r->base) >> g_shift;
|
||||
// 连续置成 PROT 的页合成一次 mprotect(逐页调用在首传大贴图时一帧上千次;选角页启动帧 5:4888 次)。
|
||||
// 已是 PROT / BUSY 的页断开连续段:不重复保护,也不碰别的线程正在解的页
|
||||
// Consecutive pages set to PROT are merged into one mprotect (per-page calls reach thousands per frame on the first upload of large textures; character select page startup frame 5: 4888 calls).
|
||||
// Pages already PROT / BUSY break the consecutive run: do not protect again, and do not touch pages another thread is unprotecting
|
||||
uintptr_t run = 0; int open = 0;
|
||||
for (uintptr_t i = p; i <= q + 1; i++) {
|
||||
uint8_t st = PG_NONE;
|
||||
int took = i <= q && atomic_compare_exchange_strong(&r->state[i], &st, PG_PROT);
|
||||
if (took && !open) { run = i; open = 1; }
|
||||
if (!took && open) { mp(r->base + (run << g_shift), (i - run) << g_shift, PROT_READ); open = 0; }
|
||||
}
|
||||
}
|
||||
uint64_t nvn_dirty_now(void) { return atomic_load(&g_now); }
|
||||
int nvn_dirty_since(const void *addr, size_t len, uint64_t stamp) {
|
||||
if (!len) return 0;
|
||||
if (!nvn_dirty_tracked(addr, len)) return 1; // 未跟踪时保守视为脏,宁可多传也不显示旧内容 | When untracked, conservatively treat as dirty: better to upload more than to show stale content
|
||||
range_t *r = find((uintptr_t)addr);
|
||||
uintptr_t a = (uintptr_t)addr, p = (a - r->base) >> g_shift, q = (a + len - 1 - r->base) >> g_shift;
|
||||
for (uintptr_t i = p; i <= q; i++) if (atomic_load(&r->gen[i]) > stamp) return 1; // 上传前最后一次写的代号 ≤ 戳;之后的写必 > 戳 | The generation of the last write before upload is <= the stamp; any later write must be > the stamp
|
||||
return 0;
|
||||
}
|
||||
void nvn_dirty_slot_stats(int *live, int *used_slots, uint64_t *adds_total) {
|
||||
int n = atomic_load(&g_nr), active = 0;
|
||||
for (int i = 0; i < n; i++) active += atomic_load_explicit(&g_r[i].live, memory_order_acquire) != 0;
|
||||
*live = active; *used_slots = n; *adds_total = atomic_load(&g_adds_total);
|
||||
}
|
||||
void nvn_dirty_stats(uint64_t *faults, uint64_t *preps) { *faults = atomic_load(&g_faults); *preps = atomic_load(&g_preps); }
|
||||
void nvn_dirty_mp_stats(uint64_t *calls, uint64_t *pages, uint64_t *ns) {
|
||||
static mach_timebase_info_data_t tb; if (!tb.denom) mach_timebase_info(&tb);
|
||||
*calls = atomic_load(&g_mp_calls); *pages = atomic_load(&g_mp_pages); *ns = atomic_load(&g_mp_ticks) * tb.numer / tb.denom;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// 客体内存写保护脏页跟踪(nvn_dirty.c)
|
||||
// Write-protect dirty-page tracking for guest memory (nvn_dirty.c)
|
||||
#pragma once
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void nvn_dirty_add_range(const void *mem, size_t size); // 登记一个内存池为跟踪区间(首次调用时注册缺页钩子与宿主写前钩子) | Register a memory pool as a tracked range (the first call registers the page-fault hook and the host pre-write hook)
|
||||
void nvn_dirty_stat(int *live, int *peak, int *cap); // 在册的内存池数、峰值、跟踪表容量(内存读数行用) | number of registered memory pools, peak, tracking table capacity (for the memory readout line)
|
||||
void nvn_dirty_remove_range(const void *mem); // 池销毁:受保护页还原可写并标失效 | Pool destruction: restore protected pages to writable and mark invalid
|
||||
int nvn_dirty_tracked(const void *addr, size_t len);
|
||||
void nvn_dirty_protect(const void *addr, size_t len); // 覆盖页设只读 | Set the covered pages read-only
|
||||
uint64_t nvn_dirty_now(void); // 当前代号:上传前取,作为该份内容的戳 | Current generation: taken before upload, as the stamp of that content
|
||||
int nvn_dirty_since(const void *addr, size_t len, uint64_t stamp); // 覆盖页在戳之后被写过 → 1 | Covered pages were written after the stamp -> 1
|
||||
void nvn_dirty_stats(uint64_t *faults, uint64_t *preps); // 累计:游戏写触发的缺页次数、宿主写前解保护的页数 | Cumulative: number of page faults triggered by game writes, number of pages unprotected before host writes
|
||||
void nvn_dirty_mp_stats(uint64_t *calls, uint64_t *pages, uint64_t *ns); // 累计:本模块 mprotect 调用次数、覆盖页数、耗时 | Cumulative: this module's mprotect call count, pages covered, time spent
|
||||
void nvn_dirty_slot_stats(int *live, int *used_slots, uint64_t *adds_total); // 当前存活槽、槽表高水位、登记总次数 | Currently live slots, slot table high-water mark, total number of registrations
|
||||
@@ -0,0 +1,79 @@
|
||||
.arch_extension lse
|
||||
// 未实现 NVN 函数的公共入口:跳板进来时 x16 = 本函数的槽地址(nvn_slot[i])。
|
||||
// 调 nvn_unimpl_c(slot, x0, x1, x2) 报红记名,返回 0。
|
||||
// Common entry for unimplemented NVN functions: when the thunk comes in, x16 = this function's slot address (nvn_slot[i]).
|
||||
// Calls nvn_unimpl_c(slot, x0, x1, x2) to report a failure and log the name, returns 0.
|
||||
.text
|
||||
.globl _nvn_unimpl_entry
|
||||
.p2align 2
|
||||
_nvn_unimpl_entry:
|
||||
stp x29, x30, [sp, #-16]!
|
||||
mov x29, sp
|
||||
mov x3, x2
|
||||
mov x2, x1
|
||||
mov x1, x0
|
||||
mov x0, x16
|
||||
bl _nvn_unimpl_c
|
||||
ldp x29, x30, [sp], #16
|
||||
ret
|
||||
|
||||
// 计时包装入口(DM_NVN_PROF=1 时槽表指向这里):跳板进来时 x16 = 本函数槽地址。
|
||||
// 保存 x0-x7 / q0-q7(NVN 函数无栈传参,生成器已核),取 mach_absolute_time → 调真实现(nvn_real[i])→ 再取,
|
||||
// 差值原子累加到 nvn_prof_ticks[i](mach 时基单位);返回值 x0/x1、q0-q3 原样带回。
|
||||
// 不用 cntvct_el0:本机实测它与系统时基不成固定比例(cntfrq 报 1 GHz,同区间增量比 98.9),不能换算成时间。
|
||||
// Timing wrapper entry (the slot table points here when DM_NVN_PROF=1): when the thunk comes in, x16 = this function's slot address.
|
||||
// Save x0-x7 / q0-q7 (NVN functions pass no arguments on the stack, verified by the generator), take mach_absolute_time -> call the real implementation (nvn_real[i]) -> take it again,
|
||||
// atomically add the difference to nvn_prof_ticks[i] (mach timebase units); return values x0/x1, q0-q3 are passed back unchanged.
|
||||
// cntvct_el0 is not used: measured on this machine it is not in a fixed ratio to the system timebase (cntfrq reports 1 GHz, increment ratio over the same interval 98.9), so it cannot be converted to time.
|
||||
.globl _nvn_prof_entry
|
||||
.p2align 2
|
||||
_nvn_prof_entry:
|
||||
sub sp, sp, #240
|
||||
stp x29, x30, [sp]
|
||||
mov x29, sp
|
||||
stp x0, x1, [sp, #16]
|
||||
stp x2, x3, [sp, #32]
|
||||
stp x4, x5, [sp, #48]
|
||||
stp x6, x7, [sp, #64]
|
||||
stp q0, q1, [sp, #96]
|
||||
stp q2, q3, [sp, #128]
|
||||
stp q4, q5, [sp, #160]
|
||||
stp q6, q7, [sp, #192]
|
||||
adrp x9, _nvn_slot@PAGE
|
||||
add x9, x9, _nvn_slot@PAGEOFF
|
||||
sub x16, x16, x9
|
||||
lsr x16, x16, #4 // 槽号 i | Slot index i
|
||||
str x16, [sp, #80]
|
||||
bl _mach_absolute_time
|
||||
str x0, [sp, #88]
|
||||
ldr x16, [sp, #80]
|
||||
adrp x9, _nvn_real@PAGE
|
||||
add x9, x9, _nvn_real@PAGEOFF
|
||||
ldr x17, [x9, x16, lsl #3]
|
||||
ldp x0, x1, [sp, #16]
|
||||
ldp x2, x3, [sp, #32]
|
||||
ldp x4, x5, [sp, #48]
|
||||
ldp x6, x7, [sp, #64]
|
||||
ldp q0, q1, [sp, #96]
|
||||
ldp q2, q3, [sp, #128]
|
||||
ldp q4, q5, [sp, #160]
|
||||
ldp q6, q7, [sp, #192]
|
||||
blr x17
|
||||
stp x0, x1, [sp, #16]
|
||||
stp q0, q1, [sp, #96]
|
||||
stp q2, q3, [sp, #128]
|
||||
bl _mach_absolute_time
|
||||
mov x9, x0
|
||||
ldr x10, [sp, #88]
|
||||
sub x9, x9, x10
|
||||
ldr x16, [sp, #80]
|
||||
adrp x10, _nvn_prof_ticks@PAGE
|
||||
add x10, x10, _nvn_prof_ticks@PAGEOFF
|
||||
add x10, x10, x16, lsl #3
|
||||
stadd x9, [x10]
|
||||
ldp x0, x1, [sp, #16]
|
||||
ldp q0, q1, [sp, #96]
|
||||
ldp q2, q3, [sp, #128]
|
||||
ldp x29, x30, [sp]
|
||||
add sp, sp, #240
|
||||
ret
|
||||
@@ -0,0 +1,76 @@
|
||||
// 定长字节键 → 指针 的开放寻址哈希表(线性探测 + 删除时回移,无墓碑)。
|
||||
// 回放热路径用它替代 NSDictionary:键不装箱、不分配,查找只做一次哈希 + memcmp。
|
||||
// 不加锁:调用方按各自的锁保护。值的所有权归调用方(put / del 返回被替换 / 删除的旧值)。单测 tests/t_hmap.c。
|
||||
// Open-addressing hash table from fixed-length byte keys -> pointers (linear probing + backward shift on deletion, no tombstones).
|
||||
// The replay hot path uses it instead of NSDictionary: keys are not boxed, no allocation, a lookup does only one hash + memcmp.
|
||||
// No locking: callers protect it with their own locks. Ownership of values belongs to the caller (put / del return the replaced / deleted old value). Unit test tests/t_hmap.c.
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct { uint8_t *keys; void **vals; uint32_t klen, cap, n; } nvn_hmap; // vals[i] == NULL 即空位 | vals[i] == NULL means an empty slot
|
||||
|
||||
static inline uint64_t nvn_hm_hash(const void *k, uint32_t len) {
|
||||
const uint8_t *p = k; uint64_t h = 0x9e3779b97f4a7c15ull ^ len;
|
||||
for (; len >= 8; p += 8, len -= 8) { uint64_t w; memcpy(&w, p, 8); h = (h ^ w) * 0xff51afd7ed558ccdull; h ^= h >> 32; }
|
||||
if (len) { uint64_t w = 0; memcpy(&w, p, len); h = (h ^ w) * 0xff51afd7ed558ccdull; }
|
||||
h ^= h >> 33; h *= 0xc4ceb9fe1a85ec53ull; h ^= h >> 33;
|
||||
return h;
|
||||
}
|
||||
static inline void nvn_hm_init(nvn_hmap *m, uint32_t klen) { memset(m, 0, sizeof *m); m->klen = klen; }
|
||||
static inline void *nvn_hm_get(const nvn_hmap *m, const void *k) {
|
||||
if (!m->n) return NULL;
|
||||
for (uint32_t i = (uint32_t)nvn_hm_hash(k, m->klen) & (m->cap - 1);; i = (i + 1) & (m->cap - 1)) {
|
||||
if (!m->vals[i]) return NULL;
|
||||
if (!memcmp(m->keys + (size_t)i * m->klen, k, m->klen)) return m->vals[i];
|
||||
}
|
||||
}
|
||||
static inline void *nvn_hm_put(nvn_hmap *m, const void *k, void *v);
|
||||
static inline void nvn_hm_grow(nvn_hmap *m) {
|
||||
nvn_hmap o = *m;
|
||||
m->cap = o.cap ? o.cap * 2 : 64; m->n = 0;
|
||||
m->keys = malloc((size_t)m->cap * m->klen); m->vals = calloc(m->cap, sizeof *m->vals);
|
||||
if (!m->keys || !m->vals) abort();
|
||||
for (uint32_t i = 0; i < o.cap; i++) if (o.vals[i]) nvn_hm_put(m, o.keys + (size_t)i * o.klen, o.vals[i]);
|
||||
free(o.keys); free(o.vals);
|
||||
}
|
||||
// v 不得为 NULL;返回同键的旧值(无则 NULL)
|
||||
// v must not be NULL; returns the old value for the same key (NULL if none)
|
||||
static inline void *nvn_hm_put(nvn_hmap *m, const void *k, void *v) {
|
||||
if ((m->n + 1) * 4 > m->cap * 3) nvn_hm_grow(m); // 装载率 ≤ 3/4 | Load factor <= 3/4
|
||||
for (uint32_t i = (uint32_t)nvn_hm_hash(k, m->klen) & (m->cap - 1);; i = (i + 1) & (m->cap - 1)) {
|
||||
uint8_t *ki = m->keys + (size_t)i * m->klen;
|
||||
if (!m->vals[i]) { memcpy(ki, k, m->klen); m->vals[i] = v; m->n++; return NULL; }
|
||||
if (!memcmp(ki, k, m->klen)) { void *old = m->vals[i]; m->vals[i] = v; return old; }
|
||||
}
|
||||
}
|
||||
// 删除后把同一探测链上后面的项回移补洞,保证查找遇空位即可停
|
||||
// After deletion, shift back later entries on the same probe chain to fill the hole, so that a lookup can stop at the first empty slot
|
||||
static inline void *nvn_hm_del(nvn_hmap *m, const void *k) {
|
||||
if (!m->n) return NULL;
|
||||
uint32_t mask = m->cap - 1, i = (uint32_t)nvn_hm_hash(k, m->klen) & mask;
|
||||
for (;; i = (i + 1) & mask) {
|
||||
if (!m->vals[i]) return NULL;
|
||||
if (!memcmp(m->keys + (size_t)i * m->klen, k, m->klen)) break;
|
||||
}
|
||||
void *old = m->vals[i];
|
||||
for (uint32_t j = i;;) {
|
||||
m->vals[i] = NULL;
|
||||
for (;;) {
|
||||
j = (j + 1) & mask;
|
||||
if (!m->vals[j]) { m->n--; return old; }
|
||||
uint32_t h = (uint32_t)nvn_hm_hash(m->keys + (size_t)j * m->klen, m->klen) & mask;
|
||||
if (i <= j ? (i < h && h <= j) : (i < h || h <= j)) continue; // 理想位在 (i, j] 内:不能前移 | Ideal position is within (i, j]: cannot move forward
|
||||
break;
|
||||
}
|
||||
memcpy(m->keys + (size_t)i * m->klen, m->keys + (size_t)j * m->klen, m->klen); m->vals[i] = m->vals[j];
|
||||
i = j;
|
||||
}
|
||||
}
|
||||
// 清空;rel 非空时对每个值调用一次(释放所有权)
|
||||
// Clear; when rel is non-null, call it once for each value (releasing ownership)
|
||||
static inline void nvn_hm_clear(nvn_hmap *m, void (*rel)(void *)) {
|
||||
for (uint32_t i = 0; i < m->cap; i++) if (m->vals[i]) { if (rel) rel(m->vals[i]); m->vals[i] = NULL; }
|
||||
m->n = 0;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// NVN 空设备的 Metal 执行层(C 接口):内存池 = 零拷贝 MTLBuffer,提交 = MTLCommandBuffer,同步 = MTLSharedEvent。
|
||||
// 时序约定(防 x86 路线 GO_MAP_SHARE 花屏的覆辙):一切「GPU 完成」的可见效果(同步对象就绪、事件值、计数器)
|
||||
// 只在 Metal 命令缓冲真正完成之后才发生;CPU 侧等待只看 MTLSharedEvent 的已完成值。
|
||||
// Metal execution layer of the NVN null device (C interface): memory pool = zero-copy MTLBuffer, submit = MTLCommandBuffer, sync = MTLSharedEvent.
|
||||
// Ordering convention (to avoid repeating the GO_MAP_SHARE corrupted-picture mistake of the x86 route): every visible effect of "GPU completion" (sync object ready, event values, counters)
|
||||
// happens only after the Metal command buffer has actually completed; CPU-side waits look only at the completed value of the MTLSharedEvent.
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
void mtl_init(void);
|
||||
void bf_want_note(const char *key);
|
||||
|
||||
// 内存池:[mem, mem+size) 外扩到页边界建零拷贝缓冲;按 GPU 地址(= CPU 地址)反查缓冲与偏移
|
||||
// Memory pool: [mem, mem+size) is expanded outward to page boundaries to build a zero-copy buffer; look up the buffer and offset by GPU address (= CPU address)
|
||||
void mtl_pool_add(const void *mem, uint64_t size);
|
||||
void mtl_pool_del(const void *mem);
|
||||
int mtl_addr(uint64_t addr, uint64_t len, void **buf, uint64_t *off); // 成功 1;buf 是 (__bridge) id<MTLBuffer> | 1 on success; buf is a (__bridge) id<MTLBuffer>
|
||||
|
||||
typedef struct {
|
||||
uint32_t pso, cps, shaders, dss;
|
||||
uint32_t view_nonnull, view_slots, live_tex, sview_nonnull;
|
||||
uint32_t pools;
|
||||
uint64_t pool_adds;
|
||||
uint32_t c1_bufs; uint64_t c1_alloc, c1_data; // 着色器 c1 常数段:缓冲个数(4 MiB 块 + 独占 64 KiB)、分配字节、实际字节 | Shader c1 constant segment: buffer count (4 MiB blocks + dedicated 64 KiB), allocated bytes, actual bytes
|
||||
} mtl_res_count;
|
||||
void mtl_res_counts(uint32_t tick, const char *why); // 打一行资源计数(宿主按拍 / 事件调用,见 dm.h dm_res_report_register) | Print one line of resource counts (the host calls it per tick / event, see dm_res_report_register in dm.h)
|
||||
void mtl_res_snapshot(mtl_res_count *out);
|
||||
|
||||
// 一次提交:begin → 若干操作 → commit(返回本次提交完成时的栅栏值)
|
||||
// One submit: begin -> several operations -> commit (returns the fence value at which this submit completes)
|
||||
void mtl_sub_begin(void);
|
||||
void mtl_sub_copy(uint64_t src, uint64_t dst, uint64_t n); // GPU 时序上的缓冲拷贝 | Buffer copy in GPU ordering
|
||||
void mtl_sub_event(volatile uint32_t *val, uint32_t mode, uint32_t v); // 完成后写事件值(0 写 / 1 加) | Write the event value after completion (0 write / 1 add)
|
||||
void mtl_sub_counter(uint64_t addr, uint32_t type); // 完成后写计数器记录 | Write the counter record after completion
|
||||
uint64_t mtl_sub_commit(void);
|
||||
|
||||
uint64_t mtl_last_fence(void); // 最近一次提交的栅栏值(0 = 从未提交) | Fence value of the most recent submit (0 = never submitted)
|
||||
int mtl_wait(uint64_t fence, uint64_t timeout_ns); // GPU 完成到 fence 返回 1,超时 0 | Returns 1 when the GPU has completed up to fence, 0 on timeout
|
||||
void mtl_finish(void); // 等所有已提交的命令完成 | Wait for all submitted commands to complete
|
||||
void mtl_drain(void); // 等队列上全部命令(含出图)完成:提交空命令缓冲并等它 | Wait for all commands on the queue (including presents) to complete: submit an empty command buffer and wait for it
|
||||
void mtl_xv_window_tex(uint64_t serial); // 登记窗口(交换链)贴图:跨提交有效性账本永不收它 | Register a window (swapchain) texture: the cross-submit validity ledger never collects it
|
||||
void mtl_ui_ghost(int on, float px, float py, const float grid[4], float cx, float cy); // 拖货跟手图:on=1 时把盖住屏幕点 (px,py)、压在货架格网 grid(左上角 x,y、一格宽高)上的那件货的图标在界面趟末尾平移到中心 (cx,cy) 再画一遍(归一化,左上原点);任意线程调 | Drag-follow image for shop items: when on=1, the icon of the item that covers screen point (px,py) and sits on the shop shelf grid `grid` (top-left x,y, width and height of one cell) is translated to center (cx,cy) and drawn once more at the end of the UI pass (normalized, top-left origin); callable from any thread
|
||||
int mtl_ui_ghost_rect(float r[4]); // 上面认到的那件货的屏幕矩形(归一化);还没认到返回 0 | Screen rectangle (normalized) of the item recognized above; returns 0 if not recognized yet
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,176 @@
|
||||
// NVN 宿主侧对象布局与命令记录格式:hle_nvn.c(接口层,写)与 nvn_mtl.m(Metal 回放层,读)共用。
|
||||
// 对象就地存在游戏分配的 NVN 对象内存里,大小不超过 nvn.h 的保留大小(FITS 静态断言)。
|
||||
// 状态对象(Blend / Color / … 4–0x18 字节)是游戏按值拷贝的小结构,布局用位域就地打包。
|
||||
// NVN host-side object layout and command record format: shared by hle_nvn.c (interface layer, writes) and nvn_mtl.m (Metal replay layer, reads).
|
||||
// Objects are stored in place in the NVN object memory allocated by the game, with size not exceeding the reserved size in nvn.h (FITS static assertion).
|
||||
// State objects (Blend / Color / ... 4–0x18 bytes) are small structs the game copies by value; their layout is packed in place with bit-fields.
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "nvn.h"
|
||||
#include "nvn_tex.h"
|
||||
|
||||
#define MAGIC(a, b, c, d) ((uint32_t)(a) | (uint32_t)(b) << 8 | (uint32_t)(c) << 16 | (uint32_t)(d) << 24)
|
||||
#define FITS(T, H) _Static_assert(sizeof(T) <= sizeof(H), #T " 超出 " #H " 的保留大小")
|
||||
|
||||
typedef struct { uint32_t flags; } dev_builder_t; FITS(dev_builder_t, NVNdeviceBuilder);
|
||||
typedef struct { uint32_t magic, flags, origin, depth_mode; void *dbg_cb, *dbg_data; } dev_t_; FITS(dev_t_, NVNdevice);
|
||||
|
||||
typedef struct { NVNdevice *dev; uint32_t flags; uint64_t cmd_sz, comp_sz, ctl_sz, flush; void *mem; uint64_t mem_sz; } queue_builder_t;
|
||||
FITS(queue_builder_t, NVNqueueBuilder);
|
||||
typedef struct { uint32_t magic; NVNdevice *dev; uint64_t submits; } queue_t; FITS(queue_t, NVNqueue);
|
||||
|
||||
typedef struct { NVNdevice *dev; void *mem; uint64_t size; uint32_t flags; } pool_builder_t; FITS(pool_builder_t, NVNmemoryPoolBuilder);
|
||||
typedef struct { uint32_t magic, flags; uint8_t *mem; uint64_t size; } pool_t; FITS(pool_t, NVNmemoryPool);
|
||||
|
||||
typedef struct { const pool_t *pool; int64_t off; int32_t n; } dpool_t; // 贴图 / 采样器描述符池 | Texture / sampler descriptor pool
|
||||
FITS(dpool_t, NVNtexturePool); FITS(dpool_t, NVNsamplerPool);
|
||||
|
||||
typedef struct {
|
||||
NVNdevice *dev; nvn_texdesc d; pool_t *pool; int64_t off;
|
||||
uint8_t has_layout, layout[8];
|
||||
} tex_builder_t; FITS(tex_builder_t, NVNtextureBuilder);
|
||||
typedef struct {
|
||||
uint32_t magic; nvn_texdesc d; nvn_texlayout L; uint8_t *mem; pool_t *pool; int64_t off; uint8_t has_layout, layout[8];
|
||||
uint64_t serial; // 初始化序号:回放层按它在宿主表里找 MTLTexture(游戏可能按值拷贝对象,不能存对象指针) | Initialization serial: the replay layer uses it to find the MTLTexture in the host table (the game may copy the object by value, so object pointers cannot be stored)
|
||||
} tex_t; FITS(tex_t, NVNtexture);
|
||||
typedef struct { uint8_t set_levels, set_layers, set_format, set_target; int32_t base_level, nlevels, min_layer, nlayers, format, target; } view_t;
|
||||
FITS(view_t, NVNtextureView);
|
||||
|
||||
// 采样器参数(builder 与对象共用一份)
|
||||
// Sampler parameters (one copy shared by builder and object)
|
||||
typedef struct { uint8_t minf, magf, ws, wt, wr, cmp_mode, cmp_func; float lod_min, lod_max, lod_bias, aniso, border[4]; } samp_par; // 枚举值都 < 256 | Enum values are all < 256
|
||||
typedef struct { NVNdevice *dev; samp_par p; } samp_builder_t; FITS(samp_builder_t, NVNsamplerBuilder);
|
||||
typedef struct { uint32_t magic; samp_par p; } samp_t; FITS(samp_t, NVNsampler);
|
||||
|
||||
typedef struct { uint32_t magic, nstage; NVNshaderData sd[6]; uint64_t serial; } prog_t; FITS(prog_t, NVNprogram); // serial:回放层解析结果的表键 | serial: table key for the replay layer's resolved result
|
||||
|
||||
typedef struct { uint32_t magic, fenced; uint64_t fence; } sync_t; FITS(sync_t, NVNsync);
|
||||
typedef struct { const pool_t *pool; int64_t off; } ev_builder_t; FITS(ev_builder_t, NVNeventBuilder);
|
||||
typedef struct { uint32_t magic; volatile uint32_t *val; } ev_t; FITS(ev_t, NVNevent);
|
||||
|
||||
typedef struct { NVNdevice *dev; void *native; int32_t ntex, interval; NVNtexture *tex[4]; } win_builder_t;
|
||||
FITS(win_builder_t, NVNwindowBuilder);
|
||||
// avail[i]:交换链第 i 张可再次获取的时刻(ns,单调时钟)= 它的显示时刻 + 一个出图周期;pace:本窗口的出图节拍器目标时刻
|
||||
// avail[i]: time at which swapchain image i can be acquired again (ns, monotonic clock) = its display time + one present period; pace: target time of this window's present pacer
|
||||
typedef struct { uint32_t magic; void *native; int32_t ntex, interval, next, crop[4]; NVNtexture *tex[4]; uint64_t presents, avail[4], pace, ticket[4]; } win_t; // ticket[i]:第 i 张最近一次出图的票号 | ticket[i]: ticket of the most recent present of image i
|
||||
FITS(win_t, NVNwindow);
|
||||
|
||||
// 命令缓冲:命令写进游戏给的命令内存(AddCommandMemory),句柄 = 段首地址;用完回调游戏补内存
|
||||
// Command buffer: commands are written into the command memory given by the game (AddCommandMemory), handle = segment start address; when it runs out, the game is called back for more memory
|
||||
typedef struct {
|
||||
uint32_t magic, recording;
|
||||
uint8_t *cur, *end; // 当前命令内存段的写指针 / 段尾 | Write pointer / end of the current command memory segment
|
||||
uint8_t *begin; // 本次录制的 BEGIN 记录 | BEGIN record of this recording
|
||||
PFNNVNCOMMANDBUFFERMEMORYCALLBACKPROC cb; void *cb_data;
|
||||
NVNdevice *dev;
|
||||
} cmd_t; FITS(cmd_t, NVNcommandBuffer);
|
||||
|
||||
// ---------- 状态对象(默认值按 NVN / GL 默认) ----------
|
||||
// ---------- State objects (defaults follow the NVN / GL defaults) ----------
|
||||
typedef struct { uint32_t blend_en : 8, logic_op : 4, alpha_func : 4; } color_st; FITS(color_st, NVNcolorState);
|
||||
typedef struct { uint32_t mask; } chmask_st; /* 每目标 4 位:r=1 g=2 b=4 a=8,置位 = 写 | 4 bits per target: r=1 g=2 b=4 a=8, bit set = write */ FITS(chmask_st, NVNchannelMaskState);
|
||||
typedef struct { uint64_t target : 3, src_rgb : 7, dst_rgb : 7, src_a : 7, dst_a : 7, eq_rgb : 3, eq_a : 3; } blend_st;
|
||||
FITS(blend_st, NVNblendState);
|
||||
typedef struct { uint8_t enable, samples, a2c, a2c_dither, raster_samples, cov_mod, cov2color_en, cov2color_out, sl_en, sl_grid; } ms_st;
|
||||
FITS(ms_st, NVNmultisampleState);
|
||||
typedef struct { uint32_t cull : 2, front : 1, mode : 2, offset_en : 3; } poly_st; FITS(poly_st, NVNpolygonState);
|
||||
typedef struct {
|
||||
uint64_t dt : 1, dw : 1, df : 4, st : 1, sf_f : 4, sf_b : 4,
|
||||
fail_f : 4, zfail_f : 4, zpass_f : 4, fail_b : 4, zfail_b : 4, zpass_b : 4;
|
||||
} ds_st; FITS(ds_st, NVNdepthStencilState);
|
||||
typedef struct { uint32_t fmt : 8, offset : 19, stream : 5; } va_st; FITS(va_st, NVNvertexAttribState);
|
||||
typedef struct { uint32_t stride, divisor; } vs_st; FITS(vs_st, NVNvertexStreamState);
|
||||
|
||||
// ---------- 命令记录:{op, size(含头,8 对齐)} + 载荷 ----------
|
||||
// ---------- Command records: {op, size (including header, aligned to 8)} + payload ----------
|
||||
typedef struct { uint32_t op, size; } op_hdr;
|
||||
enum {
|
||||
OP_END, OP_JUMP, OP_BEGIN, OP_CALL,
|
||||
OP_SIGNAL_EVENT, OP_REPORT_COUNTER, OP_COPY_B2B, OP_UPDATE_UB, // CPU 可见副作用 | CPU-visible side effects
|
||||
OP_SET_RT, OP_CLEAR_COLOR, OP_CLEAR_DS, OP_VIEWPORTS, OP_SCISSOR, OP_DEPTH_RANGE,
|
||||
OP_BIND_PROGRAM, OP_BIND_STATE, OP_BIND_VATTR, OP_BIND_VSTREAM, OP_BIND_VBUF,
|
||||
OP_BIND_UBO, OP_BIND_SSBO, OP_BIND_TEX, OP_BIND_SAMP,
|
||||
OP_STENCIL, OP_POLY_OFFSET, OP_DRAW, OP_DRAW_IDX, OP_DISPATCH, OP_BARRIER,
|
||||
OP_SET_TEX_POOL, OP_SET_SAMP_POOL, OP_COPY_B2T, OP_COPY_STRIDE, OP_BLEND_COLOR, OP_COPY_T2B, OP_BIND_IMG, OP_COPY_T2T, OP_RESET_COUNTER, OP_CLEAR_TEX, OP_COUNT_
|
||||
};
|
||||
// 载荷(紧跟 op_hdr)
|
||||
// Payload (immediately follows op_hdr)
|
||||
typedef struct { int32_t n; const tex_t *color[8]; view_t cview[8]; uint8_t has_cview[8]; const tex_t *depth; view_t dview; uint8_t has_dview; } p_set_rt;
|
||||
typedef struct { int32_t index, mask; float rgba[4]; } p_clear_color;
|
||||
typedef struct { float depth; int32_t depth_mask, stencil, stencil_mask; } p_clear_ds;
|
||||
typedef struct { int32_t first, n; float v[16][6]; } p_viewports; // x, y, w, h, 近, 远(近远由 DEPTH_RANGE 覆盖) | x, y, w, h, near, far (near and far are overridden by DEPTH_RANGE)
|
||||
typedef struct { int32_t x, y, w, h; } p_scissor;
|
||||
typedef struct { float n, f; } p_depth_range;
|
||||
typedef struct { const prog_t *prog; int32_t stages; } p_bind_program;
|
||||
typedef struct { int32_t kind; uint8_t bytes[0x18]; } p_bind_state; // kind:0 blend 1 color 2 chmask 3 ms 4 poly 5 ds
|
||||
typedef struct { int32_t first, n; uint32_t st[16]; } p_bind_vattr;
|
||||
typedef struct { int32_t first, n; vs_st st[16]; } p_bind_vstream;
|
||||
typedef struct { int32_t first, n; NVNbufferRange r[16]; } p_bind_vbuf;
|
||||
typedef struct { int32_t stage, index; uint64_t addr, size; } p_bind_buf; // UBO / SSBO
|
||||
typedef struct { int32_t stage, first, n; uint64_t h[32]; } p_bind_handles; // 分离贴图 / 采样器句柄 | Separate texture / sampler handles
|
||||
typedef struct { int32_t face, value_mask, mask, ref, which; } p_stencil; // which:0 值掩码 1 写掩码 2 参考值 | which: 0 value mask 1 write mask 2 reference value
|
||||
typedef struct { float factor, units, clamp; } p_poly_offset;
|
||||
typedef struct { int32_t prim, first, count; } p_draw;
|
||||
typedef struct { int32_t prim, itype, count, base_vertex, base_instance, instances; uint64_t ibuf; } p_draw_idx;
|
||||
typedef struct { int32_t x, y, z; uint64_t caller; } p_dispatch; // caller:游戏调用点返回地址(定位派发者) | caller: return address of the game call site (to locate the dispatcher)
|
||||
typedef struct { const dpool_t *pool; } p_set_pool;
|
||||
typedef struct { uint64_t src; const tex_t *tex; view_t view; uint8_t has_view; NVNcopyRegion r; int32_t flags; } p_copy_b2t;
|
||||
typedef struct { const tex_t *src, *dst; view_t sv, dv; uint8_t has_sv, has_dv; NVNcopyRegion sr, dr; int32_t flags; } p_copy_t2t; // T2B 复用:src 存目标缓冲地址 | Reused for T2B: src stores the destination buffer address
|
||||
typedef struct { const tex_t *tex; view_t view; uint8_t has_view, is_uint; NVNcopyRegion r; int32_t mask; union { float f[4]; uint32_t u[4]; } c; } p_clear_tex;
|
||||
typedef struct { int64_t stride; } p_copy_stride;
|
||||
typedef struct { float rgba[4]; } p_blend_color;
|
||||
|
||||
// Metal 回放层入口(nvn_mtl.m):把一组命令句柄回放进当前提交
|
||||
// Entry point of the Metal replay layer (nvn_mtl.m): replays a set of command handles into the current submission
|
||||
void mtl_exec(const uint8_t *handle);
|
||||
void mtl_exec_rest(const uint64_t *handles, int n); // 告知本次提交里当前句柄之后还有哪些句柄(通道前瞻跨句柄用) | Tells which handles in this submission still follow the current handle (used by the pass lookahead across handles)
|
||||
// 出图:把交换链贴图画到前端 CAMetalLayer(无窗口时只计数)
|
||||
// Present: draw the swapchain texture to the front-end CAMetalLayer (only counts when there is no window)
|
||||
uint64_t mtl_present(const tex_t *t, double period_s, const int crop[4]); // 出图入队、立即返回票号;period_s:该张至少显示的时长(= 出图周期,0 = 不限) | Enqueue a present and return the ticket immediately; period_s: minimum time this image is displayed (= present period, 0 = unlimited)
|
||||
void mtl_present_wait(uint64_t ticket); // 等该票号的出图处理完(blit 已提交到 GPU 队列) | Wait until the present with this ticket has been processed (blit committed to the GPU queue)
|
||||
void mtl_present_flush(void); // 等已入队的出图全部处理完 | Wait until all enqueued presents have been processed
|
||||
void mtl_present_test_stall(uint64_t ns); // 单测:出图线程每次出图前额外停顿 ns | Unit test: extra pause in ns before each present on the present thread
|
||||
int mtl_display_hz(void); // 有窗口时屏幕最高刷新率(Hz),无窗口 0 | Maximum refresh rate of the screen (Hz) when there is a window, 0 without a window
|
||||
void mtl_set_tex_pool_n(int n); // 贴图描述符池容量:池外的贴图号按「空槽」处理(读出 0) | Texture descriptor pool capacity: texture IDs outside the pool are treated as 'empty slots' (read 0)
|
||||
// 计时埋点(Mac / iOS 共用):提交按帧号打标;GPU 时间 = 该帧全部命令缓冲 GPUEnd−GPUStart 之和,全部完成后才可读(否则 −1)
|
||||
// Timing instrumentation (shared by Mac / iOS): submissions are tagged with the frame number; GPU time = sum of GPUEnd−GPUStart over all of that frame's command buffers, readable only after all complete (otherwise −1)
|
||||
void mtl_set_frame(uint64_t f);
|
||||
void mtl_ub_present(double iv_ms); // 同进程交替测量(DM_NVN_UB):出图线程每帧报实际上屏间隔 | Same-process alternating measurement (DM_NVN_UB): the present thread reports the actual present interval every frame
|
||||
double mtl_gpu_ms(uint64_t f);
|
||||
void mtl_sub_index(const uint64_t *h, int n); // 提交开始:按回放顺序建写回前瞻索引(nvn_mtl.m) | Start of submission: build the store lookahead index in replay order (nvn_mtl.m)
|
||||
void xv_test_counts(int *dc, int *viol);
|
||||
int mtl_gpu_span(uint64_t f, uint64_t *t0, uint64_t *t1); // 该帧最早 GPUStart / 最晚 GPUEnd(mach 绝对时间 ns);未全部完成或无 GPU 时间返回 0 | The frame's earliest GPUStart / latest GPUEnd (mach absolute time, ns); returns 0 if not all complete or there is no GPU time
|
||||
void mtl_stats(uint64_t *passes, uint64_t *draws);
|
||||
void mtl_args_stats(uint64_t *enc, uint64_t *reuse);
|
||||
void mtl_use_stats(uint64_t *call, uint64_t *skip);
|
||||
uint64_t mtl_ds_omit(void); // 前瞻证明不用深度模板、未挂深度附件的通道累计数 | Cumulative number of passes with no depth attachment because the lookahead proved depth-stencil unused
|
||||
uint64_t mtl_drawable_ns_take(void); // 取走并清零:出图里等 nextDrawable 的累计 ns // useResource 实发 / 同编码器去重跳过累计次数 // 参数缓冲新编 / 复用累计次数 | Take and zero: cumulative ns spent waiting for nextDrawable in present // Cumulative useResource calls actually issued / skipped by same-encoder dedup // Cumulative argument buffer new-encode / reuse counts
|
||||
void mtl_bw(uint64_t *load, uint64_t *store, uint64_t *full_rw_passes); // 附件读入 / 写出累计字节、全量读写通道累计数 | Cumulative attachment load / store bytes, cumulative number of full load-store passes
|
||||
uint64_t mtl_udc_saved_bytes(void); // DM_NVN_UNWRITTEN_DC 实际省下的写回字节 | Write-back bytes actually saved by DM_NVN_UNWRITTEN_DC
|
||||
int mtl_has_window(void);
|
||||
int mtl_warm_wait(int timeout_ms);
|
||||
int mtl_link_active(void);
|
||||
int mtl_link_wait_tick(uint64_t timeout_ns);
|
||||
double mtl_presented_time(uint64_t n);
|
||||
// 第 n 次出图(从 1 计)的实际呈现时刻(秒);0 = 未就绪,−1 = 被丢弃
|
||||
// Actual presentation time (seconds) of the n-th present (counted from 1); 0 = not ready, −1 = dropped
|
||||
// 贴图释放(Finalize 时)
|
||||
// Texture release (at Finalize)
|
||||
void mtl_tex_release(tex_t *t);
|
||||
void mtl_pkg_stats(uint64_t *uploads, uint64_t *reuploads);
|
||||
uint64_t mtl_pkg_miss(void);
|
||||
uint64_t mtl_upload_ns_take(void); // 取走并清零:上次以来提交线程上预排布贴图上传耗时 // DM_NVN_DIRTYCHECK 诊断:漏检次数 // 预排布贴图:首传次数、因池内容变化而重传次数 | Take and zero: time spent uploading packaged textures on the submit thread since last time // DM_NVN_DIRTYCHECK diagnostic: number of missed detections // Packaged textures: number of first uploads, number of re-uploads due to pool content changes
|
||||
uint64_t mtl_upload_gpu_ns_take(void); // 取走并清零:上传命令缓冲的显卡执行耗时(GPUEndTime − GPUStartTime 累加) | Take and zero: GPU execution time of upload command buffers (sum of GPUEndTime − GPUStartTime)
|
||||
void mtl_create_stats(uint64_t *lib, uint64_t *pso); // 累计:提交线程上同步载入的着色器库数、同步新建的渲染 + 计算管线数(预热领用的不算) | Cumulative: number of shader libraries loaded synchronously on the submit thread, number of render + compute pipelines created synchronously (those taken from warm-up do not count)
|
||||
// CPU 读贴图:level / layer0 起,按 row / img 字节步长写进 dst
|
||||
// CPU texture read: starting at level / layer0, written into dst with row / img byte strides
|
||||
void mtl_read_texels(const tex_t *t, unsigned level, unsigned layer0, const NVNcopyRegion *r, uint8_t *dst, size_t row, size_t img);
|
||||
// 描述符池登记(贴图号 / 采样器号 → 对象快照)、程序释放
|
||||
// Descriptor pool registration (texture ID / sampler ID → object snapshot), program release
|
||||
void mtl_reg_tex(int id, const tex_t *t, const view_t *v);
|
||||
void mtl_reg_samp(int id, const samp_par *p);
|
||||
void mtl_prog_release(prog_t *p);
|
||||
// 新序号(> 0,全局递增)
|
||||
// New serial (> 0, globally increasing)
|
||||
uint64_t nvn_new_serial(void);
|
||||
@@ -0,0 +1,20 @@
|
||||
// 出图节拍器(纯函数,Mac / iOS 共用;单测 tests/t_pace.c)。
|
||||
// 语义同垂直同步:节拍点 = 上一节拍点 + 周期。早到 → 等到节拍点;迟到不足一个周期 → 立即出图、保持原相位;
|
||||
// 落后一个周期以上(卡顿)→ 从当前时刻重新起拍,不连发追帧。周期 0 = 不等(节拍点跟随当前时刻)。
|
||||
// Present pacer (pure function, shared by Mac / iOS; unit test tests/t_pace.c).
|
||||
// Semantics as vsync: present slot = previous present slot + period. Early → wait until the present slot; late by less than one period → present immediately and keep the original phase;
|
||||
// behind by one period or more (stutter) → restart the cadence from the current time, no burst of presents to catch up. Period 0 = no wait (the present slot follows the current time).
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct { uint64_t target; } nvn_pacer;
|
||||
|
||||
// now:单调时钟(ns);period:本帧周期(ns,0 = 不等)。返回需要等待的 ns(0 = 立即出图),并更新内部目标时刻。
|
||||
// now: monotonic clock (ns); period: this frame's period (ns, 0 = no wait). Returns the ns to wait (0 = present immediately) and updates the internal target time.
|
||||
static inline uint64_t nvn_pace(nvn_pacer *p, uint64_t now, uint64_t period) {
|
||||
if (!period || !p->target) { p->target = now; return 0; }
|
||||
uint64_t next = p->target + period;
|
||||
if (now <= next) { p->target = next; return next - now; }
|
||||
p->target = now - next < period ? next : now;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,577 @@
|
||||
// 由 dm/gfx/tools/gen_protos.py 生成,勿手改。NVNboolean 参数已换成 uint32_t。
|
||||
// Generated by dm/gfx/tools/gen_protos.py, do not edit by hand. NVNboolean parameters have been replaced with uint32_t.
|
||||
#pragma once
|
||||
#include "nvn.h"
|
||||
|
||||
typedef void (*NVNT_nvnDeviceBuilderSetDefaults)(NVNdeviceBuilder*);
|
||||
typedef void (*NVNT_nvnDeviceBuilderSetFlags)(NVNdeviceBuilder*, int);
|
||||
typedef NVNboolean (*NVNT_nvnDeviceInitialize)(NVNdevice*, const NVNdeviceBuilder*);
|
||||
typedef void (*NVNT_nvnDeviceFinalize)(NVNdevice*);
|
||||
typedef void (*NVNT_nvnDeviceSetDebugLabel)(NVNdevice*, const char*);
|
||||
typedef PFNNVNGENERICFUNCPTRPROC (*NVNT_nvnDeviceGetProcAddress)(const NVNdevice*, const char*);
|
||||
typedef void (*NVNT_nvnDeviceGetInteger)(const NVNdevice*, NVNdeviceInfo, int*);
|
||||
typedef uint64_t (*NVNT_nvnDeviceGetCurrentTimestampInNanoseconds)(const NVNdevice*);
|
||||
typedef void (*NVNT_nvnDeviceSetIntermediateShaderCache)(NVNdevice*, int);
|
||||
typedef NVNtextureHandle (*NVNT_nvnDeviceGetTextureHandle)(const NVNdevice*, int, int);
|
||||
typedef NVNtextureHandle (*NVNT_nvnDeviceGetTexelFetchHandle)(const NVNdevice*, int);
|
||||
typedef NVNimageHandle (*NVNT_nvnDeviceGetImageHandle)(const NVNdevice*, int);
|
||||
typedef void (*NVNT_nvnDeviceInstallDebugCallback)(NVNdevice*, const PFNNVNDEBUGCALLBACKPROC, void*, uint32_t);
|
||||
typedef NVNdebugDomainId (*NVNT_nvnDeviceGenerateDebugDomainId)(const NVNdevice*, const char*);
|
||||
typedef void (*NVNT_nvnDeviceSetWindowOriginMode)(NVNdevice*, NVNwindowOriginMode);
|
||||
typedef void (*NVNT_nvnDeviceSetDepthMode)(NVNdevice*, NVNdepthMode);
|
||||
typedef NVNboolean (*NVNT_nvnDeviceRegisterFastClearColor)(NVNdevice*, const float*, NVNformat);
|
||||
typedef NVNboolean (*NVNT_nvnDeviceRegisterFastClearColori)(NVNdevice*, const int*, NVNformat);
|
||||
typedef NVNboolean (*NVNT_nvnDeviceRegisterFastClearColorui)(NVNdevice*, const uint32_t*, NVNformat);
|
||||
typedef NVNboolean (*NVNT_nvnDeviceRegisterFastClearDepth)(NVNdevice*, float);
|
||||
typedef NVNwindowOriginMode (*NVNT_nvnDeviceGetWindowOriginMode)(const NVNdevice*);
|
||||
typedef NVNdepthMode (*NVNT_nvnDeviceGetDepthMode)(const NVNdevice*);
|
||||
typedef uint64_t (*NVNT_nvnDeviceGetTimestampInNanoseconds)(const NVNdevice*, const NVNcounterData*);
|
||||
typedef void (*NVNT_nvnDeviceApplyDeferredFinalizes)(NVNdevice*, int);
|
||||
typedef void (*NVNT_nvnDeviceFinalizeCommandHandle)(NVNdevice*, NVNcommandHandle);
|
||||
typedef void (*NVNT_nvnDeviceWalkDebugDatabase)(const NVNdevice*, NVNdebugObjectType, PFNNVNWALKDEBUGDATABASECALLBACKPROC, void*);
|
||||
typedef NVNseparateTextureHandle (*NVNT_nvnDeviceGetSeparateTextureHandle)(const NVNdevice*, int);
|
||||
typedef NVNseparateSamplerHandle (*NVNT_nvnDeviceGetSeparateSamplerHandle)(const NVNdevice*, int);
|
||||
typedef NVNboolean (*NVNT_nvnDeviceIsExternalDebuggerAttached)(const NVNdevice*);
|
||||
typedef NVNqueueGetErrorResult (*NVNT_nvnQueueGetError)(NVNqueue*, NVNqueueErrorInfo*);
|
||||
typedef size_t (*NVNT_nvnQueueGetTotalCommandMemoryUsed)(NVNqueue*);
|
||||
typedef size_t (*NVNT_nvnQueueGetTotalControlMemoryUsed)(NVNqueue*);
|
||||
typedef size_t (*NVNT_nvnQueueGetTotalComputeMemoryUsed)(NVNqueue*);
|
||||
typedef void (*NVNT_nvnQueueResetMemoryUsageCounts)(NVNqueue*);
|
||||
typedef void (*NVNT_nvnQueueBuilderSetDevice)(NVNqueueBuilder*, NVNdevice*);
|
||||
typedef void (*NVNT_nvnQueueBuilderSetDefaults)(NVNqueueBuilder*);
|
||||
typedef void (*NVNT_nvnQueueBuilderSetFlags)(NVNqueueBuilder*, int);
|
||||
typedef void (*NVNT_nvnQueueBuilderSetCommandMemorySize)(NVNqueueBuilder*, size_t);
|
||||
typedef void (*NVNT_nvnQueueBuilderSetComputeMemorySize)(NVNqueueBuilder*, size_t);
|
||||
typedef void (*NVNT_nvnQueueBuilderSetControlMemorySize)(NVNqueueBuilder*, size_t);
|
||||
typedef size_t (*NVNT_nvnQueueBuilderGetQueueMemorySize)(const NVNqueueBuilder*);
|
||||
typedef void (*NVNT_nvnQueueBuilderSetQueueMemory)(NVNqueueBuilder*, void*, size_t);
|
||||
typedef void (*NVNT_nvnQueueBuilderSetCommandFlushThreshold)(NVNqueueBuilder*, size_t);
|
||||
typedef NVNboolean (*NVNT_nvnQueueInitialize)(NVNqueue*, const NVNqueueBuilder*);
|
||||
typedef void (*NVNT_nvnQueueFinalize)(NVNqueue*);
|
||||
typedef void (*NVNT_nvnQueueSetDebugLabel)(NVNqueue*, const char*);
|
||||
typedef void (*NVNT_nvnQueueSubmitCommands)(NVNqueue*, int, const NVNcommandHandle*);
|
||||
typedef void (*NVNT_nvnQueueFlush)(NVNqueue*);
|
||||
typedef void (*NVNT_nvnQueueFinish)(NVNqueue*);
|
||||
typedef void (*NVNT_nvnQueuePresentTexture)(NVNqueue*, NVNwindow*, int);
|
||||
typedef NVNqueueAcquireTextureResult (*NVNT_nvnQueueAcquireTexture)(NVNqueue*, NVNwindow*, int*);
|
||||
typedef void (*NVNT_nvnWindowBuilderSetDevice)(NVNwindowBuilder*, NVNdevice*);
|
||||
typedef void (*NVNT_nvnWindowBuilderSetDefaults)(NVNwindowBuilder*);
|
||||
typedef void (*NVNT_nvnWindowBuilderSetNativeWindow)(NVNwindowBuilder*, NVNnativeWindow);
|
||||
typedef void (*NVNT_nvnWindowBuilderSetTextures)(NVNwindowBuilder*, int, NVNtexture* const*);
|
||||
typedef void (*NVNT_nvnWindowBuilderSetPresentInterval)(NVNwindowBuilder*, int);
|
||||
typedef NVNnativeWindow (*NVNT_nvnWindowBuilderGetNativeWindow)(const NVNwindowBuilder*);
|
||||
typedef int (*NVNT_nvnWindowBuilderGetPresentInterval)(const NVNwindowBuilder*);
|
||||
typedef NVNboolean (*NVNT_nvnWindowInitialize)(NVNwindow*, const NVNwindowBuilder*);
|
||||
typedef void (*NVNT_nvnWindowFinalize)(NVNwindow*);
|
||||
typedef void (*NVNT_nvnWindowSetDebugLabel)(NVNwindow*, const char*);
|
||||
typedef NVNwindowAcquireTextureResult (*NVNT_nvnWindowAcquireTexture)(NVNwindow*, NVNsync*, int*);
|
||||
typedef NVNnativeWindow (*NVNT_nvnWindowGetNativeWindow)(const NVNwindow*);
|
||||
typedef int (*NVNT_nvnWindowGetPresentInterval)(const NVNwindow*);
|
||||
typedef void (*NVNT_nvnWindowSetPresentInterval)(NVNwindow*, int);
|
||||
typedef void (*NVNT_nvnWindowSetCrop)(NVNwindow*, int, int, int, int);
|
||||
typedef void (*NVNT_nvnWindowGetCrop)(const NVNwindow*, NVNrectangle*);
|
||||
typedef NVNboolean (*NVNT_nvnProgramInitialize)(NVNprogram*, NVNdevice*);
|
||||
typedef void (*NVNT_nvnProgramFinalize)(NVNprogram*);
|
||||
typedef void (*NVNT_nvnProgramSetDebugLabel)(NVNprogram*, const char*);
|
||||
typedef NVNboolean (*NVNT_nvnProgramSetShaders)(NVNprogram*, int, const NVNshaderData*);
|
||||
typedef void (*NVNT_nvnMemoryPoolBuilderSetDevice)(NVNmemoryPoolBuilder*, NVNdevice*);
|
||||
typedef void (*NVNT_nvnMemoryPoolBuilderSetDefaults)(NVNmemoryPoolBuilder*);
|
||||
typedef void (*NVNT_nvnMemoryPoolBuilderSetStorage)(NVNmemoryPoolBuilder*, void*, size_t);
|
||||
typedef void (*NVNT_nvnMemoryPoolBuilderSetFlags)(NVNmemoryPoolBuilder*, int);
|
||||
typedef void (*NVNT_nvnMemoryPoolBuilderGetMemory)(const NVNmemoryPoolBuilder*);
|
||||
typedef size_t (*NVNT_nvnMemoryPoolBuilderGetSize)(const NVNmemoryPoolBuilder*);
|
||||
typedef NVNmemoryPoolFlags (*NVNT_nvnMemoryPoolBuilderGetFlags)(const NVNmemoryPoolBuilder*);
|
||||
typedef NVNboolean (*NVNT_nvnMemoryPoolInitialize)(NVNmemoryPool*, const NVNmemoryPoolBuilder*);
|
||||
typedef void (*NVNT_nvnMemoryPoolSetDebugLabel)(NVNmemoryPool*, const char*);
|
||||
typedef void (*NVNT_nvnMemoryPoolFinalize)(NVNmemoryPool*);
|
||||
typedef void* (*NVNT_nvnMemoryPoolMap)(const NVNmemoryPool*);
|
||||
typedef void (*NVNT_nvnMemoryPoolFlushMappedRange)(const NVNmemoryPool*, ptrdiff_t, size_t);
|
||||
typedef void (*NVNT_nvnMemoryPoolInvalidateMappedRange)(const NVNmemoryPool*, ptrdiff_t, size_t);
|
||||
typedef NVNbufferAddress (*NVNT_nvnMemoryPoolGetBufferAddress)(const NVNmemoryPool*);
|
||||
typedef NVNboolean (*NVNT_nvnMemoryPoolMapVirtual)(NVNmemoryPool*, int, const NVNmappingRequest*);
|
||||
typedef size_t (*NVNT_nvnMemoryPoolGetSize)(const NVNmemoryPool*);
|
||||
typedef NVNmemoryPoolFlags (*NVNT_nvnMemoryPoolGetFlags)(const NVNmemoryPool*);
|
||||
typedef NVNboolean (*NVNT_nvnTexturePoolInitialize)(NVNtexturePool*, const NVNmemoryPool*, ptrdiff_t, int);
|
||||
typedef void (*NVNT_nvnTexturePoolSetDebugLabel)(NVNtexturePool*, const char*);
|
||||
typedef void (*NVNT_nvnTexturePoolFinalize)(NVNtexturePool*);
|
||||
typedef void (*NVNT_nvnTexturePoolRegisterTexture)(const NVNtexturePool*, int, const NVNtexture*, const NVNtextureView*);
|
||||
typedef void (*NVNT_nvnTexturePoolRegisterImage)(const NVNtexturePool*, int, const NVNtexture*, const NVNtextureView*);
|
||||
typedef const NVNmemoryPool* (*NVNT_nvnTexturePoolGetMemoryPool)(const NVNtexturePool*);
|
||||
typedef ptrdiff_t (*NVNT_nvnTexturePoolGetMemoryOffset)(const NVNtexturePool*);
|
||||
typedef int (*NVNT_nvnTexturePoolGetSize)(const NVNtexturePool*);
|
||||
typedef NVNboolean (*NVNT_nvnSamplerPoolInitialize)(NVNsamplerPool*, const NVNmemoryPool*, ptrdiff_t, int);
|
||||
typedef void (*NVNT_nvnSamplerPoolSetDebugLabel)(NVNsamplerPool*, const char*);
|
||||
typedef void (*NVNT_nvnSamplerPoolFinalize)(NVNsamplerPool*);
|
||||
typedef void (*NVNT_nvnSamplerPoolRegisterSampler)(const NVNsamplerPool*, int, const NVNsampler*);
|
||||
typedef void (*NVNT_nvnSamplerPoolRegisterSamplerBuilder)(const NVNsamplerPool*, int, const NVNsamplerBuilder*);
|
||||
typedef const NVNmemoryPool* (*NVNT_nvnSamplerPoolGetMemoryPool)(const NVNsamplerPool*);
|
||||
typedef ptrdiff_t (*NVNT_nvnSamplerPoolGetMemoryOffset)(const NVNsamplerPool*);
|
||||
typedef int (*NVNT_nvnSamplerPoolGetSize)(const NVNsamplerPool*);
|
||||
typedef void (*NVNT_nvnBufferBuilderSetDevice)(NVNbufferBuilder*, NVNdevice*);
|
||||
typedef void (*NVNT_nvnBufferBuilderSetDefaults)(NVNbufferBuilder*);
|
||||
typedef void (*NVNT_nvnBufferBuilderSetStorage)(NVNbufferBuilder*, NVNmemoryPool*, ptrdiff_t, size_t);
|
||||
typedef NVNmemoryPool (*NVNT_nvnBufferBuilderGetMemoryPool)(const NVNbufferBuilder*);
|
||||
typedef ptrdiff_t (*NVNT_nvnBufferBuilderGetMemoryOffset)(const NVNbufferBuilder*);
|
||||
typedef size_t (*NVNT_nvnBufferBuilderGetSize)(const NVNbufferBuilder*);
|
||||
typedef NVNboolean (*NVNT_nvnBufferInitialize)(NVNbuffer*, const NVNbufferBuilder*);
|
||||
typedef void (*NVNT_nvnBufferSetDebugLabel)(NVNbuffer*, const char*);
|
||||
typedef void (*NVNT_nvnBufferFinalize)(NVNbuffer*);
|
||||
typedef void* (*NVNT_nvnBufferMap)(const NVNbuffer*);
|
||||
typedef NVNbufferAddress (*NVNT_nvnBufferGetAddress)(const NVNbuffer*);
|
||||
typedef void (*NVNT_nvnBufferFlushMappedRange)(const NVNbuffer*, ptrdiff_t, size_t);
|
||||
typedef void (*NVNT_nvnBufferInvalidateMappedRange)(const NVNbuffer*, ptrdiff_t, size_t);
|
||||
typedef NVNmemoryPool* (*NVNT_nvnBufferGetMemoryPool)(const NVNbuffer*);
|
||||
typedef ptrdiff_t (*NVNT_nvnBufferGetMemoryOffset)(const NVNbuffer*);
|
||||
typedef size_t (*NVNT_nvnBufferGetSize)(const NVNbuffer*);
|
||||
typedef uint64_t (*NVNT_nvnBufferGetDebugID)(const NVNbuffer*);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetDevice)(NVNtextureBuilder*, NVNdevice*);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetDefaults)(NVNtextureBuilder*);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetFlags)(NVNtextureBuilder*, int);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetTarget)(NVNtextureBuilder*, NVNtextureTarget);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetWidth)(NVNtextureBuilder*, int);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetHeight)(NVNtextureBuilder*, int);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetDepth)(NVNtextureBuilder*, int);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetSize1D)(NVNtextureBuilder*, int);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetSize2D)(NVNtextureBuilder*, int, int);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetSize3D)(NVNtextureBuilder*, int, int, int);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetLevels)(NVNtextureBuilder*, int);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetFormat)(NVNtextureBuilder*, NVNformat);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetSamples)(NVNtextureBuilder*, int);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetSwizzle)(NVNtextureBuilder*, NVNtextureSwizzle, NVNtextureSwizzle, NVNtextureSwizzle, NVNtextureSwizzle);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetDepthStencilMode)(NVNtextureBuilder*, NVNtextureDepthStencilMode);
|
||||
typedef size_t (*NVNT_nvnTextureBuilderGetStorageSize)(const NVNtextureBuilder*);
|
||||
typedef size_t (*NVNT_nvnTextureBuilderGetStorageAlignment)(const NVNtextureBuilder*);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetStorage)(NVNtextureBuilder*, NVNmemoryPool*, ptrdiff_t);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetPackagedTextureData)(NVNtextureBuilder*, const void*);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetPackagedTextureLayout)(NVNtextureBuilder*, const NVNpackagedTextureLayout*);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetStride)(NVNtextureBuilder*, ptrdiff_t);
|
||||
typedef void (*NVNT_nvnTextureBuilderSetGLTextureName)(NVNtextureBuilder*, uint32_t);
|
||||
typedef NVNstorageClass (*NVNT_nvnTextureBuilderGetStorageClass)(const NVNtextureBuilder*);
|
||||
typedef NVNtextureFlags (*NVNT_nvnTextureBuilderGetFlags)(const NVNtextureBuilder*);
|
||||
typedef NVNtextureTarget (*NVNT_nvnTextureBuilderGetTarget)(const NVNtextureBuilder*);
|
||||
typedef int (*NVNT_nvnTextureBuilderGetWidth)(const NVNtextureBuilder*);
|
||||
typedef int (*NVNT_nvnTextureBuilderGetHeight)(const NVNtextureBuilder*);
|
||||
typedef int (*NVNT_nvnTextureBuilderGetDepth)(const NVNtextureBuilder*);
|
||||
typedef int (*NVNT_nvnTextureBuilderGetLevels)(const NVNtextureBuilder*);
|
||||
typedef NVNformat (*NVNT_nvnTextureBuilderGetFormat)(const NVNtextureBuilder*);
|
||||
typedef int (*NVNT_nvnTextureBuilderGetSamples)(const NVNtextureBuilder*);
|
||||
typedef void (*NVNT_nvnTextureBuilderGetSwizzle)(const NVNtextureBuilder*, NVNtextureSwizzle*, NVNtextureSwizzle*, NVNtextureSwizzle*, NVNtextureSwizzle*);
|
||||
typedef NVNtextureDepthStencilMode (*NVNT_nvnTextureBuilderGetDepthStencilMode)(const NVNtextureBuilder*);
|
||||
typedef const void* (*NVNT_nvnTextureBuilderGetPackagedTextureData)(const NVNtextureBuilder*);
|
||||
typedef ptrdiff_t (*NVNT_nvnTextureBuilderGetStride)(const NVNtextureBuilder*);
|
||||
typedef void (*NVNT_nvnTextureBuilderGetSparseTileLayout)(const NVNtextureBuilder*, NVNtextureSparseTileLayout*);
|
||||
typedef uint32_t (*NVNT_nvnTextureBuilderGetGLTextureName)(const NVNtextureBuilder*);
|
||||
typedef size_t (*NVNT_nvnTextureBuilderGetZCullStorageSize)(const NVNtextureBuilder*);
|
||||
typedef NVNmemoryPool (*NVNT_nvnTextureBuilderGetMemoryPool)(const NVNtextureBuilder*);
|
||||
typedef ptrdiff_t (*NVNT_nvnTextureBuilderGetMemoryOffset)(const NVNtextureBuilder*);
|
||||
typedef void (*NVNT_nvnTextureViewSetDefaults)(NVNtextureView*);
|
||||
typedef void (*NVNT_nvnTextureViewSetLevels)(NVNtextureView*, int, int);
|
||||
typedef void (*NVNT_nvnTextureViewSetLayers)(NVNtextureView*, int, int);
|
||||
typedef void (*NVNT_nvnTextureViewSetFormat)(NVNtextureView*, NVNformat);
|
||||
typedef void (*NVNT_nvnTextureViewSetSwizzle)(NVNtextureView*, NVNtextureSwizzle, NVNtextureSwizzle, NVNtextureSwizzle, NVNtextureSwizzle);
|
||||
typedef void (*NVNT_nvnTextureViewSetDepthStencilMode)(NVNtextureView*, NVNtextureDepthStencilMode);
|
||||
typedef void (*NVNT_nvnTextureViewSetTarget)(NVNtextureView*, NVNtextureTarget);
|
||||
typedef NVNboolean (*NVNT_nvnTextureViewGetLevels)(const NVNtextureView*, int*, int*);
|
||||
typedef NVNboolean (*NVNT_nvnTextureViewGetLayers)(const NVNtextureView*, int*, int*);
|
||||
typedef NVNboolean (*NVNT_nvnTextureViewGetFormat)(const NVNtextureView*, NVNformat*);
|
||||
typedef NVNboolean (*NVNT_nvnTextureViewGetSwizzle)(const NVNtextureView*, NVNtextureSwizzle*, NVNtextureSwizzle*, NVNtextureSwizzle*, NVNtextureSwizzle*);
|
||||
typedef NVNboolean (*NVNT_nvnTextureViewGetDepthStencilMode)(const NVNtextureView*, NVNtextureDepthStencilMode*);
|
||||
typedef NVNboolean (*NVNT_nvnTextureViewGetTarget)(const NVNtextureView*, NVNtextureTarget*);
|
||||
typedef NVNboolean (*NVNT_nvnTextureViewCompare)(const NVNtextureView*, const NVNtextureView*);
|
||||
typedef NVNboolean (*NVNT_nvnTextureInitialize)(NVNtexture*, const NVNtextureBuilder*);
|
||||
typedef size_t (*NVNT_nvnTextureGetZCullStorageSize)(const NVNtexture*);
|
||||
typedef void (*NVNT_nvnTextureFinalize)(NVNtexture*);
|
||||
typedef void (*NVNT_nvnTextureSetDebugLabel)(NVNtexture*, const char*);
|
||||
typedef NVNstorageClass (*NVNT_nvnTextureGetStorageClass)(const NVNtexture*);
|
||||
typedef ptrdiff_t (*NVNT_nvnTextureGetViewOffset)(const NVNtexture*, const NVNtextureView*);
|
||||
typedef NVNtextureFlags (*NVNT_nvnTextureGetFlags)(const NVNtexture*);
|
||||
typedef NVNtextureTarget (*NVNT_nvnTextureGetTarget)(const NVNtexture*);
|
||||
typedef int (*NVNT_nvnTextureGetWidth)(const NVNtexture*);
|
||||
typedef int (*NVNT_nvnTextureGetHeight)(const NVNtexture*);
|
||||
typedef int (*NVNT_nvnTextureGetDepth)(const NVNtexture*);
|
||||
typedef int (*NVNT_nvnTextureGetLevels)(const NVNtexture*);
|
||||
typedef NVNformat (*NVNT_nvnTextureGetFormat)(const NVNtexture*);
|
||||
typedef int (*NVNT_nvnTextureGetSamples)(const NVNtexture*);
|
||||
typedef void (*NVNT_nvnTextureGetSwizzle)(const NVNtexture*, NVNtextureSwizzle*, NVNtextureSwizzle*, NVNtextureSwizzle*, NVNtextureSwizzle*);
|
||||
typedef NVNtextureDepthStencilMode (*NVNT_nvnTextureGetDepthStencilMode)(const NVNtexture*);
|
||||
typedef ptrdiff_t (*NVNT_nvnTextureGetStride)(const NVNtexture*);
|
||||
typedef NVNtextureAddress (*NVNT_nvnTextureGetTextureAddress)(const NVNtexture*);
|
||||
typedef void (*NVNT_nvnTextureGetSparseTileLayout)(const NVNtexture*, NVNtextureSparseTileLayout*);
|
||||
typedef void (*NVNT_nvnTextureWriteTexels)(const NVNtexture*, const NVNtextureView*, const NVNcopyRegion*, const void*);
|
||||
typedef void (*NVNT_nvnTextureWriteTexelsStrided)(const NVNtexture*, const NVNtextureView*, const NVNcopyRegion*, const void*, ptrdiff_t, ptrdiff_t);
|
||||
typedef void (*NVNT_nvnTextureReadTexels)(const NVNtexture*, const NVNtextureView*, const NVNcopyRegion*, void*);
|
||||
typedef void (*NVNT_nvnTextureReadTexelsStrided)(const NVNtexture*, const NVNtextureView*, const NVNcopyRegion*, void*, ptrdiff_t, ptrdiff_t);
|
||||
typedef void (*NVNT_nvnTextureFlushTexels)(const NVNtexture*, const NVNtextureView*, const NVNcopyRegion*);
|
||||
typedef void (*NVNT_nvnTextureInvalidateTexels)(const NVNtexture*, const NVNtextureView*, const NVNcopyRegion*);
|
||||
typedef NVNmemoryPool (*NVNT_nvnTextureGetMemoryPool)(const NVNtexture*);
|
||||
typedef ptrdiff_t (*NVNT_nvnTextureGetMemoryOffset)(const NVNtexture*);
|
||||
typedef int (*NVNT_nvnTextureGetStorageSize)(const NVNtexture*);
|
||||
typedef NVNboolean (*NVNT_nvnTextureCompare)(const NVNtexture*, const NVNtexture*);
|
||||
typedef uint64_t (*NVNT_nvnTextureGetDebugID)(const NVNtexture*);
|
||||
typedef void (*NVNT_nvnSamplerBuilderSetDevice)(NVNsamplerBuilder*, NVNdevice*);
|
||||
typedef void (*NVNT_nvnSamplerBuilderSetDefaults)(NVNsamplerBuilder*);
|
||||
typedef void (*NVNT_nvnSamplerBuilderSetMinMagFilter)(NVNsamplerBuilder*, NVNminFilter, NVNmagFilter);
|
||||
typedef void (*NVNT_nvnSamplerBuilderSetWrapMode)(NVNsamplerBuilder*, NVNwrapMode, NVNwrapMode, NVNwrapMode);
|
||||
typedef void (*NVNT_nvnSamplerBuilderSetLodClamp)(NVNsamplerBuilder*, float, float);
|
||||
typedef void (*NVNT_nvnSamplerBuilderSetLodBias)(NVNsamplerBuilder*, float);
|
||||
typedef void (*NVNT_nvnSamplerBuilderSetCompare)(NVNsamplerBuilder*, NVNcompareMode, NVNcompareFunc);
|
||||
typedef void (*NVNT_nvnSamplerBuilderSetBorderColor)(NVNsamplerBuilder*, const float*);
|
||||
typedef void (*NVNT_nvnSamplerBuilderSetBorderColori)(NVNsamplerBuilder*, const int*);
|
||||
typedef void (*NVNT_nvnSamplerBuilderSetBorderColorui)(NVNsamplerBuilder*, const uint32_t*);
|
||||
typedef void (*NVNT_nvnSamplerBuilderSetMaxAnisotropy)(NVNsamplerBuilder*, float);
|
||||
typedef void (*NVNT_nvnSamplerBuilderSetReductionFilter)(NVNsamplerBuilder*, NVNsamplerReduction);
|
||||
typedef void (*NVNT_nvnSamplerBuilderSetLodSnap)(NVNsamplerBuilder*, float);
|
||||
typedef void (*NVNT_nvnSamplerBuilderGetMinMagFilter)(const NVNsamplerBuilder*, NVNminFilter*, NVNmagFilter*);
|
||||
typedef void (*NVNT_nvnSamplerBuilderGetWrapMode)(const NVNsamplerBuilder*, NVNwrapMode*, NVNwrapMode*, NVNwrapMode*);
|
||||
typedef void (*NVNT_nvnSamplerBuilderGetLodClamp)(const NVNsamplerBuilder*, float*, float*);
|
||||
typedef float (*NVNT_nvnSamplerBuilderGetLodBias)(const NVNsamplerBuilder*);
|
||||
typedef void (*NVNT_nvnSamplerBuilderGetCompare)(const NVNsamplerBuilder*, NVNcompareMode*, NVNcompareFunc*);
|
||||
typedef void (*NVNT_nvnSamplerBuilderGetBorderColor)(const NVNsamplerBuilder*, float*);
|
||||
typedef void (*NVNT_nvnSamplerBuilderGetBorderColori)(const NVNsamplerBuilder*, int*);
|
||||
typedef void (*NVNT_nvnSamplerBuilderGetBorderColorui)(const NVNsamplerBuilder*, uint32_t*);
|
||||
typedef float (*NVNT_nvnSamplerBuilderGetMaxAnisotropy)(const NVNsamplerBuilder*);
|
||||
typedef NVNsamplerReduction (*NVNT_nvnSamplerBuilderGetReductionFilter)(const NVNsamplerBuilder*);
|
||||
typedef float (*NVNT_nvnSamplerBuilderGetLodSnap)(const NVNsamplerBuilder*);
|
||||
typedef NVNboolean (*NVNT_nvnSamplerInitialize)(NVNsampler*, const NVNsamplerBuilder*);
|
||||
typedef void (*NVNT_nvnSamplerFinalize)(NVNsampler*);
|
||||
typedef void (*NVNT_nvnSamplerSetDebugLabel)(NVNsampler*, const char*);
|
||||
typedef void (*NVNT_nvnSamplerGetMinMagFilter)(const NVNsampler*, NVNminFilter*, NVNmagFilter*);
|
||||
typedef void (*NVNT_nvnSamplerGetWrapMode)(const NVNsampler*, NVNwrapMode*, NVNwrapMode*, NVNwrapMode*);
|
||||
typedef void (*NVNT_nvnSamplerGetLodClamp)(const NVNsampler*, float*, float*);
|
||||
typedef float (*NVNT_nvnSamplerGetLodBias)(const NVNsampler*);
|
||||
typedef void (*NVNT_nvnSamplerGetCompare)(const NVNsampler*, NVNcompareMode*, NVNcompareFunc*);
|
||||
typedef void (*NVNT_nvnSamplerGetBorderColor)(const NVNsampler*, float*);
|
||||
typedef void (*NVNT_nvnSamplerGetBorderColori)(const NVNsampler*, int*);
|
||||
typedef void (*NVNT_nvnSamplerGetBorderColorui)(const NVNsampler*, uint32_t*);
|
||||
typedef float (*NVNT_nvnSamplerGetMaxAnisotropy)(const NVNsampler*);
|
||||
typedef NVNsamplerReduction (*NVNT_nvnSamplerGetReductionFilter)(const NVNsampler*);
|
||||
typedef NVNboolean (*NVNT_nvnSamplerCompare)(const NVNsampler*, const NVNsampler*);
|
||||
typedef uint64_t (*NVNT_nvnSamplerGetDebugID)(const NVNsampler*);
|
||||
typedef void (*NVNT_nvnBlendStateSetDefaults)(NVNblendState*);
|
||||
typedef void (*NVNT_nvnBlendStateSetBlendTarget)(NVNblendState*, int);
|
||||
typedef void (*NVNT_nvnBlendStateSetBlendFunc)(NVNblendState*, NVNblendFunc, NVNblendFunc, NVNblendFunc, NVNblendFunc);
|
||||
typedef void (*NVNT_nvnBlendStateSetBlendEquation)(NVNblendState*, NVNblendEquation, NVNblendEquation);
|
||||
typedef void (*NVNT_nvnBlendStateSetAdvancedMode)(NVNblendState*, NVNblendAdvancedMode);
|
||||
typedef void (*NVNT_nvnBlendStateSetAdvancedOverlap)(NVNblendState*, NVNblendAdvancedOverlap);
|
||||
typedef void (*NVNT_nvnBlendStateSetAdvancedPremultipliedSrc)(NVNblendState*, uint32_t);
|
||||
typedef void (*NVNT_nvnBlendStateSetAdvancedNormalizedDst)(NVNblendState*, uint32_t);
|
||||
typedef int (*NVNT_nvnBlendStateGetBlendTarget)(const NVNblendState*);
|
||||
typedef void (*NVNT_nvnBlendStateGetBlendFunc)(const NVNblendState*, NVNblendFunc*, NVNblendFunc*, NVNblendFunc*, NVNblendFunc*);
|
||||
typedef void (*NVNT_nvnBlendStateGetBlendEquation)(const NVNblendState*, NVNblendEquation*, NVNblendEquation*);
|
||||
typedef NVNblendAdvancedMode (*NVNT_nvnBlendStateGetAdvancedMode)(const NVNblendState*);
|
||||
typedef NVNblendAdvancedOverlap (*NVNT_nvnBlendStateGetAdvancedOverlap)(const NVNblendState*);
|
||||
typedef NVNboolean (*NVNT_nvnBlendStateGetAdvancedPremultipliedSrc)(const NVNblendState*);
|
||||
typedef NVNboolean (*NVNT_nvnBlendStateGetAdvancedNormalizedDst)(const NVNblendState*);
|
||||
typedef void (*NVNT_nvnColorStateSetDefaults)(NVNcolorState*);
|
||||
typedef void (*NVNT_nvnColorStateSetBlendEnable)(NVNcolorState*, int, uint32_t);
|
||||
typedef void (*NVNT_nvnColorStateSetLogicOp)(NVNcolorState*, NVNlogicOp);
|
||||
typedef void (*NVNT_nvnColorStateSetAlphaTest)(NVNcolorState*, NVNalphaFunc);
|
||||
typedef NVNboolean (*NVNT_nvnColorStateGetBlendEnable)(const NVNcolorState*, int);
|
||||
typedef NVNlogicOp (*NVNT_nvnColorStateGetLogicOp)(const NVNcolorState*);
|
||||
typedef NVNalphaFunc (*NVNT_nvnColorStateGetAlphaTest)(const NVNcolorState*);
|
||||
typedef void (*NVNT_nvnChannelMaskStateSetDefaults)(NVNchannelMaskState*);
|
||||
typedef void (*NVNT_nvnChannelMaskStateSetChannelMask)(NVNchannelMaskState*, int, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
typedef void (*NVNT_nvnChannelMaskStateGetChannelMask)(const NVNchannelMaskState*, int, NVNboolean*, NVNboolean*, NVNboolean*, NVNboolean*);
|
||||
typedef void (*NVNT_nvnMultisampleStateSetDefaults)(NVNmultisampleState*);
|
||||
typedef void (*NVNT_nvnMultisampleStateSetMultisampleEnable)(NVNmultisampleState*, uint32_t);
|
||||
typedef void (*NVNT_nvnMultisampleStateSetSamples)(NVNmultisampleState*, int);
|
||||
typedef void (*NVNT_nvnMultisampleStateSetAlphaToCoverageEnable)(NVNmultisampleState*, uint32_t);
|
||||
typedef void (*NVNT_nvnMultisampleStateSetAlphaToCoverageDither)(NVNmultisampleState*, uint32_t);
|
||||
typedef NVNboolean (*NVNT_nvnMultisampleStateGetMultisampleEnable)(const NVNmultisampleState*);
|
||||
typedef int (*NVNT_nvnMultisampleStateGetSamples)(const NVNmultisampleState*);
|
||||
typedef NVNboolean (*NVNT_nvnMultisampleStateGetAlphaToCoverageEnable)(const NVNmultisampleState*);
|
||||
typedef NVNboolean (*NVNT_nvnMultisampleStateGetAlphaToCoverageDither)(const NVNmultisampleState*);
|
||||
typedef void (*NVNT_nvnMultisampleStateSetRasterSamples)(NVNmultisampleState*, int);
|
||||
typedef int (*NVNT_nvnMultisampleStateGetRasterSamples)(NVNmultisampleState*);
|
||||
typedef void (*NVNT_nvnMultisampleStateSetCoverageModulationMode)(NVNmultisampleState*, NVNcoverageModulationMode);
|
||||
typedef NVNcoverageModulationMode (*NVNT_nvnMultisampleStateGetCoverageModulationMode)(const NVNmultisampleState*);
|
||||
typedef void (*NVNT_nvnMultisampleStateSetCoverageToColorEnable)(NVNmultisampleState*, uint32_t);
|
||||
typedef NVNboolean (*NVNT_nvnMultisampleStateGetCoverageToColorEnable)(const NVNmultisampleState*);
|
||||
typedef void (*NVNT_nvnMultisampleStateSetCoverageToColorOutput)(NVNmultisampleState*, int);
|
||||
typedef int (*NVNT_nvnMultisampleStateGetCoverageToColorOutput)(const NVNmultisampleState*);
|
||||
typedef void (*NVNT_nvnMultisampleStateSetSampleLocationsEnable)(NVNmultisampleState*, uint32_t);
|
||||
typedef NVNboolean (*NVNT_nvnMultisampleStateGetSampleLocationsEnable)(const NVNmultisampleState*);
|
||||
typedef void (*NVNT_nvnMultisampleStateGetSampleLocationsGrid)(NVNmultisampleState*, int*, int*);
|
||||
typedef void (*NVNT_nvnMultisampleStateSetSampleLocationsGridEnable)(NVNmultisampleState*, uint32_t);
|
||||
typedef NVNboolean (*NVNT_nvnMultisampleStateGetSampleLocationsGridEnable)(const NVNmultisampleState*);
|
||||
typedef void (*NVNT_nvnMultisampleStateSetSampleLocations)(NVNmultisampleState*, int, int, const float*);
|
||||
typedef void (*NVNT_nvnPolygonStateSetDefaults)(NVNpolygonState*);
|
||||
typedef void (*NVNT_nvnPolygonStateSetCullFace)(NVNpolygonState*, NVNface);
|
||||
typedef void (*NVNT_nvnPolygonStateSetFrontFace)(NVNpolygonState*, NVNfrontFace);
|
||||
typedef void (*NVNT_nvnPolygonStateSetPolygonMode)(NVNpolygonState*, NVNpolygonMode);
|
||||
typedef void (*NVNT_nvnPolygonStateSetPolygonOffsetEnables)(NVNpolygonState*, int);
|
||||
typedef NVNface (*NVNT_nvnPolygonStateGetCullFace)(const NVNpolygonState*);
|
||||
typedef NVNfrontFace (*NVNT_nvnPolygonStateGetFrontFace)(const NVNpolygonState*);
|
||||
typedef NVNpolygonMode (*NVNT_nvnPolygonStateGetPolygonMode)(const NVNpolygonState*);
|
||||
typedef NVNpolygonOffsetEnable (*NVNT_nvnPolygonStateGetPolygonOffsetEnables)(const NVNpolygonState*);
|
||||
typedef void (*NVNT_nvnDepthStencilStateSetDefaults)(NVNdepthStencilState*);
|
||||
typedef void (*NVNT_nvnDepthStencilStateSetDepthTestEnable)(NVNdepthStencilState*, uint32_t);
|
||||
typedef void (*NVNT_nvnDepthStencilStateSetDepthWriteEnable)(NVNdepthStencilState*, uint32_t);
|
||||
typedef void (*NVNT_nvnDepthStencilStateSetDepthFunc)(NVNdepthStencilState*, NVNdepthFunc);
|
||||
typedef void (*NVNT_nvnDepthStencilStateSetStencilTestEnable)(NVNdepthStencilState*, uint32_t);
|
||||
typedef void (*NVNT_nvnDepthStencilStateSetStencilFunc)(NVNdepthStencilState*, NVNface, NVNstencilFunc);
|
||||
typedef void (*NVNT_nvnDepthStencilStateSetStencilOp)(NVNdepthStencilState*, NVNface, NVNstencilOp, NVNstencilOp, NVNstencilOp);
|
||||
typedef NVNboolean (*NVNT_nvnDepthStencilStateGetDepthTestEnable)(const NVNdepthStencilState*);
|
||||
typedef NVNboolean (*NVNT_nvnDepthStencilStateGetDepthWriteEnable)(const NVNdepthStencilState*);
|
||||
typedef NVNdepthFunc (*NVNT_nvnDepthStencilStateGetDepthFunc)(const NVNdepthStencilState*);
|
||||
typedef NVNboolean (*NVNT_nvnDepthStencilStateGetStencilTestEnable)(const NVNdepthStencilState*);
|
||||
typedef NVNstencilFunc (*NVNT_nvnDepthStencilStateGetStencilFunc)(const NVNdepthStencilState*, NVNface);
|
||||
typedef void (*NVNT_nvnDepthStencilStateGetStencilOp)(const NVNdepthStencilState*, NVNface, NVNstencilOp*, NVNstencilOp*, NVNstencilOp*);
|
||||
typedef void (*NVNT_nvnVertexAttribStateSetDefaults)(NVNvertexAttribState*);
|
||||
typedef void (*NVNT_nvnVertexAttribStateSetFormat)(NVNvertexAttribState*, NVNformat, ptrdiff_t);
|
||||
typedef void (*NVNT_nvnVertexAttribStateSetStreamIndex)(NVNvertexAttribState*, int);
|
||||
typedef void (*NVNT_nvnVertexAttribStateGetFormat)(const NVNvertexAttribState*, NVNformat*, ptrdiff_t*);
|
||||
typedef int (*NVNT_nvnVertexAttribStateGetStreamIndex)(const NVNvertexAttribState*);
|
||||
typedef void (*NVNT_nvnVertexStreamStateSetDefaults)(NVNvertexStreamState*);
|
||||
typedef void (*NVNT_nvnVertexStreamStateSetStride)(NVNvertexStreamState*, ptrdiff_t);
|
||||
typedef void (*NVNT_nvnVertexStreamStateSetDivisor)(NVNvertexStreamState*, int);
|
||||
typedef ptrdiff_t (*NVNT_nvnVertexStreamStateGetStride)(const NVNvertexStreamState*);
|
||||
typedef int (*NVNT_nvnVertexStreamStateGetDivisor)(const NVNvertexStreamState*);
|
||||
typedef NVNboolean (*NVNT_nvnCommandBufferInitialize)(NVNcommandBuffer*, NVNdevice*);
|
||||
typedef void (*NVNT_nvnCommandBufferFinalize)(NVNcommandBuffer*);
|
||||
typedef void (*NVNT_nvnCommandBufferSetDebugLabel)(NVNcommandBuffer*, const char*);
|
||||
typedef void (*NVNT_nvnCommandBufferSetMemoryCallback)(NVNcommandBuffer*, PFNNVNCOMMANDBUFFERMEMORYCALLBACKPROC);
|
||||
typedef void (*NVNT_nvnCommandBufferSetMemoryCallbackData)(NVNcommandBuffer*, void*);
|
||||
typedef void (*NVNT_nvnCommandBufferAddCommandMemory)(NVNcommandBuffer*, const NVNmemoryPool*, ptrdiff_t, size_t);
|
||||
typedef void (*NVNT_nvnCommandBufferAddControlMemory)(NVNcommandBuffer*, void*, size_t);
|
||||
typedef size_t (*NVNT_nvnCommandBufferGetCommandMemorySize)(const NVNcommandBuffer*);
|
||||
typedef size_t (*NVNT_nvnCommandBufferGetCommandMemoryUsed)(const NVNcommandBuffer*);
|
||||
typedef size_t (*NVNT_nvnCommandBufferGetCommandMemoryFree)(const NVNcommandBuffer*);
|
||||
typedef size_t (*NVNT_nvnCommandBufferGetControlMemorySize)(const NVNcommandBuffer*);
|
||||
typedef size_t (*NVNT_nvnCommandBufferGetControlMemoryUsed)(const NVNcommandBuffer*);
|
||||
typedef size_t (*NVNT_nvnCommandBufferGetControlMemoryFree)(const NVNcommandBuffer*);
|
||||
typedef void (*NVNT_nvnCommandBufferBeginRecording)(NVNcommandBuffer*);
|
||||
typedef NVNcommandHandle (*NVNT_nvnCommandBufferEndRecording)(NVNcommandBuffer*);
|
||||
typedef void (*NVNT_nvnCommandBufferCallCommands)(NVNcommandBuffer*, int, const NVNcommandHandle*);
|
||||
typedef void (*NVNT_nvnCommandBufferCopyCommands)(NVNcommandBuffer*, int, const NVNcommandHandle*);
|
||||
typedef void (*NVNT_nvnCommandBufferBindBlendState)(NVNcommandBuffer*, const NVNblendState*);
|
||||
typedef void (*NVNT_nvnCommandBufferBindChannelMaskState)(NVNcommandBuffer*, const NVNchannelMaskState*);
|
||||
typedef void (*NVNT_nvnCommandBufferBindColorState)(NVNcommandBuffer*, const NVNcolorState*);
|
||||
typedef void (*NVNT_nvnCommandBufferBindMultisampleState)(NVNcommandBuffer*, const NVNmultisampleState*);
|
||||
typedef void (*NVNT_nvnCommandBufferBindPolygonState)(NVNcommandBuffer*, const NVNpolygonState*);
|
||||
typedef void (*NVNT_nvnCommandBufferBindDepthStencilState)(NVNcommandBuffer*, const NVNdepthStencilState*);
|
||||
typedef void (*NVNT_nvnCommandBufferBindVertexAttribState)(NVNcommandBuffer*, int, const NVNvertexAttribState*);
|
||||
typedef void (*NVNT_nvnCommandBufferBindVertexStreamState)(NVNcommandBuffer*, int, const NVNvertexStreamState*);
|
||||
typedef void (*NVNT_nvnCommandBufferBindProgram)(NVNcommandBuffer*, const NVNprogram*, int);
|
||||
typedef void (*NVNT_nvnCommandBufferBindVertexBuffer)(NVNcommandBuffer*, int, NVNbufferAddress, size_t);
|
||||
typedef void (*NVNT_nvnCommandBufferBindVertexBuffers)(NVNcommandBuffer*, int, int, const NVNbufferRange*);
|
||||
typedef void (*NVNT_nvnCommandBufferBindUniformBuffer)(NVNcommandBuffer*, NVNshaderStage, int, NVNbufferAddress, size_t);
|
||||
typedef void (*NVNT_nvnCommandBufferBindUniformBuffers)(NVNcommandBuffer*, NVNshaderStage, int, int, const NVNbufferRange*);
|
||||
typedef void (*NVNT_nvnCommandBufferBindTransformFeedbackBuffer)(NVNcommandBuffer*, int, NVNbufferAddress, size_t);
|
||||
typedef void (*NVNT_nvnCommandBufferBindTransformFeedbackBuffers)(NVNcommandBuffer*, int, int, const NVNbufferRange*);
|
||||
typedef void (*NVNT_nvnCommandBufferBindStorageBuffer)(NVNcommandBuffer*, NVNshaderStage, int, NVNbufferAddress, size_t);
|
||||
typedef void (*NVNT_nvnCommandBufferBindStorageBuffers)(NVNcommandBuffer*, NVNshaderStage, int, int, const NVNbufferRange*);
|
||||
typedef void (*NVNT_nvnCommandBufferBindTexture)(NVNcommandBuffer*, NVNshaderStage, int, NVNtextureHandle);
|
||||
typedef void (*NVNT_nvnCommandBufferBindTextures)(NVNcommandBuffer*, NVNshaderStage, int, int, const NVNtextureHandle*);
|
||||
typedef void (*NVNT_nvnCommandBufferBindImage)(NVNcommandBuffer*, NVNshaderStage, int, NVNimageHandle);
|
||||
typedef void (*NVNT_nvnCommandBufferBindImages)(NVNcommandBuffer*, NVNshaderStage, int, int, const NVNimageHandle*);
|
||||
typedef void (*NVNT_nvnCommandBufferSetPatchSize)(NVNcommandBuffer*, int);
|
||||
typedef void (*NVNT_nvnCommandBufferSetInnerTessellationLevels)(NVNcommandBuffer*, const float*);
|
||||
typedef void (*NVNT_nvnCommandBufferSetOuterTessellationLevels)(NVNcommandBuffer*, const float*);
|
||||
typedef void (*NVNT_nvnCommandBufferSetPrimitiveRestart)(NVNcommandBuffer*, uint32_t, int);
|
||||
typedef void (*NVNT_nvnCommandBufferBeginTransformFeedback)(NVNcommandBuffer*, NVNbufferAddress);
|
||||
typedef void (*NVNT_nvnCommandBufferEndTransformFeedback)(NVNcommandBuffer*, NVNbufferAddress);
|
||||
typedef void (*NVNT_nvnCommandBufferPauseTransformFeedback)(NVNcommandBuffer*, NVNbufferAddress);
|
||||
typedef void (*NVNT_nvnCommandBufferResumeTransformFeedback)(NVNcommandBuffer*, NVNbufferAddress);
|
||||
typedef void (*NVNT_nvnCommandBufferDrawTransformFeedback)(NVNcommandBuffer*, NVNdrawPrimitive, NVNbufferAddress);
|
||||
typedef void (*NVNT_nvnCommandBufferDrawArrays)(NVNcommandBuffer*, NVNdrawPrimitive, int, int);
|
||||
typedef void (*NVNT_nvnCommandBufferDrawElements)(NVNcommandBuffer*, NVNdrawPrimitive, NVNindexType, int, NVNbufferAddress);
|
||||
typedef void (*NVNT_nvnCommandBufferDrawElementsBaseVertex)(NVNcommandBuffer*, NVNdrawPrimitive, NVNindexType, int, NVNbufferAddress, int);
|
||||
typedef void (*NVNT_nvnCommandBufferDrawArraysInstanced)(NVNcommandBuffer*, NVNdrawPrimitive, int, int, int, int);
|
||||
typedef void (*NVNT_nvnCommandBufferDrawElementsInstanced)(NVNcommandBuffer*, NVNdrawPrimitive, NVNindexType, int, NVNbufferAddress, int, int, int);
|
||||
typedef void (*NVNT_nvnCommandBufferDrawArraysIndirect)(NVNcommandBuffer*, NVNdrawPrimitive, NVNbufferAddress);
|
||||
typedef void (*NVNT_nvnCommandBufferDrawElementsIndirect)(NVNcommandBuffer*, NVNdrawPrimitive, NVNindexType, NVNbufferAddress, NVNbufferAddress);
|
||||
typedef void (*NVNT_nvnCommandBufferMultiDrawArraysIndirectCount)(NVNcommandBuffer*, NVNdrawPrimitive, NVNbufferAddress, NVNbufferAddress, int, ptrdiff_t);
|
||||
typedef void (*NVNT_nvnCommandBufferMultiDrawElementsIndirectCount)(NVNcommandBuffer*, NVNdrawPrimitive, NVNindexType, NVNbufferAddress, NVNbufferAddress, NVNbufferAddress, int, ptrdiff_t);
|
||||
typedef void (*NVNT_nvnCommandBufferClearColor)(NVNcommandBuffer*, int, const float*, int);
|
||||
typedef void (*NVNT_nvnCommandBufferClearColori)(NVNcommandBuffer*, int, const int*, int);
|
||||
typedef void (*NVNT_nvnCommandBufferClearColorui)(NVNcommandBuffer*, int, const uint32_t*, int);
|
||||
typedef void (*NVNT_nvnCommandBufferClearDepthStencil)(NVNcommandBuffer*, float, uint32_t, int, int);
|
||||
typedef void (*NVNT_nvnCommandBufferDispatchCompute)(NVNcommandBuffer*, int, int, int);
|
||||
typedef void (*NVNT_nvnCommandBufferDispatchComputeIndirect)(NVNcommandBuffer*, NVNbufferAddress);
|
||||
typedef void (*NVNT_nvnCommandBufferSetViewport)(NVNcommandBuffer*, int, int, int, int);
|
||||
typedef void (*NVNT_nvnCommandBufferSetViewports)(NVNcommandBuffer*, int, int, const float*);
|
||||
typedef void (*NVNT_nvnCommandBufferSetViewportSwizzles)(NVNcommandBuffer*, int, int, const NVNviewportSwizzle*);
|
||||
typedef void (*NVNT_nvnCommandBufferSetScissor)(NVNcommandBuffer*, int, int, int, int);
|
||||
typedef void (*NVNT_nvnCommandBufferSetScissors)(NVNcommandBuffer*, int, int, const int*);
|
||||
typedef void (*NVNT_nvnCommandBufferSetDepthRange)(NVNcommandBuffer*, float, float);
|
||||
typedef void (*NVNT_nvnCommandBufferSetDepthBounds)(NVNcommandBuffer*, uint32_t, float, float);
|
||||
typedef void (*NVNT_nvnCommandBufferSetDepthRanges)(NVNcommandBuffer*, int, int, const float*);
|
||||
typedef void (*NVNT_nvnCommandBufferSetTiledCacheAction)(NVNcommandBuffer*, NVNtiledCacheAction);
|
||||
typedef void (*NVNT_nvnCommandBufferSetTiledCacheTileSize)(NVNcommandBuffer*, int, int);
|
||||
typedef void (*NVNT_nvnCommandBufferBindSeparateTexture)(NVNcommandBuffer*, NVNshaderStage, int, NVNseparateTextureHandle);
|
||||
typedef void (*NVNT_nvnCommandBufferBindSeparateSampler)(NVNcommandBuffer*, NVNshaderStage, int, NVNseparateSamplerHandle);
|
||||
typedef void (*NVNT_nvnCommandBufferBindSeparateTextures)(NVNcommandBuffer*, NVNshaderStage, int, int, const NVNseparateTextureHandle*);
|
||||
typedef void (*NVNT_nvnCommandBufferBindSeparateSamplers)(NVNcommandBuffer*, NVNshaderStage, int, int, const NVNseparateSamplerHandle*);
|
||||
typedef void (*NVNT_nvnCommandBufferSetStencilValueMask)(NVNcommandBuffer*, NVNface, int);
|
||||
typedef void (*NVNT_nvnCommandBufferSetStencilMask)(NVNcommandBuffer*, NVNface, int);
|
||||
typedef void (*NVNT_nvnCommandBufferSetStencilRef)(NVNcommandBuffer*, NVNface, int);
|
||||
typedef void (*NVNT_nvnCommandBufferSetBlendColor)(NVNcommandBuffer*, const float*);
|
||||
typedef void (*NVNT_nvnCommandBufferSetPointSize)(NVNcommandBuffer*, float);
|
||||
typedef void (*NVNT_nvnCommandBufferSetLineWidth)(NVNcommandBuffer*, float);
|
||||
typedef void (*NVNT_nvnCommandBufferSetPolygonOffsetClamp)(NVNcommandBuffer*, float, float, float);
|
||||
typedef void (*NVNT_nvnCommandBufferSetAlphaRef)(NVNcommandBuffer*, float);
|
||||
typedef void (*NVNT_nvnCommandBufferSetSampleMask)(NVNcommandBuffer*, int);
|
||||
typedef void (*NVNT_nvnCommandBufferSetRasterizerDiscard)(NVNcommandBuffer*, uint32_t);
|
||||
typedef void (*NVNT_nvnCommandBufferSetDepthClamp)(NVNcommandBuffer*, uint32_t);
|
||||
typedef void (*NVNT_nvnCommandBufferSetConservativeRasterEnable)(NVNcommandBuffer*, uint32_t);
|
||||
typedef void (*NVNT_nvnCommandBufferSetConservativeRasterDilate)(NVNcommandBuffer*, float);
|
||||
typedef void (*NVNT_nvnCommandBufferSetSubpixelPrecisionBias)(NVNcommandBuffer*, int, int);
|
||||
typedef void (*NVNT_nvnCommandBufferCopyBufferToTexture)(NVNcommandBuffer*, NVNbufferAddress, const NVNtexture*, const NVNtextureView*, const NVNcopyRegion*, int);
|
||||
typedef void (*NVNT_nvnCommandBufferCopyTextureToBuffer)(NVNcommandBuffer*, const NVNtexture*, const NVNtextureView*, const NVNcopyRegion*, NVNbufferAddress, int);
|
||||
typedef void (*NVNT_nvnCommandBufferCopyTextureToTexture)(NVNcommandBuffer*, const NVNtexture*, const NVNtextureView*, const NVNcopyRegion*, const NVNtexture*, const NVNtextureView*, const NVNcopyRegion*, int);
|
||||
typedef void (*NVNT_nvnCommandBufferCopyBufferToBuffer)(NVNcommandBuffer*, NVNbufferAddress, NVNbufferAddress, size_t, int);
|
||||
typedef void (*NVNT_nvnCommandBufferClearBuffer)(NVNcommandBuffer*, NVNbufferAddress, size_t, uint32_t);
|
||||
typedef void (*NVNT_nvnCommandBufferClearTexture)(NVNcommandBuffer*, const NVNtexture*, const NVNtextureView*, const NVNcopyRegion*, const float*, int);
|
||||
typedef void (*NVNT_nvnCommandBufferClearTexturei)(NVNcommandBuffer*, const NVNtexture*, const NVNtextureView*, const NVNcopyRegion*, const int*, int);
|
||||
typedef void (*NVNT_nvnCommandBufferClearTextureui)(NVNcommandBuffer*, const NVNtexture*, const NVNtextureView*, const NVNcopyRegion*, const uint32_t*, int);
|
||||
typedef void (*NVNT_nvnCommandBufferUpdateUniformBuffer)(NVNcommandBuffer*, NVNbufferAddress, size_t, ptrdiff_t, size_t, const void*);
|
||||
typedef void (*NVNT_nvnCommandBufferReportCounter)(NVNcommandBuffer*, NVNcounterType, NVNbufferAddress);
|
||||
typedef void (*NVNT_nvnCommandBufferResetCounter)(NVNcommandBuffer*, NVNcounterType);
|
||||
typedef void (*NVNT_nvnCommandBufferReportValue)(NVNcommandBuffer*, uint32_t, NVNbufferAddress);
|
||||
typedef void (*NVNT_nvnCommandBufferSetRenderEnable)(NVNcommandBuffer*, uint32_t);
|
||||
typedef void (*NVNT_nvnCommandBufferSetRenderEnableConditional)(NVNcommandBuffer*, NVNconditionalRenderMode, NVNbufferAddress);
|
||||
typedef void (*NVNT_nvnCommandBufferSetRenderTargets)(NVNcommandBuffer*, int, const NVNtexture* const*, const NVNtextureView* const*, const NVNtexture*, const NVNtextureView*);
|
||||
typedef void (*NVNT_nvnCommandBufferDiscardColor)(NVNcommandBuffer*, int);
|
||||
typedef void (*NVNT_nvnCommandBufferDiscardDepthStencil)(NVNcommandBuffer*);
|
||||
typedef void (*NVNT_nvnCommandBufferDownsample)(NVNcommandBuffer*, const NVNtexture*, const NVNtexture*);
|
||||
typedef void (*NVNT_nvnCommandBufferTiledDownsample)(NVNcommandBuffer*, const NVNtexture*, const NVNtexture*);
|
||||
typedef void (*NVNT_nvnCommandBufferDownsampleTextureView)(NVNcommandBuffer*, const NVNtexture*, const NVNtextureView*, const NVNtexture*, const NVNtextureView*);
|
||||
typedef void (*NVNT_nvnCommandBufferTiledDownsampleTextureView)(NVNcommandBuffer*, const NVNtexture*, const NVNtextureView*, const NVNtexture*, const NVNtextureView*);
|
||||
typedef void (*NVNT_nvnCommandBufferBarrier)(NVNcommandBuffer*, int);
|
||||
typedef void (*NVNT_nvnCommandBufferWaitSync)(NVNcommandBuffer*, const NVNsync*);
|
||||
typedef void (*NVNT_nvnCommandBufferFenceSync)(NVNcommandBuffer*, NVNsync*, NVNsyncCondition, int);
|
||||
typedef void (*NVNT_nvnCommandBufferSetTexturePool)(NVNcommandBuffer*, const NVNtexturePool*);
|
||||
typedef void (*NVNT_nvnCommandBufferSetSamplerPool)(NVNcommandBuffer*, const NVNsamplerPool*);
|
||||
typedef void (*NVNT_nvnCommandBufferSetShaderScratchMemory)(NVNcommandBuffer*, const NVNmemoryPool*, ptrdiff_t, size_t);
|
||||
typedef void (*NVNT_nvnCommandBufferSaveZCullData)(NVNcommandBuffer*, NVNbufferAddress, size_t);
|
||||
typedef void (*NVNT_nvnCommandBufferRestoreZCullData)(NVNcommandBuffer*, NVNbufferAddress, size_t);
|
||||
typedef void (*NVNT_nvnCommandBufferSetCopyRowStride)(NVNcommandBuffer*, ptrdiff_t);
|
||||
typedef void (*NVNT_nvnCommandBufferSetCopyImageStride)(NVNcommandBuffer*, ptrdiff_t);
|
||||
typedef ptrdiff_t (*NVNT_nvnCommandBufferGetCopyRowStride)(const NVNcommandBuffer*);
|
||||
typedef ptrdiff_t (*NVNT_nvnCommandBufferGetCopyImageStride)(const NVNcommandBuffer*);
|
||||
typedef void (*NVNT_nvnCommandBufferDrawTexture)(NVNcommandBuffer*, NVNtextureHandle, const NVNdrawTextureRegion*, const NVNdrawTextureRegion*);
|
||||
typedef NVNboolean (*NVNT_nvnProgramSetSubroutineLinkage)(NVNprogram*, int, const NVNsubroutineLinkageMapPtr*);
|
||||
typedef void (*NVNT_nvnCommandBufferSetProgramSubroutines)(NVNcommandBuffer*, NVNprogram*, NVNshaderStage, const int, const int, const int*);
|
||||
typedef void (*NVNT_nvnCommandBufferBindCoverageModulationTable)(NVNcommandBuffer*, const float*);
|
||||
typedef void (*NVNT_nvnCommandBufferResolveDepthBuffer)(NVNcommandBuffer*);
|
||||
typedef void (*NVNT_nvnCommandBufferPushDebugGroupStatic)(NVNcommandBuffer*, uint32_t, const char*);
|
||||
typedef void (*NVNT_nvnCommandBufferPushDebugGroupDynamic)(NVNcommandBuffer*, uint32_t, const char*);
|
||||
typedef void (*NVNT_nvnCommandBufferPushDebugGroup)(NVNcommandBuffer*, uint32_t, const char*);
|
||||
typedef void (*NVNT_nvnCommandBufferPopDebugGroup)(NVNcommandBuffer*);
|
||||
typedef void (*NVNT_nvnCommandBufferPopDebugGroupId)(NVNcommandBuffer*, uint32_t);
|
||||
typedef void (*NVNT_nvnCommandBufferInsertDebugMarkerStatic)(NVNcommandBuffer*, uint32_t, const char*);
|
||||
typedef void (*NVNT_nvnCommandBufferInsertDebugMarkerDynamic)(NVNcommandBuffer*, uint32_t, const char*);
|
||||
typedef void (*NVNT_nvnCommandBufferInsertDebugMarker)(NVNcommandBuffer*, const char*);
|
||||
typedef PFNNVNCOMMANDBUFFERMEMORYCALLBACKPROC (*NVNT_nvnCommandBufferGetMemoryCallback)(const NVNcommandBuffer*);
|
||||
typedef void (*NVNT_nvnCommandBufferGetMemoryCallbackData)(const NVNcommandBuffer*);
|
||||
typedef NVNboolean (*NVNT_nvnCommandBufferIsRecording)(const NVNcommandBuffer*);
|
||||
typedef NVNboolean (*NVNT_nvnSyncInitialize)(NVNsync*, NVNdevice*);
|
||||
typedef void (*NVNT_nvnSyncFinalize)(NVNsync*);
|
||||
typedef void (*NVNT_nvnSyncSetDebugLabel)(NVNsync*, const char*);
|
||||
typedef void (*NVNT_nvnQueueFenceSync)(NVNqueue*, NVNsync*, NVNsyncCondition, int);
|
||||
typedef NVNsyncWaitResult (*NVNT_nvnSyncWait)(const NVNsync*, uint64_t);
|
||||
typedef NVNboolean (*NVNT_nvnQueueWaitSync)(NVNqueue*, const NVNsync*);
|
||||
typedef void (*NVNT_nvnEventBuilderSetDefaults)(NVNeventBuilder*);
|
||||
typedef void (*NVNT_nvnEventBuilderSetStorage)(NVNeventBuilder*, const NVNmemoryPool*, int64_t);
|
||||
typedef NVNboolean (*NVNT_nvnEventInitialize)(NVNevent*, const NVNeventBuilder*);
|
||||
typedef void (*NVNT_nvnEventFinalize)(NVNevent*);
|
||||
typedef uint32_t (*NVNT_nvnEventGetValue)(const NVNevent*);
|
||||
typedef void (*NVNT_nvnEventSignal)(NVNevent*, NVNeventSignalMode, uint32_t);
|
||||
typedef void (*NVNT_nvnCommandBufferWaitEvent)(NVNcommandBuffer*, const NVNevent*, NVNeventWaitMode, uint32_t);
|
||||
typedef void (*NVNT_nvnCommandBufferSignalEvent)(NVNcommandBuffer*, const NVNevent*, NVNeventSignalMode, NVNeventSignalLocation, int, uint32_t);
|
||||
|
||||
// 头文件里没有原型的名字(新版接口):只能接记名桩
|
||||
// nvnDeviceBuilderGetFlags
|
||||
// nvnQueueBuilderSetQueuePriority
|
||||
// nvnQueueBuilderGetQueuePriority
|
||||
// nvnQueueBuilderGetDevice
|
||||
// nvnQueueBuilderGetFlags
|
||||
// nvnQueueBuilderGetCommandMemorySize
|
||||
// nvnQueueBuilderGetComputeMemorySize
|
||||
// nvnQueueBuilderGetControlMemorySize
|
||||
// nvnQueueBuilderGetCommandFlushThreshold
|
||||
// nvnQueueBuilderGetMemorySize
|
||||
// nvnQueueBuilderGetMemory
|
||||
// nvnWindowBuilderSetNumActiveTextures
|
||||
// nvnWindowBuilderGetDevice
|
||||
// nvnWindowBuilderGetNumTextures
|
||||
// nvnWindowBuilderGetTexture
|
||||
// nvnWindowBuilderGetNumActiveTextures
|
||||
// nvnWindowSetNumActiveTextures
|
||||
// nvnWindowGetNumActiveTextures
|
||||
// nvnWindowGetNumTextures
|
||||
// nvnProgramSetShadersExt
|
||||
// nvnProgramSetSampleShading
|
||||
// nvnMemoryPoolBuilderGetDevice
|
||||
// nvnBufferBuilderGetDevice
|
||||
// nvnTextureBuilderGetDevice
|
||||
// nvnTextureBuilderGetPackagedTextureLayout
|
||||
// nvnTextureBuilderGetRawStorageClass
|
||||
// nvnTextureGetRawStorageClass
|
||||
// nvnSamplerBuilderGetDevice
|
||||
// nvnCommandBufferSetCommandMemoryCallbackEnabled
|
||||
// nvnCommandBufferSetColorReductionEnable
|
||||
// nvnCommandBufferSetColorReductionThresholds
|
||||
// nvnSyncInitializeFromFencedGLSync
|
||||
// nvnSyncCreateGLSync
|
||||
// nvnEventBuilderGetStorage
|
||||
// nvnEventBuilderGetMemoryPool
|
||||
// nvnEventBuilderGetMemoryOffset
|
||||
// nvnEventGetMemoryPool
|
||||
// nvnEventGetMemoryOffset
|
||||
// nvnCommandBufferSetStencilCullCriteria
|
||||
// nvnCommandBufferInsertCheckpointStatic
|
||||
// nvnCommandBufferInsertCheckpointDynamic
|
||||
// nvnDeviceSetAutomaticCheckpointsEnable
|
||||
// nvnDeviceSetAutomaticCheckpointsSamplingInterval
|
||||
// nvnDeviceSetAutomaticCheckpointsByDebugGroup
|
||||
// nvnDeviceSetCheckpointCallStacksEnable
|
||||
// nvnDeviceSetCheckpointMaxCallStacksDepth
|
||||
// Names with no prototype in the header (newer interface): can only be wired to named stubs
|
||||
// nvnDeviceBuilderGetFlags
|
||||
// nvnQueueBuilderSetQueuePriority
|
||||
// nvnQueueBuilderGetQueuePriority
|
||||
// nvnQueueBuilderGetDevice
|
||||
// nvnQueueBuilderGetFlags
|
||||
// nvnQueueBuilderGetCommandMemorySize
|
||||
// nvnQueueBuilderGetComputeMemorySize
|
||||
// nvnQueueBuilderGetControlMemorySize
|
||||
// nvnQueueBuilderGetCommandFlushThreshold
|
||||
// nvnQueueBuilderGetMemorySize
|
||||
// nvnQueueBuilderGetMemory
|
||||
// nvnWindowBuilderSetNumActiveTextures
|
||||
// nvnWindowBuilderGetDevice
|
||||
// nvnWindowBuilderGetNumTextures
|
||||
// nvnWindowBuilderGetTexture
|
||||
// nvnWindowBuilderGetNumActiveTextures
|
||||
// nvnWindowSetNumActiveTextures
|
||||
// nvnWindowGetNumActiveTextures
|
||||
// nvnWindowGetNumTextures
|
||||
// nvnProgramSetShadersExt
|
||||
// nvnProgramSetSampleShading
|
||||
// nvnMemoryPoolBuilderGetDevice
|
||||
// nvnBufferBuilderGetDevice
|
||||
// nvnTextureBuilderGetDevice
|
||||
// nvnTextureBuilderGetPackagedTextureLayout
|
||||
// nvnTextureBuilderGetRawStorageClass
|
||||
// nvnTextureGetRawStorageClass
|
||||
// nvnSamplerBuilderGetDevice
|
||||
// nvnCommandBufferSetCommandMemoryCallbackEnabled
|
||||
// nvnCommandBufferSetColorReductionEnable
|
||||
// nvnCommandBufferSetColorReductionThresholds
|
||||
// nvnSyncInitializeFromFencedGLSync
|
||||
// nvnSyncCreateGLSync
|
||||
// nvnEventBuilderGetStorage
|
||||
// nvnEventBuilderGetMemoryPool
|
||||
// nvnEventBuilderGetMemoryOffset
|
||||
// nvnEventGetMemoryPool
|
||||
// nvnEventGetMemoryOffset
|
||||
// nvnCommandBufferSetStencilCullCriteria
|
||||
// nvnCommandBufferInsertCheckpointStatic
|
||||
// nvnCommandBufferInsertCheckpointDynamic
|
||||
// nvnDeviceSetAutomaticCheckpointsEnable
|
||||
// nvnDeviceSetAutomaticCheckpointsSamplingInterval
|
||||
// nvnDeviceSetAutomaticCheckpointsByDebugGroup
|
||||
// nvnDeviceSetCheckpointCallStacksEnable
|
||||
// nvnDeviceSetCheckpointMaxCallStacksDepth
|
||||
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "nvn_obj.h"
|
||||
|
||||
typedef struct {
|
||||
const void *vs, *fs; uint32_t cfmt[8], dfmt, sfmt, samples, blend_en, chmask, a2c; blend_st blend[8];
|
||||
va_st attr[16]; vs_st stream[16];
|
||||
uint8_t lmap[8]; const void *fsfn;
|
||||
} pso_key;
|
||||
|
||||
typedef struct {
|
||||
uint8_t kind, fbmask;
|
||||
int8_t fx[32];
|
||||
} pso_fz_desc;
|
||||
|
||||
typedef struct { char vs[24], fs[24]; uint8_t vs_stage, fs_stage, merged, fz; pso_fz_desc fz_desc; pso_key k; } pso_skey;
|
||||
|
||||
static inline void pso_skey_from(const pso_key *k, NvShader *vs, NvShader *fs, int merged, const pso_fz_desc *fz, pso_skey *out) {
|
||||
memset(out, 0, sizeof *out);
|
||||
memcpy(&out->k, k, sizeof out->k);
|
||||
out->k.vs = out->k.fs = out->k.fsfn = NULL;
|
||||
if (vs) { memcpy(out->vs, vs->key, sizeof out->vs); out->vs_stage = (uint8_t)vs->stage; }
|
||||
if (fs) { memcpy(out->fs, fs->key, sizeof out->fs); out->fs_stage = (uint8_t)fs->stage; }
|
||||
out->merged = merged != 0;
|
||||
out->fz = k->fsfn != NULL;
|
||||
if (fz) memcpy(&out->fz_desc, fz, sizeof out->fz_desc);
|
||||
}
|
||||
|
||||
static inline void pso_skey_hex(const pso_skey *key, char *out) {
|
||||
static const char hex[] = "0123456789abcdef";
|
||||
const uint8_t *p = (const uint8_t *)key;
|
||||
for (size_t i = 0; i < sizeof *key; i++) { out[i * 2] = hex[p[i] >> 4]; out[i * 2 + 1] = hex[p[i] & 15]; }
|
||||
out[sizeof *key * 2] = 0;
|
||||
}
|
||||
|
||||
static inline int pso_skey_parse(const char *hex, pso_skey *out) {
|
||||
size_t n = sizeof *out * 2;
|
||||
if (!hex || strlen(hex) != n) return -1;
|
||||
uint8_t *p = (uint8_t *)out;
|
||||
for (size_t i = 0; i < n; i += 2) {
|
||||
int a = hex[i] >= '0' && hex[i] <= '9' ? hex[i] - '0' : hex[i] >= 'a' && hex[i] <= 'f' ? hex[i] - 'a' + 10 : hex[i] >= 'A' && hex[i] <= 'F' ? hex[i] - 'A' + 10 : -1;
|
||||
int b = hex[i + 1] >= '0' && hex[i + 1] <= '9' ? hex[i + 1] - '0' : hex[i + 1] >= 'a' && hex[i + 1] <= 'f' ? hex[i + 1] - 'a' + 10 : hex[i + 1] >= 'A' && hex[i + 1] <= 'F' ? hex[i + 1] - 'A' + 10 : -1;
|
||||
if (a < 0 || b < 0) return -1;
|
||||
p[i / 2] = (uint8_t)(a << 4 | b);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// 着色器反射 json → 定长 C 数组(A:PC 链反射;B:Switch 原版翻译的反射,route = "B",tools/dmsh_build.py 出)。
|
||||
// B 新增种类:SBUFP = 存储缓冲设备指针(NVN 存储缓冲槽);SUPPORT = Ryujinx 辅助常量;C1 = 着色器自带常数段(c[1]);
|
||||
// DRV0 / DRV2 = NVN 驱动常量段 c[0](存储缓冲地址表)/ c[2](贴图与采样器句柄表)
|
||||
// PC 着色器反射 json → 定长 C 数组(取着色器时转一次;每次绘制只遍历数组,不碰 NSDictionary / NSString)。
|
||||
// 单测 tests/t_refl.m 拿真实反射手算期望。
|
||||
// Shader reflection json → fixed-length C arrays (A: PC chain reflection; B: reflection produced by translating the original Switch shaders, route = "B", output of tools/dmsh_build.py).
|
||||
// Kinds added by B: SBUFP = storage buffer device pointer (NVN storage buffer slot); SUPPORT = Ryujinx auxiliary constants; C1 = the shader's own constant segment (c[1]);
|
||||
// DRV0 / DRV2 = NVN driver constant segments c[0] (storage buffer address table) / c[2] (texture and sampler handle table)
|
||||
// PC shader reflection json → fixed-length C arrays (converted once when the shader is fetched; each draw only walks the arrays and does not touch NSDictionary / NSString).
|
||||
// Unit test tests/t_refl.m computes the expectations by hand from real reflection.
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
enum { NVN_RB_CBUF = 1, NVN_RB_SAMP, NVN_RB_TEX, NVN_RB_IMG, NVN_RB_TBUF,
|
||||
NVN_RB_SBUFP, NVN_RB_SUPPORT, NVN_RB_C1, NVN_RB_DRV0, NVN_RB_DRV2, NVN_RB_SAMPT, NVN_RB_UBOP }; // UBOP:计算阶段 uniform 槽 r 的设备指针(Maxwell 计算阶段经 c0 地址表 + 全局内存读 uniform) // SAMPT:采样器取自贴图槽 r 的合并句柄(高位 = 采样器号) // 绑定种类(json 的 type);IMG = 可写贴图(D3D u_r,NVN 图像槽 r);TBUF = 类型化缓冲(D3D t_r Buffer<T>,NVN 贴图槽 r 的缓冲贴图) | UBOP: device pointer of compute-stage uniform slot r (the Maxwell compute stage reads uniforms via the c0 address table + global memory) // SAMPT: the sampler is taken from the combined handle of texture slot r (high bits = sampler ID) // Binding kind (type in the json); IMG = writable texture (D3D u_r, NVN image slot r); TBUF = typed buffer (D3D t_r Buffer<T>, buffer texture in NVN texture slot r)
|
||||
enum { NVN_DPF_FLOAT = 0, NVN_DPF_UINT, NVN_DPF_SINT, NVN_DPF_DEPTH }; // 哑贴图像素类(由 msl_type 定) | Dummy texture pixel class (determined by msl_type)
|
||||
enum { NVN_CT_FLOAT = 0, NVN_CT_UINT, NVN_CT_INT }; // 顶点输入分量类型 | Vertex input component type
|
||||
#define NVN_REFL_MAXB 64
|
||||
#define NVN_REFL_MAXV 32
|
||||
|
||||
typedef struct {
|
||||
uint8_t kind, rw; // rw:存储缓冲 access 为 read_write / write / device | rw: storage buffer access is read_write / write / device
|
||||
uint8_t dtt, dpf; // 贴图槽未绑时的哑贴图:MTLTextureType 数值、像素类 | Dummy texture when the texture slot is unbound: MTLTextureType value, pixel class
|
||||
uint16_t reg, aid; // D3D 寄存器号、参数缓冲内序号 | D3D register number, index within the argument buffer
|
||||
} nvn_rbind;
|
||||
typedef struct {
|
||||
int nb, abi, nv; // 绑定数、参数缓冲槽、顶点输入数 | Binding count, argument buffer slot, vertex input count
|
||||
nvn_rbind b[NVN_REFL_MAXB];
|
||||
struct { uint8_t loc, ct, nvn; } v[NVN_REFL_MAXV]; // loc:Metal 顶点属性槽(DXBC 输入寄存器);nvn:NVN 顶点属性号(HLSL 语义 ATTRn 的 n) | loc: Metal vertex attribute slot (DXBC input register); nvn: NVN vertex attribute number (the n of HLSL semantic ATTRn)
|
||||
uint16_t tg[3]; // 计算线程组大小(无 = 0) | Compute thread group size (none = 0)
|
||||
uint8_t route_b, has_c1; // B 路线;有 c1 常数段 | Route B; has a c1 constant segment
|
||||
uint8_t drv_read[3]; // B:运行时读驱动段 c0 / c2(下标 0、2;出包时由 MSL 静态统计,tools/dmsh_build.py drv_reads) | B: reads driver segments c0 / c2 at runtime (indices 0, 2; gathered statically from the MSL at packaging time, tools/dmsh_build.py drv_reads)
|
||||
uint16_t c1_len; // c1 常数段长度(B;全库 0 / 256 / 512 / 768) | Length of the c1 constant segment (B; 0 / 256 / 512 / 768 across the whole library)
|
||||
// 全覆盖首绘证明用(dmsh_build.py raster_facts;缺字段 = 不可证):顶点——位置 xyz 原样取自属性 pos_attr(-1 = 否),w 为常数 1(pos_w1)或取同属性 .w;
|
||||
// 片元——可能丢弃、写 sample_mask、写出的颜色号位图
|
||||
// For the fully-covering-first-draw proof (dmsh_build.py raster_facts; missing field = not provable): vertex - position xyz taken as-is from attribute pos_attr (-1 = no), w is the constant 1 (pos_w1) or taken from the same attribute's .w;
|
||||
// fragment - may discard, writes sample_mask, bitmap of the color numbers written
|
||||
int8_t pos_attr; uint8_t pos_w1, may_discard, writes_smask, color_mask;
|
||||
// 合并 B 第 2 步(可读 tile 版本 <键>_bf,dmsh_fetch.py):片元——可改采样 nfc 次(第 i 次:贴图槽 fc_reg、插值输出 fc_locn)、
|
||||
// 混用的贴图槽位图 fc_mixed(这些槽不得改读 tile)、输出 nfo 个(各自的颜色号 fo_color);顶点——插值输出 locn 的 .xy 原样取自属性 uv_attr[locn](-1 = 否)
|
||||
// Merge B step 2 (readable-tile version <key>_bf, dmsh_fetch.py): fragment - nfc redirectable samples (the i-th: texture slot fc_reg, interpolated output fc_locn),
|
||||
// bitmap fc_mixed of texture slots with mixed use (these slots must not be redirected to read the tile), nfo outputs (each with color number fo_color); vertex - .xy of interpolated output locn is taken as-is from attribute uv_attr[locn] (-1 = no)
|
||||
uint8_t nfc, fc_reg[32], fc_locn[32], nfo, fo_color[4]; uint64_t fc_mixed[2]; int8_t uv_attr[32];
|
||||
// 顶点——插值输出 locn 的 .x / .y = fma(属性 uv_aff_attr[locn] 的 .x / .y, 缩放, 偏移),缩放 / 偏移引用 uniform:(槽 << 8) | (向量 << 2) | 分量
|
||||
// Vertex - .x / .y of interpolated output locn = fma(.x / .y of attribute uv_aff_attr[locn], scale, offset), where scale / offset reference a uniform: (slot << 8) | (vector << 2) | component
|
||||
int8_t uv_aff_attr[32]; uint16_t uv_aff[32][4]; // [sx, ox, sy, oy]
|
||||
uint8_t c1[4096]; // c1 常数段原样(B) | c1 constant segment as-is (B)
|
||||
} nvn_refl;
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Foundation/Foundation.h>
|
||||
// 成功 0;失败返回非 0 并把原因写进 err(未知绑定类型、超定长上限、字段缺失)
|
||||
// 0 on success; on failure returns non-0 and writes the reason into err (unknown binding type, fixed-length limit exceeded, missing field)
|
||||
int nvn_refl_from_json(NSDictionary *j, nvn_refl *out, char *err, int errlen);
|
||||
#endif
|
||||
@@ -0,0 +1,97 @@
|
||||
// 着色器反射 json(B:Switch 原版翻译,tools/dmsh_build.py 出)→ 定长 C 数组(nvn_refl.h)
|
||||
// Shader reflection json (B: produced by translating the original Switch shaders, output of tools/dmsh_build.py) → fixed-length C arrays (nvn_refl.h)
|
||||
#import "nvn_refl.h"
|
||||
#import <Metal/Metal.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
// 哑贴图类型:与原 dummy_tex 同一套前缀判定(未绑贴图槽按 D3D 语义读出 0)
|
||||
// Dummy texture type: same prefix rules as the original dummy_tex (an unbound texture slot reads 0 per D3D semantics)
|
||||
static void dummy_kind(NSString *t, uint8_t *tt, uint8_t *pf) {
|
||||
MTLTextureType y = MTLTextureType2D;
|
||||
if ([t hasPrefix:@"texture2d_array"] || [t hasPrefix:@"depth2d_array"]) y = MTLTextureType2DArray;
|
||||
else if ([t hasPrefix:@"texturecube_array"] || [t hasPrefix:@"depthcube_array"]) y = MTLTextureTypeCubeArray;
|
||||
else if ([t hasPrefix:@"texturecube"] || [t hasPrefix:@"depthcube"]) y = MTLTextureTypeCube;
|
||||
else if ([t hasPrefix:@"texture3d"]) y = MTLTextureType3D;
|
||||
else if ([t hasPrefix:@"texture1d_array"]) y = MTLTextureType1DArray;
|
||||
else if ([t hasPrefix:@"texture1d"]) y = MTLTextureType1D;
|
||||
*tt = (uint8_t)y;
|
||||
*pf = [t hasPrefix:@"depth"] ? NVN_DPF_DEPTH : [t containsString:@"<uint"] ? NVN_DPF_UINT : [t containsString:@"<int"] ? NVN_DPF_SINT : NVN_DPF_FLOAT;
|
||||
}
|
||||
|
||||
int nvn_refl_from_json(NSDictionary *j, nvn_refl *o, char *err, int errlen) {
|
||||
memset(o, 0, sizeof *o);
|
||||
#define FAIL(...) do { snprintf(err, errlen, __VA_ARGS__); return 1; } while (0)
|
||||
if (![j[@"route"] isEqual:@"B"]) FAIL("不是 B 反射(route ≠ B;A 路线 / PC 链反射已退役)");
|
||||
{ // Switch 原版翻译:种类与 NVN 槽号已由 dmsh_build.py 从 MSL 成员名解出 | Translated original Switch shaders: kind and NVN slot number are already parsed from the MSL member names by dmsh_build.py
|
||||
NSArray *bs = j[@"bindings"];
|
||||
if (![bs isKindOfClass:[NSArray class]]) FAIL("缺 bindings");
|
||||
if (bs.count > NVN_REFL_MAXB) FAIL("绑定 %lu 个,超上限 %d", (unsigned long)bs.count, NVN_REFL_MAXB);
|
||||
o->route_b = 1; o->abi = 0; // spirv-cross 第 0 组 → [[buffer(0)]] | spirv-cross set 0 → [[buffer(0)]]
|
||||
for (NSDictionary *b in bs) {
|
||||
NSString *k = b[@"kind"]; nvn_rbind *r = &o->b[o->nb];
|
||||
id rg = b[@"reg"]; int reg = [rg isKindOfClass:[NSNumber class]] ? [rg intValue] : -1, aid = [b[@"arg_id"] intValue];
|
||||
r->aid = (uint16_t)aid; r->reg = reg < 0 ? 0 : (uint16_t)reg;
|
||||
if ([k isEqualToString:@"cbuf"]) r->kind = NVN_RB_CBUF;
|
||||
else if ([k isEqualToString:@"samp"]) r->kind = NVN_RB_SAMP;
|
||||
else if ([k isEqualToString:@"samp_tex"]) r->kind = NVN_RB_SAMPT;
|
||||
else if ([k isEqualToString:@"tex"]) { r->kind = NVN_RB_TEX; dummy_kind(b[@"msl_type"], &r->dtt, &r->dpf); }
|
||||
else if ([k isEqualToString:@"img"]) { r->kind = NVN_RB_IMG; dummy_kind(b[@"msl_type"], &r->dtt, &r->dpf); }
|
||||
else if ([k isEqualToString:@"tbuf"]) { r->kind = NVN_RB_TBUF; uint8_t tt; dummy_kind(b[@"msl_type"], &tt, &r->dpf); }
|
||||
else if ([k isEqualToString:@"sbuf"]) { r->kind = NVN_RB_SBUFP; r->rw = [b[@"rw"] boolValue]; }
|
||||
else if ([k isEqualToString:@"ubo_ptr"]) r->kind = NVN_RB_UBOP;
|
||||
else if ([k isEqualToString:@"support"]) r->kind = NVN_RB_SUPPORT;
|
||||
else if ([k isEqualToString:@"c1"]) r->kind = NVN_RB_C1;
|
||||
else if ([k isEqualToString:@"drvcb"]) r->kind = [b[@"bank"] intValue] == 2 ? NVN_RB_DRV2 : NVN_RB_DRV0;
|
||||
else FAIL("B 绑定种类 %s 未实现(%s)", k.UTF8String, [b[@"msl_name"] UTF8String]);
|
||||
if ((r->kind == NVN_RB_CBUF || r->kind == NVN_RB_SAMP || r->kind == NVN_RB_SAMPT || r->kind == NVN_RB_TEX || r->kind == NVN_RB_IMG || r->kind == NVN_RB_TBUF || r->kind == NVN_RB_SBUFP || r->kind == NVN_RB_UBOP) && reg < 0)
|
||||
FAIL("B 绑定 %s 没解出槽号", [b[@"msl_name"] UTF8String]);
|
||||
o->nb++;
|
||||
}
|
||||
NSDictionary *dr = j[@"drv_reads"];
|
||||
if ([dr isKindOfClass:[NSDictionary class]]) { o->drv_read[0] = dr[@"0"] != nil; o->drv_read[2] = dr[@"2"] != nil; }
|
||||
NSArray *uf = j[@"drv_unfillable"];
|
||||
if ([uf isKindOfClass:[NSArray class]] && uf.count) FAIL("运行时读驱动段的回放层填不了的位置:%s", [[uf componentsJoinedByString:@" "] UTF8String]);
|
||||
NSString *c1 = j[@"c1"];
|
||||
if (c1.length % 2 || c1.length / 2 > sizeof o->c1) FAIL("c1 长 %lu 字节,超上限或不成对", (unsigned long)c1.length / 2);
|
||||
if (c1.length) { o->has_c1 = 1; o->c1_len = (uint16_t)(c1.length / 2); for (unsigned i = 0; i < o->c1_len; i++) o->c1[i] = (uint8_t)strtoul([[c1 substringWithRange:NSMakeRange(2 * i, 2)] UTF8String], NULL, 16); }
|
||||
for (NSDictionary *v in j[@"vertex_inputs"]) { // [[attribute(n)]]:n 即 NVN 顶点属性号 | [[attribute(n)]]: n is the NVN vertex attribute number
|
||||
int loc = [v[@"location"] intValue]; NSString *t = v[@"msl_type"];
|
||||
if (loc < 0 || loc >= NVN_REFL_MAXV || o->nv >= NVN_REFL_MAXV) FAIL("B 顶点输入 %d 越界", loc);
|
||||
o->v[o->nv].loc = o->v[o->nv].nvn = (uint8_t)loc;
|
||||
o->v[o->nv].ct = [t hasPrefix:@"uint"] ? NVN_CT_UINT : [t hasPrefix:@"int"] ? NVN_CT_INT : NVN_CT_FLOAT;
|
||||
o->nv++;
|
||||
}
|
||||
NSDictionary *ra = j[@"raster"];
|
||||
o->pos_attr = -1; o->may_discard = 1; o->writes_smask = 1;
|
||||
if ([ra isKindOfClass:[NSDictionary class]]) {
|
||||
if (ra[@"pos_attr"]) { int pa = [ra[@"pos_attr"] intValue]; o->pos_attr = (int8_t)(pa >= 0 && pa < 16 ? pa : -1); o->pos_w1 = [ra[@"pos_w"] isEqual:@"one"]; }
|
||||
if (ra[@"discard"]) o->may_discard = [ra[@"discard"] intValue] != 0;
|
||||
if (ra[@"sample_mask"]) o->writes_smask = [ra[@"sample_mask"] intValue] != 0;
|
||||
for (NSNumber *c in ra[@"colors"]) if (c.intValue >= 0 && c.intValue < 8) o->color_mask |= (uint8_t)(1u << c.intValue);
|
||||
}
|
||||
memset(o->uv_attr, -1, sizeof o->uv_attr); memset(o->uv_aff_attr, -1, sizeof o->uv_aff_attr);
|
||||
NSDictionary *ua = [ra isKindOfClass:[NSDictionary class]] ? ra[@"uv_affine"] : nil;
|
||||
if ([ua isKindOfClass:[NSDictionary class]]) for (NSString *k in ua) { int l = k.intValue; NSDictionary *e = ua[k]; int a = [e[@"attr"] intValue];
|
||||
if (l < 0 || l >= 32 || a < 0 || a >= 16) continue;
|
||||
NSArray *refs[4] = {e[@"sx"], e[@"ox"], e[@"sy"], e[@"oy"]}; int ok = 1;
|
||||
for (int q = 0; q < 4; q++) { NSArray *r = refs[q]; if (![r isKindOfClass:[NSArray class]] || r.count != 3) { ok = 0; break; }
|
||||
int sl = [r[0] intValue], vec = [r[1] intValue], cmp = [r[2] intValue]; if (sl < 0 || sl > 15 || vec < 0 || vec > 63 || cmp < 0 || cmp > 3) { ok = 0; break; }
|
||||
o->uv_aff[l][q] = (uint16_t)(sl << 8 | vec << 2 | cmp); }
|
||||
if (ok) o->uv_aff_attr[l] = (int8_t)a; }
|
||||
NSDictionary *uv = [ra isKindOfClass:[NSDictionary class]] ? ra[@"uv_from_attr"] : nil;
|
||||
if ([uv isKindOfClass:[NSDictionary class]]) for (NSString *k in uv) { int l = k.intValue, a = [uv[k] intValue]; if (l >= 0 && l < 32 && a >= 0 && a < 16) o->uv_attr[l] = (int8_t)a; }
|
||||
NSDictionary *fe = j[@"fetch"];
|
||||
if ([fe isKindOfClass:[NSDictionary class]]) {
|
||||
for (NSDictionary *c in fe[@"calls"]) { int i = [c[@"fc"] intValue], r = [c[@"tex_reg"] intValue], l = [c[@"varying_locn"] intValue];
|
||||
if (i != o->nfc || i >= 32 || r < 0 || r >= 128 || l < 0 || l >= 32) FAIL("fetch 调用表不连续或越界(第 %d 条)", i);
|
||||
o->fc_reg[o->nfc] = (uint8_t)r; o->fc_locn[o->nfc] = (uint8_t)l; o->nfc++; }
|
||||
for (NSNumber *r in fe[@"mixed_regs"]) if (r.intValue >= 0 && r.intValue < 128) o->fc_mixed[r.intValue >> 6] |= 1ull << (r.intValue & 63);
|
||||
for (NSDictionary *u in fe[@"outputs"]) { if (o->nfo >= 4) FAIL("fetch 输出超过 4 个"); o->fo_color[o->nfo++] = (uint8_t)[u[@"color"] intValue]; }
|
||||
}
|
||||
NSArray *tg = j[@"threadgroup_size"];
|
||||
if ([tg isKindOfClass:[NSArray class]] && tg.count == 3) for (int i = 0; i < 3; i++) o->tg[i] = (uint16_t)[tg[i] intValue];
|
||||
return 0;
|
||||
}
|
||||
#undef FAIL
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
// nvn_rtex.inc —— 运行时外推的着色器(由 nvn_mtl.m 在 rp_end / m4_end / res_add / args_dirty_all / blit 等定义之后 #include)
|
||||
//
|
||||
// int rt_ex_encode(dst_hdr, dst_ds, src_hdr, src_ds, vp_prev[16], vp_cur[16], unit_bits, ui_bits)
|
||||
// 在当前 MTL4 命令缓冲 g_cb 上编一个渲染通道(全屏一个三角形),把上一全画帧的不透明 HDR 与深度按本帧相机外推进 dst_hdr / dst_ds:
|
||||
// 反向映射:目标像素 q → 源像素 p,用源深度做 2 次不动点迭代;M = inv(vp_prev) · vp_cur 在 CPU 上双精度算(1e4 量级平移下单精度逆矩阵会差出 0.01 像素)。
|
||||
// 非洞:五抽头 Catmull-Rom,按 2×2 核心纹素的最小 / 最大值夹住防振铃,再按位移的小数相位补锐化(相位 0.5 最强、整数相位为 0,强度 k = 0.5)。
|
||||
// 洞(源 2×2 核心的模板含 unit_bits | ui_bits:旧单位位置 / 界面挖空):沿 8 个方向每 4 像素往外找第一个非洞、非纯黑的像素(最远 24 步),
|
||||
// 按 1/距离² 加权平均;深度取其中最近那个。洞和屏边新露出(源越界)的像素由片元导出模板 0x80,之后的区域后处理据此重算。
|
||||
// 本帧界面挡住的像素(界面模板趟已写 0x2)按模板测试跳过。
|
||||
// 返回 1 = 编了;0 = 尺寸不齐 / 建不出管线(调用方 rt_copy_prev 先用 rx_setup 预检,建不出就整局退回原画法)。
|
||||
// 调用前后:本函数先 rp_end() 收掉当前渲染通道与拷贝编码器;编完置 args_dirty_all() / g_pso_dirty / g_dss_dirty,游戏下一个绘制按「读入」重开它的通道。
|
||||
// 资源:src_hdr / src_ds 由调用方建并 res_add;src_ds 要能开 X32_Stencil8 视图(建时带 MTLTextureUsagePixelFormatView)。
|
||||
// nvn_rtex.inc - shaders for runtime extrapolation (#included by nvn_mtl.m after the definitions of rp_end / m4_end / res_add / args_dirty_all / blit etc.)
|
||||
// int rt_ex_encode(dst_hdr, dst_ds, src_hdr, src_ds, vp_prev[16], vp_cur[16], unit_bits, ui_bits)
|
||||
// Encodes one render pass (a single fullscreen triangle) on the current MTL4 command buffer g_cb, extrapolating the opaque HDR and depth of the previous fully drawn frame into dst_hdr / dst_ds by this frame's camera:
|
||||
// Backward mapping: destination pixel q → source pixel p, with 2 fixed-point iterations using the source depth; M = inv(vp_prev) · vp_cur is computed on the CPU in double precision (with translations on the order of 1e4 a single-precision inverse matrix would be off by 0.01 pixel).
|
||||
// Non-hole: five-tap Catmull-Rom, clamped to the min / max of the 2×2 core texels against ringing, then sharpening compensation by the fractional phase of the displacement (strongest at phase 0.5, 0 at integer phase, strength k = 0.5).
|
||||
// Hole (the stencil of the source 2×2 core contains unit_bits | ui_bits: old unit position / UI cut-out): along 8 directions search outward every 4 pixels for the first pixel that is neither a hole nor pure black (at most 24 steps),
|
||||
// weighted average by 1/distance²; depth takes the nearest of them. Holes and pixels newly exposed at the screen edge (source out of bounds) get stencil 0x80 exported by the fragment, and the later regional post-processing is recomputed accordingly.
|
||||
// Pixels covered by this frame's UI (the UI stencil pass already wrote 0x2) are skipped by the stencil test.
|
||||
// Returns 1 = encoded; 0 = size mismatch / pipeline cannot be built (the caller rt_copy_prev prechecks with rx_setup first, and if it cannot be built the whole run falls back to the original drawing method).
|
||||
// Before and after the call: this function first calls rp_end() to close the current render pass and copy encoder; after encoding it sets args_dirty_all() / g_pso_dirty / g_dss_dirty, and the game's next draw reopens its pass with 'load'.
|
||||
// Resources: src_hdr / src_ds are created and res_add'ed by the caller; src_ds must be able to open an X32_Stencil8 view (created with MTLTextureUsagePixelFormatView).
|
||||
static id<MTLRenderPipelineState> g_rx_pso1; static MTLPixelFormat g_rx_fmt_c, g_rx_fmt_ds;
|
||||
static id<MTLDepthStencilState> g_rx_dss; static id<MTL4ArgumentTable> g_rx_args;
|
||||
static id<MTLBuffer> g_rx_const[3]; static int g_rx_ci;
|
||||
static id<MTLTexture> g_rx_stv; static __unsafe_unretained id<MTLTexture> g_rx_stv_src;
|
||||
static const char *k_rx_msl =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VO { float4 p [[position]]; };\n"
|
||||
"vertex VO rx_vs(uint id [[vertex_id]]) { float2 uv = float2((id << 1) & 2, id & 2); VO o; o.p = float4(uv * float2(2, -2) + float2(-1, 1), 0, 1); return o; }\n"
|
||||
"struct K { float4x4 M; uint hole; float amount; float2 pad; };\n"
|
||||
"static float4 cr_w(float t) { return float4(((-0.5 * t + 1.0) * t - 0.5) * t, (1.5 * t - 2.5) * t * t + 1.0, ((-1.5 * t + 2.0) * t + 0.5) * t, (0.5 * t - 0.5) * t * t); }\n"
|
||||
"static uint stv(texture2d<uint> s, int2 p) { uint4 v = s.read(uint2(p)); return v.r | v.g; }\n" // X32_Stencil8 视图:模板值在哪个分量随实现,r | g 两处都取(另一处为 0) | X32_Stencil8 view: which component holds the stencil value is implementation-dependent, take both r | g (the other one is 0)
|
||||
"static float zproj(float4x4 M, float2 p, float z, int W, int H) { float4 c = M * float4((p.x + 0.5) / W * 2 - 1, 1 - (p.y + 0.5) / H * 2, z, 1); return c.z / c.w; }\n"
|
||||
"struct O1 { float4 c [[color(0)]]; float d [[depth(any)]]; uint s [[stencil]]; };\n"
|
||||
"fragment O1 rx_fs1(VO in [[stage_in]], texture2d<float> hdr [[texture(0)]], depth2d<float> dep [[texture(1)]], texture2d<uint> stc [[texture(2)]], constant K& k [[buffer(0)]]) {\n"
|
||||
" constexpr sampler ls(filter::linear, address::clamp_to_edge, coord::pixel);\n"
|
||||
" int W = hdr.get_width(), H = hdr.get_height(); int2 hi = int2(W - 1, H - 1);\n"
|
||||
" float2 q = floor(in.p.xy); float2 p = q;\n"
|
||||
" for (int it = 0; it < 2; it++) {\n"
|
||||
" int2 pi = clamp(int2(rint(p)), int2(0), hi); float z = dep.read(uint2(pi));\n"
|
||||
" float4 c = k.M * float4((p.x + 0.5) / W * 2 - 1, 1 - (p.y + 0.5) / H * 2, z, 1);\n"
|
||||
" float2 qq = float2((c.x / c.w + 1) * 0.5 * W - 0.5, (1 - c.y / c.w) * 0.5 * H - 0.5); p += q - qq; }\n"
|
||||
" bool oob = p.x < -0.5 || p.y < -0.5 || p.x > float(hi.x) + 0.5 || p.y > float(hi.y) + 0.5;\n"
|
||||
" p = clamp(p, float2(0), float2(hi));\n"
|
||||
" int2 b0 = clamp(int2(floor(p)), int2(0), hi - 1);\n"
|
||||
" uint s4 = stv(stc, b0) | stv(stc, b0 + int2(1, 0)) | stv(stc, b0 + int2(0, 1)) | stv(stc, b0 + int2(1, 1));\n"
|
||||
" int2 cp = clamp(int2(rint(p)), int2(0), hi);\n"
|
||||
" O1 o; o.s = ((s4 & k.hole) || oob) ? 0x80u : 0u;\n"
|
||||
" if (!(s4 & k.hole)) {\n"
|
||||
" float3 t00 = hdr.read(uint2(b0)).rgb, t10 = hdr.read(uint2(b0 + int2(1, 0))).rgb, t01 = hdr.read(uint2(b0 + int2(0, 1))).rgb, t11 = hdr.read(uint2(b0 + int2(1, 1))).rgb;\n"
|
||||
" float3 lo = min(min(t00, t10), min(t01, t11)), hc = max(max(t00, t10), max(t01, t11)), avg = (t00 + t10 + t01 + t11) * 0.25;\n"
|
||||
" float2 sp = p + 0.5; float2 tp1 = floor(sp - 0.5) + 0.5; float2 f = sp - tp1;\n" // 五抽头 Catmull-Rom(双线性取样合并中间两抽头、丢四角) | Five-tap Catmull-Rom (bilinear sampling merges the two middle taps, the four corners are dropped)
|
||||
" float2 w0 = f * (-0.5 + f * (1.0 - 0.5 * f)), w1 = 1.0 + f * f * (-2.5 + 1.5 * f), w2 = f * (0.5 + f * (2.0 - 1.5 * f)), w3 = f * f * (-0.5 + 0.5 * f);\n"
|
||||
" float2 w12 = w1 + w2, t12 = tp1 + w2 / w12, t0 = tp1 - 1.0, t3 = tp1 + 2.0;\n"
|
||||
" float3 acc = hdr.sample(ls, float2(t12.x, t0.y)).rgb * (w12.x * w0.y) + hdr.sample(ls, float2(t0.x, t12.y)).rgb * (w0.x * w12.y) + hdr.sample(ls, t12).rgb * (w12.x * w12.y)\n"
|
||||
" + hdr.sample(ls, float2(t3.x, t12.y)).rgb * (w3.x * w12.y) + hdr.sample(ls, float2(t12.x, t3.y)).rgb * (w12.x * w3.y);\n"
|
||||
" float wt = w12.x * w0.y + w0.x * w12.y + w12.x * w12.y + w3.x * w12.y + w12.x * w3.y; float3 cr = clamp(acc / wt, lo, hc);\n"
|
||||
" o.c = float4(max(cr + k.amount * (cr - avg), 0.0), 1); o.d = zproj(k.M, p, dep.read(uint2(cp)), W, H); return o; }\n" // 按小数相位补锐化并进同一趟(邻域取 2×2 核心的均值) | Sharpening compensation by fractional phase is folded into the same pass (the neighborhood takes the mean of the 2×2 core)
|
||||
" const int2 dirs[8] = { int2(1, 0), int2(-1, 0), int2(0, 1), int2(0, -1), int2(1, 1), int2(-1, 1), int2(1, -1), int2(-1, -1) };\n"
|
||||
" float3 sum = 0; float wsum = 0; int bestr = 1000; int2 bests = cp;\n"
|
||||
" for (int d = 0; d < 8; d++) for (int r = 1; r <= 24; r++) { int2 s = cp + dirs[d] * (4 * r);\n"
|
||||
" if (s.x < 0 || s.y < 0 || s.x > hi.x || s.y > hi.y) break;\n"
|
||||
" if (stv(stc, s) & k.hole) continue;\n"
|
||||
" float3 v = hdr.read(uint2(s)).rgb; if (max(v.r, max(v.g, v.b)) <= 0) continue;\n"
|
||||
" float w = 1.0 / float(r * r); sum += v * w; wsum += w; if (r < bestr) { bestr = r; bests = s; } break; }\n"
|
||||
" if (wsum > 0) { o.c = float4(sum / wsum, 1); o.d = zproj(k.M, float2(bests), dep.read(uint2(bests)), W, H); return o; }\n"
|
||||
" o.c = float4(hdr.read(uint2(cp)).rgb, 1); o.d = zproj(k.M, p, dep.read(uint2(cp)), W, H); return o;\n"
|
||||
"}\n";
|
||||
static int rx_setup(MTLPixelFormat fc, MTLPixelFormat fds) {
|
||||
if (getenv("DM_RT_TEST_NOPSO")) return 0; // 测试:当作这台设备建不出外推管线(验整局退回原画法) | Test: pretend this device cannot build the extrapolation pipeline (verifies the whole run falls back to the original drawing method)
|
||||
if (g_rx_pso1 && g_rx_fmt_c == fc && g_rx_fmt_ds == fds) return 1;
|
||||
static int failed; if (failed) return 0;
|
||||
NSError *e = nil; id<MTLLibrary> lib = [g_dev newLibraryWithSource:@(k_rx_msl) options:nil error:&e];
|
||||
if (!lib) { MLOG("【红】运行时外推:着色器编译失败 %s", e.localizedDescription.UTF8String); failed = 1; return 0; }
|
||||
MTLRenderPipelineDescriptor *pd = [MTLRenderPipelineDescriptor new]; pd.vertexFunction = [lib newFunctionWithName:@"rx_vs"]; pd.fragmentFunction = [lib newFunctionWithName:@"rx_fs1"];
|
||||
pd.colorAttachments[0].pixelFormat = fc; pd.depthAttachmentPixelFormat = fds;
|
||||
if (fds == MTLPixelFormatDepth32Float_Stencil8) pd.stencilAttachmentPixelFormat = fds;
|
||||
g_rx_pso1 = [g_dev newRenderPipelineStateWithDescriptor:pd error:&e];
|
||||
if (!g_rx_pso1) { MLOG("【红】运行时外推:管线建不出 %s", e.localizedDescription.UTF8String); g_rx_pso1 = nil; failed = 1; return 0; }
|
||||
MTLDepthStencilDescriptor *dd = [MTLDepthStencilDescriptor new]; dd.depthCompareFunction = MTLCompareFunctionAlways; dd.depthWriteEnabled = YES;
|
||||
if (fds == MTLPixelFormatDepth32Float_Stencil8) { MTLStencilDescriptor *sd = [MTLStencilDescriptor new]; sd.stencilCompareFunction = MTLCompareFunctionEqual; sd.readMask = 0x2; sd.writeMask = 0x80; sd.depthStencilPassOperation = MTLStencilOperationReplace; // 洞 / 屏外新进来的像素由片元导出 0x80,后面 LDR 区域据此重算 // 本帧被界面挡住的像素(界面模板趟已写 0x2)不算 | Hole pixels / pixels newly entering from off-screen get 0x80 exported by the fragment, and the later LDR region is recomputed accordingly // Pixels covered by this frame's UI (the UI stencil pass already wrote 0x2) do not count
|
||||
dd.frontFaceStencil = sd; dd.backFaceStencil = sd; }
|
||||
g_rx_dss = [g_dev newDepthStencilStateWithDescriptor:dd];
|
||||
if (!g_rx_args) { MTL4ArgumentTableDescriptor *ad = [MTL4ArgumentTableDescriptor new]; ad.maxTextureBindCount = 3; ad.maxBufferBindCount = 1;
|
||||
g_rx_args = [g_dev newArgumentTableWithDescriptor:ad error:&e];
|
||||
for (int i = 0; i < 3; i++) { g_rx_const[i] = [g_dev newBufferWithLength:256 options:MTLResourceStorageModeShared]; res_add(g_rx_const[i]); } }
|
||||
if (!g_rx_args || !g_rx_dss) { MLOG("【红】运行时外推:参数表 / 深度状态建不出"); g_rx_pso1 = nil; failed = 1; return 0; }
|
||||
g_rx_fmt_c = fc; g_rx_fmt_ds = fds; MLOG("运行时外推:着色器建好(颜色格式 %lu,深度格式 %lu)", (unsigned long)fc, (unsigned long)fds);
|
||||
return 1;
|
||||
}
|
||||
static void rx_inv4(const double *m, double *o) { // 4×4 求逆(伴随矩阵法,双精度) | 4×4 inverse (adjugate method, double precision)
|
||||
double inv[16];
|
||||
inv[0] = m[5]*m[10]*m[15] - m[5]*m[11]*m[14] - m[9]*m[6]*m[15] + m[9]*m[7]*m[14] + m[13]*m[6]*m[11] - m[13]*m[7]*m[10];
|
||||
inv[4] = -m[4]*m[10]*m[15] + m[4]*m[11]*m[14] + m[8]*m[6]*m[15] - m[8]*m[7]*m[14] - m[12]*m[6]*m[11] + m[12]*m[7]*m[10];
|
||||
inv[8] = m[4]*m[9]*m[15] - m[4]*m[11]*m[13] - m[8]*m[5]*m[15] + m[8]*m[7]*m[13] + m[12]*m[5]*m[11] - m[12]*m[7]*m[9];
|
||||
inv[12] = -m[4]*m[9]*m[14] + m[4]*m[10]*m[13] + m[8]*m[5]*m[14] - m[8]*m[6]*m[13] - m[12]*m[5]*m[10] + m[12]*m[6]*m[9];
|
||||
inv[1] = -m[1]*m[10]*m[15] + m[1]*m[11]*m[14] + m[9]*m[2]*m[15] - m[9]*m[3]*m[14] - m[13]*m[2]*m[11] + m[13]*m[3]*m[10];
|
||||
inv[5] = m[0]*m[10]*m[15] - m[0]*m[11]*m[14] - m[8]*m[2]*m[15] + m[8]*m[3]*m[14] + m[12]*m[2]*m[11] - m[12]*m[3]*m[10];
|
||||
inv[9] = -m[0]*m[9]*m[15] + m[0]*m[11]*m[13] + m[8]*m[1]*m[15] - m[8]*m[3]*m[13] - m[12]*m[1]*m[11] + m[12]*m[3]*m[9];
|
||||
inv[13] = m[0]*m[9]*m[14] - m[0]*m[10]*m[13] - m[8]*m[1]*m[14] + m[8]*m[2]*m[13] + m[12]*m[1]*m[10] - m[12]*m[2]*m[9];
|
||||
inv[2] = m[1]*m[6]*m[15] - m[1]*m[7]*m[14] - m[5]*m[2]*m[15] + m[5]*m[3]*m[14] + m[13]*m[2]*m[7] - m[13]*m[3]*m[6];
|
||||
inv[6] = -m[0]*m[6]*m[15] + m[0]*m[7]*m[14] + m[4]*m[2]*m[15] - m[4]*m[3]*m[14] - m[12]*m[2]*m[7] + m[12]*m[3]*m[6];
|
||||
inv[10] = m[0]*m[5]*m[15] - m[0]*m[7]*m[13] - m[4]*m[1]*m[15] + m[4]*m[3]*m[13] + m[12]*m[1]*m[7] - m[12]*m[3]*m[5];
|
||||
inv[14] = -m[0]*m[5]*m[14] + m[0]*m[6]*m[13] + m[4]*m[1]*m[14] - m[4]*m[2]*m[13] - m[12]*m[1]*m[6] + m[12]*m[2]*m[5];
|
||||
inv[3] = -m[1]*m[6]*m[11] + m[1]*m[7]*m[10] + m[5]*m[2]*m[11] - m[5]*m[3]*m[10] - m[9]*m[2]*m[7] + m[9]*m[3]*m[6];
|
||||
inv[7] = m[0]*m[6]*m[11] - m[0]*m[7]*m[10] - m[4]*m[2]*m[11] + m[4]*m[3]*m[10] + m[8]*m[2]*m[7] - m[8]*m[3]*m[6];
|
||||
inv[11] = -m[0]*m[5]*m[11] + m[0]*m[7]*m[9] + m[4]*m[1]*m[11] - m[4]*m[3]*m[9] - m[8]*m[1]*m[7] + m[8]*m[3]*m[5];
|
||||
inv[15] = m[0]*m[5]*m[10] - m[0]*m[6]*m[9] - m[4]*m[1]*m[10] + m[4]*m[2]*m[9] + m[8]*m[1]*m[6] - m[8]*m[2]*m[5];
|
||||
double det = m[0]*inv[0] + m[1]*inv[4] + m[2]*inv[8] + m[3]*inv[12]; det = det != 0 ? 1.0 / det : 0;
|
||||
for (int i = 0; i < 16; i++) o[i] = inv[i] * det;
|
||||
}
|
||||
int rt_ex_encode(id<MTLTexture> dst_hdr, id<MTLTexture> dst_ds, id<MTLTexture> src_hdr, id<MTLTexture> src_ds,
|
||||
const float vp_prev[16], const float vp_cur[16], uint32_t unit_bits, uint32_t ui_bits) {
|
||||
if (!dst_hdr || !dst_ds || !src_hdr || !src_ds || !vp_prev || !vp_cur || !g_cb) return 0;
|
||||
if (src_hdr.width != dst_hdr.width || src_hdr.height != dst_hdr.height || src_ds.width != src_hdr.width || src_ds.height != src_hdr.height
|
||||
|| dst_ds.width != dst_hdr.width || dst_ds.height != dst_hdr.height) return 0; // 换了分辨率(读取画面 / 动态比例):这帧不外推 | Resolution changed (loading screen / dynamic scale): no extrapolation this frame
|
||||
if (!rx_setup(dst_hdr.pixelFormat, dst_ds.pixelFormat)) return 0;
|
||||
if (g_rx_stv_src != src_ds) {
|
||||
if (g_rx_stv) defer_obj_release(g_rx_stv);
|
||||
g_rx_stv = [src_ds newTextureViewWithPixelFormat:MTLPixelFormatX32_Stencil8];
|
||||
if (!g_rx_stv) { static int n; if (!n++) MLOG("【红】运行时外推:开不出模板视图(src_ds 要带 PixelFormatView 用途)"); return 0; }
|
||||
res_add(g_rx_stv); g_rx_stv_src = src_ds;
|
||||
}
|
||||
// 常量:M = inv(vp_prev) · vp_cur(行向量:clip_cur = (ndc_prev, z, 1) · M);Metal 的 float4x4 按列存,行向量矩阵的第 i 行正好当第 i 列 ⇒ 着色器里写 M * v
|
||||
// Constant: M = inv(vp_prev) · vp_cur (row vectors: clip_cur = (ndc_prev, z, 1) · M); Metal's float4x4 is stored by column, and row i of the row-vector matrix serves exactly as column i ⇒ write M * v in the shader
|
||||
double a[16], b[16], ia[16], m[16];
|
||||
for (int i = 0; i < 16; i++) { a[i] = vp_prev[i]; b[i] = vp_cur[i]; }
|
||||
rx_inv4(a, ia);
|
||||
for (int r = 0; r < 4; r++) for (int c = 0; c < 4; c++) { double s = 0; for (int k = 0; k < 4; k++) s += ia[r * 4 + k] * b[k * 4 + c]; m[r * 4 + c] = s; }
|
||||
// 小数相位:世界原点(任一点皆可,正交 + 平移全屏一致)在两帧屏幕上的像素位移 d = 目标 − 源;反向映射的源 = 目标 − d
|
||||
// Fractional phase: pixel displacement on screen between the two frames of the world origin (any point works; orthographic + translation is uniform across the screen), d = destination − source; the source of the backward mapping = destination − d
|
||||
double W = dst_hdr.width, H = dst_hdr.height;
|
||||
double c0x = m[12] / m[15], c0y = m[13] / m[15]; // 源 NDC 原点 (0, 0, 0, 1) 投到本帧 | Source NDC origin (0, 0, 0, 1) projected into this frame
|
||||
double dx = c0x / 2 * W, dy = -c0y / 2 * H, sx = -dx, sy = -dy; // 源相对目标的偏移(像素) | Offset of the source relative to the destination (pixels)
|
||||
double fx = sx - floor(sx), fy = sy - floor(sy), amount = 0.5 * 2 * (fx * (1 - fx) + fy * (1 - fy));
|
||||
float *k = g_rx_const[g_rx_ci].contents;
|
||||
for (int i = 0; i < 16; i++) k[i] = (float)m[i];
|
||||
((uint32_t *)k)[16] = unit_bits | ui_bits; k[17] = (float)amount;
|
||||
id<MTLBuffer> cbuf = g_rx_const[g_rx_ci]; g_rx_ci = (g_rx_ci + 1) % 3;
|
||||
rp_end(); if (g_blit) { enc_b_end(g_blit); g_blit = nil; }
|
||||
// 单趟:外推 + 补洞 + 按小数相位补锐化 → dst_hdr;深度写进 dst_ds;本帧界面挡住的像素按模板跳过(模板不写)
|
||||
// Single pass: extrapolation + hole filling + sharpening compensation by fractional phase → dst_hdr; depth is written into dst_ds; pixels covered by this frame's UI are skipped by stencil (stencil not written)
|
||||
MTL4RenderPassDescriptor *rp = [MTL4RenderPassDescriptor new];
|
||||
rp.colorAttachments[0].texture = dst_hdr; rp.colorAttachments[0].loadAction = MTLLoadActionLoad; rp.colorAttachments[0].storeAction = MTLStoreActionStore;
|
||||
rp.depthAttachment.texture = dst_ds; rp.depthAttachment.loadAction = MTLLoadActionLoad; rp.depthAttachment.storeAction = MTLStoreActionStore;
|
||||
if (dst_ds.pixelFormat == MTLPixelFormatDepth32Float_Stencil8) { rp.stencilAttachment.texture = dst_ds; rp.stencilAttachment.loadAction = MTLLoadActionLoad; rp.stencilAttachment.storeAction = MTLStoreActionStore; }
|
||||
id<MTL4RenderCommandEncoder> en = [g_cb renderCommandEncoderWithDescriptor:rp]; if (!en) return 0;
|
||||
[en barrierAfterQueueStages:MTLStageAll beforeStages:MTLStageAll visibilityOptions:MTL4VisibilityOptionDevice];
|
||||
[en setArgumentTable:g_rx_args atStages:MTLRenderStageFragment];
|
||||
[g_rx_args setTexture:src_hdr.gpuResourceID atIndex:0]; [g_rx_args setTexture:src_ds.gpuResourceID atIndex:1]; [g_rx_args setTexture:g_rx_stv.gpuResourceID atIndex:2];
|
||||
[g_rx_args setAddress:cbuf.gpuAddress atIndex:0];
|
||||
[en setViewport:(MTLViewport){0, 0, W, H, 0, 1}]; [en setRenderPipelineState:g_rx_pso1]; [en setDepthStencilState:g_rx_dss]; [en setStencilReferenceValue:0];
|
||||
[en drawPrimitives:MTLPrimitiveTypeTriangle vertexStart:0 vertexCount:3]; m4_end(en);
|
||||
args_dirty_all(); g_pso_dirty = g_dss_dirty = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 正交相机下两帧之间整幅平移的像素量(取整):目标 = 源 + (dx, dy)
|
||||
// Whole-image translation in pixels between two frames under an orthographic camera (rounded): destination = source + (dx, dy)
|
||||
static void rt_shift_px(const float vp_prev[16], const float vp_cur[16], double W, double H, int *dx, int *dy) {
|
||||
double a[16], b[16], ia[16], m[16];
|
||||
for (int i = 0; i < 16; i++) { a[i] = vp_prev[i]; b[i] = vp_cur[i]; }
|
||||
rx_inv4(a, ia);
|
||||
for (int r = 0; r < 4; r++) for (int c = 0; c < 4; c++) { double s = 0; for (int k = 0; k < 4; k++) s += ia[r * 4 + k] * b[k * 4 + c]; m[r * 4 + c] = s; }
|
||||
*dx = (int)lround(m[12] / m[15] / 2 * W); *dy = (int)lround(-m[13] / m[15] / 2 * H);
|
||||
}
|
||||
@@ -0,0 +1,525 @@
|
||||
# kind: evidence main NVN 取址槽与静态调用点(nvn_slots.py)
|
||||
name slot nuses first_use
|
||||
nvnDeviceBuilderSetDefaults 320e910 1 173cb6c
|
||||
nvnDeviceBuilderSetFlags 320e918 1 173cb7c
|
||||
nvnDeviceBuilderGetFlags 320e920 0 -
|
||||
nvnDeviceInitialize 320e928 1 173cb90
|
||||
nvnDeviceFinalize 320e930 1 173e31c
|
||||
nvnDeviceSetDebugLabel 320e938 0 -
|
||||
nvnDeviceGetProcAddress 320e940 1 173cba4
|
||||
nvnDeviceGetInteger 320e948 2 173cbd8
|
||||
nvnDeviceGetCurrentTimestampInNanoseconds 320e950 0 -
|
||||
nvnDeviceSetIntermediateShaderCache 320e958 0 -
|
||||
nvnDeviceGetTextureHandle 320e960 0 -
|
||||
nvnDeviceGetTexelFetchHandle 320e968 0 -
|
||||
nvnDeviceGetImageHandle 320e970 4 173ceb8
|
||||
nvnDeviceInstallDebugCallback 320e978 1 173cbb8
|
||||
nvnDeviceGenerateDebugDomainId 320e980 0 -
|
||||
nvnDeviceSetWindowOriginMode 320e988 1 173cc04
|
||||
nvnDeviceSetDepthMode 320e990 1 173cc18
|
||||
nvnDeviceRegisterFastClearColor 320e998 0 -
|
||||
nvnDeviceRegisterFastClearColori 320e9a0 0 -
|
||||
nvnDeviceRegisterFastClearColorui 320e9a8 0 -
|
||||
nvnDeviceRegisterFastClearDepth 320e9b0 0 -
|
||||
nvnDeviceGetWindowOriginMode 320e9b8 0 -
|
||||
nvnDeviceGetDepthMode 320e9c0 0 -
|
||||
nvnDeviceGetTimestampInNanoseconds 320e9c8 0 -
|
||||
nvnDeviceApplyDeferredFinalizes 320e9d0 0 -
|
||||
nvnDeviceFinalizeCommandHandle 320e9d8 1 17443fc
|
||||
nvnDeviceWalkDebugDatabase 320e9e0 0 -
|
||||
nvnDeviceGetSeparateTextureHandle 320e9e8 4 173ced0
|
||||
nvnDeviceGetSeparateSamplerHandle 320e9f0 7 173cee8
|
||||
nvnDeviceIsExternalDebuggerAttached 320e9f8 0 -
|
||||
nvnQueueGetError 320ea00 3 1744464
|
||||
nvnQueueGetTotalCommandMemoryUsed 320ea08 0 -
|
||||
nvnQueueGetTotalControlMemoryUsed 320ea10 0 -
|
||||
nvnQueueGetTotalComputeMemoryUsed 320ea18 0 -
|
||||
nvnQueueResetMemoryUsageCounts 320ea20 0 -
|
||||
nvnQueueBuilderSetDevice 320ea28 1 173d3e8
|
||||
nvnQueueBuilderSetDefaults 320ea30 1 173d3c4
|
||||
nvnQueueBuilderSetFlags 320ea38 1 173d3d4
|
||||
nvnQueueBuilderSetCommandMemorySize 320ea40 1 173d410
|
||||
nvnQueueBuilderSetComputeMemorySize 320ea48 1 173d3fc
|
||||
nvnQueueBuilderSetControlMemorySize 320ea50 1 173d424
|
||||
nvnQueueBuilderGetQueueMemorySize 320ea58 1 173d44c
|
||||
nvnQueueBuilderSetQueueMemory 320ea60 1 173d47c
|
||||
nvnQueueBuilderSetCommandFlushThreshold 320ea68 1 173d438
|
||||
nvnQueueBuilderSetQueuePriority 320ea70 0 -
|
||||
nvnQueueBuilderGetQueuePriority 320ea78 0 -
|
||||
nvnQueueBuilderGetDevice 320ea80 0 -
|
||||
nvnQueueBuilderGetFlags 320ea88 0 -
|
||||
nvnQueueBuilderGetCommandMemorySize 320ea90 0 -
|
||||
nvnQueueBuilderGetComputeMemorySize 320ea98 0 -
|
||||
nvnQueueBuilderGetControlMemorySize 320eaa0 0 -
|
||||
nvnQueueBuilderGetCommandFlushThreshold 320eaa8 0 -
|
||||
nvnQueueBuilderGetMemorySize 320eab0 0 -
|
||||
nvnQueueBuilderGetMemory 320eab8 0 -
|
||||
nvnQueueInitialize 320eac0 1 173d494
|
||||
nvnQueueFinalize 320eac8 1 1743ea4
|
||||
nvnQueueSetDebugLabel 320ead0 0 -
|
||||
nvnQueueSubmitCommands 320ead8 1 17443d4
|
||||
nvnQueueFlush 320eae0 1 1744448
|
||||
nvnQueueFinish 320eae8 1 17444e0
|
||||
nvnQueuePresentTexture 320eaf0 1 1744978
|
||||
nvnQueueAcquireTexture 320eaf8 0 -
|
||||
nvnWindowBuilderSetDevice 320eb00 1 17414e8
|
||||
nvnWindowBuilderSetDefaults 320eb08 1 17414fc
|
||||
nvnWindowBuilderSetNativeWindow 320eb10 1 1741514
|
||||
nvnWindowBuilderSetTextures 320eb18 1 1741528
|
||||
nvnWindowBuilderSetPresentInterval 320eb20 1 1741540
|
||||
nvnWindowBuilderSetNumActiveTextures 320eb28 0 -
|
||||
nvnWindowBuilderGetDevice 320eb30 0 -
|
||||
nvnWindowBuilderGetNumTextures 320eb38 0 -
|
||||
nvnWindowBuilderGetTexture 320eb40 0 -
|
||||
nvnWindowBuilderGetNativeWindow 320eb48 0 -
|
||||
nvnWindowBuilderGetPresentInterval 320eb50 0 -
|
||||
nvnWindowBuilderGetNumActiveTextures 320eb58 0 -
|
||||
nvnWindowInitialize 320eb60 1 174154c
|
||||
nvnWindowFinalize 320eb68 1 1742db4
|
||||
nvnWindowSetDebugLabel 320eb70 0 -
|
||||
nvnWindowAcquireTexture 320eb78 1 1743b38
|
||||
nvnWindowGetNativeWindow 320eb80 0 -
|
||||
nvnWindowGetPresentInterval 320eb88 0 -
|
||||
nvnWindowSetPresentInterval 320eb90 1 1743af8
|
||||
nvnWindowSetCrop 320eb98 1 1743ad0
|
||||
nvnWindowGetCrop 320eba0 0 -
|
||||
nvnWindowSetNumActiveTextures 320eba8 0 -
|
||||
nvnWindowGetNumActiveTextures 320ebb0 0 -
|
||||
nvnWindowGetNumTextures 320ebb8 0 -
|
||||
nvnProgramInitialize 320ebc0 7 173f0d8
|
||||
nvnProgramFinalize 320ebc8 7 17403c4
|
||||
nvnProgramSetDebugLabel 320ebd0 0 -
|
||||
nvnProgramSetShaders 320ebd8 7 173f100
|
||||
nvnProgramSetShadersExt 320ebe0 0 -
|
||||
nvnProgramSetSampleShading 320ebe8 0 -
|
||||
nvnMemoryPoolBuilderSetDevice 320ebf0 2 174947c
|
||||
nvnMemoryPoolBuilderSetDefaults 320ebf8 2 174946c
|
||||
nvnMemoryPoolBuilderSetStorage 320ec00 2 1749498
|
||||
nvnMemoryPoolBuilderSetFlags 320ec08 2 17494c4
|
||||
nvnMemoryPoolBuilderGetDevice 320ec10 0 -
|
||||
nvnMemoryPoolBuilderGetMemory 320ec18 0 -
|
||||
nvnMemoryPoolBuilderGetSize 320ec20 0 -
|
||||
nvnMemoryPoolBuilderGetFlags 320ec28 0 -
|
||||
nvnMemoryPoolInitialize 320ec30 2 17494d4
|
||||
nvnMemoryPoolSetDebugLabel 320ec38 0 -
|
||||
nvnMemoryPoolFinalize 320ec40 8 173e088
|
||||
nvnMemoryPoolMap 320ec48 0 -
|
||||
nvnMemoryPoolFlushMappedRange 320ec50 2 173d9a4
|
||||
nvnMemoryPoolInvalidateMappedRange 320ec58 0 -
|
||||
nvnMemoryPoolGetBufferAddress 320ec60 12 173cd40
|
||||
nvnMemoryPoolMapVirtual 320ec68 0 -
|
||||
nvnMemoryPoolGetSize 320ec70 0 -
|
||||
nvnMemoryPoolGetFlags 320ec78 0 -
|
||||
nvnTexturePoolInitialize 320ec80 1 173cdec
|
||||
nvnTexturePoolSetDebugLabel 320ec88 0 -
|
||||
nvnTexturePoolFinalize 320ec90 1 173de88
|
||||
nvnTexturePoolRegisterTexture 320ec98 5 173ec3c
|
||||
nvnTexturePoolRegisterImage 320eca0 0 -
|
||||
nvnTexturePoolGetMemoryPool 320eca8 0 -
|
||||
nvnTexturePoolGetMemoryOffset 320ecb0 0 -
|
||||
nvnTexturePoolGetSize 320ecb8 0 -
|
||||
nvnSamplerPoolInitialize 320ecc0 1 173ce88
|
||||
nvnSamplerPoolSetDebugLabel 320ecc8 0 -
|
||||
nvnSamplerPoolFinalize 320ecd0 1 173de9c
|
||||
nvnSamplerPoolRegisterSampler 320ecd8 1 1740d6c
|
||||
nvnSamplerPoolRegisterSamplerBuilder 320ece0 0 -
|
||||
nvnSamplerPoolGetMemoryPool 320ece8 0 -
|
||||
nvnSamplerPoolGetMemoryOffset 320ecf0 0 -
|
||||
nvnSamplerPoolGetSize 320ecf8 0 -
|
||||
nvnBufferBuilderSetDevice 320ed00 0 -
|
||||
nvnBufferBuilderSetDefaults 320ed08 0 -
|
||||
nvnBufferBuilderSetStorage 320ed10 0 -
|
||||
nvnBufferBuilderGetDevice 320ed18 0 -
|
||||
nvnBufferBuilderGetMemoryPool 320ed20 0 -
|
||||
nvnBufferBuilderGetMemoryOffset 320ed28 0 -
|
||||
nvnBufferBuilderGetSize 320ed30 0 -
|
||||
nvnBufferInitialize 320ed38 0 -
|
||||
nvnBufferSetDebugLabel 320ed40 0 -
|
||||
nvnBufferFinalize 320ed48 0 -
|
||||
nvnBufferMap 320ed50 0 -
|
||||
nvnBufferGetAddress 320ed58 0 -
|
||||
nvnBufferFlushMappedRange 320ed60 0 -
|
||||
nvnBufferInvalidateMappedRange 320ed68 0 -
|
||||
nvnBufferGetMemoryPool 320ed70 0 -
|
||||
nvnBufferGetMemoryOffset 320ed78 0 -
|
||||
nvnBufferGetSize 320ed80 0 -
|
||||
nvnBufferGetDebugID 320ed88 0 -
|
||||
nvnTextureBuilderSetDevice 320ed90 2 173ead8
|
||||
nvnTextureBuilderSetDefaults 320ed98 2 173eaec
|
||||
nvnTextureBuilderSetFlags 320eda0 4 173eb04
|
||||
nvnTextureBuilderSetTarget 320eda8 2 173eb48
|
||||
nvnTextureBuilderSetWidth 320edb0 1 1741be4
|
||||
nvnTextureBuilderSetHeight 320edb8 1 1741c40
|
||||
nvnTextureBuilderSetDepth 320edc0 1 1741c50
|
||||
nvnTextureBuilderSetSize1D 320edc8 1 173eb3c
|
||||
nvnTextureBuilderSetSize2D 320edd0 0 -
|
||||
nvnTextureBuilderSetSize3D 320edd8 0 -
|
||||
nvnTextureBuilderSetLevels 320ede0 1 1741c6c
|
||||
nvnTextureBuilderSetFormat 320ede8 2 173eb24
|
||||
nvnTextureBuilderSetSamples 320edf0 1 1741c98
|
||||
nvnTextureBuilderSetSwizzle 320edf8 0 -
|
||||
nvnTextureBuilderSetDepthStencilMode 320ee00 0 -
|
||||
nvnTextureBuilderGetStorageSize 320ee08 3 1741760
|
||||
nvnTextureBuilderGetStorageAlignment 320ee10 2 1741780
|
||||
nvnTextureBuilderSetStorage 320ee18 3 173eb70
|
||||
nvnTextureBuilderSetPackagedTextureData 320ee20 0 -
|
||||
nvnTextureBuilderSetPackagedTextureLayout 320ee28 1 1741b24
|
||||
nvnTextureBuilderSetStride 320ee30 1 1741b78
|
||||
nvnTextureBuilderSetGLTextureName 320ee38 0 -
|
||||
nvnTextureBuilderGetStorageClass 320ee40 0 -
|
||||
nvnTextureBuilderGetDevice 320ee48 0 -
|
||||
nvnTextureBuilderGetFlags 320ee50 2 1741728
|
||||
nvnTextureBuilderGetTarget 320ee58 0 -
|
||||
nvnTextureBuilderGetWidth 320ee60 0 -
|
||||
nvnTextureBuilderGetHeight 320ee68 0 -
|
||||
nvnTextureBuilderGetDepth 320ee70 0 -
|
||||
nvnTextureBuilderGetLevels 320ee78 0 -
|
||||
nvnTextureBuilderGetFormat 320ee80 0 -
|
||||
nvnTextureBuilderGetSamples 320ee88 0 -
|
||||
nvnTextureBuilderGetSwizzle 320ee90 0 -
|
||||
nvnTextureBuilderGetDepthStencilMode 320ee98 0 -
|
||||
nvnTextureBuilderGetPackagedTextureData 320eea0 0 -
|
||||
nvnTextureBuilderGetPackagedTextureLayout 320eea8 0 -
|
||||
nvnTextureBuilderGetStride 320eeb0 0 -
|
||||
nvnTextureBuilderGetSparseTileLayout 320eeb8 0 -
|
||||
nvnTextureBuilderGetGLTextureName 320eec0 0 -
|
||||
nvnTextureBuilderGetZCullStorageSize 320eec8 0 -
|
||||
nvnTextureBuilderGetMemoryPool 320eed0 0 -
|
||||
nvnTextureBuilderGetMemoryOffset 320eed8 0 -
|
||||
nvnTextureBuilderGetRawStorageClass 320eee0 0 -
|
||||
nvnTextureViewSetDefaults 320eee8 8 174071c
|
||||
nvnTextureViewSetLevels 320eef0 10 1740734
|
||||
nvnTextureViewSetLayers 320eef8 9 1740754
|
||||
nvnTextureViewSetFormat 320ef00 3 1740788
|
||||
nvnTextureViewSetSwizzle 320ef08 0 -
|
||||
nvnTextureViewSetDepthStencilMode 320ef10 0 -
|
||||
nvnTextureViewSetTarget 320ef18 3 17407b0
|
||||
nvnTextureViewGetLevels 320ef20 0 -
|
||||
nvnTextureViewGetLayers 320ef28 2 1745844
|
||||
nvnTextureViewGetFormat 320ef30 0 -
|
||||
nvnTextureViewGetSwizzle 320ef38 0 -
|
||||
nvnTextureViewGetDepthStencilMode 320ef40 0 -
|
||||
nvnTextureViewGetTarget 320ef48 0 -
|
||||
nvnTextureViewCompare 320ef50 0 -
|
||||
nvnTextureInitialize 320ef58 3 173eb84
|
||||
nvnTextureGetZCullStorageSize 320ef60 0 -
|
||||
nvnTextureFinalize 320ef68 4 174214c
|
||||
nvnTextureSetDebugLabel 320ef70 0 -
|
||||
nvnTextureGetStorageClass 320ef78 0 -
|
||||
nvnTextureGetViewOffset 320ef80 2 17433b4
|
||||
nvnTextureGetFlags 320ef88 2 1742ee4
|
||||
nvnTextureGetTarget 320ef90 0 -
|
||||
nvnTextureGetWidth 320ef98 7 174564c
|
||||
nvnTextureGetHeight 320efa0 7 1745668
|
||||
nvnTextureGetDepth 320efa8 7 174567c
|
||||
nvnTextureGetLevels 320efb0 0 -
|
||||
nvnTextureGetFormat 320efb8 0 -
|
||||
nvnTextureGetSamples 320efc0 0 -
|
||||
nvnTextureGetSwizzle 320efc8 0 -
|
||||
nvnTextureGetDepthStencilMode 320efd0 0 -
|
||||
nvnTextureGetStride 320efd8 0 -
|
||||
nvnTextureGetTextureAddress 320efe0 0 -
|
||||
nvnTextureGetSparseTileLayout 320efe8 0 -
|
||||
nvnTextureWriteTexels 320eff0 0 -
|
||||
nvnTextureWriteTexelsStrided 320eff8 0 -
|
||||
nvnTextureReadTexels 320f000 16 1843924
|
||||
nvnTextureReadTexelsStrided 320f008 1 18ca2d8
|
||||
nvnTextureFlushTexels 320f010 0 -
|
||||
nvnTextureInvalidateTexels 320f018 1 1883124
|
||||
nvnTextureGetMemoryPool 320f020 0 -
|
||||
nvnTextureGetMemoryOffset 320f028 0 -
|
||||
nvnTextureGetStorageSize 320f030 3 1743430
|
||||
nvnTextureCompare 320f038 2 18d6fc8
|
||||
nvnTextureGetDebugID 320f040 0 -
|
||||
nvnTextureGetRawStorageClass 320f048 8 174899c
|
||||
nvnSamplerBuilderSetDevice 320f050 1 1740bc8
|
||||
nvnSamplerBuilderSetDefaults 320f058 1 1740be8
|
||||
nvnSamplerBuilderSetMinMagFilter 320f060 2 1740c18
|
||||
nvnSamplerBuilderSetWrapMode 320f068 1 1740c80
|
||||
nvnSamplerBuilderSetLodClamp 320f070 1 1883364
|
||||
nvnSamplerBuilderSetLodBias 320f078 1 1883328
|
||||
nvnSamplerBuilderSetCompare 320f080 1 1740ca4
|
||||
nvnSamplerBuilderSetBorderColor 320f088 2 1740cdc
|
||||
nvnSamplerBuilderSetBorderColori 320f090 0 -
|
||||
nvnSamplerBuilderSetBorderColorui 320f098 0 -
|
||||
nvnSamplerBuilderSetMaxAnisotropy 320f0a0 1 1740c08
|
||||
nvnSamplerBuilderSetReductionFilter 320f0a8 0 -
|
||||
nvnSamplerBuilderSetLodSnap 320f0b0 1 1740cc0
|
||||
nvnSamplerBuilderGetDevice 320f0b8 0 -
|
||||
nvnSamplerBuilderGetMinMagFilter 320f0c0 1 18832ec
|
||||
nvnSamplerBuilderGetWrapMode 320f0c8 3 18ca2d0
|
||||
nvnSamplerBuilderGetLodClamp 320f0d0 0 -
|
||||
nvnSamplerBuilderGetLodBias 320f0d8 0 -
|
||||
nvnSamplerBuilderGetCompare 320f0e0 0 -
|
||||
nvnSamplerBuilderGetBorderColor 320f0e8 0 -
|
||||
nvnSamplerBuilderGetBorderColori 320f0f0 0 -
|
||||
nvnSamplerBuilderGetBorderColorui 320f0f8 0 -
|
||||
nvnSamplerBuilderGetMaxAnisotropy 320f100 0 -
|
||||
nvnSamplerBuilderGetReductionFilter 320f108 0 -
|
||||
nvnSamplerBuilderGetLodSnap 320f110 0 -
|
||||
nvnSamplerInitialize 320f118 1 1740cec
|
||||
nvnSamplerFinalize 320f120 2 1742920
|
||||
nvnSamplerSetDebugLabel 320f128 0 -
|
||||
nvnSamplerGetMinMagFilter 320f130 0 -
|
||||
nvnSamplerGetWrapMode 320f138 0 -
|
||||
nvnSamplerGetLodClamp 320f140 0 -
|
||||
nvnSamplerGetLodBias 320f148 0 -
|
||||
nvnSamplerGetCompare 320f150 0 -
|
||||
nvnSamplerGetBorderColor 320f158 0 -
|
||||
nvnSamplerGetBorderColori 320f160 0 -
|
||||
nvnSamplerGetBorderColorui 320f168 0 -
|
||||
nvnSamplerGetMaxAnisotropy 320f170 0 -
|
||||
nvnSamplerGetReductionFilter 320f178 0 -
|
||||
nvnSamplerCompare 320f180 0 -
|
||||
nvnSamplerGetDebugID 320f188 0 -
|
||||
nvnBlendStateSetDefaults 320f190 1 173fd44
|
||||
nvnBlendStateSetBlendTarget 320f198 1 173fd54
|
||||
nvnBlendStateSetBlendFunc 320f1a0 1 173fd8c
|
||||
nvnBlendStateSetBlendEquation 320f1a8 1 173fdac
|
||||
nvnBlendStateSetAdvancedMode 320f1b0 0 -
|
||||
nvnBlendStateSetAdvancedOverlap 320f1b8 0 -
|
||||
nvnBlendStateSetAdvancedPremultipliedSrc 320f1c0 0 -
|
||||
nvnBlendStateSetAdvancedNormalizedDst 320f1c8 0 -
|
||||
nvnBlendStateGetBlendTarget 320f1d0 0 -
|
||||
nvnBlendStateGetBlendFunc 320f1d8 0 -
|
||||
nvnBlendStateGetBlendEquation 320f1e0 0 -
|
||||
nvnBlendStateGetAdvancedMode 320f1e8 0 -
|
||||
nvnBlendStateGetAdvancedOverlap 320f1f0 0 -
|
||||
nvnBlendStateGetAdvancedPremultipliedSrc 320f1f8 0 -
|
||||
nvnBlendStateGetAdvancedNormalizedDst 320f200 0 -
|
||||
nvnColorStateSetDefaults 320f208 1 173fce4
|
||||
nvnColorStateSetBlendEnable 320f210 1 173fd2c
|
||||
nvnColorStateSetLogicOp 320f218 0 -
|
||||
nvnColorStateSetAlphaTest 320f220 0 -
|
||||
nvnColorStateGetBlendEnable 320f228 0 -
|
||||
nvnColorStateGetLogicOp 320f230 0 -
|
||||
nvnColorStateGetAlphaTest 320f238 0 -
|
||||
nvnChannelMaskStateSetDefaults 320f240 1 173fcf0
|
||||
nvnChannelMaskStateSetChannelMask 320f248 1 173fdc8
|
||||
nvnChannelMaskStateGetChannelMask 320f250 0 -
|
||||
nvnMultisampleStateSetDefaults 320f258 1 1740000
|
||||
nvnMultisampleStateSetMultisampleEnable 320f260 1 1740020
|
||||
nvnMultisampleStateSetSamples 320f268 1 1740044
|
||||
nvnMultisampleStateSetAlphaToCoverageEnable 320f270 1 1740054
|
||||
nvnMultisampleStateSetAlphaToCoverageDither 320f278 0 -
|
||||
nvnMultisampleStateGetMultisampleEnable 320f280 0 -
|
||||
nvnMultisampleStateGetSamples 320f288 0 -
|
||||
nvnMultisampleStateGetAlphaToCoverageEnable 320f290 0 -
|
||||
nvnMultisampleStateGetAlphaToCoverageDither 320f298 0 -
|
||||
nvnMultisampleStateSetRasterSamples 320f2a0 0 -
|
||||
nvnMultisampleStateGetRasterSamples 320f2a8 0 -
|
||||
nvnMultisampleStateSetCoverageModulationMode 320f2b0 0 -
|
||||
nvnMultisampleStateGetCoverageModulationMode 320f2b8 0 -
|
||||
nvnMultisampleStateSetCoverageToColorEnable 320f2c0 0 -
|
||||
nvnMultisampleStateGetCoverageToColorEnable 320f2c8 0 -
|
||||
nvnMultisampleStateSetCoverageToColorOutput 320f2d0 0 -
|
||||
nvnMultisampleStateGetCoverageToColorOutput 320f2d8 0 -
|
||||
nvnMultisampleStateSetSampleLocationsEnable 320f2e0 1 17466d8
|
||||
nvnMultisampleStateGetSampleLocationsEnable 320f2e8 0 -
|
||||
nvnMultisampleStateGetSampleLocationsGrid 320f2f0 0 -
|
||||
nvnMultisampleStateSetSampleLocationsGridEnable 320f2f8 0 -
|
||||
nvnMultisampleStateGetSampleLocationsGridEnable 320f300 0 -
|
||||
nvnMultisampleStateSetSampleLocations 320f308 1 17466c4
|
||||
nvnPolygonStateSetDefaults 320f310 1 173ff54
|
||||
nvnPolygonStateSetCullFace 320f318 1 173ff94
|
||||
nvnPolygonStateSetFrontFace 320f320 1 173ffac
|
||||
nvnPolygonStateSetPolygonMode 320f328 1 173ff70
|
||||
nvnPolygonStateSetPolygonOffsetEnables 320f330 1 173ffc8
|
||||
nvnPolygonStateGetCullFace 320f338 0 -
|
||||
nvnPolygonStateGetFrontFace 320f340 0 -
|
||||
nvnPolygonStateGetPolygonMode 320f348 0 -
|
||||
nvnPolygonStateGetPolygonOffsetEnables 320f350 0 -
|
||||
nvnDepthStencilStateSetDefaults 320f358 1 173fe28
|
||||
nvnDepthStencilStateSetDepthTestEnable 320f360 1 173fe6c
|
||||
nvnDepthStencilStateSetDepthWriteEnable 320f368 1 173fe58
|
||||
nvnDepthStencilStateSetDepthFunc 320f370 1 173fea4
|
||||
nvnDepthStencilStateSetStencilTestEnable 320f378 1 173fe80
|
||||
nvnDepthStencilStateSetStencilFunc 320f380 2 173febc
|
||||
nvnDepthStencilStateSetStencilOp 320f388 2 173ff04
|
||||
nvnDepthStencilStateGetDepthTestEnable 320f390 0 -
|
||||
nvnDepthStencilStateGetDepthWriteEnable 320f398 0 -
|
||||
nvnDepthStencilStateGetDepthFunc 320f3a0 0 -
|
||||
nvnDepthStencilStateGetStencilTestEnable 320f3a8 0 -
|
||||
nvnDepthStencilStateGetStencilFunc 320f3b0 0 -
|
||||
nvnDepthStencilStateGetStencilOp 320f3b8 0 -
|
||||
nvnVertexAttribStateSetDefaults 320f3c0 1 174027c
|
||||
nvnVertexAttribStateSetFormat 320f3c8 1 1740348
|
||||
nvnVertexAttribStateSetStreamIndex 320f3d0 1 174035c
|
||||
nvnVertexAttribStateGetFormat 320f3d8 0 -
|
||||
nvnVertexAttribStateGetStreamIndex 320f3e0 0 -
|
||||
nvnVertexStreamStateSetDefaults 320f3e8 1 1742014
|
||||
nvnVertexStreamStateSetStride 320f3f0 1 1742030
|
||||
nvnVertexStreamStateSetDivisor 320f3f8 1 1742044
|
||||
nvnVertexStreamStateGetStride 320f400 0 -
|
||||
nvnVertexStreamStateGetDivisor 320f408 0 -
|
||||
nvnCommandBufferInitialize 320f410 4 173d4c8
|
||||
nvnCommandBufferFinalize 320f418 7 17423e8
|
||||
nvnCommandBufferSetDebugLabel 320f420 0 -
|
||||
nvnCommandBufferSetMemoryCallback 320f428 3 173ef60
|
||||
nvnCommandBufferSetMemoryCallbackData 320f430 3 173ef78
|
||||
nvnCommandBufferSetCommandMemoryCallbackEnabled 320f438 0 -
|
||||
nvnCommandBufferAddCommandMemory 320f440 2 173d5ac
|
||||
nvnCommandBufferAddControlMemory 320f448 2 173d674
|
||||
nvnCommandBufferGetCommandMemorySize 320f450 0 -
|
||||
nvnCommandBufferGetCommandMemoryUsed 320f458 0 -
|
||||
nvnCommandBufferGetCommandMemoryFree 320f460 0 -
|
||||
nvnCommandBufferGetControlMemorySize 320f468 0 -
|
||||
nvnCommandBufferGetControlMemoryUsed 320f470 0 -
|
||||
nvnCommandBufferGetControlMemoryFree 320f478 0 -
|
||||
nvnCommandBufferBeginRecording 320f480 3 173d684
|
||||
nvnCommandBufferEndRecording 320f488 3 173d6ec
|
||||
nvnCommandBufferCallCommands 320f490 0 -
|
||||
nvnCommandBufferCopyCommands 320f498 1 17e2f88
|
||||
nvnCommandBufferBindBlendState 320f4a0 1 1746618
|
||||
nvnCommandBufferBindChannelMaskState 320f4a8 1 1746644
|
||||
nvnCommandBufferBindColorState 320f4b0 1 174665c
|
||||
nvnCommandBufferBindMultisampleState 320f4b8 2 17466ec
|
||||
nvnCommandBufferBindPolygonState 320f4c0 1 1746674
|
||||
nvnCommandBufferBindDepthStencilState 320f4c8 1 1746578
|
||||
nvnCommandBufferBindVertexAttribState 320f4d0 1 1746740
|
||||
nvnCommandBufferBindVertexStreamState 320f4d8 1 174675c
|
||||
nvnCommandBufferBindProgram 320f4e0 4 174671c
|
||||
nvnCommandBufferBindVertexBuffer 320f4e8 0 -
|
||||
nvnCommandBufferBindVertexBuffers 320f4f0 2 17472a8
|
||||
nvnCommandBufferBindUniformBuffer 320f4f8 9 174690c
|
||||
nvnCommandBufferBindUniformBuffers 320f500 3 1746898
|
||||
nvnCommandBufferBindTransformFeedbackBuffer 320f508 0 -
|
||||
nvnCommandBufferBindTransformFeedbackBuffers 320f510 0 -
|
||||
nvnCommandBufferBindStorageBuffer 320f518 2 174a160
|
||||
nvnCommandBufferBindStorageBuffers 320f520 3 1746868
|
||||
nvnCommandBufferBindTexture 320f528 0 -
|
||||
nvnCommandBufferBindTextures 320f530 0 -
|
||||
nvnCommandBufferBindImage 320f538 0 -
|
||||
nvnCommandBufferBindImages 320f540 3 1746814
|
||||
nvnCommandBufferSetPatchSize 320f548 1 1746780
|
||||
nvnCommandBufferSetInnerTessellationLevels 320f550 0 -
|
||||
nvnCommandBufferSetOuterTessellationLevels 320f558 0 -
|
||||
nvnCommandBufferSetPrimitiveRestart 320f560 0 -
|
||||
nvnCommandBufferBeginTransformFeedback 320f568 0 -
|
||||
nvnCommandBufferEndTransformFeedback 320f570 0 -
|
||||
nvnCommandBufferPauseTransformFeedback 320f578 0 -
|
||||
nvnCommandBufferResumeTransformFeedback 320f580 0 -
|
||||
nvnCommandBufferDrawTransformFeedback 320f588 0 -
|
||||
nvnCommandBufferDrawArrays 320f590 2 17473a0
|
||||
nvnCommandBufferDrawElements 320f598 0 -
|
||||
nvnCommandBufferDrawElementsBaseVertex 320f5a0 0 -
|
||||
nvnCommandBufferDrawArraysInstanced 320f5a8 0 -
|
||||
nvnCommandBufferDrawElementsInstanced 320f5b0 2 17474d4
|
||||
nvnCommandBufferDrawArraysIndirect 320f5b8 0 -
|
||||
nvnCommandBufferDrawElementsIndirect 320f5c0 0 -
|
||||
nvnCommandBufferMultiDrawArraysIndirectCount 320f5c8 2 1747614
|
||||
nvnCommandBufferMultiDrawElementsIndirectCount 320f5d0 2 1747784
|
||||
nvnCommandBufferClearColor 320f5d8 1 1745c98
|
||||
nvnCommandBufferClearColori 320f5e0 0 -
|
||||
nvnCommandBufferClearColorui 320f5e8 0 -
|
||||
nvnCommandBufferClearDepthStencil 320f5f0 1 1745d00
|
||||
nvnCommandBufferDispatchCompute 320f5f8 3 1747f7c
|
||||
nvnCommandBufferDispatchComputeIndirect 320f600 2 174809c
|
||||
nvnCommandBufferSetViewport 320f608 0 -
|
||||
nvnCommandBufferSetViewports 320f610 2 1747894
|
||||
nvnCommandBufferSetViewportSwizzles 320f618 0 -
|
||||
nvnCommandBufferSetScissor 320f620 4 1745c3c
|
||||
nvnCommandBufferSetScissors 320f628 0 -
|
||||
nvnCommandBufferSetDepthRange 320f630 2 17478bc
|
||||
nvnCommandBufferSetDepthBounds 320f638 3 17465ec
|
||||
nvnCommandBufferSetDepthRanges 320f640 0 -
|
||||
nvnCommandBufferSetTiledCacheAction 320f648 0 -
|
||||
nvnCommandBufferSetTiledCacheTileSize 320f650 0 -
|
||||
nvnCommandBufferBindSeparateTexture 320f658 0 -
|
||||
nvnCommandBufferBindSeparateSampler 320f660 4 1746464
|
||||
nvnCommandBufferBindSeparateTextures 320f668 3 1746880
|
||||
nvnCommandBufferBindSeparateSamplers 320f670 2 17468b0
|
||||
nvnCommandBufferSetStencilValueMask 320f678 1 17465a4
|
||||
nvnCommandBufferSetStencilMask 320f680 1 17465c0
|
||||
nvnCommandBufferSetStencilRef 320f688 2 17479fc
|
||||
nvnCommandBufferSetBlendColor 320f690 2 1747a2c
|
||||
nvnCommandBufferSetPointSize 320f698 0 -
|
||||
nvnCommandBufferSetLineWidth 320f6a0 0 -
|
||||
nvnCommandBufferSetPolygonOffsetClamp 320f6a8 1 1746694
|
||||
nvnCommandBufferSetAlphaRef 320f6b0 0 -
|
||||
nvnCommandBufferSetSampleMask 320f6b8 0 -
|
||||
nvnCommandBufferSetRasterizerDiscard 320f6c0 0 -
|
||||
nvnCommandBufferSetDepthClamp 320f6c8 0 -
|
||||
nvnCommandBufferSetConservativeRasterEnable 320f6d0 0 -
|
||||
nvnCommandBufferSetConservativeRasterDilate 320f6d8 0 -
|
||||
nvnCommandBufferSetSubpixelPrecisionBias 320f6e0 0 -
|
||||
nvnCommandBufferCopyBufferToTexture 320f6e8 1 1745390
|
||||
nvnCommandBufferCopyTextureToBuffer 320f6f0 1 17454cc
|
||||
nvnCommandBufferCopyTextureToTexture 320f6f8 3 1745238
|
||||
nvnCommandBufferCopyBufferToBuffer 320f700 4 1745050
|
||||
nvnCommandBufferClearBuffer 320f708 0 -
|
||||
nvnCommandBufferClearTexture 320f710 2 1745894
|
||||
nvnCommandBufferClearTexturei 320f718 0 -
|
||||
nvnCommandBufferClearTextureui 320f720 3 17460c0
|
||||
nvnCommandBufferUpdateUniformBuffer 320f728 1 174a140
|
||||
nvnCommandBufferReportCounter 320f730 8 1748f24
|
||||
nvnCommandBufferResetCounter 320f738 2 1744d60
|
||||
nvnCommandBufferReportValue 320f740 0 -
|
||||
nvnCommandBufferSetRenderEnable 320f748 0 -
|
||||
nvnCommandBufferSetRenderEnableConditional 320f750 0 -
|
||||
nvnCommandBufferSetRenderTargets 320f758 1 1745bdc
|
||||
nvnCommandBufferDiscardColor 320f760 0 -
|
||||
nvnCommandBufferDiscardDepthStencil 320f768 0 -
|
||||
nvnCommandBufferDownsample 320f770 0 -
|
||||
nvnCommandBufferTiledDownsample 320f778 0 -
|
||||
nvnCommandBufferDownsampleTextureView 320f780 2 1745e54
|
||||
nvnCommandBufferTiledDownsampleTextureView 320f788 0 -
|
||||
nvnCommandBufferBarrier 320f790 33 1744e74
|
||||
nvnCommandBufferWaitSync 320f798 4 1748280
|
||||
nvnCommandBufferFenceSync 320f7a0 0 -
|
||||
nvnCommandBufferSetTexturePool 320f7a8 1 173d6c0
|
||||
nvnCommandBufferSetSamplerPool 320f7b0 1 173d6dc
|
||||
nvnCommandBufferSetShaderScratchMemory 320f7b8 1 173d6a8
|
||||
nvnCommandBufferSaveZCullData 320f7c0 0 -
|
||||
nvnCommandBufferRestoreZCullData 320f7c8 0 -
|
||||
nvnCommandBufferSetCopyRowStride 320f7d0 2 1745368
|
||||
nvnCommandBufferSetCopyImageStride 320f7d8 0 -
|
||||
nvnCommandBufferGetCopyRowStride 320f7e0 0 -
|
||||
nvnCommandBufferGetCopyImageStride 320f7e8 0 -
|
||||
nvnCommandBufferDrawTexture 320f7f0 0 -
|
||||
nvnProgramSetSubroutineLinkage 320f7f8 0 -
|
||||
nvnCommandBufferSetProgramSubroutines 320f800 0 -
|
||||
nvnCommandBufferBindCoverageModulationTable 320f808 0 -
|
||||
nvnCommandBufferResolveDepthBuffer 320f810 0 -
|
||||
nvnCommandBufferSetColorReductionEnable 320f818 0 -
|
||||
nvnCommandBufferSetColorReductionThresholds 320f820 0 -
|
||||
nvnCommandBufferPushDebugGroupStatic 320f828 0 -
|
||||
nvnCommandBufferPushDebugGroupDynamic 320f830 2 1748c88
|
||||
nvnCommandBufferPushDebugGroup 320f838 0 -
|
||||
nvnCommandBufferPopDebugGroup 320f840 2 1748d68
|
||||
nvnCommandBufferPopDebugGroupId 320f848 0 -
|
||||
nvnCommandBufferInsertDebugMarkerStatic 320f850 0 -
|
||||
nvnCommandBufferInsertDebugMarkerDynamic 320f858 2 1748e18
|
||||
nvnCommandBufferInsertDebugMarker 320f860 0 -
|
||||
nvnCommandBufferGetMemoryCallback 320f868 0 -
|
||||
nvnCommandBufferGetMemoryCallbackData 320f870 0 -
|
||||
nvnCommandBufferIsRecording 320f878 2 1744f14
|
||||
nvnSyncInitialize 320f880 2 173cf14
|
||||
nvnSyncFinalize 320f888 2 173dffc
|
||||
nvnSyncSetDebugLabel 320f890 0 -
|
||||
nvnQueueFenceSync 320f898 1 1744420
|
||||
nvnSyncWait 320f8a0 2 17439fc
|
||||
nvnQueueWaitSync 320f8a8 0 -
|
||||
nvnSyncInitializeFromFencedGLSync 320f8b0 0 -
|
||||
nvnSyncCreateGLSync 320f8b8 0 -
|
||||
nvnEventBuilderSetDefaults 320f8c0 2 173f7a4
|
||||
nvnEventBuilderSetStorage 320f8c8 2 173f7b8
|
||||
nvnEventBuilderGetStorage 320f8d0 0 -
|
||||
nvnEventBuilderGetMemoryPool 320f8d8 0 -
|
||||
nvnEventBuilderGetMemoryOffset 320f8e0 0 -
|
||||
nvnEventInitialize 320f8e8 2 173f7c8
|
||||
nvnEventFinalize 320f8f0 2 17424fc
|
||||
nvnEventGetValue 320f8f8 1 1743a78
|
||||
nvnEventSignal 320f900 2 173f7e0
|
||||
nvnEventGetMemoryPool 320f908 0 -
|
||||
nvnEventGetMemoryOffset 320f910 0 -
|
||||
nvnCommandBufferWaitEvent 320f918 4 1744130
|
||||
nvnCommandBufferSignalEvent 320f920 8 17440b8
|
||||
nvnCommandBufferSetStencilCullCriteria 320f928 0 -
|
||||
nvnCommandBufferInsertCheckpointStatic 320f930 0 -
|
||||
nvnCommandBufferInsertCheckpointDynamic 320f938 0 -
|
||||
nvnDeviceSetAutomaticCheckpointsEnable 320f940 0 -
|
||||
nvnDeviceSetAutomaticCheckpointsSamplingInterval 320f948 0 -
|
||||
nvnDeviceSetAutomaticCheckpointsByDebugGroup 320f950 0 -
|
||||
nvnDeviceSetCheckpointCallStacksEnable 320f958 0 -
|
||||
nvnDeviceSetCheckpointMaxCallStacksDepth 320f960 0 -
|
||||
|
@@ -0,0 +1,139 @@
|
||||
// NVN 贴图的存储尺寸 / 对齐 / 各级偏移(Tegra X1 块线性布局)。
|
||||
// 算法移植自 deko3d source/dk_image.cpp(zlib 许可,Copyright (C) 2018-2020 fincs):
|
||||
// 一个 GOB = 64 字节 × 8 行 = 512 字节;块高(tileH,单位 GOB)按「高度×1.5」挑;各级按块对齐累加。
|
||||
// 游戏的预排布贴图(SetPackagedTextureLayout)带 8 字节布局参数:第 0 字节 = 块高 log2(真游戏 16 例对照得出,
|
||||
// 其中 4 例与自动算法不同),有它时以它为准。
|
||||
// Storage size / alignment / per-level offsets of NVN textures (Tegra X1 block-linear layout).
|
||||
// The algorithm is ported from deko3d source/dk_image.cpp (zlib license, Copyright (C) 2018-2020 fincs):
|
||||
// one GOB = 64 bytes × 8 rows = 512 bytes; the block height (tileH, in GOBs) is picked by 'height×1.5'; levels are accumulated with block alignment.
|
||||
// The game's packaged textures (SetPackagedTextureLayout) carry 8 bytes of layout parameters: byte 0 = log2 of the block height (derived by comparing 16 cases from the real game,
|
||||
// 4 of which differ from the automatic algorithm); when present it takes precedence.
|
||||
#include "nvn_tex.h"
|
||||
|
||||
typedef struct { uint8_t bpb, bw, bh; } fmt_t; // 每块字节、块宽、块高(非压缩格式块宽高 = 1) | Bytes per block, block width, block height (for uncompressed formats block width and height = 1)
|
||||
|
||||
static fmt_t fmt_of(int f) {
|
||||
static const uint8_t astc[14][2] = {{4,4},{5,4},{5,5},{6,5},{6,6},{8,5},{8,6},{8,8},{10,5},{10,6},{10,8},{10,10},{12,10},{12,12}};
|
||||
if (f >= 0x79 && f <= 0x94) { int k = (f - 0x79) % 14; return (fmt_t){16, astc[k][0], astc[k][1]}; }
|
||||
if (f >= 0x41 && f <= 0x50) { // DXT / RGTC / BPTC:4×4 块 | DXT / RGTC / BPTC: 4×4 blocks
|
||||
int b8 = (f <= 0x42) || (f == 0x45 || f == 0x46) || (f == 0x49 || f == 0x4A);
|
||||
return (fmt_t){b8 ? 8 : 16, 4, 4};
|
||||
}
|
||||
static const struct { uint8_t lo, hi, bpb; } r[] = {
|
||||
{0x01,0x04,1},{0x05,0x09,2},{0x0A,0x0C,4},{0x0D,0x10,2},{0x11,0x15,4},{0x16,0x18,8},
|
||||
{0x19,0x1C,3},{0x1D,0x21,6},{0x22,0x24,12},{0x25,0x28,4},{0x29,0x2D,8},{0x2E,0x30,16},
|
||||
{0x31,0x31,1},{0x32,0x32,2},{0x33,0x35,4},{0x36,0x36,8},{0x37,0x38,4},{0x39,0x3C,2},{0x3D,0x40,4},
|
||||
{0x51,0x52,1},{0x53,0x54,2},{0x55,0x56,4},{0x57,0x58,2},{0x59,0x5A,4},{0x5B,0x5C,8},
|
||||
{0x5D,0x5E,3},{0x5F,0x60,6},{0x61,0x62,12},{0x63,0x64,4},{0x65,0x66,8},{0x67,0x68,16},
|
||||
{0x69,0x6C,4},{0x6D,0x70,4},{0x71,0x75,8},{0x76,0x78,16},{0x95,0x98,2},{0x99,0x9C,4},
|
||||
};
|
||||
for (unsigned i = 0; i < sizeof r / sizeof *r; i++)
|
||||
if (f >= r[i].lo && f <= r[i].hi) return (fmt_t){r[i].bpb, 1, 1};
|
||||
return (fmt_t){0, 1, 1};
|
||||
}
|
||||
|
||||
int nvn_fmt_bpb(int f, int *bw, int *bh) { fmt_t t = fmt_of(f); if (bw) *bw = t.bw; if (bh) *bh = t.bh; return t.bpb; }
|
||||
|
||||
static uint32_t mip(uint32_t s, unsigned l) { s >>= l; return s ? s : 1; }
|
||||
static uint32_t blk(uint32_t s, uint32_t b) { return (s + b - 1) / b; }
|
||||
static unsigned pick_tile(uint32_t gobs) { return gobs >= 16 ? 4 : gobs >= 8 ? 3 : gobs >= 4 ? 2 : gobs >= 2 ? 1 : 0; }
|
||||
static unsigned adj_tile(unsigned shift, uint32_t unit, uint32_t dim) {
|
||||
if (!shift) return 0;
|
||||
uint32_t x = unit << (shift - 1);
|
||||
if (x >= dim) while (--shift) { x >>= 1; if (x < dim) break; }
|
||||
return shift;
|
||||
}
|
||||
|
||||
// target:NVNtextureTarget;dims 维数、是否分层由 target 决定
|
||||
// target: NVNtextureTarget; the number of dims and whether it is layered are determined by target
|
||||
static void shape(const nvn_texdesc *d, unsigned *dpl, int *layered, uint32_t *w, uint32_t *h, uint32_t *z) {
|
||||
*w = d->width; *h = d->height; *z = d->depth; *layered = 0;
|
||||
switch (d->target) {
|
||||
case 0: *dpl = 1; *h = 1; *z = 1; break; // 1D
|
||||
case 3: *dpl = 1; *z = d->height; *h = 1; *layered = 1; break; // 1D_ARRAY(层数在 height) | 1D_ARRAY (layer count is in height)
|
||||
case 2: *dpl = 3; break; // 3D
|
||||
case 4: case 6: *dpl = 2; *layered = 1; break; // 2D_ARRAY / MS_ARRAY
|
||||
case 8: *dpl = 2; *z = 6; *layered = 1; break; // CUBEMAP
|
||||
case 9: *dpl = 2; *z = d->depth * 6; *layered = 1; break; // CUBEMAP_ARRAY
|
||||
default: *dpl = 2; *z = 1; break; // 2D / MS / RECTANGLE
|
||||
}
|
||||
if (*z == 0) *z = 1;
|
||||
}
|
||||
|
||||
static void samples_xy(int s, uint32_t *sx, uint32_t *sy) {
|
||||
*sx = *sy = 1;
|
||||
if (s == 2) *sx = 2; else if (s == 4) *sx = *sy = 2; else if (s == 8) { *sx = 4; *sy = 2; }
|
||||
}
|
||||
|
||||
static uint64_t level_offset(const nvn_texdesc *d, unsigned level, unsigned dpl, uint32_t w, uint32_t h, uint32_t z,
|
||||
unsigned tileH, unsigned tileD, fmt_t t) {
|
||||
uint32_t sx, sy; samples_xy(d->samples, &sx, &sy);
|
||||
uint64_t off = 0;
|
||||
for (unsigned i = 0; i < level; i++) {
|
||||
uint32_t lw = blk(mip(w * sx, i), t.bw);
|
||||
uint32_t lh = dpl >= 2 ? blk(mip(h * sy, i), t.bh) : 1;
|
||||
uint32_t ld = dpl >= 3 ? mip(z, i) : 1;
|
||||
uint32_t lwb = lw * t.bpb;
|
||||
unsigned th = adj_tile(tileH, 8, lh), td = adj_tile(tileD, 1, ld);
|
||||
uint32_t wg = (lwb + 63) / 64, hg = (lh + 7) / 8;
|
||||
uint32_t wt = wg, ht = (hg + (1u << th) - 1) >> th, dt = (ld + (1u << td) - 1) >> td;
|
||||
off += (uint64_t)wt * ht * dt << (9 + th + td);
|
||||
}
|
||||
return off;
|
||||
}
|
||||
|
||||
void nvn_tex_layout(const nvn_texdesc *d, nvn_texlayout *o) {
|
||||
fmt_t t = fmt_of(d->format);
|
||||
unsigned dpl; int layered; uint32_t w, h, z;
|
||||
shape(d, &dpl, &layered, &w, &h, &z);
|
||||
uint32_t sx, sy; samples_xy(d->samples, &sx, &sy);
|
||||
o->bpb = t.bpb; o->tileH = o->tileD = 0; o->layers = layered ? z : 1;
|
||||
if (!t.bpb) { o->size = 0; o->align = 512; o->layer_size = 0; return; }
|
||||
if (d->target == 10) { // BUFFER
|
||||
o->layer_size = o->size = (uint64_t)t.bpb * d->width;
|
||||
o->align = t.bpb == 12 ? 4 : t.bpb; return;
|
||||
}
|
||||
if (d->flags & 0x10) { // LINEAR:行距 = stride 或按 32 对齐 | LINEAR: row pitch = stride or aligned to 32
|
||||
o->align = (d->flags & 0x40) ? 128 : 32;
|
||||
uint32_t stride = d->stride ? d->stride : (t.bpb * blk(w, t.bw) + o->align - 1) & ~(o->align - 1);
|
||||
o->layer_size = o->size = (uint64_t)stride * blk(h, t.bh);
|
||||
return;
|
||||
}
|
||||
unsigned tileH = 0, tileD = 0;
|
||||
if (dpl == 2) { uint32_t ah = blk(h * sy, t.bh); tileH = d->pkg_block_h ? (unsigned)d->pkg_block_h - 1 : pick_tile((ah + ah / 2 + 7) / 8); }
|
||||
else if (dpl == 3) tileD = pick_tile(z + z / 2);
|
||||
o->tileH = tileH; o->tileD = tileD;
|
||||
unsigned levels = d->levels ? d->levels : 1;
|
||||
uint64_t ls = level_offset(d, levels, dpl, w, h, z, tileH, tileD, t);
|
||||
if (layered) { // 层尺寸按块对齐 | Layer size is aligned to the block
|
||||
uint32_t hh = blk(h, t.bh); unsigned th = tileH, td = tileD;
|
||||
while (th && hh <= (8u << (th - 1))) th--;
|
||||
while (td && z <= (1u << (td - 1))) td--;
|
||||
unsigned sh = th + td + 9; uint64_t g = ls >> sh;
|
||||
if (ls != g << sh) ls = (g + 1) << sh;
|
||||
}
|
||||
o->layer_size = ls;
|
||||
o->size = layered ? ls * z : ls;
|
||||
o->align = 512;
|
||||
}
|
||||
|
||||
uint64_t nvn_tex_level_offset(const nvn_texdesc *d, unsigned level) {
|
||||
fmt_t t = fmt_of(d->format);
|
||||
unsigned dpl; int layered; uint32_t w, h, z;
|
||||
shape(d, &dpl, &layered, &w, &h, &z);
|
||||
if (!t.bpb || (d->flags & 0x10) || d->target == 10) return 0;
|
||||
nvn_texlayout L; nvn_tex_layout(d, &L);
|
||||
return level_offset(d, level, dpl, w, h, z, L.tileH, L.tileD, t);
|
||||
}
|
||||
|
||||
void nvn_tex_level_tiles(const nvn_texdesc *d, unsigned level, unsigned *tileH, unsigned *tileD) {
|
||||
fmt_t t = fmt_of(d->format);
|
||||
unsigned dpl; int layered; uint32_t w, h, z;
|
||||
shape(d, &dpl, &layered, &w, &h, &z);
|
||||
uint32_t sx, sy; samples_xy(d->samples, &sx, &sy);
|
||||
nvn_texlayout L; nvn_tex_layout(d, &L);
|
||||
uint32_t lh = dpl >= 2 ? blk(mip(h * sy, level), t.bh) : 1;
|
||||
uint32_t ld = dpl >= 3 ? mip(z, level) : 1;
|
||||
*tileH = adj_tile(L.tileH, 8, lh);
|
||||
*tileD = adj_tile(L.tileD, 1, ld);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// NVN 贴图存储布局(Tegra X1 块线性),见 nvn_tex.c。
|
||||
// NVN texture storage layout (Tegra X1 block-linear), see nvn_tex.c.
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
int target, format, flags, samples; // NVNtextureTarget / NVNformat / NVNtextureFlags / 采样数(0 或 1 = 单采样) | NVNtextureTarget / NVNformat / NVNtextureFlags / sample count (0 or 1 = single-sampled)
|
||||
uint32_t width, height, depth, levels, stride;
|
||||
int pkg_block_h; // 预排布贴图布局参数第 0 字节(块高 log2)+ 1;0 = 按自动算法 | Byte 0 of the packaged texture layout parameters (log2 of block height) + 1; 0 = use the automatic algorithm
|
||||
} nvn_texdesc;
|
||||
|
||||
typedef struct {
|
||||
uint64_t size, layer_size; // 总存储字节、每层字节 | Total storage bytes, bytes per layer
|
||||
uint32_t align, layers, bpb; // 对齐、层数、每块字节 | Alignment, layer count, bytes per block
|
||||
unsigned tileH, tileD; // 块高 / 块深(log2 GOB 数) | Block height / block depth (log2 of the GOB count)
|
||||
} nvn_texlayout;
|
||||
|
||||
void nvn_tex_layout(const nvn_texdesc *d, nvn_texlayout *o);
|
||||
uint64_t nvn_tex_level_offset(const nvn_texdesc *d, unsigned level);
|
||||
int nvn_fmt_bpb(int format, int *bw, int *bh); // 每块字节(0 = 未知格式),块宽高 | Bytes per block (0 = unknown format), block width and height
|
||||
// 第 level 级实际使用的块高 / 块深(log2 GOB 数):贴图级块高按该级行数(块行)收缩,解排布逐级用它
|
||||
// Block height / block depth actually used by level `level` (log2 of the GOB count): the per-level block height shrinks with that level's row count (block rows), and deswizzling uses it level by level
|
||||
void nvn_tex_level_tiles(const nvn_texdesc *d, unsigned level, unsigned *tileH, unsigned *tileD);
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,397 @@
|
||||
# 预热种子清单(随包,与 shader_map.tsv 同目录)。行:S<TAB>着色器键<TAB>阶段 / R<TAB>渲染管线键(pso_skey 十六进制)/ C<TAB>计算着色器键。
|
||||
# 来源:DM_PSO_RECORD 重录并按行去重(管线键加了特化来源字段,旧行作废)——画面闸门 17 页主机 / 掌机各一轮 + cvd5 营地主机、掌机、局内两个方向切换各一局。
|
||||
# 行序 = 录制时的首次使用顺序(前端在前、局内在后;真机追加的在最后):预热按行序建,启动最先要用的最先就绪。不要排序。
|
||||
# 追加:真机(野外走打三段)用户清单里种子没有的 102 行——着色器 42、普通通道管线 35、合并通道管线 25(旧键格式按「无特化」补零转换;6 条特化片元管线缺重建参数未并入)。
|
||||
# 追加(二):真机重场面(亡者大殿二层)与野外走打用到、种子没有的 32 行——着色器 15、普通通道管线 15、合并通道 1、可读 tile 特化 1。
|
||||
S a1217a07d94c1184_b 5
|
||||
C a1217a07d94c1184_b
|
||||
S f88d27f131d71049_b 0
|
||||
S 62ddcb3faa41a92a_b 1
|
||||
S ce3ad354c986bf85_b 1
|
||||
S b3d4dd57cd4d630c_b 1
|
||||
S 69cfdc6545a66915_b 0
|
||||
S 7a865245b73eb96b_b 1
|
||||
S de7267a552710c58_b 5
|
||||
S 890de4b2c99eb9ba_b 5
|
||||
S 552f45c348a61b86_b 5
|
||||
S da5e3bfe00b88521_b 5
|
||||
S 4639dd6d3e3f0c1b_b 5
|
||||
S 098a126f92bf533a_b 5
|
||||
S 6a7a308d61928982_b 5
|
||||
S b54d192f7c620ded_b 5
|
||||
S 60f3906f2280721c_b 1
|
||||
S 646e86038aa9e52c_b 0
|
||||
S 56c2fef6ecb186d5_b 1
|
||||
S d5fcb22fbc1b5fa5_b 1
|
||||
S 45a5b1ff67fc3724_b 1
|
||||
S 5ddee022e68e6a2d_b 1
|
||||
S 4a819818b8e489c5_b 1
|
||||
S c9468c9400b8df6f_b 0
|
||||
S e71f0d71ed3b2c71_b 1
|
||||
S 8e80084d3c30340a_b 1
|
||||
S d5eaef5580e95b5c_b 0
|
||||
S 95423174e654085d_b 1
|
||||
S fa0f7422e4d89595_b 1
|
||||
S 2938a5b71b8e21b2_b 1
|
||||
S 019ce2f82edbda84_b 1
|
||||
S cc264583f2000c81_b 1
|
||||
S 2e2d6700a2569795_b 1
|
||||
S 0800e9969c585b7d_b 1
|
||||
S a1b1aab66933fa8f_b 1
|
||||
S ebcfcd1fa0a77dbc_b 1
|
||||
S 52aac1f2306b8fc5_b 1
|
||||
S 9a650561e5c40791_b 1
|
||||
R 663838643237663133316437313034395f62000000000000363264646362336661613431613932615f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000460000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000ffffffff000000002818028604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000160c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 663838643237663133316437313034395f62000000000000636533616433353463393836626638355f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000460000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000ffffffff000000002818028604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000160c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 663838643237663133316437313034395f62000000000000623364346464353763643464363330635f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000460000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000ffffffff000000002818028604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000160c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000376138363532343562373365623936625f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040100000100000000000000ffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
C de7267a552710c58_b
|
||||
C 890de4b2c99eb9ba_b
|
||||
C 552f45c348a61b86_b
|
||||
C da5e3bfe00b88521_b
|
||||
C 4639dd6d3e3f0c1b_b
|
||||
C 098a126f92bf533a_b
|
||||
C 6a7a308d61928982_b
|
||||
C b54d192f7c620ded_b
|
||||
R 363963666463363534356136363931355f62000000000000363066333930366632323830373231635f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000ffffffff000000001004048104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363436653836303338616139653532635f62000000000000353663326665663665636231383664355f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000f1ffffff000000001004048104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000643566636232326662633162356661355f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000ffffffff000000001004048104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000343561356231666636376663333732345f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000ffffffff000000001004048104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000356464656530323265363865366132645f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004010000000000000100000000000000ffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 633934363863393430306238646636665f62000000000000653731663064373165643362326337315f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000ffffffff000000001004048104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 633934363863393430306238646636665f62000000000000386538303038346433633330333430615f62000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c000000000000000000000000000000000000000000000000000000000000000100000007000000ffffffff000000001008048204000000090c02850400000012080482040000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 633934363863393430306238646636665f62000000000000386538303038346433633330333430615f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000000000000040100000100000007000000ffffffff000000001008048204000000090c028504000000120804820400000013040481040000001404048104000000150404810400000016040481040000001704048104000000220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000102ffffffffff0000000000000000
|
||||
R 643565616566353538306539356235635f62000000000000393534323331373465363534303835645f6200000000000000010101010700000002ff01ffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000000000000040100000100000000000000ffffffff000000001004048104000000090c028504000000120804820400000013040481040000001404048104000000150404810400000016040481040000001704048104000000220000000000000000000000162800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff00ffffffff0000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000666130663734323265346438393539355f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000ffffffff000000001004048104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000303139636532663832656462646138345f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000ffffffff000000001004048104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000636332363435383366323030306338315f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000ffffffff00000000080b048104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000326532643637303061323536393739355f6200000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000005c00000000000000000000000000000000000000000000000000000000000000040100000100000001000000ffffffff00000000080b048104000000090c02850400000012080482040000001304048104000000140404810400000015040481040000001604048104000000170404810400000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffff0000000000000000
|
||||
R 643565616566353538306539356235635f62000000000000303830306539393639633538356237645f6200000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000005c00000000000000000000000000000000000000000000000000000000000000040100000100000001000000ffffffff000000001014028504000000090c02850400000012080482040000001304048104000000140404810400000015040481040000001604048104000000170404810400000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffff0000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000613162316161623636393333666138665f62000000000000000101010101000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000005c0000005c00000000000000000000000000000000000000000000000000000000000000040100000100000000000000ffffffff000000001004048104000000090c028504000000120804820400000013040481040000001404048104000000150404810400000016040481040000001704048104000000220000000000000000000000162800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ff00ffffffffffff0000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000656263666364316661306137376462635f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000000000000040100000100000000000000ffffffff000000001004048104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000396136353035363165356334303739315f620000000000000001010102000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000460000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000ffffffff000000001004048104000000090c02850400000012080482040000001304048104000000140404810400000015040481040000001604048104000000170404810400000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffff0000000000000000
|
||||
C
|
||||
R 363963666463363534356136363931355f62000000000000396136353035363165356334303739315f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000460000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000ffffffff000000001004048104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S ed8df20b114afc67_b 0
|
||||
S 949495670492f2e4_b 1
|
||||
S 0f715b1a5e03f11f_b 5
|
||||
S b28286da8956e9a4_b 0
|
||||
S f57adeb0447b3dd9_b 1
|
||||
S af64b417689666bf_b 0
|
||||
S 358197ac3db59cbc_b 1
|
||||
S 54f730a6c0efc118_b 0
|
||||
S 5c1ca4e7c3e4657c_b 1
|
||||
S 38f344adf801b153_b 1
|
||||
S b70c638ef69450c5_b 1
|
||||
S fbb330365d3f53ff_b 1
|
||||
S 15f7712f6966060b_b 0
|
||||
S 943e19bc3ea02a59_b 1
|
||||
S bc8c31cad521e0c8_b 0
|
||||
S f0faf05b99e7a4a2_b 1
|
||||
S fa27a102ecd14b3e_b 0
|
||||
S 1bd6a72fa95c6a07_b 1
|
||||
S 6dc4afb46d96bc66_b 0
|
||||
S 1518b75a6c1e460a_b 1
|
||||
S 267cb1d4c373d33b_b 0
|
||||
S 04ae2ac7d2b62bb5_b 1
|
||||
S 4d47301a1db40fc7_b 0
|
||||
S fcccde2ec93d3553_b 1
|
||||
S af50d9d0c4e98e8a_b 0
|
||||
S e6e68409769c8bdd_b 1
|
||||
R 656438646632306231313461666336375f62000000000000393439343935363730343932663265345f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fa000000000000000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
C 0f715b1a5e03f11f_b
|
||||
R 623238323836646138393536653961345f62000000000000663537616465623034343762336464395f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000260800000000000025100000111400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 656438646632306231313461666336375f62000000000000663537616465623034343762336464395f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 656438646632306231313461666336375f62000000000000393439343935363730343932663265345f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 616636346234313736383936363662665f62000000000000333538313937616333646235396362635f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000025100000111400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353466373330613663306566633131385f62000000000000333538313937616333646235396362635f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353466373330613663306566633131385f62000000000000356331636134653763336534363537635f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353466373330613663306566633131385f62000000000000333866333434616466383031623135335f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 616636346234313736383936363662665f62000000000000333866333434616466383031623135335f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000025100000111400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353466373330613663306566633131385f62000000000000623730633633386566363934353063355f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 626338633331636164353231653063385f62000000000000663066616630356239396537613461325f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 666132376131303265636431346233655f62000000000000316264366137326661393563366130375f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 366463346166623436643936626336365f62000000000000313531386237356136633165343630615f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 323637636231643463333733643333625f62000000000000303461653261633764326236326262355f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 346434373330316131646234306663375f62000000000000666363636465326563393364333535335f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008160000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 616635306439643063346539386538615f62000000000000653665363834303937363963386264645f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008160000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353466373330613663306566633131385f62000000000000666262333330333635643366353366665f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002b00000026080000260c00001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 313566373731326636393636303630625f62000000000000393433653139626333656130326135395f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002e0000002e0000082e0000101600001800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000001000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 633934363863393430306238646636665f62000000000000386538303038346433633330333430615f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000007000000ffffffff000000001008048204000000090c028504000000120804820400000013040481040000001404048104000000150404810400000016040481040000001704048104000000220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000102ffffffffff0000000000000000
|
||||
R 643565616566353538306539356235635f62000000000000393534323331373465363534303835645f6200000000000000010101010700000002ff01ffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000000000000ffffffff000000001004048104000000090c028504000000120804820400000013040481040000001404048104000000150404810400000016040481040000001704048104000000220000000000000000000000162800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff00ffffffff0000000000000000
|
||||
S 3deaf68fd65b5298_b 0
|
||||
S d3678c2bd7da227d_b 1
|
||||
S e9ba089446aab577_b 1
|
||||
S 26d5ae725c9d0bd7_b 1
|
||||
S 54c93fa22abff9ee_b 0
|
||||
S f1ae4555a6c44f4e_b 1
|
||||
S 203a07fdc5444d77_b 1
|
||||
S 634bc9f2af5d9216_b 1
|
||||
S 7482bf0e7f5de616_b 1
|
||||
R 336465616636386664363562353239385f62000000000000643336373863326264376461323237645f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fa000000000000000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000000000000000000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 336465616636386664363562353239385f62000000000000653962613038393434366161623537375f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fa000000000000000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000000000000000000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 336465616636386664363562353239385f62000000000000393439343935363730343932663265345f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fa000000000000000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000000000000000000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 336465616636386664363562353239385f62000000000000323664356165373235633964306264375f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fa000000000000000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000000000000000000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 336465616636386664363562353239385f62000000000000393439343935363730343932663265345f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000000000000000000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 336465616636386664363562353239385f62000000000000323664356165373235633964306264375f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000000000000000000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000663161653435353561366334346634655f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000323033613037666463353434346437375f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000363334626339663261663564393231365f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000373438326266306537663564653631365f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
S a71801f7ce2dd10d_b 1
|
||||
R 666132376131303265636431346233655f62000000000000613731383031663763653264643130645f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002e00000000000000000000001600000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
S f079dcf4974fd7b9_b 1
|
||||
R 656438646632306231313461666336375f62000000000000393439343935363730343932663265345f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004010000000000000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 643565616566353538306539356235635f62000000000000663037396463663439373466643762395f6200000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000005c00000000000000000000000000000000000000000000000000000000000000040100000100000001000000ffffffff000000001014028504000000090c02850400000012080482040000001304048104000000140404810400000015040481040000001604048104000000170404810400000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffff0000000000000000
|
||||
S 7df0f17b3b325d31_b 1
|
||||
S 00da6be561241990_b 0
|
||||
S eed4afa7b0f076ab_b 1
|
||||
S 0fbb232e68f9fbfa_b 0
|
||||
S 5ea5ef2f3e8e8135_b 1
|
||||
S 06ece8336c8c242c_b 0
|
||||
S 405e645129f39ebc_b 1
|
||||
S 3bedd0f440391756_b 1
|
||||
S 25fcbaa0072d6f8e_b 1
|
||||
S e1c00b41f984949c_b 1
|
||||
S 913751f67bc50268_b 5
|
||||
S 2cf273eba56846c3_b 1
|
||||
S f371fb3f5b46dc6d_b 1
|
||||
R 663838643237663133316437313034395f62000000000000376466306631376233623332356433315f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000460000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000ffffffff000000002818028604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000160c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 303064613662653536313234313939305f62000000000000393439343935363730343932663265345f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fa000000000000000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 303064613662653536313234313939305f62000000000000663537616465623034343762336464395f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fa000000000000000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 336465616636386664363562353239385f62000000000000663537616465623034343762336464395f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fa000000000000000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000000000000000000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 656438646632306231313461666336375f62000000000000663537616465623034343762336464395f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fa000000000000000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 336465616636386664363562353239385f62000000000000656564346166613762306630373661625f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fa000000000000000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000000000000000000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 306662623233326536386639666266615f62000000000000393439343935363730343932663265345f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fa000000000000000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000260800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 303064613662653536313234313939305f62000000000000393439343935363730343932663265345f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 303064613662653536313234313939305f62000000000000663537616465623034343762336464395f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 336465616636386664363562353239385f62000000000000663537616465623034343762336464395f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000000000000000000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 336465616636386664363562353239385f62000000000000356561356566326633653865383133355f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000000000000000000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 306662623233326536386639666266615f62000000000000393439343935363730343932663265345f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000260800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 303665636538333336633863323432635f62000000000000356331636134653763336534363537635f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 303665636538333336633863323432635f62000000000000333866333434616466383031623135335f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000333538313937616333646235396362635f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 303665636538333336633863323432635f62000000000000333538313937616333646235396362635f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000343035653634353132396633396562635f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000336265646430663434303339313735365f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000323566636261613030373264366638655f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000356331636134653763336534363537635f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 306662623233326536386639666266615f62000000000000653163303062343166393834393439635f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000260800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
C 913751f67bc50268_b
|
||||
R 353463393366613232616266663965655f62000000000000326366323733656261353638343663335f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000613162316161623636393333666138665f6200000000000000010101020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000000000000040100000100000000000000ffffffff000000001004048104000000090c02850400000012080482040000001304048104000000140404810400000015040481040000001604048104000000170404810400000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffff0000000000000000
|
||||
S 1188eaedc8db3285_b 5
|
||||
C 1188eaedc8db3285_b
|
||||
S e411675c31157063_b 0
|
||||
S 58a0b840cd0b1e58_b 1
|
||||
R 653431313637356333313135373036335f62000000000000353861306238343063643062316535385f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 24373179821a89b8_b 0
|
||||
S 00f1902d880682c7_b 1
|
||||
S ff91743a2d7561cc_b 0
|
||||
S 18e91ef32f8623ca_b 1
|
||||
S acd655d88042767c_b 1
|
||||
S a9a839a220417792_b 0
|
||||
S 3be9871c4d40cf22_b 1
|
||||
S f70970fd3d9d4f2c_b 0
|
||||
S 4b0b7f6cb3b4c9e9_b 1
|
||||
S 86270a3c87cee47f_b 1
|
||||
R 656438646632306231313461666336375f62000000000000393439343935363730343932663265345f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000000000000000000025100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 323433373331373938323161383962385f62000000000000303066313930326438383036383263375f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000025100000111400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 666639313734336132643735363163635f62000000000000313865393165663332663836323363615f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000616364363535643838303432373637635f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 613961383339613232303431373739325f62000000000000336265393837316334643430636632325f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000004600000000000000000000000000000000000000000000000000000004010000000000000100000000000000ffffffff00000000100404810400000011040481040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 663730393730666433643964346632635f62000000000000346230623766366362336234633965395f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000004600000000000000000000000000000000000000000000000000000004010000000000000100000000000000ffffffff00000000100404810400000011040481040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353466373330613663306566633131385f62000000000000666262333330333635643366353366665f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001204048104000000130404810400000014040481040000001504048104000000160404810400000017040481040000002b00000026080000260c00001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 666639313734336132643735363163635f62000000000000383632373061336338376365653437665f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001204048104000000130404810400000014040481040000001504048104000000160404810400000017040481040000002b00000026080000260c00001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000373438326266306537663564653631365f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001204048104000000130404810400000014040481040000001504048104000000160404810400000017040481040000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 313566373731326636393636303630625f62000000000000393433653139626333656130326135395f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001204048104000000130404810400000014040481040000001504048104000000160404810400000017040481040000002e0000002e0000082e0000101600001800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000001000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
S aac1cfbce5b7c113_b 1
|
||||
S 431cd4628fe13ffe_b 0
|
||||
S 6b1a415756894d2a_b 1
|
||||
S 13f6113d923edb98_b 0
|
||||
S f71c51f9729527fb_b 1
|
||||
S 6d19a794f1206668_b 1
|
||||
S 30153313e494b538_b 0
|
||||
S 93501565681849a0_b 1
|
||||
R 353466373330613663306566633131385f62000000000000363334626339663261663564393231365f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353466373330613663306566633131385f62000000000000616163316366626365356237633131335f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 303665636538333336633863323432635f62000000000000363334626339663261663564393231365f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000616163316366626365356237633131335f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 343331636434363238666531336666655f62000000000000366231613431353735363839346432615f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e0000002e0000082e00001016000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000010000000000000001000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 313366363131336439323365646239385f62000000000000663731633531663937323935323766625f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e0000002e0000082e00001016000018160000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000010000000000000001000000000000000080000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000366431396137393466313230363636385f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000346138313938313862386534383963355f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000ffffffff000000001004048104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000346138313938313862386534383963355f6200000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff000000001004048104000000090c02860400000012080482040000001304048104000000140404810400000015040481040000001604048104000000170404810400000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffff0000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000366431396137393466313230363636385f6200000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff000000001004048104000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffff0000000000000000
|
||||
R 346434373330316131646234306663375f62000000000000666363636465326563393364333535335f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008160000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 666132376131303265636431346233655f62000000000000316264366137326661393563366130375f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 333031353333313365343934623533385f62000000000000393335303135363536383138343961305f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 336465616636386664363562353239385f62000000000000356561356566326633653865383133355f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fa000000000000000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000000000000000000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 832d4dd08089e58c_b 0
|
||||
S 94295c0108746c40_b 1
|
||||
R 383332643464643038303839653538635f62000000000000393432393563303130383734366334305f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e0000002e0000082e00001016000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000010000000000000001000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000333866333434616466383031623135335f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 303665636538333336633863323432635f62000000000000366431396137393466313230363636385f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 303665636538333336633863323432635f62000000000000366431396137393466313230363636385f6200000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff000000001004048104000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffff0000000000000000
|
||||
R 616635306439643063346539386538615f62000000000000653665363834303937363963386264645f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008160000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 366463346166623436643936626336365f62000000000000313531386237356136633165343630615f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 323637636231643463333733643333625f62000000000000303461653261633764326236326262355f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 303665636538333336633863323432635f62000000000000366431396137393466313230363636385f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 34d99325b3a5896f_b 0
|
||||
S 49335a14af61b79e_b 1
|
||||
R 333464393933323562336135383936665f62000000000000343933333561313461663631623739655f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 57308d2793f59f72_b 0
|
||||
S fed04d7e34db9788_b 1
|
||||
R 353733303864323739336635396637325f62000000000000666564303464376533346462393738385f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 8ac93c54cfb3cbe3_b 0
|
||||
S 0d721a0acc36c0bf_b 1
|
||||
R 386163393363353463666233636265335f62000000000000306437323161306163633336633062665f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000460000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000ffffffff0000000028180a860400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000251000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 623238323836646138393536653961345f62000000000000663537616465623034343762336464395f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fa000000000000000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000260800000000000025100000111400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 60f397caa5e8b057_b 0
|
||||
S 8874c23936fc2a39_b 1
|
||||
S 434101471006d0e5_b 0
|
||||
S b98cd9f809e2bb4a_b 1
|
||||
R 343334313031343731303036643065355f62000000000000623938636439663830396532626234615f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363066333937636161356538623035375f62000000000000383837346332333933366663326133395f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002e00000000000000000000001600000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000353261616331663233303662386663355f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000460000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000ffffffff000000001004048104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 43c6fdfecea8a4cf_b 0
|
||||
S d8c1f99434f76ac6_b 1
|
||||
S aaa6e9e56009665b_b 1
|
||||
R 343363366664666563656138613463665f62000000000000643863316639393433346637366163365f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363066333937636161356538623035375f62000000000000616161366539653536303039363635625f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 26f0e1b6606f8f8f_b 1
|
||||
R 666132376131303265636431346233655f62000000000000323666306531623636303666386638665f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000323933386135623731623865323162325f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000ffffffff000000001004048104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000326532643637303061323536393739355f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000000000000040100000100000001000000ffffffff00000000080b048104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 643565616566353538306539356235635f62000000000000303830306539393639633538356237645f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000000000000040100000100000001000000ffffffff000000001014028504000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000613162316161623636393333666138665f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000000000000040100000100000000000000ffffffff000000001004048104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000373438326266306537663564653631365f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 4dffa355f2fbcdaf_b 0
|
||||
S f08b6f90ba832e04_b 1
|
||||
R 346466666133353566326662636461665f62000000000000663038623666393062613833326530345f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000004600000000000000000000000000000000000000000000000000000004010000000000000100000000000000ffffffff00000000100404810400000011040481040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000346138313938313862386534383963355f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000000000000ffffffff0000000010040481040000001104048104000000120404810400000013040481040000001404048104000000150404810400000016040481040000001704048104000000220000000000000000000000162800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffff00ffffffffff0000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000346138313938313862386534383963355f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000000000000ffffffff000000001004048104000000090c028504000000120804820400000013040481040000001404048104000000150404810400000016040481040000001704048104000000220000000000000000000000162800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffff00ffffffffff0000000000000000
|
||||
S 6fe6fa561417c0e5_b 0
|
||||
S 4d3ad70532012a16_b 1
|
||||
S ca452e812a294f77_b 0
|
||||
S 508f43146f0c9927_b 1
|
||||
S a094013b6c675fef_b 0
|
||||
S f1ef8fdeb5c0bd56_b 1
|
||||
R 366665366661353631343137633065355f62000000000000346433616437303533323031326131365f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 636134353265383132613239346637375f62000000000000353038663433313436663063393932375f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008160000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 613039343031336236633637356665665f62000000000000663165663866646562356330626435365f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008160000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 7df3a39125b025fc_b 0
|
||||
S 372d8bfaed684eb8_b 1
|
||||
R 376466336133393132356230323566635f62000000000000333732643862666165643638346562385f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 44ff7d4cebcbd1ec_b 0
|
||||
S 87574c4c2e6808c1_b 1
|
||||
R 343466663764346365626362643165635f62000000000000383735373463346332653638303863315f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000025100000111400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 35a28eb15010bf03_b 0
|
||||
S aca45224f1489150_b 1
|
||||
S 3fb8919ff6ef9db2_b 1
|
||||
R 333561323865623135303130626630335f62000000000000616361343532323466313438393135305f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000002e0000182e000020000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000100000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 303431363065343432623162616236645f62000000000000336662383931396666366566396462325f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S a4c74a484f864372_b 0
|
||||
S c1d9206301953400_b 1
|
||||
S 74cb94eeb5b40d0b_b 1
|
||||
R 613463373461343834663836343337325f62000000000000633164393230363330313935333430305f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 333031353333313365343934623533385f62000000000000373463623934656562356234306430625f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000353261616331663233303662386663355f620000000000000001010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000460000004600000000000000000000000000000000000000000000000000000000000000000000000100000000000000ffffffff000000001004048104000000090c02850400000012080482040000001304048104000000140404810400000015040481040000001604048104000000170404810400000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffff0000000000000000
|
||||
R 643565616566353538306539356235635f62000000000000663337316662336635623436646336645f6200000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000005c00000000000000000000000000000000000000000000000000000000000000040100000100000001000000ffffffff000000001014028504000000090c02850400000012080482040000001304048104000000140404810400000015040481040000001604048104000000170404810400000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffff0000000000000000
|
||||
R 643565616566353538306539356235635f62000000000000393534323331373465363534303835645f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000000000000040100000100000000000000ffffffff000000001004048104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353466373330613663306566633131385f62000000000000666262333330333635643366353366665f6200000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002b00000026080000260c00001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 313566373731326636393636303630625f62000000000000393433653139626333656130326135395f6200000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002e0000002e0000082e0000101600001800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000001000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 643565616566353538306539356235635f62000000000000393534323331373465363534303835645f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff000000001004048104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000373438326266306537663564653631365f6200000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000326366323733656261353638343663335f6200000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000326532643637303061323536393739355f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000001000000ffffffff00000000080b048104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 643565616566353538306539356235635f62000000000000663337316662336635623436646336645f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000001000000ffffffff000000001014028504000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353466373330613663306566633131385f62000000000000666262333330333635643366353366665f6200000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000000000000000000000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002b00000026080000260c00001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000326366323733656261353638343663335f6200000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000000000000000000000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000373438326266306537663564653631365f6200000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000000000000000000000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
S 50f0ce62b195446e_b 1
|
||||
R 313566373731326636393636303630625f62000000000000393433653139626333656130326135395f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e0000002e0000082e00001016000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000010000000000000001000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 643565616566353538306539356235635f62000000000000353066306365363262313935343436655f6200000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000005c00000000000000000000000000000000000000000000000000000000000000040100000100000001000000ffffffff000000001014028504000000090c02850400000012080482040000001304048104000000140404810400000015040481040000001604048104000000170404810400000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffff0000000000000000
|
||||
R 363963666463363534356136363931355f62000000000000346138313938313862386534383963355f6200000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff000000001004048104000000090c02860400000012040481040000001304048104000000140404810400000015040481040000001604048104000000170404810400000022000000000000000000000016280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffff0000000000000000
|
||||
R 303665636538333336633863323432635f62000000000000366431396137393466313230363636385f6200000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff000000001004048104000000090c0286040000001204048104000000130404810400000014040481040000001504048104000000160404810400000017040481040000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffff0000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000326366323733656261353638343663335f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001204048104000000130404810400000014040481040000001504048104000000160404810400000017040481040000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 666132376131303265636431346233655f62000000000000613731383031663763653264643130645f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001204048104000000130404810400000014040481040000001504048104000000160404810400000017040481040000002e00000000000000000000001600000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 366665366661353631343137633065355f62000000000000346433616437303533323031326131365f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002e00000000000000000000001600000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 376466336133393132356230323566635f62000000000000333732643862666165643638346562385f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002e00000000000000000000001600000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 343466663764346365626362643165635f62000000000000383735373463346332653638303863315f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002b00000026080000260c00002510000011140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 333561323865623135303130626630335f62000000000000616361343532323466313438393135305f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002e000000000000000000000000000000000000002e0000182e00002000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000010000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 303431363065343432623162616236645f62000000000000336662383931396666366566396462325f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002e00000000000000000000001600000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 333031353333313365343934623533385f62000000000000373463623934656562356234306430625f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 613463373461343834663836343337325f62000000000000633164393230363330313935333430305f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002e00000000000000000000001600000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
S 228ac21b01ac8272_b 0
|
||||
S b996352a54c7c554_b 0
|
||||
S b3e1b35237757df2_b 1
|
||||
S e833fe6d44bd091e_b 0
|
||||
S 9dafaeb1b3505783_b 1
|
||||
R 323238616332316230316163383237325f620000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000260800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 623939363335326135346337633535345f62000000000000623365316233353233373735376466325f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 653833336665366434346264303931655f62000000000000396461666165623162333530353738335f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000025100000111400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 9ecd8e8edc829b2c_b 0
|
||||
S c9871ba3e716aace_b 1
|
||||
R 396563643865386564633832396232635f62000000000000633938373162613365373136616163655f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S f02c213a0471ae4b_b 1
|
||||
R 666132376131303265636431346233655f62000000000000663032633231336130343731616534625f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 3296391e11cf92a6_b 0
|
||||
S 2747a1418c858a23_b 1
|
||||
R 333239363339316531316366393261365f62000000000000323734376131343138633835386132335f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000025100000111400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 666132376131303265636431346233655f62000000000000663032633231336130343731616534625f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002e00000000000000000000001600000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
S afdd1d5f24a570d1_b 0
|
||||
S 279d49d320adca06_b 1
|
||||
R 616664643164356632346135373064315f62000000000000323739643439643332306164636130365f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e0000002e0000082e00001016000018160000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000010000000000000001000000000000000080000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 7ec0ca4f8e27c10e_b 1
|
||||
R 343331636434363238666531336666655f62000000000000376563306361346638653237633130655f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e0000002e0000082e00001016000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000010000000000000001000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353466373330613663306566633131385f62000000000000616364363535643838303432373637635f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 2f2a18e30b53c626_b 1
|
||||
R 303064613662653536313234313939305f62000000000000326632613138653330623533633632365f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fa000000000000000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 303064613662653536313234313939305f62000000000000323664356165373235633964306264375f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fa000000000000000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 2a0d8f4680281390_b 0
|
||||
S d147e21cbc820772_b 1
|
||||
S ec7ab6f7041d3dd8_b 0
|
||||
S 9d0e6650dcee931c_b 1
|
||||
S d1c50a68ed5a4c2b_b 0
|
||||
S ffa1003fd7d94c19_b 1
|
||||
R 326130643866343638303238313339305f62000000000000643134376532316362633832303737325f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e0000002e0000082e00001016000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000010000000000000001000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 656337616236663730343164336464385f62000000000000396430653636353064636565393331635f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e0000002e0000082e00001016000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000010000000000000001000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 643163353061363865643561346332625f62000000000000666661313030336664376439346331395f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e0000002e0000082e00001016000018160000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000010000000000000001000000000000000080000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 46ac23df6139630d_b 0
|
||||
S 4912ef6a3d3fd770_b 1
|
||||
R 343661633233646636313339363330645f62000000000000343931326566366133643366643737305f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002e0000002e0000082e0000101600001800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000001000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
S 1f752fd6f02d54bf_b 1
|
||||
R 366463346166623436643936626336365f62000000000000316637353266643666303264353462665f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002e00000000000000000000001600000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
R 643565616566353538306539356235635f62000000000000393534323331373465363534303835645f6200000000000000010101010f000000020301ffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000000000000ffffffff000000001004048104000000090c028504000000120804820400000013040481040000001404048104000000150404810400000016040481040000001704048104000000220000000000000000000000162800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff00ffffffff0000000000000000
|
||||
S 6a4347e473cc751b_b 1
|
||||
R 353463393366613232616266663965655f62000000000000366134333437653437336363373531625f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 44e41de8108725b1_b 1
|
||||
S 40e6a1e73082d7c8_b 1
|
||||
S a0c341d1743322bb_b 1
|
||||
S 525ad1193849d94c_b 1
|
||||
R 353466373330613663306566633131385f62000000000000666262333330333635643366353366665f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 336465616636386664363562353239385f62000000000000393439343935363730343932663265345f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000000000000ffffffff00000000100404810400000011040481040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000000000000000000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000343465343164653831303837323562315f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 336465616636386664363562353239385f62000000000000356561356566326633653865383133355f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000000000000ffffffff00000000100404810400000011040481040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000000000000000000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000343065366131653733303832643763385f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000613063333431643137343333323262625f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 353463393366613232616266663965655f62000000000000353235616431313933383439643934635f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000025080000270c0000261000002614000011180000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 303431363065343432623162616236645f62000000000000336662383931396666366566396462325f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000000000000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S cd9aa82ceb6746c6_b 1
|
||||
R 303064613662653536313234313939305f62000000000000636439616138326365623637343663365f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000fa000000000000000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S fa85525dc10e694b_b 0
|
||||
S 6164a15e85a4298c_b 0
|
||||
S 5f5438069d94ed61_b 1
|
||||
R 666138353532356463313065363934625f620000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363136346131356538356134323938635f62000000000000356635343338303639643934656436315f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000040100000100000000000000ffffffff00000000100404810400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b00000026080000260c000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S a199c4d81cd1d22b_b 0
|
||||
S 031add7213cfbffe_b 1
|
||||
R 613139396334643831636431643232625f62000000000000303331616464373231336366626666655f62000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073000000460000005c0000005c0000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000001208048204000000130404810400000014040481040000001504048104000000160404810400000017040481040000002e0000002e0000082e0000101600001816000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000001000000000000000100000000000000008000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffffffff0000000000000000
|
||||
S 25299715e6687a28_b 0
|
||||
S 1f2749847659cbcb_b 1
|
||||
R 323532393937313565363638376132385f62000000000000316632373439383437363539636263625f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
S 95b2624368e1b442_b 0
|
||||
S eafb083540b56169_b 1
|
||||
R 393562323632343336386531623434325f62000000000000656166623038333534306235363136395f6200000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000000000000000000000000000000000000000004010000000000000100000001000000ffffffff00000000100804820400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
R 363066333937636161356538623035375f62000000000000383837346332333933366663326133395f620000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000730000004600000000000000000000000000000000000000000000000000000004010000040100000100000003000000ffffffff000000001008048204000000090c0286040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e000000000000000000000016000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
|
@@ -0,0 +1,63 @@
|
||||
// 私有原游戏检查器:同帧初态→候选→恢复初态→原双pass;仅验证已观测outline/billboard,不进普通构建。
|
||||
// Private checker for the original game: same-frame initial state → candidate → restore initial state → original two passes; only verifies the observed outline/billboard, not part of normal builds.
|
||||
typedef struct { typeof(S) s; typeof(R) r; tex_t c,d; p_draw dw; p_draw_idx di; int indexed; } rr_snapshot;
|
||||
static rr_snapshot g_rr_s[2];
|
||||
static int g_rr_active,g_rr_n,g_rr_bad,g_rr_first_fresh,g_rr_resets;
|
||||
static id<MTLBuffer> g_rr_vis[2],g_rr_before,g_rr_before_vis;static int g_rr_slot[2],g_rr_before_slot,g_rr_use_before;
|
||||
static void rr_reset(void){if(g_rr_active&&!g_rr_checking){g_rr_resets++;if(g_rr_n!=1)g_rr_bad=1;}}
|
||||
static uint64_t g_rr_frame,g_rr_dirty,g_rr_load,g_rr_store,g_rr_reg,g_rr_ser;
|
||||
static id<MTLTexture> g_rr_initial[2];
|
||||
static tex_t g_rr_t[2];
|
||||
static void rr_copy(id<MTLTexture> a,id<MTLTexture> b) {
|
||||
[blit()copyFromTexture:a sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(0,0,0)sourceSize:MTLSizeMake(a.width,a.height,1)toTexture:b destinationSlice:0 destinationLevel:0 destinationOrigin:MTLOriginMake(0,0,0)];
|
||||
}
|
||||
static void rr_begin(void) {
|
||||
if(g_rr_checking||g_rr_active||!rt_range_on()||!getenv("DM_NVN_RT_RANGE_CHECK")||!passdump()||g_fz.active||!R.has_rt||R.rt.n!=1||!R.rt.depth||R.clear_c[0]||R.clear_d||R.clear_s)return;
|
||||
NvProg *p=prog_get(S.prog);if(!rt_range_pr_ro(p)||strcmp(p->sh[1]->key,"6d19a794f1206668_b")||!S.ds.dt||S.ds.dw||S.ds.st)return;
|
||||
p_set_rt b=R.rt;b.cview[0].nlevels=1;if(!rt_range_shape(&R.rt,&b)||R.rt.cview[0].base_level||R.rt.dview.base_level)return;
|
||||
id<MTLTexture> color=tex_mtl(R.rt.color[0]),depth=tex_mtl(R.rt.depth);
|
||||
if(color.pixelFormat!=MTLPixelFormatRG11B10Float||depth.pixelFormat!=MTLPixelFormatDepth32Float_Stencil8||color.width!=depth.width||color.height!=depth.height||color.sampleCount!=1||depth.sampleCount!=1)return;
|
||||
g_rr_t[0]=*R.rt.color[0];g_rr_t[1]=*R.rt.depth;
|
||||
for(int k=0;k<2;k++){id<MTLTexture> t=tex_mtl(&g_rr_t[k]);MTLTextureDescriptor *d=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:t.pixelFormat width:t.width height:t.height mipmapped:NO];d.storageMode=MTLStorageModePrivate;d.usage=MTLTextureUsageRenderTarget|MTLTextureUsageShaderRead;g_rr_initial[k]=[g_dev newTextureWithDescriptor:d];if(!g_rr_initial[k])abort();rr_copy(t,g_rr_initial[k]);}
|
||||
g_rr_frame=atomic_load(&g_cur_frame);g_rr_dirty=nvn_dirty_now();g_rr_load=g_bw_load;g_rr_store=g_bw_store;g_rr_first_fresh=g_vis_cur<0;g_rr_before_vis=g_vis;g_rr_before_slot=g_vis_cur;g_rr_use_before=0;g_rr_before=[g_dev newBufferWithLength:8 options:MTLResourceStorageModeShared];
|
||||
if(g_vis_cur>=0 && g_vis)[blit()copyFromBuffer:g_vis sourceOffset:g_vis_cur*8 toBuffer:g_rr_before destinationOffset:0 size:8];g_rr_resets=0;g_rr_vis[0]=g_rr_vis[1]=nil;g_rr_n=g_rr_bad=0;g_rr_active=1;
|
||||
}
|
||||
static void rr_snap(const p_draw *dw,const p_draw_idx *di) {
|
||||
if(!g_rr_active||g_rr_checking)return;if(g_rr_n>=2){g_rr_bad=1;return;}int k=g_rr_n;if(!k){g_rr_dirty=nvn_dirty_now();g_rr_reg=g_reg_gen;g_rr_ser=g_ser_gen;}else if(g_rr_reg!=g_reg_gen||g_rr_ser!=g_ser_gen)g_rr_bad=1;if(!k)g_rr_use_before=g_vis==g_rr_before_vis && g_vis_cur==g_rr_before_slot && g_vis_cur>=0;g_rr_vis[k]=(g_vis_on&&g_vis_counting&&g_vis_cur>=0)?g_vis:nil;g_rr_slot[k]=g_vis_cur;rr_snapshot *z=&g_rr_s[g_rr_n++];memcpy(&z->s,&S,sizeof S);z->r=R;z->c=*R.rt.color[0];z->d=*R.rt.depth;z->r.rt.color[0]=&z->c;z->r.rt.depth=&z->d;z->indexed=di!=NULL;if(dw)z->dw=*dw;if(di)z->di=*di;
|
||||
}
|
||||
static NSArray *rr_read(id<MTLTexture> c,id<MTLTexture> d) {
|
||||
NSUInteger w=c.width,h=c.height;id<MTLBuffer> a=[g_dev newBufferWithLength:w*h*4 options:MTLResourceStorageModeShared],b=[g_dev newBufferWithLength:w*h*4 options:MTLResourceStorageModeShared],e=[g_dev newBufferWithLength:w*h options:MTLResourceStorageModeShared];
|
||||
[blit()copyFromTexture:c sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(0,0,0)sourceSize:MTLSizeMake(w,h,1)toBuffer:a destinationOffset:0 destinationBytesPerRow:w*4 destinationBytesPerImage:w*h*4];
|
||||
[blit()copyFromTexture:d sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(0,0,0)sourceSize:MTLSizeMake(w,h,1)toBuffer:b destinationOffset:0 destinationBytesPerRow:w*4 destinationBytesPerImage:w*h*4 options:MTLBlitOptionDepthFromDepthStencil];
|
||||
[blit()copyFromTexture:d sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(0,0,0)sourceSize:MTLSizeMake(w,h,1)toBuffer:e destinationOffset:0 destinationBytesPerRow:w destinationBytesPerImage:w*h options:MTLBlitOptionStencilFromDepthStencil];return @[a,b,e];
|
||||
}
|
||||
static void rr_finish(int ranged) {
|
||||
if(!g_rr_active||g_rr_checking)return;g_rr_active=0;
|
||||
if(!ranged||g_rr_n!=2||g_rr_bad||g_rr_dirty!=nvn_dirty_now() || g_rr_reg!=g_reg_gen || g_rr_ser!=g_ser_gen || g_rr_resets!=1 || !g_rr_vis[0] || !g_rr_vis[1] || !g_rr_s[0].s.ds.dt || g_rr_s[0].s.ds.dw || g_rr_s[0].s.ds.st || !g_rr_s[1].s.ds.dt || g_rr_s[1].s.ds.dw || g_rr_s[1].s.ds.st){NSString *p=[@(getenv("DM_NVN_RT_RANGE_CHECK")) stringByAppendingPathComponent:@"SKIP.tsv"];FILE *f=fopen(p.UTF8String,"a");if(f){fprintf(f,"%llu\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n",(unsigned long long)g_rr_frame,ranged,g_rr_n,g_rr_bad,g_rr_dirty!=nvn_dirty_now(),g_rr_resets,g_rr_vis[0]!=nil,g_rr_vis[1]!=nil);fclose(f);}g_rr_initial[0]=g_rr_initial[1]=nil;return;}
|
||||
uint64_t candidate_bytes=g_bw_load-g_rr_load+g_bw_store-g_rr_store;
|
||||
g_rr_checking=1;typeof(S) ss;memcpy(&ss,&S,sizeof S);typeof(R) rs=R;const uint8_t *next=g_exec_next,*cur_op=g_exec_cur;
|
||||
uint64_t curpass=g_vis_cur_pass;int vis=g_vis_on,counting=g_vis_counting,cur=g_vis_cur,visn=g_vis_n,vsn=g_nvs,vscap=g_vscap;id<MTLBuffer> oldvis=g_vis;vis_slot *oldvs=g_vs;
|
||||
id<MTLBuffer> before=g_rr_before;int use_before=g_rr_use_before;NSArray *actualvis=@[g_rr_vis[0],g_rr_vis[1]];int slot0=g_rr_slot[0],slot1=g_rr_slot[1];uint64_t pass=g_stat_pass,draws=g_stat_draw,load=g_bw_load,store=g_bw_store,full=g_pass_full_rw,dead=g_sd_dead_bytes,ndead=g_sd_n_dead,nall=g_sd_n_all;
|
||||
id<MTLTexture> c=tex_mtl(&g_rr_t[0]),d=tex_mtl(&g_rr_t[1]);id<MTLTexture> saved[2];id<MTLTexture> source[2]={c,d};
|
||||
for(int k=0;k<2;k++){id<MTLTexture> t=source[k];MTLTextureDescriptor *td=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:t.pixelFormat width:t.width height:t.height mipmapped:NO];td.storageMode=MTLStorageModePrivate;td.usage=MTLTextureUsageRenderTarget|MTLTextureUsageShaderRead;saved[k]=[g_dev newTextureWithDescriptor:td];if(!saved[k])abort();rr_copy(t,saved[k]);}
|
||||
if(g_rr_reg!=g_reg_gen||g_rr_ser!=g_ser_gen)MDIE("RT范围oracle资源代号变化,提交前停止未比");
|
||||
NSArray *candidate=rr_read(c,d);rr_copy(g_rr_initial[0],c);rr_copy(g_rr_initial[1],d);g_vis=[g_dev newBufferWithLength:VIS_SLOTS*8 options:MTLResourceStorageModeShared];g_vis_n=0;g_vis_cur=-1;g_vis_on=g_vis_counting=1;g_vs=NULL;g_nvs=g_vscap=0;g_exec_next=g_exec_cur=NULL;
|
||||
id<MTLBuffer> refvis[2];int refslot[2];
|
||||
for(int i=0;i<2;i++){if(i)rp_end();g_vis_cur=-1;memcpy(&S,&g_rr_s[i].s,sizeof S);R=g_rr_s[i].r;g_pso_dirty=g_dss_dirty=1;rp_begin_ex(4); // 原trace两个pass均mode4,不以无扫描起点的mode0多挂模板 | In the original trace both passes are mode4; do not attach an extra stencil with mode0, which has no scan start point
|
||||
draw(g_rr_s[i].indexed?NULL:&g_rr_s[i].dw,g_rr_s[i].indexed?&g_rr_s[i].di:NULL);refvis[i]=g_vis;refslot[i]=g_vis_cur;}rp_end();
|
||||
uint64_t original_passes=g_stat_pass-pass,original_bytes=g_bw_load-load+g_bw_store-store;NSArray *reference=rr_read(c,d);
|
||||
if(g_rr_reg!=g_reg_gen||g_rr_ser!=g_ser_gen||g_rr_dirty!=nvn_dirty_now())MDIE("RT范围oracle绑定期间资源/数据代号变化,提交前停止未比");
|
||||
rr_copy(saved[0],c);rr_copy(saved[1],d); // 后继命令读取candidate,不能由oracle覆盖凑截图绿 | Subsequent commands read the candidate; the oracle must not overwrite it to force the screenshot green
|
||||
NSArray *referencevis=@[refvis[0],refvis[1]];int refslot0=refslot[0],refslot1=refslot[1];vis_clear();free(g_vs);g_vs=oldvs;g_nvs=vsn;g_vscap=vscap;g_vis=oldvis;g_vis_n=visn;
|
||||
memcpy(&S,&ss,sizeof S);R=rs;g_exec_next=next;g_exec_cur=cur_op;g_vis_on=vis;g_vis_counting=counting;g_vis_cur=cur;g_vis_cur_pass=curpass;g_pso_dirty=g_dss_dirty=1;g_stat_pass=pass;g_stat_draw=draws;g_bw_load=load;g_bw_store=store;g_pass_full_rw=full;g_sd_dead_bytes=dead;g_sd_n_dead=ndead;g_sd_n_all=nall;
|
||||
uint64_t frame=g_rr_frame;unsigned vc=g_rr_s[1].indexed?g_rr_s[1].di.count:g_rr_s[1].dw.count;NSUInteger n=c.width*c.height;NSString *out=@(getenv("DM_NVN_RT_RANGE_CHECK"));
|
||||
[g_cb addCompletedHandler:^(id<MTLCommandBuffer> cb){unsigned long long diff[3]={0};
|
||||
unsigned long long av[2],rv[2];int as[2]={slot0,slot1},rs[2]={refslot0,refslot1};for(int k=0;k<2;k++){id<MTLBuffer> a=actualvis[k],r=referencevis[k];av[k]=((uint64_t *)a.contents)[as[k]];rv[k]=((uint64_t *)r.contents)[rs[k]];}if(use_before)av[0]-=*(uint64_t *)before.contents;const char *names[3]={"color","depth","stencil"};
|
||||
for(int k=0;k<3;k++){id<MTLBuffer> a=candidate[k],b=reference[k];size_t bp=k==2?1:4;for(NSUInteger j=0;j<n;j++)diff[k]+=memcmp((uint8_t *)a.contents+j*bp,(uint8_t *)b.contents+j*bp,bp)!=0;
|
||||
for(int m=0;m<2;m++){id<MTLBuffer> x=m?b:a;NSString *path=[NSString stringWithFormat:@"%@/F%llu_P%llu_%s_%s.raw",out,(unsigned long long)frame,(unsigned long long)pass,m?"reference":"candidate",names[k]];FILE *f=fopen(path.UTF8String,"wb");if(!f||fwrite(x.contents,1,n*bp,f)!=n*bp)MLOG("【红】RT范围检查raw写盘失败 %s",path.UTF8String);if(f)fclose(f);}}
|
||||
NSString *qp=[out stringByAppendingPathComponent:@"QUERY_RESULTS.tsv"];FILE *qf=fopen(qp.UTF8String,"a");if(qf){fprintf(qf,"%llu\t%llu\t%llu\t%llu\t%llu\t%llu\n",(unsigned long long)frame,(unsigned long long)pass,rv[0],rv[1],av[0],av[1]);fclose(qf);}else MLOG("【红】RT范围query写盘失败");
|
||||
NSString *result=[out stringByAppendingPathComponent:@"CHECK_RESULTS.tsv"];FILE *rf=fopen(result.UTF8String,"a");if(rf){fprintf(rf,"%llu\t%llu\t%u\t%llu\t1\t%llu\t%llu\t%llu\t%llu\t%llu\t%lu\t%lu\n",(unsigned long long)frame,(unsigned long long)pass,vc,(unsigned long long)original_passes,(unsigned long long)original_bytes,(unsigned long long)candidate_bytes,diff[0],diff[1],diff[2],(unsigned long)n,(unsigned long)cb.status);fclose(rf);}else MLOG("【红】RT范围结果写盘失败");
|
||||
MLOG("%sRT范围query F%llu P%llu 原=%llu,%llu 候选=%llu,%llu",av[0]!=rv[0]||av[1]!=rv[1]?"【红】":"",(unsigned long long)frame,(unsigned long long)pass,rv[0],rv[1],av[0],av[1]);
|
||||
MLOG("%sRT范围双渲染 F%llu P%llu vc=%u 原pass=%llu 候选pass=1 原模型=%llu 候选模型=%llu diff=%llu,%llu,%llu/%lu CB=%lu",diff[0]||diff[1]||diff[2]?"【红】":"",(unsigned long long)frame,(unsigned long long)pass,vc,(unsigned long long)original_passes,(unsigned long long)original_bytes,(unsigned long long)candidate_bytes,diff[0],diff[1],diff[2],(unsigned long)n,(unsigned long)cb.status);
|
||||
}];g_rr_initial[0]=g_rr_initial[1]=nil;g_rr_checking=0;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,17 @@
|
||||
# kind: evidence Switch 控制段键冲突的 PC 候选裁定(差异最小 → 最简 → 哈希最小)
|
||||
dm_ctl_sha16 chosen_pc class candidates(pc:差异:规模) records
|
||||
170d711cb0290746 67c858efc3fcf781 指令块不同(真实代码差异,Switch 编成同一二进制;需运行期定位包与序号或画面确认) 67c858efc3fcf781:4:31 83bb2ed8030f2e5b:4:31 ps_hair_p.bin#8 ps_hair_p.bin#10
|
||||
228ac21b01ac8272 261a6029b87a3a5b 指令块等长·输入签名不同(疑为输入寄存器重编号,同按配对选) 261a6029b87a3a5b:1:3 72e75628cab4e60a:1:3 7ca2c6b7e4d55e50:1:3 vs_popcorn_liquid_mesh_depth_v.bin#0 vs_popcorn_liquid_mesh_depth_v.bin#2 vs_popcorn_uber_mesh_depth_v.bin#0 vs_popcorn_uber_mesh_depth_v.bin#8
|
||||
463d9e09323caaca f3334e2447570533 指令块相同·仅输入签名不同(建管线时按顶点着色器输出配对选) f3334e2447570533:0:1 f3e1146daf6518c4:0:1 ps_models_hash_p.bin#0 ps_quad_efficiency_collect_p.bin#0
|
||||
60ff01e8ae40e485 3ac2e99eac3c9cb8 指令块等长·输入签名不同(疑为输入寄存器重编号,同按配对选) 3ac2e99eac3c9cb8:2:4 3c63926eff1b340d:2:4 vs_popcorn_uber_mesh_depth_v.bin#1 vs_popcorn_uber_mesh_depth_v.bin#9
|
||||
618342d86ec36c81 48611265537b4bf7 指令块不同(真实代码差异,Switch 编成同一二进制;需运行期定位包与序号或画面确认) 48611265537b4bf7:0:9 51de8ea74df55fd8:0:9 ps_compose_p.bin#2 ps_compose_p.bin#5
|
||||
62d3197aa02247ed ecba1a74eda4d42a 指令块等长·输入签名不同(疑为输入寄存器重编号,同按配对选) ecba1a74eda4d42a:2:4 fe107f2746969f21:2:4 vs_popcorn_mesh_depth_v.bin#1 vs_popcorn_mesh_depth_v.bin#9 vs_popcorn_stencil_v.bin#5
|
||||
63616a06a1ccd034 af002517ae365cc4 指令块不同(真实代码差异,Switch 编成同一二进制;需运行期定位包与序号或画面确认) af002517ae365cc4:4:30 f361d09d2f890138:4:30 ps_hair_p.bin#2 ps_hair_p.bin#4
|
||||
74afe0c274ac090e 4a053d52b1e635c7 指令块相同·仅输入签名不同(建管线时按顶点着色器输出配对选) 4a053d52b1e635c7:0:2 50f10bae0d377115:0:2 a51dd28f80e80687:0:2 ps_popcorn_default_p.bin#144 ps_popcorn_default_p.bin#146 ps_popcorn_default_p.bin#147 ps_popcorn_default_p.bin#149 ps_popcorn_default_p.bin#150 ps_popcorn_default_p.bin#152 ps_popcorn_default_p.bin#153 ps_popcorn_default_p.bin#156 ps_popcorn_default_p.bin#159
|
||||
7bf4832d3985c501 15b71014e328ab75 指令块相同·仅输入签名不同(建管线时按顶点着色器输出配对选) 15b71014e328ab75:0:2 b674a0db47d3629b:0:2 ps_alpha_threshold_velocity_p.bin#0 ps_alpha_threshold_velocity_p.bin#2 ps_models_velocity_p.bin#0
|
||||
7fbab804c6ba3dcf 506653c87391b685 指令块相同·仅输入签名不同(建管线时按顶点着色器输出配对选) 506653c87391b685:0:4 6510fa008b8bc356:0:4 vs_models_grass_force_v.bin#2 vs_models_grass_force_v.bin#3
|
||||
949495670492f2e4 6f571a39533eb2d8 指令块相同·仅输入签名不同(建管线时按顶点着色器输出配对选) 6f571a39533eb2d8:0:0 bb1e231e80b4442f:0:0 be1975491388c4ac:0:0 ps_alpha_threshold_shadows_p.bin#0 ps_alpha_threshold_shadows_p.bin#2 ps_models_shadows_p.bin#0 ps_popcorn_stencil_p.bin#0
|
||||
9a650561e5c40791 07e14c16200e4132 指令块不同(真实代码差异,Switch 编成同一二进制;需运行期定位包与序号或画面确认) 07e14c16200e4132:1:7 263766e5cd512650:1:7 ps_compose_p.bin#1 ps_compose_p.bin#4
|
||||
b2ee08eed36b3efd 69a41eaba6863a1f 指令块相同·仅输入签名不同(建管线时按顶点着色器输出配对选) 69a41eaba6863a1f:0:2 88e11d6d09d2fd24:0:2 e3efadc299b11545:0:2 ps_popcorn_default_p.bin#180 ps_popcorn_default_p.bin#182 ps_popcorn_default_p.bin#183 ps_popcorn_default_p.bin#185 ps_popcorn_default_p.bin#186 ps_popcorn_default_p.bin#188 ps_popcorn_default_p.bin#189 ps_popcorn_default_p.bin#192 ps_popcorn_default_p.bin#195
|
||||
b76211745124af86 74ebc67ee92d1734 指令块相同·仅输入签名不同(建管线时按顶点着色器输出配对选) 74ebc67ee92d1734:0:3 ff60ddad549824e0:0:3 vs_models_grass_force_v.bin#0 vs_models_grass_force_v.bin#1
|
||||
fa85525dc10e694b 238ad1aaa8a95fb8 指令块等长·输入签名不同(疑为输入寄存器重编号,同按配对选) 238ad1aaa8a95fb8:1:3 7570b0b80b9e81fa:1:3 vs_popcorn_mesh_depth_v.bin#0 vs_popcorn_mesh_depth_v.bin#8 vs_popcorn_stencil_v.bin#1
|
||||
|
@@ -0,0 +1,78 @@
|
||||
# NVN → Metal object mapping
|
||||
|
||||
中文:[nvn_metal_mapping.zh-CN.md](nvn_metal_mapping.zh-CN.md)
|
||||
|
||||
This document lists what each kind of NVN (the Switch's native graphics interface) object and command lands on in Metal within D2R Mobile's graphics layer. For the overall structure of the graphics layer see [README.md](README.md).
|
||||
|
||||
Scope: the 216 NVN functions that have call sites in the game's main program (listed in `nvn/nvn_slots.tsv`). The remaining 307 are connected to a red-reporting stub that, when called, prints `【红】NVN 未实现被调用:名字` in the log ("[red] unimplemented NVN function called: name").
|
||||
|
||||
Two conventions that run through the whole table:
|
||||
|
||||
- **GPU address = CPU address**. NVN memory pools use memory the game allocates itself, and the graphics layer creates zero-copy Metal buffers on that same memory. Any buffer address the game passes in is looked up in the memory pools' interval table and turned into "which `MTLBuffer` + offset" (`mtl_addr()`).
|
||||
- **Record first, replay later**. Command buffer calls only write records into the command memory provided by the game (for the format see `nvn/nvn_obj.h`); only at submit time does `nvn/nvn_mtl.m` replay them as Metal commands.
|
||||
|
||||
## 1. Objects
|
||||
|
||||
| NVN object | Metal implementation | Key points |
|
||||
|---|---|---|
|
||||
| Device | `MTLDevice` (unified memory required) | The device properties returned by `nvnDeviceGetInteger` are still given to the game with the Tegra X1's values (`g_devinfo` in `hle_nvn.c`) |
|
||||
| MemoryPool | `newBufferWithBytesNoCopy` on game memory | Pages on Apple silicon are 16 KiB and pools are not guaranteed to be aligned to that: the start is rounded down and the end rounded up to page boundaries before the buffer is created, and the buffers of adjacent pools are allowed to overlap (`mtl_pool_add()`; the approach is verified by `metal/probe/p_nocopy.m`) |
|
||||
| Buffer address (`NVNbufferAddress`) | (`MTLBuffer`, offset) | Looked up in the pools' interval table |
|
||||
| Texture | `MTLTexture` | The game's packaged textures are in block-linear layout and are deswizzled at upload; format mapping and deswizzling are in `tex/`. After the game rewrites pool memory the texture is uploaded again, which is detected by the write-protection dirty page tracking of `nvn/nvn_dirty.c`. `ReadTexels`: packaged textures are deswizzled and read directly from pool memory, and textures written by the GPU are read back from the `MTLTexture` |
|
||||
| TextureView | `newTextureViewWithPixelFormat:textureType:levels:slices:` | — |
|
||||
| Sampler | `MTLSamplerState` | For border color Metal has only three presets (transparent black, opaque black, opaque white); the nearest one to the border color NVN gives is chosen |
|
||||
| TexturePool / SamplerPool | A host-side table: descriptor number → texture / sampler | The value of a separate texture handle is the descriptor number |
|
||||
| Program | One `MTLFunction` per stage | Keyed by the hash of the shader's control section and loaded from the offline-translated `<key>_b.metallib`; nothing is translated at run time. For the translation chain see the README |
|
||||
| State objects (Blend / Color / ChannelMask / Multisample / Polygon / DepthStencil / VertexAttrib / VertexStream) | Fields of the render pipeline descriptor + `MTLDepthStencilState` + encoder state | The game copies these small structures by value, and the host side packs them in place with bit fields. Render pipelines and depth-stencil states are cached by state hash |
|
||||
| CommandBuffer | A record stream recorded in the game's command memory | Replayed at submit time |
|
||||
| Queue | Metal command queue | `SubmitCommands` = replay and submit |
|
||||
| Sync | The fence value of a submission | `FenceSync` records the fence value of the most recent submission; `SyncWait` lets the caller through only after the GPU has actually completed up to that value (the completed value of an `MTLSharedEvent`). Waiting on a sync object that was never fenced returns a timeout directly |
|
||||
| Event | A 32-bit value in game memory | The value is written after the GPU completes |
|
||||
| Window | The game's own swapchain textures ↔ `CAMetalLayer` | `AcquireTexture` returns the index of a swapchain texture, and the wait for vertical sync happens here; `QueuePresentTexture` only puts the presentation into a queue and returns immediately, and the presentation thread draws that texture onto the drawable using the crop region given by `WindowSetCrop` |
|
||||
|
||||
## 2. Commands
|
||||
|
||||
| NVN command | Metal | Notes |
|
||||
|---|---|---|
|
||||
| SetRenderTargets | Ends the current render encoder and opens a new render pass | Clears before the first command in the pass are folded into the attachment's load action (load = Clear) |
|
||||
| ClearColor / ClearDepthStencil | Same as above | Clears in the middle of a pass, and color clears with a partial mask or partial scissor, are not implemented and report red when encountered |
|
||||
| ClearTexture / ClearTextureui | Clears one texture on its own | Some forms are not implemented and report red when encountered |
|
||||
| BindProgram and the various state Bind* calls | Recorded into the current state; the pipeline is fetched as needed before the next draw | — |
|
||||
| BindUniformBuffer(s) / BindStorageBuffer(s) / BindSeparateTextures / BindSeparateSamplers / BindImages | Fills the argument buffer according to the shader's reflection json | For how slot numbers correspond to the constant sections in the shader see "Shader translation chain" in the README |
|
||||
| BindVertexBuffers | Vertex buffer = (`MTLBuffer`, offset) | — |
|
||||
| SetViewports / SetScissor / SetDepthRange / Stencil* / SetBlendColor / SetPolygonOffsetClamp | The corresponding setting on the encoder | — |
|
||||
| DrawArrays / DrawElementsInstanced | Draw / indexed draw | Metal has no quad primitive: non-indexed quads are drawn as two triangles using the shared indices 0,1,2,0,2,3; indexed quads and 8-bit indices are not implemented and report red when encountered |
|
||||
| DispatchCompute | Compute encoder, with the thread group size taken from the reflection json | The 4 compute shaders embedded in the main program use the hand-written versions in `nvn/nvn_builtin.h` |
|
||||
| CopyBufferToBuffer / UpdateUniformBuffer | Buffer copies inserted in order into the command stream | The data of `UpdateUniformBuffer` is copied into command memory at record time, because NVN allows the caller to modify the original data after recording |
|
||||
| CopyBufferToTexture / CopyTextureToBuffer / CopyTextureToTexture | Texture copies | Some forms of texture-to-texture are not implemented and report red when encountered |
|
||||
| ReportCounter / ResetCounter | The counter's value is written back after the GPU completes | The "samples passed" kind is implemented with Metal's visibility result buffer |
|
||||
| SignalEvent | The event's value is written, which happens after the GPU completes | — |
|
||||
| SetTexturePool / SetSamplerPool | Recorded into the command stream, noting the descriptor pool currently in use | — |
|
||||
|
||||
The following are empty implementations (`g_nops` in `hle_nvn.c`); calling them neither reports red nor has any effect:
|
||||
|
||||
`SetPatchSize`, `MultiDrawArraysIndirectCount`, `MultiDrawElementsIndirectCount`, `DispatchComputeIndirect`, `SetDepthBounds`, `DownsampleTextureView`, `WaitSync`, `SetShaderScratchMemory`, `PushDebugGroupDynamic`, `PopDebugGroup`, `InsertDebugMarkerDynamic`, `WaitEvent`, and `nvnWindowFinalize`.
|
||||
|
||||
## 3. Shader bindings
|
||||
|
||||
Switch shaders obtain their resources through a few constant sections maintained by the driver, and during replay the graphics layer fills the same contents into Metal's argument buffer. Each binding in the reflection json carries a kind (`NVN_RB_*` in `nvn/nvn_refl.h`):
|
||||
|
||||
| Kind | Meaning |
|
||||
|---|---|
|
||||
| `CBUF` | uniform buffer slot r |
|
||||
| `TEX` / `SAMP` / `SAMPT` | Separate texture slot, separate sampler slot; `SAMPT` means the sampler is taken from the combined handle of the texture slot |
|
||||
| `IMG` | Writable texture (image slot) |
|
||||
| `TBUF` | Typed buffer (buffer texture) |
|
||||
| `SBUFP` | Device pointer of a storage buffer slot |
|
||||
| `UBOP` | Device pointer of a compute-stage uniform slot |
|
||||
| `C1` | The shader's built-in constant section |
|
||||
| `DRV0` / `DRV2` | The driver constant sections c[0] (storage buffer address table) and c[2] (texture and sampler handle table), filled in on the spot by the replay layer according to the current bindings |
|
||||
| `SUPPORT` | Auxiliary constants used by the translator itself |
|
||||
|
||||
A texture slot with nothing bound is given a dummy texture, whose type and pixel class are taken from the reflection.
|
||||
|
||||
## 4. Adding a function that is not implemented yet
|
||||
|
||||
1. In `nvn/hle_nvn.c`, write the implementation with the `NVN(name, return type, parameters…)` macro. The macro does a signature check against `nvn/nvn_protos.h` and registers the implementation in the slot table; if the name is not in `nvn/names.txt`, the program aborts at startup.
|
||||
2. If it is a command: add the record format in `nvn/nvn_obj.h`, write the recording in `hle_nvn.c`, and write the replay in `nvn/nvn_mtl.m`.
|
||||
3. Add a test in `tests/`, then `make -C dm/gfx/tests run`.
|
||||
@@ -0,0 +1,78 @@
|
||||
# NVN → Metal 对象映射
|
||||
|
||||
English: [nvn_metal_mapping.md](nvn_metal_mapping.md)
|
||||
|
||||
这份文档列出 NVN(Switch 的原生图形接口)的各类对象与命令,在 D2R Mobile 的图形层里分别落到 Metal 的什么上。图形层的整体结构见 [README.zh-CN.md](README.zh-CN.md)。
|
||||
|
||||
范围:游戏主程序里有调用点的 216 个 NVN 函数(清单在 `nvn/nvn_slots.tsv`)。其余 307 个接报红桩,被调到时日志打印 `【红】NVN 未实现被调用:名字`。
|
||||
|
||||
两条贯穿全表的约定:
|
||||
|
||||
- **GPU 地址 = CPU 地址**。NVN 的内存池用的是游戏自己分配的内存,图形层在同一段内存上建零拷贝的 Metal 缓冲。游戏传来的任何缓冲地址,都用内存池的区间表反查成「哪个 `MTLBuffer` + 偏移」(`mtl_addr()`)。
|
||||
- **先录后放**。命令缓冲的调用只是把记录写进游戏提供的命令内存(格式见 `nvn/nvn_obj.h`),到提交时才由 `nvn/nvn_mtl.m` 回放成 Metal 命令。
|
||||
|
||||
## 1. 对象
|
||||
|
||||
| NVN 对象 | Metal 实现 | 要点 |
|
||||
|---|---|---|
|
||||
| Device | `MTLDevice`(要求统一内存) | `nvnDeviceGetInteger` 返回的设备属性仍按 Tegra X1 的值给游戏(`hle_nvn.c` 的 `g_devinfo`) |
|
||||
| MemoryPool | 游戏内存上的 `newBufferWithBytesNoCopy` | 苹果芯片的页是 16 KiB,池不保证按它对齐:起点向下、终点向上取整到页边界再建缓冲,相邻池的缓冲允许重叠(`mtl_pool_add()`;做法由 `metal/probe/p_nocopy.m` 验证) |
|
||||
| 缓冲地址(`NVNbufferAddress`) | (`MTLBuffer`, 偏移) | 按池的区间表反查 |
|
||||
| Texture | `MTLTexture` | 游戏打包贴图是块线性排布,上传时解排布;格式映射与解排布在 `tex/`。池内存被游戏改写后重新上传,靠 `nvn/nvn_dirty.c` 的写保护脏页跟踪发现。`ReadTexels`:打包贴图直接从池内存解排布读,GPU 写出的贴图从 `MTLTexture` 读回 |
|
||||
| TextureView | `newTextureViewWithPixelFormat:textureType:levels:slices:` | — |
|
||||
| Sampler | `MTLSamplerState` | 边框色 Metal 只有三种预设(透明黑、不透明黑、不透明白),按 NVN 给的边框色就近取 |
|
||||
| TexturePool / SamplerPool | 宿主侧的表:描述符号 → 贴图 / 采样器 | 分离贴图句柄的值就是描述符号 |
|
||||
| Program | 每个阶段一个 `MTLFunction` | 以着色器控制段的哈希为键,从离线翻译好的 `<键>_b.metallib` 加载;运行时不翻译。翻译链见 README |
|
||||
| 状态对象(Blend / Color / ChannelMask / Multisample / Polygon / DepthStencil / VertexAttrib / VertexStream) | 渲染管线描述符的字段 + `MTLDepthStencilState` + 编码器状态 | 游戏按值拷贝这些小结构,宿主侧用位域就地打包。渲染管线、深度模板状态按状态哈希缓存 |
|
||||
| CommandBuffer | 录在游戏命令内存里的记录流 | 提交时回放 |
|
||||
| Queue | Metal 命令队列 | `SubmitCommands` = 回放并提交 |
|
||||
| Sync | 提交的栅栏值 | `FenceSync` 记下最近一次提交的栅栏值;`SyncWait` 只在 GPU 真正完成到该值之后放行(`MTLSharedEvent` 的已完成值)。没围栏过的同步对象等待直接返回超时 |
|
||||
| Event | 游戏内存里的一个 32 位值 | 写值在 GPU 完成之后发生 |
|
||||
| Window | 游戏自己的交换链贴图 ↔ `CAMetalLayer` | `AcquireTexture` 返回交换链贴图的下标,垂直同步的等待发生在这里;`QueuePresentTexture` 只把出图排进队列立即返回,由出图线程把该贴图按 `WindowSetCrop` 给的裁切区画到 drawable 上 |
|
||||
|
||||
## 2. 命令
|
||||
|
||||
| NVN 命令 | Metal | 说明 |
|
||||
|---|---|---|
|
||||
| SetRenderTargets | 结束当前渲染编码器,开新的渲染通道 | 通道里第一条命令之前的清除并进附件的读入动作(load = Clear) |
|
||||
| ClearColor / ClearDepthStencil | 同上 | 通道中途的清除、带部分掩码或部分剪裁的清色没有实现,遇到报红 |
|
||||
| ClearTexture / ClearTextureui | 单独清一张贴图 | 部分形态没有实现,遇到报红 |
|
||||
| BindProgram 与各状态 Bind* | 记进当前状态,下一次绘制前按需取管线 | — |
|
||||
| BindUniformBuffer(s) / BindStorageBuffer(s) / BindSeparateTextures / BindSeparateSamplers / BindImages | 按着色器的反射 json 填参数缓冲(argument buffer) | 槽号与着色器里常量段的对应见 README「着色器翻译链」 |
|
||||
| BindVertexBuffers | 顶点缓冲 = (`MTLBuffer`, 偏移) | — |
|
||||
| SetViewports / SetScissor / SetDepthRange / Stencil* / SetBlendColor / SetPolygonOffsetClamp | 编码器上对应的设置 | — |
|
||||
| DrawArrays / DrawElementsInstanced | 绘制 / 带索引绘制 | Metal 没有四边形图元:不带索引的四边形用共享的索引 0,1,2,0,2,3 画成两个三角形;带索引的四边形、8 位索引没有实现,遇到报红 |
|
||||
| DispatchCompute | 计算编码器,线程组大小取反射 json | 主程序内嵌的 4 个计算着色器用 `nvn/nvn_builtin.h` 里手写的版本 |
|
||||
| CopyBufferToBuffer / UpdateUniformBuffer | 命令流里按序插入的缓冲拷贝 | `UpdateUniformBuffer` 的数据在录制时就拷进命令内存,因为 NVN 允许调用方录完后改原数据 |
|
||||
| CopyBufferToTexture / CopyTextureToBuffer / CopyTextureToTexture | 贴图拷贝 | 贴图到贴图的部分形态没有实现,遇到报红 |
|
||||
| ReportCounter / ResetCounter | 计数器的值在 GPU 完成之后写回 | 「通过采样数」这一类用 Metal 的可见性结果缓冲实现 |
|
||||
| SignalEvent | 事件写值,GPU 完成之后发生 | — |
|
||||
| SetTexturePool / SetSamplerPool | 录进命令流,记下当前用的描述符池 | — |
|
||||
|
||||
下面这些是空实现(`hle_nvn.c` 的 `g_nops`),调用不报红也不产生效果:
|
||||
|
||||
`SetPatchSize`、`MultiDrawArraysIndirectCount`、`MultiDrawElementsIndirectCount`、`DispatchComputeIndirect`、`SetDepthBounds`、`DownsampleTextureView`、`WaitSync`、`SetShaderScratchMemory`、`PushDebugGroupDynamic`、`PopDebugGroup`、`InsertDebugMarkerDynamic`、`WaitEvent`,以及 `nvnWindowFinalize`。
|
||||
|
||||
## 3. 着色器绑定
|
||||
|
||||
Switch 的着色器通过驱动维护的几个常量段拿到资源,图形层在回放时把同样的内容填进 Metal 的参数缓冲。反射 json 里每个绑定带一个种类(`nvn/nvn_refl.h` 的 `NVN_RB_*`):
|
||||
|
||||
| 种类 | 含义 |
|
||||
|---|---|
|
||||
| `CBUF` | uniform 缓冲槽 r |
|
||||
| `TEX` / `SAMP` / `SAMPT` | 分离贴图槽、分离采样器槽;`SAMPT` 表示采样器取自贴图槽的合并句柄 |
|
||||
| `IMG` | 可写贴图(图像槽) |
|
||||
| `TBUF` | 类型化缓冲(缓冲贴图) |
|
||||
| `SBUFP` | 存储缓冲槽的设备指针 |
|
||||
| `UBOP` | 计算阶段 uniform 槽的设备指针 |
|
||||
| `C1` | 着色器自带的常数段 |
|
||||
| `DRV0` / `DRV2` | 驱动常量段 c[0](存储缓冲地址表)与 c[2](贴图、采样器句柄表),由回放层按当前绑定现填 |
|
||||
| `SUPPORT` | 翻译器自己用的辅助常量 |
|
||||
|
||||
没有绑定的贴图槽给一张哑贴图,类型与像素类别取自反射。
|
||||
|
||||
## 4. 加一个还没实现的函数
|
||||
|
||||
1. 在 `nvn/hle_nvn.c` 里用 `NVN(名字, 返回类型, 参数…)` 宏写实现。宏会按 `nvn/nvn_protos.h` 做签名检查,并把实现登记进槽表;名字不在 `nvn/names.txt` 里启动即中止。
|
||||
2. 如果是命令:在 `nvn/nvn_obj.h` 里加记录格式,录制写在 `hle_nvn.c`,回放写在 `nvn/nvn_mtl.m`。
|
||||
3. 在 `tests/` 里加测试,`make -C dm/gfx/tests run`。
|
||||
@@ -0,0 +1,43 @@
|
||||
t_nvn
|
||||
t_nvn.dSYM/
|
||||
t_builtin
|
||||
t_deswz_gpu
|
||||
t_deswz_gpu.dSYM/
|
||||
t_builtin.dSYM/
|
||||
t_pace
|
||||
.precommit.err
|
||||
.precommit_snap/
|
||||
t_refl
|
||||
t_refl.dSYM
|
||||
t_hmap
|
||||
t_cover
|
||||
t_fuse_check
|
||||
t_fuse_check.dSYM/
|
||||
t_present_crop
|
||||
t_present_crop.dSYM/
|
||||
t_reorder_chain
|
||||
t_reorder_chain.dSYM/
|
||||
t_mip_extent
|
||||
t_mip_extent.dSYM/
|
||||
t_rt_range_shape
|
||||
t_rt_range_shape.dSYM/
|
||||
t_rt_range_ro
|
||||
t_rt_range_ro.dSYM/
|
||||
t_rt_range
|
||||
t_rt_range.dSYM/
|
||||
t_rt_depth_ro
|
||||
t_rt_depth_ro.dSYM/
|
||||
t_pso_skey
|
||||
t_pso_skey.dSYM/
|
||||
t_dirty_slots
|
||||
t_dirty_slots.dSYM/
|
||||
t_pfv
|
||||
t_pfv.dSYM/
|
||||
t_defer_chain
|
||||
t_defer_chain.dSYM/
|
||||
t_zskip
|
||||
t_zskip.dSYM/
|
||||
t_xv
|
||||
t_xv.dSYM/
|
||||
t_ub
|
||||
t_ub.dSYM/
|
||||
@@ -0,0 +1,84 @@
|
||||
# 单测:make 编译并运行(秒级)
|
||||
# 源文件按通配纳入,口径与宿主 Makefile 的 GFX 一致(hle_nvn.c 由 t_nvn.c 直接 #include,故剔除);新增源文件无需改这里
|
||||
# Unit tests: make compiles and runs them (seconds)
|
||||
# Source files are included by wildcard, same convention as GFX in the host Makefile (hle_nvn.c is #included directly by t_nvn.c, so it is excluded); adding new source files needs no change here
|
||||
CFLAGS=-O1 -g -Wall -Wno-unused-function -I../nvn/include
|
||||
GFX=$(filter-out ../nvn/hle_nvn.c,$(sort $(wildcard ../nvn/*.c ../nvn/*.m ../nvn/*.S ../tex/*.c ../tex/*.m)))
|
||||
GFX_H=$(wildcard ../nvn/*.h ../nvn/*.inc ../nvn/include/*.h ../tex/*.h)
|
||||
FW=-framework Metal -framework Foundation -framework QuartzCore -framework ImageIO -framework CoreGraphics -framework UniformTypeIdentifiers
|
||||
# 宿主 crash.c 一并链入:写保护单测走生产同一套缺页钩子
|
||||
# Host crash.c is linked in as well: the write-protect unit tests go through the same page-fault hook as production
|
||||
t_nvn: t_nvn.c ../nvn/hle_nvn.c ../../host/crash.c $(GFX) $(GFX_H)
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_nvn.c ../../host/crash.c $(GFX) $(FW)
|
||||
t_dirty_slots: t_dirty_slots.c ../nvn/nvn_dirty.c ../../host/crash.c ../nvn/nvn_dirty.h
|
||||
clang $(CFLAGS) -o $@ t_dirty_slots.c ../../host/crash.c ../nvn/nvn_dirty.c
|
||||
t_builtin: t_builtin.m ../nvn/nvn_builtin.h
|
||||
clang -O1 -g -Wall -fobjc-arc -o $@ t_builtin.m -framework Metal -framework Foundation
|
||||
t_deswz_gpu: t_deswz_gpu.m ../tex/nvn_deswizzle.c ../tex/nvn_deswizzle_gpu.m ../tex/nvn_deswizzle.h ../tex/nvn_deswizzle_gpu.h ../nvn/nvn_tex.c ../nvn/nvn_tex.h
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_deswz_gpu.m ../tex/nvn_deswizzle.c ../tex/nvn_deswizzle_gpu.m ../nvn/nvn_tex.c -framework Metal -framework Foundation
|
||||
t_refl: t_refl.m ../nvn/nvn_refl.m ../nvn/nvn_refl.h ../nvn/dmsh_chain.h
|
||||
clang -O1 -g -Wall -fobjc-arc -o $@ t_refl.m ../nvn/nvn_refl.m -framework Metal -framework Foundation
|
||||
t_hmap: t_hmap.c ../nvn/nvn_hmap.h
|
||||
clang -O1 -Wall -o $@ t_hmap.c
|
||||
t_cover: t_cover.c ../nvn/nvn_cover.h
|
||||
clang -O1 -Wall -o $@ t_cover.c
|
||||
t_pace: t_pace.c ../nvn/nvn_pace.h
|
||||
clang -O1 -Wall -o $@ t_pace.c
|
||||
t_fuse_check: t_fuse_check.m ../../host/crash.c $(GFX) $(GFX_H)
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_fuse_check.m ../../host/crash.c $(filter-out ../nvn/nvn_mtl.m ../nvn/nvn_entry.S ../nvn/nvn_thunks.S,$(GFX)) $(FW)
|
||||
t_present_crop: t_present_crop.m ../nvn/hle_nvn.c ../../host/crash.c $(GFX) $(GFX_H)
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_present_crop.m ../../host/crash.c $(filter-out ../nvn/nvn_mtl.m,$(GFX)) $(FW)
|
||||
t_reorder_chain: t_reorder_chain.m ../../host/crash.c $(GFX) $(GFX_H)
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_reorder_chain.m ../../host/crash.c $(filter-out ../nvn/nvn_mtl.m ../nvn/nvn_entry.S ../nvn/nvn_thunks.S,$(GFX)) $(FW)
|
||||
t_defer_chain: t_defer_chain.m ../../host/crash.c $(GFX) $(GFX_H)
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_defer_chain.m ../../host/crash.c $(filter-out ../nvn/nvn_mtl.m ../nvn/nvn_entry.S ../nvn/nvn_thunks.S,$(GFX)) $(FW)
|
||||
t_zskip: t_zskip.m ../../host/crash.c $(GFX) $(GFX_H)
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_zskip.m ../../host/crash.c $(filter-out ../nvn/nvn_mtl.m ../nvn/nvn_entry.S ../nvn/nvn_thunks.S,$(GFX)) $(FW)
|
||||
t_xv: t_xv.m ../../host/crash.c $(GFX) $(GFX_H)
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_xv.m ../../host/crash.c $(filter-out ../nvn/nvn_mtl.m ../nvn/nvn_entry.S ../nvn/nvn_thunks.S,$(GFX)) $(FW)
|
||||
t_ub: t_ub.m ../../host/crash.c $(GFX) $(GFX_H)
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_ub.m ../../host/crash.c $(filter-out ../nvn/nvn_mtl.m ../nvn/nvn_entry.S ../nvn/nvn_thunks.S,$(GFX)) $(FW)
|
||||
t_mip_extent: t_mip_extent.m ../nvn/hle_nvn.c ../../host/crash.c $(GFX) $(GFX_H)
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_mip_extent.m ../../host/crash.c $(filter-out ../nvn/nvn_mtl.m,$(GFX)) $(FW)
|
||||
t_rt_range_shape: t_rt_range_shape.m ../../host/crash.c $(GFX) $(GFX_H)
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_rt_range_shape.m ../../host/crash.c $(filter-out ../nvn/nvn_mtl.m ../nvn/nvn_entry.S ../nvn/nvn_thunks.S,$(GFX)) $(FW)
|
||||
t_rt_range_ro: t_rt_range_ro.m ../../host/crash.c $(GFX) $(GFX_H)
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_rt_range_ro.m ../../host/crash.c $(filter-out ../nvn/nvn_mtl.m ../nvn/nvn_entry.S ../nvn/nvn_thunks.S,$(GFX)) $(FW)
|
||||
t_rt_range: t_rt_range.m ../../host/crash.c $(GFX) $(GFX_H)
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_rt_range.m ../../host/crash.c $(filter-out ../nvn/nvn_mtl.m ../nvn/nvn_entry.S ../nvn/nvn_thunks.S,$(GFX)) $(FW)
|
||||
t_rt_depth_ro: t_rt_depth_ro.m ../../host/crash.c $(GFX) $(GFX_H)
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_rt_depth_ro.m ../../host/crash.c $(filter-out ../nvn/nvn_mtl.m ../nvn/nvn_entry.S ../nvn/nvn_thunks.S,$(GFX)) $(FW)
|
||||
t_pso_skey: t_pso_skey.m ../nvn/nvn_pso_skey.h ../nvn/nvn_obj.h
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_pso_skey.m -framework Foundation
|
||||
t_pfv: t_pfv.m ../../host/crash.c $(GFX) $(GFX_H)
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_pfv.m ../../host/crash.c $(filter-out ../nvn/nvn_mtl.m ../nvn/nvn_entry.S ../nvn/nvn_thunks.S,$(GFX)) $(FW)
|
||||
run: t_nvn t_dirty_slots t_builtin t_deswz_gpu t_pace t_refl t_hmap t_cover t_fuse_check t_present_crop t_reorder_chain t_defer_chain t_zskip t_xv t_ub t_mip_extent t_rt_range_shape t_rt_range_ro t_rt_range t_rt_depth_ro t_pso_skey t_pfv
|
||||
./t_nvn
|
||||
./t_dirty_slots
|
||||
./t_builtin
|
||||
./t_deswz_gpu
|
||||
./t_pace
|
||||
./t_refl
|
||||
./t_hmap
|
||||
./t_cover
|
||||
./t_fuse_check
|
||||
./t_present_crop
|
||||
MTL_DEBUG_LAYER=1 ./t_reorder_chain
|
||||
MTL_DEBUG_LAYER=1 ./t_defer_chain
|
||||
./t_zskip
|
||||
./t_xv
|
||||
./t_ub
|
||||
MTL_DEBUG_LAYER=1 ./t_mip_extent
|
||||
MTL_DEBUG_LAYER=1 ./t_mip_extent --stencil-only
|
||||
./t_rt_depth_ro
|
||||
./t_rt_range_shape
|
||||
./t_rt_range_ro
|
||||
DM_NVN_UNWRITTEN_DC=0 MTL_DEBUG_LAYER=1 ./t_rt_range
|
||||
MTL_DEBUG_LAYER=1 ./t_rt_range # DontCare 缺省开:附件字节按「每通道省一次深度模板写回」闭式期望 | DontCare on by default: attachment bytes use the closed-form expectation of "one depth-stencil store saved per pass"
|
||||
DM_NVN_UNWRITTEN_DC=0 MTL_DEBUG_LAYER=1 ./t_rt_range --disabled
|
||||
DM_NVN_UNWRITTEN_DC=0 MTL_DEBUG_LAYER=1 ./t_rt_range --small-depth
|
||||
DM_NVN_UNWRITTEN_DC=0 MTL_DEBUG_LAYER=1 ./t_rt_range --sample-attachment --both-flags
|
||||
./t_pso_skey
|
||||
MTL_DEBUG_LAYER=1 ./t_pfv
|
||||
python3 test_tbdr_budget.py
|
||||
.PHONY: run
|
||||
@@ -0,0 +1,58 @@
|
||||
// main 内嵌 4 个计算核的 MSL 单测:期望值按 Maxwell 反汇编语义在 C 里直接算(nvn_builtin.h 头注释),不经被测 MSL。
|
||||
// 负对照:4×4 交叉矩阵——每个核对每个期望都跑一遍,只有对角线全等(核之间可区分、哈希→核的对应配错会被抓)。
|
||||
// MSL unit tests for the 4 compute kernels embedded in main: expected values are computed directly in C from the Maxwell disassembly semantics (header comment of nvn_builtin.h), without going through the MSL under test.
|
||||
// Negative control: 4×4 cross matrix - every kernel is run against every expectation, and only the diagonal matches exactly (kernels are distinguishable, and a wrong hash→kernel mapping would be caught).
|
||||
#import <Metal/Metal.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "../nvn/nvn_builtin.h"
|
||||
|
||||
enum { NREC = 40, N = 37, CAP = 64 }; // n = 37:跨两个线程组(32 + 5),第 37..63 个元素必须保持哨兵值 | n = 37: spans two thread groups (32 + 5); elements 37..63 must keep the sentinel value
|
||||
|
||||
static void expect(int k, const uint64_t *s, uint64_t *e) {
|
||||
for (int i = 0; i < CAP; i++) e[i] = 0xAAAAAAAAAAAAAAAAull;
|
||||
for (int i = 0; i < N; i++)
|
||||
switch (k) {
|
||||
case 0: e[i] = s[2 * i]; break; // src + (id<<4)
|
||||
case 1: e[i] = s[2 * i + 1]; break; // src + (id<<4) + 8
|
||||
case 2: e[i] = s[4 * i + 2] - s[4 * i]; break; // src + (id<<5) + 16 − src + (id<<5)
|
||||
case 3: e[i] = s[4 * i + 3] - s[4 * i + 1]; break; // src + (id<<5) + 24 − src + (id<<5) + 8
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
id<MTLDevice> dev = MTLCreateSystemDefaultDevice();
|
||||
NSError *err = nil;
|
||||
id<MTLLibrary> lib = [dev newLibraryWithSource:@(k_nvn_builtin_msl) options:nil error:&err];
|
||||
if (!lib) { printf("MSL 编译失败 %s\n", err.localizedDescription.UTF8String); return 1; }
|
||||
id<MTLCommandQueue> q = [dev newCommandQueue];
|
||||
// 源数据:NREC 条 32 字节记录(= 2×NREC 条 16 字节记录),值带高位与「后小于前」的回绕情形
|
||||
// Source data: NREC 32-byte records (= 2×NREC 16-byte records), with values that have high bits set and wraparound cases where "the later is smaller than the earlier"
|
||||
uint64_t src[4 * NREC];
|
||||
for (int i = 0; i < 4 * NREC; i++) src[i] = 0x0123456789ABCDEFull * (uint64_t)(i + 1) ^ ((uint64_t)i << 40);
|
||||
src[2] = 5; src[0] = 9; // 第 0 条计数差 = 5 − 9 → 64 位回绕 | count difference of entry 0 = 5 − 9 → 64-bit wraparound
|
||||
uint32_t n = N;
|
||||
id<MTLBuffer> bn = [dev newBufferWithBytes:&n length:4 options:MTLResourceStorageModeShared];
|
||||
id<MTLBuffer> bs = [dev newBufferWithBytes:src length:sizeof src options:MTLResourceStorageModeShared];
|
||||
id<MTLBuffer> bd = [dev newBufferWithLength:CAP * 8 options:MTLResourceStorageModeShared];
|
||||
int fail = 0;
|
||||
for (int k = 0; k < 4; k++) {
|
||||
id<MTLComputePipelineState> ps = [dev newComputePipelineStateWithFunction:[lib newFunctionWithName:@(k_nvn_builtin_map[k].fn)] error:&err];
|
||||
int row[4];
|
||||
for (int j = 0; j < 4; j++) {
|
||||
memset(bd.contents, 0xAA, CAP * 8);
|
||||
id<MTLCommandBuffer> cb = [q commandBuffer]; id<MTLComputeCommandEncoder> ce = [cb computeCommandEncoder];
|
||||
[ce setComputePipelineState:ps]; [ce setBuffer:bn offset:0 atIndex:0]; [ce setBuffer:bs offset:0 atIndex:1]; [ce setBuffer:bd offset:0 atIndex:2];
|
||||
[ce dispatchThreadgroups:MTLSizeMake((N + 31) / 32, 1, 1) threadsPerThreadgroup:MTLSizeMake(32, 1, 1)];
|
||||
[ce endEncoding]; [cb commit]; [cb waitUntilCompleted];
|
||||
uint64_t e[CAP]; expect(j, src, e);
|
||||
row[j] = !memcmp(bd.contents, e, sizeof e);
|
||||
}
|
||||
int ok = row[k] && !row[(k + 1) % 4] && !row[(k + 2) % 4] && !row[(k + 3) % 4];
|
||||
printf("%s(%s):对自身期望 %s;对其余 3 个期望全等数 %d(期望 0)→ %s\n", k_nvn_builtin_map[k].fn, k_nvn_builtin_map[k].ctl,
|
||||
row[k] ? "全等(含回绕、哨兵 27 个未动)" : "不等", row[(k + 1) % 4] + row[(k + 2) % 4] + row[(k + 3) % 4], ok ? "✓" : "✗");
|
||||
fail += !ok;
|
||||
}
|
||||
printf("== 4 项,失败 %d ==\n", fail);
|
||||
return fail != 0;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// 全覆盖首绘几何证明单测(nvn_cover.h):期望值按几何手算,不跑被测实现。
|
||||
// 正例:全屏大三角形(-1,-1)(3,-1)(-1,3)、全屏四边形条带;负例:视口只占附件一部分、剪裁只占一部分、三角形缺一角、
|
||||
// 被背面剔除、z 越界、w ≠ 1、两三角形各包一半(单个三角形都包不住四角,按规则不成立——保守)。
|
||||
// Unit tests for the geometric proof of a full-coverage first draw (nvn_cover.h): expected values are hand-calculated from geometry, without running the implementation under test.
|
||||
// Positive cases: fullscreen big triangle (-1,-1)(3,-1)(-1,3), fullscreen quad strip; negative cases: viewport covers only part of the attachment, scissor covers only part, triangle missing a corner,
|
||||
// back-face culled, z out of range, w ≠ 1, two triangles each covering half (no single triangle covers all four corners, so by the rule it does not hold - conservative).
|
||||
#include "../nvn/nvn_cover.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static int fail, total;
|
||||
static void t(const char *name, int want, int got) {
|
||||
total++; fail += want != got;
|
||||
printf("%-44s 期望 %s → 真结果 %s %s\n", name, want ? "成立" : "不成立", got ? "成立" : "不成立", want == got ? "✓" : "✗");
|
||||
}
|
||||
int main(void) {
|
||||
const float big[3][4] = {{-1, -1, 0, 1}, {3, -1, 0, 1}, {-1, 3, 0, 1}}; // 逆时针(NDC y 向上) | counterclockwise (NDC y up)
|
||||
const float big_cw[3][4] = {{-1, -1, 0, 1}, {-1, 3, 0, 1}, {3, -1, 0, 1}}; // 同一三角形,顺时针 | same triangle, clockwise
|
||||
const float quad[4][4] = {{-1, -1, 0.5f, 1}, {1, -1, 0.5f, 1}, {-1, 1, 0.5f, 1}, {1, 1, 0.5f, 1}}; // 条带:两三角形各半屏 | strip: two triangles each covering half the screen
|
||||
const float small[3][4] = {{-1, -1, 0, 1}, {1.9f, -1, 0, 1}, {-1, 1.9f, 0, 1}}; // 斜边 x+y=0.9 切掉 (1,1) 角 | hypotenuse x+y=0.9 cuts off the (1,1) corner
|
||||
const float zout[3][4] = {{-1, -1, 1.5f, 1}, {3, -1, 1.5f, 1}, {-1, 3, 1.5f, 1}};
|
||||
const float w2[3][4] = {{-2, -2, 0, 2}, {6, -2, 0, 2}, {-2, 6, 0, 2}};
|
||||
const float vp_full[4] = {0, 0, 1600, 900}, vp_half[4] = {0, 0, 800, 900}, vp_off[4] = {0, 450, 1600, 900};
|
||||
const int sc_full[4] = {0, 0, 1600, 900}, sc_part[4] = {0, 0, 1600, 450};
|
||||
t("全屏三角形,视口 = 整块,不剔除", 1, nvn_cover(big, 3, 4, 0, 1, 1, vp_full, 0, NULL, 1600, 900));
|
||||
t("全屏三角形,无视口设置(缺省整块)", 1, nvn_cover(big, 3, 4, 0, 1, 0, NULL, 0, NULL, 1600, 900));
|
||||
t("全屏三角形,剔背面,逆时针为正面", 1, nvn_cover(big, 3, 4, 2, 1, 1, vp_full, 1, sc_full, 1600, 900));
|
||||
t("负:同一三角形顺时针,剔背面(被剔)", 0, nvn_cover(big_cw, 3, 4, 2, 1, 1, vp_full, 0, NULL, 1600, 900));
|
||||
t("负:视口只占附件左半", 0, nvn_cover(big, 3, 4, 0, 1, 1, vp_half, 0, NULL, 1600, 900));
|
||||
t("负:视口下移(不从 0 起)", 0, nvn_cover(big, 3, 4, 0, 1, 1, vp_off, 0, NULL, 1600, 900));
|
||||
t("负:视口整块 1600x900,附件是 1920x1080", 0, nvn_cover(big, 3, 4, 0, 1, 1, vp_full, 0, NULL, 1920, 1080));
|
||||
t("负:剪裁只占上半", 0, nvn_cover(big, 3, 4, 0, 1, 1, vp_full, 1, sc_part, 1600, 900));
|
||||
t("负:三角形缺 (1,1) 角", 0, nvn_cover(small, 3, 4, 0, 1, 1, vp_full, 0, NULL, 1600, 900));
|
||||
t("负:z 超出 [0,1]", 0, nvn_cover(zout, 3, 4, 0, 1, 1, vp_full, 0, NULL, 1600, 900));
|
||||
t("负:w ≠ 1", 0, nvn_cover(w2, 3, 4, 0, 1, 1, vp_full, 0, NULL, 1600, 900));
|
||||
t("负:全屏四边形条带(单个三角形包不住,保守)", 0, nvn_cover(quad, 4, 5, 0, 1, 1, vp_full, 0, NULL, 1600, 900));
|
||||
t("负:正背面都剔", 0, nvn_cover(big, 3, 4, 3, 1, 1, vp_full, 0, NULL, 1600, 900));
|
||||
t("负:图元是线(非三角形)", 0, nvn_cover(big, 3, 1, 0, 1, 1, vp_full, 0, NULL, 1600, 900));
|
||||
printf("== %d 项,失败 %d ==\n", total, fail);
|
||||
return fail != 0;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#include "../nvn/nvn_mtl.m"
|
||||
void *front_metal_layer(void) { return NULL; }
|
||||
module_t *module_of(const void *p) { (void)p; return NULL; }
|
||||
module_t g_mod[MAX_MOD]; int g_nmod;
|
||||
void svc_thread_dump(void) {}
|
||||
uint64_t now_ns(void) { return bp_now(); }
|
||||
static int fail, count;
|
||||
#define EXPECT(name, want, got) do { uint64_t w=(want), g=(got); count++; printf("%s 期望 %llu → 真结果 %llu %s\n", name, (unsigned long long)w, (unsigned long long)g, w==g?"✓":"✗"); fail += w != g; } while (0)
|
||||
typedef struct { uint8_t *p; size_t n; } chain;
|
||||
static chain chain_new(void) { chain c={0}; if (posix_memalign((void **)&c.p,getpagesize(),65536)) abort(); memset(c.p,0,65536); mtl_pool_add(c.p,65536); return c; }
|
||||
static void emit(chain *c, unsigned op, const void *a, size_t n) { size_t z=(8+n+7)&~7ull; op_hdr h={op,(uint32_t)z}; memcpy(c->p+c->n,&h,8); if(n) memcpy(c->p+c->n+8,a,n); c->n+=z; }
|
||||
static tex_t tex(unsigned w) { static uint64_t s=9000; tex_t t={.serial=s++}; t.d.width=t.d.height=w; t.d.depth=t.d.samples=1; t.d.levels=2; t.d.target=NVN_TEXTURE_TARGET_2D; t.d.format=NVN_FORMAT_RGBA8; return t; }
|
||||
static int view(const tex_t *t, int lv) { static int id=1200; view_t v={.set_levels=1,.base_level=lv,.nlevels=1}; mtl_reg_tex(id,t,&v); return id++; }
|
||||
static void set_rt(chain *c, const tex_t *a, const tex_t *b, int alv) { p_set_rt r={.n=b?2:1}; r.color[0]=a; r.color[1]=b; for(int i=0;i<r.n;i++){r.has_cview[i]=1;r.cview[i].set_levels=1;r.cview[i].base_level=i?0:alv;r.cview[i].nlevels=1;} emit(c,OP_SET_RT,&r,sizeof r); p_viewports v={.n=1};v.v[0][2]=v.v[0][3]=8;emit(c,OP_VIEWPORTS,&v,sizeof v);p_scissor sc={0,0,8,8};emit(c,OP_SCISSOR,&sc,sizeof sc); }
|
||||
static void clear_color(chain *c, int i, float r, float g, float b) { p_clear_color x={.index=i,.mask=15,.rgba={r,g,b,1}}; emit(c,OP_CLEAR_COLOR,&x,sizeof x); }
|
||||
static void bind_prog(chain *c, prog_t *p) { p_bind_program b={p,3}; emit(c,OP_BIND_PROGRAM,&b,sizeof b); }
|
||||
static void bind_tex(chain *c, int id) { p_bind_handles b={.stage=1,.first=0,.n=1};b.h[0]=id;emit(c,OP_BIND_TEX,&b,sizeof b); }
|
||||
static void draw_cmd(chain *c) { p_draw d={NVN_DRAW_PRIMITIVE_TRIANGLES,0,3}; emit(c,OP_DRAW,&d,sizeof d); }
|
||||
static void blend(chain *c) { color_st col={1,NVN_LOGIC_OP_COPY,NVN_ALPHA_FUNC_ALWAYS}; p_bind_state x={.kind=1};memcpy(x.bytes,&col,sizeof col);emit(c,OP_BIND_STATE,&x,sizeof x); blend_st b={0,NVN_BLEND_FUNC_SRC_ALPHA,NVN_BLEND_FUNC_ONE_MINUS_SRC_ALPHA,NVN_BLEND_FUNC_ONE,NVN_BLEND_FUNC_ZERO,NVN_BLEND_EQUATION_ADD,NVN_BLEND_EQUATION_ADD};x.kind=0;memcpy(x.bytes,&b,sizeof b);emit(c,OP_BIND_STATE,&x,sizeof x); }
|
||||
static void ds_off(chain *c) { ds_st d={0,0,NVN_DEPTH_FUNC_ALWAYS,0,NVN_STENCIL_FUNC_ALWAYS,NVN_STENCIL_FUNC_ALWAYS,NVN_STENCIL_OP_KEEP,NVN_STENCIL_OP_KEEP,NVN_STENCIL_OP_KEEP,NVN_STENCIL_OP_KEEP,NVN_STENCIL_OP_KEEP,NVN_STENCIL_OP_KEEP}; p_bind_state x={.kind=5}; memcpy(x.bytes,&d,sizeof d); emit(c,OP_BIND_STATE,&x,sizeof x); }
|
||||
static void readback(const tex_t *t, uint8_t out[256]) { id<MTLBuffer> b=[g_dev newBufferWithLength:256 options:MTLResourceStorageModeShared]; [blit() copyFromTexture:tex_mtl(t) sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(0,0,0) sourceSize:MTLSizeMake(8,8,1) toBuffer:b destinationOffset:0 destinationBytesPerRow:32 destinationBytesPerImage:256]; uint64_t f=mtl_sub_commit(); EXPECT("提交完成",1,mtl_wait(f,5000000000ull)); EXPECT("提交反馈无错误",0,mtl_last_commit_error()); memcpy(out,b.contents,256); }
|
||||
static NvProg *g_tkeep[256]; static int g_tnkeep; /* 测试里的程序对象常驻:释放后新对象可能落在同一地址,管线缓存按对象地址认会取到旧管线(生产里程序对象不释放) | Program objects in the tests are permanent: after a free, a new object may land at the same address, and the pipeline cache, keyed by object address, would return the old pipeline (in production program objects are never freed) */
|
||||
static void setup_prog(prog_t *pg) { NSError *e=nil; id<MTLLibrary> l=[g_dev newLibraryWithSource:@"#include <metal_stdlib>\nusing namespace metal; vertex float4 v(uint n[[vertex_id]]){float2 p[3]={float2(-1,-1),float2(3,-1),float2(-1,3)};return float4(p[n],0,1);}\nfragment float4 red(){return float4(1,0,0,0.5);}\nstruct A{texture2d<float> t[[id(0)]];}; fragment float4 sample(constant A&a[[buffer(0)]]){return a.t.read(uint2(0));}\n" options:nil error:&e]; if(!l){fprintf(stderr,"%s\n",e.localizedDescription.UTF8String);abort();} for(int i=0;i<2;i++)pg[i].serial=8000+i; for(int i=0;i<2;i++){NvProg *p=[NvProg new];p->sh[0]=[NvShader new];p->sh[0]->fn=[l newFunctionWithName:@"v"];p->sh[1]=[NvShader new];p->sh[1]->stage=1;p->sh[1]->fn=[l newFunctionWithName:i?@"sample":@"red"];if(i){p->sh[1]->rf.nb=1;p->sh[1]->rf.b[0]=(nvn_rbind){.kind=NVN_RB_TEX,.reg=0,.dtt=2};p->sh[1]->ae=[p->sh[1]->fn newArgumentEncoderWithBufferIndex:0];}if(g_tnkeep<256)g_tkeep[g_tnkeep++]=p;serial_put(pg[i].serial,p);} }
|
||||
static uint64_t run_case(int mode, int enabled, uint8_t px[256]) { tex_t a=tex(8),b=tex(8),q2=tex(8); int aid=view(&a,0), a1=view(&a,1); chain c=chain_new(); prog_t pg[2]={0}; setup_prog(pg); set_rt(&c,&a,NULL,0);clear_color(&c,0,0,0,0);ds_off(&c);bind_prog(&c,&pg[0]);blend(&c);draw_cmd(&c);set_rt(&c,&b,NULL,0);clear_color(&c,0,0,0,0);if(mode==1){uint64_t t=NVN_COUNTER_TYPE_SAMPLES_PASSED;emit(&c,OP_RESET_COUNTER,&t,sizeof t);}if(mode==2){bind_prog(&c,&pg[1]);bind_tex(&c,aid);}ds_off(&c);draw_cmd(&c);set_rt(&c,&a,&q2,0);if(mode==3)clear_color(&c,0,0,0,0);bind_prog(&c,&pg[1]);bind_tex(&c,mode==5?aid:a1);draw_cmd(&c);emit(&c,OP_END,NULL,0);state_reset();memset(&R,0,sizeof R);vis_clear();g_vis_on=g_vis_counting=0;if(!enabled)setenv("DM_NVN_DEFER","0",1);else setenv("DM_NVN_DEFER","1",1);uint64_t start=g_stat_pass;mtl_sub_begin();uint64_t hh=(uint64_t)c.p;mtl_sub_index(&hh,1);mtl_exec(c.p);readback(&a,px);return g_stat_pass-start; }
|
||||
static uint64_t run_multi(int enabled, uint8_t px[256]) { tex_t a=tex(8),b=tex(8),mid=tex(8); chain c=chain_new(); static prog_t pg[2]; memset(pg,0,sizeof pg); /* 静态:程序缓存按 prog_t 地址认,栈上会与 run_case 的 pg 重址 | Static: the program cache is keyed by prog_t address, and on the stack it would share an address with run_case's pg */ setup_prog(pg); set_rt(&c,&a,NULL,0);clear_color(&c,0,0,0,0);ds_off(&c);bind_prog(&c,&pg[0]);blend(&c);draw_cmd(&c);set_rt(&c,&mid,NULL,0);ds_off(&c);draw_cmd(&c);set_rt(&c,&b,NULL,0);clear_color(&c,0,0,0,0);draw_cmd(&c);set_rt(&c,&a,&b,0);bind_prog(&c,&pg[0]);draw_cmd(&c);emit(&c,OP_END,NULL,0);state_reset();memset(&R,0,sizeof R);vis_clear();g_vis_on=g_vis_counting=0;setenv("DM_NVN_DEFER",enabled?"1":"0",1);uint64_t start=g_stat_pass;mtl_sub_begin();uint64_t hh=(uint64_t)c.p;mtl_sub_index(&hh,1);mtl_exec(c.p);readback(&a,px);return g_stat_pass-start; }
|
||||
static uint64_t run_chain_id(int enabled, uint8_t px[256]) { /* 链式正例:A 在三个通道里都是第 0 个附件——P1 画 A;P2 的通道 (A, D) 是 P1 的 Q,P2 画 A 并整体推迟进 Q2 (A, D) | Chained positive case: A is attachment 0 in all three passes - P1 draws A; P2's pass (A, D) is P1's Q, P2 draws A and is deferred as a whole into Q2 (A, D) */
|
||||
tex_t a=tex(8),d=tex(8),mid=tex(8); chain c=chain_new(); static prog_t pg[2]; memset(pg,0,sizeof pg); setup_prog(pg);
|
||||
set_rt(&c,&a,NULL,0);clear_color(&c,0,0,0,0);ds_off(&c);bind_prog(&c,&pg[0]);blend(&c);draw_cmd(&c);
|
||||
set_rt(&c,&mid,NULL,0);ds_off(&c);draw_cmd(&c);
|
||||
set_rt(&c,&a,&d,0);clear_color(&c,1,0,0,0);draw_cmd(&c);
|
||||
set_rt(&c,&mid,NULL,0);draw_cmd(&c);
|
||||
set_rt(&c,&a,&d,0);bind_prog(&c,&pg[0]);draw_cmd(&c);emit(&c,OP_END,NULL,0);
|
||||
state_reset();memset(&R,0,sizeof R);vis_clear();g_vis_on=g_vis_counting=0;setenv("DM_NVN_DEFER",enabled?"1":"0",1);
|
||||
uint64_t start=g_stat_pass;mtl_sub_begin();uint64_t hh=(uint64_t)c.p;mtl_sub_index(&hh,1);mtl_exec(c.p);readback(&a,px);return g_stat_pass-start; }
|
||||
static uint64_t run_chain(int enabled, uint8_t px[256]) { /* 链式:P1 画 A;P2 的通道 (D, A) 正是 P1 的 Q,P2 自己画 D 并整体推迟进 Q2 (A, D)——A 在两个通道里的下标不同(1 → 0),映射复合错了 A 就画到 D 上 | Chained: P1 draws A; P2's pass (D, A) is exactly P1's Q, P2 itself draws D and is deferred as a whole into Q2 (A, D) - A's index differs between the two passes (1 → 0), and if the mapping is composed wrongly A gets drawn onto D */
|
||||
tex_t a=tex(8),d=tex(8),mid=tex(8); chain c=chain_new(); static prog_t pg[2]; memset(pg,0,sizeof pg); setup_prog(pg);
|
||||
set_rt(&c,&a,NULL,0);clear_color(&c,0,0,0,0);ds_off(&c);bind_prog(&c,&pg[0]);blend(&c);draw_cmd(&c);
|
||||
set_rt(&c,&mid,NULL,0);ds_off(&c);draw_cmd(&c);
|
||||
set_rt(&c,&d,&a,0);clear_color(&c,0,0,0,0);draw_cmd(&c);
|
||||
set_rt(&c,&mid,NULL,0);draw_cmd(&c);
|
||||
set_rt(&c,&a,&d,0);bind_prog(&c,&pg[0]);draw_cmd(&c);emit(&c,OP_END,NULL,0);
|
||||
state_reset();memset(&R,0,sizeof R);vis_clear();g_vis_on=g_vis_counting=0;setenv("DM_NVN_DEFER",enabled?"1":"0",1);
|
||||
uint64_t start=g_stat_pass;mtl_sub_begin();uint64_t hh=(uint64_t)c.p;mtl_sub_index(&hh,1);mtl_exec(c.p);readback(&a,px);return g_stat_pass-start; }
|
||||
int main(void){@autoreleasepool{setvbuf(stdout,NULL,_IONBF,0);setenv("DM_NVN_TBDR","1",1);mtl_init();uint8_t p[256];uint8_t off[256];uint64_t n0=run_case(0,0,off);uint64_t d0=g_defer_n;uint64_t n1=run_case(0,1,p);uint64_t d1=g_defer_n;EXPECT("正例推迟计数",1,d1-d0);EXPECT("正例开通道少一",1,n0-n1);EXPECT("正例像素非黑",1,p[0]>0);EXPECT("正例开关逐字节相同",0,(uint64_t)memcmp(p,off,256));
|
||||
uint64_t m0=run_multi(0,off);uint64_t md0=g_defer_n;uint64_t m1=run_multi(1,p);EXPECT("同Q两组推迟计数(B 在 Q 里下标不同,只成立 A)",1,g_defer_n-md0);EXPECT("同Q两组开通道少一",1,m0-m1);EXPECT("同Q两组开关逐字节相同",0,(uint64_t)memcmp(p,off,256));
|
||||
uint64_t k0=run_chain(0,off);uint64_t kd0=g_defer_n;uint64_t k1=run_chain(1,p);EXPECT("链式下标不同不推迟",0,g_defer_n-kd0);EXPECT("链式下标不同开通道数不变",0,k0-k1);EXPECT("链式开关逐字节相同",0,(uint64_t)memcmp(p,off,256));
|
||||
uint64_t j0=run_chain_id(0,off);uint64_t jd0=g_defer_n;uint64_t j1=run_chain_id(1,p);EXPECT("链式恒等两组成立",2,g_defer_n-jd0);EXPECT("链式恒等开通道少二",2,j0-j1);EXPECT("链式恒等开关逐字节相同",0,(uint64_t)memcmp(p,off,256));
|
||||
for(int m=1;m<=5;m++){run_case(m,0,off);uint64_t before=g_defer_n;run_case(m,1,p);EXPECT(m==2||m==3||m==5?"反例不推迟":"另一个正例仍推迟",m==2||m==3||m==5?0:1,g_defer_n-before);EXPECT("开关逐字节相同",0,(uint64_t)memcmp(p,off,256));}printf("== %d 项,失败 %d ==\n",count,fail);return fail!=0;}}
|
||||
@@ -0,0 +1,122 @@
|
||||
#import <Metal/Metal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "../nvn/include/nvn.h"
|
||||
#include "../nvn/nvn_tex.h"
|
||||
#include "../tex/nvn_deswizzle.h"
|
||||
#include "../tex/nvn_deswizzle_gpu.h"
|
||||
|
||||
typedef struct { const char *name; nvn_texdesc d; } test_case;
|
||||
typedef struct { size_t off, pitch, bytes; unsigned level, layer, slices, rows; } record;
|
||||
|
||||
static uint64_t now_ns(void) { struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return (uint64_t)t.tv_sec * 1000000000ull + t.tv_nsec; }
|
||||
static void fill_bytes(unsigned char *p, size_t n, uint32_t seed) { for (size_t i = 0; i < n; i++) p[i] = (unsigned char)(seed + i * 37u + (i >> 7)); }
|
||||
|
||||
static int run_case(id<MTLDevice> dev, id<MTLCommandQueue> queue, const test_case *tc, int special) {
|
||||
nvn_texlayout layout; nvn_tex_layout(&tc->d, &layout);
|
||||
size_t source_off = special ? 4 : 0;
|
||||
unsigned levels = tc->d.levels ? tc->d.levels : 1;
|
||||
unsigned count = 0; size_t dst_size = 32;
|
||||
for (unsigned l = 0; l < levels; l++) {
|
||||
uint32_t rb, rows, slices, bpb; uint64_t base; unsigned th, td;
|
||||
if (nvn_deswizzle_geom(&tc->d, l, 0, &rb, &rows, &slices, &base, &th, &td, &bpb)) return 1;
|
||||
unsigned layers = layout.layers;
|
||||
for (unsigned layer = 0; layer < layers; layer++) {
|
||||
size_t pitch = rb + ((special && !count) ? 3 : 0);
|
||||
size_t bytes = (size_t)slices * rows * pitch;
|
||||
count++; dst_size += bytes + 7;
|
||||
}
|
||||
}
|
||||
record *records = calloc(count, sizeof(*records));
|
||||
unsigned char *expected = calloc(1, dst_size + 32), *source = calloc(1, source_off + layout.size + 32);
|
||||
if (!records || !expected || !source) return 1;
|
||||
size_t cursor = 4;
|
||||
unsigned ri = 0;
|
||||
for (unsigned l = 0; l < levels; l++) {
|
||||
uint32_t rb, rows, slices, bpb; uint64_t base; unsigned th, td;
|
||||
nvn_deswizzle_geom(&tc->d, l, 0, &rb, &rows, &slices, &base, &th, &td, &bpb);
|
||||
for (unsigned layer = 0; layer < layout.layers; layer++) {
|
||||
size_t pitch = rb + ((special && ri == 0) ? 3 : 0), bytes = (size_t)slices * rows * pitch;
|
||||
cursor = (cursor + 3) & ~3ull;
|
||||
records[ri] = (record){cursor, pitch, (size_t)slices * rows * rb, l, layer, slices, rows};
|
||||
fill_bytes(expected + cursor, bytes, 17u + ri * 29u);
|
||||
if (nvn_swizzle(&tc->d, l, layer, expected + cursor, pitch, source + source_off)) return 1;
|
||||
cursor += bytes + 7; ri++;
|
||||
}
|
||||
}
|
||||
id<MTLBuffer> src = [dev newBufferWithBytes:source length:source_off + layout.size + 32 options:MTLResourceStorageModeShared];
|
||||
id<MTLBuffer> dst = [dev newBufferWithLength:dst_size + 32 options:MTLResourceStorageModeShared];
|
||||
memset(dst.contents, 0xCD, dst.length);
|
||||
id<MTLCommandBuffer> cb = [queue commandBuffer]; id<MTLComputeCommandEncoder> enc = [cb computeCommandEncoder];
|
||||
int fail = 0;
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
fail |= nvn_deswz_gpu_encode(enc, src, source_off, &tc->d, records[i].level, records[i].layer, dst, records[i].off, records[i].pitch) != 0;
|
||||
[enc endEncoding]; [cb commit]; [cb waitUntilCompleted];
|
||||
for (unsigned i = 0; i < count; i++) {
|
||||
size_t row_bytes = records[i].bytes / (records[i].slices * records[i].rows);
|
||||
int ok = 1;
|
||||
for (unsigned z = 0; z < records[i].slices; z++)
|
||||
for (unsigned y = 0; y < records[i].rows; y++)
|
||||
ok &= !memcmp((unsigned char *)dst.contents + records[i].off + ((size_t)z * records[i].rows + y) * records[i].pitch,
|
||||
expected + records[i].off + ((size_t)z * records[i].rows + y) * records[i].pitch, row_bytes);
|
||||
printf("%s L%u layer%u: %s %zu 字节\n", tc->name, records[i].level, records[i].layer, ok ? "OK" : "BAD", records[i].bytes);
|
||||
fail |= !ok;
|
||||
}
|
||||
free(records); free(expected); free(source);
|
||||
return fail;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
@autoreleasepool {
|
||||
id<MTLDevice> dev = MTLCreateSystemDefaultDevice();
|
||||
if (!dev) { printf("BAD:无 Metal 设备\n"); return 1; }
|
||||
if (nvn_deswz_gpu_init(dev)) { printf("BAD:GPU 解排布管线初始化失败\n"); return 1; }
|
||||
id<MTLCommandQueue> queue = [dev newCommandQueue];
|
||||
test_case cases[] = {
|
||||
{"RGBA8 1x1", {1, NVN_FORMAT_RGBA8, 0, 0, 1, 1, 1, 1, 0}},
|
||||
{"RGBA8 3x5", {1, NVN_FORMAT_RGBA8, 0, 0, 3, 5, 1, 1, 0}},
|
||||
{"RGBA8 64x64", {1, NVN_FORMAT_RGBA8, 0, 0, 64, 64, 1, 1, 0}},
|
||||
{"RGBA8 1000x700", {1, NVN_FORMAT_RGBA8, 0, 0, 1000, 700, 1, 1, 0}},
|
||||
{"RGBA8 2048x2048 mip", {1, NVN_FORMAT_RGBA8, 0, 0, 2048, 2048, 1, 12, 0}},
|
||||
{"R8 3", {1, NVN_FORMAT_R8, 0, 0, 3, 1, 1, 1, 0}},
|
||||
{"R8 17", {1, NVN_FORMAT_R8, 0, 0, 17, 1, 1, 1, 0}},
|
||||
{"RGBA16F", {1, NVN_FORMAT_RGBA16F, 0, 0, 17, 9, 1, 2, 0}},
|
||||
{"RGBA32F", {1, NVN_FORMAT_RGBA32F, 0, 0, 17, 9, 1, 2, 0}},
|
||||
{"BC1 30x18 mip", {1, NVN_FORMAT_RGBA_DXT1, 0, 0, 30, 18, 1, 4, 0}},
|
||||
{"BC3 30x18 mip", {1, NVN_FORMAT_RGBA_DXT3, 0, 0, 30, 18, 1, 4, 0}},
|
||||
{"BC7 30x18 mip", {1, NVN_FORMAT_BPTC_UNORM, 0, 0, 30, 18, 1, 4, 0}},
|
||||
{"2D array 5", {4, NVN_FORMAT_RGBA8, 0, 0, 17, 9, 5, 2, 0}},
|
||||
{"cube", {8, NVN_FORMAT_RGBA8, 0, 0, 17, 9, 1, 2, 0}},
|
||||
{"3D 64x64x16 mip", {2, NVN_FORMAT_RGBA8, 0, 0, 64, 64, 16, 7, 0}},
|
||||
};
|
||||
int fail = 0; unsigned n = 0;
|
||||
for (unsigned i = 0; i < sizeof(cases) / sizeof(*cases); i++) { fail |= run_case(dev, queue, &cases[i], i == 1); n++; }
|
||||
|
||||
test_case neg = {"负对照", {1, NVN_FORMAT_RGBA8, 0, 0, 64, 64, 1, 2, 0}};
|
||||
nvn_texlayout nl; nvn_tex_layout(&neg.d, &nl);
|
||||
size_t rb, expected_bytes = 64 * 64 * 4; rb = 64 * 4;
|
||||
unsigned char *lin = malloc(expected_bytes), *srcmem = calloc(1, nl.size + 32);
|
||||
fill_bytes(lin, expected_bytes, 91); nvn_swizzle(&neg.d, 0, 0, lin, rb, srcmem);
|
||||
id<MTLBuffer> sb = [dev newBufferWithBytes:srcmem length:nl.size + 32 options:MTLResourceStorageModeShared];
|
||||
id<MTLBuffer> db = [dev newBufferWithLength:expected_bytes options:MTLResourceStorageModeShared]; memset(db.contents, 0xCD, db.length);
|
||||
id<MTLCommandBuffer> ncb = [queue commandBuffer]; id<MTLComputeCommandEncoder> ne = [ncb computeCommandEncoder];
|
||||
int enc_bad = nvn_deswz_gpu_encode(ne, sb, 0, &neg.d, 1, 0, db, 0, rb); [ne endEncoding]; [ncb commit]; [ncb waitUntilCompleted];
|
||||
int mismatch = enc_bad || memcmp(db.contents, lin, expected_bytes) != 0; printf("负对照(错误 level): %s %zu 字节\n", mismatch ? "OK(判红)" : "BAD(未判红)", expected_bytes); fail |= !mismatch;
|
||||
free(lin); free(srcmem);
|
||||
|
||||
test_case perf = {"性能参考", {1, NVN_FORMAT_RGBA8, 0, 0, 2048, 2048, 1, 12, 0}};
|
||||
nvn_texlayout pl; nvn_tex_layout(&perf.d, &pl); size_t perf_size = 0;
|
||||
for (unsigned l = 0; l < perf.d.levels; l++) { uint32_t pr, py, pz, pb; uint64_t pbase; unsigned pth, ptd; nvn_deswizzle_geom(&perf.d, l, 0, &pr, &py, &pz, &pbase, &pth, &ptd, &pb); perf_size += (size_t)pr * py; }
|
||||
unsigned char *ps = calloc(1, pl.size), *pd = calloc(1, perf_size); size_t perf_cursor = 0;
|
||||
for (unsigned l = 0; l < perf.d.levels; l++) { uint32_t pr, py, pz, pb; uint64_t pbase; unsigned pth, ptd; nvn_deswizzle_geom(&perf.d, l, 0, &pr, &py, &pz, &pbase, &pth, &ptd, &pb); fill_bytes(pd + perf_cursor, (size_t)pr * py, 7 + l); nvn_swizzle(&perf.d, l, 0, pd + perf_cursor, pr, ps); perf_cursor += (size_t)pr * py; }
|
||||
uint64_t c0 = now_ns(); perf_cursor = 0; for (unsigned l = 0; l < perf.d.levels; l++) { uint32_t pr, py, pz, pb; uint64_t pbase; unsigned pth, ptd; nvn_deswizzle_geom(&perf.d, l, 0, &pr, &py, &pz, &pbase, &pth, &ptd, &pb); nvn_deswizzle(&perf.d, l, 0, ps, pd + perf_cursor, pr); perf_cursor += (size_t)pr * py; } uint64_t cpu_ns = now_ns() - c0;
|
||||
id<MTLBuffer> psrc = [dev newBufferWithBytes:ps length:pl.size options:MTLResourceStorageModeShared];
|
||||
id<MTLBuffer> pdst = [dev newBufferWithLength:perf_size options:MTLResourceStorageModeShared];
|
||||
c0 = now_ns(); id<MTLCommandBuffer> pcb = [queue commandBuffer]; id<MTLComputeCommandEncoder> pe = [pcb computeCommandEncoder]; perf_cursor = 0; for (unsigned l = 0; l < perf.d.levels; l++) { uint32_t pr, py, pz, pb; uint64_t pbase; unsigned pth, ptd; nvn_deswizzle_geom(&perf.d, l, 0, &pr, &py, &pz, &pbase, &pth, &ptd, &pb); nvn_deswz_gpu_encode(pe, psrc, 0, &perf.d, l, 0, pdst, perf_cursor, pr); perf_cursor += (size_t)pr * py; } [pe endEncoding]; uint64_t encode_ns = now_ns() - c0; [pcb commit]; [pcb waitUntilCompleted]; uint64_t gpu_ns = now_ns() - c0;
|
||||
printf("性能参考:2048x2048 RGBA8 带 mip(约 22 MB),CPU nvn_deswizzle %.3f ms;GPU 编码 %.3f ms + waitUntilCompleted 总计 %.3f ms\n", cpu_ns / 1e6, encode_ns / 1e6, gpu_ns / 1e6); free(ps); free(pd);
|
||||
printf("== %u 例全过 / 负对照判红 ==\n", n);
|
||||
return fail != 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#include "../nvn/nvn_dirty.h"
|
||||
#include "../../host/dm.h"
|
||||
#include <sys/mman.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
module_t g_mod[MAX_MOD];
|
||||
int g_nmod;
|
||||
module_t *module_of(const void *p) { (void)p; return NULL; }
|
||||
void crash_install(void);
|
||||
|
||||
static int g_fail;
|
||||
#define EXPECT(name, want, got) do { \
|
||||
long long want_ = (long long)(want), got_ = (long long)(got); \
|
||||
printf("%-52s 期望 %-4lld → 真结果 %-4lld %s\n", name, want_, got_, want_ == got_ ? "✓" : "✗"); \
|
||||
if (want_ != got_) g_fail++; \
|
||||
} while (0)
|
||||
|
||||
static void *page_map(void) {
|
||||
void *p = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||
if (p == MAP_FAILED) { perror("mmap"); exit(2); }
|
||||
return p;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
crash_install();
|
||||
|
||||
for (int i = 0; i < 65; i++) {
|
||||
void *p = page_map();
|
||||
nvn_dirty_add_range(p, 4096);
|
||||
nvn_dirty_remove_range(p);
|
||||
munmap(p, 4096);
|
||||
}
|
||||
|
||||
void *reused = page_map();
|
||||
nvn_dirty_add_range(reused, 4096);
|
||||
nvn_dirty_protect(reused, 4096);
|
||||
uint64_t stamp = nvn_dirty_now();
|
||||
((volatile uint8_t *)reused)[0] = 1;
|
||||
EXPECT("累计 65 次销池后新池写入被判脏", 1, nvn_dirty_since(reused, 4096, stamp));
|
||||
nvn_dirty_remove_range(reused);
|
||||
munmap(reused, 4096);
|
||||
|
||||
void *live[300];
|
||||
for (int i = 0; i < 300; i++) {
|
||||
live[i] = page_map();
|
||||
nvn_dirty_add_range(live[i], 4096);
|
||||
}
|
||||
void *overflow = live[299];
|
||||
nvn_dirty_protect(overflow, 4096);
|
||||
stamp = nvn_dirty_now();
|
||||
((volatile uint8_t *)overflow)[0] = 2;
|
||||
EXPECT("同时存活超过上限的池保守判脏", 1, nvn_dirty_since(overflow, 4096, stamp));
|
||||
for (int i = 0; i < 300; i++) {
|
||||
nvn_dirty_remove_range(live[i]);
|
||||
munmap(live[i], 4096);
|
||||
}
|
||||
return g_fail != 0;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// 局内双渲染回归:直接走生产 fz_end / fz_check_run,用 16×16 真 Metal 附件。
|
||||
// 后通道逻辑 c0 位于并集物理 c3;红色与蓝色的期望值由常量定义,不借被测实现算。
|
||||
// In-run double-render regression: goes directly through production fz_end / fz_check_run, with real 16×16 Metal attachments.
|
||||
// The later pass's logical c0 is at physical c3 of the union; the expected red and blue values are defined by constants, not computed via the implementation under test.
|
||||
#include "../nvn/nvn_mtl.m"
|
||||
void *front_metal_layer(void) { return NULL; }
|
||||
module_t *module_of(const void *p) { (void)p; return NULL; }
|
||||
module_t g_mod[MAX_MOD]; int g_nmod;
|
||||
void svc_thread_dump(void) {}
|
||||
uint64_t now_ns(void) { return bp_now(); }
|
||||
|
||||
static int fail, count;
|
||||
#define EXPECT(name, want, got) do { uint64_t w = (want), v = (got); count++; \
|
||||
printf("%s 期望 %llu → 真结果 %llu %s\n", name, (unsigned long long)w, \
|
||||
(unsigned long long)v, w == v ? "✓" : "✗"); fail += w != v; } while (0)
|
||||
|
||||
static void check_color(int blue, const prog_t *pg, tex_t t[4]) {
|
||||
uint64_t same = g_fzc_same, diff = g_fzc_diff;
|
||||
state_reset(); S.prog = pg;
|
||||
memset(&R, 0, sizeof R); R.has_rt = 1; R.rt.n = 4;
|
||||
for (int i = 0; i < 4; i++) R.rt.color[i] = &t[i];
|
||||
R.clear_c[3] = 1; R.cc[3] = MTLClearColorMake(!blue, 0, blue, 1);
|
||||
memset(&g_fz, 0, sizeof g_fz);
|
||||
g_fz.active = 1; g_fz.phase = 2; g_fz.n1 = 3;
|
||||
g_fz.rt2.n = 1; g_fz.rt2.color[0] = &t[3];
|
||||
memset(g_fz.p2map, -1, sizeof g_fz.p2map); g_fz.p2map[0] = 3;
|
||||
g_fz.wrote[3] = 1;
|
||||
p_draw dw = {NVN_DRAW_PRIMITIVE_TRIANGLES, 0, 3};
|
||||
fz_snap_take(&dw, NULL);
|
||||
mtl_sub_begin(); rp_begin_ex(1); rp_end();
|
||||
uint64_t f = mtl_sub_commit();
|
||||
EXPECT("GPU 完成", 1, mtl_wait(f, 5000000000ull));
|
||||
EXPECT(blue ? "负对照:蓝色合并结果 vs 红色普通结果,确实比到不同附件" : "物理 c3 → 逻辑 c0,确实比到同一红色附件",
|
||||
1, blue ? g_fzc_diff - diff : g_fzc_same - same);
|
||||
EXPECT("本例恰好登记一个比对,不漏报也不重复", 1, g_fzc_same - same + g_fzc_diff - diff);
|
||||
EXPECT("结束后保持后通道逻辑目标", 1, R.rt.n == 1 && R.rt.color[0] == &t[3]);
|
||||
EXPECT("快照释放", 0, g_nfzs);
|
||||
}
|
||||
|
||||
int main(void) { @autoreleasepool {
|
||||
setenv("DM_NVN_FUSE_CHECK", "1", 1); mtl_init();
|
||||
NSError *error = nil;
|
||||
id<MTLLibrary> lib = [g_dev newLibraryWithSource:@"#include <metal_stdlib>\nusing namespace metal;\n"
|
||||
"vertex float4 v(uint n [[vertex_id]]) { float2 p[3] = {float2(-1,-1),float2(3,-1),float2(-1,3)}; return float4(p[n],0,1); }\n"
|
||||
"fragment float4 f() { return float4(1,0,0,1); }\n" options:nil error:&error];
|
||||
if (!lib) { fprintf(stderr, "%s\n", error.localizedDescription.UTF8String); return 2; }
|
||||
NvProg *pr = [NvProg new];
|
||||
pr->sh[0] = [NvShader new]; pr->sh[0]->fn = [lib newFunctionWithName:@"v"];
|
||||
pr->sh[1] = [NvShader new]; pr->sh[1]->fn = [lib newFunctionWithName:@"f"]; pr->sh[1]->stage = 1;
|
||||
prog_t pg = {.serial = 100}; serial_put(pg.serial, pr);
|
||||
tex_t t[4] = {0};
|
||||
for (int i = 0; i < 4; i++) { t[i].serial = 101 + i; t[i].d.width = t[i].d.height = 16;
|
||||
t[i].d.depth = t[i].d.levels = t[i].d.samples = 1; t[i].d.target = NVN_TEXTURE_TARGET_2D; t[i].d.format = NVN_FORMAT_RGBA8; }
|
||||
check_color(0, &pg, t); check_color(1, &pg, t);
|
||||
printf("== %d 项,失败 %d ==\n", count, fail); return fail != 0;
|
||||
} }
|
||||
@@ -0,0 +1,31 @@
|
||||
// 哈希表单测:随机插入 / 覆盖 / 删除 / 清空对照朴素数组模型;键空间小、键长取 8 与 20(含非 8 倍数尾巴),逼出长探测链与回移删除。
|
||||
// Hash table unit tests: random insert / overwrite / delete / clear checked against a naive array model; small key space, key lengths 8 and 20 (including a tail that is not a multiple of 8), to force long probe chains and backward-shift deletion.
|
||||
#include "../nvn/nvn_hmap.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define KS 3000
|
||||
static uint64_t rng = 88172645463325252ull;
|
||||
static uint64_t rnd(void) { rng ^= rng << 13; rng ^= rng >> 7; rng ^= rng << 17; return rng; }
|
||||
static int run(uint32_t klen, int ops) {
|
||||
static void *ref[KS]; memset(ref, 0, sizeof ref);
|
||||
nvn_hmap m; nvn_hm_init(&m, klen);
|
||||
uint8_t k[32]; int bad = 0, live = 0;
|
||||
for (int t = 0; t < ops && !bad; t++) {
|
||||
uint32_t x = (uint32_t)(rnd() % KS); memset(k, 0xab, sizeof k); memcpy(k, &x, 4);
|
||||
int op = (int)(rnd() % 10);
|
||||
if (op < 5) { void *v = (void *)(uintptr_t)(t + 1), *old = nvn_hm_put(&m, k, v); bad |= old != ref[x]; live += !ref[x]; ref[x] = v; }
|
||||
else if (op < 8) { void *old = nvn_hm_del(&m, k); bad |= old != ref[x]; live -= !!ref[x]; ref[x] = NULL; }
|
||||
else bad |= nvn_hm_get(&m, k) != ref[x];
|
||||
if (t % 50000 == 49999) { nvn_hm_clear(&m, NULL); memset(ref, 0, sizeof ref); live = 0; }
|
||||
bad |= (int)m.n != live;
|
||||
}
|
||||
for (uint32_t x = 0; x < KS && !bad; x++) { memset(k, 0xab, sizeof k); memcpy(k, &x, 4); bad |= nvn_hm_get(&m, k) != ref[x]; } // 终态全量对照 | full comparison of the final state
|
||||
printf("键长 %2u:%d 次随机操作 + 终态 %d 键全量对照 期望全等 → 真结果 %s(终态 %u 项、容量 %u)\n", klen, ops, KS, bad ? "不等 ✗" : "全等 ✓", m.n, m.cap);
|
||||
free(m.keys); free(m.vals);
|
||||
return bad;
|
||||
}
|
||||
int main(void) {
|
||||
int fail = run(8, 190000) + run(20, 190000);
|
||||
printf("== 2 项,失败 %d ==\n", fail);
|
||||
return fail != 0;
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
// 真实NVN录制入口→生产Metal回放;8x6各mip独立手算,未设置viewport不借显式viewport规避。
|
||||
// Real NVN recording entry → production Metal replay; each mip of 8x6 is hand-calculated independently; with no viewport set, an explicit viewport is not used to dodge it.
|
||||
#include "../nvn/nvn_mtl.m"
|
||||
#include "../nvn/hle_nvn.c"
|
||||
uint64_t g_t0_ns; // 宿主 main.c 的进程起点(hle_nvn 逐帧 @t_s 用),单测替身 | process start time from host main.c (used by hle_nvn's per-frame @t_s); unit test stub
|
||||
void *front_metal_layer(void) { return NULL; }
|
||||
module_t *module_of(const void *p) { (void)p; return NULL; }
|
||||
module_t g_mod[MAX_MOD]; int g_nmod;
|
||||
void svc_thread_dump(void) {}
|
||||
uint64_t now_ns(void) { return bp_now(); }
|
||||
static int cases,failed; static prog_t colour_pg,depth_pg;
|
||||
#define EXPECT(n,w,v) do { uint64_t a=(w),b=(v);cases++;printf("%s 期望 %llu → 真结果 %llu %s\n",n,(unsigned long long)a,(unsigned long long)b,a==b?"✓":"✗");failed+=a!=b;}while(0)
|
||||
static tex_t make_tex(int w,int h,int levels,int format) {
|
||||
static uint64_t ser=90000; tex_t t={.serial=ser++};t.d.width=w;t.d.height=h;
|
||||
t.d.depth=t.d.samples=1;t.d.levels=levels;t.d.target=NVN_TEXTURE_TARGET_2D;t.d.format=format;return t;
|
||||
}
|
||||
typedef struct { NVNcommandBuffer cb; pool_t pool; void *mem; } recording;
|
||||
static recording begin(void) {
|
||||
recording r={0};if(posix_memalign(&r.mem,getpagesize(),65536))abort();memset(r.mem,0,65536);
|
||||
r.pool.mem=r.mem;r.pool.size=65536;mtl_pool_add(r.mem,65536);
|
||||
EXPECT("NVN command初始化",1,h_nvnCommandBufferInitialize(&r.cb,NULL));
|
||||
h_nvnCommandBufferAddCommandMemory(&r.cb,(const NVNmemoryPool *)&r.pool,0,65536);h_nvnCommandBufferBeginRecording(&r.cb);return r;
|
||||
}
|
||||
static void target(recording *r,const tex_t *t,int lv,int slot,const tex_t *other,int other_lv,int depth) {
|
||||
NVNtextureView view,ov;h_nvnTextureViewSetDefaults(&view);h_nvnTextureViewSetLevels(&view,lv,1);
|
||||
h_nvnTextureViewSetDefaults(&ov);h_nvnTextureViewSetLevels(&ov,other_lv,1);
|
||||
const NVNtexture *ct[2]={NULL,NULL};const NVNtextureView *cv[2]={NULL,NULL};
|
||||
if(!depth){ct[slot]=(const NVNtexture *)t;cv[slot]=&view;if(other){ct[1]=(const NVNtexture *)other;cv[1]=&ov;}}
|
||||
h_nvnCommandBufferSetRenderTargets(&r->cb,depth?0:other?2:slot+1,ct,cv,depth?(const NVNtexture *)t:NULL,depth?&view:NULL);
|
||||
// 录制后改view不应改变已录level;源码保留原参数快照。
|
||||
// Changing the view after recording must not change the recorded level; the source keeps a snapshot of the original parameters.
|
||||
h_nvnTextureViewSetLevels(&view,0,1);
|
||||
}
|
||||
static void finish(recording *r) {
|
||||
NVNcommandHandle h=h_nvnCommandBufferEndRecording(&r->cb);state_reset();memset(&R,0,sizeof R);
|
||||
mtl_sub_begin();mtl_exec((const uint8_t *)h);
|
||||
int done=mtl_wait(mtl_sub_commit(),5000000000ull);EXPECT("生产GPU完成",1,done);if(!done)abort();EXPECT("提交反馈无错误",0,mtl_last_commit_error());
|
||||
mtl_pool_del(r->mem);free(r->mem);
|
||||
}
|
||||
static void seed(const tex_t *t) {
|
||||
id<MTLTexture> m=tex_mtl(t);id<MTLCommandBuffer> cb=[g_q commandBuffer];
|
||||
for(int l=0;l<t->d.levels;l++){MTLRenderPassDescriptor *p=[MTLRenderPassDescriptor renderPassDescriptor];
|
||||
if(t->d.format==NVN_FORMAT_RGBA8){p.colorAttachments[0].texture=m;p.colorAttachments[0].level=l;
|
||||
p.colorAttachments[0].loadAction=MTLLoadActionClear;p.colorAttachments[0].storeAction=MTLStoreActionStore;p.colorAttachments[0].clearColor=MTLClearColorMake(0,0,1,1);}
|
||||
else if(t->d.format==NVN_FORMAT_STENCIL8){p.stencilAttachment.texture=m;p.stencilAttachment.level=l;p.stencilAttachment.loadAction=MTLLoadActionClear;p.stencilAttachment.storeAction=MTLStoreActionStore;p.stencilAttachment.clearStencil=0;}
|
||||
else {p.depthAttachment.texture=m;p.depthAttachment.level=l;p.depthAttachment.loadAction=MTLLoadActionClear;p.depthAttachment.storeAction=MTLStoreActionStore;p.depthAttachment.clearDepth=.75;}
|
||||
if(t->d.format==NVN_FORMAT_DEPTH32F_STENCIL8){p.stencilAttachment.texture=m;p.stencilAttachment.level=l;p.stencilAttachment.loadAction=MTLLoadActionClear;p.stencilAttachment.storeAction=MTLStoreActionStore;p.stencilAttachment.clearStencil=0;}
|
||||
[[cb renderCommandEncoderWithDescriptor:p] endEncoding];}
|
||||
[cb commit];[cb waitUntilCompleted];EXPECT("独立Metal种子完成",4,cb.status);
|
||||
}
|
||||
static uint8_t *read_mip(const tex_t *t,int lv,int w,int h,int bpp) {
|
||||
NSUInteger row=(w*bpp+15)&~15u;id<MTLBuffer> buf=[g_dev newBufferWithLength:row*h options:MTLResourceStorageModeShared];
|
||||
id<MTLCommandBuffer> cb=[g_q commandBuffer];id<MTLBlitCommandEncoder> b=[cb blitCommandEncoder];
|
||||
id<MTLTexture> src=tex_mtl(t);MTLBlitOption opt=t->d.format==NVN_FORMAT_DEPTH32F_STENCIL8?(bpp==1?MTLBlitOptionStencilFromDepthStencil:MTLBlitOptionDepthFromDepthStencil):MTLBlitOptionNone;
|
||||
[b copyFromTexture:src sourceSlice:0 sourceLevel:lv sourceOrigin:MTLOriginMake(0,0,0) sourceSize:MTLSizeMake(w,h,1)
|
||||
toBuffer:buf destinationOffset:0 destinationBytesPerRow:row destinationBytesPerImage:row*h options:opt];[b endEncoding];[cb commit];[cb waitUntilCompleted];EXPECT("逐纹素读回完成",4,cb.status);
|
||||
uint8_t *out=malloc(w*h*bpp);for(int y=0;y<h;y++)memcpy(out+y*w*bpp,(uint8_t *)buf.contents+y*row,w*bpp);return out;
|
||||
}
|
||||
static void save(const char *name,int lv,const uint8_t *out,int n) {
|
||||
const char *dir=getenv("DM_GFX_FIXTURE_OUT");if(!dir)return;char path[1024];snprintf(path,sizeof path,"%s/%s_lv%d.raw",dir,name,lv);
|
||||
FILE *f=fopen(path,"wb");if(!f||fwrite(out,1,n,f)!=n)abort();fclose(f);
|
||||
}
|
||||
static void colour_check(const char *name,const tex_t *t,int lv,int kind,int draw_w,int draw_h,int partial) {
|
||||
// 四级尺寸是题面常数表,不调被测mip helper。
|
||||
// The four level sizes are a constant table given by the problem statement; the mip helper under test is not called.
|
||||
static const int W[]={8,4,2,1},H[]={6,3,1,1};
|
||||
for(int l=0;l<4;l++){int w=W[l],h=H[l],bad=0;uint8_t *out=read_mip(t,l,w,h,4);
|
||||
for(int y=0;y<h;y++)for(int x=0;x<w;x++){uint8_t want[4]={0,0,255,255};
|
||||
int in=l==lv&&x<draw_w&&y<draw_h&&(!partial||(x>=1&&x<3&&y==1));
|
||||
if(in&&kind==1){want[0]=255;want[2]=0;} // 合法NVN full clear红 | valid NVN full clear: red
|
||||
if(in&&kind==2){int rx=5*(2*x+1)>=4*draw_w,by=5*(2*y+1)>=4*draw_h;
|
||||
want[0]=rx?0:255;want[1]=rx?255:0;want[2]=by?255:0;}
|
||||
bad+=memcmp(out+4*(y*w+x),want,4)!=0;}
|
||||
char label[128];snprintf(label,sizeof label,"%s lv%d %d纹素",name,l,w*h);EXPECT(label,0,bad);save(name,l,out,w*h*4);free(out);}
|
||||
}
|
||||
static void colour_case(const char *name,int lv,int sc,int clear_only,int slot,int mrt) {
|
||||
static const int W[]={8,4,2,1},H[]={6,3,1,1};int w=W[lv],h=H[lv];tex_t t=make_tex(8,6,4,NVN_FORMAT_RGBA8),other=make_tex(8,6,4,NVN_FORMAT_RGBA8);
|
||||
seed(&t);if(mrt)seed(&other);recording r=begin();target(&r,&t,lv,slot,mrt?&other:NULL,1,0);
|
||||
if(mrt){w=4;h=3;}
|
||||
if(sc==1)h_nvnCommandBufferSetScissor(&r.cb,0,0,w,h);
|
||||
if(sc==2)h_nvnCommandBufferSetScissor(&r.cb,-2,-3,30,40);
|
||||
if(sc==3)h_nvnCommandBufferSetScissor(&r.cb,1,1,2,1);
|
||||
if(clear_only){float red[4]={1,0,0,1};h_nvnCommandBufferClearColor(&r.cb,slot,red,15);}
|
||||
else {h_nvnCommandBufferBindProgram(&r.cb,(const NVNprogram *)&colour_pg,3);h_nvnCommandBufferDrawArrays(&r.cb,NVN_DRAW_PRIMITIVE_TRIANGLES,0,3);}
|
||||
finish(&r);NSUInteger pre_w,pre_h;rt_dims(&pre_w,&pre_h);EXPECT("预检查首目标selected宽上界",W[lv],pre_w);EXPECT("预检查首目标selected高上界",H[lv],pre_h);
|
||||
if(sc!=3||!clear_only){EXPECT("实际pass有效宽",w,g_pass.tw);EXPECT("实际pass有效高",h,g_pass.th);}
|
||||
colour_check(name,&t,lv,clear_only?(sc==3?0:1):2,w,h,sc==3);
|
||||
if(mrt)colour_check("MRT未写附件",&other,-1,0,0,0,0);
|
||||
}
|
||||
static void plane_case(const char *name,int stencil,int clear_only) {
|
||||
tex_t t=make_tex(8,6,4,stencil?NVN_FORMAT_DEPTH32F_STENCIL8:NVN_FORMAT_DEPTH32F);seed(&t);recording r=begin();target(&r,&t,1,0,NULL,0,1);
|
||||
if(clear_only){h_nvnCommandBufferSetScissor(&r.cb,0,0,4,3);h_nvnCommandBufferClearDepthStencil(&r.cb,.25,!stencil,0x5a,stencil?255:0);}
|
||||
else {ds_st ds={.dt=!stencil,.dw=!stencil,.df=NVN_DEPTH_FUNC_ALWAYS,.st=stencil,.sf_f=8,.sf_b=8,.fail_f=1,.zfail_f=1,.zpass_f=3,.fail_b=1,.zfail_b=1,.zpass_b=3};
|
||||
p_bind_state st={.kind=5};memcpy(st.bytes,&ds,sizeof ds);*REC(&r.cb,OP_BIND_STATE,p_bind_state)=st;
|
||||
if(stencil)for(int k=0;k<3;k++)*REC(&r.cb,OP_STENCIL,p_stencil)=(p_stencil){.face=3,.which=k,.value_mask=255,.mask=255,.ref=0x5a};
|
||||
h_nvnCommandBufferBindProgram(&r.cb,(const NVNprogram *)&depth_pg,1);h_nvnCommandBufferDrawArrays(&r.cb,NVN_DRAW_PRIMITIVE_TRIANGLES,0,3);}
|
||||
finish(&r);EXPECT("depth/stencil有效宽",4,g_pass.tw);EXPECT("depth/stencil有效高",3,g_pass.th);
|
||||
static const int W[]={8,4,2,1},H[]={6,3,1,1};for(int l=0;l<4;l++){int n=W[l]*H[l],bad=0;uint8_t *b=read_mip(&t,l,W[l],H[l],stencil?1:4);
|
||||
for(int i=0;i<n;i++)if(stencil)bad+=b[i]!=(l==1?0x5a:0);else bad+=((float *)b)[i]!=(l==1?.25f:.75f);
|
||||
EXPECT("选中plane逐纹素/未选级不变",0,bad);save(name,l,b,n*(stencil?1:4));free(b);}
|
||||
if(stencil)for(int l=0;l<4;l++){int n=W[l]*H[l],bad=0;uint8_t *b=read_mip(&t,l,W[l],H[l],4);
|
||||
for(int i=0;i<n;i++)bad+=((float *)b)[i]!=.75f;EXPECT("模板操作不改深度plane",0,bad);
|
||||
char label[96];snprintf(label,sizeof label,"%s_preserved_depth",name);save(label,l,b,n*4);free(b);}
|
||||
}
|
||||
int main(int argc,char **argv){@autoreleasepool{
|
||||
setvbuf(stdout,NULL,_IONBF,0);int stencil_only=argc>1&&!strcmp(argv[1],"--stencil-only");setenv("DM_NVN_TBDR",stencil_only?"1":"0",1);mtl_init();NSError *e=nil;
|
||||
id<MTLLibrary> lib=[g_dev newLibraryWithSource:@"#include <metal_stdlib>\nusing namespace metal;struct O{float4 p[[position]];float2 uv[[user(locn0)]];};\n"
|
||||
"vertex O v(uint n[[vertex_id]]){float2 p[3]={float2(-1,-1),float2(3,-1),float2(-1,3)};return {float4(p[n],.25,1),float2((p[n].x+1)/2,(1-p[n].y)/2)};}\n"
|
||||
"fragment float4 f(O o[[stage_in]]){return float4(o.uv.x<.4?1:0,o.uv.x<.4?0:1,o.uv.y<.4?0:1,1);}\n" options:nil error:&e];if(!lib){fprintf(stderr,"%s\n",e.localizedDescription.UTF8String);return 2;}
|
||||
for(int i=0;i<2;i++){NvProg *p=[NvProg new];p->sh[0]=[NvShader new];p->sh[0]->fn=[lib newFunctionWithName:@"v"];
|
||||
if(!i){p->sh[1]=[NvShader new];p->sh[1]->fn=[lib newFunctionWithName:@"f"];p->sh[1]->stage=1;}
|
||||
(i?&depth_pg:&colour_pg)->serial=80000+i;serial_put(80000+i,p);}
|
||||
if(stencil_only){plane_case("stencil_only",1,0);EXPECT("现有only-stencil模式",3,g_enc_mode);EXPECT("仅模板不挂深度",1,g_pass.hs&&!g_pass.hd);}
|
||||
else if(argc>1&&!strcmp(argv[1],"--default"))colour_case("default",1,0,0,0,0);
|
||||
else if(argc>1&&!strcmp(argv[1],"--oversized"))colour_case("oversized",1,2,0,0,0);
|
||||
else {for(int lv=0;lv<4;lv++){char name[64];snprintf(name,sizeof name,"bounded_L%d",lv);colour_case(name,lv,1,0,0,0);
|
||||
snprintf(name,sizeof name,"clear_L%d",lv);colour_case(name,lv,1,1,0,0);}
|
||||
colour_case("partial_draw",1,3,0,0,0);colour_case("partial_clear_reject",1,3,1,0,0);colour_case("slot1_clear",1,1,1,1,0);
|
||||
if(argc==1){colour_case("default",1,0,0,0,0);colour_case("oversized",1,2,0,0,0);colour_case("MRT_min",0,0,0,0,1);plane_case("depth",0,0);plane_case("stencil",1,0);plane_case("depth_clear",0,1);plane_case("stencil_clear",1,1);}}
|
||||
printf("== %d 项,失败 %d ==\n",cases,failed);return failed!=0;
|
||||
}}
|
||||
@@ -0,0 +1,371 @@
|
||||
// NVN 空设备单测:照游戏的用法从 nvnBootstrapLoader 取址,一路走到出图;期望值全部手算,不调被测实现。
|
||||
// 编译运行见 dm/gfx/tests/Makefile(make -C dm/gfx/tests)。
|
||||
// NVN null device unit tests: look up addresses from nvnBootstrapLoader the way the game does and go all the way to present; all expected values are hand-calculated, without calling the implementation under test.
|
||||
// For build and run see dm/gfx/tests/Makefile (make -C dm/gfx/tests).
|
||||
#include "../nvn/hle_nvn.c"
|
||||
uint64_t g_t0_ns; // 宿主 main.c 的进程起点(hle_nvn 逐帧 @t_s 用),单测替身 | process start time from host main.c (used by hle_nvn's per-frame @t_s); unit test stub
|
||||
#include "../tex/nvn_deswizzle.h"
|
||||
#include <time.h>
|
||||
void *front_metal_layer(void) { return NULL; } // 单测无窗口:出图只计数 | no window in unit tests: present only counts
|
||||
module_t *module_of(const void *p) { (void)p; return NULL; } // 单测无客体模块 | no guest modules in unit tests
|
||||
module_t g_mod[MAX_MOD]; int g_nmod; // crash.c 依赖的宿主符号 | host symbols that crash.c depends on
|
||||
void svc_thread_dump(void) {}
|
||||
void crash_install(void);
|
||||
void nvn_present_config(int hz, int display_mode);
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
uint64_t now_ns(void) { struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return (uint64_t)t.tv_sec * 1000000000ull + t.tv_nsec; }
|
||||
|
||||
static int g_fail, g_n;
|
||||
#define EXPECT(name, want, got) do { long long w_ = (long long)(want), g_ = (long long)(got); g_n++; \
|
||||
printf("%-44s 期望 %-12lld → 真结果 %-12lld %s\n", name, w_, g_, w_ == g_ ? "✓" : "✗"); if (w_ != g_) g_fail++; } while (0)
|
||||
|
||||
#define P(name) ((NVNT_##name)proc(#name))
|
||||
static PFNNVNDEVICEGETPROCADDRESSPROC gpa; static NVNdevice dev;
|
||||
static void *proc(const char *n) { void *p = (void *)gpa(&dev, n); if (!p) { printf("取址失败 %s\n", n); exit(1); } return p; }
|
||||
|
||||
// 命令内存回调:每次给一段 256 字节的新内存(强制多段 JUMP 链)
|
||||
// Command memory callback: hands out a new 256-byte memory segment each time (forces a multi-segment JUMP chain)
|
||||
static uint8_t g_cmdmem[64 * 1024]; static size_t g_cmdoff; static int g_cb_calls; static NVNmemoryPool g_cmdpool;
|
||||
static void mem_cb(NVNcommandBuffer *c, NVNcommandBufferMemoryEvent ev, size_t minsz, void *data) {
|
||||
(void)data; g_cb_calls++;
|
||||
if (ev != NVN_COMMAND_BUFFER_MEMORY_EVENT_OUT_OF_COMMAND_MEMORY) return;
|
||||
size_t n = minsz > 256 ? minsz : 256;
|
||||
P(nvnCommandBufferAddCommandMemory)(c, &g_cmdpool, (ptrdiff_t)g_cmdoff, n); g_cmdoff += n;
|
||||
}
|
||||
|
||||
// 挂起单测:另一线程里做提交
|
||||
// Suspend unit test: do the submit on another thread
|
||||
static _Atomic int g_sstarted, g_sdone; static pthread_mutex_t g_smu = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t g_scv = PTHREAD_COND_INITIALIZER;
|
||||
static NVNqueue *g_sq; static NVNcommandHandle g_sh; static NVNT_nvnQueueSubmitCommands g_sub;
|
||||
static void *susp_thr(void *a) { (void)a; pthread_mutex_lock(&g_smu); atomic_store(&g_sstarted, 1); pthread_cond_broadcast(&g_scv); pthread_mutex_unlock(&g_smu); g_sub(g_sq, 1, &g_sh); atomic_store(&g_sdone, 1); return NULL; }
|
||||
static int wait_started(void) { struct timespec dl; clock_gettime(CLOCK_REALTIME, &dl); dl.tv_sec += 10; pthread_mutex_lock(&g_smu); while (!atomic_load(&g_sstarted) && pthread_cond_timedwait(&g_scv, &g_smu, &dl) == 0) {} int ok = atomic_load(&g_sstarted); pthread_mutex_unlock(&g_smu); return ok; }
|
||||
|
||||
static size_t tex_size(int fmt, int w, int h, int flags, size_t *align) {
|
||||
NVNtextureBuilder tb;
|
||||
P(nvnTextureBuilderSetDevice)(&tb, &dev); P(nvnTextureBuilderSetDefaults)(&tb);
|
||||
P(nvnTextureBuilderSetFlags)(&tb, flags); P(nvnTextureBuilderSetTarget)(&tb, NVN_TEXTURE_TARGET_2D);
|
||||
P(nvnTextureBuilderSetWidth)(&tb, w); P(nvnTextureBuilderSetHeight)(&tb, h); P(nvnTextureBuilderSetFormat)(&tb, fmt);
|
||||
if (align) *align = P(nvnTextureBuilderGetStorageAlignment)(&tb);
|
||||
return P(nvnTextureBuilderGetStorageSize)(&tb);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
crash_install(); // 生产同一套 SIGSEGV / SIGBUS 处理(缺页钩子在其中分发) | the same SIGSEGV / SIGBUS handling as production (the page-fault hook is dispatched from within it)
|
||||
// 1. 引导取址:bootstrap 取 GetProcAddress,再用它取全部名字
|
||||
// 1. Bootstrap address lookup: bootstrap gets GetProcAddress, then uses it to get all the names
|
||||
PFNNVNBOOTSTRAPLOADERPROC boot = (PFNNVNBOOTSTRAPLOADERPROC)h_nvnBootstrapLoader;
|
||||
gpa = (PFNNVNDEVICEGETPROCADDRESSPROC)boot("nvnDeviceGetProcAddress");
|
||||
EXPECT("bootstrap 取 GetProcAddress 非空", 1, gpa != NULL);
|
||||
int nonnull = 0; for (unsigned i = 0; i < NVN_NFUNC; i++) nonnull += gpa(NULL, nvn_names[i]) != NULL;
|
||||
EXPECT("523 个名字全部取到地址", 523, nonnull);
|
||||
EXPECT("未知名字取址返回空", 0, gpa(NULL, "nvnNoSuchFunction") != NULL);
|
||||
|
||||
// 2. 设备
|
||||
// 2. Device
|
||||
NVNdeviceBuilder db; P(nvnDeviceBuilderSetDefaults)(&db); P(nvnDeviceBuilderSetFlags)(&db, 0);
|
||||
EXPECT("DeviceInitialize 成功", 1, P(nvnDeviceInitialize)(&dev, &db));
|
||||
int v; P(nvnDeviceGetInteger)(&dev, NVN_DEVICE_INFO_UNIFORM_BUFFER_ALIGNMENT, &v);
|
||||
EXPECT("uniform 缓冲对齐(X1 实测 256)", 256, v);
|
||||
P(nvnDeviceGetInteger)(&dev, NVN_DEVICE_INFO_TEXTURE_DESCRIPTOR_SIZE, &v); EXPECT("贴图描述符大小(32)", 32, v);
|
||||
P(nvnDeviceGetInteger)(&dev, NVN_DEVICE_INFO_QUEUE_COMMAND_MEMORY_MIN_SIZE, &v); EXPECT("队列命令内存下限(65536)", 65536, v);
|
||||
|
||||
// 3. 内存池:GPU 地址 = 游戏给的存储地址
|
||||
// 3. Memory pool: GPU address = the storage address given by the game
|
||||
static uint8_t poolmem[1 << 20] __attribute__((aligned(4096)));
|
||||
NVNmemoryPoolBuilder pb; NVNmemoryPool pool;
|
||||
P(nvnMemoryPoolBuilderSetDevice)(&pb, &dev); P(nvnMemoryPoolBuilderSetDefaults)(&pb);
|
||||
P(nvnMemoryPoolBuilderSetStorage)(&pb, poolmem, sizeof poolmem); P(nvnMemoryPoolBuilderSetFlags)(&pb, 0x24);
|
||||
EXPECT("MemoryPoolInitialize 成功", 1, P(nvnMemoryPoolInitialize)(&pool, &pb));
|
||||
EXPECT("池 GPU 地址 = 存储地址", (long long)(uintptr_t)poolmem, P(nvnMemoryPoolGetBufferAddress)(&pool));
|
||||
|
||||
// 4. 贴图存储尺寸(块线性:GOB = 64 B × 8 行;块高按「高×1.5」取 GOB 数 ≥16→16、≥8→8 …)
|
||||
// 256×256 RGBA8:每行 1024 B = 16 GOB;高 256 行 = 32 GOB 行,块高 16 GOB → 2 块;16×2×(512×16) = 262144
|
||||
// 4. Texture storage size (block-linear: GOB = 64 B × 8 rows; block height from the GOB count of "height × 1.5": ≥16→16, ≥8→8 ...)
|
||||
// 256×256 RGBA8: 1024 B per row = 16 GOBs; height 256 rows = 32 GOB rows, block height 16 GOBs → 2 blocks; 16×2×(512×16) = 262144
|
||||
size_t al; EXPECT("256x256 RGBA8 尺寸", 262144, tex_size(NVN_FORMAT_RGBA8, 256, 256, 0, &al));
|
||||
EXPECT("块线性对齐", 512, al);
|
||||
// 100×100 RGBA8:400 B → 7 GOB 宽;高 100 → 13 GOB 行,1.5 倍 = 150 行 = 19 GOB → 块高 16 → 1 块;7×1×8192 = 57344
|
||||
// 100×100 RGBA8: 400 B → 7 GOBs wide; height 100 → 13 GOB rows, ×1.5 = 150 rows = 19 GOBs → block height 16 → 1 block; 7×1×8192 = 57344
|
||||
EXPECT("100x100 RGBA8 尺寸", 57344, tex_size(NVN_FORMAT_RGBA8, 100, 100, 0, NULL));
|
||||
// 128×128 DXT1:32×32 块、8 B/块 → 256 B = 4 GOB 宽;32 行 → 1.5 倍 48 行 = 6 GOB → 块高 4 → 4 GOB 行 = 1 块;4×1×2048 = 8192
|
||||
// 128×128 DXT1: 32×32 blocks, 8 B/block → 256 B = 4 GOBs wide; 32 rows → ×1.5 = 48 rows = 6 GOBs → block height 4 → 4 GOB rows = 1 block; 4×1×2048 = 8192
|
||||
EXPECT("128x128 DXT1 尺寸", 8192, tex_size(NVN_FORMAT_RGBA_DXT1, 128, 128, 0, NULL));
|
||||
// LINEAR 100×100 RGBA8:行距 400 按 32 对齐 = 416;416×100 = 41600,对齐 32
|
||||
// LINEAR 100×100 RGBA8: row pitch 400 aligned to 32 = 416; 416×100 = 41600, aligned to 32
|
||||
EXPECT("线性 100x100 RGBA8 尺寸", 41600, tex_size(NVN_FORMAT_RGBA8, 100, 100, NVN_TEXTURE_FLAGS_LINEAR, &al));
|
||||
EXPECT("线性对齐", 32, al);
|
||||
|
||||
// 5. 命令缓冲:录 uniform 更新 / 事件 / 计数器 / 缓冲拷贝 / 嵌套调用,内存 256 B 一段逼出多段链接
|
||||
// 5. Command buffer: record uniform updates / events / counters / buffer copies / nested calls, with memory in 256 B segments to force multi-segment linking
|
||||
NVNcommandBuffer cb; P(nvnCommandBufferInitialize)(&cb, &dev);
|
||||
NVNmemoryPoolBuilder cpb; P(nvnMemoryPoolBuilderSetDefaults)(&cpb); P(nvnMemoryPoolBuilderSetStorage)(&cpb, g_cmdmem, sizeof g_cmdmem);
|
||||
P(nvnMemoryPoolInitialize)(&g_cmdpool, &cpb);
|
||||
P(nvnCommandBufferSetMemoryCallback)(&cb, mem_cb); P(nvnCommandBufferSetMemoryCallbackData)(&cb, NULL);
|
||||
NVNeventBuilder eb; NVNevent ev; P(nvnEventBuilderSetDefaults)(&eb); P(nvnEventBuilderSetStorage)(&eb, &pool, 0x1000);
|
||||
P(nvnEventInitialize)(&ev, &eb);
|
||||
uint8_t *ub = poolmem + 0x2000, *cnt = poolmem + 0x3000, *src = poolmem + 0x4000, *dst = poolmem + 0x5000;
|
||||
for (int i = 0; i < 64; i++) src[i] = (uint8_t)(i * 3 + 1);
|
||||
uint32_t data[16];
|
||||
|
||||
P(nvnCommandBufferBeginRecording)(&cb);
|
||||
EXPECT("录制中", 1, P(nvnCommandBufferIsRecording)(&cb));
|
||||
for (int k = 0; k < 20; k++) { // 20 次更新同一缓冲不同偏移,每次 64 B 数据 | 20 updates to different offsets of the same buffer, 64 B of data each
|
||||
for (int i = 0; i < 16; i++) data[i] = k * 100 + i;
|
||||
P(nvnCommandBufferUpdateUniformBuffer)(&cb, (NVNbufferAddress)ub, 4096, k * 64, 64, data);
|
||||
memset(data, 0xEE, sizeof data); // 录完改原数据:提交时必须用录制时拷进去的值 | modify the original data after recording: the submit must use the values copied in at record time
|
||||
}
|
||||
P(nvnCommandBufferSignalEvent)(&cb, &ev, NVN_EVENT_SIGNAL_MODE_WRITE, NVN_EVENT_SIGNAL_LOCATION_BOTTOM, 0, 7);
|
||||
P(nvnCommandBufferSignalEvent)(&cb, &ev, NVN_EVENT_SIGNAL_MODE_ADD, NVN_EVENT_SIGNAL_LOCATION_BOTTOM, 0, 5);
|
||||
P(nvnCommandBufferReportCounter)(&cb, NVN_COUNTER_TYPE_TIMESTAMP, (NVNbufferAddress)cnt);
|
||||
NVNcommandHandle h1 = P(nvnCommandBufferEndRecording)(&cb);
|
||||
EXPECT("录完不在录制", 0, P(nvnCommandBufferIsRecording)(&cb));
|
||||
P(nvnCommandBufferBeginRecording)(&cb);
|
||||
P(nvnCommandBufferCopyBufferToBuffer)(&cb, (NVNbufferAddress)src, (NVNbufferAddress)dst, 64, 0);
|
||||
P(nvnCommandBufferCopyCommands)(&cb, 1, &h1); // 嵌套:再执行一遍 h1(事件 7 → +5 → 再写 7 → +5) | nested: execute h1 once more (event 7 → +5 → write 7 again → +5)
|
||||
NVNcommandHandle h2 = P(nvnCommandBufferEndRecording)(&cb);
|
||||
printf("(命令内存回调 %d 次,用掉 %zu B)\n", g_cb_calls, g_cmdoff);
|
||||
EXPECT("命令内存回调至少 2 次(多段)", 1, g_cb_calls >= 2);
|
||||
EXPECT("提交前事件值仍为 0", 0, P(nvnEventGetValue)(&ev));
|
||||
|
||||
NVNqueueBuilder qb; NVNqueue q; static uint8_t qmem[1 << 19];
|
||||
P(nvnQueueBuilderSetDevice)(&qb, &dev); P(nvnQueueBuilderSetDefaults)(&qb);
|
||||
size_t qsz = P(nvnQueueBuilderGetQueueMemorySize)(&qb);
|
||||
EXPECT("队列内存 = 64K+256K+16K 取整 4K", 65536 + 262144 + 16384, qsz);
|
||||
P(nvnQueueBuilderSetQueueMemory)(&qb, qmem, qsz);
|
||||
EXPECT("QueueInitialize 成功", 1, P(nvnQueueInitialize)(&q, &qb));
|
||||
NVNcommandHandle hs[2] = {h1, h2};
|
||||
P(nvnQueueSubmitCommands)(&q, 2, hs);
|
||||
NVNsync sf; P(nvnSyncInitialize)(&sf, &dev); P(nvnQueueFenceSync)(&q, &sf, NVN_SYNC_CONDITION_ALL_GPU_COMMANDS_COMPLETE, 0);
|
||||
int wr = P(nvnSyncWait)(&sf, 5000000000ull);
|
||||
EXPECT("提交后围栏等待成功(0 或 1)", 1, wr == 0 || wr == 1);
|
||||
int ub_ok = 1;
|
||||
for (int k = 0; k < 20; k++) for (int i = 0; i < 16; i++) { uint32_t w; memcpy(&w, ub + k * 64 + i * 4, 4); ub_ok &= w == (uint32_t)(k * 100 + i); }
|
||||
EXPECT("uniform 缓冲 20×16 个字全等录制值", 1, ub_ok);
|
||||
EXPECT("事件值:h1(7,+5) h2 拷贝后再跑 h1(7,+5) = 12", 12, P(nvnEventGetValue)(&ev));
|
||||
EXPECT("缓冲拷贝 64 B 全等", 0, memcmp(src, dst, 64));
|
||||
uint64_t ts[2]; memcpy(ts, cnt, 16);
|
||||
EXPECT("计数器时间戳已写(非 0)", 1, ts[0] != 0 && ts[0] == ts[1]);
|
||||
|
||||
// 5b. 同步必须挡住 CPU:先排 24 次 64 MiB 拷贝把 GPU 占住,最后一条把 src 拷到 dst;
|
||||
// 等围栏返回后 CPU 才改写 src。若等待提前放行,最后那条拷贝会读到改写后的 src。
|
||||
// 5b. Sync must hold the CPU back: first queue 24 copies of 64 MiB to keep the GPU busy, with the last one copying src to dst;
|
||||
// the CPU rewrites src only after the fence wait returns. If the wait is released early, that last copy reads the rewritten src.
|
||||
{
|
||||
size_t big = 64u << 20, pgsz = 16384;
|
||||
uint8_t *heap; posix_memalign((void **)&heap, pgsz, 4 * big);
|
||||
uint8_t *busy_a = heap, *busy_b = heap + big, *bsrc = heap + 2 * big, *bdst = heap + 3 * big;
|
||||
memset(heap, 0, 4 * big); memset(bsrc, 0x5A, big);
|
||||
NVNmemoryPoolBuilder hb; NVNmemoryPool hp; P(nvnMemoryPoolBuilderSetDefaults)(&hb); P(nvnMemoryPoolBuilderSetStorage)(&hb, heap, 4 * big);
|
||||
P(nvnMemoryPoolInitialize)(&hp, &hb);
|
||||
P(nvnCommandBufferBeginRecording)(&cb);
|
||||
for (int i = 0; i < 24; i++) P(nvnCommandBufferCopyBufferToBuffer)(&cb, (NVNbufferAddress)busy_a, (NVNbufferAddress)busy_b, big, 0);
|
||||
P(nvnCommandBufferCopyBufferToBuffer)(&cb, (NVNbufferAddress)bsrc, (NVNbufferAddress)bdst, big, 0);
|
||||
NVNcommandHandle hb2 = P(nvnCommandBufferEndRecording)(&cb);
|
||||
NVNsync sb; P(nvnSyncInitialize)(&sb, &dev);
|
||||
uint64_t t0 = now_ns();
|
||||
P(nvnQueueSubmitCommands)(&q, 1, &hb2); P(nvnQueueFenceSync)(&q, &sb, NVN_SYNC_CONDITION_ALL_GPU_COMMANDS_COMPLETE, 0);
|
||||
int w0 = P(nvnSyncWait)(&sb, 0);
|
||||
int w1 = P(nvnSyncWait)(&sb, 10000000000ull);
|
||||
double ms = (now_ns() - t0) / 1e6;
|
||||
memset(bsrc, 0xC3, big); // 等待放行后才改写 | rewrite only after the wait is released
|
||||
size_t bad = 0; for (size_t i = 0; i < big; i += 4096) bad += bdst[i] != 0x5A;
|
||||
printf("(GPU 占用约 %.1f ms)\n", ms);
|
||||
EXPECT("刚提交时零超时等待 = 超时(2)", 2, w0);
|
||||
EXPECT("长等待 = 满足(1)", 1, w1);
|
||||
EXPECT("dst 全为改写前的值(抽 16384 处)", 0, bad);
|
||||
P(nvnMemoryPoolFinalize)(&hp); free(heap);
|
||||
}
|
||||
|
||||
// 6. 同步 / 窗口 / 出图
|
||||
// 6. Sync / window / present
|
||||
NVNsync s1, s2; P(nvnSyncInitialize)(&s1, &dev); P(nvnSyncInitialize)(&s2, &dev);
|
||||
EXPECT("未围栏的同步等待 = 超时(2)", 2, P(nvnSyncWait)(&s1, 0));
|
||||
P(nvnQueueFenceSync)(&q, &s1, NVN_SYNC_CONDITION_ALL_GPU_COMMANDS_COMPLETE, 0);
|
||||
EXPECT("围栏后等待 = 已就绪(0)", 0, P(nvnSyncWait)(&s1, 0));
|
||||
NVNtexture sc[2]; NVNtextureBuilder tb; P(nvnTextureBuilderSetDevice)(&tb, &dev); P(nvnTextureBuilderSetDefaults)(&tb);
|
||||
P(nvnTextureBuilderSetWidth)(&tb, 1280); P(nvnTextureBuilderSetHeight)(&tb, 720); P(nvnTextureBuilderSetFormat)(&tb, NVN_FORMAT_RGBA8);
|
||||
P(nvnTextureBuilderSetStorage)(&tb, &pool, 0); P(nvnTextureInitialize)(&sc[0], &tb); P(nvnTextureInitialize)(&sc[1], &tb);
|
||||
EXPECT("贴图宽", 1280, P(nvnTextureGetWidth)(&sc[0]));
|
||||
NVNtexture *scp[2] = {&sc[0], &sc[1]};
|
||||
NVNwindowBuilder wb; NVNwindow win; P(nvnWindowBuilderSetDevice)(&wb, &dev); P(nvnWindowBuilderSetDefaults)(&wb);
|
||||
P(nvnWindowBuilderSetTextures)(&wb, 2, scp); EXPECT("WindowInitialize 成功", 1, P(nvnWindowInitialize)(&win, &wb));
|
||||
int idx[4];
|
||||
for (int f = 0; f < 4; f++) {
|
||||
P(nvnWindowAcquireTexture)(&win, &s2, &idx[f]);
|
||||
for (int b = 0; b < 5; b++) P(nvnCommandBufferBarrier)(&cb, 0);
|
||||
P(nvnQueuePresentTexture)(&q, &win, idx[f]);
|
||||
}
|
||||
EXPECT("交换链轮转 0,1,0,1", 0x0101, idx[0] << 12 | idx[1] << 8 | idx[2] << 4 | idx[3]);
|
||||
EXPECT("取图后同步已就绪(0)", 0, P(nvnSyncWait)(&s2, 0));
|
||||
unsigned bi = 0; while (strcmp(nvn_names[bi], "nvnCommandBufferBarrier")) bi++;
|
||||
EXPECT("Barrier 计数 = 4 帧 × 5", 20, nvn_slot[bi].cnt);
|
||||
|
||||
// 6b. 读回:像素 (x,y) = {x*16+y, y*16+x, 0x55, 0xAA}(期望按公式直接算)
|
||||
// 6b. Readback: pixel (x,y) = {x*16+y, y*16+x, 0x55, 0xAA} (expected values computed directly from the formula)
|
||||
{
|
||||
#define PX(x, y, c) ((uint8_t)((c) == 0 ? (x) * 16 + (y) : (c) == 1 ? (y) * 16 + (x) : (c) == 2 ? 0x55 : 0xAA))
|
||||
static uint8_t rb[256 << 10] __attribute__((aligned(16384)));
|
||||
NVNmemoryPoolBuilder rpb; NVNmemoryPool rp; P(nvnMemoryPoolBuilderSetDefaults)(&rpb); P(nvnMemoryPoolBuilderSetStorage)(&rpb, rb, sizeof rb);
|
||||
P(nvnMemoryPoolInitialize)(&rp, &rpb);
|
||||
uint8_t *stage = rb + 0x8000, *outb = rb + 0xC000;
|
||||
for (int y = 0; y < 4; y++) for (int x = 0; x < 8; x++) for (int c = 0; c < 4; c++) stage[(y * 8 + x) * 4 + c] = PX(x, y, c);
|
||||
NVNtextureBuilder b; NVNtexture ta; P(nvnTextureBuilderSetDevice)(&b, &dev); P(nvnTextureBuilderSetDefaults)(&b);
|
||||
P(nvnTextureBuilderSetWidth)(&b, 8); P(nvnTextureBuilderSetHeight)(&b, 4); P(nvnTextureBuilderSetFormat)(&b, NVN_FORMAT_RGBA8);
|
||||
P(nvnTextureBuilderSetStorage)(&b, &rp, 0); P(nvnTextureInitialize)(&ta, &b);
|
||||
NVNcopyRegion all = {0, 0, 0, 8, 4, 1}, sub = {2, 1, 0, 5, 3, 1}, cp = {1, 0, 0, 4, 2, 1};
|
||||
P(nvnCommandBufferBeginRecording)(&cb);
|
||||
P(nvnCommandBufferSetCopyRowStride)(&cb, 0);
|
||||
P(nvnCommandBufferCopyBufferToTexture)(&cb, (NVNbufferAddress)stage, &ta, NULL, &all, 0);
|
||||
P(nvnCommandBufferSetCopyRowStride)(&cb, 64);
|
||||
P(nvnCommandBufferCopyTextureToBuffer)(&cb, &ta, NULL, &cp, (NVNbufferAddress)outb, 0);
|
||||
NVNcommandHandle hr = P(nvnCommandBufferEndRecording)(&cb);
|
||||
memset(outb, 0xEE, 256);
|
||||
P(nvnQueueSubmitCommands)(&q, 1, &hr); P(nvnQueueFinish)(&q);
|
||||
uint8_t got[5 * 3 * 4]; P(nvnTextureReadTexels)(&ta, NULL, &sub, got);
|
||||
int bad = 0; for (int y = 0; y < 3; y++) for (int x = 0; x < 5; x++) for (int c = 0; c < 4; c++) bad += got[(y * 5 + x) * 4 + c] != PX(x + 2, y + 1, c);
|
||||
EXPECT("ReadTexels 子区域 5x3 逐字节(GPU 写入的贴图)", 0, bad);
|
||||
uint8_t gs[4 * 40]; memset(gs, 0xEE, sizeof gs); P(nvnTextureReadTexelsStrided)(&ta, NULL, &all, gs, 40, 0);
|
||||
bad = 0; for (int y = 0; y < 4; y++) { for (int x = 0; x < 8; x++) for (int c = 0; c < 4; c++) bad += gs[y * 40 + x * 4 + c] != PX(x, y, c); for (int k = 32; k < 40; k++) bad += gs[y * 40 + k] != 0xEE; }
|
||||
EXPECT("ReadTexelsStrided 行距 40(行尾填充不动)", 0, bad);
|
||||
bad = 0; for (int y = 0; y < 2; y++) { for (int x = 0; x < 4; x++) for (int c = 0; c < 4; c++) bad += outb[y * 64 + x * 4 + c] != PX(x + 1, y, c); for (int k = 16; k < 64; k++) bad += outb[y * 64 + k] != 0xEE; }
|
||||
EXPECT("CopyTextureToBuffer 行距 64(GPU 拷回)", 0, bad);
|
||||
// 预排布贴图:池内存就是真值(块线性),ReadTexels 解排布直读
|
||||
// Packaged texture: the pool memory is the ground truth (block-linear); ReadTexels deswizzles and reads it directly
|
||||
uint8_t lin[16 * 8 * 4]; for (int y = 0; y < 8; y++) for (int x = 0; x < 16; x++) for (int c = 0; c < 4; c++) lin[(y * 16 + x) * 4 + c] = PX(x, y, c);
|
||||
NVNtexture tb; NVNpackagedTextureLayout lay = {{1, 0, 0, 0, 7, 0, 1, 0}};
|
||||
P(nvnTextureBuilderSetDefaults)(&b); P(nvnTextureBuilderSetWidth)(&b, 16); P(nvnTextureBuilderSetHeight)(&b, 8); P(nvnTextureBuilderSetFormat)(&b, NVN_FORMAT_RGBA8);
|
||||
P(nvnTextureBuilderSetPackagedTextureLayout)(&b, &lay); P(nvnTextureBuilderSetStorage)(&b, &rp, 0x10000); P(nvnTextureInitialize)(&tb, &b);
|
||||
nvn_texdesc dd = ((tex_t *)&tb)->d;
|
||||
if (nvn_swizzle(&dd, 0, 0, lin, 64, rb + 0x10000)) { printf("nvn_swizzle 失败\n"); g_fail++; }
|
||||
NVNcopyRegion s2 = {3, 2, 0, 9, 5, 1}; uint8_t g2[9 * 5 * 4];
|
||||
P(nvnTextureReadTexels)(&tb, NULL, &s2, g2);
|
||||
bad = 0; for (int y = 0; y < 5; y++) for (int x = 0; x < 9; x++) for (int c = 0; c < 4; c++) bad += g2[(y * 9 + x) * 4 + c] != PX(x + 3, y + 2, c);
|
||||
EXPECT("ReadTexels 预排布贴图 9x5(池内存块线性直读)", 0, bad);
|
||||
P(nvnMemoryPoolFinalize)(&rp);
|
||||
}
|
||||
|
||||
// 6c. 写保护脏页:预排布贴图上传后池页只读;游戏写 → 缺页 → 标脏 → 下次使用重传;宿主 read() 直写需先 prepare
|
||||
// 6c. Write-protected dirty pages: after a packaged texture is uploaded its pool pages are read-only; game write → page fault → mark dirty → re-upload on next use; a direct host read() write needs prepare first
|
||||
{
|
||||
static uint8_t wb_[256 << 10] __attribute__((aligned(16384)));
|
||||
NVNmemoryPoolBuilder wpb; NVNmemoryPool wp; P(nvnMemoryPoolBuilderSetDefaults)(&wpb); P(nvnMemoryPoolBuilderSetStorage)(&wpb, wb_, sizeof wb_);
|
||||
P(nvnMemoryPoolInitialize)(&wp, &wpb);
|
||||
NVNtextureBuilder b; NVNtexture tw; NVNpackagedTextureLayout lay = {{1, 0, 0, 0, 7, 0, 1, 0}};
|
||||
P(nvnTextureBuilderSetDevice)(&b, &dev); P(nvnTextureBuilderSetDefaults)(&b); P(nvnTextureBuilderSetWidth)(&b, 16); P(nvnTextureBuilderSetHeight)(&b, 8);
|
||||
P(nvnTextureBuilderSetFormat)(&b, NVN_FORMAT_RGBA8); P(nvnTextureBuilderSetPackagedTextureLayout)(&b, &lay);
|
||||
P(nvnTextureBuilderSetStorage)(&b, &wp, 0x10000); P(nvnTextureInitialize)(&tw, &b);
|
||||
nvn_texdesc dd = ((tex_t *)&tw)->d;
|
||||
uint8_t lin[16 * 8 * 4], *store = wb_ + 0x10000, *outb = wb_ + 0x20000;
|
||||
#define FILLPAT(k) for (int y = 0; y < 8; y++) for (int x = 0; x < 16; x++) for (int c = 0; c < 4; c++) lin[(y * 16 + x) * 4 + c] = (uint8_t)(x * 16 + y + (k) * 3 + c * 41)
|
||||
FILLPAT(0); nvn_swizzle(&dd, 0, 0, lin, 64, store);
|
||||
NVNcopyRegion all = {0, 0, 0, 16, 8, 1};
|
||||
// 用 GPU 拷回(CopyTextureToBuffer 读 MTLTexture)检验 GPU 侧实际内容:期望 = 第 k 版图案
|
||||
// Check the actual GPU-side contents with a GPU copy-back (CopyTextureToBuffer reading the MTLTexture): expected = pattern version k
|
||||
#define GPU_READ_EQ(k, name) do { P(nvnCommandBufferBeginRecording)(&cb); P(nvnCommandBufferSetCopyRowStride)(&cb, 0); \
|
||||
P(nvnCommandBufferCopyTextureToBuffer)(&cb, &tw, NULL, &all, (NVNbufferAddress)outb, 0); NVNcommandHandle hh = P(nvnCommandBufferEndRecording)(&cb); \
|
||||
P(nvnQueueSubmitCommands)(&q, 1, &hh); P(nvnQueueFinish)(&q); FILLPAT(k); EXPECT(name, 0, memcmp(outb, lin, sizeof lin)); } while (0)
|
||||
uint64_t up0, re0, fa0, pr0, up, re, fa, pr; mtl_pkg_stats(&up0, &re0); nvn_dirty_stats(&fa0, &pr0);
|
||||
GPU_READ_EQ(0, "首传:GPU 侧内容 = 第 0 版");
|
||||
mtl_pkg_stats(&up, &re); EXPECT("首传次数 +1", 1, up - up0);
|
||||
FILLPAT(1); nvn_swizzle(&dd, 0, 0, lin, 64, store); // 游戏式 CPU 写:受保护页 → 缺页 → 钩子标脏 | game-style CPU write: protected page → page fault → hook marks it dirty
|
||||
nvn_dirty_stats(&fa, &pr); EXPECT("游戏写触发缺页 ≥ 1 次(已被钩子接住、未崩)", 1, fa - fa0 >= 1);
|
||||
GPU_READ_EQ(1, "重传后 GPU 侧内容 = 第 1 版");
|
||||
mtl_pkg_stats(&up, &re); EXPECT("池内容变化重传 +1", 1, re - re0);
|
||||
uint64_t fa1 = fa; GPU_READ_EQ(1, "内容不变再用:仍为第 1 版");
|
||||
nvn_dirty_stats(&fa, &pr); mtl_pkg_stats(&up, &re); EXPECT("内容不变:缺页 +0", 0, fa - fa1); EXPECT("内容不变:重传仍为 1", 1, re - re0);
|
||||
// 坑一:宿主 read() 直写受保护页。不 prepare 时内核返回 EFAULT(不缺页);prepare 后读成功、标脏、下次重传
|
||||
// Pitfall 1: host read() writing directly into protected pages. Without prepare the kernel returns EFAULT (no page fault); after prepare the read succeeds, the pages are marked dirty and re-uploaded next time
|
||||
char path[1024]; snprintf(path, sizeof path, "%s/t_nvn_rd_XXXXXX", getenv("TMPDIR") ? getenv("TMPDIR") : "."); int fd = mkstemp(path); // 每用户临时目录,不写 /tmp | per-user temp directory, do not write to /tmp
|
||||
FILLPAT(2); uint8_t tmpst[sizeof lin * 4]; memset(tmpst, 0, sizeof tmpst);
|
||||
static uint8_t full[0x10000]; memcpy(full, store, sizeof full); // 现有存储内容(块线性),把第 2 版写进副本再存文件 | existing storage contents (block-linear); write version 2 into a copy and then save it to a file
|
||||
nvn_swizzle(&dd, 0, 0, lin, 64, full); if (write(fd, full, ((tex_t *)&tw)->L.size) < 0) g_fail++;
|
||||
ssize_t r0 = pread(fd, store, ((tex_t *)&tw)->L.size, 0); int e0 = errno;
|
||||
EXPECT("不 prepare:read() 进受保护页返回 -1 且 EFAULT", 1, r0 == -1 && e0 == EFAULT);
|
||||
dm_guest_write_prepare(store, ((tex_t *)&tw)->L.size);
|
||||
ssize_t r1 = pread(fd, store, ((tex_t *)&tw)->L.size, 0);
|
||||
EXPECT("prepare 后 read() 成功", (long long)((tex_t *)&tw)->L.size, r1);
|
||||
close(fd); unlink(path);
|
||||
GPU_READ_EQ(2, "宿主写后重传:GPU 侧内容 = 第 2 版");
|
||||
mtl_pkg_stats(&up, &re); EXPECT("宿主写触发重传,累计 2", 2, re - re0);
|
||||
P(nvnMemoryPoolFinalize)(&wp);
|
||||
}
|
||||
|
||||
// 6d. 生命周期:挂起返回时在途 GPU 工作为 0;挂起期间提交被挡住,恢复后放行
|
||||
// 6d. Lifecycle: in-flight GPU work is 0 when suspend returns; submits are blocked during suspend and let through after resume
|
||||
{
|
||||
size_t big = 64u << 20; uint8_t *heap; posix_memalign((void **)&heap, 16384, 2 * big); memset(heap, 0, 2 * big);
|
||||
NVNmemoryPoolBuilder hb; NVNmemoryPool hp; P(nvnMemoryPoolBuilderSetDefaults)(&hb); P(nvnMemoryPoolBuilderSetStorage)(&hb, heap, 2 * big);
|
||||
P(nvnMemoryPoolInitialize)(&hp, &hb);
|
||||
P(nvnCommandBufferBeginRecording)(&cb);
|
||||
for (int i = 0; i < 24; i++) P(nvnCommandBufferCopyBufferToBuffer)(&cb, (NVNbufferAddress)heap, (NVNbufferAddress)(heap + big), big, 0);
|
||||
NVNcommandHandle hbusy = P(nvnCommandBufferEndRecording)(&cb);
|
||||
P(nvnQueueSubmitCommands)(&q, 1, &hbusy);
|
||||
uint64_t f = mtl_last_fence();
|
||||
int busy_before = !mtl_wait(f, 0);
|
||||
dm_gfx_suspend(1);
|
||||
EXPECT("挂起前 GPU 确实在忙(零超时等待未完成)", 1, busy_before);
|
||||
EXPECT("挂起返回时在途工作已完成", 1, mtl_wait(f, 0));
|
||||
P(nvnCommandBufferBeginRecording)(&cb); P(nvnCommandBufferBarrier)(&cb, 0); NVNcommandHandle hsmall = P(nvnCommandBufferEndRecording)(&cb);
|
||||
g_sq = &q; g_sh = hsmall; g_sub = P(nvnQueueSubmitCommands); atomic_store(&g_sstarted, 0); atomic_store(&g_sdone, 0);
|
||||
pthread_t th; pthread_create(&th, NULL, susp_thr, NULL);
|
||||
int started = wait_started();
|
||||
EXPECT("挂起期间另一线程已进入提交且尚未返回", 1, started && !atomic_load(&g_sdone));
|
||||
dm_gfx_suspend(0);
|
||||
pthread_join(th, NULL);
|
||||
EXPECT("恢复后该提交放行返回", 1, atomic_load(&g_sdone));
|
||||
P(nvnQueueFinish)(&q); P(nvnMemoryPoolFinalize)(&hp); free(heap);
|
||||
}
|
||||
|
||||
// 6e. 出图节拍(真机语义):出图立即返回;阻塞在取图——交换链 3 张、间隔 1、60 Hz,第 4 次取图等到第 0 张显示满一周期
|
||||
// 6e. Present pacing (real-device semantics): present returns immediately; blocking happens at acquire - swapchain of 3, interval 1, 60 Hz, the 4th acquire waits until texture 0 has been displayed for a full period
|
||||
{
|
||||
nvn_present_config(60, 0);
|
||||
NVNwindowBuilder wb2; NVNwindow w2; P(nvnWindowBuilderSetDevice)(&wb2, &dev); P(nvnWindowBuilderSetDefaults)(&wb2);
|
||||
NVNtexture *sc3[3] = {&sc[0], &sc[1], &sc[0]};
|
||||
P(nvnWindowBuilderSetTextures)(&wb2, 3, sc3); P(nvnWindowInitialize)(&w2, &wb2); P(nvnWindowSetPresentInterval)(&w2, 1);
|
||||
int ix;
|
||||
for (int k = 0; k < 3; k++) {
|
||||
P(nvnWindowAcquireTexture)(&w2, NULL, &ix);
|
||||
P(nvnQueuePresentTexture)(&q, &w2, ix);
|
||||
}
|
||||
P(nvnWindowAcquireTexture)(&w2, NULL, &ix);
|
||||
EXPECT("第 4 次取到的是第 0 张", 0, ix);
|
||||
P(nvnQueuePresentTexture)(&q, &w2, ix);
|
||||
P(nvnWindowAcquireTexture)(&w2, NULL, &ix);
|
||||
EXPECT("第 5 次取到的是第 1 张", 1, ix);
|
||||
nvn_present_config(0, 0);
|
||||
}
|
||||
|
||||
// 6f. 出图线程:drawable 迟迟不可用(出图线程每次停 200 ms)时,出图调用仍立即返回;
|
||||
// 交换链转满一圈后,取回第 0 张要等它那次出图被处理完(第一次入队 + 200 ms)
|
||||
// 6f. Present thread: when the drawable stays unavailable for a long time (the present thread stalls 200 ms each time), the present call still returns immediately;
|
||||
// after the swapchain has gone a full round, re-acquiring texture 0 has to wait until its present has been processed (first enqueue + 200 ms)
|
||||
{
|
||||
nvn_present_config(0, 0); // 不按节拍等,只看出图线程归还 | do not wait on the display link; only check that the present thread hands it back
|
||||
const double S = 200;
|
||||
mtl_present_test_stall((uint64_t)(S * 1e6));
|
||||
NVNwindowBuilder wb3; NVNwindow w3; P(nvnWindowBuilderSetDevice)(&wb3, &dev); P(nvnWindowBuilderSetDefaults)(&wb3);
|
||||
NVNtexture *sc3[3] = {&sc[0], &sc[1], &sc[0]};
|
||||
P(nvnWindowBuilderSetTextures)(&wb3, 3, sc3); P(nvnWindowInitialize)(&w3, &wb3);
|
||||
int ix;
|
||||
for (int k = 0; k < 3; k++) {
|
||||
P(nvnWindowAcquireTexture)(&w3, NULL, &ix);
|
||||
P(nvnQueuePresentTexture)(&q, &w3, ix);
|
||||
}
|
||||
P(nvnWindowAcquireTexture)(&w3, NULL, &ix);
|
||||
EXPECT("取到的是第 0 张", 0, ix);
|
||||
mtl_present_test_stall(0); mtl_present_flush();
|
||||
}
|
||||
|
||||
// 7. 未实现函数:返回 0、报红、只报一次
|
||||
// 7. Unimplemented functions: return 0, report a failure, report only once
|
||||
unsigned ui = 0; while (strcmp(nvn_names[ui], "nvnBufferBuilderSetDefaults")) ui++;
|
||||
((void (*)(void *))proc("nvnBufferBuilderSetDefaults"))(NULL); ((void (*)(void *))proc("nvnBufferBuilderSetDefaults"))(NULL);
|
||||
EXPECT("未实现函数被调用后记为已报红", 1, g_unimpl_seen[ui] > 0);
|
||||
EXPECT("未实现函数计数 2", 2, nvn_slot[ui].cnt);
|
||||
|
||||
printf("== %d 项,失败 %d ==\n", g_n, g_fail);
|
||||
return g_fail != 0;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// 节拍器单测:给定时钟序列,期望等待时长手算。周期 16.666 ms 记为 P = 16666667 ns。
|
||||
// Pacer unit tests: given a clock sequence, the expected wait durations are hand-calculated. The period 16.666 ms is written as P = 16666667 ns.
|
||||
#include "../nvn/nvn_pace.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
const uint64_t P = 16666667, MS = 1000000;
|
||||
struct { uint64_t now, period, want; const char *why; } c[] = {
|
||||
{1000 * MS, P, 0, "首帧:起拍,不等"},
|
||||
{1005 * MS, P, 1000 * MS + P - 1005 * MS, "早到 5 ms:等到 1000+P"},
|
||||
{1000 * MS + 2 * P - 2 * MS, P, 2 * MS, "第三帧早 2 ms:等 2 ms"},
|
||||
{1000 * MS + 3 * P + 3 * MS, P, 0, "迟到 3 ms(不足一周期):立即出图,节拍点仍为 1000+3P"},
|
||||
{1000 * MS + 4 * P - 1 * MS, P, 1 * MS, "下一帧早 1 ms:按原相位等到 1000+4P"},
|
||||
{1000 * MS + 7 * P, P, 0, "落后两个周期(卡顿):重新起拍于当时,不连发追帧"},
|
||||
{1000 * MS + 7 * P + 4 * MS, P, P - 4 * MS, "重新起拍后的下一帧:等到新目标"},
|
||||
{1000 * MS + 9 * P, 0, 0, "周期 0(DM_PRESENT_HZ=0):不等"},
|
||||
{1000 * MS + 9 * P + 1 * MS, 2 * P, 2 * P - 1 * MS, "切回间隔 2:节拍点 = 上帧时刻 9P + 2P"},
|
||||
{1000 * MS + 11 * P + 3 * MS, 2 * P, 2 * P - 3 * MS, "间隔 2 下一帧:节拍点 13P"},
|
||||
};
|
||||
nvn_pacer p = {0}; int fail = 0, n = sizeof c / sizeof *c;
|
||||
for (int i = 0; i < n; i++) {
|
||||
uint64_t got = nvn_pace(&p, c[i].now, c[i].period);
|
||||
int ok = got == c[i].want;
|
||||
printf("%-52s 期望等 %8.3f ms → 真结果 %8.3f ms %s\n", c[i].why, c[i].want / 1e6, got / 1e6, ok ? "✓" : "✗");
|
||||
fail += !ok;
|
||||
}
|
||||
printf("== %d 项,失败 %d ==\n", n, fail);
|
||||
return fail != 0;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#include "../nvn/nvn_mtl.m"
|
||||
|
||||
void *front_metal_layer(void) { return NULL; }
|
||||
module_t *module_of(const void *p) { (void)p; return NULL; }
|
||||
module_t g_mod[MAX_MOD]; int g_nmod;
|
||||
void svc_thread_dump(void) {}
|
||||
uint64_t now_ns(void) { return bp_now(); }
|
||||
|
||||
int main(void) {
|
||||
int failed = 0;
|
||||
failed += tex_need_pfv(MTLPixelFormatRGBA8Unorm, MTLPixelFormatRGBA8Unorm) != 0;
|
||||
failed += tex_need_pfv(MTLPixelFormatRGBA8Unorm, MTLPixelFormatRGBA8Unorm_sRGB) != 0;
|
||||
failed += tex_need_pfv(MTLPixelFormatBGRA8Unorm, MTLPixelFormatBGRA8Unorm_sRGB) != 0;
|
||||
failed += tex_need_pfv(MTLPixelFormatBC7_RGBAUnorm, MTLPixelFormatBC7_RGBAUnorm_sRGB) != 0;
|
||||
failed += tex_need_pfv(MTLPixelFormatRGBA8Unorm, MTLPixelFormatR32Uint) != 1;
|
||||
tex_t t = {.serial = 70001};
|
||||
t.d.width = 4; t.d.height = 1; t.d.depth = 1; t.d.levels = 1; t.d.target = NVN_TEXTURE_TARGET_2D; t.d.format = NVN_FORMAT_RGBA8;
|
||||
mtl_init();
|
||||
MTLTextureDescriptor *d = tex_desc(&t, 0);
|
||||
failed += (d.usage & MTLTextureUsagePixelFormatView) != 0;
|
||||
id<MTLTexture> base = [g_dev newTextureWithDescriptor:d];
|
||||
uint8_t bytes[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
|
||||
id<MTLBuffer> src = [g_dev newBufferWithBytes:bytes length:sizeof bytes options:MTLResourceStorageModeShared];
|
||||
mtl_sub_begin();
|
||||
res_add(src); res_add(base); // Metal 4:拷贝两端都要在驻留集里 | Metal 4: both ends of a copy must be in the residency set
|
||||
id fill = blit(); // 主命令缓冲上的拷贝走宿主封装(自带屏障) | copies on the main command buffer go through the host wrapper (which carries its own barrier)
|
||||
[fill copyFromBuffer:src sourceOffset:0 sourceBytesPerRow:16 sourceBytesPerImage:16 sourceSize:MTLSizeMake(4, 1, 1)
|
||||
toTexture:base destinationSlice:0 destinationLevel:0 destinationOrigin:MTLOriginMake(0, 0, 0)];
|
||||
enc_b_end(g_blit); g_blit = nil;
|
||||
serial_put(t.serial, base);
|
||||
id<MTLTexture> upgraded = tex_upgrade_pfv(&t, base, MTLPixelFormatR32Uint);
|
||||
failed += upgraded.pixelFormat != MTLPixelFormatRGBA8Unorm; // 升级保留原格式 | the upgrade keeps the original format
|
||||
failed += !(upgraded.usage & MTLTextureUsagePixelFormatView);
|
||||
failed += serial_get(t.serial) != upgraded; // 登记已替换 | the registration has been replaced
|
||||
if (g_blit) { enc_b_end(g_blit); g_blit = nil; }
|
||||
id<MTLTexture> view = [upgraded newTextureViewWithPixelFormat:MTLPixelFormatR32Uint];
|
||||
id<MTLBuffer> dst = [g_dev newBufferWithLength:sizeof bytes options:MTLResourceStorageModeShared];
|
||||
res_add(dst);
|
||||
id read = blit();
|
||||
[read copyFromTexture:view sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(0, 0, 0) sourceSize:MTLSizeMake(4, 1, 1)
|
||||
toBuffer:dst destinationOffset:0 destinationBytesPerRow:16 destinationBytesPerImage:16];
|
||||
enc_b_end(g_blit); g_blit = nil;
|
||||
mtl_sub_commit(); mtl_drain();
|
||||
failed += memcmp(dst.contents, bytes, sizeof bytes) != 0;
|
||||
printf("pfv predicate failed=%d\n", failed);
|
||||
return failed != 0;
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
// 出图裁切回归:彩色8×8纹理,闭式RGBA期望;真实Metal渲染,不依赖游戏或跨局确定性。
|
||||
// Present crop regression: colored 8×8 texture, closed-form RGBA expectations; real Metal rendering, no dependence on the game or on cross-run determinism.
|
||||
#include "../nvn/nvn_mtl.m"
|
||||
#include "../nvn/hle_nvn.c"
|
||||
uint64_t g_t0_ns; // 宿主 main.c 的进程起点(hle_nvn 逐帧 @t_s 用),单测替身 | process start time from host main.c (used by hle_nvn's per-frame @t_s); unit test stub
|
||||
void *front_metal_layer(void) { return NULL; }
|
||||
module_t *module_of(const void *p) { (void)p; return NULL; }
|
||||
module_t g_mod[MAX_MOD]; int g_nmod;
|
||||
void svc_thread_dump(void) {}
|
||||
uint64_t now_ns(void) { return bp_now(); }
|
||||
#ifdef CROP_LEGACY_HEADER
|
||||
#include CROP_LEGACY_HEADER
|
||||
#define ENCODE legacy_present_encode
|
||||
#else
|
||||
#define ENCODE present_encode
|
||||
#endif
|
||||
static int failed, cases;
|
||||
#define EXPECT(n, w, v) do { int a=(w),b=(v); cases++; printf("%s 期望 %d → 真结果 %d %s\n",n,a,b,a==b?"✓":"✗");failed+=a!=b; } while(0)
|
||||
static const uint8_t colors[4][4]={{255,0,0,255},{0,255,0,255},{0,0,255,255},{255,255,0,255}};
|
||||
|
||||
static void check(id<MTLTexture> src, const char *name, const int crop[4], int w, int h, int color) {
|
||||
MTLTextureDescriptor *d=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm width:w height:h mipmapped:NO];
|
||||
d.storageMode=MTLStorageModeShared;d.usage=MTLTextureUsageRenderTarget;
|
||||
id<MTLTexture> dst=[g_dev newTextureWithDescriptor:d];id<MTLCommandBuffer> cb=[g_q commandBuffer];
|
||||
EXPECT("编码成功",1,ENCODE(cb,src,dst,crop));[cb commit];[cb waitUntilCompleted];
|
||||
EXPECT("GPU完成",MTLCommandBufferStatusCompleted,cb.status);
|
||||
uint8_t *out=malloc(w*h*4);[dst getBytes:out bytesPerRow:w*4 fromRegion:MTLRegionMake2D(0,0,w,h) mipmapLevel:0];
|
||||
int bad=0;
|
||||
for(int y=0;y<h;y++)for(int x=0;x<w;x++) {
|
||||
int q=color;
|
||||
if(q==4) { // 正方形有效区对2:1目标:两侧各4列黑,中间8列全红。 | square valid area onto a 2:1 target: 4 black columns on each side, the middle 8 columns all red.
|
||||
static const uint8_t black[4]={0,0,0,255};
|
||||
const uint8_t *want=x<4||x>=12?black:colors[0];bad+=memcmp(out+4*(y*w+x),want,4)!=0;continue;
|
||||
}
|
||||
if(q==-2) { // crop=(1,1,4,4):3×3红、末列绿、末行蓝、右下1格黄。 | crop=(1,1,4,4): 3×3 red, last column green, last row blue, bottom-right 1 cell yellow.
|
||||
q=(x+1>=4)+2*(y+1>=4);
|
||||
} else if(q<0) { // 同尺寸默认整帧:分界在正中。 | same-size default whole frame: the boundary is dead center.
|
||||
q=(x>=w/2)+2*(y>=h/2);
|
||||
}
|
||||
bad+=memcmp(out+4*(y*w+x),colors[q],4)!=0;
|
||||
}
|
||||
EXPECT(name,0,bad);free(out);
|
||||
}
|
||||
|
||||
int main(void) { @autoreleasepool {
|
||||
mtl_init();
|
||||
MTLTextureDescriptor *d=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm width:8 height:8 mipmapped:NO];d.storageMode=MTLStorageModeShared;d.usage=MTLTextureUsageShaderRead;
|
||||
id<MTLTexture> src=[g_dev newTextureWithDescriptor:d];uint8_t px[8*8*4];
|
||||
for(int y=0;y<8;y++)for(int x=0;x<8;x++)memcpy(px+4*(y*8+x),colors[(x>=4)+2*(y>=4)],4);
|
||||
[src replaceRegion:MTLRegionMake2D(0,0,8,8) mipmapLevel:0 withBytes:px bytesPerRow:32];
|
||||
int zero[4]={0},tl[4]={0,0,4,4},tr[4]={4,0,4,4},bl[4]={0,4,4,4},br[4]={4,4,4,4},one[4]={3,3,1,1},inset[4]={1,1,4,4};
|
||||
check(src,"默认整帧64像素",zero,8,8,-1);
|
||||
check(src,"NULL默认整帧64像素",NULL,8,8,-1);
|
||||
check(src,"左上裁切放大256像素全红",tl,16,16,0);
|
||||
check(src,"非零x裁切放大256像素全绿",tr,16,16,1);
|
||||
check(src,"非零y裁切放大256像素全蓝",bl,16,16,2);
|
||||
check(src,"右下裁切贴边256像素全黄",br,16,16,3);
|
||||
check(src,"单纹素放大不跨边界256像素全红",one,16,16,0);
|
||||
check(src,"非零双偏移16像素逐字节等手写子矩形",inset,4,4,-2);
|
||||
check(src,"有效区比例保留,128像素中间红/两侧黑",tl,16,8,4);
|
||||
int invalid[4][4]={{-1,0,4,4},{0,-1,4,4},{0,0,0,4},{7,0,4,4}};
|
||||
for(int i=0;i<4;i++) {
|
||||
MTLTextureDescriptor *dd=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm width:8 height:8 mipmapped:NO];dd.usage=MTLTextureUsageRenderTarget;dd.storageMode=MTLStorageModeShared;
|
||||
id<MTLTexture> dst=[g_dev newTextureWithDescriptor:dd];
|
||||
EXPECT("无效crop不编码、不把整张拉伸冒充成功",0,ENCODE([g_q commandBuffer],src,dst,invalid[i]));
|
||||
}
|
||||
// 真实QueuePresent入口:先设crop入队,再立即改window,出图票号必须保留当帧副本。
|
||||
// Real QueuePresent entry: set crop and enqueue first, then immediately change the window; the present ticket must keep that frame's copy.
|
||||
PFNNVNDEVICEGETPROCADDRESSPROC get=(PFNNVNDEVICEGETPROCADDRESSPROC)h_nvnBootstrapLoader("nvnDeviceGetProcAddress");
|
||||
NVNT_nvnWindowSetCrop set=(NVNT_nvnWindowSetCrop)get(NULL,"nvnWindowSetCrop");
|
||||
NVNT_nvnQueuePresentTexture present=(NVNT_nvnQueuePresentTexture)get(NULL,"nvnQueuePresentTexture");
|
||||
tex_t tex={.serial=10001};tex.d.width=tex.d.height=8;tex.d.depth=tex.d.levels=1;tex.d.format=NVN_FORMAT_RGBA8;tex.d.target=NVN_TEXTURE_TARGET_2D;serial_put(tex.serial,src);
|
||||
win_t win={.ntex=1};win.tex[0]=(NVNtexture *)&tex;set((NVNwindow *)&win,4,4,4,4);
|
||||
mtl_present_test_stall(100000000);present(NULL,(NVNwindow *)&win,0);uint64_t tk=win.ticket[0];set((NVNwindow *)&win,0,0,8,8);
|
||||
#ifdef CROP_LEGACY_HEADER
|
||||
EXPECT("旧队列结构没有四参数副本空间(结构检查)",1,sizeof(pq_item)>=sizeof(tex_t)+sizeof(double)+sizeof(uint64_t)+sizeof br);
|
||||
#else
|
||||
pthread_mutex_lock(&g_pq_mu);int saved=memcmp(g_pq[(tk-1)%PQ].crop,br,sizeof br)==0;pthread_mutex_unlock(&g_pq_mu);
|
||||
EXPECT("真实QueuePresent当帧crop副本不随window变化",1,saved);
|
||||
#endif
|
||||
mtl_present_wait(tk);mtl_present_test_stall(0);
|
||||
printf("== %d 项,失败 %d ==\n",cases,failed);return failed!=0;
|
||||
} }
|
||||
@@ -0,0 +1,33 @@
|
||||
// 可序列化管线键单测:pso_skey 十六进制往返逐字节一致,篡改 / 长度错 / 非法字符被识别(期望由构造直接给出)。
|
||||
// Serializable pipeline key unit tests: the pso_skey hex round trip is byte-identical; tampering / wrong length / illegal characters are detected (expectations given directly by construction).
|
||||
#import <Foundation/Foundation.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include "../nvn/nvn_obj.h"
|
||||
@interface NvShader : NSObject { @public int stage; char key[24]; } @end
|
||||
@implementation NvShader @end
|
||||
#include "../nvn/nvn_pso_skey.h"
|
||||
|
||||
static void fill(pso_key *k, unsigned seed) {
|
||||
memset(k, 0, sizeof *k);
|
||||
for (size_t i = 0; i < sizeof *k; i++) ((unsigned char *)k)[i] = (unsigned char)(seed + i * 13);
|
||||
k->vs = (void *)1; k->fs = (void *)2; k->fsfn = (void *)3;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
for (unsigned seed = 1; seed <= 3; seed++) {
|
||||
pso_key k; fill(&k, seed);
|
||||
NvShader *vs = [NvShader new], *fs = [NvShader new];
|
||||
vs->stage = (int)seed; fs->stage = (int)(seed + 1);
|
||||
snprintf(vs->key, sizeof vs->key, "vs-%u", seed); snprintf(fs->key, sizeof fs->key, "fs-%u", seed);
|
||||
pso_fz_desc fz = {.kind = 1, .fbmask = 0xa5};
|
||||
for (int i = 0; i < 32; i++) fz.fx[i] = (int8_t)(i - 7);
|
||||
pso_skey a, b; char hex[sizeof a * 2 + 1];
|
||||
pso_skey_from(&k, vs, fs, seed & 1, &fz, &a); pso_skey_hex(&a, hex);
|
||||
assert(pso_skey_parse(hex, &b) == 0); assert(memcmp(&a, &b, sizeof a) == 0);
|
||||
hex[0] = hex[0] == '0' ? '1' : '0'; assert(pso_skey_parse(hex, &b) == 0); assert(memcmp(&a, &b, sizeof a) != 0);
|
||||
assert(pso_skey_parse(hex + 1, &b) == -1); hex[0] = 'g'; assert(pso_skey_parse(hex, &b) == -1);
|
||||
}
|
||||
puts("PSO_SKEY OK 3 例往返一致;篡改一字符不等、缺位 / 非法字符拒收");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
// 反射转换单测:真实 B 反射 json(Switch 原版翻译,build/cache/metal_shader_cache/<键>_b.json)→ C 数组,期望按 json 原文手抄。
|
||||
// 哑贴图类型 MTLTextureType:1D=0 1DArray=1 2D=2 2DArray=3 Cube=5 CubeArray=6 3D=7
|
||||
// Reflection conversion unit tests: real B reflection json (translation of the original Switch shaders, build/cache/metal_shader_cache/<key>_b.json) → C arrays, expectations hand-copied from the json text.
|
||||
// Dummy texture type MTLTextureType: 1D=0 1DArray=1 2D=2 2DArray=3 Cube=5 CubeArray=6 3D=7
|
||||
#import "../nvn/nvn_refl.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "../nvn/dmsh_chain.h"
|
||||
|
||||
enum { C = NVN_RB_CBUF, S = NVN_RB_SAMP, T = NVN_RB_TEX, I = NVN_RB_IMG, TB = NVN_RB_TBUF };
|
||||
enum { F = NVN_DPF_FLOAT, U = NVN_DPF_UINT, D = NVN_DPF_DEPTH };
|
||||
static int fail, n;
|
||||
static void check(const char *what, long want, long got) {
|
||||
n++; int ok = want == got; fail += !ok;
|
||||
if (!ok) printf(" %-40s 期望 %ld → 真结果 %ld ✗\n", what, want, got);
|
||||
}
|
||||
static NSDictionary *load(const char *key) {
|
||||
NSString *p = [NSString stringWithFormat:@"%s%s/build/cache/metal_shader_cache/b-%s/%s.json", getenv("DM_ROOT") ?: getenv("HOME"), getenv("DM_ROOT") ? "" : "/dm-work", DMSH_CHAIN, key]; // 现行翻译链版本的那一份库 | the library of the current translation chain version
|
||||
NSData *d = [NSData dataWithContentsOfFile:p];
|
||||
if (!d) { printf("【红】缺反射样本 %s\n", p.UTF8String); fail++; return nil; }
|
||||
return [NSJSONSerialization JSONObjectWithData:d options:0 error:nil];
|
||||
}
|
||||
|
||||
int main(void) { @autoreleasepool {
|
||||
nvn_refl r; char err[160] = "";
|
||||
{ int f0 = fail; // A 路线已退役:PC 链反射(无 route = B)必须被拒 | Route A is retired: PC-chain reflection (no route = B) must be rejected
|
||||
NSDictionary *pc = @{@"arg_buffer_index": @0, @"bindings": @[@{@"type": @"cbuffer", @"reg": @10, @"arg_id": @0, @"access": @"constant", @"msl_type": @"constant cb1_struct*"}], @"vertex_inputs": @[]};
|
||||
check("PC 链反射(无 route = B)报失败", 1, nvn_refl_from_json(pc, &r, err, sizeof err) != 0);
|
||||
printf("%-60s %s\n", "负对照:PC 链反射被拒(A 路线已退役)", fail == f0 ? "✓" : "✗");
|
||||
}
|
||||
|
||||
// B 路线(Switch 原版翻译,tools/dmsh_build.py 出):真实反射 ps_models_p#0 / vs_models_v#0,期望按 json 原文手抄
|
||||
// Route B (translation of the original Switch shaders, produced by tools/dmsh_build.py): real reflection ps_models_p#0 / vs_models_v#0, expectations hand-copied from the json text
|
||||
{ NSDictionary *j = load("5c1ca4e7c3e4657c_b");
|
||||
if (j) { int f1 = fail;
|
||||
check("B 片元:转换成功", 0, nvn_refl_from_json(j, &r, err, sizeof err));
|
||||
check("B 片元:B 标记", 1, r.route_b); check("B 片元:参数缓冲槽", 0, r.abi); check("B 片元:绑定数", 44, r.nb); check("B 片元:顶点输入数", 0, r.nv);
|
||||
check("B 片元:有 c1", 1, r.has_c1); check("B 片元:c1 长 256(控制段字段)", 256, r.c1_len);
|
||||
uint32_t c1w; memcpy(&c1w, r.c1, 4); check("B 片元:c1 首字 = −√1.5(0xbf9cc471)", 0xbf9cc471u, c1w);
|
||||
struct { int i, kind, reg, aid, rw, dtt, dpf; } w[] = {
|
||||
{0, NVN_RB_SUPPORT, 0, 0, 0, -1, -1}, {1, C, 10, 1, 0, -1, -1}, {4, NVN_RB_C1, 0, 4, 0, -1, -1}, {7, NVN_RB_DRV0, 0, 7, 0, -1, -1},
|
||||
{8, NVN_RB_DRV2, 0, 8, 0, -1, -1}, {11, NVN_RB_SBUFP, 4, 11, 0, -1, -1}, {13, TB, 8, 13, 0, -1, -1}, {14, T, 41, 14, 0, 2, F},
|
||||
{15, S, 3, 15, 0, -1, -1}, {28, T, 39, 28, 0, 3, D}, {34, T, 33, 34, 0, 5, D}, {36, T, 46, 36, 0, 7, F}};
|
||||
for (unsigned k = 0; k < sizeof w / sizeof *w; k++) {
|
||||
const nvn_rbind *g = &r.b[w[k].i]; char m[64];
|
||||
snprintf(m, sizeof m, "B 绑定[%d] 种类", w[k].i); check(m, w[k].kind, g->kind);
|
||||
snprintf(m, sizeof m, "B 绑定[%d] 槽号", w[k].i); check(m, w[k].reg, g->reg);
|
||||
snprintf(m, sizeof m, "B 绑定[%d] 参数序号", w[k].i); check(m, w[k].aid, g->aid);
|
||||
snprintf(m, sizeof m, "B 绑定[%d] 读写", w[k].i); check(m, w[k].rw, g->rw);
|
||||
if (w[k].dtt >= 0) { snprintf(m, sizeof m, "B 绑定[%d] 哑贴图类型", w[k].i); check(m, w[k].dtt, g->dtt);
|
||||
snprintf(m, sizeof m, "B 绑定[%d] 哑贴图像素类", w[k].i); check(m, w[k].dpf, g->dpf); }
|
||||
}
|
||||
printf("%-60s %s\n", "B 片元 ps_models_p#0:44 个绑定(含 support / c1 / 驱动段 / 存储缓冲指针)", fail == f1 ? "✓" : "✗");
|
||||
} }
|
||||
{ NSDictionary *j = load("54f730a6c0efc118_b");
|
||||
if (j) { int f1 = fail;
|
||||
check("B 顶点:转换成功", 0, nvn_refl_from_json(j, &r, err, sizeof err));
|
||||
check("B 顶点:绑定数", 2, r.nb); check("B 顶点:输入数", 4, r.nv); check("B 顶点:c1 长 0(控制段 +0x704 − +0x700)→ 无 c1", 0, r.has_c1);
|
||||
for (int i = 0; i < 4 && i < r.nv; i++) { char m[48]; snprintf(m, sizeof m, "B 顶点输入[%d] 属性号 = 位置", i); check(m, i, r.v[i].nvn); check(m, i, r.v[i].loc); check("B 顶点分量 float", NVN_CT_FLOAT, r.v[i].ct); }
|
||||
check("B 顶点:绑定[0] uniform 槽 0", 0, r.b[0].reg); check("B 顶点:绑定[1] uniform 槽 3", 3, r.b[1].reg);
|
||||
printf("%-60s %s\n", "B 顶点 vs_models_v#0:4 个属性(属性号 = MSL attribute)", fail == f1 ? "✓" : "✗");
|
||||
} }
|
||||
{ int f1 = fail;
|
||||
NSDictionary *b1 = @{@"route": @"B", @"bindings": @[@{@"kind": @"foo", @"arg_id": @0, @"msl_name": @"x", @"msl_type": @"constant _16*"}]};
|
||||
NSDictionary *b2 = @{@"route": @"B", @"bindings": @[@{@"kind": @"tex", @"reg": [NSNull null], @"arg_id": @0, @"msl_name": @"fp_t_x", @"msl_type": @"texture2d<float>"}]};
|
||||
check("B 未知种类报失败", 1, nvn_refl_from_json(b1, &r, err, sizeof err) != 0);
|
||||
check("B 贴图没解出槽号报失败", 1, nvn_refl_from_json(b2, &r, err, sizeof err) != 0);
|
||||
printf("%-60s %s\n", "B 负对照:未知种类 / 槽号缺失", fail == f1 ? "✓" : "✗");
|
||||
}
|
||||
printf("== %d 项,失败 %d ==\n", n, fail);
|
||||
return fail != 0;
|
||||
} }
|
||||
@@ -0,0 +1,283 @@
|
||||
// 固定命令链实验:生产 mtl_exec,手写常量着色器和闭式期望;不含生产重排器。
|
||||
// G 完整模板块、M 小视图+复制、U 混合、R 模板 resolve;只交换 G/M。
|
||||
// Fixed command chain experiment: production mtl_exec, hand-written constant shaders and closed-form expectations; does not include the production reorderer.
|
||||
// G full stencil block, M small view + copy, U blend, R stencil resolve; only G/M are swapped.
|
||||
#include "../nvn/nvn_mtl.m"
|
||||
void *front_metal_layer(void) { return NULL; }
|
||||
module_t *module_of(const void *p) { (void)p; return NULL; }
|
||||
module_t g_mod[MAX_MOD]; int g_nmod;
|
||||
void svc_thread_dump(void) {}
|
||||
uint64_t now_ns(void) { return bp_now(); }
|
||||
static int fail, count, all_independent;
|
||||
#define EXPECT(n,w,v) do { uint64_t a=(w), b=(v); count++; \
|
||||
printf("%s 期望 %llu → 真结果 %llu %s\n",n,(unsigned long long)a,(unsigned long long)b,a==b?"✓":"✗"); fail+=a!=b; } while(0)
|
||||
typedef struct { uint8_t *p; size_t n; int width; } chain;
|
||||
static chain make_chain(void) {
|
||||
chain c={0}; if(posix_memalign((void **)&c.p,getpagesize(),65536)) abort();
|
||||
memset(c.p,0,65536); mtl_pool_add(c.p,65536); return c;
|
||||
}
|
||||
static void emit(chain *c, unsigned op, const void *a, size_t n) {
|
||||
size_t sz=(8+n+7)&~7ull; if(c->n+sz>65536) abort();
|
||||
op_hdr h={op,(uint32_t)sz}; memcpy(c->p+c->n,&h,8);
|
||||
if(n) memcpy(c->p+c->n+8,a,n); c->n+=sz;
|
||||
}
|
||||
static void state(chain *c, int kind, const void *s, size_t n) {
|
||||
p_bind_state b={.kind=kind}; if(n>sizeof b.bytes) abort(); memcpy(b.bytes,s,n); emit(c,OP_BIND_STATE,&b,sizeof b);
|
||||
}
|
||||
static tex_t texture(unsigned w, unsigned levels, int depth) {
|
||||
static uint64_t ser=5000; tex_t t={.serial=ser++}; t.d.width=t.d.height=w;
|
||||
t.d.depth=t.d.samples=1; t.d.levels=levels; t.d.target=NVN_TEXTURE_TARGET_2D;
|
||||
t.d.format=depth?NVN_FORMAT_DEPTH32F_STENCIL8:NVN_FORMAT_RGBA8; return t;
|
||||
}
|
||||
static void rt(chain *c, const tex_t *t, unsigned lv, const tex_t *ds) {
|
||||
p_set_rt r={.n=1,.depth=ds}; r.color[0]=t;
|
||||
r.has_cview[0]=1; r.cview[0].set_levels=1; r.cview[0].base_level=lv; r.cview[0].nlevels=1;
|
||||
emit(c,OP_SET_RT,&r,sizeof r);
|
||||
p_viewports v={.n=1}; v.v[0][2]=v.v[0][3]=MAX(t->d.width>>lv,1u); emit(c,OP_VIEWPORTS,&v,sizeof v);
|
||||
c->width=(int)v.v[0][2];
|
||||
// clear的剪裁覆盖基尺寸,兼容现有scissor_full;每次draw再显式取实际mip尺寸。
|
||||
// The clear's scissor covers the base size, compatible with the existing scissor_full; each draw then explicitly takes the actual mip size.
|
||||
p_scissor sc={0,0,(int)t->d.width,(int)t->d.height}; emit(c,OP_SCISSOR,&sc,sizeof sc);
|
||||
}
|
||||
static void clear(chain *c, const tex_t *t, unsigned lv, const tex_t *ds, int red, int green, int blue) {
|
||||
rt(c,t,lv,ds); p_clear_color b={.index=0,.mask=15,.rgba={red,green,blue,1}}; emit(c,OP_CLEAR_COLOR,&b,sizeof b);
|
||||
if(ds) { p_clear_ds d={.depth=1,.depth_mask=1,.stencil=2,.stencil_mask=255}; emit(c,OP_CLEAR_DS,&d,sizeof d); }
|
||||
}
|
||||
static ds_st ds_state(int stencil, int func, int op) {
|
||||
return (ds_st){0,0,NVN_DEPTH_FUNC_ALWAYS,stencil,func,func,1,1,op,1,1,op};
|
||||
}
|
||||
static void stencil(chain *c, int enabled, int func, int op, unsigned read, unsigned write, unsigned ref) {
|
||||
ds_st d=ds_state(enabled,func,op); state(c,5,&d,sizeof d);
|
||||
for(int k=0;k<3;k++) { p_stencil s={.face=3,.which=k,.value_mask=read,.mask=write,.ref=ref}; emit(c,OP_STENCIL,&s,sizeof s); }
|
||||
}
|
||||
static void blending(chain *c, int enabled) {
|
||||
color_st col={enabled,NVN_LOGIC_OP_COPY,NVN_ALPHA_FUNC_ALWAYS}; state(c,1,&col,sizeof col);
|
||||
blend_st b={0,NVN_BLEND_FUNC_SRC_ALPHA,NVN_BLEND_FUNC_ONE_MINUS_SRC_ALPHA,NVN_BLEND_FUNC_ONE,NVN_BLEND_FUNC_ZERO,NVN_BLEND_EQUATION_ADD,NVN_BLEND_EQUATION_ADD};
|
||||
state(c,0,&b,sizeof b);
|
||||
}
|
||||
static prog_t pg[8];
|
||||
static void draw_prog(chain *c, int p, int tid) {
|
||||
p_bind_program b={&pg[p],3}; emit(c,OP_BIND_PROGRAM,&b,sizeof b);
|
||||
if(tid) { p_bind_handles h={.stage=1,.first=0,.n=1}; h.h[0]=tid; emit(c,OP_BIND_TEX,&h,sizeof h); }
|
||||
p_scissor sc={0,0,c->width,c->width}; emit(c,OP_SCISSOR,&sc,sizeof sc);
|
||||
p_draw d={NVN_DRAW_PRIMITIVE_TRIANGLES,0,3}; emit(c,OP_DRAW,&d,sizeof d);
|
||||
}
|
||||
static int bind_view_range(const tex_t *t, int lv, int levels, int sl, int slices) {
|
||||
static int tid=1000; view_t v={.set_levels=1,.base_level=lv,.nlevels=levels,
|
||||
.set_layers=slices>0,.min_layer=sl,.nlayers=slices};
|
||||
mtl_reg_tex(tid,t,&v); return tid++;
|
||||
}
|
||||
static int bind_view(const tex_t *t, int lv) { return bind_view_range(t,lv,1,0,0); }
|
||||
typedef struct { uint8_t a[256],b[256],c[256],e[256]; uint64_t query; } result;
|
||||
static result execute(chain *c, const tex_t *a, const tex_t *b, const tex_t *out, const tex_t *e, uint64_t *q) {
|
||||
emit(c,OP_END,NULL,0); state_reset(); memset(&R,0,sizeof R); vis_clear(); g_vis_on=g_vis_counting=0;
|
||||
mtl_sub_begin(); mtl_exec(c->p);
|
||||
const tex_t *t[4]={a,b,out,e}; id<MTLBuffer> buf[4];
|
||||
for(int k=0;k<4;k++) { buf[k]=[g_dev newBufferWithLength:256 options:MTLResourceStorageModeShared];
|
||||
[blit() copyFromTexture:tex_mtl(t[k]) sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(0,0,0) sourceSize:MTLSizeMake(8,8,1)
|
||||
toBuffer:buf[k] destinationOffset:0 destinationBytesPerRow:32 destinationBytesPerImage:256]; }
|
||||
uint64_t f=mtl_sub_commit(); EXPECT("生产提交完成",1,mtl_wait(f,5000000000ull)); EXPECT("提交反馈无错误",0,mtl_last_commit_error());
|
||||
result r={0}; uint8_t *dst[4]={r.a,r.b,r.c,r.e}; for(int k=0;k<4;k++) memcpy(dst[k],buf[k].contents,256);
|
||||
if(q) r.query=*q; mtl_pool_del(c->p); free(c->p); return r;
|
||||
}
|
||||
static void uniform_pixels(const char *name, const uint8_t *b, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) {
|
||||
uint8_t want[4]={red,green,blue,alpha}; unsigned bad=0;
|
||||
for(int k=0;k<64;k++) bad+=memcmp(b+4*k,want,4)!=0; EXPECT(name,0,bad);
|
||||
}
|
||||
static void save_raw(const char *name, int reordered, const void *r, size_t n) {
|
||||
const char *dir=getenv("DM_GFX_FIXTURE_OUT"); if(!dir) return;
|
||||
char path[1024]; snprintf(path,sizeof path,"%s/%s_%s.raw",dir,name,reordered?"reordered":"original");
|
||||
FILE *f=fopen(path,"wb"); if(!f || fwrite(r,1,n,f)!=n) abort(); fclose(f);
|
||||
}
|
||||
static void save_result(const char *name, int reordered, const result *r) { save_raw(name,reordered,r,sizeof *r); }
|
||||
enum { INDEPENDENT, SAME_MIP, STENCIL_INDEPENDENT, STENCIL_DEPENDENT, COPY_DEPENDENT, INTERNAL_ORDER };
|
||||
static void full_block(chain *c,const tex_t *a,const tex_t *ds,int reverse) {
|
||||
rt(c,a,0,ds); blending(c,0);
|
||||
for(int i=0;i<2;i++) { int reader=reverse?i==0:i==1;
|
||||
stencil(c,1,reader?NVN_STENCIL_FUNC_NOTEQUAL:NVN_STENCIL_FUNC_ALWAYS,reader?NVN_STENCIL_OP_KEEP:NVN_STENCIL_OP_REPLACE,
|
||||
reader?0x34:0,reader?0:0x10,reader?0:0x30); draw_prog(c,reader?1:0,0); }
|
||||
}
|
||||
static void middle_block(chain *c,const tex_t *a,const tex_t *b,const tex_t *ds,const tex_t *d,const tex_t *e,int tid,int mode) {
|
||||
rt(c,b,0,mode==STENCIL_INDEPENDENT||mode==STENCIL_DEPENDENT?ds:NULL); blending(c,0);
|
||||
unsigned mask=mode==STENCIL_DEPENDENT?0x10:0x2;
|
||||
stencil(c,mode==STENCIL_INDEPENDENT||mode==STENCIL_DEPENDENT,NVN_STENCIL_FUNC_EQUAL,NVN_STENCIL_OP_KEEP,mask,0,mask); draw_prog(c,2,tid);
|
||||
p_copy_t2t cp={.src=mode==COPY_DEPENDENT?a:d,.dst=e,.sr={0,0,0,8,8,1},.dr={0,0,0,8,8,1}};
|
||||
emit(c,OP_COPY_T2T,&cp,sizeof cp);
|
||||
}
|
||||
static result render_case(int mode,int reordered) {
|
||||
tex_t a=texture(8,2,0), b=texture(8,1,0), out=texture(8,1,0), ds=texture(8,1,1), d=texture(8,1,0), e=texture(8,1,0);
|
||||
int at=bind_view(&a,mode==SAME_MIP?0:1),bt=bind_view(&b,0),af=bind_view(&a,0); chain c=make_chain();
|
||||
clear(&c,&a,0,&ds,0,0,0); clear(&c,&a,1,NULL,0,1,0); clear(&c,&b,0,NULL,0,0,0);
|
||||
clear(&c,&d,0,NULL,0,0,1); clear(&c,&e,0,NULL,0,0,0); clear(&c,&out,0,NULL,0,0,0);
|
||||
if(reordered) middle_block(&c,&a,&b,&ds,&d,&e,at,mode);
|
||||
full_block(&c,&a,&ds,reordered&&mode==INTERNAL_ORDER);
|
||||
if(!reordered) middle_block(&c,&a,&b,&ds,&d,&e,at,mode);
|
||||
rt(&c,&a,0,NULL); stencil(&c,0,8,1,255,255,0); blending(&c,1); draw_prog(&c,3,bt);
|
||||
rt(&c,&out,0,&ds); stencil(&c,1,NVN_STENCIL_FUNC_EQUAL,1,2,0,2); blending(&c,0); draw_prog(&c,2,af);
|
||||
return execute(&c,&a,&b,&out,&e,NULL);
|
||||
}
|
||||
static uint64_t query_case(int reordered, int mode) {
|
||||
tex_t a=texture(8,1,0),b=texture(4,1,0); chain c=make_chain(); uint64_t q[2]={UINT64_MAX,0}, type=NVN_COUNTER_TYPE_SAMPLES_PASSED;
|
||||
emit(&c,OP_RESET_COUNTER,&type,8); stencil(&c,0,8,1,255,255,0); blending(&c,0);
|
||||
if(!reordered) { clear(&c,&a,0,NULL,0,0,0); draw_prog(&c,0,0); }
|
||||
if(mode!=1) emit(&c,OP_RESET_COUNTER,&type,8);
|
||||
clear(&c,&b,0,NULL,0,0,0); draw_prog(&c,1,0);
|
||||
if(reordered) { clear(&c,&a,0,NULL,0,0,0); draw_prog(&c,0,0); }
|
||||
if(mode==2) { // 两块计数都在任何report之前被后继reset抹去;只报告新的4x4绘制。 | both blocks' counts are wiped by the subsequent reset before any report; only the new 4x4 draw is reported.
|
||||
emit(&c,OP_RESET_COUNTER,&type,8); clear(&c,&b,0,NULL,0,0,0); draw_prog(&c,1,0); }
|
||||
uint64_t report[2]={type,(uint64_t)q}; emit(&c,OP_REPORT_COUNTER,report,sizeof report); emit(&c,OP_END,NULL,0);
|
||||
state_reset(); memset(&R,0,sizeof R); vis_clear(); g_vis_on=g_vis_counting=0; mtl_sub_begin(); mtl_exec(c.p);
|
||||
EXPECT("查询完成",1,mtl_wait(mtl_sub_commit(),5000000000ull)); EXPECT("查询提交反馈无错误",0,mtl_last_commit_error());
|
||||
const char *names[]={"查询","同区间查询","后继reset覆盖查询"};
|
||||
save_raw(names[mode],reordered,q,sizeof q); mtl_pool_del(c.p); free(c.p); return q[0];
|
||||
}
|
||||
static void uniform_case(int reordered,uint8_t pixels[256]) {
|
||||
void *mem=NULL; if(posix_memalign(&mem,getpagesize(),getpagesize())) abort(); memset(mem,0,getpagesize());
|
||||
float red[4]={1,0,0,1},green[4]={0,1,0,1}; memcpy(mem,red,16); mtl_pool_add(mem,getpagesize());
|
||||
tex_t a=texture(8,1,0),b=texture(8,1,0),out=texture(8,1,0),e=texture(8,1,0); chain c=make_chain();
|
||||
clear(&c,&out,0,NULL,0,0,0); clear(&c,&e,0,NULL,0,0,0); stencil(&c,0,8,1,255,255,0); blending(&c,0);
|
||||
p_bind_buf ub={.stage=1,.index=0,.addr=(uint64_t)mem,.size=16}; emit(&c,OP_BIND_UBO,&ub,sizeof ub);
|
||||
if(!reordered) { clear(&c,&a,0,NULL,0,0,0); draw_prog(&c,4,0); }
|
||||
struct { uint64_t dst,n; float color[4]; } update={(uint64_t)mem,16,{0}}; memcpy(update.color,green,16); emit(&c,OP_UPDATE_UB,&update,sizeof update);
|
||||
if(reordered) { clear(&c,&a,0,NULL,0,0,0); draw_prog(&c,4,0); }
|
||||
clear(&c,&b,0,NULL,0,0,0); draw_prog(&c,4,0); result r=execute(&c,&a,&b,&out,&e,NULL); save_result("UB写",reordered,&r); memcpy(pixels,r.a,256);
|
||||
uniform_pixels("UB更新后的第二绘制始终绿色",r.b,0,255,0,255); mtl_pool_del(mem); free(mem);
|
||||
}
|
||||
// view的可访问区间不能只看base:shader读相对第二级/第二层,G写该子资源。
|
||||
// A view's accessible range cannot be judged by base alone: the shader reads relative to the second level/second layer, and G writes that subresource.
|
||||
static void slice_rt(chain *c,const tex_t *t,int lv,int sl) {
|
||||
p_set_rt r={.n=1}; r.color[0]=t; r.has_cview[0]=1;
|
||||
r.cview[0]=(view_t){.set_levels=1,.base_level=lv,.nlevels=1,.set_layers=1,.min_layer=sl,.nlayers=1};
|
||||
emit(c,OP_SET_RT,&r,sizeof r); p_viewports v={.n=1}; v.v[0][2]=v.v[0][3]=MAX(t->d.width>>lv,1u); emit(c,OP_VIEWPORTS,&v,sizeof v);
|
||||
c->width=(int)v.v[0][2]; p_scissor sc={0,0,(int)t->d.width,(int)t->d.height}; emit(c,OP_SCISSOR,&sc,sizeof sc);
|
||||
}
|
||||
static void slice_clear(chain *c,const tex_t *t,int lv,int sl,int green) {
|
||||
slice_rt(c,t,lv,sl); p_clear_color cc={.index=0,.mask=15,.rgba={0,green,0,1}}; emit(c,OP_CLEAR_COLOR,&cc,sizeof cc);
|
||||
}
|
||||
static void sample_block(chain *c,const tex_t *dst,int program,int tid) {
|
||||
rt(c,dst,0,NULL); stencil(c,0,8,1,255,255,0); blending(c,0); draw_prog(c,program,tid);
|
||||
}
|
||||
static result range_case(int array,int reordered) {
|
||||
tex_t a=texture(8,array?1:2,0),b=texture(8,1,0),out=texture(8,1,0),e=texture(8,1,0);
|
||||
if(array) { a.d.target=NVN_TEXTURE_TARGET_2D_ARRAY; a.d.depth=2; }
|
||||
int tid=bind_view_range(&a,0,array?1:2,0,array?2:0); chain c=make_chain();
|
||||
slice_clear(&c,&a,0,0,0); slice_clear(&c,&a,array?0:1,array?1:0,1);
|
||||
clear(&c,&b,0,NULL,0,0,0); clear(&c,&out,0,NULL,0,0,0); clear(&c,&e,0,NULL,0,0,0);
|
||||
if(reordered) sample_block(&c,&b,array?6:5,tid);
|
||||
slice_rt(&c,&a,array?0:1,array?1:0); stencil(&c,0,8,1,255,255,0); blending(&c,0); draw_prog(&c,1,0);
|
||||
if(!reordered) sample_block(&c,&b,array?6:5,tid);
|
||||
result r=execute(&c,&a,&b,&out,&e,NULL);
|
||||
NSUInteger w=array?8:4; id<MTLBuffer> buf=[g_dev newBufferWithLength:w*w*4 options:MTLResourceStorageModeShared];
|
||||
id<MTLCommandBuffer> cb=[g_q commandBuffer]; id<MTLBlitCommandEncoder> bl=[cb blitCommandEncoder];
|
||||
[bl copyFromTexture:tex_mtl(&a) sourceSlice:array?1:0 sourceLevel:array?0:1 sourceOrigin:MTLOriginMake(0,0,0) sourceSize:MTLSizeMake(w,w,1)
|
||||
toBuffer:buf destinationOffset:0 destinationBytesPerRow:w*4 destinationBytesPerImage:w*w*4]; [bl endEncoding]; [cb commit]; [cb waitUntilCompleted];
|
||||
EXPECT("第二子资源读回GPU完成",4,cb.status); uint8_t blue[4]={0,0,255,255}; unsigned bad=0;
|
||||
for(NSUInteger i=0;i<w*w;i++) bad+=memcmp((const uint8_t *)buf.contents+4*i,blue,4)!=0;
|
||||
EXPECT("G第二子资源逐像素蓝",0,bad); save_raw(array?"整slice写目标":"整mip写目标",reordered,buf.contents,w*w*4);
|
||||
return r;
|
||||
}
|
||||
// 附件不交仍会通过继承的程序产生依赖;只演示显式补齐program,不冒充完整S/R快照。
|
||||
// Disjoint attachments can still create a dependency through an inherited program; this only demonstrates explicitly filling in the program and does not pass itself off as a full S/R snapshot.
|
||||
static result state_case(int restored,int reordered) {
|
||||
tex_t a=texture(8,1,0),b=texture(8,1,0),out=texture(8,1,0),e=texture(8,1,0); chain c=make_chain();
|
||||
clear(&c,&a,0,NULL,0,0,0); clear(&c,&b,0,NULL,0,0,0); clear(&c,&out,0,NULL,0,0,0); clear(&c,&e,0,NULL,0,0,0);
|
||||
stencil(&c,0,8,1,255,255,0); blending(&c,0); p_bind_program seed={&pg[0],3}; emit(&c,OP_BIND_PROGRAM,&seed,sizeof seed);
|
||||
for(int k=0;k<2;k++) { int middle=reordered?k==0:k==1;
|
||||
rt(&c,middle?&b:&a,0,NULL);
|
||||
if(!middle) draw_prog(&c,1,0);
|
||||
else { if(restored) { p_bind_program p={&pg[1],3}; emit(&c,OP_BIND_PROGRAM,&p,sizeof p); }
|
||||
p_draw d={NVN_DRAW_PRIMITIVE_TRIANGLES,0,3}; emit(&c,OP_DRAW,&d,sizeof d); } }
|
||||
return execute(&c,&a,&b,&out,&e,NULL);
|
||||
}
|
||||
static result exit_state_case(int restored,int reordered) {
|
||||
tex_t a=texture(8,1,0),b=texture(8,1,0),out=texture(8,1,0),e=texture(8,1,0); chain c=make_chain();
|
||||
clear(&c,&a,0,NULL,0,0,0); clear(&c,&b,0,NULL,0,0,0); clear(&c,&out,0,NULL,0,0,0); clear(&c,&e,0,NULL,0,0,0);
|
||||
for(int k=0;k<2;k++) { int middle=reordered?k==0:k==1; sample_block(&c,middle?&b:&a,middle?1:0,0); }
|
||||
rt(&c,&out,0,NULL);
|
||||
if(restored) { p_bind_program p={&pg[1],3}; emit(&c,OP_BIND_PROGRAM,&p,sizeof p); }
|
||||
p_draw d={NVN_DRAW_PRIMITIVE_TRIANGLES,0,3}; emit(&c,OP_DRAW,&d,sizeof d);
|
||||
return execute(&c,&a,&b,&out,&e,NULL);
|
||||
}
|
||||
// 写掩码不交也不够:IncrementWrap的隐含读包含低位,低位清零会改变向bit1的进位。
|
||||
// Disjoint write masks are not enough either: the implicit read of IncrementWrap includes the low bits, and clearing the low bits changes the carry into bit1.
|
||||
static result stencil_carry_case(int reordered) {
|
||||
tex_t a=texture(8,1,0),b=texture(8,1,0),out=texture(8,1,0),e=texture(8,1,0),ds=texture(8,1,1); chain c=make_chain();
|
||||
clear(&c,&a,0,&ds,0,0,0); p_clear_ds init={.depth=1,.depth_mask=1,.stencil=1,.stencil_mask=255}; emit(&c,OP_CLEAR_DS,&init,sizeof init);
|
||||
clear(&c,&b,0,NULL,0,0,0); clear(&c,&out,0,NULL,0,0,0); clear(&c,&e,0,NULL,0,0,0); blending(&c,0);
|
||||
chmask_st mask={0}; state(&c,2,&mask,sizeof mask);
|
||||
for(int k=0;k<2;k++) { int inc=reordered?k==0:k==1; rt(&c,inc?&b:&a,0,&ds);
|
||||
stencil(&c,1,NVN_STENCIL_FUNC_ALWAYS,inc?NVN_STENCIL_OP_INCR_WRAP:NVN_STENCIL_OP_ZERO,0,inc?2:1,0); draw_prog(&c,0,0); }
|
||||
mask.mask=0xffffffffu; state(&c,2,&mask,sizeof mask); rt(&c,&out,0,&ds); stencil(&c,1,NVN_STENCIL_FUNC_EQUAL,1,2,0,2); draw_prog(&c,7,0);
|
||||
return execute(&c,&a,&b,&out,&e,NULL);
|
||||
}
|
||||
// G写入藏在真实CALL/JUMP目标;跳转列表用跳回地址保持原执行路径与块内顺序。
|
||||
// The G write is hidden in a real CALL/JUMP target; the jump list uses return addresses to preserve the original execution path and in-block order.
|
||||
static result control_case(int jump,int reordered) {
|
||||
tex_t a=texture(8,1,0),b=texture(8,1,0),out=texture(8,1,0),e=texture(8,1,0); int tid=bind_view(&a,0);
|
||||
chain c=make_chain(),child=make_chain();
|
||||
clear(&c,&a,0,NULL,0,0,0); clear(&c,&b,0,NULL,0,0,0); clear(&c,&out,0,NULL,0,0,0); clear(&c,&e,0,NULL,0,0,0);
|
||||
if(reordered) sample_block(&c,&b,2,tid);
|
||||
uint64_t ptr=(uint64_t)child.p; emit(&c,jump?OP_JUMP:OP_CALL,&ptr,8);
|
||||
uint64_t ret=(uint64_t)(c.p+c.n); sample_block(&child,&a,1,0);
|
||||
emit(&child,jump?OP_JUMP:OP_END,jump?&ret:NULL,jump?8:0);
|
||||
if(!reordered) sample_block(&c,&b,2,tid);
|
||||
result r=execute(&c,&a,&b,&out,&e,NULL); mtl_pool_del(child.p); free(child.p); return r;
|
||||
}
|
||||
static void compare_pair(const char *name,const result *o,const result *r,unsigned different) {
|
||||
save_result(name,0,o); save_result(name,1,r); unsigned bad=0;
|
||||
for(int k=0;k<1024;k+=4) bad+=memcmp((const uint8_t *)o+k,(const uint8_t *)r+k,4)!=0;
|
||||
EXPECT("完整区间/状态/控制流不同像素(256分母)",all_independent?0:different,bad);
|
||||
}
|
||||
int main(int argc,char **argv) { @autoreleasepool {
|
||||
setvbuf(stdout,NULL,_IONBF,0);
|
||||
all_independent=argc>1&&!strcmp(argv[1],"--all-independent"); setenv("DM_NVN_TBDR","0",1); mtl_init();
|
||||
NSError *err=nil; id<MTLLibrary> lib=[g_dev newLibraryWithSource:@"#include <metal_stdlib>\nusing namespace metal;\n"
|
||||
"vertex float4 v(uint n [[vertex_id]]){float2 p[3]={float2(-1,-1),float2(3,-1),float2(-1,3)};return float4(p[n],0,1);}\n"
|
||||
"fragment float4 red(){return float4(1,0,0,1);} fragment float4 blue(){return float4(0,0,1,1);} fragment float4 green(){return float4(0,1,0,1);}\n"
|
||||
"struct A{texture2d<float> t [[id(0)]];}; fragment float4 readtex(constant A&a [[buffer(0)]]){return a.t.read(uint2(0));}\n"
|
||||
"fragment float4 halftex(constant A&a [[buffer(0)]]){return float4(a.t.read(uint2(0)).rgb,0.5);}\n"
|
||||
"fragment float4 readlevel1(constant A&a [[buffer(0)]]){return a.t.read(uint2(0),1);}\n"
|
||||
"struct T{texture2d_array<float> t [[id(0)]];}; fragment float4 readslice1(constant T&a [[buffer(0)]]){return a.t.read(uint2(0),1);}\n"
|
||||
"struct U{constant float4 *c [[id(0)]];}; fragment float4 ub(constant U&a [[buffer(0)]]){return *a.c;}\n" options:nil error:&err];
|
||||
if(!lib) { fprintf(stderr,"%s\n",err.localizedDescription.UTF8String); return 2; }
|
||||
NSString *fn[8]={@"red",@"blue",@"readtex",@"halftex",@"ub",@"readlevel1",@"readslice1",@"green"};
|
||||
for(int i=0;i<8;i++) { NvProg *p=[NvProg new]; p->sh[0]=[NvShader new]; p->sh[0]->fn=[lib newFunctionWithName:@"v"];
|
||||
p->sh[1]=[NvShader new]; NvShader *f=p->sh[1]; f->fn=[lib newFunctionWithName:fn[i]]; f->stage=1;
|
||||
if(i>=2&&i!=7) { f->rf.nb=1; f->rf.b[0]=(nvn_rbind){.kind=i==4?NVN_RB_CBUF:NVN_RB_TEX,.dtt=i==6?3:2}; f->ae=[f->fn newArgumentEncoderWithBufferIndex:0]; }
|
||||
pg[i].serial=4000+i; serial_put(pg[i].serial,p); }
|
||||
const char *names[]={"独立mip复制","同mip反例","模板不交位","模板交位反例","复制读源反例","块内次序反例"};
|
||||
for(int mode=0;mode<6;mode++) { printf("CASE %s\n",names[mode]); result o=render_case(mode,0),r=render_case(mode,1);
|
||||
save_result(names[mode],0,&o); save_result(names[mode],1,&r);
|
||||
int same=mode==SAME_MIP; uniform_pixels("原序闭式resolve",o.c,0,same?0:128,same?255:128,128);
|
||||
uint8_t cr=mode==INTERNAL_ORDER?128:0,cg=mode==SAME_MIP||mode==STENCIL_DEPENDENT?0:128,cb=mode==INTERNAL_ORDER?0:128;
|
||||
uniform_pixels("候选闭式resolve",r.c,cr,cg,cb,128);
|
||||
uniform_pixels("原序独立/依赖复制结果",o.e,0,0,255,255);
|
||||
uniform_pixels("候选复制结果",r.e,0,0,mode==COPY_DEPENDENT?0:255,255);
|
||||
unsigned different=0; const uint8_t *x=(const uint8_t *)&o,*y=(const uint8_t *)&r;
|
||||
for(int k=0;k<1024;k+=4) different+=memcmp(x+k,y+k,4)!=0;
|
||||
EXPECT("重排不同像素(4附件256像素分母)",all_independent?0:mode==INDEPENDENT||mode==STENCIL_INDEPENDENT?0:mode==COPY_DEPENDENT?64:mode==INTERNAL_ORDER?128:192,different);
|
||||
}
|
||||
uint64_t q0=query_case(0,0),q1=query_case(1,0); EXPECT("reset原区间4x4通过采样",16,q0); EXPECT("跨reset反例4x4+8x8通过采样",80,q1);
|
||||
EXPECT("查询生命周期不能当独立",all_independent?1:0,q0==q1);
|
||||
uint8_t u0[256],u1[256]; uniform_case(0,u0); uniform_case(1,u1); uniform_pixels("UB原序首绘红",u0,255,0,0,255); uniform_pixels("跨UB写首绘绿",u1,0,255,0,255);
|
||||
EXPECT("UB写不能跨绘制搬动",all_independent?1:0,!memcmp(u0,u1,256));
|
||||
for(int array=0;array<2;array++) { const char *name=array?"整slice范围":"整mip范围"; printf("CASE %s\n",name);
|
||||
result o=range_case(array,0),r=range_case(array,1); uniform_pixels("范围原序第二子资源蓝",o.b,0,0,255,255);
|
||||
uniform_pixels("范围候选第二子资源绿",r.b,0,255,0,255); compare_pair(name,&o,&r,64); }
|
||||
for(int restored=0;restored<2;restored++) { const char *name=restored?"入口程序显式补齐":"入口程序继承"; printf("CASE %s\n",name);
|
||||
result o=state_case(restored,0),r=state_case(restored,1); uniform_pixels("继承原序蓝",o.b,0,0,255,255);
|
||||
uniform_pixels("候选显式补齐蓝/未补齐红",r.b,restored?0:255,0,restored?255:0,255); compare_pair(name,&o,&r,restored?0:64); }
|
||||
for(int restored=0;restored<2;restored++) { const char *name=restored?"出口程序显式补齐":"出口程序继承"; printf("CASE %s\n",name);
|
||||
result o=exit_state_case(restored,0),r=exit_state_case(restored,1); uniform_pixels("后续原序继承蓝",o.c,0,0,255,255);
|
||||
uniform_pixels("后续候选显式补齐蓝/未补齐红",r.c,restored?0:255,0,restored?255:0,255); compare_pair(name,&o,&r,restored?0:64); }
|
||||
for(int jump=0;jump<2;jump++) { const char *name=jump?"JUMP隐藏写":"CALL隐藏写"; printf("CASE %s\n",name);
|
||||
result o=control_case(jump,0),r=control_case(jump,1); uniform_pixels("控制原序蓝",o.b,0,0,255,255);
|
||||
uniform_pixels("控制候选先读黑",r.b,0,0,0,255); compare_pair(name,&o,&r,64); }
|
||||
q0=query_case(0,1); q1=query_case(1,1); EXPECT("同epoch原序通过采样64+16",80,q0); EXPECT("同epoch换序通过采样16+64",80,q1);
|
||||
EXPECT("同epoch固定两绘制换序保持报告80",1,q0==q1);
|
||||
q0=query_case(0,2); q1=query_case(1,2); EXPECT("后继reset覆盖原未报告计数",16,q0); EXPECT("后继reset覆盖候选未报告计数",16,q1);
|
||||
EXPECT("本固定后继reset支配report,交换前后所报16相同",1,q0==q1);
|
||||
printf("CASE 模板隐含进位读\n"); result co=stencil_carry_case(0),cr=stencil_carry_case(1);
|
||||
uniform_pixels("低位先清导致bit1为0",co.c,0,0,0,255); uniform_pixels("先增进位导致bit1为1",cr.c,0,255,0,255); compare_pair("模板隐含进位读",&co,&cr,64);
|
||||
printf("== %d 项,失败 %d ==\n",count,fail); return fail!=0;
|
||||
} }
|
||||
@@ -0,0 +1,25 @@
|
||||
// CPU资格反例:真实production rt_range_same,Metal对象由明确mock提供,不启GPU/不证明像素。
|
||||
// CPU eligibility counterexample: real production rt_range_same, Metal objects supplied by explicit mocks; no GPU is started and no pixels are proven.
|
||||
#include "../nvn/nvn_mtl.m"
|
||||
void *front_metal_layer(void){return NULL;}
|
||||
module_t *module_of(const void *p){(void)p;return NULL;}
|
||||
module_t g_mod[MAX_MOD];int g_nmod;void svc_thread_dump(void){}uint64_t now_ns(void){return bp_now();}
|
||||
@interface MockTex:NSObject @end
|
||||
@implementation MockTex
|
||||
-(NSUInteger)width{return 8;}-(NSUInteger)height{return 8;}-(NSUInteger)sampleCount{return 1;}-(MTLTextureType)textureType{return MTLTextureType2D;}
|
||||
@end
|
||||
static int n,bad;
|
||||
#define E(s,w,a) do{int v=(a);n++;printf("%s 期望%d → 真结果%d\n",s,w,v);bad+=(w)!=v;}while(0)
|
||||
static void history(void){
|
||||
#ifdef NVN_RT_RANGE_DEPTH_IMPL
|
||||
rt_range_note_depth();
|
||||
#endif
|
||||
}
|
||||
int main(void){@autoreleasepool{setenv("DM_NVN_RT_RANGE","1",1);tex_t c={.serial=26},d={.serial=29};c.d.width=c.d.height=d.d.width=d.d.height=8;c.d.depth=d.d.depth=c.d.samples=d.d.samples=1;c.d.levels=4;d.d.levels=1;c.d.target=d.d.target=NVN_TEXTURE_TARGET_2D;c.d.format=NVN_FORMAT_RGBA8;d.d.format=NVN_FORMAT_DEPTH32F_STENCIL8;
|
||||
view_t cv={.set_levels=1,.nlevels=4};p_set_rt a={.n=1,.depth=&d};a.color[0]=&c;a.has_cview[0]=1;a.cview[0]=cv;p_set_rt b=a;b.cview[0].nlevels=1;
|
||||
id<MTLTexture> tc=(id)[MockTex new],td=(id)[MockTex new];serial_put(26,tc);serial_put(29,td);g_enc=(id)[NSObject new];g_enc_mode=4;g_pass.hd=1;g_pass.tw=g_pass.th=8;g_pass.range_color=tc;g_pass.range_depth=td;g_pass.reg_gen=g_reg_gen;g_pass.ser_gen=g_ser_gen;g_pass.range_dirty=nvn_dirty_now();S.ds.dt=1;
|
||||
E("原已证深度RO资格保持",1,rt_range_same(&a,&b));S.ds.dw=1;E("当前深度写拒绝",0,rt_range_same(&a,&b));history();S.ds.dw=0;E("曾写深度不能只看末态",0,rt_range_same(&a,&b));
|
||||
#ifdef NVN_RT_RANGE_DEPTH_IMPL
|
||||
g_pass.range_depth_nonro=0;
|
||||
#endif
|
||||
S.ds.dt=0;E("当前无depth读取不扩checker射程",0,rt_range_same(&a,&b));g_enc=nil;printf("RT_DEPTH_RO cases=%d failed=%d MOCK_METAL_NO_GPU\n",n,bad);return bad!=0;}}
|
||||
@@ -0,0 +1,52 @@
|
||||
// 实际RT单级选择不变,仅view范围4→1;同纹理同CB原guard参考与候选,手写常量shader不冒游戏shader。
|
||||
// The actual RT single-level selection is unchanged, only the view range goes 4→1; same texture and same CB for the original-guard reference and the candidate; hand-written constant shaders do not pass themselves off as game shaders.
|
||||
#include "../nvn/nvn_mtl.m"
|
||||
void *front_metal_layer(void){return NULL;}
|
||||
module_t *module_of(const void *p){(void)p;return NULL;}
|
||||
module_t g_mod[MAX_MOD];int g_nmod;
|
||||
void svc_thread_dump(void){}
|
||||
uint64_t now_ns(void){return bp_now();}
|
||||
static int cases,bad,enabled,small_depth,force_invalid,sample_attachment,both_flags;
|
||||
#define E(n,w,a) do{uint64_t actual=(a),want=(w);cases++;printf("%s 期望%llu → 真结果%llu\n",n,(unsigned long long)want,(unsigned long long)actual);bad+=want!=actual;}while(0)
|
||||
typedef struct{uint8_t b[8192];size_t n;} code;
|
||||
static void emit(code *c,int op,const void *p,size_t n){size_t z=(8+n+7)&~7ull;op_hdr h={op,(uint32_t)z};memcpy(c->b+c->n,&h,8);if(n)memcpy(c->b+c->n+8,p,n);c->n+=z;}
|
||||
static void st(code *c,int k,const void *v,size_t n){p_bind_state b={.kind=k};memcpy(b.bytes,v,n);emit(c,OP_BIND_STATE,&b,sizeof b);}
|
||||
static tex_t color={.serial=52000},depth={.serial=52001};static prog_t pg[2]={{.serial=52002},{.serial=52003}};
|
||||
static p_set_rt rt(int levels){p_set_rt r={.n=1,.depth=&depth,.has_dview=1};r.color[0]=&color;r.has_cview[0]=1;
|
||||
r.cview[0]=(view_t){.set_levels=1,.set_layers=1,.set_format=1,.set_target=1,.nlevels=levels,.nlayers=1,.format=NVN_FORMAT_RGBA8,.target=NVN_TEXTURE_TARGET_2D};
|
||||
r.dview=r.cview[0];r.dview.nlevels=1;r.dview.base_level=small_depth?1:0;r.dview.format=NVN_FORMAT_DEPTH32F_STENCIL8;return r;}
|
||||
static void seed(void){MTL4RenderPassDescriptor *p=[MTL4RenderPassDescriptor new];p.colorAttachments[0].texture=tex_mtl(&color);p.colorAttachments[0].loadAction=MTLLoadActionClear;p.colorAttachments[0].storeAction=MTLStoreActionStore;p.colorAttachments[0].clearColor=MTLClearColorMake(0,0,0,1);
|
||||
p.depthAttachment.texture=p.stencilAttachment.texture=tex_mtl(&depth);p.depthAttachment.loadAction=p.stencilAttachment.loadAction=MTLLoadActionClear;p.depthAttachment.storeAction=p.stencilAttachment.storeAction=MTLStoreActionStore;p.depthAttachment.clearDepth=.75;p.stencilAttachment.clearStencil=0x2d;enc_r_end(enc_r_begin(p));
|
||||
if(sample_attachment){MTL4RenderPassDescriptor *q=[MTL4RenderPassDescriptor new];q.colorAttachments[0].texture=tex_mtl(&color);q.colorAttachments[0].level=1;q.colorAttachments[0].loadAction=MTLLoadActionClear;q.colorAttachments[0].storeAction=MTLStoreActionStore;q.colorAttachments[0].clearColor=MTLClearColorMake(0,1,0,0);enc_r_end(enc_r_begin(q));}
|
||||
if(small_depth){p.colorAttachments[0].texture=nil;p.depthAttachment.level=p.stencilAttachment.level=1;enc_r_end(enc_r_begin(p));}}
|
||||
static void rr_read_planes(id<MTLBuffer> __strong *b){id<MTLTexture> t=tex_mtl(&color),d=tex_mtl(&depth);[blit()copyFromTexture:t sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(0,0,0)sourceSize:MTLSizeMake(8,8,1)toBuffer:b[0]destinationOffset:0 destinationBytesPerRow:32 destinationBytesPerImage:256];
|
||||
[blit()copyFromTexture:d sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(0,0,0)sourceSize:MTLSizeMake(8,8,1)toBuffer:b[1]destinationOffset:0 destinationBytesPerRow:32 destinationBytesPerImage:256 options:MTLBlitOptionDepthFromDepthStencil];
|
||||
[blit()copyFromTexture:d sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(0,0,0)sourceSize:MTLSizeMake(8,8,1)toBuffer:b[2]destinationOffset:0 destinationBytesPerRow:8 destinationBytesPerImage:64 options:MTLBlitOptionStencilFromDepthStencil];}
|
||||
int main(int argc,char **argv){@autoreleasepool{enabled=1;for(int i=1;i<argc;i++){if(!strcmp(argv[i],"--disabled"))enabled=0;else if(!strcmp(argv[i],"--small-depth"))small_depth=1;else if(!strcmp(argv[i],"--force-invalid"))force_invalid=1;else if(!strcmp(argv[i],"--sample-attachment"))sample_attachment=1;else if(!strcmp(argv[i],"--both-flags"))both_flags=1;}if(enabled)setenv("DM_NVN_RT_RANGE","1",1);else unsetenv("DM_NVN_RT_RANGE");if(both_flags)setenv("DM_NVN_VIEW_CONTINUE","1",1);else unsetenv("DM_NVN_VIEW_CONTINUE");mtl_init();NSError *err=nil;
|
||||
id<MTLLibrary> lib=[g_dev newLibraryWithSource:@"#include <metal_stdlib>\nusing namespace metal;vertex float4 v(uint n[[vertex_id]]){float2 p[3]={float2(-1,-1),float2(3,-1),float2(-1,3)};return float4(p[n],.5,1);}\nfragment float4 r(){return float4(1,0,0,1);}\nfragment float4 g(){return float4(0,1,0,0);}struct A{texture2d<float> t[[id(0)]];};fragment float4 s(constant A&a[[buffer(0)]]){return a.t.read(uint2(0));}\n"options:nil error:&err];if(!lib)abort();
|
||||
for(int i=0;i<2;i++){NvProg *p=[NvProg new];p->sh[0]=[NvShader new];p->sh[0]->fn=[lib newFunctionWithName:@"v"];p->sh[1]=[NvShader new];p->sh[1]->fn=[lib newFunctionWithName:i?(sample_attachment?@"s":@"g"):@"r"];p->sh[1]->stage=1;p->sh[1]->rf.color_mask=1;if(i&&sample_attachment){p->sh[1]->rf.nb=1;p->sh[1]->rf.b[0]=(nvn_rbind){.kind=NVN_RB_TEX,.dtt=MTLTextureType2D};p->sh[1]->ae=[p->sh[1]->fn newArgumentEncoderWithBufferIndex:0];}
|
||||
#ifdef NVN_RT_RANGE_RO_IMPL
|
||||
p->sh[0]->range_ro=p->sh[1]->range_ro=1; // 本测试手写constant shader,已直接查无外部写 | this test hand-writes constant shaders and has directly verified there are no external writes
|
||||
#endif
|
||||
serial_put(pg[i].serial,p);}
|
||||
color.d.width=color.d.height=depth.d.width=depth.d.height=8;color.d.depth=color.d.samples=depth.d.depth=depth.d.samples=1;color.d.levels=4;depth.d.levels=small_depth?2:1;color.d.target=depth.d.target=NVN_TEXTURE_TARGET_2D;color.d.format=NVN_FORMAT_RGBA8;depth.d.format=NVN_FORMAT_DEPTH32F_STENCIL8;
|
||||
(void)tex_mtl(&color);(void)tex_mtl(&depth);if(sample_attachment){view_t v={.set_levels=1,.base_level=1,.nlevels=1};mtl_reg_tex(1000,&color,&v);}
|
||||
uint16_t *ix;posix_memalign((void **)&ix,getpagesize(),getpagesize());for(int i=0;i<120;i++)ix[i]=i%3;mtl_pool_add(ix,getpagesize());
|
||||
code first={0},second={0};p_set_rt a=rt(4),b=rt(1);emit(&first,OP_SET_RT,&a,sizeof a);ds_st ds={.dt=1,.df=NVN_DEPTH_FUNC_LESS};st(&first,5,&ds,sizeof ds);
|
||||
color_st col={0,NVN_LOGIC_OP_COPY,NVN_ALPHA_FUNC_ALWAYS};st(&first,1,&col,sizeof col);p_bind_program pr={&pg[0],3};emit(&first,OP_BIND_PROGRAM,&pr,sizeof pr);uint64_t reset=NVN_COUNTER_TYPE_SAMPLES_PASSED;emit(&first,OP_RESET_COUNTER,&reset,8);p_draw dw={NVN_DRAW_PRIMITIVE_TRIANGLES,0,3};emit(&first,OP_DRAW,&dw,sizeof dw);emit(&first,OP_END,NULL,0);
|
||||
emit(&second,OP_RESET_COUNTER,&reset,8);emit(&second,OP_SET_RT,&b,sizeof b);if(small_depth){ds_st off={.df=NVN_DEPTH_FUNC_ALWAYS};st(&second,5,&off,sizeof off);}pr.prog=&pg[1];emit(&second,OP_BIND_PROGRAM,&pr,sizeof pr);if(sample_attachment){p_bind_handles h={.stage=1,.first=0,.n=1};h.h[0]=1000;emit(&second,OP_BIND_TEX,&h,sizeof h);}col.blend_en=1;st(&second,1,&col,sizeof col);blend_st blend={0,NVN_BLEND_FUNC_ONE,NVN_BLEND_FUNC_ONE,NVN_BLEND_FUNC_ONE,NVN_BLEND_FUNC_ZERO,NVN_BLEND_EQUATION_ADD,NVN_BLEND_EQUATION_ADD};st(&second,0,&blend,sizeof blend);p_draw_idx di={.prim=NVN_DRAW_PRIMITIVE_TRIANGLES,.count=120,.itype=1,.ibuf=(uint64_t)ix,.instances=1};emit(&second,OP_DRAW_IDX,&di,sizeof di);emit(&second,OP_END,NULL,0);
|
||||
id<MTLBuffer> buffers[2][3];for(int m=0;m<2;m++)for(int j=0;j<3;j++)buffers[m][j]=[g_dev newBufferWithLength:j==2?64:256 options:MTLResourceStorageModeShared];uint64_t passes[2],bytes[2],q[2][2]={{0}};
|
||||
mtl_sub_begin();
|
||||
for(int m=0;m<2;m++){state_reset();memset(&R,0,sizeof R);vis_clear();g_vis_on=g_vis_counting=0;seed();uint64_t p=g_stat_pass,l=g_bw_load,s=g_bw_store,draws=g_stat_draw;mtl_exec(first.b);E("首绘按深度只读模式",4,g_enc_mode);if(!m)rp_end();else if(force_invalid)R.rt.cview[0].nlevels=1; // 负控:错误地假设附件范围/目标始终等价 | negative control: wrongly assume the attachment range/target is always equivalent
|
||||
mtl_exec(second.b);rp_end();passes[m]=g_stat_pass-p;bytes[m]=g_bw_load-l+g_bw_store-s;E("真实draw次数不变",2,g_stat_draw-draws);post((post_op){3,NULL,0,0,(uint64_t)q[m],(uint32_t)reset,vis_snapshot()});rr_read_planes(buffers[m]);if(g_blit){[g_blit endEncoding];g_blit=nil;}}
|
||||
int done=mtl_wait(mtl_sub_commit(),5000000000ull);E("同纹理同CB完成",1,done);if(!done)abort();E("提交反馈无错误",0,mtl_last_commit_error());
|
||||
uint8_t yellow[4]={255,255,0,0},green[4]={0,255,0,0}; // alpha由第二draw ONE/ ZERO给0;整数闭式RGB黄色。 | alpha is given 0 by the second draw's ONE/ ZERO; integer closed-form RGB yellow.
|
||||
for(int m=0;m<2;m++){unsigned bc=0,bd=0,bs=0;for(int i=0;i<64;i++){bc+=memcmp((uint8_t *)buffers[m][0].contents+4*i,small_depth && (i%8>=4||i/8>=4)?green:yellow,4)!=0;bd+=((float *)buffers[m][1].contents)[i]!=.75f;bs+=((uint8_t *)buffers[m][2].contents)[i]!=0x2d;}E("各64纹素手算黄色",0,bc);E("depth .75种子保持",0,bd);E("stencil 0x2d种子保持",0,bs);E("Reset后120索引40三角采样数",2560,q[m][0]);}
|
||||
E("三平面原候选逐字节",0,memcmp(buffers[0][0].contents,buffers[1][0].contents,256)||memcmp(buffers[0][1].contents,buffers[1][1].contents,256)||memcmp(buffers[0][2].contents,buffers[1][2].contents,64));
|
||||
E("原guard两pass",2,passes[0]);E("候选一pass/默认两pass",enabled&&!small_depth&&!sample_attachment?1:2,passes[1]);{ // DontCare(本通道没写不写回):两个通道的深度状态都只开测试不开写,每个通道省一次深度模板写回 = 8×8×5 字节(Depth32F_S8 附件模型 5 B/像素) | DontCare (not stored if this pass did not write it): both passes' depth state enables only test, not write, so each pass saves one depth-stencil store = 8×8×5 bytes (Depth32F_S8 attachment model, 5 B/pixel)
|
||||
const char *u=getenv("DM_NVN_UNWRITTEN_DC"); int udc=!(u&&!strcmp(u,"0")); unsigned dsb=udc&&!small_depth&&!sample_attachment?8*8*5:0;
|
||||
E(udc?"原附件模型2048−2×320(DontCare)":"原附件模型2048",(small_depth?1152:2048)-2*dsb,bytes[0]);
|
||||
E(udc?"候选附件模型1024−320(DontCare)":"候选附件模型1024/默认2048",(small_depth?1152:enabled&&!sample_attachment?1024:2048)-(enabled&&!sample_attachment?1:2)*dsb,bytes[1]); }
|
||||
const char *dir=getenv("DM_GFX_FIXTURE_OUT");if(dir){char p[1024];for(int m=0;m<2;m++)for(int j=0;j<3;j++){snprintf(p,sizeof p,"%s/%s_%s.raw",dir,m?"candidate":"reference",j==0?"color":j==1?"depth":"stencil");FILE *f=fopen(p,"wb");if(!f||fwrite(buffers[m][j].contents,1,j==2?64:256,f)!=(j==2?64:256))abort();fclose(f);}}
|
||||
mtl_pool_del(ix);free(ix);printf("RT_RANGE_GPU cases=%d failed=%d\n",cases,bad);return bad!=0;
|
||||
}}
|
||||
@@ -0,0 +1,38 @@
|
||||
#include "../nvn/nvn_mtl.m"
|
||||
void *front_metal_layer(void){return NULL;}
|
||||
module_t *module_of(const void *p){(void)p;return NULL;}
|
||||
module_t g_mod[MAX_MOD];int g_nmod;
|
||||
void svc_thread_dump(void){}
|
||||
uint64_t now_ns(void){return bp_now();}
|
||||
static int cases,bad;
|
||||
static int ro(NSDictionary *j){
|
||||
#ifdef NVN_RT_RANGE_RO_IMPL
|
||||
return rt_range_bindings_ro(j);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#define E(n,w,a) do{int v=(a);cases++;printf("%s 期望%d → 真结果%d\n",n,w,v);bad+=(w)!=v;}while(0)
|
||||
static NSDictionary *one(NSDictionary *b){return @{ @"route":@"B",@"drv_reads":@{},@"bindings":@[b] };}
|
||||
int main(void){@autoreleasepool{
|
||||
E("明确sbuf RO",1,ro(one(@{@"kind":@"sbuf",@"msl_type":@"const device _27*",@"rw":@NO})));
|
||||
E("缺rw不当默认0证明",0,ro(one(@{@"kind":@"sbuf",@"msl_type":@"const device _27*"})));
|
||||
E("rw写用途拒绝",0,ro(one(@{@"kind":@"sbuf",@"msl_type":@"device _27*",@"rw":@YES})));
|
||||
E("device缺const拒绝",0,ro(one(@{@"kind":@"sbuf",@"msl_type":@"device _27*",@"rw":@NO})));
|
||||
E("image未知用途拒绝",0,ro(one(@{@"kind":@"img",@"msl_type":@"texture2d<float, access::read>"})));
|
||||
E("sample纹理明确RO",1,ro(one(@{@"kind":@"tex",@"msl_type":@"texture2d<float>"})));
|
||||
E("tex显式rw拒绝",0,ro(one(@{@"kind":@"tex",@"msl_type":@"texture2d<float>",@"rw":@YES})));
|
||||
E("constant cbuf显式rw拒绝",0,ro(one(@{@"kind":@"cbuf",@"msl_type":@"constant _16*",@"rw":@YES})));
|
||||
E("rw类型未知拒绝",0,ro(one(@{@"kind":@"tex",@"msl_type":@"texture2d<float>",@"rw":@"false"})));
|
||||
E("driver间接地址不扩展",0,ro(one(@{@"kind":@"drv0",@"msl_type":@"constant _16*"})));
|
||||
E("texture read_write拒绝",0,ro(one(@{@"kind":@"tex",@"msl_type":@"texture2d<float, access::read_write>"})));
|
||||
E("texture write拒绝",0,ro(one(@{@"kind":@"tex",@"msl_type":@"texture2d<float, access::write>"})));
|
||||
E("cbuf constant明确RO",1,ro(one(@{@"kind":@"cbuf",@"msl_type":@"constant _16*"})));
|
||||
E("cbuf类型未知拒绝",0,ro(one(@{@"kind":@"cbuf",@"msl_type":@"device _16*"})));
|
||||
E("未知kind拒绝",0,ro(one(@{@"kind":@"opaque",@"msl_type":@"constant _16*"})));
|
||||
E("缺bindings拒绝",0,ro(@{@"route":@"B"}));
|
||||
E("缺driver语义信息拒绝",0,ro(@{@"route":@"B",@"bindings":@[]}));
|
||||
E("存在driver间接读取拒绝",0,ro(@{@"route":@"B",@"bindings":@[],@"drv_reads":@{@"0":@YES}}));
|
||||
NSString *d=[NSString stringWithFormat:@"%s%s/build/cache/metal_shader_cache/b-%s", getenv("DM_ROOT") ?: getenv("HOME"), getenv("DM_ROOT") ? "" : "/dm-work", DMSH_CHAIN];
|
||||
for(NSString *k in @[@"06ece8336c8c242c",@"6d19a794f1206668",@"fa27a102ecd14b3e",@"1bd6a72fa95c6a07"]){NSData *s=[NSData dataWithContentsOfFile:[NSString stringWithFormat:@"%@/%@_b.json",d,k]];NSDictionary *j=[NSJSONSerialization JSONObjectWithData:s options:0 error:nil];E(k.UTF8String,1,ro(j));}
|
||||
printf("RT_RANGE_RO cases=%d failed=%d\n",cases,bad);return bad!=0;}}
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "../nvn/nvn_mtl.m"
|
||||
void *front_metal_layer(void){return NULL;}
|
||||
module_t *module_of(const void *p){(void)p;return NULL;}
|
||||
module_t g_mod[MAX_MOD];int g_nmod;
|
||||
void svc_thread_dump(void){}
|
||||
uint64_t now_ns(void){return bp_now();}
|
||||
static int cases,bad;
|
||||
#define E(label,w,a) do{int actual=(a);cases++;printf("%s 期望%d → 真结果%d\n",label,w,actual);bad+=(w)!=actual;}while(0)
|
||||
static int shape(const p_set_rt *a,const p_set_rt *b){
|
||||
#ifdef NVN_RT_RANGE_IMPL
|
||||
return rt_range_shape(a,b);
|
||||
#else
|
||||
return rt_same(a,b);
|
||||
#endif
|
||||
}
|
||||
int main(void){@autoreleasepool{
|
||||
tex_t c={.serial=26},d={.serial=29};c.d.width=c.d.height=8;c.d.depth=c.d.samples=1;c.d.levels=4;c.d.target=NVN_TEXTURE_TARGET_2D;c.d.format=NVN_FORMAT_RGBA8;d.d=c.d;d.d.levels=1;d.d.format=NVN_FORMAT_DEPTH32F_STENCIL8;
|
||||
view_t cv={.set_levels=1,.set_layers=1,.set_format=1,.set_target=1,.base_level=0,.nlevels=4,.min_layer=0,.nlayers=1,.format=NVN_FORMAT_RGBA8,.target=NVN_TEXTURE_TARGET_2D};view_t dv=cv;dv.nlevels=1;dv.format=d.d.format;
|
||||
p_set_rt a={.n=1,.depth=&d,.has_dview=1,.dview=dv};a.color[0]=&c;a.has_cview[0]=1;a.cview[0]=cv;p_set_rt b=a;b.cview[0].nlevels=1;
|
||||
E("实际level0同层仅级数变化",1,shape(&a,&b));
|
||||
tex_t small=d;small.d.levels=2;p_set_rt sa=a,sb=b;sa.depth=sb.depth=&small;sa.dview.base_level=sb.dview.base_level=1;E("深度尺寸收窄颜色时仍切",0,shape(&sa,&sb));
|
||||
p_set_rt x=b;x.cview[0].base_level=1;E("level变化仍切",0,shape(&a,&x));x=b;x.cview[0].min_layer=1;E("层变化仍切",0,shape(&a,&x));
|
||||
x=b;x.cview[0].nlevels=0;E("未知零级数仍切",0,shape(&a,&x));x=b;x.cview[0].nlevels=5;E("越界级数仍切",0,shape(&a,&x));
|
||||
x=b;x.cview[0].format=NVN_FORMAT_RGBA16F;E("格式变化仍切",0,shape(&a,&x));x=b;x.cview[0].target=NVN_TEXTURE_TARGET_2D_ARRAY;E("target变化仍切",0,shape(&a,&x));
|
||||
x=b;x.has_cview[0]=0;E("未知view仍切",0,shape(&a,&x));x=b;x.cview[0].set_levels=0;E("无明确level仍切",0,shape(&a,&x));
|
||||
x=b;x.cview[0].nlayers=2;E("未知层范围仍切",0,shape(&a,&x));x=b;x.dview.nlevels=0;E("深度view变化仍切",0,shape(&a,&x));x=b;x.depth=NULL;E("深度附件变化仍切",0,shape(&a,&x));
|
||||
tex_t other=c;other.serial++;x=b;x.color[0]=&other;E("对象序号变化仍切",0,shape(&a,&x));other=c;other.d.width=16;x.color[0]=&other;E("同序号元数据变化仍切",0,shape(&a,&x));
|
||||
other=c;other.has_layout=1;other.mem=(uint8_t *)1;x=b;x.color[0]=&other;E("packaged未知版本仍切",0,shape(&a,&x));
|
||||
other=c;other.d.target=NVN_TEXTURE_TARGET_2D_ARRAY;x=b;x.color[0]=&other;E("数组目标仍切",0,shape(&a,&x));other=c;other.d.samples=4;x.color[0]=&other;E("多采样仍切",0,shape(&a,&x));
|
||||
x=b;x.n=2;x.color[1]=&c;E("多颜色不扩展",0,shape(&a,&x));
|
||||
printf("RT_RANGE_SHAPE cases=%d failed=%d\n",cases,bad);return bad!=0;
|
||||
}}
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "../nvn/nvn_mtl.m"
|
||||
void *front_metal_layer(void) { return NULL; }
|
||||
module_t *module_of(const void *p) { (void)p; return NULL; }
|
||||
module_t g_mod[MAX_MOD]; int g_nmod;
|
||||
void svc_thread_dump(void) {}
|
||||
uint64_t now_ns(void) { return bp_now(); }
|
||||
static int fail, count;
|
||||
#define EXPECT(name, want, got) do { long long w=(want), g=(got); count++; printf("%s 期望 %lld → 真结果 %lld %s\n", name, w, g, w==g?"OK":"FAIL"); if(w!=g) fail++; } while(0)
|
||||
int g_t_ub_var = 7, g_t_ub_var2 = -3; // 被 @set 按符号名找到的全局变量 | global variables found by @set via symbol name
|
||||
// 同进程交替测量(DM_NVN_UB)的相位逻辑单测:不起渲染,只按帧号推进。
|
||||
// 配置:两类,每相 60 帧。相序 = 基准, a, 基准, b, 基准, a, …;a = 设 g_t_ub_var=5 且丢键 abcd…;b = 设 g_t_ub_var2=9 且丢全部(*)。
|
||||
// Unit tests for the phase logic of same-process alternating measurement (DM_NVN_UB): no rendering is started, it only advances by frame number.
|
||||
// Configuration: two classes, 60 frames per phase. Phase order = baseline, a, baseline, b, baseline, a, ...; a = set g_t_ub_var=5 and drop keys abcd...; b = set g_t_ub_var2=9 and drop everything (*).
|
||||
int main(void) {
|
||||
setenv("DM_NVN_UB", "a=@set:g_t_ub_var=5,abcd;b=@set:g_t_ub_var2=9,*;c=@set:g_no_such_var=1", 1); setenv("DM_NVN_UB_N", "60", 1);
|
||||
struct { int f, v1, v2, skip_abcd, skip_other; const char *what; } T[] = {
|
||||
{0, 7, -3, 0, 0, "相 0 基准"}, {59, 7, -3, 0, 0, "相 0 末帧"},
|
||||
{60, 5, -3, 1, 0, "相 1 = a:变量 1 被设、丢 abcd"}, {119, 5, -3, 1, 0, "相 1 末帧"},
|
||||
{120, 7, -3, 0, 0, "相 2 基准:变量 1 还原"},
|
||||
{180, 7, 9, 1, 1, "相 3 = b:变量 2 被设、全丢"},
|
||||
{240, 7, -3, 0, 0, "相 4 基准:变量 2 还原"},
|
||||
{300, 7, -3, 0, 0, "相 5 = c:变量不存在,什么都不改"},
|
||||
{360, 7, -3, 0, 0, "相 6 基准"},
|
||||
{420, 5, -3, 1, 0, "相 7 = a(第二圈)"},
|
||||
};
|
||||
int ti = 0, n = (int)(sizeof T / sizeof T[0]);
|
||||
for (int f = 0; f <= 420 && ti < n; f++) { mtl_set_frame((uint64_t)f);
|
||||
if (f != T[ti].f) continue;
|
||||
char nm[96]; snprintf(nm, sizeof nm, "%s 变量1", T[ti].what); EXPECT(nm, T[ti].v1, g_t_ub_var);
|
||||
snprintf(nm, sizeof nm, "%s 变量2", T[ti].what); EXPECT(nm, T[ti].v2, g_t_ub_var2);
|
||||
snprintf(nm, sizeof nm, "%s 丢 abcd0123", T[ti].what); EXPECT(nm, T[ti].skip_abcd, ub_skip("abcd0123ffff0000"));
|
||||
snprintf(nm, sizeof nm, "%s 丢别的键", T[ti].what); EXPECT(nm, T[ti].skip_other, ub_skip("9999888877776666"));
|
||||
ti++; }
|
||||
EXPECT("走完的检查点数", n, ti);
|
||||
// 上屏间隔按相统计:相内第 45 帧起才计;三档界线 20.8 / 29.2 ms;−1 记丢弃
|
||||
// On-screen present intervals are tallied per phase: counted only from frame 45 of the phase on; boundaries of the three bands are 20.8 / 29.2 ms; −1 is recorded as discarded
|
||||
for (int f = 480; f < 480 + 45; f++) { mtl_set_frame((uint64_t)f); mtl_ub_present(16.7); } // 过渡段:不计 | transition segment: not counted
|
||||
EXPECT("过渡段不计", 0, atomic_load(&g_ubp_c[0]));
|
||||
mtl_set_frame(480 + 45); mtl_ub_present(16.7); mtl_ub_present(25.0); mtl_ub_present(25.0); mtl_ub_present(33.3); mtl_ub_present(-1); mtl_ub_present(0);
|
||||
EXPECT("16.7 ms 档", 1, atomic_load(&g_ubp_c[0])); EXPECT("25 ms 档", 2, atomic_load(&g_ubp_c[1])); EXPECT("≥33 ms 档", 1, atomic_load(&g_ubp_c[2])); EXPECT("丢弃", 1, atomic_load(&g_ubp_c[3]));
|
||||
EXPECT("间隔和(微秒)", 16700 + 25000 + 25000 + 33300, (long long)atomic_load(&g_ubp_sum_us));
|
||||
printf("t_ub:%d 项,失败 %d\n", count, fail); return fail != 0;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
#include "../nvn/nvn_mtl.m"
|
||||
void *front_metal_layer(void) { return NULL; }
|
||||
module_t *module_of(const void *p) { (void)p; return NULL; }
|
||||
module_t g_mod[MAX_MOD]; int g_nmod;
|
||||
void svc_thread_dump(void) {}
|
||||
uint64_t now_ns(void) { return bp_now(); }
|
||||
static int fail, count;
|
||||
#define EXPECT(name, want, got) do { uint64_t w=(want), g=(got); count++; printf("%s 期望 %llu → 真结果 %llu %s\n", name, (unsigned long long)w, (unsigned long long)g, w==g?"✓":"✗"); fail += w != g; } while (0)
|
||||
typedef struct { uint8_t *p; size_t n; } chain;
|
||||
static chain chain_new(void) { chain c={0}; if (posix_memalign((void **)&c.p,getpagesize(),65536)) abort(); memset(c.p,0,65536); mtl_pool_add(c.p,65536); return c; }
|
||||
static void emit(chain *c, unsigned op, const void *a, size_t n) { size_t z=(8+n+7)&~7ull; op_hdr h={op,(uint32_t)z}; memcpy(c->p+c->n,&h,8); if(n) memcpy(c->p+c->n+8,a,n); c->n+=z; }
|
||||
static tex_t tex(unsigned w) { static uint64_t s=9000; tex_t t={.serial=s++}; t.d.width=t.d.height=w; t.d.depth=t.d.samples=1; t.d.levels=2; t.d.target=NVN_TEXTURE_TARGET_2D; t.d.format=NVN_FORMAT_RGBA8; return t; }
|
||||
static int view(const tex_t *t, int lv) { static int id=1200; view_t v={.set_levels=1,.base_level=lv,.nlevels=1}; mtl_reg_tex(id,t,&v); return id++; }
|
||||
static void set_rt(chain *c, const tex_t *a, const tex_t *b, int alv) { p_set_rt r={.n=b?2:1}; r.color[0]=a; r.color[1]=b; for(int i=0;i<r.n;i++){r.has_cview[i]=1;r.cview[i].set_levels=1;r.cview[i].base_level=i?0:alv;r.cview[i].nlevels=1;} emit(c,OP_SET_RT,&r,sizeof r); p_viewports v={.n=1};v.v[0][2]=v.v[0][3]=8;emit(c,OP_VIEWPORTS,&v,sizeof v);p_scissor sc={0,0,8,8};emit(c,OP_SCISSOR,&sc,sizeof sc); }
|
||||
static void clear_color(chain *c, int i, float r, float g, float b) { p_clear_color x={.index=i,.mask=15,.rgba={r,g,b,1}}; emit(c,OP_CLEAR_COLOR,&x,sizeof x); }
|
||||
static void bind_prog(chain *c, prog_t *p) { p_bind_program b={p,3}; emit(c,OP_BIND_PROGRAM,&b,sizeof b); }
|
||||
static void bind_tex(chain *c, int id) { p_bind_handles b={.stage=1,.first=0,.n=1};b.h[0]=id;emit(c,OP_BIND_TEX,&b,sizeof b); }
|
||||
static void draw_cmd(chain *c) { p_draw d={NVN_DRAW_PRIMITIVE_TRIANGLES,0,3}; emit(c,OP_DRAW,&d,sizeof d); }
|
||||
static void blend(chain *c) { color_st col={1,NVN_LOGIC_OP_COPY,NVN_ALPHA_FUNC_ALWAYS}; p_bind_state x={.kind=1};memcpy(x.bytes,&col,sizeof col);emit(c,OP_BIND_STATE,&x,sizeof x); blend_st b={0,NVN_BLEND_FUNC_SRC_ALPHA,NVN_BLEND_FUNC_ONE_MINUS_SRC_ALPHA,NVN_BLEND_FUNC_ONE,NVN_BLEND_FUNC_ZERO,NVN_BLEND_EQUATION_ADD,NVN_BLEND_EQUATION_ADD};x.kind=0;memcpy(x.bytes,&b,sizeof b);emit(c,OP_BIND_STATE,&x,sizeof x); }
|
||||
static void ds_off(chain *c) { ds_st d={0,0,NVN_DEPTH_FUNC_ALWAYS,0,NVN_STENCIL_FUNC_ALWAYS,NVN_STENCIL_FUNC_ALWAYS,NVN_STENCIL_OP_KEEP,NVN_STENCIL_OP_KEEP,NVN_STENCIL_OP_KEEP,NVN_STENCIL_OP_KEEP,NVN_STENCIL_OP_KEEP,NVN_STENCIL_OP_KEEP}; p_bind_state x={.kind=5}; memcpy(x.bytes,&d,sizeof d); emit(c,OP_BIND_STATE,&x,sizeof x); }
|
||||
static void readback(const tex_t *t, uint8_t out[256]) { id<MTLBuffer> b=[g_dev newBufferWithLength:256 options:MTLResourceStorageModeShared]; [blit() copyFromTexture:tex_mtl(t) sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(0,0,0) sourceSize:MTLSizeMake(8,8,1) toBuffer:b destinationOffset:0 destinationBytesPerRow:32 destinationBytesPerImage:256]; uint64_t f=mtl_sub_commit(); EXPECT("提交完成",1,mtl_wait(f,5000000000ull)); EXPECT("提交反馈无错误",0,mtl_last_commit_error()); memcpy(out,b.contents,256); }
|
||||
static NvProg *g_tkeep[256]; static int g_tnkeep; /* 测试里的程序对象常驻:释放后新对象可能落在同一地址,管线缓存按对象地址认会取到旧管线(生产里程序对象不释放) | Program objects in the tests are permanent: after a free, a new object may land at the same address, and the pipeline cache, keyed by object address, would return the old pipeline (in production program objects are never freed) */
|
||||
static void setup_prog(prog_t *pg) { NSError *e=nil; id<MTLLibrary> l=[g_dev newLibraryWithSource:@"#include <metal_stdlib>\nusing namespace metal; vertex float4 v(uint n[[vertex_id]]){float2 p[3]={float2(-1,-1),float2(3,-1),float2(-1,3)};return float4(p[n],0,1);}\nfragment float4 red(){return float4(1,0,0,0.5);}\nstruct A{texture2d<float> t[[id(0)]];}; fragment float4 sample(constant A&a[[buffer(0)]]){return a.t.read(uint2(0));}\n" options:nil error:&e]; if(!l){fprintf(stderr,"%s\n",e.localizedDescription.UTF8String);abort();} for(int i=0;i<2;i++)pg[i].serial=8000+i; for(int i=0;i<2;i++){NvProg *p=[NvProg new];p->sh[0]=[NvShader new];p->sh[0]->fn=[l newFunctionWithName:@"v"];p->sh[1]=[NvShader new];p->sh[1]->stage=1;p->sh[1]->fn=[l newFunctionWithName:i?@"sample":@"red"];if(i){p->sh[1]->rf.nb=1;p->sh[1]->rf.b[0]=(nvn_rbind){.kind=NVN_RB_TEX,.reg=0,.dtt=2};p->sh[1]->ae=[p->sh[1]->fn newArgumentEncoderWithBufferIndex:0];}if(g_tnkeep<256)g_tkeep[g_tnkeep++]=p;serial_put(pg[i].serial,p);} }
|
||||
// 跨提交附件有效性账本单测:每个「周期」是一次提交。A 每周期先清再画(提交末尾没人再碰它)→ 试用期满后不写回。
|
||||
// Unit tests for the cross-submit attachment validity ledger: each "cycle" is one submit. A is cleared then drawn every cycle (nobody touches it again at the end of the submit) → not stored once the trial period is over.
|
||||
static void commit(void) { id<MTLCommandBuffer> cb=g_cb; uint64_t f=mtl_sub_commit(); mtl_wait(f,5000000000ull); (void)cb; }
|
||||
static prog_t t_pg[2];
|
||||
// kind:0 = 清 A、画 A(合规周期);1 = 清 A、画 A、再用 B 采样 A 并读回 B(A 提交内被读 → 照常写回;验证重置后的内容);2 = 不清 A,直接 B 采样 A(读旧内容 = 违规)
|
||||
// kind: 0 = clear A, draw A (compliant cycle); 1 = clear A, draw A, then B samples A and B is read back (A is read within the submit → stored as usual; verifies the contents after reset); 2 = do not clear A, B samples A directly (reading old contents = violation)
|
||||
static tex_t t_mid, t_x; static int t_two; // t_two:A 的通道多挂一张(换一个通道签名 = 换一个键) | t_two: A's pass has one more attachment (a different pass signature = a different key)
|
||||
static void cycle(const tex_t *a, const tex_t *b, int aid, int kind, uint8_t px[256]) {
|
||||
chain c=chain_new();
|
||||
if (kind!=2) { set_rt(&c,a,t_two?&t_x:NULL,0); clear_color(&c,0,0,0,0); if (t_two) clear_color(&c,1,0,0,0); ds_off(&c); bind_prog(&c,&t_pg[0]); blend(&c); draw_cmd(&c);
|
||||
set_rt(&c,&t_mid,NULL,0); clear_color(&c,0,0,0,0); draw_cmd(&c); } /* A 的通道在命令流里结束(下一个 SetRenderTargets),和游戏里一样;最后这个通道在提交结束时才结束(一律写回) | A's pass ends in the command stream (at the next SetRenderTargets), as in the game; this last pass only ends when the submit ends (always stored) */
|
||||
if (kind) { set_rt(&c,b,NULL,0); clear_color(&c,0,0,0,0); ds_off(&c); bind_prog(&c,&t_pg[1]); bind_tex(&c,aid); draw_cmd(&c); }
|
||||
emit(&c,OP_END,NULL,0); state_reset(); memset(&R,0,sizeof R); vis_clear(); g_vis_on=g_vis_counting=0;
|
||||
mtl_sub_begin(); uint64_t hh=(uint64_t)c.p; mtl_sub_index(&hh,1); mtl_exec(c.p);
|
||||
if (kind) readback(b,px); else commit();
|
||||
}
|
||||
int main(void){@autoreleasepool{setvbuf(stdout,NULL,_IONBF,0);setenv("DM_NVN_TBDR","1",1);
|
||||
char path[256]; snprintf(path,sizeof path,"/tmp/t_xv_%d.txt",(int)getpid()); unlink(path); setenv("DM_XV_FILE",path,1);
|
||||
mtl_init(); setup_prog(t_pg); t_mid=tex(8); t_x=tex(8); uint8_t ref[256],px[256]; int dc=0,viol=0,dc0,viol0;
|
||||
// ① 正例:试用期(XV_TRIAL 个合规周期)内照常写回,之后才不写回;被作废后重新清、画,内容与最初一致
|
||||
// ① Positive case: during the trial period (XV_TRIAL compliant cycles) it is stored as usual, and only afterwards is it not stored; after being invalidated it is cleared and drawn again, and the contents match the original
|
||||
{ tex_t a=tex(8),b=tex(8); int aid=view(&a,0);
|
||||
cycle(&a,&b,aid,1,ref);
|
||||
xv_test_counts(&dc0,&viol0);
|
||||
/* 计数按键(格式 / 尺寸 / 通道签名 / 附件序号)累计,同键的别的贴图也会推进试用期——所以断言看 A 自己在账本里的状态 | Counts accumulate per key (format / size / pass signature / attachment index), and other textures with the same key also advance the trial period - so the assertions look at A's own state in the ledger */
|
||||
#define ST(t) (xv_find((t).serial,0,0) ? xv_find((t).serial,0,0)->state : 0)
|
||||
cycle(&a,&b,aid,0,NULL);
|
||||
EXPECT("首个合规周期:A 在试用期(照常写回)",XV_PROBE,(uint64_t)ST(a)); xv_test_counts(&dc,&viol); EXPECT("首个合规周期:不写回次数 0",0,(uint64_t)(dc-dc0));
|
||||
for(int k=0;k<XV_TRIAL+2;k++) cycle(&a,&b,aid,0,NULL);
|
||||
EXPECT("试用期满:A 已作废(不写回)",XV_INVALID,(uint64_t)ST(a)); xv_test_counts(&dc,&viol); EXPECT("试用期满后不写回次数 ≥ 1",1,(uint64_t)(dc-dc0>=1)); EXPECT("合规周期无违规",0,(uint64_t)(viol-viol0));
|
||||
cycle(&a,&b,aid,1,px); xv_test_counts(&dc0,&viol); EXPECT("作废后重置再用:内容与最初逐字节相同",0,(uint64_t)(memcmp(px,ref,256)!=0)); EXPECT("重置再用无违规",0,(uint64_t)(viol-viol0));
|
||||
// ② 违规:先让 A 再次被作废,然后不清就读
|
||||
// ② Violation: first let A be invalidated again, then read without clearing
|
||||
for(int k=0;k<2;k++) cycle(&a,&b,aid,0,NULL);
|
||||
xv_test_counts(&dc0,&viol0); cycle(&a,&b,aid,2,px); xv_test_counts(&dc,&viol); EXPECT("作废后被读:违规 +1",1,(uint64_t)(viol-viol0));
|
||||
for(int k=0;k<XV_TRIAL+3;k++) cycle(&a,&b,aid,0,NULL); EXPECT("违规后该键永久不做(A 不再进账本)",0,(uint64_t)ST(a));
|
||||
FILE *f=fopen(path,"r"); char line[256]; int nl=0; while(f&&fgets(line,sizeof line,f)) nl++; if(f) fclose(f); EXPECT("违规落盘 1 行",1,(uint64_t)nl);
|
||||
int nd=g_xv_ndis; g_xv_init=0; g_xv_ndis=0; xv_init(); EXPECT("重读文件后禁用集合恢复(模拟下次启动)",1,(uint64_t)(g_xv_ndis>=1 && nd>=1)); }
|
||||
// ③ 试用期里见读者:不报红、不落盘、该键不做(不同尺寸 = 不同键)
|
||||
// ③ A reader seen during the trial period: no failure reported, nothing written to disk, that key is not done (different size = different key)
|
||||
{ tex_t a=tex(8),b=tex(8); int aid=view(&a,0); t_two=1;
|
||||
xv_test_counts(&dc0,&viol0); cycle(&a,&b,aid,0,NULL); cycle(&a,&b,aid,2,px); for(int k=0;k<6;k++) cycle(&a,&b,aid,0,NULL);
|
||||
xv_test_counts(&dc,&viol); EXPECT("试用期见读者:不算违规",0,(uint64_t)(viol-viol0)); EXPECT("试用期见读者:A 的键不做(A 不进账本)",0,(uint64_t)ST(a)); }
|
||||
unlink(path); printf("== %d 项,失败 %d ==\n",count,fail); return fail!=0; }}
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "../nvn/nvn_mtl.m"
|
||||
void *front_metal_layer(void) { return NULL; }
|
||||
module_t *module_of(const void *p) { (void)p; return NULL; }
|
||||
module_t g_mod[MAX_MOD]; int g_nmod;
|
||||
void svc_thread_dump(void) {}
|
||||
uint64_t now_ns(void) { return bp_now(); }
|
||||
static int fail, count;
|
||||
#define EXPECT(name, want, got) do { uint64_t w=(want), g=(got); count++; printf("%s 期望 %llu → 真结果 %llu %s\n", name, (unsigned long long)w, (unsigned long long)g, w==g?"✓":"✗"); fail += w != g; } while (0)
|
||||
typedef struct { uint8_t *p; size_t n; } chain;
|
||||
static chain chain_new(void) { chain c={0}; if (posix_memalign((void **)&c.p,getpagesize(),65536)) abort(); memset(c.p,0,65536); mtl_pool_add(c.p,65536); return c; }
|
||||
static void emit(chain *c, unsigned op, const void *a, size_t n) { size_t z=(8+n+7)&~7ull; op_hdr h={op,(uint32_t)z}; memcpy(c->p+c->n,&h,8); if(n) memcpy(c->p+c->n+8,a,n); c->n+=z; }
|
||||
static tex_t tex(unsigned w) { static uint64_t s=9000; tex_t t={.serial=s++}; t.d.width=t.d.height=w; t.d.depth=t.d.samples=1; t.d.levels=2; t.d.target=NVN_TEXTURE_TARGET_2D; t.d.format=NVN_FORMAT_RGBA8; return t; }
|
||||
static int view(const tex_t *t, int lv) { static int id=1200; view_t v={.set_levels=1,.base_level=lv,.nlevels=1}; mtl_reg_tex(id,t,&v); return id++; }
|
||||
static void set_rt(chain *c, const tex_t *a, const tex_t *b, int alv) { p_set_rt r={.n=b?2:1}; r.color[0]=a; r.color[1]=b; for(int i=0;i<r.n;i++){r.has_cview[i]=1;r.cview[i].set_levels=1;r.cview[i].base_level=i?0:alv;r.cview[i].nlevels=1;} emit(c,OP_SET_RT,&r,sizeof r); p_viewports v={.n=1};v.v[0][2]=v.v[0][3]=8;emit(c,OP_VIEWPORTS,&v,sizeof v);p_scissor sc={0,0,8,8};emit(c,OP_SCISSOR,&sc,sizeof sc); }
|
||||
static void clear_color(chain *c, int i, float r, float g, float b) { p_clear_color x={.index=i,.mask=15,.rgba={r,g,b,1}}; emit(c,OP_CLEAR_COLOR,&x,sizeof x); }
|
||||
static void bind_prog(chain *c, prog_t *p) { p_bind_program b={p,3}; emit(c,OP_BIND_PROGRAM,&b,sizeof b); }
|
||||
static void bind_tex(chain *c, int id) { p_bind_handles b={.stage=1,.first=0,.n=1};b.h[0]=id;emit(c,OP_BIND_TEX,&b,sizeof b); }
|
||||
static void draw_cmd(chain *c) { p_draw d={NVN_DRAW_PRIMITIVE_TRIANGLES,0,3}; emit(c,OP_DRAW,&d,sizeof d); }
|
||||
static void blend(chain *c) { color_st col={1,NVN_LOGIC_OP_COPY,NVN_ALPHA_FUNC_ALWAYS}; p_bind_state x={.kind=1};memcpy(x.bytes,&col,sizeof col);emit(c,OP_BIND_STATE,&x,sizeof x); blend_st b={0,NVN_BLEND_FUNC_SRC_ALPHA,NVN_BLEND_FUNC_ONE_MINUS_SRC_ALPHA,NVN_BLEND_FUNC_ONE,NVN_BLEND_FUNC_ZERO,NVN_BLEND_EQUATION_ADD,NVN_BLEND_EQUATION_ADD};x.kind=0;memcpy(x.bytes,&b,sizeof b);emit(c,OP_BIND_STATE,&x,sizeof x); }
|
||||
static void ds_off(chain *c) { ds_st d={0,0,NVN_DEPTH_FUNC_ALWAYS,0,NVN_STENCIL_FUNC_ALWAYS,NVN_STENCIL_FUNC_ALWAYS,NVN_STENCIL_OP_KEEP,NVN_STENCIL_OP_KEEP,NVN_STENCIL_OP_KEEP,NVN_STENCIL_OP_KEEP,NVN_STENCIL_OP_KEEP,NVN_STENCIL_OP_KEEP}; p_bind_state x={.kind=5}; memcpy(x.bytes,&d,sizeof d); emit(c,OP_BIND_STATE,&x,sizeof x); }
|
||||
static void readback(const tex_t *t, uint8_t out[256]) { id<MTLBuffer> b=[g_dev newBufferWithLength:256 options:MTLResourceStorageModeShared]; [blit() copyFromTexture:tex_mtl(t) sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(0,0,0) sourceSize:MTLSizeMake(8,8,1) toBuffer:b destinationOffset:0 destinationBytesPerRow:32 destinationBytesPerImage:256]; uint64_t f=mtl_sub_commit(); EXPECT("提交完成",1,mtl_wait(f,5000000000ull)); EXPECT("提交反馈无错误",0,mtl_last_commit_error()); memcpy(out,b.contents,256); }
|
||||
static NvProg *g_tkeep[256]; static int g_tnkeep; /* 测试里的程序对象常驻:释放后新对象可能落在同一地址,管线缓存按对象地址认会取到旧管线(生产里程序对象不释放) | Program objects in the tests are permanent: after a free, a new object may land at the same address, and the pipeline cache, keyed by object address, would return the old pipeline (in production program objects are never freed) */
|
||||
static void setup_prog(prog_t *pg) { NSError *e=nil; id<MTLLibrary> l=[g_dev newLibraryWithSource:@"#include <metal_stdlib>\nusing namespace metal; vertex float4 v(uint n[[vertex_id]]){float2 p[3]={float2(-1,-1),float2(3,-1),float2(-1,3)};return float4(p[n],0,1);}\nfragment float4 red(){return float4(1,0,0,0.5);}\nstruct A{texture2d<float> t[[id(0)]];}; fragment float4 sample(constant A&a[[buffer(0)]]){return a.t.read(uint2(0));}\n" options:nil error:&e]; if(!l){fprintf(stderr,"%s\n",e.localizedDescription.UTF8String);abort();} for(int i=0;i<2;i++)pg[i].serial=8000+i; for(int i=0;i<2;i++){NvProg *p=[NvProg new];p->sh[0]=[NvShader new];p->sh[0]->fn=[l newFunctionWithName:@"v"];p->sh[1]=[NvShader new];p->sh[1]->stage=1;p->sh[1]->fn=[l newFunctionWithName:i?@"sample":@"red"];if(i){p->sh[1]->rf.nb=1;p->sh[1]->rf.b[0]=(nvn_rbind){.kind=NVN_RB_TEX,.reg=0,.dtt=2};p->sh[1]->ae=[p->sh[1]->fn newArgumentEncoderWithBufferIndex:0];}if(g_tnkeep<256)g_tkeep[g_tnkeep++]=p;serial_put(pg[i].serial,p);} }
|
||||
// 零源跳过单测(生产 mtl_exec + 手写着色器):sample 着色器输出 = 被采样贴图的 (0,0) 纹素——对采样值齐次线性,测试里注入事实表
|
||||
// Zero-source skip unit tests (production mtl_exec + hand-written shaders): the sample shader's output = texel (0,0) of the sampled texture - homogeneous linear in the sampled value; the fact table is injected in the test
|
||||
static void copy_cmd(chain *c, const tex_t *s, const tex_t *d) { p_copy_t2t x={.src=s,.dst=d}; x.sr=(NVNcopyRegion){0,0,0,8,8,1}; x.dr=x.sr; emit(c,OP_COPY_T2T,&x,sizeof x); }
|
||||
// mode:0 正例(A 清 0 → B 清 0 后采样 A);1 传播(A 清 0 → 整张拷 A→C → B 采样 C);2 A 清成非 0;3 A 清 0 后被画过;4 B 的清除值非 0
|
||||
// mode: 0 positive case (A cleared to 0 → B cleared to 0 then samples A); 1 propagation (A cleared to 0 → whole-texture copy A→C → B samples C); 2 A cleared to non-zero; 3 A drawn to after being cleared to 0; 4 B's clear value is non-zero
|
||||
static int run(int mode, int enabled, uint8_t px[256]) {
|
||||
tex_t a=tex(8),b=tex(8),c2=tex(8); int aid=view(&a,0), cid=view(&c2,0); chain c=chain_new(); static prog_t pg[2]; memset(pg,0,sizeof pg); setup_prog(pg);
|
||||
strcpy(g_tkeep[g_tnkeep-1]->sh[1]->key, "feedfacefeedface_b");
|
||||
float av = mode==2 ? 0.5f : 0.0f;
|
||||
set_rt(&c,&a,NULL,0); clear_color(&c,0,av,av,av); c.n -= 0;
|
||||
{ p_clear_color *last=(p_clear_color *)(c.p + c.n - ((8+sizeof(p_clear_color)+7)&~7ull) + 8); last->rgba[3] = av; } /* clear_color 帮手把 alpha 固定成 1:这里改成与 rgb 一致(0 = 全零) | The clear_color helper fixes alpha at 1: here it is changed to match rgb (0 = all zeros) */
|
||||
if (mode==3) { ds_off(&c); bind_prog(&c,&pg[0]); draw_cmd(&c); }
|
||||
if (mode==1) copy_cmd(&c,&a,&c2);
|
||||
float bv = mode==4 ? 0.25f : 0.0f;
|
||||
set_rt(&c,&b,NULL,0); clear_color(&c,0,bv,bv,bv);
|
||||
{ p_clear_color *last=(p_clear_color *)(c.p + c.n - ((8+sizeof(p_clear_color)+7)&~7ull) + 8); last->rgba[3] = bv; }
|
||||
ds_off(&c); bind_prog(&c,&pg[1]); bind_tex(&c,mode==1?cid:aid); draw_cmd(&c); emit(&c,OP_END,NULL,0);
|
||||
state_reset(); memset(&R,0,sizeof R); vis_clear(); g_vis_on=g_vis_counting=0; setenv("DM_NVN_ZSKIP",enabled?"1":"0",1); g_zskip_env=-1;
|
||||
mtl_sub_begin(); uint64_t hh=(uint64_t)c.p; mtl_sub_index(&hh,1); mtl_exec(c.p); int n=zskip_test_count(); readback(&b,px); return n;
|
||||
}
|
||||
int main(void){@autoreleasepool{setvbuf(stdout,NULL,_IONBF,0);setenv("DM_NVN_TBDR","1",1);mtl_init();uint8_t on[256],off[256];
|
||||
run(0,0,off); int n=run(0,1,on); EXPECT("不在事实表:不跳过",0,n); EXPECT("不在事实表:开关逐字节相同",0,(uint64_t)(memcmp(on,off,256)!=0));
|
||||
zskip_test_add("feedfacefeedface",-1,0,0);
|
||||
static const char *nm[5]={"正例(A 清 0)","传播(A 清 0 → 拷到 C)","反例 A 清成非 0","反例 A 清 0 后被画过","反例 B 清除值非 0"}; static const int want[5]={1,1,0,0,0};
|
||||
for(int m=0;m<5;m++){ run(m,0,off); n=run(m,1,on); char t1[96],t2[96]; snprintf(t1,sizeof t1,"%s:跳过次数",nm[m]); snprintf(t2,sizeof t2,"%s:开关逐字节相同",nm[m]);
|
||||
EXPECT(t1,want[m],n); EXPECT(t2,0,(uint64_t)(memcmp(on,off,256)!=0)); if(m==2) EXPECT("反例 A 非 0:B 读回非 0",1,on[0]!=0); if(m==0) EXPECT("正例:B 读回全 0",0,on[0]|on[1]|on[2]|on[3]); }
|
||||
printf("== %d 项,失败 %d ==\n",count,fail); return fail!=0; }}
|
||||
@@ -0,0 +1,87 @@
|
||||
"""预算表导出回归:小日志闭式期望,不需要游戏或 GPU;临时文件只放 run/gfx。 | Budget table export regression: small logs with closed-form expectations, no game or GPU needed; temp files go only under run/gfx."""
|
||||
import csv
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
DM_ROOT = os.environ.get('DM_ROOT') or os.path.expanduser('~/dm-work') # 工作区根目录(游戏文件、产物、运行现场都在它下面) | Workspace root (game files, build outputs and run artifacts are all under it)
|
||||
|
||||
TOOL = Path(os.environ.get('TBDR_BUDGET_TOOL', Path(__file__).resolve().parents[1] / 'tools/tbdr_budget.py'))
|
||||
|
||||
class BudgetExport(unittest.TestCase):
|
||||
def export(self, text):
|
||||
root = Path(DM_ROOT) / 'run/gfx'
|
||||
root.mkdir(parents=True, exist_ok=True)
|
||||
with tempfile.TemporaryDirectory(prefix='budget_test_', dir=root) as tmp:
|
||||
log, out = Path(tmp) / 'pass.log', Path(tmp) / 'pass.tsv'
|
||||
log.write_text(text)
|
||||
p = subprocess.run([sys.executable, str(TOOL), str(log), '700', '170', '--tsv=' + str(out)], capture_output=True, text=True)
|
||||
self.assertEqual(p.returncode, 0, p.stderr)
|
||||
self.assertTrue(out.exists(), '全量通道 TSV 未导出')
|
||||
with out.open() as f:
|
||||
return list(csv.DictReader(f, delimiter='\t'))
|
||||
|
||||
def test_all_passes_not_only_console_top25(self):
|
||||
# 30 个独立 4×4 RGBA8 clear:每个写回 4×4×4=64 字节。
|
||||
# 30 independent 4×4 RGBA8 clears: each stores 4×4×4=64 bytes.
|
||||
rows = self.export(''.join(f'[pass] F700 P {p} c0 ser={p} fmt=70 4x4 ms1 lv0 sl0 clear\n' for p in range(1, 31)))
|
||||
self.assertEqual(len(rows), 30)
|
||||
self.assertEqual([int(x['pass']) for x in rows], list(range(1, 31)))
|
||||
self.assertEqual(sum(int(x['store_bytes']) for x in rows), 1920)
|
||||
self.assertTrue(all(x['draw_source'] == 'clear_only' for x in rows))
|
||||
|
||||
def test_draws_attachment_bytes_and_untruncated_shader_keys(self):
|
||||
key = '0123456789abcdef'
|
||||
rows = self.export(f'''[pass] F700 P 501 c0 ser=1 fmt=70 4x4 ms1 lv0 sl0 load
|
||||
[pass] F700 Z 501 c ser=1 lv0 sl0 dontcare why=0
|
||||
[pass] F700 P 502 c0 ser=2 fmt=70 8x4 ms1 lv0 sl0 clear
|
||||
[pass] F700 K 502 st1 key={key}_b nb=1
|
||||
[pass] F700 B 502 st1 tex reg0 tid=1 实 ser=12 fmt=70 8x4x1
|
||||
[pass] F700 R 502 st1 ser=12
|
||||
[pass] F700 d 502 fs={key}_b vc=3
|
||||
[pass] F700 d 502 fs={key}_b vc=3
|
||||
''')
|
||||
self.assertEqual((rows[0]['load_bytes'], rows[0]['store_bytes']), ('64', '0'))
|
||||
self.assertEqual((rows[1]['draws'], rows[1]['draw_source']), ('2', 'PASSDUMP_ALL'))
|
||||
self.assertEqual(rows[1]['fragment_keys'], key)
|
||||
self.assertEqual(rows[1]['texture_est_bytes'], '128')
|
||||
self.assertEqual(rows[1]['unknown_textures'], '0')
|
||||
|
||||
def test_unknown_texture_metadata_is_reported(self):
|
||||
rows = self.export('''[pass] F700 P 1 c0 ser=1 fmt=70 4x4 ms1 lv0 sl0 clear
|
||||
[pass] F700 R 1 st1 ser=99
|
||||
[pass] F700 d 1 fs=unknown_b vc=3
|
||||
''')
|
||||
self.assertEqual(rows[0]['unknown_textures'], '1')
|
||||
self.assertEqual(rows[0]['texture_est_bytes'], '64')
|
||||
|
||||
def test_texture_views_do_not_leak_between_passes(self):
|
||||
# 两通道均 8×4 输出;同 ser=99 的实际绑定视图分别 8×4、4×4。
|
||||
# RGBA8:独立期望 128 / 64 字节,不能让后通道尺寸覆盖前通道。
|
||||
# Both passes output 8×4; the actual bound views of the same ser=99 are 8×4 and 4×4 respectively.
|
||||
# RGBA8: independent expectations of 128 / 64 bytes; the later pass's size must not overwrite the earlier pass's.
|
||||
rows = self.export('''[pass] F700 P 1 c0 ser=1 fmt=70 8x4 ms1 lv0 sl0 clear
|
||||
[pass] F700 B 1 st1 tex reg0 tid=1 实 ser=99 fmt=70 8x4x1
|
||||
[pass] F700 R 1 st1 ser=99
|
||||
[pass] F700 d 1 fs=unknown_b vc=3
|
||||
[pass] F700 P 2 c0 ser=2 fmt=70 8x4 ms1 lv0 sl0 clear
|
||||
[pass] F700 B 2 st1 tex reg0 tid=2 实 ser=99 fmt=70 4x4x1
|
||||
[pass] F700 R 2 st1 ser=99
|
||||
[pass] F700 d 2 fs=unknown_b vc=3
|
||||
''')
|
||||
self.assertEqual([x['texture_est_bytes'] for x in rows], ['128', '64'])
|
||||
|
||||
def test_distinct_views_within_same_pass_are_kept(self):
|
||||
rows = self.export('''[pass] F700 P 1 c0 ser=1 fmt=70 8x4 ms1 lv0 sl0 clear
|
||||
[pass] F700 B 1 st1 tex reg0 tid=1 实 ser=99 fmt=70 8x4x1
|
||||
[pass] F700 R 1 st1 ser=99
|
||||
[pass] F700 B 1 st1 tex reg1 tid=2 实 ser=99 fmt=70 4x4x1
|
||||
[pass] F700 R 1 st1 ser=99
|
||||
[pass] F700 d 1 fs=unknown_b vc=3
|
||||
''')
|
||||
self.assertEqual(rows[0]['texture_est_bytes'], '192')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,70 @@
|
||||
# dm/gfx/tex — texture format mapping, block-linear deswizzling, BC decompression
|
||||
|
||||
中文:[README.zh-CN.md](README.zh-CN.md)
|
||||
|
||||
The part of the graphics layer that deals with texture data, called by the replay layer `../nvn/nvn_mtl.m`. It does three things:
|
||||
|
||||
1. converts NVN texture format numbers to Metal pixel formats;
|
||||
2. unpacks the Switch's "block-linear" layout into an ordinary row-by-row layout;
|
||||
3. decompresses BC textures on GPUs that do not support BC compressed textures.
|
||||
|
||||
Block linear is how the Tegra X1 GPU stores textures: the data is not one row after another, but interleaved in small blocks of 64 bytes × 8 rows (GOBs), and several GOBs are then stacked into larger blocks according to a "block height" and a "block depth". The game's packaged texture files are in exactly this layout, and it must be undone before uploading to Metal.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Contents |
|
||||
|---|---|
|
||||
| `nvn_fmt_mtl.h`, `nvn_fmt_mtl.c` | `nvn_fmt_to_mtl()`: NVN format (0x01–0x9C) → Metal pixel format + component remapping. Returns 1 for an exact match, 2 for a substitute (precision, bit order or interpretation differs and a conversion is needed), 0 when Metal has no corresponding format. How each format is handled is written in the comments inside the table. Pure C, no dependency on Metal headers |
|
||||
| `nvn_deswizzle.h`, `nvn_deswizzle.c` | `nvn_deswizzle()`: deswizzles one level and one layer from block linear to linear; `nvn_swizzle()`: the reverse, used for round trips in unit tests; `nvn_bl_offset()`: the block-linear address of a single point. Pure C |
|
||||
| `nvn_deswizzle_gpu.h`, `nvn_deswizzle_gpu.m` | A Metal compute shader version of the same deswizzling algorithm, used by the replay layer when uploading packaged textures; when initialization fails or an unsupported format is encountered, the replay layer falls back to the CPU version |
|
||||
| `nvn_bcdec.h`, `nvn_bcdec.c` | `nvn_bc_unpacked()` / `nvn_bc_decode()`: decompress BC textures on the CPU into uncompressed formats; decoding uses `dm/third_party/bcdec` |
|
||||
| `tests/` | Unit tests |
|
||||
|
||||
The offsets of each level and layer within the storage, and the block height and block depth actually used by each level, are all taken from `../nvn/nvn_tex.c` (`nvn_tex_layout`, `nvn_tex_level_offset`, `nvn_tex_level_tiles`); this directory only does addressing and moving within a level. The game's packaged textures carry their own layout parameters, whose byte 0 is the log2 of the level 0 block height; when it is present it takes precedence (the `pkg_block_h` field of `nvn_texdesc`).
|
||||
|
||||
## Devices without BC support
|
||||
|
||||
Some older Apple GPUs do not support BC compressed textures (determined by `supportsBCTextureCompression` of `MTLDevice`). On these devices:
|
||||
|
||||
- the game's textures can be converted to ASTC format offline in advance with an optional supplementary pack (`dm/tools/astc_pack.py`; for dependencies see the "Optional" section of `docs/DEPENDENCIES.md`);
|
||||
- the remaining BC textures are created by the replay layer in their decompressed format and decompressed at upload; decompression on the CPU goes through `nvn_bcdec.c` in this directory.
|
||||
|
||||
The environment variable `DM_TEST_NO_BC=1` forces this path on any machine.
|
||||
|
||||
## Tests
|
||||
|
||||
```sh
|
||||
make -C dm/gfx/tex/tests samples # fetch real-data samples (see below)
|
||||
make -C dm/gfx/tex/tests run # run t_fmt_mtl and t_tex
|
||||
```
|
||||
|
||||
- **`t_fmt_mtl`**: takes the mapping for every NVN format in 0x01–0x9C and, for every one whose mapping is not 0, actually creates a texture on the local Metal device; all of them must be created successfully. It also checks that every NVN format with sRGB in its name lands on a Metal sRGB format. No game files needed.
|
||||
- **`t_tex`**: the deswizzling tests, in several groups:
|
||||
|
||||
| Group | Criterion |
|
||||
|---|---|
|
||||
| A round trip | Writes random data into each level and layer and reads it back out; must be byte-for-byte equal. Covers 2D, 2D array and 3D, several bytes-per-block values and non-power-of-two sizes |
|
||||
| B address formula | The result of `nvn_bl_offset()` equals the address computed by hand from the public layout rules |
|
||||
| E hand-made 3D | Places markers at hand-computed addresses, checks where they land after deswizzling, and checks block height, block depth and storage size |
|
||||
| C real data | The Switch version (block linear) of a texture, after deswizzling, is compared with the PC version (linear) of the same texture: those at the same resolution must be byte-for-byte equal; those whose Switch version was reduced in resolution were recompressed, so the comparison is instead that the PSNR after decoding (peak signal-to-noise ratio, a measure of how alike two images are) is not below 22 dB. It also checks that the per-level offsets in the file agree with `nvn_tex_level_offset` |
|
||||
| D negative control | Deliberately deswizzles with the block height off by one step; the result must no longer be byte-for-byte equal and the PSNR must be below 22 dB, proving that the criterion of group C can tell a wrong layout apart |
|
||||
|
||||
The A round trip can only prove "one-to-one and within bounds"; it cannot prove that the layout formula is right. What really backs it up is the hand-computed addresses of group B and the byte-for-byte equality of the same-resolution samples of group C.
|
||||
|
||||
**About the real-data samples**: groups C and D need one copy each of the Switch version and the PC version of the same texture. `tests/fetch_samples.py` takes samples from the game files in your workspace: the Switch version is read from `$DM_ROOT/data/switch/3.3.94012/Update/RomFS/data`, the PC version from `$DM_ROOT/data/assets-src/raw`, and the output goes to `$DM_ROOT/build/cache/dm/tex_samples`. When there are no samples, the real-data items of `t_tex` count as failed and are not skipped; groups A, B and E need no game files. The samples do not go into the repository.
|
||||
|
||||
## Layout-related fields in the texture file header
|
||||
|
||||
Facts used by `t_tex.c` when parsing the game's `.texture` files:
|
||||
|
||||
- The file begins with `<DE(`; the Switch version and the PC version use the same container.
|
||||
- In files that went through the Switch conversion, the four bytes starting at offset 0x14 are `00 00 00 07` (0 in the PC version), which indicates that the pixel area is in block-linear layout; offset 0x13 is the log2 of the level 0 block height, with the same meaning as byte 0 of the layout parameters the game passes to `SetPackagedTextureLayout` at run time.
|
||||
- Files without this marker are stored linearly and are byte-for-byte identical to the PC version.
|
||||
|
||||
## Limitations
|
||||
|
||||
- `nvn_deswizzle()` does not support multisampled textures, textures with the LINEAR flag (which are linear to begin with) or the BUFFER target; it returns -1 when it encounters them.
|
||||
- Cubes and cube arrays are handled as layered textures and have not been separately checked with real data.
|
||||
- 3D textures have only the round-trip and hand-computed address checks; there are no real-data samples.
|
||||
- The component bit order of the 16-bit packed formats (565 / 5551 / 4444) is mapped according to the format names and has not been checked with real data; they are marked as "substitute" in the format table.
|
||||
- The real-data sample set is small, covering the four formats RGBA8, BC1, BC3 and BC4.
|
||||
@@ -0,0 +1,70 @@
|
||||
# dm/gfx/tex — 贴图格式映射、块线性解排布、BC 解压
|
||||
|
||||
English: [README.md](README.md)
|
||||
|
||||
图形层里和贴图数据打交道的部分,供回放层 `../nvn/nvn_mtl.m` 调用。做三件事:
|
||||
|
||||
1. 把 NVN 的贴图格式号换成 Metal 的像素格式;
|
||||
2. 把 Switch 的「块线性」排布解成普通的逐行排布;
|
||||
3. 在不支持 BC 压缩贴图的显卡上把 BC 贴图解压。
|
||||
|
||||
块线性(block linear)是 Tegra X1 显卡存贴图的方式:数据不是一行接一行,而是按 64 字节 × 8 行的小块(GOB)交错排列,再按「块高」「块深」把若干 GOB 叠成更大的块。游戏打包好的贴图文件里就是这种排布,上传给 Metal 之前必须先解开。
|
||||
|
||||
## 文件
|
||||
|
||||
| 文件 | 内容 |
|
||||
|---|---|
|
||||
| `nvn_fmt_mtl.h`、`nvn_fmt_mtl.c` | `nvn_fmt_to_mtl()`:NVN 格式(0x01–0x9C)→ Metal 像素格式 + 分量重映射。返回 1 表示精确对应,2 表示替代(精度、位序或读法不同,需要转换),0 表示 Metal 没有对应格式。每个格式的处理办法写在表内注释里。纯 C,不依赖 Metal 头文件 |
|
||||
| `nvn_deswizzle.h`、`nvn_deswizzle.c` | `nvn_deswizzle()`:把某一级、某一层从块线性解到线性;`nvn_swizzle()`:反向,单测往返用;`nvn_bl_offset()`:单点的块线性地址。纯 C |
|
||||
| `nvn_deswizzle_gpu.h`、`nvn_deswizzle_gpu.m` | 同一个解排布算法的 Metal 计算着色器版本,回放层上传打包贴图时用;初始化失败或遇到不支持的格式时回放层退回 CPU 版 |
|
||||
| `nvn_bcdec.h`、`nvn_bcdec.c` | `nvn_bc_unpacked()` / `nvn_bc_decode()`:BC 贴图在 CPU 上解压成不压缩格式,解码用 `dm/third_party/bcdec` |
|
||||
| `tests/` | 单元测试 |
|
||||
|
||||
各级、各层在存储里的偏移,以及每一级实际使用的块高、块深,一律取自 `../nvn/nvn_tex.c`(`nvn_tex_layout`、`nvn_tex_level_offset`、`nvn_tex_level_tiles`),这里只做级内的寻址与搬运。游戏的打包贴图自带布局参数,其第 0 字节是第 0 级块高的 log2,有它时以它为准(`nvn_texdesc` 的 `pkg_block_h` 字段)。
|
||||
|
||||
## 不支持 BC 的设备
|
||||
|
||||
一部分较老的苹果显卡不支持 BC 压缩贴图(由 `MTLDevice` 的 `supportsBCTextureCompression` 判断)。在这些设备上:
|
||||
|
||||
- 游戏贴图可以用可选的补充包事先离线换成 ASTC 格式(`dm/tools/astc_pack.py`,依赖见 `docs/DEPENDENCIES.zh-CN.md` 的「可选」一节);
|
||||
- 剩下的 BC 贴图由回放层建成解压后的格式,上传时解压,CPU 上的解压走本目录的 `nvn_bcdec.c`。
|
||||
|
||||
环境变量 `DM_TEST_NO_BC=1` 可以在任何机器上强制走这条路径。
|
||||
|
||||
## 测试
|
||||
|
||||
```sh
|
||||
make -C dm/gfx/tex/tests samples # 取真数据样本(见下)
|
||||
make -C dm/gfx/tex/tests run # 跑 t_fmt_mtl 与 t_tex
|
||||
```
|
||||
|
||||
- **`t_fmt_mtl`**:对 0x01–0x9C 每个 NVN 格式取映射,凡映射不为 0 的,都在本机的 Metal 设备上真建一张贴图,必须全部建成;另核名字带 sRGB 的 NVN 格式都落到 Metal 的 sRGB 格式。不需要游戏文件。
|
||||
- **`t_tex`**:解排布的测试,分几组:
|
||||
|
||||
| 组 | 判据 |
|
||||
|---|---|
|
||||
| A 往返 | 往各级、各层写入随机数据再解出,逐字节相等。覆盖 2D、2D 数组、3D,多种每块字节数与非 2 的幂尺寸 |
|
||||
| B 地址公式 | `nvn_bl_offset()` 的结果与按公开排布规则手算的地址相等 |
|
||||
| E 手工 3D | 在手算地址放标记,解排布后核对落点,并核块高、块深与存储尺寸 |
|
||||
| C 真数据 | 同一张贴图的 Switch 版(块线性)解排布后与 PC 版(线性)比:同分辨率的逐字节相等;Switch 版降了分辨率的是重新压缩过的,改比解码后的 PSNR(峰值信噪比,衡量两张图有多像)不低于 22 dB。同时核文件里的逐级偏移与 `nvn_tex_level_offset` 一致 |
|
||||
| D 负对照 | 故意把块高错一级再解,结果必须不再逐字节相等、PSNR 低于 22 dB,证明 C 组的判据能分辨错误的排布 |
|
||||
|
||||
A 往返只能证明「一一对应、不越界」,证明不了排布公式是对的;真正兜底的是 B 组的手算地址与 C 组同分辨率样本的逐字节相等。
|
||||
|
||||
**关于真数据样本**:C、D 两组需要同一张贴图的 Switch 版与 PC 版各一份。`tests/fetch_samples.py` 从你工作区里的游戏文件取样,Switch 版读 `$DM_ROOT/data/switch/3.3.94012/Update/RomFS/data`,PC 版读 `$DM_ROOT/data/assets-src/raw`,输出到 `$DM_ROOT/build/cache/dm/tex_samples`。没有样本时 `t_tex` 的真数据项算失败,不会跳过;A、B、E 三组不需要游戏文件。样本不进仓库。
|
||||
|
||||
## 贴图文件头里与排布有关的字段
|
||||
|
||||
`t_tex.c` 解析游戏的 `.texture` 文件时用到的事实:
|
||||
|
||||
- 文件以 `<DE(` 开头,Switch 版与 PC 版是同一种容器。
|
||||
- 经过 Switch 转换的文件,偏移 0x14 起的四个字节是 `00 00 00 07`(PC 版为 0),表示像素区是块线性排布;偏移 0x13 是第 0 级块高的 log2,与游戏运行时传给 `SetPackagedTextureLayout` 的布局参数第 0 字节含义相同。
|
||||
- 没有这个标记的文件是线性存放的,与 PC 版逐字节相同。
|
||||
|
||||
## 局限
|
||||
|
||||
- `nvn_deswizzle()` 不支持多重采样贴图、带 LINEAR 标志的贴图(本来就是线性的)和 BUFFER 目标,遇到返回 -1。
|
||||
- 立方体与立方体数组按分层贴图处理,没有单独用真数据核对。
|
||||
- 3D 贴图只有往返与手算地址的核对,没有真数据样本。
|
||||
- 16 位打包格式(565 / 5551 / 4444)的分量位序是按格式名对应的,没有用真数据核过,在格式表里标为「替代」。
|
||||
- 真数据样本集小,覆盖 RGBA8、BC1、BC3、BC4 四种格式。
|
||||
@@ -0,0 +1,58 @@
|
||||
// 见 nvn_bcdec.h。解码用 bcdec(dm/third_party/bcdec,单头文件,MIT / 公有领域)。
|
||||
// See nvn_bcdec.h. Decoding uses bcdec (dm/third_party/bcdec, single header, MIT / public domain).
|
||||
#define BCDEC_IMPLEMENTATION
|
||||
#define BCDEC_BC4BC5_PRECISE // BC4 / BC5 带有符号版本的接口 | interface with signed variants of BC4 / BC5
|
||||
#include "../../third_party/bcdec/bcdec.h"
|
||||
#include "nvn_bcdec.h"
|
||||
#include <string.h>
|
||||
|
||||
enum { R8Unorm = 10, R8Snorm = 12, RG8Unorm = 30, RG8Snorm = 32, RGBA8Unorm = 70, RGBA8Unorm_sRGB = 71, RGBA16Float = 115 };
|
||||
// NVN:0x41 RGB_DXT1、0x42 RGBA_DXT1、0x43 DXT3、0x44 DXT5、0x45–0x48 同上 sRGB、0x49 / 0x4a BC4 无 / 有符号、0x4b / 0x4c BC5、0x4d / 0x4e BC7(sRGB)、0x4f / 0x50 BC6H 有 / 无符号
|
||||
// NVN: 0x41 RGB_DXT1, 0x42 RGBA_DXT1, 0x43 DXT3, 0x44 DXT5, 0x45–0x48 the same in sRGB, 0x49 / 0x4a BC4 unsigned / signed, 0x4b / 0x4c BC5, 0x4d / 0x4e BC7 (sRGB), 0x4f / 0x50 BC6H signed / unsigned
|
||||
int nvn_bc_unpacked(uint32_t f, uint32_t *pf, int *bpp) {
|
||||
switch (f) {
|
||||
case 0x41: case 0x42: case 0x43: case 0x44: case 0x4d: *pf = RGBA8Unorm; *bpp = 4; return 1;
|
||||
case 0x45: case 0x46: case 0x47: case 0x48: case 0x4e: *pf = RGBA8Unorm_sRGB; *bpp = 4; return 1;
|
||||
case 0x49: *pf = R8Unorm; *bpp = 1; return 1;
|
||||
case 0x4a: *pf = R8Snorm; *bpp = 1; return 1;
|
||||
case 0x4b: *pf = RG8Unorm; *bpp = 2; return 1;
|
||||
case 0x4c: *pf = RG8Snorm; *bpp = 2; return 1;
|
||||
case 0x4f: case 0x50: *pf = RGBA16Float; *bpp = 8; return 1;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void block(uint32_t f, const uint8_t *b, uint8_t *o, int op) { // 一块 → 4×4 像素(o 每行 op 字节) | one block → 4×4 pixels (o has op bytes per row)
|
||||
switch (f) {
|
||||
case 0x41: case 0x42: case 0x45: case 0x46: bcdec_bc1(b, o, op); break;
|
||||
case 0x43: case 0x47: bcdec_bc2(b, o, op); break;
|
||||
case 0x44: case 0x48: bcdec_bc3(b, o, op); break;
|
||||
case 0x49: bcdec_bc4(b, o, op, 0); break;
|
||||
case 0x4a: bcdec_bc4(b, o, op, 1); break;
|
||||
case 0x4b: bcdec_bc5(b, o, op, 0); break;
|
||||
case 0x4c: bcdec_bc5(b, o, op, 1); break;
|
||||
case 0x4d: case 0x4e: bcdec_bc7(b, o, op); break;
|
||||
case 0x4f: case 0x50: { // bcdec 出 RGB 半精度,补 alpha = 1.0 | bcdec outputs RGB half-float; add alpha = 1.0
|
||||
uint16_t rgb[16 * 3]; bcdec_bc6h_half(b, rgb, 4 * 3, f == 0x4f);
|
||||
for (int y = 0; y < 4; y++) for (int x = 0; x < 4; x++) {
|
||||
uint16_t *d = (uint16_t *)(o + y * op) + x * 4; const uint16_t *s = rgb + (y * 4 + x) * 3;
|
||||
d[0] = s[0]; d[1] = s[1]; d[2] = s[2]; d[3] = 0x3c00;
|
||||
}
|
||||
break; }
|
||||
}
|
||||
}
|
||||
|
||||
int nvn_bc_decode(uint32_t f, const uint8_t *src, size_t pitch, uint32_t w, uint32_t h, uint8_t *dst, size_t dpitch) {
|
||||
uint32_t pf; int bpp; if (!nvn_bc_unpacked(f, &pf, &bpp)) return -1;
|
||||
int bb = (f == 0x41 || f == 0x42 || f == 0x45 || f == 0x46 || f == 0x49 || f == 0x4a) ? 8 : 16; // 每块字节 | bytes per block
|
||||
uint8_t tmp[4 * 4 * 8];
|
||||
for (uint32_t by = 0; by * 4 < h; by++) for (uint32_t bx = 0; bx * 4 < w; bx++) {
|
||||
const uint8_t *b = src + by * pitch + bx * bb;
|
||||
uint32_t cw = w - bx * 4 < 4 ? w - bx * 4 : 4, ch = h - by * 4 < 4 ? h - by * 4 : 4;
|
||||
uint8_t *o = dst + (size_t)by * 4 * dpitch + (size_t)bx * 4 * bpp;
|
||||
if (cw == 4 && ch == 4) { block(f, b, o, (int)dpitch); continue; }
|
||||
block(f, b, tmp, 4 * bpp); // 边上不满 4×4 的块:先解到临时块再拷需要的部分 | blocks at the edge that are not a full 4×4: decode into a temporary block first, then copy the needed part
|
||||
for (uint32_t y = 0; y < ch; y++) memcpy(o + y * dpitch, tmp + y * 4 * bpp, cw * bpp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// 不支持 BC 压缩格式的显卡(A15 / A16 等,苹果 GPU 族 Apple8 及以下):BC 贴图在 CPU 上解压成不压缩格式。
|
||||
// 游戏贴图里的 BC3 由老机型补充包离线换成 ASTC(dm/tools/astc_pack.py);剩下的 BC(精灵图里的 BC3、少量 BC1 / BC4 / BC5 / BC6H)走这里。
|
||||
// GPUs without BC compressed format support (A15 / A16 etc., Apple GPU family Apple8 and below): BC textures are decompressed on the CPU into uncompressed formats.
|
||||
// BC3 in game textures is converted offline to ASTC by the Legacy Device Pack (dm/tools/astc_pack.py); the remaining BC (BC3 in sprites, a few BC1 / BC4 / BC5 / BC6H) goes through here.
|
||||
#pragma once
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// NVN 格式是 BC → 返回 1,*mtl_pf = 解压后的 Metal 像素格式、*bpp = 解压后每像素字节;不是 BC 返回 0
|
||||
// NVN format is BC → returns 1, *mtl_pf = Metal pixel format after decompression, *bpp = bytes per pixel after decompression; returns 0 if not BC
|
||||
int nvn_bc_unpacked(uint32_t nvn_fmt, uint32_t *mtl_pf, int *bpp);
|
||||
// 解一片 w×h 像素:src 按块行排(每块行 pitch 字节),dst 每像素行 dpitch 字节。成功 0
|
||||
// Decode a w×h pixel region: src is laid out by block rows (pitch bytes per block row), dst has dpitch bytes per pixel row. Returns 0 on success
|
||||
int nvn_bc_decode(uint32_t nvn_fmt, const uint8_t *src, size_t pitch, uint32_t w, uint32_t h, uint8_t *dst, size_t dpitch);
|
||||
@@ -0,0 +1,71 @@
|
||||
// Tegra X1 块线性排布(公开描述见 deko3d / Ryujinx BlockLinearLayout):
|
||||
// GOB = 64 字节 × 8 行 = 512 字节;GOB 内 (x 字节, y 行) 的偏移 =
|
||||
// (x%64/32)·256 + (y%8/2)·64 + (x%32/16)·32 + (y%2)·16 + x%16
|
||||
// 块 = 1 个 GOB 宽 × 2^tileH 个 GOB 高 × 2^tileD 个 GOB 深,块内先排 y 再排 z;块按 x → y → z 行优先铺满本级。
|
||||
// 级 / 层起点与本级实际块高块深取自 nvn_tex.c,这里只做级内寻址与搬运。
|
||||
// Tegra X1 block-linear layout (public descriptions: deko3d / Ryujinx BlockLinearLayout):
|
||||
// GOB = 64 bytes × 8 rows = 512 bytes; offset of (x byte, y row) within a GOB =
|
||||
// (x%64/32)·256 + (y%8/2)·64 + (x%32/16)·32 + (y%2)·16 + x%16
|
||||
// block = 1 GOB wide × 2^tileH GOBs high × 2^tileD GOBs deep, ordered y first then z within a block; blocks fill the level in x → y → z row-major order.
|
||||
// Level / layer start offsets and the actual block height and block depth of this level come from nvn_tex.c; here we only do intra-level addressing and copying.
|
||||
#include "nvn_deswizzle.h"
|
||||
#include <string.h>
|
||||
|
||||
static uint32_t gob_off(uint32_t x, uint32_t y) {
|
||||
return (x % 64 / 32) * 256 + (y % 8 / 2) * 64 + (x % 32 / 16) * 32 + (y % 2) * 16 + x % 16;
|
||||
}
|
||||
|
||||
uint64_t nvn_bl_offset(uint32_t x, uint32_t y, uint32_t z, uint32_t row_bytes, uint32_t rows, unsigned th, unsigned td) {
|
||||
uint32_t bh = 1u << th, bd = 1u << td;
|
||||
uint64_t gobs_x = (row_bytes + 63) / 64, blocks_y = (rows + 8 * bh - 1) / (8 * bh);
|
||||
uint64_t block = 512ull * bh * bd; // 一个块的字节 | bytes in one block
|
||||
return (z / bd) * gobs_x * blocks_y * block // 第几层块(深度方向) | which block layer (along depth)
|
||||
+ (y / (8 * bh)) * gobs_x * block // 第几行块 | which block row
|
||||
+ (x / 64) * block // 第几列块 | which block column
|
||||
+ ((z % bd) * bh + (y % (8 * bh)) / 8) * 512ull // 块内第几个 GOB | which GOB within the block
|
||||
+ gob_off(x, y);
|
||||
}
|
||||
|
||||
static uint32_t mip(uint32_t s, unsigned l) { s >>= l; return s ? s : 1; }
|
||||
|
||||
// 本级几何:块宽字节数、块行数、切片数,以及本级本层在存储里的起点;不支持的贴图返回 -1
|
||||
// Geometry of this level: width-in-blocks byte count, block row count, slice count, and where this level and layer starts in storage; returns -1 for unsupported textures
|
||||
int nvn_deswizzle_geom(const nvn_texdesc *d, unsigned level, unsigned layer,
|
||||
uint32_t *row_bytes, uint32_t *rows, uint32_t *slices, uint64_t *base, unsigned *th, unsigned *td, uint32_t *bpb) {
|
||||
if (d->target == 5 || d->target == 6 || d->target == 10 || (d->flags & 0x10) || d->samples > 1) return -1; // MS / BUFFER / LINEAR
|
||||
int bw, bh; *bpb = (uint32_t)nvn_fmt_bpb(d->format, &bw, &bh);
|
||||
if (!*bpb || level >= (d->levels ? d->levels : 1)) return -1;
|
||||
nvn_texlayout L; nvn_tex_layout(d, &L);
|
||||
if (layer >= L.layers) return -1;
|
||||
int one_d = d->target == 0 || d->target == 3;
|
||||
uint32_t w = mip(d->width, level), h = one_d ? 1 : mip(d->height, level);
|
||||
*slices = d->target == 2 ? mip(d->depth ? d->depth : 1, level) : 1;
|
||||
*row_bytes = (w + bw - 1) / bw * *bpb; *rows = (h + bh - 1) / bh;
|
||||
*base = (uint64_t)layer * L.layer_size + nvn_tex_level_offset(d, level);
|
||||
nvn_tex_level_tiles(d, level, th, td);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int move(const nvn_texdesc *d, unsigned level, unsigned layer, uint8_t *bl, uint8_t *lin, size_t pitch, int to_linear) {
|
||||
uint32_t row_bytes, rows, slices, bpb; uint64_t base; unsigned th, td;
|
||||
if (nvn_deswizzle_geom(d, level, layer, &row_bytes, &rows, &slices, &base, &th, &td, &bpb)) return -1;
|
||||
if (pitch < row_bytes) return -1;
|
||||
bl += base;
|
||||
for (uint32_t z = 0; z < slices; z++)
|
||||
for (uint32_t y = 0; y < rows; y++) {
|
||||
uint8_t *row = lin + ((size_t)z * rows + y) * pitch;
|
||||
for (uint32_t x = 0; x < row_bytes; x += 16) { // 16 字节一段:GOB 内 16 字节连续,且整除所有块宽 | 16-byte segments: 16 bytes are contiguous within a GOB, and 16 divides all block widths
|
||||
uint32_t n = row_bytes - x < 16 ? row_bytes - x : 16;
|
||||
uint8_t *p = bl + nvn_bl_offset(x, y, z, row_bytes, rows, th, td);
|
||||
if (to_linear) memcpy(row + x, p, n); else memcpy(p, row + x, n);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nvn_deswizzle(const nvn_texdesc *d, unsigned level, unsigned layer, const void *src, void *dst, size_t dst_pitch) {
|
||||
return move(d, level, layer, (uint8_t *)src, (uint8_t *)dst, dst_pitch, 1);
|
||||
}
|
||||
int nvn_swizzle(const nvn_texdesc *d, unsigned level, unsigned layer, const void *src, size_t src_pitch, void *dst) {
|
||||
return move(d, level, layer, (uint8_t *)dst, (uint8_t *)src, src_pitch, 0);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Tegra 块线性 ↔ 线性。级 / 层偏移与逐级块高块深一律取 nvn/nvn_tex.c(nvn_tex_level_offset / nvn_tex_layout / nvn_tex_level_tiles)。
|
||||
// Tegra block-linear ↔ linear. Level / layer offsets and per-level block height and block depth always come from nvn/nvn_tex.c (nvn_tex_level_offset / nvn_tex_layout / nvn_tex_level_tiles).
|
||||
#pragma once
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "../nvn/nvn_tex.h"
|
||||
|
||||
// 把第 level 级、第 layer 层(数组 / 立方体的层;非分层贴图取 0)从整张贴图存储 src_storage 解到线性 dst_linear。
|
||||
// dst 按块行排:每行 dst_pitch 字节(≥ 本级块宽 × 每块字节),压缩格式一行 = 一行块。
|
||||
// 3D 贴图:一次解出本级全部深度切片,切片 k 位于 dst_linear + k × dst_pitch × 本级块行数。
|
||||
// 不支持:多重采样、LINEAR 标志(本就线性)、BUFFER;遇到返回 -1,成功返回 0。
|
||||
// Decode level number level, layer number layer (layer of an array / cube; 0 for non-layered textures) from the whole-texture storage src_storage into linear dst_linear.
|
||||
// dst is laid out by block rows: dst_pitch bytes per row (≥ width in blocks of this level × bytes per block); for compressed formats one row = one row of blocks.
|
||||
// 3D textures: all depth slices of this level are decoded at once; slice k is at dst_linear + k × dst_pitch × block row count of this level.
|
||||
// Not supported: multisampling, the LINEAR flag (already linear), BUFFER; returns -1 on these, 0 on success.
|
||||
int nvn_deswizzle(const nvn_texdesc *d, unsigned level, unsigned layer, const void *src_storage, void *dst_linear, size_t dst_pitch);
|
||||
// 反向(单测往返用):线性 src_linear → 写进整张贴图存储 dst_storage 的对应级 / 层
|
||||
// Reverse (for unit test round trips): linear src_linear → written into the corresponding level / layer of the whole-texture storage dst_storage
|
||||
int nvn_swizzle(const nvn_texdesc *d, unsigned level, unsigned layer, const void *src_linear, size_t src_pitch, void *dst_storage);
|
||||
// 单点地址:本级本层内,线性 (x 字节, y 块行, z 切片) → 相对本级本层起点的块线性字节偏移(单测按手算核)
|
||||
// Single-point address: within this level and layer, linear (x byte, y block row, z slice) → block-linear byte offset relative to the start of this level and layer (unit tests verify against hand calculation)
|
||||
uint64_t nvn_bl_offset(uint32_t x, uint32_t y, uint32_t z, uint32_t row_bytes, uint32_t rows, unsigned tileH, unsigned tileD);
|
||||
|
||||
int nvn_deswizzle_geom(const nvn_texdesc *d, unsigned level, unsigned layer,
|
||||
uint32_t *row_bytes, uint32_t *rows, uint32_t *slices,
|
||||
uint64_t *base, unsigned *tileH, unsigned *tileD, uint32_t *bpb);
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#import <Metal/Metal.h>
|
||||
#include "nvn_deswizzle.h"
|
||||
|
||||
int nvn_deswz_gpu_init(id<MTLDevice> dev);
|
||||
int nvn_deswz_gpu_encode(id<MTLComputeCommandEncoder> enc, id<MTLBuffer> src, uint64_t src_off,
|
||||
const nvn_texdesc *d, unsigned level, unsigned layer,
|
||||
id<MTLBuffer> dst, uint64_t dst_off, size_t dst_pitch);
|
||||
int nvn_deswz_gpu_encode_m4(id<MTL4ComputeCommandEncoder> enc, id<MTL4ArgumentTable> table,
|
||||
id<MTLBuffer> params, size_t params_off, id<MTLBuffer> src, uint64_t src_off,
|
||||
const nvn_texdesc *d, unsigned level, unsigned layer,
|
||||
id<MTLBuffer> dst, uint64_t dst_off, size_t dst_pitch);
|
||||
@@ -0,0 +1,73 @@
|
||||
#import "nvn_deswizzle_gpu.h"
|
||||
|
||||
static id<MTLComputePipelineState> g_nvn_deswz_pipeline;
|
||||
|
||||
static const char *const k_nvn_deswz_msl =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct P { ulong src_off, dst_off, base, pitch; uint row_bytes, rows, slices, th, td; };\n"
|
||||
"kernel void deswz(device const uchar *src [[buffer(0)]], device uchar *dst [[buffer(1)]], constant P& p [[buffer(2)]], uint3 id [[thread_position_in_grid]]) {\n"
|
||||
" uint bh = 1u << p.th, bd = 1u << p.td, gobs_x = (p.row_bytes + 63u) >> 6, blocks_y = (p.rows + (8u * bh) - 1u) >> (3u + p.th);\n"
|
||||
" uint tid = id.x & 31u, gob_x = id.x >> 5, gob_y = id.y, z = id.z; uint xseg = ((tid >> 4) << 1) | ((tid >> 1) & 1u), y = (gob_y << 3) | (((tid >> 2) & 3u) << 1) | (tid & 1u), x = (gob_x << 6) | (xseg << 4);\n"
|
||||
" if (x >= p.row_bytes || y >= p.rows || z >= p.slices) return;\n"
|
||||
" uint n = min(16u, p.row_bytes - x); ulong block = 512ul * bh * bd; ulong gob_in_block = ((ulong)(z & (bd - 1u)) << p.th) + (gob_y & (bh - 1u)); ulong so = p.src_off + p.base + ((ulong)(z >> p.td) * gobs_x * blocks_y + (gob_y >> p.th) * gobs_x + gob_x) * block + gob_in_block * 512ul + (ulong)tid * 16ul; ulong doff = p.dst_off + ((ulong)z * p.rows + y) * p.pitch + x;\n"
|
||||
" if (n == 16u && ((so | doff) & 15ul) == 0ul) *(device uint4 *)(dst + doff) = *(device const uint4 *)(src + so);\n"
|
||||
" else for (uint i = 0; i < n; i++) dst[doff + i] = src[so + i];\n"
|
||||
"}\n";
|
||||
|
||||
int nvn_deswz_gpu_init(id<MTLDevice> dev) {
|
||||
if (g_nvn_deswz_pipeline) return 0;
|
||||
if (!dev) return -1;
|
||||
NSError *error = nil;
|
||||
id<MTLLibrary> library = [dev newLibraryWithSource:@(k_nvn_deswz_msl) options:nil error:&error];
|
||||
if (!library) return -1;
|
||||
id<MTLFunction> function = [library newFunctionWithName:@"deswz"];
|
||||
if (!function) return -1;
|
||||
g_nvn_deswz_pipeline = [dev newComputePipelineStateWithFunction:function error:&error];
|
||||
return g_nvn_deswz_pipeline ? 0 : -1;
|
||||
}
|
||||
|
||||
int nvn_deswz_gpu_encode(id<MTLComputeCommandEncoder> enc, id<MTLBuffer> src, uint64_t src_off,
|
||||
const nvn_texdesc *d, unsigned level, unsigned layer,
|
||||
id<MTLBuffer> dst, uint64_t dst_off, size_t dst_pitch) {
|
||||
if (!g_nvn_deswz_pipeline || !enc || !src || !dst || !d) return -1;
|
||||
uint32_t row_bytes, rows, slices, bpb;
|
||||
uint64_t base;
|
||||
unsigned th, td;
|
||||
if (nvn_deswizzle_geom(d, level, layer, &row_bytes, &rows, &slices, &base, &th, &td, &bpb) || dst_pitch < row_bytes) return -1;
|
||||
struct { uint64_t src_off, dst_off, base, pitch; uint32_t row_bytes, rows, slices, th, td; } p = {
|
||||
src_off, dst_off, base, dst_pitch, row_bytes, rows, slices, th, td
|
||||
};
|
||||
[enc setComputePipelineState:g_nvn_deswz_pipeline];
|
||||
[enc setBuffer:src offset:0 atIndex:0];
|
||||
[enc setBuffer:dst offset:0 atIndex:1];
|
||||
[enc setBytes:&p length:sizeof p atIndex:2];
|
||||
NSUInteger gobs_x = (row_bytes + 63u) >> 6;
|
||||
NSUInteger gobs_y = (rows + 7u) >> 3;
|
||||
[enc dispatchThreadgroups:MTLSizeMake(gobs_x, gobs_y, slices) threadsPerThreadgroup:MTLSizeMake(32, 1, 1)];
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nvn_deswz_gpu_encode_m4(id<MTL4ComputeCommandEncoder> enc, id<MTL4ArgumentTable> table,
|
||||
id<MTLBuffer> params, size_t params_off, id<MTLBuffer> src, uint64_t src_off,
|
||||
const nvn_texdesc *d, unsigned level, unsigned layer,
|
||||
id<MTLBuffer> dst, uint64_t dst_off, size_t dst_pitch) {
|
||||
if (!g_nvn_deswz_pipeline || !enc || !table || !params || !src || !dst || !d) return -1;
|
||||
uint32_t row_bytes, rows, slices, bpb;
|
||||
uint64_t base;
|
||||
unsigned th, td;
|
||||
if (nvn_deswizzle_geom(d, level, layer, &row_bytes, &rows, &slices, &base, &th, &td, &bpb) || dst_pitch < row_bytes) return -1;
|
||||
struct { uint64_t src_off, dst_off, base, pitch; uint32_t row_bytes, rows, slices, th, td; } p = {
|
||||
src_off, dst_off, base, dst_pitch, row_bytes, rows, slices, th, td
|
||||
};
|
||||
memcpy((uint8_t *)params.contents + params_off, &p, sizeof p);
|
||||
[enc setArgumentTable:table];
|
||||
[enc setComputePipelineState:g_nvn_deswz_pipeline];
|
||||
[table setAddress:src.gpuAddress atIndex:0];
|
||||
[table setAddress:dst.gpuAddress atIndex:1];
|
||||
[table setAddress:params.gpuAddress + params_off atIndex:2];
|
||||
NSUInteger gobs_x = (row_bytes + 63u) >> 6;
|
||||
NSUInteger gobs_y = (rows + 7u) >> 3;
|
||||
[enc dispatchThreadgroups:MTLSizeMake(gobs_x, gobs_y, slices) threadsPerThreadgroup:MTLSizeMake(32, 1, 1)];
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
// NVNformat(nvn.h 0x01–0x9C)→ Metal。表按 NVN 枚举顺序逐项写,未列的格式(含 0、越界)返回 0。
|
||||
// 分量重映射:RGBX / RGB_DXT1 一类「无 alpha」格式 a 取 1;RGB 系 16 位打包格式交换 r/b;其余恒等。
|
||||
// BC1–7 在 iOS 上需 GPU 支持 BC(MTLDevice.supportsBCTextureCompression,iOS 16.4+;A19 已支持,未在本表核设备能力)。
|
||||
// NVNformat (nvn.h 0x01–0x9C) → Metal. The table is written entry by entry in NVN enum order; unlisted formats (including 0 and out of range) return 0.
|
||||
// Component remapping: "no alpha" formats such as RGBX / RGB_DXT1 read a as 1; RGB-family 16-bit packed formats swap r/b; all others are identity.
|
||||
// BC1–7 on iOS require GPU BC support (MTLDevice.supportsBCTextureCompression, iOS 16.4+; A19 supports it; device capability is not checked in this table).
|
||||
#include "nvn_fmt_mtl.h"
|
||||
|
||||
enum { // MTLPixelFormat
|
||||
R8Unorm = 10, R8Snorm = 12, R8Uint = 13, R8Sint = 14, R16Unorm = 20, R16Snorm = 22, R16Uint = 23, R16Sint = 24, R16Float = 25,
|
||||
RG8Unorm = 30, RG8Snorm = 32, RG8Uint = 33, RG8Sint = 34, B5G6R5Unorm = 40, A1BGR5Unorm = 41, ABGR4Unorm = 42, BGR5A1Unorm = 43,
|
||||
R32Uint = 53, R32Sint = 54, R32Float = 55, RG16Unorm = 60, RG16Snorm = 62, RG16Uint = 63, RG16Sint = 64, RG16Float = 65,
|
||||
RGBA8Unorm = 70, RGBA8Unorm_sRGB = 71, RGBA8Snorm = 72, RGBA8Uint = 73, RGBA8Sint = 74, BGRA8Unorm = 80, BGRA8Unorm_sRGB = 81,
|
||||
RGB10A2Unorm = 90, RGB10A2Uint = 91, RG11B10Float = 92, RGB9E5Float = 93, RG32Uint = 103, RG32Sint = 104, RG32Float = 105,
|
||||
RGBA16Unorm = 110, RGBA16Snorm = 112, RGBA16Uint = 113, RGBA16Sint = 114, RGBA16Float = 115, RGBA32Uint = 123, RGBA32Sint = 124,
|
||||
RGBA32Float = 125, BC1 = 130, BC1_sRGB = 131, BC2 = 132, BC2_sRGB = 133, BC3 = 134, BC3_sRGB = 135, BC4_U = 140, BC4_S = 141,
|
||||
BC5_U = 142, BC5_S = 143, BC6H_S = 150, BC6H_U = 151, BC7 = 152, BC7_sRGB = 153,
|
||||
ASTC_SRGB0 = 186, ASTC_LDR0 = 204, // 4x4 起;7x? 不存在,故 8x5 起跳一号(见 astc_off) | starting at 4x4; 7x? does not exist, so one number is skipped from 8x5 on (see astc_off)
|
||||
Depth16Unorm = 250, Depth32Float = 252, Stencil8 = 253, Depth32Float_Stencil8 = 260,
|
||||
};
|
||||
|
||||
typedef struct { uint16_t mtl; uint8_t kind, noalpha, rb; } ent; // kind 1 精确 2 替代;noalpha:a 取 1;rb:交换 r/b | kind: 1 exact, 2 substitute; noalpha: a reads as 1; rb: swap r/b
|
||||
#define E(m) {m, 1, 0, 0}
|
||||
#define X(m) {m, 1, 1, 0} // 精确,无 alpha | exact, no alpha
|
||||
#define S(m) {m, 2, 0, 0} // 替代 | substitute
|
||||
#define SX(m) {m, 2, 1, 0}
|
||||
#define N {0, 0, 0, 0} // 无对应 | no counterpart
|
||||
#define SR(m) {m, 2, 0, 1} // 替代,交换 r/b | substitute, swap r/b
|
||||
#define SXR(m) {m, 2, 1, 1}
|
||||
|
||||
static const ent T[0x9D] = {
|
||||
[0x01] = E(R8Unorm), E(R8Snorm), E(R8Uint), E(R8Sint),
|
||||
[0x05] = E(R16Float), E(R16Unorm), E(R16Snorm), E(R16Uint), E(R16Sint),
|
||||
[0x0A] = E(R32Float), E(R32Uint), E(R32Sint),
|
||||
[0x0D] = E(RG8Unorm), E(RG8Snorm), E(RG8Uint), E(RG8Sint),
|
||||
[0x11] = E(RG16Float), E(RG16Unorm), E(RG16Snorm), E(RG16Uint), E(RG16Sint),
|
||||
[0x16] = E(RG32Float), E(RG32Uint), E(RG32Sint),
|
||||
// 0x19–0x24 RGB8 / RGB16 / RGB32 三分量:Metal 无 3 分量像素格式 → 返回 0。
|
||||
// 处理:上传时逐像素扩成同类 4 分量(RGBA8 / RGBA16 / RGBA32,a = 1,整数类 a = 1 原值),按 RGBX 采样;
|
||||
// 作缓冲贴图(target BUFFER)时改由着色器按 3 分量手读。
|
||||
// 0x19–0x24 RGB8 / RGB16 / RGB32 three-component: Metal has no 3-component pixel formats → return 0.
|
||||
// Handling: on upload expand per pixel to the 4-component format of the same kind (RGBA8 / RGBA16 / RGBA32, a = 1; for integer kinds a = raw value 1), sampled as RGBX;
|
||||
// when used as a buffer texture (target BUFFER), the shader reads the 3 components manually instead.
|
||||
[0x19] = N, N, N, N, N, N, N, N, N, N, N, N,
|
||||
[0x25] = E(RGBA8Unorm), E(RGBA8Snorm), E(RGBA8Uint), E(RGBA8Sint),
|
||||
[0x29] = E(RGBA16Float), E(RGBA16Unorm), E(RGBA16Snorm), E(RGBA16Uint), E(RGBA16Sint),
|
||||
[0x2E] = E(RGBA32Float), E(RGBA32Uint), E(RGBA32Sint),
|
||||
[0x31] = E(Stencil8), E(Depth16Unorm),
|
||||
// DEPTH24:Apple GPU 无 Depth24(Depth24Unorm_Stencil8 iOS 不可用)→ Depth32Float:作渲染目标精度升级、行为等价;
|
||||
// 标替代只因上传现成 24 位深度数据时需转浮点(渲染目标不涉及)
|
||||
// DEPTH24: Apple GPUs have no Depth24 (Depth24Unorm_Stencil8 is unavailable on iOS) → Depth32Float: as a render target this is a precision upgrade with equivalent behavior;
|
||||
// marked substitute only because uploading existing 24-bit depth data requires conversion to float (render targets are not affected)
|
||||
[0x33] = S(Depth32Float), E(Depth32Float),
|
||||
// DEPTH24_STENCIL8 → Depth32Float_Stencil8(同上:渲染目标精度升级、行为等价;上传数据需转换故标替代);DEPTH32F_STENCIL8 精确
|
||||
// DEPTH24_STENCIL8 → Depth32Float_Stencil8 (as above: precision upgrade as a render target, equivalent behavior; marked substitute because uploaded data needs conversion); DEPTH32F_STENCIL8 is exact
|
||||
[0x35] = S(Depth32Float_Stencil8), E(Depth32Float_Stencil8),
|
||||
[0x37] = X(RGBA8Unorm_sRGB), E(RGBA8Unorm_sRGB),
|
||||
// 16 位打包格式:按名字对应——BGR 系(0x95–0x98)直接对 Metal 同名,RGB 系用同一 Metal 格式并交换 r/b。
|
||||
// NVN 与 Metal 的实际位序未用真数据核 → 全部标替代,首次遇到真贴图时核位序再升精确
|
||||
// 16-bit packed formats: matched by name - the BGR family (0x95–0x98) maps directly to the same-named Metal format, the RGB family uses the same Metal format with r/b swapped.
|
||||
// The actual bit order of NVN vs Metal has not been verified with real data → all marked substitute; verify the bit order when a real texture is first encountered, then upgrade to exact
|
||||
[0x39] = S(ABGR4Unorm), SXR(BGR5A1Unorm), SR(BGR5A1Unorm), SR(B5G6R5Unorm),
|
||||
[0x3D] = E(RGB10A2Unorm), E(RGB10A2Uint), E(RG11B10Float), E(RGB9E5Float),
|
||||
// DXT / RGTC / BPTC = BC1–7;RGB_DXT1 无 alpha
|
||||
// DXT / RGTC / BPTC = BC1–7; RGB_DXT1 has no alpha
|
||||
[0x41] = X(BC1), E(BC1), E(BC2), E(BC3), X(BC1_sRGB), E(BC1_sRGB), E(BC2_sRGB), E(BC3_sRGB),
|
||||
[0x49] = E(BC4_U), E(BC4_S), E(BC5_U), E(BC5_S), E(BC7), E(BC7_sRGB), E(BC6H_S), E(BC6H_U),
|
||||
// *_UI2F / *_I2F:整数存储、按浮点读(不归一化转换)。Metal 无此读法 → 替代为同宽整数格式,着色器按整数采样后转 float;
|
||||
// 3 分量的同 0x19 组处理(返回 0)
|
||||
// *_UI2F / *_I2F: integer storage, read as float (conversion without normalization). Metal has no such read mode → substituted with the same-width integer format; the shader samples as integer and then converts to float;
|
||||
// 3-component ones are handled like the 0x19 group (return 0)
|
||||
[0x51] = S(R8Uint), S(R8Sint), S(R16Uint), S(R16Sint), S(R32Uint), S(R32Sint),
|
||||
[0x57] = S(RG8Uint), S(RG8Sint), S(RG16Uint), S(RG16Sint), S(RG32Uint), S(RG32Sint),
|
||||
[0x5D] = N, N, N, N, N, N,
|
||||
[0x63] = S(RGBA8Uint), S(RGBA8Sint), S(RGBA16Uint), S(RGBA16Sint), S(RGBA32Uint), S(RGBA32Sint),
|
||||
// RGB10A2 有符号 / 有符号整数:Metal 只有 Unorm / Uint → 0;处理:上传时解包到 RGBA16Snorm / RGBA16Sint
|
||||
// RGB10A2_UI2F → RGB10A2Uint 着色器转 float(替代);RGB10A2_I2F → 0(同上解包到 RGBA16Sint)
|
||||
// RGB10A2 signed / signed integer: Metal only has Unorm / Uint → 0; handling: unpack to RGBA16Snorm / RGBA16Sint on upload
|
||||
// RGB10A2_UI2F → RGB10A2Uint with the shader converting to float (substitute); RGB10A2_I2F → 0 (unpacked to RGBA16Sint as above)
|
||||
[0x69] = N, N, S(RGB10A2Uint), N,
|
||||
[0x6D] = X(RGBA8Unorm), X(RGBA8Snorm), X(RGBA8Uint), X(RGBA8Sint),
|
||||
[0x71] = X(RGBA16Float), X(RGBA16Unorm), X(RGBA16Snorm), X(RGBA16Uint), X(RGBA16Sint),
|
||||
[0x76] = X(RGBA32Float), X(RGBA32Uint), X(RGBA32Sint),
|
||||
// 0x79–0x94 ASTC 由 astc_off 计算(LDR / sRGB 两组各 14 种)
|
||||
// 0x79–0x94 ASTC is computed by astc_off (two groups, LDR / sRGB, 14 each)
|
||||
[0x95] = S(B5G6R5Unorm), SX(BGR5A1Unorm), S(BGR5A1Unorm), S(A1BGR5Unorm),
|
||||
[0x99] = X(BGRA8Unorm), E(BGRA8Unorm), X(BGRA8Unorm_sRGB), E(BGRA8Unorm_sRGB),
|
||||
};
|
||||
|
||||
// NVN ASTC 序:4x4 5x4 5x5 6x5 6x6 8x5 8x6 8x8 10x5 10x6 10x8 10x10 12x10 12x12;Metal 在 6x6 与 8x5 之间空一号
|
||||
// NVN ASTC order: 4x4 5x4 5x5 6x5 6x6 8x5 8x6 8x8 10x5 10x6 10x8 10x10 12x10 12x12; Metal skips one number between 6x6 and 8x5
|
||||
static const uint8_t astc_off[14] = {0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14};
|
||||
|
||||
int nvn_fmt_to_mtl(int f, uint32_t *mtl, uint8_t swz[4]) {
|
||||
ent e = {0, 0, 0, 0};
|
||||
if (f >= 0x79 && f <= 0x94) { int k = (f - 0x79) % 14; e = (ent){(uint16_t)((f < 0x87 ? ASTC_LDR0 : ASTC_SRGB0) + astc_off[k]), 1, 0, 0}; }
|
||||
else if (f > 0 && f < (int)(sizeof T / sizeof *T)) e = T[f];
|
||||
if (mtl) *mtl = e.kind ? e.mtl : 0;
|
||||
if (swz) { swz[0] = e.rb ? NVN_SWZ_B : NVN_SWZ_R; swz[1] = NVN_SWZ_G; swz[2] = e.rb ? NVN_SWZ_R : NVN_SWZ_B; swz[3] = e.noalpha ? NVN_SWZ_ONE : NVN_SWZ_A; }
|
||||
return e.kind;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// NVNformat → Metal 像素格式 + 分量重映射。纯 C,不依赖 Metal 头(数值取自 SDK MTLPixelFormat.h / MTLTexture.h,iOS 26.5 SDK)。
|
||||
// NVNformat → Metal pixel format + component remapping. Pure C, no dependency on Metal headers (values taken from the SDK's MTLPixelFormat.h / MTLTexture.h, iOS 26.5 SDK).
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
// MTLTextureSwizzle 数值
|
||||
// MTLTextureSwizzle values
|
||||
enum { NVN_SWZ_ZERO = 0, NVN_SWZ_ONE = 1, NVN_SWZ_R = 2, NVN_SWZ_G = 3, NVN_SWZ_B = 4, NVN_SWZ_A = 5 };
|
||||
|
||||
// 返回:1 = 精确对应(数据原样上传);
|
||||
// 2 = 替代(精度 / 位序 / 读法不同:上传需转换或着色器需改读法,每个格式的办法见 nvn_fmt_mtl.c 表内注释);
|
||||
// 0 = Metal 无对应(*mtl 写 0;处理办法见表内注释,主要是 3 分量格式上传时扩成 4 分量)。
|
||||
// swz 为 r/g/b/a 四个输出分量各取哪个源分量(MTLTextureSwizzleChannels 顺序);可为 NULL。
|
||||
// Returns: 1 = exact match (data uploaded as is);
|
||||
// 2 = substitute (precision / bit order / read mode differs: upload needs conversion or the shader must read differently; per-format handling is in the table comments in nvn_fmt_mtl.c);
|
||||
// 0 = no Metal counterpart (*mtl is set to 0; handling is in the table comments, mainly expanding 3-component formats to 4 components on upload).
|
||||
// swz gives, for each of the four output components r/g/b/a, which source component to take (MTLTextureSwizzleChannels order); may be NULL.
|
||||
int nvn_fmt_to_mtl(int nvn_format, uint32_t *mtl_pixel_format, uint8_t swz[4]);
|
||||
@@ -0,0 +1,3 @@
|
||||
t_tex
|
||||
t_fmt_mtl
|
||||
*.dSYM
|
||||
@@ -0,0 +1,15 @@
|
||||
DM_ROOT ?= $(HOME)/dm-work
|
||||
# 贴图子块单测(秒级):make run。真数据样本 make samples 取到 $(SAMPLES)(构建缓存,不进仓)
|
||||
# Texture sub-module unit tests (seconds): make run. Real-data samples: make samples fetches them into $(SAMPLES) (build cache, not in the repo)
|
||||
SAMPLES ?= $(DM_ROOT)/build/cache/dm/tex_samples
|
||||
PY ?= $(DM_ROOT)/build/cache/dm/venv/bin/python
|
||||
CFLAGS = -O2 -g -Wall -Wextra
|
||||
t_tex: t_tex.c ../nvn_deswizzle.c ../nvn_deswizzle.h ../../nvn/nvn_tex.c ../../nvn/nvn_tex.h
|
||||
clang $(CFLAGS) -o $@ t_tex.c ../nvn_deswizzle.c ../../nvn/nvn_tex.c -lm
|
||||
t_fmt_mtl: t_fmt_mtl.m ../nvn_fmt_mtl.c ../nvn_fmt_mtl.h
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_fmt_mtl.m ../nvn_fmt_mtl.c -framework Metal -framework Foundation
|
||||
samples:
|
||||
$(PY) fetch_samples.py $(SAMPLES)
|
||||
run: t_tex t_fmt_mtl
|
||||
./t_fmt_mtl && ./t_tex $(SAMPLES)
|
||||
.PHONY: samples run
|
||||
@@ -0,0 +1,29 @@
|
||||
# 取真数据对拍样本:Switch 包(RomFS,块线性)与 PC 包(已提取原件,线性)同名 .texture 各一份。
|
||||
# 用法:fetch_samples.py <输出目录> → <输出目录>/{dm,pc}/<序号>.texture + list.tsv(序号 路径 说明)
|
||||
# 选样:覆盖 RGBA8 / BC1 / BC3 / BC4,大小从 32² 到 2048²、含非方形;同分辨率的逐字节比,降分辨率的比解码 PSNR。
|
||||
# Fetch real-data samples for cross-checking: one copy each of the same-named .texture from the Switch package (RomFS, block-linear) and the PC package (extracted originals, linear).
|
||||
# Usage: fetch_samples.py <output dir> → <output dir>/{dm,pc}/<index>.texture + list.tsv (index, path, note)
|
||||
# Sample selection: covers RGBA8 / BC1 / BC3 / BC4, sizes from 32² to 2048², including non-square; same-resolution ones are compared byte for byte, reduced-resolution ones by decoded PSNR.
|
||||
import os, sys
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../../tools'))
|
||||
DM_ROOT = os.environ.get('DM_ROOT') or os.path.expanduser('~/dm-work') # 工作区根目录(游戏文件、产物、运行现场都在它下面) | Workspace root (game files, build outputs and run artifacts are all under it)
|
||||
os.environ.setdefault('DMX_ROOT', os.path.join(DM_ROOT, 'data/switch/3.3.94012/Update/RomFS/data'))
|
||||
import dmx
|
||||
PC = os.path.join(DM_ROOT, 'data/assets-src/raw')
|
||||
SAMPLES = [
|
||||
('hd/vfx/textures/gradient/T_FX_perlin_wipe_03.texture', 'RGBA8 256² 同分辨率'),
|
||||
('hd/vfx/textures/gradient/T_FX_portal_gradient.texture', 'RGBA8 256×16 非方形 同分辨率'),
|
||||
('hd/env/texture/terrain/path/066_PATH.texture', 'BC4 32² 同分辨率'),
|
||||
('hd/debug/wasted_mip_size_2048.texture', 'BC3 sRGB 2048² 12 级 同分辨率'),
|
||||
('hd/items/armor/armor/plate_mail/textures/armor_plate_mail_alb.texture', 'BC3 sRGB 256²(PC 1024²)降分辨率'),
|
||||
('hd/env/texture/global/flow/act4/lava/lava_lavaNS_FLOW.texture', 'BC1 64²(PC 256²)降分辨率'),
|
||||
('hd/character/enemy/fingermage1/Textures/fingermage_KTINT.texture', 'BC3 256²(PC 1024²)降分辨率'),
|
||||
]
|
||||
out = sys.argv[1]
|
||||
os.makedirs(f'{out}/dm', exist_ok=True); os.makedirs(f'{out}/pc', exist_ok=True)
|
||||
with open(f'{out}/list.tsv', 'w') as f:
|
||||
for i, (p, why) in enumerate(SAMPLES):
|
||||
open(f'{out}/dm/{i}.texture', 'wb').write(dmx.get('data:data/' + p))
|
||||
open(f'{out}/pc/{i}.texture', 'wb').write(open(os.path.join(PC, p), 'rb').read())
|
||||
f.write(f'{i}\t{p}\t{why}\n')
|
||||
print(len(SAMPLES), '对样本 →', out)
|
||||
@@ -0,0 +1,35 @@
|
||||
// 格式表实建核对:对 0x01–0x9C 每个 NVN 格式取映射,用本机 MTLDevice 真建一张 2D 贴图(带分量重映射),统计能建成的条数。
|
||||
// 判据:映射非 0 的格式全部建成(newTextureWithDescriptor 非 nil);另核 sRGB 名的 NVN 格式全部落到 Metal _sRGB 格式。
|
||||
// Format table verification by actual creation: for every NVN format 0x01–0x9C take the mapping and actually create a 2D texture (with component remapping) on the local MTLDevice, counting how many can be created.
|
||||
// Criterion: every format with a non-zero mapping is created (newTextureWithDescriptor non-nil); also verify that every NVN format with sRGB in its name lands on a Metal _sRGB format.
|
||||
#import <Metal/Metal.h>
|
||||
#include <stdio.h>
|
||||
#include "../nvn_fmt_mtl.h"
|
||||
int main(void) {
|
||||
@autoreleasepool {
|
||||
id<MTLDevice> dev = MTLCreateSystemDefaultDevice();
|
||||
printf("设备 %s\n", dev.name.UTF8String);
|
||||
int mapped = 0, ok = 0, exact = 0, sub = 0, none = 0, bad_srgb = 0;
|
||||
static const int srgb[] = {0x37, 0x38, 0x45, 0x46, 0x47, 0x48, 0x4E, 0x9B, 0x9C};
|
||||
for (int f = 0x01; f <= 0x9C; f++) {
|
||||
uint32_t m; uint8_t s[4]; int k = nvn_fmt_to_mtl(f, &m, s);
|
||||
if (!k) { none++; continue; }
|
||||
mapped++; k == 1 ? exact++ : sub++;
|
||||
MTLTextureDescriptor *d = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:(MTLPixelFormat)m width:120 height:120 mipmapped:NO];
|
||||
d.swizzle = MTLTextureSwizzleChannelsMake(s[0], s[1], s[2], s[3]);
|
||||
BOOL depth = m >= 250 && m <= 262;
|
||||
d.storageMode = depth ? MTLStorageModePrivate : MTLStorageModeShared;
|
||||
d.usage = MTLTextureUsageShaderRead | (depth ? MTLTextureUsageRenderTarget : 0);
|
||||
if (depth) d.swizzle = MTLTextureSwizzleChannelsDefault; // 深度格式不允许重映射 | remapping is not allowed for depth formats
|
||||
id<MTLTexture> t = [dev newTextureWithDescriptor:d];
|
||||
if (t) ok++; else printf("建不成 NVN %#x → MTL %u\n", f, m);
|
||||
}
|
||||
for (unsigned i = 0; i < sizeof srgb / sizeof *srgb; i++) {
|
||||
uint32_t m; nvn_fmt_to_mtl(srgb[i], &m, NULL);
|
||||
if (!(m == 71 || m == 81 || m == 131 || m == 133 || m == 135 || m == 153)) { printf("sRGB 未落到 _sRGB:%#x → %u\n", srgb[i], m); bad_srgb++; }
|
||||
}
|
||||
for (int f = 0x87; f <= 0x94; f++) { uint32_t m; nvn_fmt_to_mtl(f, &m, NULL); if (m < 186 || m > 200) { printf("ASTC sRGB 未落到 _sRGB:%#x → %u\n", f, m); bad_srgb++; } }
|
||||
printf("映射非 0:%d(精确 %d、替代 %d),无对应 %d,共 %d;实建成 %d/%d;sRGB 违例 %d\n", mapped, exact, sub, none, 0x9C, ok, mapped, bad_srgb);
|
||||
return (ok == mapped && !bad_srgb) ? 0 : 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
// 块线性解排布单测(秒级)。A 往返;B 手算地址;C 真数据对拍(Switch 块线性 vs PC 线性,含逐级偏移核对);D 错块高负对照。
|
||||
// 用法:t_tex <样本目录>(fetch_samples.py 产出)。样本缺失算红,不跳过。
|
||||
// Block-linear deswizzle unit tests (seconds). A round trip; B hand-calculated addresses; C real-data cross-check (Switch block-linear vs PC linear, including per-level offset verification); D wrong-block-height negative control.
|
||||
// Usage: t_tex <sample dir> (produced by fetch_samples.py). Missing samples count as red, not skipped.
|
||||
#include "../nvn_deswizzle.h"
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static int checks, fails;
|
||||
#define CHECK(c, ...) do { checks++; if (!(c)) { fails++; printf(" ✗ "); printf(__VA_ARGS__); printf("\n"); } } while (0)
|
||||
static uint32_t mipd(uint32_t s, unsigned l) { s >>= l; return s ? s : 1; }
|
||||
static uint64_t rng = 0x9E3779B97F4A7C15ull;
|
||||
static uint8_t rnd(void) { rng ^= rng << 13; rng ^= rng >> 7; rng ^= rng << 17; return (uint8_t)rng; }
|
||||
|
||||
// 本级线性尺寸(测试侧独立算:块宽字节、块行、切片)
|
||||
// Linear size of this level (computed independently on the test side: width-in-blocks bytes, block rows, slices)
|
||||
static void dims(const nvn_texdesc *d, unsigned l, uint32_t *rb, uint32_t *rows, uint32_t *sl) {
|
||||
int bw, bh, bpb = nvn_fmt_bpb(d->format, &bw, &bh);
|
||||
*rb = (mipd(d->width, l) + bw - 1) / bw * bpb; *rows = (mipd(d->height, l) + bh - 1) / bh;
|
||||
*sl = d->target == 2 ? mipd(d->depth, l) : 1;
|
||||
}
|
||||
|
||||
// ---------- A 往返:全部级 / 层先各写入不同随机数据,再全部解出比对(级间、层间重叠或越界都会红)----------
|
||||
// ---------- A round trip: first write different random data into every level / layer, then decode them all and compare (overlap between levels or between layers, or out-of-bounds, all fail) ----------
|
||||
static void roundtrip(const char *tag, int target, int fmt, uint32_t w, uint32_t h, uint32_t depth, uint32_t levels) {
|
||||
nvn_texdesc d = {target, fmt, 0, 0, w, h, depth, levels, 0};
|
||||
nvn_texlayout L; nvn_tex_layout(&d, &L);
|
||||
size_t guard = 4096; uint8_t *st = malloc(L.size + guard); memset(st, 0, L.size); memset(st + L.size, 0xAB, guard);
|
||||
uint8_t *ref[64][16] = {{0}}; uint64_t bytes = 0;
|
||||
for (unsigned y = 0; y < L.layers; y++) for (unsigned l = 0; l < levels; l++) {
|
||||
uint32_t rb, rows, sl; dims(&d, l, &rb, &rows, &sl);
|
||||
size_t n = (size_t)rb * rows * sl; ref[y][l] = malloc(n); for (size_t i = 0; i < n; i++) ref[y][l][i] = rnd();
|
||||
CHECK(!nvn_swizzle(&d, l, y, ref[y][l], rb, st), "%s 写入失败 层%u 级%u", tag, y, l);
|
||||
}
|
||||
int guard_ok = 1; for (size_t i = 0; i < guard; i++) guard_ok &= st[L.size + i] == 0xAB;
|
||||
CHECK(guard_ok, "%s 写出存储末尾(越界)", tag);
|
||||
int ok = 1;
|
||||
for (unsigned y = 0; y < L.layers; y++) for (unsigned l = 0; l < levels; l++) {
|
||||
uint32_t rb, rows, sl; dims(&d, l, &rb, &rows, &sl);
|
||||
size_t n = (size_t)rb * rows * sl; uint8_t *out = malloc(n);
|
||||
CHECK(!nvn_deswizzle(&d, l, y, st, out, rb), "%s 解出失败", tag);
|
||||
if (memcmp(out, ref[y][l], n)) { ok = 0; printf(" ✗ %s 层%u 级%u 往返不等\n", tag, y, l); }
|
||||
bytes += n; free(out); free(ref[y][l]);
|
||||
}
|
||||
checks++; if (!ok) fails++;
|
||||
printf(" A %-34s 层%u × 级%u,往返 %llu 字节 %s\n", tag, L.layers, levels, (unsigned long long)bytes, ok ? "全等" : "不等");
|
||||
free(st);
|
||||
}
|
||||
|
||||
// ---------- 真数据 ----------
|
||||
// ---------- Real data ----------
|
||||
static uint8_t *slurp(const char *p, size_t *n) {
|
||||
FILE *f = fopen(p, "rb"); if (!f) return NULL;
|
||||
fseek(f, 0, SEEK_END); *n = (size_t)ftell(f); fseek(f, 0, SEEK_SET);
|
||||
uint8_t *b = malloc(*n); if (fread(b, 1, *n, f) != *n) { free(b); b = NULL; } fclose(f); return b;
|
||||
}
|
||||
// Switch 转换过的文件:0x14 四字节 = 00 00 00 07(PC 为 0),0x13 = 第 0 级块高 log2(与游戏 SetPackagedTextureLayout 第 0 字节同义)。
|
||||
// 未转换的(如 hd/debug 下的)与 PC 文件逐字节相同、线性存放。
|
||||
// Files converted for Switch: the four bytes at 0x14 = 00 00 00 07 (0 on PC), 0x13 = log2 of the level-0 block height (same meaning as byte 0 of the game's SetPackagedTextureLayout).
|
||||
// Unconverted ones (e.g. those under hd/debug) are byte-identical to the PC files and stored linearly.
|
||||
typedef struct { int code, nvn, bl, th_hdr; uint32_t w, h, mips, hdr; uint32_t size[16]; uint64_t off[16]; const uint8_t *px; } tex_t;
|
||||
static int d2r_nvn(int code) { // D2R .texture 格式码 → NVNformat | D2R .texture format code → NVNformat
|
||||
switch (code) { case 0x1F: return 0x25; case 0x39: return 0x42; case 0x3A: return 0x46; case 0x3D: return 0x44;
|
||||
case 0x3E: return 0x48; case 0x3F: return 0x49; case 0x41: return 0x4B; }
|
||||
return 0;
|
||||
}
|
||||
static int parse(const uint8_t *b, size_t n, tex_t *t) {
|
||||
if (n < 0x24 || memcmp(b, "<DE(", 4)) return -1;
|
||||
t->code = b[4]; t->nvn = d2r_nvn(t->code); t->bl = b[0x14] == 0 && b[0x15] == 0 && b[0x16] == 0 && b[0x17] == 7; t->th_hdr = b[0x13];
|
||||
memcpy(&t->w, b + 8, 4); memcpy(&t->h, b + 12, 4); memcpy(&t->mips, b + 0x1C, 4);
|
||||
if (!t->nvn || t->mips == 0 || t->mips > 16) return -1;
|
||||
t->hdr = 36 + 8 * t->mips; uint64_t o = 0;
|
||||
for (unsigned i = 0; i < t->mips; i++) { memcpy(&t->size[i], b + 0x24 + 8 * i, 4); t->off[i] = o; o += t->size[i]; }
|
||||
if (t->hdr + o != n) return -1;
|
||||
t->px = b + t->hdr; return 0;
|
||||
}
|
||||
|
||||
// 解码成 8 位 RGB(BC1 / BC3 取颜色块,BC4 取单通道铺三份,RGBA8 取 RGB)。行 = 块行,按 4×4 展开
|
||||
// Decode to 8-bit RGB (BC1 / BC3 take the color block, BC4 takes the single channel replicated three times, RGBA8 takes RGB). Row = block row, expanded as 4×4
|
||||
static void bc1(const uint8_t *b, uint8_t out[16][3]) {
|
||||
unsigned c0 = b[0] | b[1] << 8, c1 = b[2] | b[3] << 8; uint32_t bits = b[4] | b[5] << 8 | b[6] << 16 | (uint32_t)b[7] << 24;
|
||||
int p[4][3];
|
||||
for (int k = 0; k < 2; k++) { unsigned c = k ? c1 : c0; p[k][0] = (c >> 11 & 31) * 255 / 31; p[k][1] = (c >> 5 & 63) * 255 / 63; p[k][2] = (c & 31) * 255 / 31; }
|
||||
for (int j = 0; j < 3; j++) {
|
||||
if (c0 > c1) { p[2][j] = (2 * p[0][j] + p[1][j]) / 3; p[3][j] = (p[0][j] + 2 * p[1][j]) / 3; }
|
||||
else { p[2][j] = (p[0][j] + p[1][j]) / 2; p[3][j] = 0; }
|
||||
}
|
||||
for (int i = 0; i < 16; i++) for (int j = 0; j < 3; j++) out[i][j] = (uint8_t)p[bits >> (2 * i) & 3][j];
|
||||
}
|
||||
static void bc4(const uint8_t *b, uint8_t out[16][3]) {
|
||||
int a0 = b[0], a1 = b[1], v[8] = {a0, a1};
|
||||
for (int k = 2; k < 8; k++) v[k] = a0 > a1 ? ((8 - k) * a0 + (k - 1) * a1) / 7 : k < 6 ? ((6 - k) * a0 + (k - 1) * a1) / 5 : (k == 6 ? 0 : 255);
|
||||
uint64_t bits = 0; for (int k = 0; k < 6; k++) bits |= (uint64_t)b[2 + k] << (8 * k);
|
||||
for (int i = 0; i < 16; i++) out[i][0] = out[i][1] = out[i][2] = (uint8_t)v[bits >> (3 * i) & 7];
|
||||
}
|
||||
static uint8_t *decode(int nvn, const uint8_t *lin, uint32_t w, uint32_t h) { // → w×h×3
|
||||
uint8_t *img = calloc((size_t)w * h, 3);
|
||||
if (nvn == 0x25) { for (size_t i = 0; i < (size_t)w * h; i++) memcpy(img + 3 * i, lin + 4 * i, 3); return img; }
|
||||
uint32_t bwn = (w + 3) / 4, bhn = (h + 3) / 4, bpb = (nvn == 0x42 || nvn == 0x46 || nvn == 0x49) ? 8 : 16;
|
||||
for (uint32_t by = 0; by < bhn; by++) for (uint32_t bx = 0; bx < bwn; bx++) {
|
||||
const uint8_t *b = lin + ((size_t)by * bwn + bx) * bpb; uint8_t px[16][3];
|
||||
if (nvn == 0x49) bc4(b, px); else bc1(bpb == 16 ? b + 8 : b, px);
|
||||
for (int i = 0; i < 16; i++) { uint32_t x = bx * 4 + i % 4, y = by * 4 + i / 4; if (x < w && y < h) memcpy(img + 3 * ((size_t)y * w + x), px[i], 3); }
|
||||
}
|
||||
return img;
|
||||
}
|
||||
static double psnr(const uint8_t *a, const uint8_t *b, size_t n) {
|
||||
double e = 0; for (size_t i = 0; i < n; i++) { double d = (double)a[i] - b[i]; e += d * d; }
|
||||
return e == 0 ? 99 : 10 * log10(255.0 * 255.0 / (e / n));
|
||||
}
|
||||
// 用指定块高解一级(负对照用;越过存储的地址按 0 读)
|
||||
// Decode one level with a specified block height (for the negative control; addresses beyond the storage read as 0)
|
||||
static void deswz_tile(const uint8_t *st, uint64_t st_size, uint64_t base, uint32_t rb, uint32_t rows, unsigned th, uint8_t *out) {
|
||||
for (uint32_t y = 0; y < rows; y++) for (uint32_t x = 0; x < rb; x++) {
|
||||
uint64_t a = base + nvn_bl_offset(x, y, 0, rb, rows, th, 0);
|
||||
out[(size_t)y * rb + x] = a < st_size ? st[a] : 0;
|
||||
}
|
||||
}
|
||||
|
||||
// 判据阈值:正确块高须 ≥、错块高须 < 此值。实测:正确 28.45–38.90 dB(降分辨率重压缩的 3 张;同分辨率的逐字节全等),
|
||||
// 错一级块高 6.94–16.64 dB ⇒ 取两侧中点 22 dB,两边各留约 6 dB
|
||||
// Criterion threshold: the correct block height must be ≥ this value and a wrong block height must be < it. Measured: correct 28.45–38.90 dB (the 3 reduced-resolution recompressed ones; same-resolution ones are byte-identical),
|
||||
// block height off by one step 6.94–16.64 dB ⇒ take the midpoint of the two sides, 22 dB, leaving about 6 dB on each side
|
||||
#define PSNR_PASS 22.0
|
||||
|
||||
static void real_pair(const char *dir, int i, const char *why) {
|
||||
char p[1024]; size_t ns, np;
|
||||
snprintf(p, sizeof p, "%s/dm/%d.texture", dir, i); uint8_t *sb = slurp(p, &ns);
|
||||
snprintf(p, sizeof p, "%s/pc/%d.texture", dir, i); uint8_t *pb = slurp(p, &np);
|
||||
tex_t s, c;
|
||||
CHECK(sb && pb && !parse(sb, ns, &s) && !parse(pb, np, &c), "样本 %d 读取 / 解析失败(%s)", i, why);
|
||||
if (!sb || !pb || parse(sb, ns, &s) || parse(pb, np, &c)) return;
|
||||
if (!s.bl) { // 未经 Switch 转换:线性,应与 PC 原件逐字节相同 | not converted for Switch: linear, should be byte-identical to the PC original
|
||||
CHECK(ns == np && !memcmp(sb, pb, ns), "样本%d 无块线性标记但与 PC 原件不同", i);
|
||||
printf(" C %d %-30s 无 Switch 块线性标记(0x14 = 0)→ 线性存放,与 PC 原件 %s(%zu 字节)\n", i, why, ns == np && !memcmp(sb, pb, ns) ? "逐字节全等" : "不等", ns);
|
||||
free(sb); free(pb); return;
|
||||
}
|
||||
nvn_texdesc d = {1, s.nvn, 0, 0, s.w, s.h, 1, s.mips, 0, s.th_hdr + 1}; // 块高以文件头为准(同游戏传入的预排布参数) | block height follows the file header (same as the packaged layout parameters the game passes in)
|
||||
unsigned th_auto, td_auto; { nvn_texdesc a = d; a.pkg_block_h = 0; nvn_tex_level_tiles(&a, 0, &th_auto, &td_auto); }
|
||||
// ③ 文件里的逐级偏移(mip 表累加)对 nvn_tex_level_offset
|
||||
// ③ Per-level offsets in the file (cumulative mip table) vs nvn_tex_level_offset
|
||||
int off_ok = 1;
|
||||
for (unsigned l = 0; l < s.mips; l++)
|
||||
if (s.off[l] != nvn_tex_level_offset(&d, l)) { off_ok = 0; printf(" ✗ 样本%d 级%u 文件偏移 %llu ≠ nvn_tex %llu\n", i, l, (unsigned long long)s.off[l], (unsigned long long)nvn_tex_level_offset(&d, l)); }
|
||||
nvn_texlayout L; nvn_tex_layout(&d, &L);
|
||||
uint64_t file_total = s.off[s.mips - 1] + s.size[s.mips - 1];
|
||||
checks++; if (!off_ok) fails++;
|
||||
CHECK(file_total == L.size, "样本%d 文件像素区 %llu ≠ nvn_tex 总尺寸 %llu", i, (unsigned long long)file_total, (unsigned long long)L.size);
|
||||
// 对应 PC 级:PC 边长 = Switch × 2^k
|
||||
// Corresponding PC level: PC side length = Switch × 2^k
|
||||
unsigned k = 0; while ((s.w << k) < c.w) k++;
|
||||
if ((s.w << k) != c.w || (s.h << k) != c.h) { CHECK(0, "样本%d 尺寸比非 2 的幂", i); return; }
|
||||
unsigned nl = s.mips < c.mips - k ? s.mips : c.mips - k;
|
||||
uint64_t eq = 0, tot = 0; double ps = 0, ps_bad = 99; unsigned th0, td0;
|
||||
nvn_tex_level_tiles(&d, 0, &th0, &td0);
|
||||
for (unsigned l = 0; l < nl; l++) {
|
||||
uint32_t rb, rows, sl; dims(&d, l, &rb, &rows, &sl);
|
||||
uint8_t *lin = malloc((size_t)rb * rows);
|
||||
CHECK(!nvn_deswizzle(&d, l, 0, s.px, lin, rb), "样本%d 级%u 解排布失败", i, l);
|
||||
const uint8_t *pcl = c.px + c.off[l + k];
|
||||
CHECK(c.size[l + k] >= (uint64_t)rb * rows, "样本%d 级%u PC 级尺寸不足", i, l);
|
||||
if (!k) { for (size_t j = 0; j < (size_t)rb * rows; j++) eq += lin[j] == pcl[j]; tot += (uint64_t)rb * rows; }
|
||||
if (l == 0) {
|
||||
uint32_t w = s.w, h = s.h;
|
||||
uint8_t *a = decode(s.nvn, lin, w, h), *b = decode(c.nvn, pcl, w, h); ps = psnr(a, b, (size_t)w * h * 3);
|
||||
for (int dt = -1; dt <= 1; dt += 2) { // D:块高错一级(只有 1 个 GOB 高时块高不影响排布,不适用) | D: block height off by one step (when only 1 GOB high, block height does not affect the layout; not applicable)
|
||||
if ((int)th0 + dt < 0 || rows <= 8) continue;
|
||||
uint8_t *bad = malloc((size_t)rb * rows); deswz_tile(s.px, ns - s.hdr, 0, rb, rows, th0 + dt, bad);
|
||||
uint8_t *e = decode(s.nvn, bad, w, h); double q = psnr(e, b, (size_t)w * h * 3); if (q < ps_bad) ps_bad = q;
|
||||
if (!k) CHECK(memcmp(bad, pcl, (size_t)rb * rows), "样本%d 块高 %+d 仍逐字节相等(负对照失效)", i, dt);
|
||||
free(bad); free(e);
|
||||
}
|
||||
free(a); free(b);
|
||||
}
|
||||
free(lin);
|
||||
}
|
||||
if (!k) CHECK(eq == tot, "样本%d 逐字节 %llu/%llu", i, (unsigned long long)eq, (unsigned long long)tot);
|
||||
CHECK(ps >= PSNR_PASS, "样本%d 正确块高 PSNR %.2f < %.0f", i, ps, PSNR_PASS);
|
||||
uint32_t rows0 = (s.h + 3) / 4; if (s.nvn == 0x25) rows0 = s.h;
|
||||
if (rows0 > 8) CHECK(ps_bad < PSNR_PASS, "样本%d 错块高 PSNR %.2f ≥ %.0f(负对照失效)", i, ps_bad, PSNR_PASS);
|
||||
char neg[48]; if (rows0 > 8) snprintf(neg, sizeof neg, "%.2f", ps_bad); else snprintf(neg, sizeof neg, "不适用(1 个 GOB 高)");
|
||||
printf(" C %d %-30s %4u×%-4u→PC 级%u 头块高 %d(自动 %u)偏移%s %s PSNR 正确 %.2f / 错块高 %s dB\n", i, why, s.w, s.h, k,
|
||||
s.th_hdr, th_auto, off_ok ? "✓" : "✗", k ? "(降分辨率,不比字节)" : (eq == tot ? "逐字节全等" : "逐字节不等"), ps, neg);
|
||||
if (!k) printf(" 逐字节 %llu/%llu\n", (unsigned long long)eq, (unsigned long long)tot);
|
||||
free(sb); free(pb);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
printf("A 往返(随机数据,非 2 的幂尺寸)\n");
|
||||
roundtrip("2D 100×37 R8 4 级", 1, 0x01, 100, 37, 1, 4);
|
||||
roundtrip("2D 100×37 RG8 4 级", 1, 0x0D, 100, 37, 1, 4);
|
||||
roundtrip("2D 100×37 RGBA8 4 级", 1, 0x25, 100, 37, 1, 4);
|
||||
roundtrip("2D 100×37 RGBA16F 4 级", 1, 0x29, 100, 37, 1, 4);
|
||||
roundtrip("2D 100×37 RGBA32F 4 级", 1, 0x2E, 100, 37, 1, 4);
|
||||
roundtrip("2D 100×37 BC3(16B/块) 4 级", 1, 0x44, 100, 37, 1, 4);
|
||||
roundtrip("2D 300×300 BC1(8B/块) 5 级", 1, 0x42, 300, 300, 1, 5);
|
||||
roundtrip("2D 数组 100×37×3 层 RGBA8 3 级", 4, 0x25, 100, 37, 3, 3);
|
||||
roundtrip("2D 数组 64×64×2 层 BC3 4 级", 4, 0x44, 64, 64, 2, 4);
|
||||
roundtrip("3D 100×37×5 RGBA8 3 级", 2, 0x25, 100, 37, 5, 3);
|
||||
roundtrip("3D 64×64×20 R8 4 级", 2, 0x01, 64, 64, 20, 4);
|
||||
roundtrip("3D 40×30×9 RGBA32F 3 级", 2, 0x2E, 40, 30, 9, 3);
|
||||
|
||||
printf("B 地址公式(期望值按 GOB 64B×8 行公开排布手算)\n");
|
||||
struct { uint32_t x, y, z, rb, rows; unsigned th, td; uint64_t want; const char *how; } B[] = {
|
||||
{0, 0, 0, 64, 8, 0, 0, 0, "原点"},
|
||||
{17, 3, 0, 64, 8, 0, 0, 113, "GOB 内:(3/2)·64 + (17%32/16)·32 + (3%2)·16 + 17%16 = 64+32+16+1"},
|
||||
{70, 9, 0, 128, 32, 1, 0, 1558, "块高 2:第 1 列块 1024 + 块内第 1 个 GOB 512 + GOB 内 (9%2)·16 + 6 = 22"},
|
||||
{0, 0, 1, 64, 8, 0, 1, 512, "块深 2:块内第 1 个 GOB(z%2·块高1)= 512"},
|
||||
{0, 0, 2, 64, 8, 0, 1, 1024, "块深 2:第 1 层块 = 1 列 × 1 行 × 1024"},
|
||||
{200, 40, 0, 256, 64, 2, 0, 9284, "块高 4(32 行):第 1 行块 4·2048=8192 + 第 3 列块 3·2048=6144?见下"},
|
||||
};
|
||||
// 最后一例手算:rb=256 → 4 个 GOB 宽;块高 4 GOB = 32 行、块 2048 字节;y=40 → 第 1 行块:4×2048 = 8192;
|
||||
// x=200 → 第 3 列块:3×2048 = 6144;块内 GOB = (40%32)/8 = 1 → 512;GOB 内 x%64=8、y%8=0 → 8。合计 8192+6144+512+8 = 14856
|
||||
// Last hand-calculated case: rb=256 → 4 GOBs wide; block height 4 GOBs = 32 rows, block 2048 bytes; y=40 → block row 1: 4×2048 = 8192;
|
||||
// x=200 → block column 3: 3×2048 = 6144; GOB within the block = (40%32)/8 = 1 → 512; within the GOB x%64=8, y%8=0 → 8. Total 8192+6144+512+8 = 14856
|
||||
B[5].want = 14856; B[5].how = "块高 4:行块 8192 + 列块 6144 + 块内 GOB 512 + GOB 内 8";
|
||||
for (unsigned i = 0; i < sizeof B / sizeof *B; i++) {
|
||||
uint64_t got = nvn_bl_offset(B[i].x, B[i].y, B[i].z, B[i].rb, B[i].rows, B[i].th, B[i].td);
|
||||
CHECK(got == B[i].want, "B%u 得 %llu 期望 %llu", i, (unsigned long long)got, (unsigned long long)B[i].want);
|
||||
printf(" B%u (%u,%u,%u) → %llu %s %s\n", i, B[i].x, B[i].y, B[i].z, (unsigned long long)got, got == B[i].want ? "✓" : "✗", B[i].how);
|
||||
}
|
||||
|
||||
// ---------- E 手工 3D:按手算地址往块线性存储里放标记,解出后核标记落点(往返 A 只证自洽,证不了排布对不对)----------
|
||||
// 块高块深规则出处:deko3d dk_image.cpp —— 3D 贴图块高固定 1 个 GOB,块深 = pickTileSize(深度 + 深度/2)。
|
||||
// ---------- E hand-built 3D: place markers into block-linear storage at hand-calculated addresses, decode, and verify where the markers land (round trip A only proves self-consistency, not whether the layout is right) ----------
|
||||
// Source of the block height / block depth rule: deko3d dk_image.cpp - for 3D textures block height is fixed at 1 GOB, block depth = pickTileSize(depth + depth/2).
|
||||
printf("E 手工 3D 块线性(标记放在手算地址,解排布后核落点)\n");
|
||||
{
|
||||
nvn_texdesc d = {2, 0x25, 0, 0, 32, 16, 20, 1, 0, 0}; // 3D RGBA8 32×16×20:行 128 字节 = 2 个 GOB 宽,16 行 = 2 个 GOB 高 | 3D RGBA8 32×16×20: row 128 bytes = 2 GOBs wide, 16 rows = 2 GOBs high
|
||||
nvn_texlayout L; nvn_tex_layout(&d, &L);
|
||||
// 块深:20 + 10 = 30 ≥ 16 → 16 片(log2 = 4);块 = 512 × 16 = 8192 字节;一层块 = 2 列 × 2 行 × 8192 = 32768;ceil(20/16) = 2 层 → 65536
|
||||
// Block depth: 20 + 10 = 30 ≥ 16 → 16 slices (log2 = 4); block = 512 × 16 = 8192 bytes; one block layer = 2 columns × 2 rows × 8192 = 32768; ceil(20/16) = 2 layers → 65536
|
||||
CHECK(L.tileH == 0 && L.tileD == 4, "E 32×16×20 块高/块深 = %u/%u,期望 0/4", L.tileH, L.tileD);
|
||||
CHECK(L.size == 65536, "E 32×16×20 存储 %llu 期望 65536", (unsigned long long)L.size);
|
||||
struct { uint32_t x, y, z; uint64_t addr; const char *how; } V[] = {
|
||||
{0, 0, 0, 0, "原点"},
|
||||
{20, 11, 3, 26224, "行块 1·2·8192=16384 + 列块(80/64=1)·8192 + 块内 GOB z%16=3·512=1536 + GOB 内 (x80%64=16,y3) 64+32+16 = 112"},
|
||||
{31, 15, 17, 58364, "深块 1·32768 + 行块 16384 + 列块 8192 + 块内 GOB 1·512 + GOB 内 (x60,y7) 256+192+32+16+12 = 508"},
|
||||
{5, 2, 19, 34404, "深块 32768 + 块内 GOB 3·512=1536 + GOB 内 (x20,y2) 64+32+4 = 100"},
|
||||
};
|
||||
uint8_t *st = calloc(L.size, 1), *lin = calloc(128 * 16 * 20, 1);
|
||||
for (unsigned i = 0; i < 4; i++) for (int k = 0; k < 4; k++) st[V[i].addr + k] = (uint8_t)(0x10 * (i + 1) + k + 1);
|
||||
CHECK(!nvn_deswizzle(&d, 0, 0, st, lin, 128), "E 解排布失败");
|
||||
for (unsigned i = 0; i < 4; i++) {
|
||||
const uint8_t *p = lin + ((size_t)V[i].z * 16 + V[i].y) * 128 + V[i].x * 4; int ok = 1;
|
||||
for (int k = 0; k < 4; k++) ok &= p[k] == (uint8_t)(0x10 * (i + 1) + k + 1);
|
||||
CHECK(ok, "E 体素 (%u,%u,%u) 未在手算地址 %llu 处取到标记", V[i].x, V[i].y, V[i].z, (unsigned long long)V[i].addr);
|
||||
printf(" E (%2u,%2u,%2u) ← 存储 %5llu %s %s\n", V[i].x, V[i].y, V[i].z, (unsigned long long)V[i].addr, ok ? "✓" : "✗", V[i].how);
|
||||
}
|
||||
size_t nz = 0; for (size_t j = 0; j < 128 * 16 * 20; j++) nz += lin[j] != 0;
|
||||
CHECK(nz == 16, "E 解出非零字节 %zu 期望 16(标记外不该有数据)", nz);
|
||||
free(st); free(lin);
|
||||
// 选角页真调色表的形态:32³ RGBA16F(ser 17 / 16)。块深 32 + 16 = 48 ≥ 16 → 16 片;行 256 字节 = 4 GOB 宽、32 行 = 4 GOB 高、2 层块 → 4·4·2·8192 = 262144
|
||||
// Shape of the real color lookup table on the character select screen: 32³ RGBA16F (ser 17 / 16). Block depth 32 + 16 = 48 ≥ 16 → 16 slices; row 256 bytes = 4 GOBs wide, 32 rows = 4 GOBs high, 2 block layers → 4·4·2·8192 = 262144
|
||||
nvn_texdesc lut = {2, 0x29, 0, 0, 32, 32, 32, 1, 0, 0}; nvn_tex_layout(&lut, &L);
|
||||
CHECK(L.tileH == 0 && L.tileD == 4 && L.size == 4 * 4 * 2 * 8192ull, "E 32³ RGBA16F 块高/块深 %u/%u 存储 %llu,期望 0/4、262144", L.tileH, L.tileD, (unsigned long long)L.size);
|
||||
printf(" E 32³ RGBA16F(选角页调色表形态)块高/块深 %u/%u、存储 %llu(期望 0/4、262144)\n", L.tileH, L.tileD, (unsigned long long)L.size);
|
||||
}
|
||||
|
||||
printf("C/D 真数据对拍(Switch 块线性 vs PC 线性)+ 错块高负对照,阈值 %.0f dB\n", PSNR_PASS);
|
||||
const char *dir = argc > 1 ? argv[1] : getenv("DM_TEX_SAMPLES");
|
||||
char lp[1024]; snprintf(lp, sizeof lp, "%s/list.tsv", dir ? dir : "."); FILE *f = dir ? fopen(lp, "r") : NULL;
|
||||
CHECK(f, "缺样本目录(先 make samples)"); int npair = 0;
|
||||
if (f) { char line[1024]; while (fgets(line, sizeof line, f)) { int i; char path[512], why[256];
|
||||
if (sscanf(line, "%d\t%511[^\t]\t%255[^\n]", &i, path, why) == 3) { real_pair(dir, i, why); npair++; } } fclose(f); }
|
||||
CHECK(npair >= 3, "真数据样本不足 3 对(%d)", npair);
|
||||
printf("%s:%d/%d 项通过(真数据 %d 对)\n", fails ? "红" : "全过", checks - fails, checks, npair);
|
||||
return fails ? 1 : 0;
|
||||
}
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
import datetime
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
ACCESS = re.compile(r"(?:fp|vp)_c1\)\._m0\[([^\]]+)\]")
|
||||
DEFINITION = re.compile(r"\b(?:u?int|long|short)\s+(_\d+)\s*=\s*([^;]+);")
|
||||
VARIABLE = re.compile(r"\b(_\d+)\b")
|
||||
|
||||
|
||||
def bounded(index, definitions):
|
||||
names = VARIABLE.findall(index)
|
||||
current = names[-1] if names else index.strip()
|
||||
for _ in range(8):
|
||||
expression = definitions.get(current)
|
||||
if expression is None:
|
||||
return False
|
||||
if re.search(r"\bmin\s*\(|\bclamp\s*\(|&\s*(?:0x[0-9a-fA-F]+|\d+)", expression):
|
||||
return True
|
||||
names = VARIABLE.findall(expression)
|
||||
if not names:
|
||||
return False
|
||||
current = names[-1]
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 3:
|
||||
raise SystemExit(f"用法:{sys.argv[0]} <dmsh_b 版本目录> <输出 tsv>")
|
||||
version_dir, output = map(os.path.abspath, sys.argv[1:])
|
||||
keys = []
|
||||
for name in sorted(os.listdir(version_dir)):
|
||||
if not name.endswith(".metal"):
|
||||
continue
|
||||
path = os.path.join(version_dir, name)
|
||||
with open(path, encoding="utf-8") as stream:
|
||||
source = stream.read()
|
||||
accesses = ACCESS.findall(source)
|
||||
if not accesses:
|
||||
continue
|
||||
definitions = dict(DEFINITION.findall(source))
|
||||
if any(not index.strip().isdigit() and not bounded(index, definitions) for index in accesses):
|
||||
keys.append(name[:-len("_b.metal")] if name.endswith("_b.metal") else name[:-6])
|
||||
os.makedirs(os.path.dirname(output), exist_ok=True)
|
||||
with open(output, "w", encoding="utf-8", newline="") as stream:
|
||||
stamp = datetime.datetime.now().astimezone().isoformat(timespec="seconds")
|
||||
stream.write(f"# chain {os.path.basename(version_dir)} {stamp}\n")
|
||||
for key in keys:
|
||||
stream.write(key + "\n")
|
||||
print(f"未证有界:{len(keys)} 个着色器")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,483 @@
|
||||
#!/usr/bin/env python3
|
||||
# B 路线离线出包:Switch 原版着色器 → SPIR-V(dmsh_xlate,Ryujinx 翻译器)→ spirv-cross MSL → metallib + 回放反射 JSON。
|
||||
# 运行时不翻译(iOS 无 JIT):产物进着色器缓存目录,文件名 = Switch 控制段键(dm_ctl_sha16,与 shader_map.tsv 第 4 列同)+「_b」。
|
||||
# 查询作答来源:仓内的作答表 nvn/shader_facts.tsv(dmsh_facts.py)——贴图类型、顶点属性 / 片元输出分量类型、计算线程组大小与共享内存;出包不需要 PC 版文件。
|
||||
# 用法:dmsh_build.py <Switch 包目录> <输出缓存目录> [键…](不给键 = 全部);产物实际写进 <输出缓存目录>/b-<链版本>/(IOSOUT 同),链版本见 dmsh_chain.py 环境:XLATE=翻译工具路径,DMSH_CAS=内容寻址缓存目录(缺省为输出缓存目录/cas),J=并发
|
||||
# 程序本体内嵌的图形着色器(映射表 main.rodata@偏移 行)从 MAIN(Switch main NSO,缺省 3.3.94012 Update/ExeFS/main)解出;解 NSO 要 lz4,用 dm 的 venv python 跑
|
||||
# 产物:<键>_b.metallib、<键>_b.json(回放反射,含驱动段 c0 / c2 的运行时读取偏移 drv_reads)、<键>_b.metal(MSL)
|
||||
# 环境 IOSOUT=目录:同一份 MSL 经 dm/ios/tools/ios_metal.compile 同时出 iphoneos metallib + 反射(chain_metal 记 iOS 编译口径)
|
||||
# 末尾汇总:成功 / 失败数与原因分布;驱动段读取的偏移分布(落在回放层能填的范围外的单列)
|
||||
# Route B offline build: original Switch shaders → SPIR-V (dmsh_xlate, the Ryujinx translator) → spirv-cross MSL → metallib + replay reflection JSON.
|
||||
# No translation at runtime (iOS has no JIT): build output goes into the shader cache directory, file name = Switch control segment key (dm_ctl_sha16, same as column 4 of shader_map.tsv) + "_b".
|
||||
# Source of query answers: the in-repo answer table nvn/shader_facts.tsv (dmsh_facts.py) - texture types, vertex attribute / fragment output component types, compute thread group size and shared memory; the build needs no PC version files.
|
||||
# Usage: dmsh_build.py <Switch package dir> <output cache dir> [key...] (no keys = all); build output is actually written to <output cache dir>/b-<chain version>/ (same for IOSOUT), for the chain version see dmsh_chain.py Environment: XLATE=path to the translation tool, DMSH_CAS=content-addressed cache dir (default <output cache dir>/cas), J=concurrency
|
||||
# Graphics shaders embedded in the executable itself (mapping table rows main.rodata@offset) are extracted from MAIN (Switch main NSO, default 3.3.94012 Update/ExeFS/main); extracting the NSO needs lz4, run with dm's venv python
|
||||
# Build output: <key>_b.metallib, <key>_b.json (replay reflection, including drv_reads, the runtime read offsets into driver segments c0 / c2), <key>_b.metal (MSL)
|
||||
# Environment IOSOUT=dir: the same MSL also goes through dm/ios/tools/ios_metal.compile to produce an iphoneos metallib + reflection (chain_metal records the iOS compile convention)
|
||||
# Final summary: success / failure counts and the distribution of reasons; distribution of driver segment read offsets (those outside the range the replay layer can fill are listed separately)
|
||||
import ast, inspect, os, re, sys, json, struct, hashlib, shutil, subprocess, tempfile, collections, threading, concurrent.futures as cf
|
||||
DM_ROOT = os.environ.get('DM_ROOT') or os.path.expanduser('~/dm-work') # 工作区根目录(游戏文件、产物、运行现场都在它下面) | Workspace root (game files, build outputs and run artifacts are all under it)
|
||||
HOME = os.path.expanduser('~')
|
||||
dm_dir, out = sys.argv[1:3]; want = set(sys.argv[3:]); cache_root = out
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))); import dmsh_chain, dmsh_fetch, dmsh_facts # 翻译链版本:先核工具与锁文件,产物进 b-<V>/ | translation chain version: verify the tools against the lock file first; build output goes into b-<V>/
|
||||
_bad = dmsh_chain.check_tools()
|
||||
if _bad: sys.exit('\n'.join('【红】翻译链工具与锁文件不符:' + b for b in _bad) + '\n(换了工具就 dmsh_chain.py --update-lock 并入仓;只是没重编翻译器就重编)')
|
||||
CHAIN = dmsh_chain.version(); out = os.path.join(out, 'b-' + CHAIN)
|
||||
if f'"{CHAIN}"' not in open(dmsh_chain.HEADER).read(): sys.exit(f'【红】nvn/dmsh_chain.h 不是当前翻译链版本 {CHAIN}:先跑 dmsh_chain.py --header(否则宿主找不到这批库)')
|
||||
XLATE = os.environ.get('XLATE', f'{DM_ROOT}/build/gfx/dmsh_xlate/dmsh_xlate')
|
||||
FACTS = dmsh_facts.load()
|
||||
if not FACTS: sys.exit('【红】没有作答表 nvn/shader_facts.tsv(随仓库;维护者用 dmsh_facts.py --freeze 重出)')
|
||||
IOSOUT = os.environ.get('IOSOUT') # 设了就同时出 iOS 版(iphoneos metallib + 反射)到该目录 | if set, also build the iOS version (iphoneos metallib + reflection) into that directory
|
||||
if IOSOUT:
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../ios/tools')); import ios_metal
|
||||
IOSOUT = os.path.join(IOSOUT, 'b-' + CHAIN); os.makedirs(IOSOUT, exist_ok=True)
|
||||
MAIN = os.environ.get('MAIN', f'{DM_ROOT}/data/switch/3.3.94012/Update/ExeFS/main')
|
||||
MAP = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../nvn/shader_map.tsv')
|
||||
BF_WANT_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../nvn/bf_want.tsv')
|
||||
BF_WANT = {line.strip() for line in open(BF_WANT_FILE) if line.strip() and not line.lstrip().startswith('#')} if os.path.exists(BF_WANT_FILE) else set()
|
||||
XC = ['--msl', '--msl-version', '20300', '--msl-argument-buffers', '--msl-texture-buffer-native', '--msl-pad-fragment-output']
|
||||
CAS = os.environ.get('DMSH_CAS', os.path.join(cache_root, 'cas'))
|
||||
CAS_LOCKS, CAS_LOCKS_GUARD = {}, threading.Lock()
|
||||
PRE_STATS = collections.Counter()
|
||||
MAC_RECORD = 'xcrun -sdk macosx metal -c; xcrun -sdk macosx metallib'
|
||||
TEX_BASE, SAMP_BASE, IMG_BASE = 0x168, 0x568, 0x120 # c[2]:图像句柄表 0x120 + 8 r(8 槽,紧接贴图表之前;cs_lut_combine_c 写 u4 = 0x140 反推,u5 = 0x148 核对) | c[2]: image handle table 0x120 + 8 r (8 slots, immediately before the texture table; inferred from cs_lut_combine_c writing u4 = 0x140, checked with u5 = 0x148)
|
||||
|
||||
def records(d):
|
||||
r = [m.start() for m in re.finditer(b'BTCDBTCD', d)]
|
||||
return [d[x:(r[k + 1] if k + 1 < len(r) else len(d))] for k, x in enumerate(r)]
|
||||
|
||||
def clone(src, dst):
|
||||
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
||||
tmp = dst + '.tmp-' + str(os.getpid()) + '-' + str(threading.get_ident())
|
||||
r = subprocess.run(['cp', '-c', src, tmp], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, timeout=60)
|
||||
if r.returncode:
|
||||
shutil.copyfile(src, tmp)
|
||||
os.replace(tmp, dst)
|
||||
|
||||
def atomic_json(path, value):
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
tmp = path + '.tmp-' + str(os.getpid()) + '-' + str(threading.get_ident())
|
||||
with open(tmp, 'w') as f: json.dump(value, f, ensure_ascii=False, indent=1)
|
||||
os.replace(tmp, path)
|
||||
|
||||
def source_without_rule_bodies():
|
||||
source = open(__file__, 'r').read(); lines = source.splitlines(True); tree = ast.parse(source)
|
||||
names = {f.__name__ for f, _ in RULES}
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)) and node.name in names and node.body:
|
||||
first = node.body[0].lineno - 1
|
||||
last = max(getattr(x, 'end_lineno', x.lineno) for x in ast.walk(node) if getattr(x, 'lineno', 0) >= node.body[0].lineno)
|
||||
indent = re.match(r'\s*', lines[first]).group(0); lines[first:last] = [indent + 'pass\n']
|
||||
return ''.join(lines)
|
||||
|
||||
def shader_rule_source(name):
|
||||
return b''.join(inspect.getsource(f).encode() for f, applies in RULES if applies(name))
|
||||
|
||||
def tool_fingerprint():
|
||||
sc = subprocess.run(['spirv-cross', '--version'], capture_output=True, text=True, timeout=30)
|
||||
return ('lock\0' + open(dmsh_chain.LOCK).read() + '\0options\0' + dmsh_chain.options() +
|
||||
'\0xlate\0' + dmsh_chain.xlate_source_sha() + '\0spirv-cross\0' + sc.stdout + sc.stderr +
|
||||
'\0xc\0' + repr(XC) + '\0mac\0' + MAC_RECORD + '\0ios\0' + (ios_metal.RECORD if IOSOUT else ''))
|
||||
|
||||
def shader_key(key, name, rec):
|
||||
pc = dmsh_facts.row(key, FACTS[key]).encode() if key in FACTS else '缺'.encode()
|
||||
map_row = MAP_ROWS.get(key, '缺'.encode()) + MAP_CONFLICT_ROWS.get(key, b'')
|
||||
embedded = rec if name.startswith('main.rodata@') else b''
|
||||
payload = (b'record\0' + rec + b'\0map\0' + map_row + b'\0pc\0' + pc + b'\0embedded\0' + embedded +
|
||||
b'\0tools\0' + TOOL_FP + b'\0code\0' + CODE_FP.encode() +
|
||||
b'\0rule\0' + shader_rule_source(name))
|
||||
return hashlib.sha256(payload).hexdigest()
|
||||
|
||||
def cache_meta_path(key): return os.path.join(CAS, 'index', key + '.json')
|
||||
def cache_path(digest): return os.path.join(CAS, 'shader', digest)
|
||||
|
||||
def cache_outputs(key, digest, cached=False):
|
||||
root = cache_path(digest); files = {}
|
||||
for label, directory, names in (
|
||||
('mac', out, [key + '_b.metallib', key + '_b.metal', key + '_b.json']),
|
||||
('ios', IOSOUT, [key + '_b.metallib', key + '_b.json'])):
|
||||
if not directory: continue
|
||||
base = os.path.join(root, label) if cached else directory
|
||||
found = [n for n in names if os.path.exists(os.path.join(base, n))]
|
||||
if key + '_b.metallib' not in found or key + '_b.json' not in found: return None
|
||||
files[label] = found
|
||||
return root, files
|
||||
|
||||
def restore_cache(key, digest):
|
||||
found = cache_outputs(key, digest, cached=True)
|
||||
if not found: return False
|
||||
root, files = found
|
||||
for label, names in files.items():
|
||||
directory = out if label == 'mac' else IOSOUT
|
||||
for name in names:
|
||||
src = os.path.join(root, label, name); dst = os.path.join(directory, name)
|
||||
if name.endswith('.json'):
|
||||
tmp = dst + '.tmp-' + str(os.getpid()) + '-' + str(threading.get_ident())
|
||||
with open(tmp, 'wb') as f: f.write(re.sub(rb'("chain"\s*:\s*")[^"]*"', rb'\g<1>' + CHAIN.encode() + b'"', open(src, 'rb').read(), count=1))
|
||||
os.replace(tmp, dst)
|
||||
else: clone(src, dst)
|
||||
return True
|
||||
|
||||
def cache_lookup(key, digest, rule_fp, code_fp):
|
||||
with CAS_LOCKS_GUARD: lock = CAS_LOCKS.setdefault(('shader', key), threading.Lock())
|
||||
with lock:
|
||||
if restore_cache(key, digest): PRE_STATS['hit'] += 1; return True, '命中'
|
||||
old = json.load(open(cache_meta_path(key))) if os.path.exists(cache_meta_path(key)) else None
|
||||
if old and old.get('code_fp') != code_fp: reason = '代码指纹变化:全部重出'
|
||||
elif old and old.get('rule_fp') != rule_fp: reason = '规则变'
|
||||
else: reason = '新键'
|
||||
PRE_STATS['miss'] += 1; PRE_STATS[reason] += 1; return False, reason
|
||||
|
||||
def publish_cache(key, digest, rule_fp, code_fp):
|
||||
found = cache_outputs(key, digest)
|
||||
if not found: return
|
||||
root, files = found
|
||||
for label, names in files.items():
|
||||
d = os.path.join(root, label); os.makedirs(d, exist_ok=True)
|
||||
for name in names: clone(os.path.join(out if label == 'mac' else IOSOUT, name), os.path.join(d, name))
|
||||
for name in names:
|
||||
if name.endswith('.json'):
|
||||
src = os.path.join(out if label == 'mac' else IOSOUT, name)
|
||||
value = json.load(open(src)); value.pop('fetch', None)
|
||||
atomic_json(os.path.join(d, name), value)
|
||||
atomic_json(cache_meta_path(key), {'digest': digest, 'rule_fp': rule_fp, 'code_fp': code_fp})
|
||||
|
||||
BF_STATS = collections.Counter()
|
||||
|
||||
def bf_digest(msl, key):
|
||||
h = hashlib.sha256()
|
||||
h.update(msl.encode())
|
||||
h.update(b'\0mac\0' + MAC_RECORD.encode())
|
||||
h.update(b'\0ios\0' + (ios_metal.RECORD if IOSOUT else '').encode())
|
||||
h.update(b'\0bf-want\0' + (b'1' if key in BF_WANT else b'0'))
|
||||
return h.hexdigest()
|
||||
|
||||
def bf_cache_root(digest): return os.path.join(CAS, 'variant', digest)
|
||||
|
||||
def bf_cache_restore(key, digest, fmeta, fmsl):
|
||||
root = bf_cache_root(digest)
|
||||
names = ['metal', 'mac.metallib'] + (['ios.metallib'] if IOSOUT else [])
|
||||
if not all(os.path.exists(os.path.join(root, n)) for n in names): return False
|
||||
clone(os.path.join(root, 'metal'), fmsl)
|
||||
clone(os.path.join(root, 'mac.metallib'), os.path.join(out, key + '_bf.metallib'))
|
||||
if IOSOUT: clone(os.path.join(root, 'ios.metallib'), os.path.join(IOSOUT, key + '_bf.metallib'))
|
||||
BF_STATS['hit'] += 1
|
||||
return True
|
||||
|
||||
def bf_cache_publish(digest, fmsl, maclib, ioslib, fmeta):
|
||||
root = bf_cache_root(digest); os.makedirs(root, exist_ok=True)
|
||||
clone(fmsl, os.path.join(root, 'metal'))
|
||||
clone(maclib, os.path.join(root, 'mac.metallib'))
|
||||
if IOSOUT: clone(ioslib, os.path.join(root, 'ios.metallib'))
|
||||
atomic_json(os.path.join(root, 'fetch.json'), fmeta)
|
||||
|
||||
def write_refl(key, refl):
|
||||
for d, rec in ((out, MAC_RECORD),) + (((IOSOUT, ios_metal.RECORD),) if IOSOUT else ()):
|
||||
value = dict(refl, chain_metal=rec)
|
||||
atomic_json(os.path.join(d, key + '_b.json'), value)
|
||||
|
||||
def fetch_finish(key, src, refl):
|
||||
if refl['stage'] != 'ps': return refl
|
||||
# 有可改采样的照旧出变体;没有可改采样的只给名单(bf_want.tsv,宿主规划器产出)里的键出仅输出映射变体
|
||||
# Those with rewritable samples get variants as before; those without get an output-mapping-only variant, and only for keys in the list (bf_want.tsv, produced by the host planner)
|
||||
fv, fmeta = dmsh_fetch.variant(src, refl['bindings'], om_only_ok=key in BF_WANT)
|
||||
if not fv:
|
||||
for path in (os.path.join(out, key + '_bf.metallib'), os.path.join(out, key + '_bf.metal')) + ((os.path.join(IOSOUT, key + '_bf.metallib'),) if IOSOUT else ()):
|
||||
try: os.unlink(path)
|
||||
except FileNotFoundError: pass
|
||||
write_refl(key, refl)
|
||||
return refl
|
||||
BF_STATS['generated'] += 1
|
||||
fmsl = os.path.join(out, key + '_bf.metal')
|
||||
digest = bf_digest(fv, key)
|
||||
with CAS_LOCKS_GUARD: lock = CAS_LOCKS.setdefault(('variant', digest), threading.Lock())
|
||||
with lock:
|
||||
try:
|
||||
if not bf_cache_restore(key, digest, fmeta, fmsl):
|
||||
BF_STATS['miss'] += 1
|
||||
open(fmsl, 'w').write(fv)
|
||||
fair = fmsl[:-6] + '.air'; flib = os.path.join(out, key + '_bf.metallib')
|
||||
try:
|
||||
subprocess.run(['xcrun', '-sdk', 'macosx', 'metal', '-c', fmsl, '-o', fair], check=True)
|
||||
tmp_flib = flib + '.tmp-' + str(os.getpid())
|
||||
subprocess.run(['xcrun', '-sdk', 'macosx', 'metallib', fair, '-o', tmp_flib], check=True)
|
||||
os.replace(tmp_flib, flib)
|
||||
ilib = None
|
||||
if IOSOUT:
|
||||
ilib = os.path.join(IOSOUT, key + '_bf.metallib')
|
||||
ios_metal.compile(fmsl, fmsl[:-6] + '.ios.air', ilib + '.tmp')
|
||||
os.replace(ilib + '.tmp', ilib)
|
||||
except subprocess.CalledProcessError:
|
||||
return refl
|
||||
BF_STATS['compile'] += 1
|
||||
bf_cache_publish(digest, fmsl, flib, ilib, fmeta)
|
||||
finally:
|
||||
for path in (fmsl, fmsl[:-6] + '.air', fmsl[:-6] + '.ios.air'):
|
||||
try: os.unlink(path)
|
||||
except FileNotFoundError: pass
|
||||
refl['fetch'] = fmeta
|
||||
write_refl(key, refl)
|
||||
return refl
|
||||
|
||||
pc_of, loc, stage_of = {}, {}, {}
|
||||
MAP_ROWS, MAP_CONFLICT_ROWS = {}, {}
|
||||
for raw in open(MAP, 'rb'):
|
||||
c = raw.rstrip(b'\n').split(b'\t')
|
||||
if len(c) > 4: MAP_ROWS.setdefault(c[3].decode(), raw)
|
||||
for raw in open(MAP + '.conflicts.tsv', 'rb'):
|
||||
c = raw.rstrip(b'\n').split(b'\t')
|
||||
if len(c) > 1 and not raw.startswith((b'#', b'dm_')): MAP_CONFLICT_ROWS.setdefault(c[0].decode(), raw)
|
||||
for ln in open(MAP):
|
||||
c = ln.rstrip('\n').split('\t')
|
||||
if len(c) > 4 and c[0].endswith('.bin'): pc_of.setdefault(c[3], c[4]); loc.setdefault(c[3], (c[0], int(c[1])))
|
||||
if len(c) > 4 and c[0].startswith('main.rodata@'): # 内嵌:位置 = main 映像偏移(控制段起点),阶段取映射表第 3 列 | embedded: location = main image offset (start of the control segment), stage taken from column 3 of the mapping table
|
||||
pc_of.setdefault(c[3], c[4]); loc.setdefault(c[3], (c[0], int(c[0].split('@')[1], 16))); stage_of[c[3]] = {'顶点': 'vs', '像素': 'ps'}[c[2]]
|
||||
for ln in open(MAP + '.conflicts.tsv'):
|
||||
c = ln.rstrip('\n').split('\t')
|
||||
if len(c) > 1 and not ln.startswith('#') and not ln.startswith('dm_') and c[0] in pc_of: pc_of[c[0]] = c[1]
|
||||
|
||||
def main_rec(mi, o):
|
||||
"""内嵌着色器 → 与包内记录同布局的字节:包内记录 +0x38 起是代码区(0x30 头 + SPH + 指令,标记 78563412),紧接控制段(34127698);
|
||||
内嵌的代码区紧贴在控制段之前(核对 5 个:代码区长 0x100–0x300、c1 均为空,与同名包内记录布局一致)
|
||||
Embedded shader → bytes in the same layout as a package record: in a package record the code area starts at +0x38 (0x30 header + SPH + instructions, marker 78563412), immediately followed by the control segment (34127698);
|
||||
the embedded code area sits immediately before the control segment (checked 5: code area length 0x100–0x300, c1 empty in all, consistent with the layout of the same-named package records)"""
|
||||
g = mi.rfind(bytes.fromhex('78563412'), o - 0x1000, o)
|
||||
if g < 0 or mi[o:o + 4] != bytes.fromhex('34127698'): sys.exit(f'【红】main 映像 @{o:#x} 不是内嵌着色器控制段(MAIN={MAIN})')
|
||||
return bytes(0x38) + mi[g:o + 0x880]
|
||||
|
||||
def job_for(key, name, rec, w):
|
||||
ci = rec.find(bytes.fromhex('34127698')); code = rec[0x38:ci]; stage = stage_of.get(key, name[:2])
|
||||
c1o, c1t = struct.unpack_from('<2I', rec, ci + 0x700) # 控制段 +0x700:c1 相对指令区起点、+0x704:指令区总长(c1 = 两者之间;全库长度 0 / 256 / 512 / 768) | control segment +0x700: c1 relative to the start of the instruction area, +0x704: total length of the instruction area (c1 = what lies between the two; lengths across the whole library are 0 / 256 / 512 / 768)
|
||||
c1 = rec[0x38 + c1o:0x38 + c1t]
|
||||
if stage != 'cs': code = code[0x30:]
|
||||
cp = os.path.join(w, key + '.bin'); open(cp, 'wb').write(code)
|
||||
j = {'key': key, 'stage': stage, 'code': cp, 'tex': {}, 'img': {}, 'attr': {}, 'fout': {}, 'c1': c1.hex(),
|
||||
'debug': os.environ.get('XLATE_DEBUG', '1') != '0', 'reduced': os.environ.get('XLATE_REDUCED', '1') == '1'} # 翻译选项(见 dmsh_xlate/Program.cs);放宽精度缺省开(GPU 浮点末位误差不进游戏状态,mini 整帧 −26%) # c1:翻译器读间接跳转表用 | translation options (see dmsh_xlate/Program.cs); relaxed precision is on by default (GPU float last-bit error does not enter game state, whole frame −26% on the second Mac) # c1: used by the translator to read indirect jump tables
|
||||
if key not in FACTS: j['pc_missing'] = True; return j, c1 # 作答表里没有:查询按缺省(汇总里单列) | not in the answer table: queries use defaults (listed separately in the summary)
|
||||
j.update(FACTS[key])
|
||||
return j, c1
|
||||
|
||||
def raster_facts(stage, src):
|
||||
"""读入可省(全覆盖首绘)的运行时证明所需的静态事实(nvn_mtl.m first_draw_covers):
|
||||
顶点:位置 x / y / z 是否原样取自同一个顶点属性的 .x / .y / .z(w 为常数 1 或同属性 .w),主函数无分支、无裁剪距离——是则 pos_attr = 属性槽;
|
||||
片元:是否可能丢弃(discard_fragment)、是否写 sample_mask、写出的颜色号。认不出一律按「不可证」(pos_attr = -1 / discard = 1)
|
||||
Static facts needed for the runtime proof that the load can be skipped (full-coverage first draw) (nvn_mtl.m first_draw_covers):
|
||||
Vertex: whether position x / y / z are taken unchanged from the .x / .y / .z of one and the same vertex attribute (w is the constant 1 or the same attribute's .w), with no branches and no clip distances in the main function - if so, pos_attr = attribute slot;
|
||||
Fragment: whether it may discard (discard_fragment), whether it writes sample_mask, and which color indices it writes. Anything unrecognized is treated as "unprovable" (pos_attr = -1 / discard = 1)"""
|
||||
if stage == 'ps':
|
||||
out = re.search(r'struct main0_out\s*\{(.*?)\};', src, re.S)
|
||||
return {'discard': int('discard_fragment' in src), 'sample_mask': int('sample_mask' in (out.group(1) if out else '')),
|
||||
'colors': sorted({int(x) for x in re.findall(r'\[\[color\((\d+)\)\]\]', out.group(1) if out else '')})}
|
||||
if stage != 'vs': return {}
|
||||
body = re.search(r'\bvertex\s+\w+\s+\w+\s*\(.*?\)\s*\{(.*)\}\s*$', src, re.S) # 主函数是文件里最后一个函数 | the main function is the last function in the file
|
||||
if not body or re.search(r'\b(if|for|while|switch|do)\b|clip_distance|ClipDistance', body.group(1)): return {'pos_attr': -1}
|
||||
b = body.group(1)
|
||||
attr = {m.group(2): int(m.group(3)) for m in re.finditer(r'(\w+)\s+(\w+)\s*\[\[attribute\((\d+)\)\]\]', src)}
|
||||
var = {m.group(1): (m.group(2), m.group(3)) for m in re.finditer(r'float\s+(_\w+)\s*=\s*in\.(\w+)\.([xyzw]);', b)}
|
||||
last = {}
|
||||
for m in re.finditer(r'out\.gl_Position\.([xyzw])\s*=\s*([^;]+);', b): last[m.group(1)] = m.group(2).strip()
|
||||
src_of = {c: var.get(v) for c, v in last.items()}
|
||||
m0 = src_of.get('x')
|
||||
if not m0 or m0[0] not in attr or any(src_of.get(c) != (m0[0], c) for c in 'xyz'): return {'pos_attr': -1}
|
||||
if last.get('w') == '1.0': w = 'one'
|
||||
elif src_of.get('w') == (m0[0], 'w'): w = 'attr'
|
||||
else: return {'pos_attr': -1}
|
||||
# uv 直传(合并 B 第 2 步「本像素寻址」证明用):插值输出 locn K 的 .x / .y 原样取自顶点属性 A 的 .x / .y → uv_from_attr[K] = A
|
||||
# uv pass-through (used for the "this-pixel addressing" proof in merge B step 2): the .x / .y of interpolated output locn K are taken unchanged from the .x / .y of vertex attribute A → uv_from_attr[K] = A
|
||||
ost = re.search(r'struct main0_out\s*\{(.*?)\};', src, re.S)
|
||||
locn = {m.group(1): int(m.group(2)) for m in re.finditer(r'(m_\d+) \[\[user\(locn(\d+)\)\]\]', ost.group(1) if ost else '')}
|
||||
olast = {}
|
||||
for m in re.finditer(r'out\.(m_\d+)\.([xyzw])\s*=\s*([^;]+);', b): olast[(m.group(1), m.group(2))] = m.group(3).strip()
|
||||
uv, aff = {}, {}
|
||||
for mem, k in locn.items():
|
||||
sx, sy = var.get(olast.get((mem, 'x'), '')), var.get(olast.get((mem, 'y'), ''))
|
||||
if sx and sy and sx[0] == sy[0] and sx[0] in attr and sx[1] == 'x' and sy[1] == 'y': uv[str(k)] = attr[sx[0]]; continue
|
||||
# 仿射:分量 = fma(属性分量, uniform[槽].向量[i].分量, uniform[槽].向量[j].分量)(vp_cN 即 uniform 槽 N − 3)
|
||||
# Affine: component = fma(attribute component, uniform[slot].vector[i].component, uniform[slot].vector[j].component) (vp_cN is uniform slot N − 3)
|
||||
def fm(v_):
|
||||
m = re.search(r'float %s = fma\((_\w+), \(\*spvDescriptorSet0\.vp_c(\d+)\)\._m0\[(\d+)\]\.([xyzw]), \(\*spvDescriptorSet0\.vp_c(\d+)\)\._m0\[(\d+)\]\.([xyzw])\);' % re.escape(v_), b)
|
||||
if not m or m.group(1) not in var: return None
|
||||
return var[m.group(1)], [int(m.group(2)) - 3, int(m.group(3)), 'xyzw'.index(m.group(4))], [int(m.group(5)) - 3, int(m.group(6)), 'xyzw'.index(m.group(7))]
|
||||
fx, fy = fm(olast.get((mem, 'x'), '')), fm(olast.get((mem, 'y'), ''))
|
||||
if fx and fy and fx[0][0] == fy[0][0] and fx[0][0] in attr and fx[0][1] == 'x' and fy[0][1] == 'y' and min(fx[1][0], fx[2][0], fy[1][0], fy[2][0]) >= 0:
|
||||
aff[str(k)] = {'attr': attr[fx[0][0]], 'sx': fx[1], 'ox': fx[2], 'sy': fy[1], 'oy': fy[2]}
|
||||
return {'pos_attr': attr[m0[0]], 'pos_w': w, 'uv_from_attr': uv, 'uv_affine': aff}
|
||||
|
||||
def decode_tex(name):
|
||||
"""fp_t_cb{slots}_{handle} / fp_t_tcb_{handle}:贴图槽、采样器槽(Ryujinx TextureHandle 编码;c[2] 句柄表) | fp_t_cb{slots}_{handle} / fp_t_tcb_{handle}: texture slot, sampler slot (Ryujinx TextureHandle encoding; c[2] handle table)"""
|
||||
m = re.match(r'[a-z]+_[ti]\w*?_(?:cb(\d+)|tcb)_([0-9A-F]+)', name)
|
||||
if not m: return None
|
||||
slots = int(m.group(1)) if m.group(1) else -1; h = int(m.group(2), 16)
|
||||
tb = (slots & 0xffff) if slots >= 0 else 2; sb = ((slots >> 16) - 1) if slots >= 0 and (slots >> 16) else tb
|
||||
o0, o1, ty = h & 0x3fff, (h >> 14) & 0x3fff, h >> 28
|
||||
def slot(word, base, cb): return (word * 4 - base) // 8 if cb == 2 and word * 4 >= base and (word * 4 - base) % 8 == 0 else None
|
||||
words = [o0] + ([o1] if ty else [])
|
||||
if re.match(r'[a-z]+_i', name): # 图像 | image
|
||||
return next((slot(x, IMG_BASE, tb) for x in words if IMG_BASE <= x * 4 < TEX_BASE and slot(x, IMG_BASE, tb) is not None), None), None, ty
|
||||
t = next((slot(x, TEX_BASE, tb) for x in words if slot(x, TEX_BASE, tb) is not None and x * 4 < SAMP_BASE), None)
|
||||
s = next((slot(x, SAMP_BASE, sb) for x in words if x * 4 >= SAMP_BASE and slot(x, SAMP_BASE, sb) is not None), None)
|
||||
return t, s, ty
|
||||
|
||||
def reflect(key, stage, msl, res):
|
||||
"""MSL 参数缓冲结构体成员 → 回放反射:kind(同 nvn_refl.h)+ NVN 槽号 + 参数缓冲成员号 | MSL argument buffer struct member → replay reflection: kind (same as nvn_refl.h) + NVN slot number + argument buffer member index"""
|
||||
body = re.search(r'struct spvDescriptorSetBuffer0\s*\{(.*?)\};', msl, re.S)
|
||||
sb_cb = {b['binding']: b for b in res['sbufs']}
|
||||
binds = []
|
||||
for m in re.finditer(r'^\s*(.+?)\s+(\w+)\s*\[\[id\((\d+)\)\]\];', body.group(1) if body else '', re.M):
|
||||
ty, nm, aid = m.group(1).strip(), m.group(2), int(m.group(3))
|
||||
e = {'msl_name': nm, 'msl_type': ty, 'arg_id': aid}
|
||||
if nm == 'support_buffer': e.update(kind='support')
|
||||
elif re.fullmatch(r'[a-z]+_c(\d+)', nm):
|
||||
n = int(re.fullmatch(r'[a-z]+_c(\d+)', nm).group(1))
|
||||
e.update(kind='cbuf', reg=n - 3) if 3 <= n <= 16 else e.update(kind='c1' if n == 1 else 'drvcb', bank=n)
|
||||
elif re.fullmatch(r'[a-z]+_s(\d+)', nm):
|
||||
e.update(kind='sbuf', index=int(re.fullmatch(r'[a-z]+_s(\d+)', nm).group(1)))
|
||||
elif nm.endswith('Smplr'): # 句柄类型 0 = 贴图与采样器合在同一句柄:采样器号取该贴图槽句柄的高位 | handle type 0 = texture and sampler combined in one handle: the sampler index is taken from the high bits of that texture slot's handle
|
||||
t, s, ty = decode_tex(nm[:-5]); e.update(kind='samp', reg=s) if ty else e.update(kind='samp_tex', reg=t)
|
||||
else:
|
||||
d = decode_tex(nm)
|
||||
if not d: e.update(kind='?')
|
||||
else: e.update(kind='img' if re.match(r'[a-z]+_i', nm) else ('tbuf' if 'texture_buffer' in ty else 'tex'), reg=d[0])
|
||||
binds.append(e)
|
||||
# 存储缓冲:SPIR-V 绑定号 → c0 偏移 → NVN 存储缓冲槽(c0 基址:顶点 0x110、计算 0x310、像素 0x510,每槽 0x10)
|
||||
# Storage buffers: SPIR-V binding number → c0 offset → NVN storage buffer slot (c0 base: vertex 0x110, compute 0x310, pixel 0x510, 0x10 per slot)
|
||||
base = {'vs': 0x110, 'cs': 0x310, 'ps': 0x510}.get(stage) # 外壳 / 域阶段的存储缓冲基址未实测:遇到存储缓冲按「无槽」报 | storage buffer base for the hull / domain stages has not been measured: a storage buffer there is reported as 「无槽」(no slot)
|
||||
sb_sorted = sorted(res['sbufs'], key=lambda b: b['binding'])
|
||||
for e in binds:
|
||||
if e['kind'] == 'sbuf':
|
||||
b = sb_sorted[e['index']] if e['index'] < len(sb_sorted) else None
|
||||
off = b['cb_offset'] * 4 if b and b['cb_slot'] == 0 else None
|
||||
if stage == 'cs' and off is not None and 0x210 <= off < 0x310 and (off - 0x210) % 16 == 0:
|
||||
e.update(kind='ubo_ptr', reg=(off - 0x210) // 16) # 计算阶段 uniform 槽 r:地址在 c0[0x210 + 0x10 r],经全局内存读(cs_lut_combine_c 读 cb10[66] 核对) | compute-stage uniform slot r: address at c0[0x210 + 0x10 r], read through global memory (checked against cs_lut_combine_c reading cb10[66])
|
||||
else: e['reg'] = (off - base) // 16 if off is not None and base is not None and 0 <= off - base < 0x100 and (off - base) % 16 == 0 else None
|
||||
e['rw'] = bool(b and b['flags'] & 2)
|
||||
return binds
|
||||
|
||||
DRV_FILL = {0: [(0x110, 0x210), (0x310, 0x410), (0x510, 0x610)], # c0:存储缓冲地址表(顶点 / 计算 / 像素,各 16 槽 × 0x10) | c0: storage buffer address tables (vertex / compute / pixel, 16 slots × 0x10 each)
|
||||
2: [(0x168, 0x568), (0x568, 0x968)]} # c2:贴图句柄表、采样器句柄表(各 128 槽 × 8) | c2: texture handle table, sampler handle table (128 slots × 8 each)
|
||||
|
||||
def drv_reads(src):
|
||||
"""MSL 里对驱动段 c0 / c2 的读取:常量下标 → 字节区间;非常量下标记为动态 | Reads of driver segments c0 / c2 in the MSL: constant index → byte range; non-constant indices are recorded as dynamic"""
|
||||
out = {}
|
||||
for bank in (0, 2):
|
||||
offs, dyn = set(), False
|
||||
for m in re.finditer(r'fp_c%d\)\._m0\[([^\]]+)\]' % bank, src):
|
||||
idx = m.group(1).rstrip('u')
|
||||
if idx.isdigit(): offs.add(int(idx) * 16)
|
||||
else: dyn = True
|
||||
if offs or dyn: out[str(bank)] = {'vec4_offsets': sorted(offs), 'dynamic': dyn}
|
||||
return out
|
||||
|
||||
def unfillable(dr):
|
||||
bad = []
|
||||
for bank, d in dr.items():
|
||||
if d['dynamic']: bad.append(f'c{bank} 动态下标')
|
||||
for o in d['vec4_offsets']:
|
||||
if not any(a <= o and o + 16 <= b or (a <= o < b) for a, b in DRV_FILL[int(bank)]): bad.append(f'c{bank}+{o:#x}')
|
||||
return bad
|
||||
|
||||
RULES = [] # 按着色器名挂的 MSL 改写规则(函数, 适用判定);原有的暗部重映射 toe 已删(回到 Switch 原版亮度) | MSL rewrite rules attached by shader name (function, applicability test); the former dark-range remap toe has been removed (back to the original Switch brightness)
|
||||
# 第一段代码指纹不包含 dmsh_fetch.py;可读 tile 变体单独按生成 MSL 做第二段缓存。
|
||||
# The first-stage code fingerprint does not include dmsh_fetch.py; readable-tile variants get a separate second-stage cache keyed on the generated MSL.
|
||||
CODE_FP = hashlib.sha256(source_without_rule_bodies().encode() + b''.join(b'\0' + open(m.__file__, 'rb').read() for m in (dmsh_chain,) + ((ios_metal,) if IOSOUT else ()))).hexdigest()
|
||||
TOOL_FP = tool_fingerprint().encode()
|
||||
|
||||
def finish(key, w, j, c1):
|
||||
name, k = loc[key]
|
||||
res = json.load(open(os.path.join(w, key + '.res.json')))
|
||||
msl = os.path.join(w, key + '.metal'); air = msl[:-6] + '.air'; lib = os.path.join(out, key + '_b.metallib')
|
||||
r = subprocess.run(['spirv-cross', *XC, os.path.join(w, key + '.spv'), '--output', msl], capture_output=True, text=True)
|
||||
if r.returncode: return 'MSL 失败', r.stderr.strip()[:160], None
|
||||
src = open(msl).read()
|
||||
try:
|
||||
subprocess.run(['xcrun', '-sdk', 'macosx', 'metal', '-c', msl, '-o', air], check=True)
|
||||
tmp_lib = lib + '.tmp-' + str(os.getpid())
|
||||
subprocess.run(['xcrun', '-sdk', 'macosx', 'metallib', air, '-o', tmp_lib], check=True)
|
||||
os.replace(tmp_lib, lib)
|
||||
except subprocess.CalledProcessError as e:
|
||||
return 'metal 失败', str(e)[:160], None
|
||||
clone(msl, os.path.join(out, key + '_b.metal'))
|
||||
if IOSOUT: # iOS:同一份 MSL 走 iOS 的唯一编译口径(dm/ios/tools/ios_metal.py)出 iphoneos metallib | iOS: the same MSL goes through iOS's single compile convention (dm/ios/tools/ios_metal.py) to produce an iphoneos metallib
|
||||
ilib = os.path.join(IOSOUT, key + '_b.metallib')
|
||||
try:
|
||||
ios_metal.compile(msl, msl[:-6] + '.ios.air', ilib + '.tmp')
|
||||
os.replace(ilib + '.tmp', ilib)
|
||||
except subprocess.CalledProcessError as e: return 'iOS metal 失败', str(e)[:160], None
|
||||
entry = re.search(r'(vertex|fragment|kernel)\s+\S+\s+(\w+)\s*\(', src)
|
||||
dr = drv_reads(src)
|
||||
refl = {'key': key + '_b', 'route': 'B', 'chain': CHAIN, 'dm_ctl': key, 'source': f'{name}#{k}', 'pc_paired': pc_of[key], 'stage': j['stage'],
|
||||
'entry': entry.group(2) if entry else 'main0', 'msl_entry_kind': entry.group(1) if entry else None,
|
||||
'threadgroup_size': j.get('local'), 'c1': c1.hex(), 'notes': res['notes'] + (['无配对 PC 反射,查询按缺省'] if j.get('pc_missing') else []), 'drv_reads': dr, 'drv_unfillable': unfillable(dr),
|
||||
'bindings': reflect(key, j['stage'], src, res),
|
||||
'vertex_inputs': [{'location': int(m.group(2)), 'msl_type': m.group(1)} for m in re.finditer(r'(\w+)\s+\w+\s*\[\[attribute\((\d+)\)\]\]', src)],
|
||||
'raster': raster_facts(j['stage'], src)}
|
||||
write_refl(key, refl)
|
||||
fetch_finish(key, src, refl)
|
||||
return 'ok', '', refl
|
||||
|
||||
keys = sorted(want) if want else sorted(loc)
|
||||
NJ = int(os.environ.get('J', '8'))
|
||||
os.makedirs(out, exist_ok=True)
|
||||
w = tempfile.mkdtemp(prefix='dmsh_', dir=os.environ.get('WORK'))
|
||||
packs, jobs, c1s = {}, {}, {}
|
||||
digests, rule_fps, cache_reasons, cache_hits = {}, {}, {}, set()
|
||||
for key in keys:
|
||||
name, k = loc[key]
|
||||
if name.startswith('main.rodata@'):
|
||||
if 'main' not in packs:
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../verify'))
|
||||
try: import nsoimg
|
||||
except ImportError as e: sys.exit(f'【红】解 main NSO 要 lz4({e}):用 $DM_ROOT/build/cache/dm/venv/bin/python 跑')
|
||||
packs['main'] = nsoimg.load(MAIN)
|
||||
rec = main_rec(packs['main'], k)
|
||||
if hashlib.sha256(rec[rec.find(bytes.fromhex('34127698')):][:0x880]).hexdigest()[:16] != key: sys.exit(f'【红】{name} 控制段哈希与映射表键 {key} 不符(MAIN={MAIN})')
|
||||
else:
|
||||
if name not in packs: packs[name] = records(open(os.path.join(dm_dir, name), 'rb').read())
|
||||
rec = packs[name][k]
|
||||
digests[key] = shader_key(key, name, rec)
|
||||
rule_fps[key] = hashlib.sha256(shader_rule_source(name)).hexdigest()
|
||||
hit, cache_reasons[key] = cache_lookup(key, digests[key], rule_fps[key], CODE_FP)
|
||||
if hit: cache_hits.add(key)
|
||||
else: jobs[key], c1s[key] = job_for(key, name, rec, w)
|
||||
misses = [key for key in keys if key not in cache_hits]
|
||||
chunks = [misses[i::NJ] for i in range(NJ)]
|
||||
def xl(ch):
|
||||
jp = os.path.join(w, f'job_{abs(hash(ch[0]))}.json'); json.dump([jobs[k] for k in ch], open(jp, 'w'))
|
||||
return subprocess.run([XLATE, jp, w], capture_output=True, text=True)
|
||||
with cf.ThreadPoolExecutor(NJ) as ex: xr = list(ex.map(xl, [c for c in chunks if c]))
|
||||
xerr = {}
|
||||
for r in xr:
|
||||
for ln in r.stderr.splitlines():
|
||||
m = re.match(r'【红】(\w+):(.*)', ln)
|
||||
if m: xerr[m.group(1)] = m.group(2)[:160]
|
||||
def fin(key):
|
||||
if key in cache_hits:
|
||||
refl = json.load(open(os.path.join(out, key + '_b.json')))
|
||||
src = open(os.path.join(out, key + '_b.metal')).read() if refl['stage'] == 'ps' else ''
|
||||
return key, 'ok', '', fetch_finish(key, src, refl)
|
||||
if key in xerr or not os.path.exists(os.path.join(w, key + '.spv')): return key, '翻译失败', xerr.get(key, '无 spv'), None
|
||||
result = (key,) + finish(key, w, jobs[key], c1s[key])
|
||||
if result[1] == 'ok': publish_cache(key, digests[key], rule_fps[key], CODE_FP)
|
||||
return result
|
||||
with cf.ThreadPoolExecutor(NJ) as ex: res = list(ex.map(fin, keys))
|
||||
shutil.rmtree(w, ignore_errors=True)
|
||||
st = collections.Counter(r[1] for r in res)
|
||||
print(f'着色器 {len(res)}:成功 {st["ok"]},' + ','.join(f'{k} {v}' for k, v in st.items() if k != 'ok'))
|
||||
print(f'前置缓存:命中 {PRE_STATS["hit"]},重出 {PRE_STATS["miss"]}')
|
||||
for reason in ('新键', '规则变', '代码指纹变化:全部重出'):
|
||||
if PRE_STATS[reason]: print(f' {reason} {PRE_STATS[reason]}')
|
||||
print(f'变体缓存:生成 {BF_STATS["generated"]},命中 {BF_STATS["hit"]},重出 {BF_STATS["miss"]},编译 {BF_STATS["compile"]}')
|
||||
for lvl in [k for k in st if k != 'ok']:
|
||||
for e, n in collections.Counter(r[2] for r in res if r[1] == lvl).most_common(10): print(f' [{lvl}] {n:5d} {e}')
|
||||
ok = [r[3] for r in res if r[1] == 'ok']
|
||||
rd = [x for x in ok if x['drv_reads']]
|
||||
print(f'运行时读驱动段的着色器 {len(rd)}(c0 {sum("0" in x["drv_reads"] for x in rd)},c2 {sum("2" in x["drv_reads"] for x in rd)});读到回放层填不了的 {sum(bool(x["drv_unfillable"]) for x in ok)}')
|
||||
for e, n in collections.Counter(u for x in ok for u in x['drv_unfillable']).most_common(15): print(f' 填不了 {n:5d} {e}')
|
||||
SLOTK = {'cbuf', 'samp', 'samp_tex', 'tex', 'img', 'tbuf', 'sbuf', 'ubo_ptr'}
|
||||
noreg = [x for x in ok if any(b['kind'] in SLOTK and b.get('reg') is None for b in x['bindings'])]
|
||||
unk = [x for x in ok if any(b['kind'] == '?' for b in x['bindings'])]
|
||||
print(f'绑定没解出槽号的着色器 {len(noreg)},种类认不出的 {len(unk)}(运行时加载会报红)')
|
||||
for e, n in collections.Counter(f"{b['kind']} {b['msl_name'][:28]}" for x in noreg + unk for b in x['bindings'] if b['kind'] == '?' or (b['kind'] in SLOTK and b.get('reg') is None)).most_common(8): print(f' {n:5d} {e}')
|
||||
nt = collections.Counter(nn.split('(')[0] for x in ok for nn in x['notes'])
|
||||
for e, n in nt.most_common(8): print(f' 查询无 PC 作答 {n:5d} {e}')
|
||||
json.dump([{'key': r[0], 'st': r[1], 'err': r[2]} for r in res], open(os.path.join(out, '_b_build.json'), 'w'), ensure_ascii=False)
|
||||
@@ -0,0 +1,8 @@
|
||||
# 翻译链工具指纹(dmsh_chain.py --update-lock 生成;换工具后重生成并随提交入仓)
|
||||
dmsh_xlate.dll aff3b70cff6bf29e
|
||||
Ryujinx.Graphics.Shader.dll 72886c0b30bc0016
|
||||
Ryujinx.Common.dll 614dced78b44547d
|
||||
xlate_source 1cc46907ca1ee8d0
|
||||
spirv-cross c95d3fc88f6ae5f5
|
||||
metal_macosx Apple metal version 32023.883 (metalfe-32023.883)
|
||||
metal_iphoneos Apple metal version 32023.883 (metalfe-32023.883)
|
||||
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env python3
|
||||
# B 着色器库的翻译链版本(构建结果须只由源码决定)。
|
||||
# 链版本 V = 下列仓内文件内容 + 翻译选项的 sha256 前 12 位:本脚本、dmsh_build.py、dmsh_fetch.py(可读 tile 版本)、dmsh_xlate 源(Program.cs、csproj)、
|
||||
# 映射表(含冲突表)、翻译查询的作答表(dmsh_facts.py 与 nvn/shader_facts.tsv)、iOS 编译口径 ios_metal.py、工具锁 dmsh_chain.lock(Ryujinx 着色器 dll / spirv-cross / metal 编译器的实测指纹)。
|
||||
# 出包(dmsh_build.py)写进 <缓存目录>/b-<V>/,反射 json 记 chain = V;宿主编译时取 nvn/dmsh_chain.h 里的 V,只从 b-<V>/ 加载并逐个核 json。
|
||||
# 用法:dmsh_chain.py 打印 V(缺省选项)
|
||||
# dmsh_chain.py --header 重写 nvn/dmsh_chain.h(改了上列任一文件后要跑,tests/t_chain.sh 核对)
|
||||
# dmsh_chain.py --check-tools 核对实际工具与锁文件一致,不一致报红退出 1
|
||||
# dmsh_chain.py --update-lock 按实际工具重写锁文件(换 Ryujinx / spirv-cross / Xcode 后跑,随提交入仓)
|
||||
# 环境:XLATE_DEBUG / XLATE_REDUCED(与 dmsh_build.py 同义,缺省 1 / 1;非缺省选项得到不同的 V,宿主不会加载)
|
||||
# Translation chain version of the B shader library (the build result must be determined by source alone).
|
||||
# Chain version V = first 12 digits of the sha256 of the contents of the following in-repo files + the translation options: this script, dmsh_build.py, dmsh_fetch.py (readable-tile version), the dmsh_xlate sources (Program.cs, csproj),
|
||||
# the mapping table (including the conflict table), the answer table for translation queries (dmsh_facts.py and nvn/shader_facts.tsv), the iOS compile convention ios_metal.py, the tool lock dmsh_chain.lock (measured fingerprints of the Ryujinx shader dll / spirv-cross / metal compiler).
|
||||
# The build (dmsh_build.py) writes into <cache dir>/b-<V>/ and the reflection json records chain = V; at compile time the host takes V from nvn/dmsh_chain.h, loads only from b-<V>/ and verifies each json.
|
||||
# Usage: dmsh_chain.py print V (default options)
|
||||
# dmsh_chain.py --header rewrite nvn/dmsh_chain.h (run after changing any file listed above; tests/t_chain.sh verifies it)
|
||||
# dmsh_chain.py --check-tools verify that the actual tools match the lock file; on mismatch report a failure and exit 1
|
||||
# dmsh_chain.py --update-lock rewrite the lock file from the actual tools (run after changing Ryujinx / spirv-cross / Xcode; committed to the repo)
|
||||
# Environment: XLATE_DEBUG / XLATE_REDUCED (same meaning as in dmsh_build.py, default 1 / 1; non-default options yield a different V, which the host will not load)
|
||||
import os, sys, hashlib, subprocess
|
||||
DM_ROOT = os.environ.get('DM_ROOT') or os.path.expanduser('~/dm-work') # 工作区根目录(游戏文件、产物、运行现场都在它下面) | Workspace root (game files, build outputs and run artifacts are all under it)
|
||||
HERE = os.path.dirname(os.path.abspath(__file__)); GFX = os.path.dirname(HERE); HOME = os.path.expanduser('~')
|
||||
FILES = ['tools/dmsh_chain.py', 'tools/dmsh_build.py', 'tools/dmsh_fetch.py', 'tools/dmsh_facts.py', 'nvn/shader_facts.tsv', 'tools/dmsh_xlate/Program.cs', 'tools/dmsh_xlate/dmsh_xlate.csproj',
|
||||
'nvn/shader_map.tsv', 'nvn/shader_map.tsv.conflicts.tsv', '../ios/tools/ios_metal.py', 'tools/dmsh_chain.lock']
|
||||
LOCK = os.path.join(HERE, 'dmsh_chain.lock'); HEADER = os.path.join(GFX, 'nvn/dmsh_chain.h')
|
||||
XLATE_DIR = os.path.dirname(os.environ.get('XLATE', f'{DM_ROOT}/build/gfx/dmsh_xlate/dmsh_xlate'))
|
||||
|
||||
def options():
|
||||
return 'debug=%s reduced=%s' % (os.environ.get('XLATE_DEBUG', '1') != '0', os.environ.get('XLATE_REDUCED', '1') == '1')
|
||||
|
||||
def version():
|
||||
h = hashlib.sha256()
|
||||
for f in FILES:
|
||||
h.update(f.encode() + b'\0' + open(os.path.join(GFX, f), 'rb').read() + b'\0')
|
||||
h.update(options().encode())
|
||||
return h.hexdigest()[:12]
|
||||
|
||||
def sha16(p): return hashlib.sha256(open(p, 'rb').read()).hexdigest()[:16]
|
||||
|
||||
def tools_now():
|
||||
"""实际工具指纹:翻译器 dll(含 Ryujinx 着色器库)、spirv-cross、metal 编译器(macOS / iOS) | Actual tool fingerprints: translator dll (including the Ryujinx shader library), spirv-cross, metal compiler (macOS / iOS)"""
|
||||
t = {}
|
||||
for dll in ('dmsh_xlate.dll', 'Ryujinx.Graphics.Shader.dll', 'Ryujinx.Common.dll'): t[dll] = sha16(os.path.join(XLATE_DIR, dll))
|
||||
t['xlate_source'] = subprocess.run([os.path.join(XLATE_DIR, 'dmsh_xlate'), '--source-sha'], capture_output=True, text=True).stdout.strip()
|
||||
sc = subprocess.run(['which', 'spirv-cross'], capture_output=True, text=True).stdout.strip()
|
||||
t['spirv-cross'] = sha16(sc) if sc else 'missing'
|
||||
for sdk in ('macosx', 'iphoneos'):
|
||||
t['metal_' + sdk] = subprocess.run(['xcrun', '-sdk', sdk, 'metal', '--version'], capture_output=True, text=True).stdout.splitlines()[0:1] or ['missing']
|
||||
t['metal_' + sdk] = t['metal_' + sdk][0]
|
||||
return t
|
||||
|
||||
def xlate_source_sha(): # 与 dmsh_xlate --source-sha 同口径:嵌入的 Program.cs 与 csproj 依次拼接 | same convention as dmsh_xlate --source-sha: the embedded Program.cs and csproj concatenated in that order
|
||||
return hashlib.sha256(b''.join(open(os.path.join(HERE, 'dmsh_xlate', f), 'rb').read() for f in ('Program.cs', 'dmsh_xlate.csproj'))).hexdigest()[:16]
|
||||
|
||||
def check_tools():
|
||||
want = dict(l.rstrip('\n').split('\t', 1) for l in open(LOCK) if '\t' in l and not l.startswith('#'))
|
||||
now = tools_now(); bad = [f'{k}:锁 {want.get(k)} / 实际 {v}' for k, v in now.items() if want.get(k) != v]
|
||||
if now['xlate_source'] != xlate_source_sha(): bad.append(f'翻译器不是用仓内源编的:嵌入源 {now["xlate_source"]} / 仓内 {xlate_source_sha()}(重编 dmsh_xlate)')
|
||||
return bad
|
||||
|
||||
if __name__ == '__main__':
|
||||
a = sys.argv[1:]
|
||||
if a == ['--update-lock']:
|
||||
t = tools_now()
|
||||
if t['xlate_source'] != xlate_source_sha(): sys.exit(f'【红】翻译器不是用仓内源编的(嵌入 {t["xlate_source"]} / 仓内 {xlate_source_sha()}):先重编 dmsh_xlate')
|
||||
open(LOCK, 'w').write('# 翻译链工具指纹(dmsh_chain.py --update-lock 生成;换工具后重生成并随提交入仓)\n' + ''.join(f'{k}\t{v}\n' for k, v in t.items()))
|
||||
print('已写', LOCK)
|
||||
elif a == ['--check-tools']:
|
||||
bad = check_tools()
|
||||
for b in bad: print('【红】翻译链工具与锁文件不符:' + b)
|
||||
sys.exit(1 if bad else 0)
|
||||
elif a == ['--header']:
|
||||
open(HEADER, 'w').write('// 生成文件(dm/gfx/tools/dmsh_chain.py --header):本源码树期望的 B 着色器库翻译链版本(缺省选项);宿主只加载 <库目录>/b-<V>/\n'
|
||||
f'#define DMSH_CHAIN "{version()}"\n')
|
||||
print(version())
|
||||
elif not a: print(version())
|
||||
else: sys.exit(__doc__ if __doc__ else '用法见文件头')
|
||||
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
# B 路线全库干转:Switch 着色器包每个变体(按控制段哈希去重)→ Ryujinx ShaderTools 出 SPIR-V → spirv-cross 出 MSL → metal 编译。
|
||||
# 逐级记成败与报错首行,汇总成功率与失败原因分布。干转用 ShaderTools 缺省查询(贴图类型等未按真实作答),只量「能不能转」。
|
||||
# 用法:dmsh_dryrun.py <Switch 包目录> <ShaderTools 可执行> <输出目录> 环境 J=并发
|
||||
# Route B whole-library dry run: every variant in the Switch shader packages (deduplicated by control segment hash) → SPIR-V via Ryujinx ShaderTools → MSL via spirv-cross → metal compile.
|
||||
# Records pass/fail and the first error line at each stage, and summarizes the success rate and the distribution of failure reasons. The dry run uses ShaderTools' default queries (texture types etc. are not answered truthfully) and only measures "can it be converted".
|
||||
# Usage: dmsh_dryrun.py <Switch package dir> <ShaderTools executable> <output dir> Environment J=concurrency
|
||||
import os, re, sys, json, hashlib, subprocess, struct, tempfile, collections, concurrent.futures as cf
|
||||
dm_dir, shtools, out = sys.argv[1:4]
|
||||
os.makedirs(out, exist_ok=True)
|
||||
XC = ['--msl', '--msl-version', '20300', '--msl-argument-buffers', '--msl-texture-buffer-native']
|
||||
|
||||
def records(d):
|
||||
r = [m.start() for m in re.finditer(b'BTCDBTCD', d)]
|
||||
return [d[x:(r[k + 1] if k + 1 < len(r) else len(d))] for k, x in enumerate(r)]
|
||||
|
||||
def first_err(s):
|
||||
for ln in s.splitlines():
|
||||
if 'error' in ln.lower() or 'exception' in ln.lower(): return re.sub(r'/[^ :]*/', '', ln.strip())[:160]
|
||||
return (s.strip().splitlines() or ['(无输出)'])[-1][:160]
|
||||
|
||||
def one(job):
|
||||
key, name, comp, code = job
|
||||
with tempfile.TemporaryDirectory() as w:
|
||||
bi, spv, msl, air = (os.path.join(w, n) for n in ('c.bin', 'c.spv', 'c.metal', 'c.air'))
|
||||
open(bi, 'wb').write(code)
|
||||
r = subprocess.run([shtools, '--target-language', 'Spirv', '--target-api', 'Vulkan'] + (['--compute'] if comp else []) + [bi, spv], capture_output=True, text=True)
|
||||
if r.returncode or not os.path.exists(spv) or os.path.getsize(spv) == 0: return key, name, 'spirv', first_err(r.stdout + r.stderr)
|
||||
r = subprocess.run(['spirv-cross', *XC, spv, '--output', msl], capture_output=True, text=True)
|
||||
if r.returncode: return key, name, 'msl', first_err(r.stdout + r.stderr)
|
||||
r = subprocess.run(['xcrun', '-sdk', 'macosx', 'metal', '-c', msl, '-o', air], capture_output=True, text=True)
|
||||
if r.returncode: return key, name, 'metal', first_err(r.stdout + r.stderr)
|
||||
return key, name, 'ok', ''
|
||||
|
||||
jobs, seen = [], set()
|
||||
for name in sorted(os.listdir(dm_dir)):
|
||||
if not name.endswith('.bin'): continue
|
||||
for b in records(open(os.path.join(dm_dir, name), 'rb').read()):
|
||||
ci = b.find(bytes.fromhex('34127698')); csz = struct.unpack_from('<I', b, 0x28)[0]
|
||||
key = hashlib.sha256(b[ci:ci + csz]).hexdigest()[:16]
|
||||
if key in seen: continue
|
||||
seen.add(key); comp = name.startswith('cs_'); code = b[0x38:ci]
|
||||
jobs.append((key, name, comp, code if comp else code[0x30:]))
|
||||
with cf.ThreadPoolExecutor(int(os.environ.get('J', '8'))) as ex: res = list(ex.map(one, jobs))
|
||||
json.dump(res, open(os.path.join(out, 'dryrun.json'), 'w'), ensure_ascii=False, indent=0)
|
||||
st = collections.Counter(r[2] for r in res)
|
||||
print(f'去重后着色器 {len(res)}:成功 {st["ok"]}({st["ok"] / len(res):.1%}),SPIR-V 失败 {st["spirv"]},MSL 失败 {st["msl"]},metal 编译失败 {st["metal"]}')
|
||||
for lvl in ('spirv', 'msl', 'metal'):
|
||||
c = collections.Counter(r[3] for r in res if r[2] == lvl)
|
||||
for e, n in c.most_common(12): print(f' [{lvl}] {n:5d} {e}')
|
||||
byf = collections.Counter(r[1] for r in res if r[2] == lvl)
|
||||
if byf: print(f' [{lvl}] 按文件:', dict(byf.most_common(12)))
|
||||
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env python3
|
||||
# 翻译查询的作答表 nvn/shader_facts.tsv:每个 Switch 着色器键一行,记翻译器问得到、但 Switch 机器码里读不出的那几项事实——
|
||||
# 贴图 / 图像的维度类型、图像格式、顶点属性与片元输出的分量类型、计算着色器的线程组大小与共享内存字节数。
|
||||
# 这些事实取自与它一一配对的 PC 版着色器的反射(NVN 槽号 = D3D 寄存器号,见 dm/gfx/README.md)。表随仓库,出着色器库只读这张表,
|
||||
# 不需要 PC 版游戏文件;表里没有的键,翻译查询按缺省作答(出包汇总里单列)。
|
||||
# 用法:dmsh_facts.py --freeze 从 PC 反射重出整张表(维护者用;要 PCCACHE 反射目录、PC DXBC 目录与 vkd3d-compiler)
|
||||
# dmsh_facts.py --check 重算一遍与仓内的表逐键比对,不一致报红退出 1(同上,要 PC 侧输入)
|
||||
# dmsh_facts.py 打印表的行数与各项事实的覆盖数
|
||||
# 行格式:键 <TAB> JSON(键按字典序、紧凑写法;同样的输入逐字节同样的表)
|
||||
# Answer table for translation queries, nvn/shader_facts.tsv: one row per Switch shader key, recording the few facts the translator asks for but that cannot be read from the Switch machine code -
|
||||
# dimension type of textures / images, image format, component types of vertex attributes and fragment outputs, thread group size and shared memory bytes of compute shaders.
|
||||
# These facts come from the reflection of the PC shader paired one-to-one with it (NVN slot number = D3D register number, see dm/gfx/README.md). The table ships with the repo; building the shader library reads only this table
|
||||
# and needs no PC game files; for keys not in the table, translation queries are answered with defaults (listed separately in the build summary).
|
||||
# Usage: dmsh_facts.py --freeze regenerate the whole table from PC reflection (for maintainers; needs the PCCACHE reflection dir, the PC DXBC dir and vkd3d-compiler)
|
||||
# dmsh_facts.py --check recompute and compare key by key against the in-repo table; on mismatch report a failure and exit 1 (as above, needs the PC-side inputs)
|
||||
# dmsh_facts.py print the table's row count and the coverage count of each fact
|
||||
# Row format: key <TAB> JSON (keys in lexicographic order, compact form; the same input gives a byte-identical table)
|
||||
import json, os, re, subprocess, sys
|
||||
DM_ROOT = os.environ.get('DM_ROOT') or os.path.expanduser('~/dm-work') # 工作区根目录(游戏文件、产物、运行现场都在它下面) | Workspace root (game files, build outputs and run artifacts are all under it)
|
||||
HERE = os.path.dirname(os.path.abspath(__file__)); HOME = os.path.expanduser('~')
|
||||
TABLE = os.path.join(HERE, '../nvn/shader_facts.tsv'); MAP = os.path.join(HERE, '../nvn/shader_map.tsv')
|
||||
TT = {'texture1d': '1d', 'texture1darray': '1darray', 'texture2d': '2d', 'texture2darray': '2darray', 'texture2dms': '2dms',
|
||||
'texture2dmsarray': '2dmsarray', 'texture3d': '3d', 'texturecube': 'cube', 'texturecubearray': 'cubearray', 'buffer_typed': 'buffer'}
|
||||
CT = {'float': 'float', 'int': 'sint', 'uint': 'uint'}
|
||||
|
||||
def load():
|
||||
"""键 → 事实字典;表不存在返回空字典 | key → fact dict; returns an empty dict if the table does not exist"""
|
||||
if not os.path.exists(TABLE): return {}
|
||||
return {k: json.loads(v) for k, v in (l.rstrip('\n').split('\t', 1) for l in open(TABLE) if l.strip() and not l.startswith('#'))}
|
||||
|
||||
def row(key, facts): return key + '\t' + json.dumps(facts, sort_keys=True, separators=(',', ':'), ensure_ascii=False) + '\n'
|
||||
|
||||
def from_pc(pj, stage, dxbc_asm):
|
||||
"""PC 反射 json(pj)+ 计算着色器的 DXBC 反汇编文本(没有给 None)→ 事实字典 | PC reflection json (pj) + DXBC disassembly text of the compute shader (None if absent) → fact dict"""
|
||||
f = {'tex': {}, 'img': {}, 'attr': {}, 'fout': {}}
|
||||
for b in pj['bindings']:
|
||||
if b['kind'] == 't' and b['type'] in TT: f['tex'][str(b['reg'])] = TT[b['type']]
|
||||
if b['kind'] == 'u' and b['type'] in TT:
|
||||
f['img'][str(b['reg'])] = {'type': TT[b['type']], 'fmt': 'R32Uint' if 'uint' in (b.get('msl_type') or '') else 'R16G16B16A16Float'}
|
||||
for v in pj.get('vertex_inputs') or []: f['attr'][str(v.get('location', v.get('index')))] = CT.get(v.get('component_type'), 'float')
|
||||
for o in pj.get('fragment_outputs') or []: f['fout'][str(o.get('index', 0))] = CT.get(o.get('component_type'), 'float')
|
||||
if pj.get('threadgroup_size'): f['local'] = pj['threadgroup_size']
|
||||
if stage == 'cs': # 共享内存:PC DXBC 的 groupshared 声明求和(翻译器缺省 48 KB,超 Metal 上限 32 KB) | shared memory: sum of the groupshared declarations in the PC DXBC (the translator default is 48 KB, over Metal's 32 KB limit)
|
||||
asm = dxbc_asm or ''
|
||||
n = sum(int(m.group(1)) for m in re.finditer(r'dcl_tgsm_raw\s+g\d+,\s*(\d+)', asm)) + \
|
||||
sum(int(m.group(1)) * int(m.group(2)) for m in re.finditer(r'dcl_tgsm_structured\s+g\d+,\s*(\d+),\s*(\d+)', asm))
|
||||
f['shared'] = (n + 15) // 16 * 16
|
||||
if dxbc_asm is None: f['pc_missing'] = True
|
||||
return f
|
||||
|
||||
def pairs():
|
||||
"""映射表(含冲突表的改判)→ {键: (配对的 PC 名, 阶段)} | Mapping table (with the conflict table's overrides) → {key: (paired PC name, stage)}"""
|
||||
pc_of, stage_of = {}, {}
|
||||
for ln in open(MAP):
|
||||
c = ln.rstrip('\n').split('\t')
|
||||
if len(c) > 4 and c[0].endswith('.bin'): pc_of.setdefault(c[3], c[4]); stage_of.setdefault(c[3], c[0][:2])
|
||||
if len(c) > 4 and c[0].startswith('main.rodata@'): pc_of.setdefault(c[3], c[4]); stage_of[c[3]] = {'顶点': 'vs', '像素': 'ps'}[c[2]]
|
||||
for ln in open(MAP + '.conflicts.tsv'):
|
||||
c = ln.rstrip('\n').split('\t')
|
||||
if len(c) > 1 and not ln.startswith('#') and not ln.startswith('dm_') and c[0] in pc_of: pc_of[c[0]] = c[1]
|
||||
return {k: (pc_of[k], stage_of[k]) for k in pc_of}
|
||||
|
||||
def recompute():
|
||||
pcc = os.environ.get('PCCACHE', f'{DM_ROOT}/build/cache/metal_shader_cache')
|
||||
dxdirs = os.environ.get('PCDXBC', f'{DM_ROOT}/build/ios/dxbc_all_0930:{DM_ROOT}/data/d3d12_study/shaders').split(':')
|
||||
vk = os.environ.get('VKD3D', f'{DM_ROOT}/build/vkd3d/inst/bin/vkd3d-compiler')
|
||||
if not os.path.isdir(pcc): sys.exit(f'【红】没有 PC 反射目录 {pcc}(PCCACHE=)')
|
||||
out, missing = {}, 0
|
||||
for key, (pc, stage) in sorted(pairs().items()):
|
||||
pp = os.path.join(pcc, pc + '.json')
|
||||
if not os.path.exists(pp): missing += 1; continue # 无配对 PC 反射:不进表,查询按缺省 | no paired PC reflection: not entered in the table, queries use defaults
|
||||
asm = None
|
||||
if stage == 'cs':
|
||||
dx = next((p for d in dxdirs for p in (os.path.join(d, pc + '.dxbc'), os.path.join(d, pc[:12] + '.dxbc')) if os.path.exists(p)), None)
|
||||
if dx: asm = subprocess.run([vk, '-x', 'dxbc-tpf', '-b', 'd3d-asm', dx], capture_output=True, text=True).stdout
|
||||
out[key] = from_pc(json.load(open(pp)), stage, asm)
|
||||
return out, missing
|
||||
|
||||
if __name__ == '__main__':
|
||||
a = sys.argv[1:]
|
||||
if a == ['--freeze']:
|
||||
t, missing = recompute()
|
||||
open(TABLE, 'w').write('# 翻译查询的作答表(dmsh_facts.py --freeze 生成,勿手改):键 <TAB> 事实 JSON\n' + ''.join(row(k, t[k]) for k in sorted(t)))
|
||||
print(f'已写 {TABLE}:{len(t)} 键;无配对 PC 反射、未进表 {missing}')
|
||||
elif a == ['--check']:
|
||||
t, missing = recompute(); have = load()
|
||||
bad = sorted(k for k in set(t) | set(have) if t.get(k) != have.get(k))
|
||||
for k in bad[:10]: print(f'【红】{k}:表 {have.get(k)} / 重算 {t.get(k)}')
|
||||
print(f'逐键比对 {len(set(t) | set(have))}:不一致 {len(bad)};无配对 PC 反射 {missing}'); sys.exit(1 if bad else 0)
|
||||
elif not a:
|
||||
t = load(); print(f'{len(t)} 键:' + ','.join(f'{n} {sum(bool(f.get(n)) for f in t.values())}' for n in ('tex', 'img', 'attr', 'fout', 'local', 'shared', 'pc_missing')))
|
||||
else: sys.exit('用法见文件头')
|
||||
@@ -0,0 +1,64 @@
|
||||
# 片元着色器的「可读 tile」版本(合并 B 第 2 步):同一通道里,后一次绘制本像素采样前一次绘制写的颜色附件时,
|
||||
# 改成直接读 tile 内的颜色(framebuffer fetch),两个渲染通道合成一个,中间附件不必为被采样而落主存再读回。
|
||||
# 离线出包、运行时只做函数常量特化(不编译源码)。用法:variant(msl, bindings, om_only_ok=False) → (新 MSL, 元数据) 或 (None, 原因)
|
||||
# 函数常量编号:FX_i(第 i 次可改采样读第几号颜色,-1 = 照常采样)= i;FB_k(启用第 k 号颜色输入)= 32 + k;
|
||||
# OM_j_k(第 j 个输出写到第 k 号附件)= 64 + 8 j + k
|
||||
# 可改的采样:2D 浮点贴图的 .sample(采样器, select(_N, float2(0.0), isnan(_N))),且 _N = float2(in.m_X.x, in.m_X.y)(插值输出原样);
|
||||
# 是否真在本像素取纹素由运行时证明(顶点 uv 与位置的对应、贴图尺寸 = 目标尺寸),证不出就用原版本
|
||||
# "Readable-tile" version of a fragment shader (merge B step 2): within one pass, when a later draw samples, at its own pixel, a color attachment written by an earlier draw,
|
||||
# it is changed to read the color directly from the tile (framebuffer fetch); the two render passes become one, and the intermediate attachment need not be stored to main memory and loaded back just to be sampled.
|
||||
# Built offline; at runtime only function-constant specialization is done (no source compilation). Usage: variant(msl, bindings, om_only_ok=False) → (new MSL, metadata) or (None, reason)
|
||||
# Function constant numbering: FX_i (which color index the i-th rewritable sample reads, -1 = sample as usual) = i; FB_k (enable color input k) = 32 + k;
|
||||
# OM_j_k (the j-th output writes to attachment k) = 64 + 8 j + k
|
||||
# Rewritable samples: .sample(sampler, select(_N, float2(0.0), isnan(_N))) on a 2D float texture, where _N = float2(in.m_X.x, in.m_X.y) (interpolated output unchanged);
|
||||
# whether the texel is really fetched at this pixel is proven at runtime (correspondence between vertex uv and position, texture size = target size); if it cannot be proven, the original version is used
|
||||
import re
|
||||
|
||||
NFB = 8
|
||||
|
||||
def variant(msl, bindings, om_only_ok=False):
|
||||
tex = {m.group(1) for m in re.finditer(r'texture2d<float> (\w+) \[\[id\(\d+\)\]\];', msl)}
|
||||
locn = {m.group(1): int(m.group(2)) for m in re.finditer(r'float4 (m_\d+) \[\[user\(locn(\d+)\)\]\];', msl.split('struct main0_in', 1)[-1].split('};', 1)[0])}
|
||||
reg = {b['msl_name']: b['reg'] for b in bindings if b.get('kind') == 'tex' and b.get('msl_name') and b.get('reg') is not None}
|
||||
pat = re.compile(r'spvDescriptorSet0\.(\w+)\.sample\(spvDescriptorSet0\.(\w+)Smplr, select\((_\d+), float2\(0\.0\), isnan\(\3\)\)\)')
|
||||
calls, out_parts, pos = [], [], 0
|
||||
for m in pat.finditer(msl):
|
||||
member, var = m.group(1), m.group(3)
|
||||
if member not in tex or member != m.group(2) or member not in reg: continue
|
||||
d = re.search(r'float2 %s = float2\((_\d+), (_\d+)\);' % var, msl)
|
||||
a = d and re.search(r'float %s = in\.(m_\d+)\.x;' % d.group(1), msl); b = d and re.search(r'float %s = in\.(m_\d+)\.y;' % d.group(2), msl)
|
||||
if not (a and b) or a.group(1) != b.group(1) or a.group(1) not in locn: continue
|
||||
i = len(calls)
|
||||
if i >= 32: break
|
||||
sel = ''.join(f'FX_{i} == {k} ? fb{k} : ' for k in range(NFB))
|
||||
out_parts.append(msl[pos:m.start()]); out_parts.append(f'({sel}{m.group(0)})'); pos = m.end()
|
||||
calls.append({'fc': i, 'tex_reg': reg[member], 'varying_locn': locn[a.group(1)]})
|
||||
if not calls and not om_only_ok:
|
||||
return None, '没有可改的采样'
|
||||
# 混用的槽:同一贴图还有别的(不可改的)用法——运行时不得把这张贴图改成读 tile(改了的几次与没改的读到的会不是同一份数据)
|
||||
# Mixed-use slots: the same texture also has other (non-rewritable) uses - at runtime this texture must not be switched to tile reads (the rewritten reads and the unrewritten ones would not see the same data)
|
||||
conv = {}
|
||||
for c in calls: conv[c['tex_reg']] = conv.get(c['tex_reg'], 0) + 1
|
||||
mixed = sorted({reg[mb] for mb in reg if mb in tex and msl.count(f'spvDescriptorSet0.{mb}.') > conv.get(reg[mb], 0)})
|
||||
body = ''.join(out_parts) + msl[pos:]
|
||||
om = re.search(r'struct main0_out\s*\{(.*?)\};', body, re.S)
|
||||
if not om: return None, '没有输出结构'
|
||||
outs = [(t, n, int(c)) for t, n, c in re.findall(r'(\w+) (m_\d+) \[\[color\((\d+)\)\]\];', om.group(1))]
|
||||
if not outs or len(outs) > 4 or re.sub(r'\w+ m_\d+ \[\[color\(\d+\)\]\];', '', om.group(1)).strip(): return None, '输出结构不是单纯的颜色输出(或超过 4 个)'
|
||||
members = ''.join(f' {t} {n}_at{k} [[color({k}), function_constant(OM_{j}_{k})]];\n' for j, (t, n, c) in enumerate(outs) for k in range(NFB))
|
||||
body = body[:om.start(1)] + '\n' + members + body[om.end(1):]
|
||||
consts = ''.join(f'constant int FX_{c["fc"]} [[function_constant({c["fc"]})]];\n' for c in calls) + \
|
||||
''.join(f'constant bool FB_{k} [[function_constant({32 + k})]];\n' for k in range(NFB)) + \
|
||||
''.join(f'constant bool OM_{j}_{k} [[function_constant({64 + 8 * j + k})]];\n' for j in range(len(outs)) for k in range(NFB))
|
||||
body = body.replace('using namespace metal;\n', 'using namespace metal;\n\n' + consts, 1)
|
||||
i0 = body.find('fragment main0_out main0(')
|
||||
i1 = body.find(')\n{', i0) if i0 >= 0 else -1 # 签名结尾:右括号后紧跟换行与左花括号(参数属性里有 [[buffer(0)]] 等括号) | end of signature: closing parenthesis immediately followed by a newline and an opening brace (parameter attributes contain brackets such as [[buffer(0)]])
|
||||
if i0 < 0 or i1 < 0: return None, '主函数签名认不出'
|
||||
body = body[:i1] + ''.join(f', float4 fb{k} [[color({k}), function_constant(FB_{k})]]' for k in range(NFB)) + body[i1:]
|
||||
decl = ''.join(f' {t} spv_o_{n} = {t}(0);\n' for t, n, c in outs)
|
||||
body = body.replace(' main0_out out = {};\n', ' main0_out out = {};\n' + decl, 1)
|
||||
for t, n, c in outs: body = body.replace(f'out.{n}', f'spv_o_{n}')
|
||||
put = ''.join(f' if (OM_{j}_{k}) out.{n}_at{k} = spv_o_{n};\n' for j, (t, n, c) in enumerate(outs) for k in range(NFB))
|
||||
if body.count(' return out;\n') < 1: return None, '找不到 return out'
|
||||
body = body.replace(' return out;\n', put + ' return out;\n')
|
||||
return body, {'calls': calls, 'mixed_regs': mixed, 'outputs': [{'color': c, 'type': t} for t, n, c in outs]}
|
||||
@@ -0,0 +1,143 @@
|
||||
// Switch 原版着色器(Maxwell 机器码)→ SPIR-V(Ryujinx.Graphics.Shader 翻译器),供 B 路线离线出 metallib。
|
||||
// 与 Ryujinx.ShaderTools 的区别:翻译器的「查询」按真实情况作答,而不是一律缺省值——
|
||||
// 贴图类型 / 图像格式 / 顶点属性类型 / 片元输出类型 / 计算线程组大小取自作业文件(由映射表配对的 PC 反射给出,同槽号 = 同资源);
|
||||
// 窗口原点左上、深度 0..1(游戏实测 nvnDeviceSetWindowOriginMode / SetDepthMode)。
|
||||
// 用法:dmsh_xlate <作业.json> <输出目录>
|
||||
// 作业:[{ "key", "stage": "vs|ps|cs", "code": 机器码文件(图形 = 0x50 字节 SPH + 指令,计算 = 指令),
|
||||
// "tex": { "槽": "2d|2darray|cube|cubearray|3d|buffer|1d|1darray|2dms|2dmsarray", … }, "img": { "槽": { "type", "fmt" } },
|
||||
// "attr": { "位置": "float|sint|uint" }, "fout": { "目标": "float|sint|uint" }, "local": [x, y, z] }]
|
||||
// 输出:<key>.spv 与 <key>.res.json(存储缓冲槽在 c0 的偏移等,贴图句柄 → 槽号的解码在出 metallib 的脚本里做)
|
||||
// Original Switch shaders (Maxwell machine code) → SPIR-V (the Ryujinx.Graphics.Shader translator), for route B's offline metallib build.
|
||||
// Difference from Ryujinx.ShaderTools: the translator's "queries" are answered truthfully rather than always with defaults -
|
||||
// texture type / image format / vertex attribute type / fragment output type / compute thread group size come from the job file (given by the PC reflection paired via the mapping table; same slot number = same resource);
|
||||
// window origin upper-left, depth 0..1 (measured from the game: nvnDeviceSetWindowOriginMode / SetDepthMode).
|
||||
// Usage: dmsh_xlate <job.json> <output dir>
|
||||
// Job: [{ "key", "stage": "vs|ps|cs", "code": machine code file (graphics = 0x50-byte SPH + instructions, compute = instructions),
|
||||
// "tex": { "slot": "2d|2darray|cube|cubearray|3d|buffer|1d|1darray|2dms|2dmsarray", ... }, "img": { "slot": { "type", "fmt" } },
|
||||
// "attr": { "location": "float|sint|uint" }, "fout": { "target": "float|sint|uint" }, "local": [x, y, z] }]
|
||||
// Output: <key>.spv and <key>.res.json (offsets of storage buffer slots in c0, etc.; decoding texture handle → slot number is done in the script that builds the metallib)
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Graphics.Shader;
|
||||
using Ryujinx.Graphics.Shader.Translation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
static class SwshXlate
|
||||
{
|
||||
const int TexBase = 0x168, SampBase = 0x568; // NVN 分离贴图 / 采样器句柄在 c[2] 的字节基址(每槽 8 字节;dm/gfx/tools/maxwell_refs.py 全量实测) | byte base of NVN separate texture / sampler handles in c[2] (8 bytes per slot; full measurement in dm/gfx/tools/maxwell_refs.py)
|
||||
|
||||
sealed class Accessor : IGpuAccessor
|
||||
{
|
||||
readonly byte[] _code; readonly JsonObject _job; int _binding = 1; public readonly List<string> Notes = new();
|
||||
readonly byte[] _c1;
|
||||
public Accessor(byte[] code, JsonObject job) { _code = code; _job = job; _c1 = job["c1"] is JsonNode h ? Convert.FromHexString((string)h) : Array.Empty<byte>(); }
|
||||
// c1 常数段(着色器包控制段前 0x100 字节):间接跳转 BRX 的跳转表在这里(LDC c[1]);不提供时翻译器解不出跳转目标、控制流出错(粒子着色器死循环)
|
||||
// c1 constant segment (the 0x100 bytes before the control segment in the shader package): the jump table of indirect jump BRX lives here (LDC c[1]); without it the translator cannot resolve jump targets and control flow goes wrong (particle shaders loop forever)
|
||||
public uint ConstantBuffer1Read(int offset) { if (offset >= 0 && offset + 4 <= _c1.Length) return BitConverter.ToUInt32(_c1, offset); Notes.Add($"c1 读越界 +{offset:X}(c1 长 {_c1.Length})"); return 0; }
|
||||
// 全部资源放进第 0 组,各占不同绑定号(spirv-cross 出成一个参数缓冲);常量段号 index 的缓冲由翻译器给 binding = index+1 的惯例不依赖
|
||||
// All resources go into set 0, each with a distinct binding number (spirv-cross emits them as one argument buffer); the translator's convention of giving the buffer of constant segment number index binding = index+1 is not relied on
|
||||
public SetBindingPair CreateConstantBufferBinding(int index) => new(0, _binding++);
|
||||
public SetBindingPair CreateImageBinding(int count, bool isBuffer) { int b = _binding; _binding += count; return new(0, b); }
|
||||
public SetBindingPair CreateStorageBufferBinding(int index) => new(0, _binding++);
|
||||
public SetBindingPair CreateTextureBinding(int count, bool isBuffer) { int b = _binding; _binding += count; return new(0, b); }
|
||||
public ReadOnlySpan<ulong> GetCode(ulong address, int minimumSize) => MemoryMarshal.Cast<byte, ulong>(new ReadOnlySpan<byte>(_code)[(int)address..]);
|
||||
public int QuerySamplerArrayLengthFromPool() => 32;
|
||||
public int QueryTextureArrayLengthFromBuffer(int slot) => 32;
|
||||
public int QueryTextureArrayLengthFromPool() => 32;
|
||||
|
||||
string Get(string table, int slot) => _job[table] is JsonObject t && t[slot.ToString()] is JsonNode n ? (n is JsonObject o ? (string)o["type"] : (string)n) : null;
|
||||
int TexSlot(int handle, int cbufSlot)
|
||||
{
|
||||
(int off0, _, _) = TextureHandle.UnpackOffsets(handle);
|
||||
int bytes = off0 * 4;
|
||||
return (cbufSlot < 0 || (cbufSlot & 0xffff) == 2) && bytes >= TexBase && bytes < SampBase && (bytes - TexBase) % 8 == 0 ? (bytes - TexBase) / 8 : -1;
|
||||
}
|
||||
public SamplerType QuerySamplerType(int handle, int cbufSlot = -1)
|
||||
{
|
||||
int slot = TexSlot(handle, cbufSlot);
|
||||
string t = slot >= 0 ? Get("tex", slot) ?? Get("img", slot) : null;
|
||||
if (t == null) { Notes.Add($"贴图句柄 {handle:X}(常量段 {cbufSlot},槽 {slot})无 PC 类型,按 2D"); return SamplerType.Texture2D; }
|
||||
return t switch
|
||||
{
|
||||
"1d" => SamplerType.Texture1D, "1darray" => SamplerType.Texture1D | SamplerType.Array,
|
||||
"buffer" => SamplerType.TextureBuffer, "2d" => SamplerType.Texture2D, "2darray" => SamplerType.Texture2D | SamplerType.Array,
|
||||
"2dms" => SamplerType.Texture2D | SamplerType.Multisample, "2dmsarray" => SamplerType.Texture2D | SamplerType.Multisample | SamplerType.Array,
|
||||
"3d" => SamplerType.Texture3D, "cube" => SamplerType.TextureCube, "cubearray" => SamplerType.TextureCube | SamplerType.Array,
|
||||
_ => SamplerType.Texture2D,
|
||||
};
|
||||
}
|
||||
public TextureFormat QueryTextureFormat(int handle, int cbufSlot = -1)
|
||||
{
|
||||
int slot = TexSlot(handle, cbufSlot);
|
||||
string f = _job["img"] is JsonObject t && slot >= 0 && t[slot.ToString()] is JsonObject o ? (string)o["fmt"] : null;
|
||||
if (f == null) { Notes.Add($"图像句柄 {handle:X} 槽 {slot} 无 PC 格式,按 R8G8B8A8Unorm"); return TextureFormat.R8G8B8A8Unorm; }
|
||||
return Enum.TryParse(f, true, out TextureFormat tf) ? tf : TextureFormat.R8G8B8A8Unorm;
|
||||
}
|
||||
int Local(int i) => _job["local"] is JsonArray a && a.Count > i ? (int)a[i] : 1;
|
||||
public int QueryComputeLocalSizeX() => Local(0);
|
||||
public int QueryComputeLocalSizeY() => Local(1);
|
||||
public int QueryComputeLocalSizeZ() => Local(2);
|
||||
public int QueryComputeSharedMemorySize() => _job["shared"] is JsonNode n ? (int)n : 0; // 配对 PC 的 groupshared 声明之和 | sum of the paired PC shader's groupshared declarations
|
||||
static AttributeType Attr(string s) => s switch { "sint" => AttributeType.Sint, "uint" => AttributeType.Uint, _ => AttributeType.Float };
|
||||
public GpuGraphicsState QueryGraphicsState()
|
||||
{
|
||||
Array32<AttributeType> attr = default; Array8<AttributeType> fout = default;
|
||||
if (_job["attr"] is JsonObject a) foreach (var kv in a) attr[int.Parse(kv.Key)] = Attr((string)kv.Value);
|
||||
if (_job["fout"] is JsonObject f) foreach (var kv in f) fout[int.Parse(kv.Key)] = Attr((string)kv.Value);
|
||||
return new GpuGraphicsState(false, InputTopology.Triangles, false, TessPatchType.Triangles, TessSpacing.EqualSpacing,
|
||||
false, false, false, false /* 深度 0..1 | depth 0..1 */, false, 1f, AlphaTestOp.Always, 0f, attr, false, fout, false,
|
||||
false /* 不做 Y 取反 | no Y flip */, true /* 原点左上 | origin upper-left */, false);
|
||||
}
|
||||
public bool QueryHostSupportsTextureShadowLod() => true;
|
||||
// 作业 reduced = true:放宽精度——翻译器只给强制精确的运算打 NoContraction(缺省全部打:保持 Maxwell 分开舍入的逐位结果,代价是 MSL 里大量禁优化的 spvFMul 等)
|
||||
// Job reduced = true: relaxed precision - the translator marks NoContraction only on operations that must be exact (the default marks all: keeps the bit-exact results of Maxwell's separate rounding, at the cost of many optimization-disabled spvFMul etc. in the MSL)
|
||||
public bool QueryHostReducedPrecision() => _job["reduced"] is JsonNode n && (bool)n;
|
||||
}
|
||||
|
||||
static int Main(string[] args)
|
||||
{
|
||||
if (args.Length == 1 && args[0] == "--source-sha") // 嵌入的 Program.cs + csproj 的 sha256 前 16 位(dmsh_chain.py 同口径) | first 16 digits of the sha256 of the embedded Program.cs + csproj (same convention as dmsh_chain.py)
|
||||
{
|
||||
var asm = typeof(SwshXlate).Assembly; var ms = new MemoryStream();
|
||||
foreach (var n in new[] { "src0", "src1" }) asm.GetManifestResourceStream(n).CopyTo(ms);
|
||||
Console.WriteLine(Convert.ToHexString(System.Security.Cryptography.SHA256.HashData(ms.ToArray()))[..16].ToLowerInvariant());
|
||||
return 0;
|
||||
}
|
||||
var jobs = JsonNode.Parse(File.ReadAllText(args[0])).AsArray(); string outDir = args[1]; Directory.CreateDirectory(outDir);
|
||||
int ok = 0, bad = 0;
|
||||
foreach (JsonObject job in jobs)
|
||||
{
|
||||
string key = (string)job["key"];
|
||||
try
|
||||
{
|
||||
byte[] code = File.ReadAllBytes((string)job["code"]);
|
||||
var acc = new Accessor(code, job);
|
||||
// 作业 debug = false:关 DebugMode(DebugMode 会跳过 AST 优化器,产物满是临时变量;不改语义)
|
||||
// Job debug = false: turn off DebugMode (DebugMode skips the AST optimizer and the output is full of temporaries; semantics unchanged)
|
||||
var flags = (job["debug"] is JsonNode dbg && !(bool)dbg ? 0 : TranslationFlags.DebugMode) | ((string)job["stage"] == "cs" ? TranslationFlags.Compute : 0);
|
||||
var ctx = Translator.CreateContext(0, acc, new TranslationOptions(TargetLanguage.Spirv, TargetApi.Vulkan, flags));
|
||||
ShaderProgram p = ctx.Translate();
|
||||
File.WriteAllBytes(Path.Combine(outDir, key + ".spv"), p.BinaryCode);
|
||||
var res = new JsonObject
|
||||
{
|
||||
["key"] = key, ["stage"] = (string)job["stage"], ["notes"] = new JsonArray(acc.Notes.ConvertAll(n => (JsonNode)n).ToArray()),
|
||||
["cbufs"] = new JsonArray(), ["sbufs"] = new JsonArray(), ["textures"] = new JsonArray(), ["images"] = new JsonArray(),
|
||||
["uses_frag_coord"] = p.Info.UsesFragCoord, ["frag_out_map"] = p.Info.FragmentOutputMap,
|
||||
};
|
||||
foreach (var b in p.Info.CBuffers) res["cbufs"].AsArray().Add(new JsonObject { ["binding"] = b.Binding, ["slot"] = b.Slot });
|
||||
foreach (var b in p.Info.SBuffers) res["sbufs"].AsArray().Add(new JsonObject { ["binding"] = b.Binding, ["slot"] = b.Slot, ["cb_slot"] = b.SbCbSlot, ["cb_offset"] = b.SbCbOffset, ["flags"] = (int)b.Flags });
|
||||
foreach (var (list, name) in new[] { (p.Info.Textures, "textures"), (p.Info.Images, "images") })
|
||||
foreach (var t in list) res[name].AsArray().Add(new JsonObject { ["binding"] = t.Binding, ["type"] = (int)t.Type, ["format"] = t.Format.ToString(), ["cbuf_slot"] = t.CbufSlot, ["handle"] = t.HandleIndex, ["array"] = t.ArrayLength, ["separate"] = t.Separate, ["flags"] = (int)t.Flags });
|
||||
File.WriteAllText(Path.Combine(outDir, key + ".res.json"), res.ToJsonString(new JsonSerializerOptions { WriteIndented = true }));
|
||||
ok++;
|
||||
}
|
||||
catch (Exception e) { bad++; Console.Error.WriteLine($"【红】{key}:{e.GetType().Name}:{e.Message.Split('\n')[0]}"); if (Environment.GetEnvironmentVariable("DMSH_STACK") != null) Console.Error.WriteLine(e.StackTrace); }
|
||||
}
|
||||
Console.WriteLine($"翻译 {ok} 成功,{bad} 失败");
|
||||
return bad == 0 ? 0 : 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<!-- Switch 着色器 → SPIR-V 翻译工具。引用仓内收录的 Ryujinx 着色器翻译库源码(dm/third_party/ryujinx);可用 -p:RyuSrc=<目录> 指到别的一份。 -->
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>disable</Nullable>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<RyuSrc Condition="'$(RyuSrc)' == ''">$(MSBuildThisFileDirectory)../../../third_party/ryujinx</RyuSrc>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(RyuSrc)/src/Ryujinx.Graphics.Shader/Ryujinx.Graphics.Shader.csproj" />
|
||||
<ProjectReference Include="$(RyuSrc)/src/Ryujinx.Common/Ryujinx.Common.csproj" />
|
||||
</ItemGroup>
|
||||
<!-- 嵌入自身源码:参数 source-sha 报出,dmsh_chain.py 核对翻译器是用仓内源编的 -->
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Program.cs" LogicalName="src0" />
|
||||
<EmbeddedResource Include="dmsh_xlate.csproj" LogicalName="src1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env python3
|
||||
# 从 nvn.h 的 PFNNVN*PROC 原型生成宿主侧签名检查表 nvn_protos.h。
|
||||
# 苹果 arm64 与 Switch 的 AAPCS64 差异:<32 位整型参数苹果要求调用方扩展、Switch 不扩展 ⇒
|
||||
# NVNboolean 参数在宿主签名里一律换成 uint32_t(实现里只看低 8 位);其余 <32 位参数出现即报红。
|
||||
# 栈传参(>8 个整型或 >8 个浮点参数)两边打包规则不同 ⇒ 出现即报红。
|
||||
# 用法:gen_protos.py <nvn.h> <名字表(一行一个, 加载顺序)> <输出 .h>
|
||||
# Generate the host-side signature check table nvn_protos.h from the PFNNVN*PROC prototypes in nvn.h.
|
||||
# Difference between Apple arm64 and Switch AAPCS64: for integer arguments narrower than 32 bits, Apple requires the caller to extend them and Switch does not ⇒
|
||||
# NVNboolean parameters are always replaced with uint32_t in the host signature (the implementation only looks at the low 8 bits); any other <32-bit parameter is reported as a failure on sight.
|
||||
# Stack-passed arguments (>8 integer or >8 floating-point parameters) are packed differently on the two sides ⇒ reported a failure on sight.
|
||||
# Usage: gen_protos.py <nvn.h> <name table (one per line, in load order)> <output .h>
|
||||
import re, sys
|
||||
|
||||
hdr, names_path, out = sys.argv[1:4]
|
||||
src = open(hdr).read()
|
||||
protos = {}
|
||||
for m in re.finditer(r'typedef\s+([\w\s\*]+?)\s*\(\*PFNNVN(\w+)PROC\)\s*\(([^;]*?)\);', src, re.S):
|
||||
ret, key, args = m.group(1).strip(), m.group(2), ' '.join(m.group(3).split())
|
||||
protos[key] = (ret, [a.strip() for a in args.split(',')] if args.strip() not in ('', 'void') else [])
|
||||
|
||||
FP = re.compile(r'^(const\s+)?(float|double)$')
|
||||
SMALL = re.compile(r'^(const\s+)?(uint8_t|int8_t|uint16_t|int16_t|char|unsigned char|short|unsigned short|bool)$')
|
||||
names = [l.strip() for l in open(names_path) if l.strip()]
|
||||
lines = ['// 由 dm/gfx/tools/gen_protos.py 生成,勿手改。NVNboolean 参数已换成 uint32_t。', '#pragma once', '#include "nvn.h"', '']
|
||||
red, missing = [], []
|
||||
for n in names:
|
||||
key = n[3:].upper()
|
||||
if key not in protos:
|
||||
missing.append(n)
|
||||
continue
|
||||
ret, args = protos[key]
|
||||
gp = fp = 0
|
||||
conv = []
|
||||
for a in args:
|
||||
t = re.sub(r'\s+\w+$', '', a) if not a.endswith('*') and len(a.split()) > 1 and a.split()[-1] not in ('int', 'float', 'double', 'char') and not a.split()[-1].endswith('_t') and not a.split()[-1].startswith(('NVN', 'PFN')) else a
|
||||
t = t.strip()
|
||||
if FP.match(t): fp += 1
|
||||
else: gp += 1
|
||||
if t == 'NVNboolean': t = 'uint32_t'
|
||||
elif SMALL.match(t): red.append(f'{n}: <32 位参数 {t}')
|
||||
conv.append(t)
|
||||
if gp > 8 or fp > 8: red.append(f'{n}: 栈传参 gp={gp} fp={fp}')
|
||||
lines.append(f'typedef {ret} (*NVNT_{n})({", ".join(conv) if conv else "void"});')
|
||||
lines.append('')
|
||||
lines.append('// 头文件里没有原型的名字(新版接口):只能接记名桩')
|
||||
for n in missing: lines.append(f'// {n}')
|
||||
open(out, 'w').write('\n'.join(lines) + '\n')
|
||||
print(f'原型 {len(names) - len(missing)} / 名字 {len(names)};无原型 {len(missing)};报红 {len(red)}')
|
||||
for r in red: print(' 红', r)
|
||||
|
||||
# 计数跳板:每个名字一个静态汇编入口 _nvnth_<i>,原子累加 nvn_slot[i].cnt 后跳到 nvn_slot[i].fn。
|
||||
# 不在运行期生成代码(iOS 无 JIT),x16/x17 是过程间暂存寄存器,跳板可自由使用。
|
||||
# 跳进目标时 x16 仍指向本槽:未实现桩 nvn_unimpl_entry 据此反查名字。
|
||||
# Counting trampolines: one static assembly entry _nvnth_<i> per name, which atomically increments nvn_slot[i].cnt and then jumps to nvn_slot[i].fn.
|
||||
# No code is generated at runtime (iOS has no JIT); x16/x17 are intra-procedure-call scratch registers, so the trampoline may use them freely.
|
||||
# On entry to the target, x16 still points to this slot: the unimplemented stub nvn_unimpl_entry uses it to look the name back up.
|
||||
th = out.replace('nvn_protos.h', 'nvn_thunks.S')
|
||||
S = ['// 由 dm/gfx/tools/gen_protos.py 生成,勿手改。',
|
||||
'// 计数用 LSE 原子 stadd(ARMv8.1;Apple A12 / M1 起全部支持):下一行让本文件不依赖编译器的 -mcpu 基线。',
|
||||
' .arch_extension lse', ' .text', ' .p2align 2']
|
||||
for i, n in enumerate(names):
|
||||
S += [f' .globl _nvnth_{i}', f'_nvnth_{i}:',
|
||||
' adrp x16, _nvn_slot@PAGE', ' add x16, x16, _nvn_slot@PAGEOFF',
|
||||
f' mov x17, #{i * 16}', ' add x16, x16, x17',
|
||||
' mov x17, #1', ' stadd x17, [x16]', ' ldr x17, [x16, #8]', ' br x17']
|
||||
S += [' .data', ' .p2align 3', ' .globl _nvn_thunk', '_nvn_thunk:'] + [f' .quad _nvnth_{i}' for i in range(len(names))]
|
||||
S += [' .globl _nvn_names', '_nvn_names:'] + [f' .quad Ln{i}' for i in range(len(names))]
|
||||
S += [' .cstring'] + [f'Ln{i}: .asciz "{n}"' for i, n in enumerate(names)]
|
||||
open(th, 'w').write('\n'.join(S) + '\n')
|
||||
hn = out.replace('nvn_protos.h', 'nvn_count.h')
|
||||
open(hn, 'w').write('// 由 gen_protos.py 生成\n#pragma once\n#define NVN_NFUNC %d\n' % len(names))
|
||||
@@ -0,0 +1,70 @@
|
||||
# Maxwell(Tegra X1)着色器机器码里的资源引用:只解读绑定映射需要的那几类,不是完整反汇编器。
|
||||
# 指令位模式取自 yuzu shader decode 表;代码段布局:图形阶段 = 0x30 NVN 头(0x12345678)+ 0x50 SPH + 指令,
|
||||
# 计算阶段直接是指令;每 4 个 64 位字的第 1 个是调度控制字。
|
||||
# 全量实测(10847 条变体,tools/shader_map.py)得出 NVN 绑定 ↔ D3D 寄存器:
|
||||
# uniform 缓冲 binding r ↔ cb_r,机器码里是 c[3 + r](每阶段 14 个,c[3]..c[16];更高的 c[22]/c[27] 是驱动内部)
|
||||
# 分离贴图 slot r ↔ t_r,句柄在 c[2][0x168 + 8r](读法两种:c[2] 操作数,或贴图指令立即数贴图号 ×4)
|
||||
# 分离采样器 slot r ↔ s_r,句柄在 c[2][0x568 + 8r](例外 1 条:cs_terrain_composite 多用 s2,PC 无)
|
||||
# 存储缓冲 slot r ↔ u_r 或只读结构化/原始缓冲 t_r(同一编号空间),地址/大小在 c[0][基址 + 0x10 r]
|
||||
# 基址:顶点 0x110、计算 0x310、像素 0x510;10847 条双向全等
|
||||
# Resource references in Maxwell (Tegra X1) shader machine code: only decodes the few kinds needed for the binding mapping; not a full disassembler.
|
||||
# Instruction bit patterns are taken from the yuzu shader decode table; code segment layout: graphics stage = 0x30 NVN header (0x12345678) + 0x50 SPH + instructions,
|
||||
# compute stage is instructions directly; the 1st of every 4 64-bit words is the scheduling control word.
|
||||
# A full measurement (10847 variants, tools/shader_map.py) gives NVN binding ↔ D3D register:
|
||||
# uniform buffer binding r ↔ cb_r, which is c[3 + r] in machine code (14 per stage, c[3]..c[16]; the higher c[22]/c[27] are driver-internal)
|
||||
# separate texture slot r ↔ t_r, handle at c[2][0x168 + 8r] (two ways to read it: a c[2] operand, or the texture instruction's immediate texture index ×4)
|
||||
# separate sampler slot r ↔ s_r, handle at c[2][0x568 + 8r] (1 exception: cs_terrain_composite additionally uses s2, absent on PC)
|
||||
# storage buffer slot r ↔ u_r or read-only structured/raw buffer t_r (same numbering space), address/size at c[0][base + 0x10 r]
|
||||
# base: vertex 0x110, compute 0x310, pixel 0x510; all 10847 match exactly in both directions
|
||||
import struct
|
||||
|
||||
TEX_BASE, SAMP_BASE, UBO_FIRST, UBO_LAST = 0x168, 0x568, 3, 16
|
||||
SSBO_BASE = {'vs': 0x110, 'cs': 0x310, 'ps': 0x510}
|
||||
|
||||
def instrs(code, graphics):
|
||||
off = 0x80 if graphics and code[:4] == bytes.fromhex('78563412') else 0
|
||||
out = []
|
||||
for k in range(off, len(code) - 7, 8):
|
||||
if ((k - off) // 8) % 4 == 0: continue
|
||||
out.append(struct.unpack_from('<Q', code, k)[0])
|
||||
return out
|
||||
|
||||
def match(w, pat):
|
||||
for i, ch in enumerate(pat):
|
||||
if ch != '-' and int(ch) != (w >> (63 - i)) & 1: return False
|
||||
return True
|
||||
|
||||
def cbuf_alu(ins):
|
||||
"""操作数类为常量缓冲的 ALU 指令(最高 4 位 = 0100):{(索引, 字节偏移)} | ALU instructions whose operand class is constant buffer (top 4 bits = 0100): {(index, byte offset)}"""
|
||||
return {((w >> 34) & 0x1f, ((w >> 20) & 0x3fff) * 4) for w in ins if (w >> 60) == 0x4 and w}
|
||||
|
||||
def ldc(ins):
|
||||
"""LDC(按下标读常量缓冲):{(索引, 字节偏移)} | LDC (read constant buffer by index): {(index, byte offset)}"""
|
||||
return {((w >> 36) & 0x1f, (w >> 20) & 0xffff) for w in ins if match(w, '1110111110010---')}
|
||||
|
||||
def bindings(code, stage):
|
||||
ins = instrs(code, stage != 'cs')
|
||||
refs = cbuf_alu(ins) | ldc(ins)
|
||||
ubo = {i - UBO_FIRST for i, _ in refs if UBO_FIRST <= i <= UBO_LAST}
|
||||
c2 = {o for i, o in refs if i == 2}
|
||||
# 立即数贴图号(TEX/TEXS/TLD/TLDS/TLD4/TLD4S 的 bits 36..48)= 句柄在 c[2] 里的字偏移,×4 即字节偏移(内嵌着色器 TLDS 0x6e→t10 核实)
|
||||
# Immediate texture index (bits 36..48 of TEX/TEXS/TLD/TLDS/TLD4/TLD4S) = word offset of the handle within c[2]; ×4 gives the byte offset (verified with the embedded shader's TLDS 0x6e→t10)
|
||||
for w in ins:
|
||||
for pat in ('110000----111---', '110010----111---', '11011100--11----', '1101111100------', '1101-00---------', '1101-01---------'):
|
||||
if match(w, pat): c2.add(((w >> 36) & 0x1fff) * 4); break
|
||||
tex = {(o - TEX_BASE) // 8 for o in c2 if TEX_BASE <= o < SAMP_BASE and (o - TEX_BASE) % 8 == 0}
|
||||
samp = {(o - SAMP_BASE) // 8 for o in c2 if o >= SAMP_BASE and (o - SAMP_BASE) % 8 == 0}
|
||||
base = SSBO_BASE.get(stage)
|
||||
ssbo = {(o - base) // 16 for i, o in refs if i == 0 and base and o >= base and (o - base) % 16 == 0 and (o - base) // 16 < 16} if base else set()
|
||||
drv = sorted(o for o in c2 if o < TEX_BASE)
|
||||
return {'ubo': ubo, 'tex': tex, 'samp': samp, 'ssbo': ssbo, 'c2drv': drv}
|
||||
|
||||
def vs_inputs(code):
|
||||
"""顶点着色器读取的通用属性槽:ALD(1110111111011---)的属性地址 bits 20..29,通用属性 n 在 0x80 + 16n | Generic attribute slots read by the vertex shader: attribute address bits 20..29 of ALD (1110111111011---); generic attribute n is at 0x80 + 16n"""
|
||||
ins = instrs(code, True)
|
||||
return {((w >> 20) & 0x3ff) - 0x80 >> 4 for w in ins if match(w, '1110111111011---') and 0x80 <= ((w >> 20) & 0x3ff) < 0x280}
|
||||
|
||||
def sph_stage(code):
|
||||
"""图形着色器 SPH 头的阶段字段(第 0 字 bits 10..13):1 顶点、5 像素 | Stage field of the graphics shader SPH header (word 0, bits 10..13): 1 vertex, 5 pixel"""
|
||||
if code[:4] != bytes.fromhex('78563412'): return None
|
||||
return {1: 'vs', 5: 'ps'}.get((struct.unpack_from('<I', code, 0x30)[0] >> 10) & 0xf)
|
||||
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
# 在没有苹果 Metal 编译器的机器上跑着色器出库链(Windows / Linux / 没装 Xcode 的 Mac;给 tools/d2rm_pack.py 用)。
|
||||
# 用法:nometal_run.py <脚本.py> [参数…] 例:nometal_run.py dmsh_build.py <包目录> <缓存目录>
|
||||
# 做法:不改出库链的任何一个文件(它们的内容参与翻译链版本,一改内测的着色器库就得整体换代),只在本进程里把它们调外部命令的
|
||||
# 那一个入口(subprocess.run)接过来,认出下面几条命令自己答,其余原样放行:
|
||||
# xcrun -sdk <x> metal --version → 答「none」(工具指纹里编译器记成不用 → 链版本自成一支,缓存与正常模式互不相混)
|
||||
# xcrun -sdk <x> metal -c <源码> -o <中间件> → 把源码拷成中间件(换行统一成 \n)
|
||||
# xcrun -sdk <x> metallib <中间件> -o <库> → 把中间件原样拷成库
|
||||
# which <名字> → 用 Python 自己找
|
||||
# cp -c <甲> <乙> → 普通拷贝
|
||||
# 结果:「库文件」(*_b.metallib / *_bf.metallib)里放的是着色器源码。壳(DM_SHELL 构建)的图形层发现库不是编好的就在设备上现编
|
||||
# (gfx/nvn/nvn_mtl.m),系统会把编好的结果缓存,第二次启动起不再编。
|
||||
# 少掉的一道:正常模式下苹果编译器顺带验了每份源码能编过;这里不验,编不过的要到设备上用到它时才报红。
|
||||
# Runs the shader build chain on a machine without Apple's Metal compiler (Windows / Linux / a Mac without Xcode; for use by tools/d2rm_pack.py).
|
||||
# Usage: nometal_run.py <script.py> [args...] Example: nometal_run.py dmsh_build.py <package dir> <cache dir>
|
||||
# How: not a single file of the build chain is modified (their contents feed into the translation chain version, and any change would force a whole new generation of the beta shader libraries); only, within this process, the one entry through which they call external commands
|
||||
# (subprocess.run) is taken over: the commands below are recognized and answered here, and everything else is passed through unchanged:
|
||||
# xcrun -sdk <x> metal --version → answers "none" (the compiler is recorded as unused in the tool fingerprint → the chain version forms its own branch, and its cache never mixes with normal mode's)
|
||||
# xcrun -sdk <x> metal -c <source> -o <intermediate file> → copies the source as the intermediate file (line endings normalized to LF)
|
||||
# xcrun -sdk <x> metallib <intermediate file> -o <library> → copies the intermediate file verbatim as the library
|
||||
# which <name> → looked up by Python itself
|
||||
# cp -c <a> <b> → ordinary copy
|
||||
# Result: the "library files" (*_b.metallib / *_bf.metallib) contain shader source. When the graphics layer of the shell (DM_SHELL build) finds that a library is not a compiled one, it compiles it on the device
|
||||
# (gfx/nvn/nvn_mtl.m); the system caches the compiled result, and from the second launch on nothing is compiled again.
|
||||
# The one check that is lost: in normal mode Apple's compiler also verifies along the way that every source compiles; here that is not verified, and one that fails to compile only reports a failure when it is used on the device.
|
||||
import os, runpy, shutil, subprocess, sys
|
||||
|
||||
_real = subprocess.run
|
||||
|
||||
|
||||
def _done(args, out=''):
|
||||
return subprocess.CompletedProcess(args, 0, stdout=out, stderr='')
|
||||
|
||||
|
||||
def run(args, *a, **k):
|
||||
text = k.get('text') or k.get('universal_newlines')
|
||||
enc = (lambda s: s) if text else (lambda s: s.encode())
|
||||
if isinstance(args, (list, tuple)) and args:
|
||||
c = [str(x) for x in args]
|
||||
if c[0] == 'xcrun' and 'metal' in c and '--version' in c: return _done(args, enc('none\n'))
|
||||
if c[0] == 'xcrun' and 'metal' in c and '-c' in c and '-o' in c: # 源码 = metal 之后第一个不是选项、也不是 -o 的值的参数(iOS 那条命令在 -c 后面还带一个版本选项) | source = the first argument after metal that is neither an option nor the value of -o (the iOS command also carries a version option after -c)
|
||||
o = c.index('-o'); src = [x for i, x in enumerate(c[c.index('metal') + 1:], c.index('metal') + 1) if not x.startswith('-') and i != o + 1]
|
||||
if len(src) != 1: raise RuntimeError('nometal_run:认不出源码参数 %r' % c)
|
||||
with open(src[0], 'rb') as f: b = f.read()
|
||||
with open(c[o + 1], 'wb') as f: f.write(b.replace(b'\r\n', b'\n')) # Windows 上 spirv-cross 写出的源码是 \r\n 换行:进安装包前归一,同样的输入各系统出的包才相同 | On Windows spirv-cross writes sources with CRLF line endings: normalize before they go into the install package, so the same input gives the same package on every system
|
||||
return _done(args, enc(''))
|
||||
if c[0] == 'xcrun' and 'metallib' in c and '-o' in c: shutil.copyfile(c[c.index('metallib') + 1], c[c.index('-o') + 1]); return _done(args, enc(''))
|
||||
if c[0] == 'xcrun': raise RuntimeError('nometal_run:没认出的 xcrun 命令 %r' % c)
|
||||
if c[0] == 'which' and len(c) == 2: return _done(args, enc((shutil.which(c[1]) or '') + '\n'))
|
||||
if c[0] == 'cp' and len(c) == 4 and c[1] == '-c': shutil.copyfile(c[2], c[3]); return _done(args, enc(''))
|
||||
return _real(args, *a, **k)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) < 2: sys.exit(__doc__ or '用法:nometal_run.py <脚本.py> [参数…]')
|
||||
subprocess.run = run
|
||||
script = os.path.abspath(sys.argv[1]); sys.argv = sys.argv[1:]; sys.path.insert(0, os.path.dirname(script))
|
||||
runpy.run_path(script, run_name='__main__')
|
||||
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env python3
|
||||
# main 的 NVN 取址表与静态调用面(3.3.94012)。
|
||||
# 1) 解析 main 里的 NVN 加载函数(按名字取址后逐个存进全局指针槽)→ 名字 → 槽;
|
||||
# 2) 全 .text 扫「ldr xT,[xN,#imm]」读槽:从读取点往回找 xN 的上一次写入,是 adrp 到槽页才算一次调用点。
|
||||
# (前向寄存器跟踪会把陈旧值当槽地址、或漏掉循环外提的 adrp,两种都抽查出过错,故用回溯。)
|
||||
# 用法:nvn_slots.py <main 原映像 .bin(dm/tools/nso.py 解出)> <输出 tsv> [名字表输出]
|
||||
# 输出列:名字 槽地址 调用点数 首个调用点;名字表按槽地址(= 加载顺序)。
|
||||
# main's NVN address-lookup table and static call surface (3.3.94012).
|
||||
# 1) Parse the NVN loader function in main (looks up addresses by name and stores them one by one into global pointer slots) → name → slot;
|
||||
# 2) Scan all of .text for "ldr xT,[xN,#imm]" slot reads: search backward from the read for the previous write to xN; it only counts as a call site if that write is an adrp to the slot's page.
|
||||
# (Forward register tracking treats stale values as slot addresses, or misses an adrp hoisted out of a loop; spot checks found both kinds of error, hence the backward trace.)
|
||||
# Usage: nvn_slots.py <main raw image .bin (extracted by dm/tools/nso.py)> <output tsv> [name table output]
|
||||
# Output columns: name, slot address, call site count, first call site; the name table is ordered by slot address (= load order).
|
||||
import struct, sys
|
||||
LOADER = 0x1739290 # main 内 NVN 加载函数(3.3.94012;换版本先重新定位) | NVN loader function inside main (3.3.94012; re-locate it first when changing versions)
|
||||
img, out = sys.argv[1], sys.argv[2]
|
||||
d = open(img, 'rb').read()
|
||||
TEXT_END = 0x1b786a0 # main .text 尾(NSO 段头) | end of main .text (NSO segment header)
|
||||
N = TEXT_END // 4
|
||||
w = struct.unpack_from('<%dI' % N, d, 0)
|
||||
|
||||
def adrp(x, pc):
|
||||
imm = ((x >> 29) & 3) | (((x >> 5) & 0x7ffff) << 2)
|
||||
if imm & (1 << 20): imm -= 1 << 21
|
||||
return (pc & ~0xfff) + (imm << 12)
|
||||
def cstr(a): return d[a:d.index(b'\0', a)].decode()
|
||||
|
||||
# 1) 加载函数:adrp/add x1 = 名字,str x0,[xn,#imm] = 槽
|
||||
# 1) Loader function: adrp/add x1 = name, str x0,[xn,#imm] = slot
|
||||
i, reg, cur, slot = LOADER // 4, {}, None, {}
|
||||
while w[i] != 0xd65f03c0:
|
||||
x, pc = w[i], i * 4
|
||||
if x & 0x9f000000 == 0x90000000: reg[x & 31] = adrp(x, pc)
|
||||
elif x & 0xffc00000 == 0x91000000 and (x & 31) == 1: cur = cstr(reg[(x >> 5) & 31] + ((x >> 10) & 0xfff))
|
||||
elif x & 0xffc00000 == 0xf9000000 and (x & 31) == 0: slot[reg[(x >> 5) & 31] + ((x >> 10) & 0xfff) * 8] = cur
|
||||
i += 1
|
||||
offs = {a & 0xfff for a in slot}
|
||||
|
||||
def writes(x, r):
|
||||
"""x 是否写通用寄存器 r(近似、偏保守) | Whether x writes general-purpose register r (approximate, conservative)"""
|
||||
op0 = (x >> 25) & 0xf
|
||||
if x & 0xfc000000 == 0x94000000 or x & 0xfffffc1f == 0xd63f0000: return r <= 18 # bl / blr
|
||||
if op0 in (0b1000, 0b1001, 0b0101, 0b1101): return (x & 31) == r # 数据处理 | data processing
|
||||
if op0 & 0b0101 == 0b0100: # 读写内存 | memory load/store
|
||||
L = (x >> 22) & 1
|
||||
if (x >> 27) & 7 == 0b101:
|
||||
wb = (x >> 23) & 3 in (1, 3)
|
||||
return (L and ((x & 31) == r or ((x >> 10) & 31) == r)) or (wb and ((x >> 5) & 31) == r)
|
||||
if (x >> 27) & 7 == 0b111 and (x >> 24) & 3 == 0:
|
||||
wb = (x >> 21) & 1 == 0 and (x >> 10) & 3 in (1, 3)
|
||||
return (L and (x & 31) == r) or (wb and ((x >> 5) & 31) == r)
|
||||
if (x >> 27) & 7 == 0b111: return bool(L) and (x & 31) == r
|
||||
if (x >> 27) & 7 == 0b011: return (x & 31) == r
|
||||
return False
|
||||
|
||||
# 2) 回溯归属每次读槽
|
||||
# 2) Attribute each slot read by tracing backward
|
||||
uses = {a: [] for a in slot}
|
||||
for i in range(N):
|
||||
x = w[i]
|
||||
if x & 0xffc00000 != 0xf9400000: continue
|
||||
off = ((x >> 10) & 0xfff) * 8
|
||||
rn = (x >> 5) & 31
|
||||
if off not in offs or rn == 31: continue
|
||||
for j in range(i - 1, max(i - 4000, -1), -1):
|
||||
y = w[j]
|
||||
if y == 0xd65f03c0: break
|
||||
if writes(y, rn):
|
||||
if y & 0x9f000000 == 0x90000000 and (y & 31) == rn and adrp(y, j * 4) + off in uses:
|
||||
uses[adrp(y, j * 4) + off].append(i * 4)
|
||||
break
|
||||
with open(out, 'w') as f:
|
||||
f.write('# kind: evidence main NVN 取址槽与静态调用点(nvn_slots.py)\nname\tslot\tnuses\tfirst_use\n')
|
||||
for a in sorted(slot):
|
||||
u = uses[a]; f.write('%s\t%x\t%d\t%s\n' % (slot[a], a, len(u), '%x' % u[0] if u else '-'))
|
||||
if len(sys.argv) > 3: open(sys.argv[3], 'w').write(''.join(slot[a] + '\n' for a in sorted(slot)))
|
||||
used = sum(1 for a in slot if uses[a])
|
||||
print('槽 %d,有调用点 %d,调用点 %d' % (len(slot), used, sum(len(v) for v in uses.values())))
|
||||
@@ -0,0 +1,23 @@
|
||||
# 逐通道 GPU:按帧内序号平均时间线增量 inc_ms;与 @gpu_ms 对照(列见 nvn_mtl.m DM_NVN_PASSGPU 注释)
|
||||
# Per-pass GPU: average the timeline increment inc_ms by in-frame index; compare against @gpu_ms (for the columns see the DM_NVN_PASSGPU comment in nvn_mtl.m)
|
||||
import sys, collections, statistics as S
|
||||
X=sys.argv[1]; F0=int(sys.argv[2]) if len(sys.argv)>2 else 300; N=int(sys.argv[3]) if len(sys.argv)>3 else 10
|
||||
rows=[l.rstrip('\n').split('\t') for l in open(f'{X}/passgpu.tsv')][1:]
|
||||
inc=collections.defaultdict(list); per=collections.defaultdict(float); meta={}
|
||||
for r in rows:
|
||||
f=int(r[0])
|
||||
if f<=F0: continue
|
||||
inc[int(r[1])].append(float(r[4])); per[f]+=float(r[4]); meta[int(r[1])]=r
|
||||
g={}
|
||||
try:
|
||||
for l in open(f'{X}/frames.tsv'):
|
||||
p=l.rstrip('\n').split('\t')
|
||||
if len(p)==3 and p[0].isdigit() and p[1]=='@gpu_ms': g[int(p[0])]=float(p[2])
|
||||
except FileNotFoundError: pass
|
||||
c=[f for f in per if f in g]
|
||||
print('帧数 %d;每帧增量之和 p50 %.2f / p95 %.2f ms%s'%(len(per),S.median(per.values()),sorted(per.values())[int(len(per)*.95)],';同帧 @gpu_ms p50 %.2f ms'%S.median(g[f] for f in c) if c else ''))
|
||||
tot=sum(S.mean(v) for v in inc.values())
|
||||
print('前列(帧内序号:增量均值 ms,占比 | 尺寸 颜色格式 深度格式 读入 绘制数 种类)')
|
||||
for k in sorted(inc,key=lambda k:-S.mean(inc[k]))[:N]:
|
||||
r=meta[k]; m=S.mean(inc[k]); print(' #%d:%.3f ms %4.1f%% | %sx%s fmt%s d%s %s %s 绘制 %s'%(k,m,100*m/tot,r[5],r[6],r[7],r[8],r[9],r[10],r[2]))
|
||||
print('通道数 / 帧:%d;合计 %.2f ms'%(len(inc),tot))
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user