Compare commits

...
3 Commits
15 changed files with 603 additions and 36 deletions
+3 -2
View File
@@ -423,8 +423,9 @@ namespace MobileGL::MG_Config {
Uint32 PipeIndexMirrorMb = 64;
// MOBILEGL_PIPE_STATS_PERIOD: frames per boundary-counter summary line. 120 is the
// steady-state cadence; the device retrace harness never reaches the teardown dump
// and a trimmed fixture (create-indirect) is shorter than 120 frames, so a run that
// needs its numbers at all sets this low enough to land at least one window.
// and a trimmed fixture (minecraft-1.21.1-neoforge-create-indirect-in-world-align1024)
// is shorter than 120 frames, so a run that needs its numbers at all sets this low
// enough to land at least one window.
Uint32 PipeStatsPeriod = 120;
// MOBILEGL_PIPE_STATS_FILE: where the boundary counters' teardown JSON dump goes.
// Empty (the default) means no dump; the per-120-frame summary line still goes to
+76 -7
View File
@@ -2983,6 +2983,67 @@ namespace MobileGL::MG_Backend::DirectGLES {
return imported;
}
// The POST's second round: the CPU writes region 1 through the held lock only now, after
// the import and a GPU use of it, and reads region 4 (the first round's fill) back into
// its cache; a second dispatch copies region 1 out and overwrites region 4. Appends its
// counts to `detail`.
Bool SelfTestExternalSteady(GLuint imported, GLuint out, void* heldPtr, char* detail, SizeT detailBytes) {
constexpr Uint32 kWords = 1024;
constexpr Uint32 kSteadyAtWord = kWords; // region 1
constexpr Uint32 kFillAtWord = 4 * kWords; // region 4
auto* held = static_cast<volatile Uint32*>(heldPtr);
Uint32 cached = 0;
for (Uint32 i = 0; i < kWords; ++i) {
held[kSteadyAtWord + i] = 0xA5000000u ^ (i * 40503u);
cached ^= held[kFillAtWord + i];
}
(void)cached;
static const char* kSource =
"#version 310 es\n"
"layout(local_size_x = 64) in;\n"
"layout(std430, binding = 0) buffer Ext { uint w[]; } ext;\n"
"layout(std430, binding = 1) buffer Out { uint w[]; } outb;\n"
"void main() {\n"
" uint i = gl_GlobalInvocationID.x;\n"
" outb.w[i] = ext.w[1024u + i];\n"
" ext.w[4096u + i] = 0x3D5EA11Eu ^ i;\n"
"}\n";
const GLuint program = g_GLESFuncs.glCreateShaderProgramv(GL_COMPUTE_SHADER, 1, &kSource);
GLint linked = 0;
if (program != 0) g_GLESFuncs.glGetProgramiv(program, GL_LINK_STATUS, &linked);
const SizeT used = std::strlen(detail);
if (!linked) {
if (program != 0) g_GLESFuncs.glDeleteProgram(program);
std::snprintf(detail + used, detailBytes - used, "; steady: the second program did not link");
return false;
}
g_GLESFuncs.glUseProgram(program);
g_GLESFuncs.glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, imported);
g_GLESFuncs.glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, out);
g_GLESFuncs.glMemoryBarrier(0x00004000 /*GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT*/);
g_GLESFuncs.glDispatchCompute(kWords / 64, 1, 1);
g_GLESFuncs.glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT | GL_SHADER_STORAGE_BARRIER_BIT |
0x00004000 /*GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT*/);
g_GLESFuncs.glFinish();
Uint32 steadyRead = 0, steadySaw = 0;
for (Uint32 i = 0; i < kWords; ++i)
if (held[kFillAtWord + i] == (0x3D5EA11Eu ^ i)) ++steadySaw;
g_GLESFuncs.glBindBuffer(GL_SHADER_STORAGE_BUFFER, out);
const auto* copied = static_cast<const Uint32*>(
g_GLESFuncs.glMapBufferRange(GL_SHADER_STORAGE_BUFFER, 0, kWords * 4, GL_MAP_READ_BIT));
if (copied != nullptr) {
for (Uint32 i = 0; i < kWords; ++i)
if (copied[i] == (0xA5000000u ^ (i * 40503u))) ++steadyRead;
g_GLESFuncs.glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
}
g_GLESFuncs.glDeleteProgram(program);
std::snprintf(detail + used, detailBytes - used,
"; with the import in use, GPU read %u/%u words the CPU wrote after it, GPU write "
"seen through the held lock %u/%u words",
steadyRead, kWords, steadySaw, kWords);
return steadyRead == kWords && steadySaw == kWords;
}
// THE POST (B2, the standing rule: decide by probe, never by driver name). The AHB API
// promises CPU coherence only across an unlock/lock; T0 keeps the client's lock for the
// store's life, so the pattern it depends on is exactly what this exercises, on this
@@ -2993,7 +3054,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
// gpu - a compute dispatch copies that pattern out of the import (the GPU read) and
// fills another region of it (the GPU write);
// back - after glFinish the fill is read through the HELD pointer and the copy is
// read back from the dispatch's output.
// read back from the dispatch's output;
// steady - the same again with bytes the CPU wrote AFTER the import and its first GPU
// use (VkBufferManager::SelfTestWireImport says why the first round is not enough).
// In a throwaway ES 3.1 pbuffer context, so none of this context's state or Espryt's
// binding caches is disturbed; the caller's bind is restored before returning.
Bool Ops_H_SelfTestExternal(char* whyOut, Uint64 whyBytes) {
@@ -3046,7 +3109,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
GLuint out = 0, program = 0;
void* hostMap = nullptr;
const GLuint imported = ImportAhbAsBuffer(held.ahb, kBytes, &hostMap, why, /*throwaway=*/true);
char detail[256] = {};
char detail[512] = {};
if (imported == 0) {
std::snprintf(detail, sizeof(detail), "import: %s", why.c_str());
} else if (std::memcmp(hostMap, pattern.data(), kWords * 4) != 0) {
@@ -3096,6 +3159,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
"64 KiB AHB, lock held throughout: host map read ok, GPU read %u/%u words of "
"the CPU's pattern, GPU write seen through the held lock %u/%u words",
gpuRead, kWords, heldSaw, kWords);
if (ok) ok = SelfTestExternalSteady(imported, out, held.ptr, detail, sizeof(detail));
}
}
if (program != 0) g_GLESFuncs.glDeleteProgram(program);
@@ -14050,7 +14114,8 @@ namespace MobileGL::MG_Backend::DirectGLES {
// re-serialised copy either way, and adopting that copy for every vertex
// shader would put every one of them through a round trip they do not need
// - which is not free: it cost the create-indirect retrace 0.15 SSIM the
// first time this gate was missing.
// first time this gate was missing (the original capture; the case is now
// minecraft-1.21.1-neoforge-create-indirect-in-world-align1024).
effectiveSpirv = &splitArrayInputSpirv;
}
@@ -14058,8 +14123,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
// blocks - the optimizer hands back a re-serialised copy either way, and taking
// that copy for a module it did not rewrite is not free (it cost the
// create-indirect retrace 0.15 SSIM when the array-input split first missed
// this gate). The report has to be per stage, not cumulative: a fragment shader
// consuming the same block reports a name the vertex stage already reported,
// this gate; the case is now
// minecraft-1.21.1-neoforge-create-indirect-in-world-align1024). The report has to be
// per stage, not cumulative: a fragment shader consuming the same block reports a
// name the vertex stage already reported,
// and its own rewrite must still be taken or the two stages stop matching.
Vector<unsigned int> flattenedXfbSpirv;
if (!xfbCaptureBlockNames.empty()) {
@@ -14778,8 +14845,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
// per stage below so a producer and its consumer keep naming the same block.
// Gated twice over, because a re-serialised module is not free (it cost the
// create-indirect retrace 0.15 SSIM the first time the array-input split missed
// its gate): only a tessellation or geometry stage can declare blocks in both
// directions at all, and even then the probe has to FIND a collision before any
// its gate; the case is now
// minecraft-1.21.1-neoforge-create-indirect-in-world-align1024): only a tessellation
// or geometry stage can declare blocks in both directions at all, and even then the
// probe has to FIND a collision before any
// stage is rewritten.
std::set<String> collidingIoBlockNames;
std::set<String> declaredIoBlockNames;
@@ -786,7 +786,9 @@ namespace MobileGL::MG_Backend::DirectVulkan {
// read - this server's own host map of the import reads what the CPU wrote through the lock;
// gpu - one submission copies that pattern out of the import (the GPU read) and fills another
// region of it (the GPU write), then a transfer->host barrier and a fence wait;
// back - the fill is read through the HELD pointer, the copy from a host-visible staging buffer.
// back - the fill is read through the HELD pointer, the copy from a host-visible staging buffer;
// steady - the same again with bytes the CPU wrote AFTER the import and its first GPU use (the
// block at the end says why the first round alone is not enough).
Bool VkBufferManager::SelfTestWireImport(char* whyOut, Uint64 whyBytes) {
const auto answer = [&](Bool ok, const String& text) {
std::snprintf(whyOut, static_cast<SizeT>(whyBytes), "%s", text.c_str());
@@ -909,6 +911,55 @@ namespace MobileGL::MG_Backend::DirectVulkan {
String(imported.coherent ? "coherent" : "non-coherent") + " memory), GPU read " +
std::to_string(gpuRead) + "/1024 words of the CPU's pattern, GPU write seen through the "
"held lock " + std::to_string(heldSaw) + "/1024 words";
if (!ok) break;
// STEADY STATE. The round above reads bytes the CPU wrote BEFORE the import, and an import
// can clean the CPU's caches on its way in, so it passes on a device whose GPU never sees a
// write made through the held lock afterwards - which is all of T0's real traffic (Mali-G1
// on a Dimensity: the first round passed, then Flywheel's staging scatter read stale bytes
// and the create-indirect trace lost every instanced object). So the CPU now writes a fresh
// pattern into region 1 and reads region 4 back into its cache, and one more submission
// copies region 1 out and overwrites region 4.
constexpr Uint64 kSteadyAt = 1 * 4096; // region 1
constexpr Uint32 kSteadyFillWord = 0x3D5EA11Eu;
auto* heldWrite = static_cast<volatile Uint32*>(held.ptr);
Uint32 cached = 0;
for (Uint32 i = 0; i < kWords; ++i) {
heldWrite[kSteadyAt / 4 + i] = 0xA5000000u ^ (i * 40503u);
cached ^= heldWrite[kFillAt / 4 + i];
}
(void)cached;
std::memset(staging.mapped, 0, kWords * 4);
if (vkResetFences(ctx.device, 1, &fence) != VK_SUCCESS ||
vkResetCommandPool(ctx.device, pool, 0) != VK_SUCCESS ||
vkBeginCommandBuffer(commands, &begin) != VK_SUCCESS) {
ok = false;
verdict = "steady: the second submission could not be recorded";
break;
}
vkCmdPipelineBarrier(commands, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1,
&hostWrites, 0, nullptr, 0, nullptr);
VkBufferCopy steadyRegion{kSteadyAt, 0, kWords * 4};
vkCmdCopyBuffer(commands, imported.buffer, staging.buffer, 1, &steadyRegion);
vkCmdFillBuffer(commands, imported.buffer, kFillAt, kWords * 4, kSteadyFillWord);
vkCmdPipelineBarrier(commands, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_HOST_BIT, 0, 1, &toHost,
0, nullptr, 0, nullptr);
vkEndCommandBuffer(commands);
if (vkQueueSubmit(ctx.queue, 1, &submit, fence) != VK_SUCCESS ||
vkWaitForFences(ctx.device, 1, &fence, VK_TRUE, 2'000'000'000ull) != VK_SUCCESS) {
ok = false;
verdict = "steady: the second submission did not complete within 2 s";
break;
}
Uint32 steadyRead = 0, steadySaw = 0;
for (Uint32 i = 0; i < kWords; ++i) {
if (copied[i] == (0xA5000000u ^ (i * 40503u))) ++steadyRead;
if (heldWords[kFillAt / 4 + i] == kSteadyFillWord) ++steadySaw;
}
ok = steadyRead == kWords && steadySaw == kWords;
verdict += "; with the import in use, GPU read " + std::to_string(steadyRead) +
"/1024 words the CPU wrote after it, GPU write seen through the held lock " +
std::to_string(steadySaw) + "/1024 words";
} while (false);
if (fence != VK_NULL_HANDLE) vkDestroyFence(ctx.device, fence, nullptr);
if (pool != VK_NULL_HANDLE) vkDestroyCommandPool(ctx.device, pool, nullptr);
@@ -10,8 +10,9 @@
//
// Before P8-D every wire indirect draw read its commands (and its count word) through
// ReadWireBuffer and expanded them on the CPU, and a store a shader had written turned that read
// into a whole-GPU wait per draw (create-indirect: 321 expansions, 327 waits, ~4-8 s of waiting
// per replay on lavapipe). The cases pin both halves of the change:
// into a whole-GPU wait per draw (the create-indirect trace, now
// minecraft-1.21.1-neoforge-create-indirect-in-world-align1024: 321 expansions, 327 waits, ~4-8 s of
// waiting per replay on lavapipe). The cases pin both halves of the change:
// * PIXELS, on every arm and both backends where the backend's own semantics allow it - each
// indirect form draws exactly the strips its commands name, and GPU-written commands are the
// ones the draw sees (the poison the buffers start with names the OTHER strips);
@@ -336,8 +337,9 @@ void main() { words[gl_GlobalInvocationID.x] = source[gl_GlobalInvocationID.x];
EXPECT_EQ(delta.barriers, 2u) << "one barrier per draw whose count store a shader wrote";
}
// Flywheel's shape (create-indirect's trace: 322 cull-then-draw rounds, no glMemoryBarrier
// between them). GL leaves it undefined; the wire arm orders it anyway, once per write,
// Flywheel's shape (minecraft-1.21.1-neoforge-create-indirect-in-world-align1024: 322
// cull-then-draw rounds, no glMemoryBarrier between them). GL leaves it undefined; the
// wire arm orders it anyway, once per write,
// because the CPU path it replaced did (by waiting). Magma's split arms only: the monolith
// arm records no dependency here (recorded for dev), and Espryt's is its driver's.
TEST_F(WireIndirectDrawScenario, ShaderWrittenCommandsWithoutAnApplicationBarrierAreOrdered) {
+7 -4
View File
@@ -264,10 +264,13 @@
### POST(`kCapAdoptT0` 的前提)
持续持锁形状:分配 64 KiB AHB,**整个测试期间 CPU lock 不放**,导入,GPU 读 CPU 写的图案、GPU 写一段,经持有的指针读回比较。
- Espryt(`Ops_H_SelfTestExternal`):一次性 ES 3.1 pbuffer 上下文(不碰 Espryt 的绑定缓存),`glBufferStorageExternalEXT` + 持久 coherent 映射,映射读一遍,compute shader 把 region 0 拷到输出、在 word 4096 起写 `0x6C0FFEE0 ^ i`。
- Magma(`VkBufferManager::SelfTestWireImport`,`VkBufferManager.cpp:768`):renderer 的设备,`vkCmdCopyBuffer` region 0 → staging、`vkCmdFillBuffer` region 4,栅栏等 2 s。
- 结果一行 I `T0 POST (<后端>, sustained-lock pattern) PASSED|FAILED - …`。红米(Adreno 830)两后端 PASSED。
持续持锁形状:分配 64 KiB AHB,**整个测试期间 CPU lock 不放**,导入,GPU 读 CPU 写的图案、GPU 写一段,经持有的指针读回比较。**两轮**:
- 第一轮读的是导入**之前**写进去的图案。导入会顺手清 CPU 缓存,所以只有这一轮的 POST 在「导入之后经持有指针的写 GPU 永远看不见」的设备上照样通过——而 T0 的真实流量全是导入之后的写。
- 第二轮(steady,2026-09-30 补):导入且 GPU 用过之后,CPU 才经持有的指针写 region 1、把 region 4(第一轮的 GPU 写)读进缓存;再一次 GPU 工作把 region 1 拷出、改写 region 4,两个方向都比对。两轮都全对才 PASSED。
- 实测:Mali-G1-Ultra(天玑,`3B159D009VZ00000`)第一轮全对、第二轮 Magma 读到 0/1024 词、写回 16/1024(import 内存 non-coherent),Espryt 48/1024、160/1024 → FAILED,T0 回退 T2。改之前该机 T0 被授予,`create-indirect-in-world-align1024` × Magma 的 inproc / spawn 丢掉全部 Flywheel 实例物体(0.867 / 0.848),同 trace 的 T2 0.99998;改之后两臂 0.999984。红米(Adreno 830)两后端两轮全对(Magma coherent),T0 照旧授予。
- Espryt(`Ops_H_SelfTestExternal`,第二轮 `SelfTestExternalSteady`):一次性 ES 3.1 pbuffer 上下文(不碰 Espryt 的绑定缓存),`glBufferStorageExternalEXT` + 持久 coherent 映射,映射读一遍,compute shader 把 region 0 拷到输出、在 word 4096 起写 `0x6C0FFEE0 ^ i`;第二轮另一个 compute program 拷 word 1024 起、在 word 4096 起写 `0x3D5EA11E ^ i`。
- Magma(`VkBufferManager::SelfTestWireImport`,`VkBufferManager.cpp:768`):renderer 的设备,`vkCmdCopyBuffer` region 0 → staging、`vkCmdFillBuffer` region 4,栅栏等 2 s;第二轮同一命令池重录:region 1 → staging、region 4 填 `0x3D5EA11E`。
- 结果一行 I `T0 POST (<后端>, sustained-lock pattern) PASSED|FAILED - …`,两轮的计数都在这一行。红米(Adreno 830)两后端 PASSED;Mali-G1-Ultra 两后端 FAILED(缺省旋钮下这行降为 D,见上表)。
### server 端存储
@@ -634,8 +634,8 @@ void main() { noBinding.c = afterLayout.a + beforeLayout.b + uint(texelFetch(tex
<< "a samplerBuffer is not a buffer block";
}
// THE REGRESSION THIS MIGRATION EXISTS FOR (7de7cfc6,
// minecraft-1.21.1-neoforge-create-indirect-in-world, both backends). Flywheel's indirect
// THE REGRESSION THIS MIGRATION EXISTS FOR (7de7cfc6, the original capture now replayed as
// minecraft-1.21.1-neoforge-create-indirect-in-world-align1024, both backends). Flywheel's indirect
// engine spells every storage-block binding as a macro, and the scan that used to answer this
// question ran on MACRO-UNEXPANDED text: MobileGL's preprocessing rewrites the source, it does
// not run the C preprocessor, so `binding = _FLW_MODEL_BUFFER_BINDING` reached the scanner
+2 -4
View File
@@ -1,6 +1,6 @@
# 仍开放的债务(跨阶段)
> 路线图只列"有债务、看这里"。每条写明去向;已关闭的历史债与当时的完整债务表见 [`p5b/README.md`](p5b/README.md) 末节。开放问题另见 [`OPEN-QUESTIONS.md`](OPEN-QUESTIONS.md)。更新:2026-09-30(P8 第二波;按债务审查重排)。去向「需裁定」= 等用户定;「可进行」= 随时可开的小修,不依赖别的阶段。
> 路线图只列"有债务、看这里"。每条写明去向;已关闭的历史债与当时的完整债务表见 [`p5b/README.md`](p5b/README.md) 末节。开放问题另见 [`OPEN-QUESTIONS.md`](OPEN-QUESTIONS.md)。更新:2026-09-30(P8 第二波;按债务审查重排。同日:create-indirect 换成派生 fixture `minecraft-1.21.1-neoforge-create-indirect-in-world-align1024`(不是原抓取,16 字节对齐的 SSBO 范围绑定挪到 1024 对齐),ID-P8-14、ID-P8-19 两条关闭——红米两后端 monolith / spawn 全过,Magma spawn 不再丢设备)。去向「需裁定」= 等用户定;「可进行」= 随时可开的小修,不依赖别的阶段。
| 债务 | 去向 |
|---|---|
@@ -18,14 +18,12 @@
| P11 转出(B2):handle 臂的 CPU 读者读采纳 / T0 映射前先落排队常驻写——split 半已由 P8-C 实现(`SplitHostBytesForCpuRead` 的 T0 臂:落写 + `glFinish`,ID-P8-9),但主机无 T0、未能证红 | 需设备验证(红米 Android 集成测试 + static-peek) |
| P11 转出(B2):server 准了 T0 而 client 选了 T2 时,每个存储的 `map_persistent` 等 2 s 再具名拒绝(产品里 grant 与 caps 一致,只在变异下见过) | 可进行(小修:每会话一个「client 不要 T0」提示) |
| P9 转出:Espryt 重铸保留路径上 framebuffer clear 后 `imageLoad` 偶读旧值(主机 3/30,加 barrier 后 0/30;`TextureRemintPullScenario` case C 暂钉 barrier),疑 llvmpipe(ID-P9-11);P11 合并 dev 后 push 单进程臂上也见过一次,`ImageBindableRemintScenario` 同样钉 barrier(ID-P11-6) | 可进行(在红米上不加 barrier 归因) |
| P8 转出(D):应用省略 `glMemoryBarrier` 时,两臂在计算写与顶点着色器读之间都没有依赖(GL 未定义,但真实应用依赖它);D 的每轮屏障在真机上的开销未测;create-indirect 验证不了这两件事(ID-P8-14),需要一个「计算写命令、无应用屏障、不重写」的 fixture | 待归因(需新 fixture) |
| P8 转出(D):应用省略 `glMemoryBarrier` 时,两臂在计算写与顶点着色器读之间都没有依赖(GL 未定义,但真实应用依赖它);D 的每轮屏障在真机上的开销未测;create-indirect(现为派生的 `minecraft-1.21.1-neoforge-create-indirect-in-world-align1024`,内容相同)验证不了这两件事(ID-P8-14),需要一个「计算写命令、无应用屏障、不重写」的 fixture | 待归因(需新 fixture) |
| P8 转出(E):driver-written 标按整张纹理打(`GenerateMipmap` 也打),驱动拒读时连基级也具名拒绝,偏保守;跨格式拷贝 store 不跟随;拒绝仍是会话 Fatal(要改回包状态才能答 `GL_INVALID_OPERATION`) | 小修(按 level 打标);其余按需 |
| P8 转出(B):`PipeCalls.def:260` `GenerateMipmap` 仍是 `kWaitApplied`,裁定 14 的理由(CPU 滤波碰 client 影子)已不成立,可改 `kWaitNone` | 性能工作(协议行为变更,需单独裁定) |
| P8 转出(C):server SSBO 标记过近似(窗口内每个绑定的 SSBO 都标);一个留在 SSBO 绑定上又当 restart EBO 用的 buffer 每次 draw 都回读 | 性能工作 |
| P8 转出(monolith,ID-P8-13):9 条 monolith 缺陷真实内容 0 命中,不在 dev 上修——Espryt `*IndirectCount` / 原生 indirect `gl_BaseVertex` / fp64 收窄读未同步影子;Magma `glMultiDrawArraysIndirectCount` CPU 臂同病;Magma 录制中途 `SyncGpuWrites` → SIGSEGV;Espryt RGB16F / RGB32F CPU 滤波读陈旧影子、R11F / 深度链无视 BASE / MAX;Magma 无 BLIT 颜色格式缺着色器 mip 臂;Espryt 拷贝后 `glGetTexImage` 读拷贝前影子(证据见 `notes/p8/{B,C,D,E}.md`) | P13(monolith 换到已修好的记录臂) |
| P8 转出(monolith,feat,ID-P8-14):feat 的 monolith 臂每次 indirect draw 在命令缓冲有 GPU 写时整 buffer 同步回读(`SyncClientSideVertexArraysForIndirectFetch`,`62bfe461`,dev 无);Magma 的 split 构建 monolith 深度 mip 不传 view 类型,无深度 `BLIT_DST` 的设备上 1D 深度链会拿到 2D view(推断,Release 下断言编译掉,SV) | P13(monolith 换臂) |
| P8 转出(ID-P8-19):create-indirect × Magma × spawn 在红米上由 0.84 变为每次丢设备(该 fixture 的 indirect 命令本身是乱的;推断 D 原生化后乱命令直达 GPU,monolith 臂一直原生、基线上也偶发丢设备);坏命令能打挂 GPU 是 GL 未定义行为,robust buffer access 可兜住 | 待归因(fixture 重抓后复测) |
| P8 转出(ID-P8-14):create-indirect fixture 在桌面上抓(SSBO 偏移对齐 16),Adreno 要求 64,任何臂任何后端都过不了;设备车道记为不适用 | 需要时在对齐 64 的设备上重抓 |
| P8 转出(MD):dev 的 `RingAllocateSlow` 在出错的上下文上无上限地排水(设备上挂在 `glFinish`) | 小修(dev) |
| P8 转出:`LogForwardChannel.APeerThatStopsReadingCostsWarnLinesNotTheCallersTime` 在负载下超时(两次),单跑必过 | 小修(放宽时限或隔离) |
| P8 转出(SV):`gen_pipe_dirty_surface.py` 扫描集成测试源,测试成员名与 GLContext 成员同名(如 `m_parameters`)会静默弄坏它的自检;`.Mip3DValidation.` 在没装校验层的车道上是失败不是跳过 | 小修 / CI 记录 |
+1 -1
View File
@@ -20,7 +20,7 @@ P0 已回答的不再列出(spike A 的域、spike B 的分档、`posix_spawn`
14. **推送模型改变哪些按拉取模式调过的缓存命中率。** 幸存者容量在 P13 重调。一条线索:设备上 26.3 Espryt 的 `sve` ≈ draw 数(每 draw 重发一次 sampler-view 集合),桌面只有 ~0.07/draw;列入 P3b/P4b 优化清单。
15. **monolith 的 `*IndirectCount` 不调 `SyncGpuWrites()` 是不是潜在缺口。** 独立 `dev` 问题,拆分不得借机顺手修。**已答(2026-09-30):是**——P8-C / P8-D 主机 red-once 证实(Espryt `*IndirectCount`、Magma `glMultiDrawArraysIndirectCount` 读到 0);split 半已修(ID-P8-9),monolith 半在 P8 第二波的 dev 包里修(ID-P8-3)。
16. **索引宿主镜像的实际内存占用。** MC / Sodium / Iris 语料里 element-array buffer 总量未测;若显著超 64 MiB,退化路径的频率与代价必须实测。P8。
17. **`create-indirect` fixture 在 Adreno 830 上的失败**是 `dev@81b17c0b` 就有的(基线 APK 复现),不是本分支造成;`rd12` + Magma 在两台 Adreno 830 上的 `scudo::reportMapError` 崩溃同样是 `dev` 侧。两者排除在设备 A/B 之外、留在桌面语料里;P8 要在 `create-indirect` 上断言 `roundtrips-per-frame == 0`,所以 `dev` 的修复在别人的关键路径上。
17. **`create-indirect` fixture 在 Adreno 830 上的失败**是 `dev@81b17c0b` 就有的(基线 APK 复现),不是本分支造成;`rd12` + Magma 在两台 Adreno 830 上的 `scudo::reportMapError` 崩溃同样是 `dev` 侧。两者排除在设备 A/B 之外、留在桌面语料里;P8 要在 `create-indirect` 上断言 `roundtrips-per-frame == 0`,所以 `dev` 的修复在别人的关键路径上。**create-indirect 部分已答(2026-09-30)**:原 fixture 在 `GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT` = 16 的桌面驱动上抓,Flywheel 按 16 摆 scatter 列表;Adreno 830 两后端与 Mali 的 Vulkan 要 64,1,270 次范围绑定全被 `GL_INVALID_VALUE` 拒掉。原 fixture 退役,换成派生的 `minecraft-1.21.1-neoforge-create-indirect-in-world-align1024`(**不是同一个 trace**:`tools/trace_replay/fixture_tools/realign_buffer_ranges.cpp --align 1024` 把这些绑定挪到 1024 对齐的槽,插入 3,812 个调用,目标调用 504631 → 508443;主机 SSIM 与原 fixture 9 位一致)。红米两后端 monolith / spawn 全过;Mali-G1-Ultra 上 Magma 全过(split 臂另修了 T0 POST,见 `CONTRACT-P11.md` POST 节),Espryt 仍 0.848:该机 GLES 驱动顶点阶段 SSBO 上限为 0,Flywheel indirect 的顶点程序链接不了(能力缺失,不是分离缺陷)。
18. **split 两侧的负载平衡。** P5e 解锁出来的新问题:VD32(~3550 draws/帧)下 apply 线程 **11-12 ms**、client **15.7 ms**,**client 是瓶颈且打满 ~94%**。把工作从 client 挪到 apply 会直接降瓶颈——这在 lockstep 下毫无意义(两侧串行相加),**run-ahead 才使它成为一个杠杆**。供选:编码侧的 emitter、tracker 走查、持久映射的脏页追踪(`change_protection` 在侧写里占 1.3%)。需先重新侧写:等待消失后尾部各项的分母都变了。排在 P5e 之后;无主,2026-09-22 建议挂在路线图推完后的优化阶段,P6.5 的 2×2 矩阵车道顺带重新侧写
19. **链路带宽预算与压缩。** TCP 终局下 `SEG_STAGE` 字节/帧对的是 Wi-Fi / USB(量级 30–100 MB/s),不是内存;`ARCHITECTURE.md` §14 的 ~1 MB/帧预算在 60 fps 是 60 MB/s,已贴着 Wi-Fi 上限。是否对 stage 载荷做 LZ4 类压缩、纹理上传是否按内容哈希在 server 侧去重,要等门 8 的分布出来再定。P6.5 契约写下第一行之前必答。
20. **大单次上传的停顿。** 128 MiB 一次上传在 50 MB/s 上是 2.5 s;内容侧分块解决的是"装不装得下",不是"要等多久"。跨机臂上要么接受并记录,要么给上传做异步化(与 P9 的语义一起想)。不假装解决。
+12 -4
View File
@@ -124,10 +124,18 @@ The bundled fixtures cover:
- minecraft-1.21.4-fabric-iris-sundial-lite-in-world: captured from Minecraft 1.21.4 Fabric with Sodium, Iris, and
Sundial Lite after entering a singleplayer world.
![Minecraft 1.21.4 Fabric Iris Sundial Lite in-world golden](fixtures/minecraft-1.21.4-fabric-iris-sundial-lite-in-world.0000150023.png)
- minecraft-1.21.1-neoforge-create-indirect-in-world: captured from Minecraft 1.21.1 NeoForge with Create, Sodium,
and Iris (no shader pack) in a world facing Create water wheels and a large cogwheel, with Flywheel's
`flywheel:indirect` backend (compute-shader culling, glMultiDrawElementsIndirect, persistent-mapped staging).
![Minecraft 1.21.1 NeoForge Create indirect in-world golden](fixtures/minecraft-1.21.1-neoforge-create-indirect-in-world.0000504631.png)
- minecraft-1.21.1-neoforge-create-indirect-in-world-align1024: **not an original capture** - derived from the retired
`minecraft-1.21.1-neoforge-create-indirect-in-world` capture (Minecraft 1.21.1 NeoForge with Create, Sodium, and
Iris (no shader pack) in a world facing Create water wheels and a large cogwheel, with Flywheel's
`flywheel:indirect` backend: compute-shader culling, glMultiDrawElementsIndirect, persistent-mapped staging). That
capture came from a desktop driver whose `GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT` is 16, so Flywheel bound its
scatter lists at 16-byte offsets, and a driver that requires more (Adreno 830: 64) rejects every one of those binds
with `GL_INVALID_VALUE`. [`fixture_tools/realign_buffer_ranges.cpp`](fixture_tools/realign_buffer_ranges.cpp)
`--align 1024` rewrote it: each of the 1,270 range binds off a 1024-byte boundary now binds a 1024-aligned slot of
an added buffer that is filled with the same bytes right before the dispatch that reads them. The 3,812 inserted
calls renumber the trace (target call 504631 -> 508443); the golden is the original one (the same frame), and the
host replay matches it with the original's SSIM to 9 digits on both backends.
![Minecraft 1.21.1 NeoForge Create indirect (align 1024) in-world golden](fixtures/minecraft-1.21.1-neoforge-create-indirect-in-world-align1024.0000508443.png)
- minecraft-1.21.1-neoforge-create-instancing-in-world: same world and camera as the indirect case, with Flywheel's
`flywheel:instancing` backend (texture-buffer instance data, glDrawElementsInstancedBaseVertex).
![Minecraft 1.21.1 NeoForge Create instancing in-world golden](fixtures/minecraft-1.21.1-neoforge-create-instancing-in-world.0000530333.png)
@@ -0,0 +1,432 @@
// realign_buffer_ranges: make a GL trace's indexed uniform / storage buffer range binds portable.
//
// An app sizes glBindBufferRange offsets by the GL_{UNIFORM,SHADER_STORAGE}_BUFFER_OFFSET_ALIGNMENT
// of the driver it was captured on (Flywheel's staging scatter lists: 16 on desktop). A driver that
// requires more rejects those binds with GL_INVALID_VALUE. This tool rewrites every such bind whose
// offset is not a multiple of --align:
// - the bind itself becomes glBindBuffer(target, buffer) (the generic binding it also set);
// - right before the next draw / dispatch, the bytes the range holds at that point are uploaded into a
// fresh --align-aligned slot of one relocation buffer, and that slot is bound at the same index.
// The bytes come from the trace itself (buffer data / subdata and the persistent-map memcpy commits), so a
// source buffer written any other way (GPU copies, clears) is refused rather than guessed.
//
// Inserting calls renumbers every later call: --map-call N prints where original call N landed (a case's
// target_call). The output is snappy-compressed; `apitrace repack --brotli` it before packaging.
//
// Build (A = 3rdparty/apitrace, B = a Release build of it, e.g. `cmake -S $A -B $B -G Ninja -DENABLE_GUI=OFF
// && ninja -C $B apitrace`):
// g++ -std=c++17 -O2 -flto=auto -fno-rtti -fno-exceptions -I$A/lib/trace -I$A/lib/os -I$B -I$B/lib/trace \
// realign_buffer_ranges.cpp -o realign_buffer_ranges $B/lib/trace/libcommon.a $B/lib/guids/libguids.a \
// $B/lib/highlight/libhighlight.a $B/lib/os/libos.a $B/thirdparty/libbacktrace.a $B/thirdparty/libsnappy.a \
// $B/thirdparty/libzstd_seekable.a -lbrotlidec -lbrotlienc -lz -lzstd -lpthread -ldl
// Usage: realign_buffer_ranges [--align N] [--map-call N]... in.trace out.trace
#include <algorithm>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#include "trace_model.hpp"
#include "trace_parser.hpp"
#include "trace_writer.hpp"
namespace {
constexpr unsigned kUniformBuffer = 0x8A11;
constexpr unsigned kShaderStorageBuffer = 0x90D2;
constexpr unsigned kDynamicStorageBit = 0x0100;
constexpr unsigned kRelocBufferName = 1000000;
[[noreturn]] void Fail(const trace::Call *call, const std::string &what) {
std::fprintf(stderr, "error: call %u %s: %s\n", call ? call->no : 0u, call ? call->name() : "-", what.c_str());
std::exit(1);
}
bool Is(const trace::Call *call, const char *name) { return std::strcmp(call->name(), name) == 0; }
bool StartsWith(const char *s, const char *prefix) { return std::strncmp(s, prefix, std::strlen(prefix)) == 0; }
bool ReadsIndexedBuffers(const trace::Call *call) {
const char *n = call->name();
return StartsWith(n, "glDraw") || StartsWith(n, "glMultiDraw") || StartsWith(n, "glDispatchCompute");
}
bool IsRangeTarget(unsigned target) { return target == kUniformBuffer || target == kShaderStorageBuffer; }
struct MapRegion {
unsigned buffer;
uint64_t offset;
uint64_t length;
uint64_t ptr;
};
struct Reloc {
unsigned src = 0;
uint64_t offset = 0;
uint64_t size = 0;
bool dirty = true;
std::vector<char> last;
const trace::EnumSig *targetSig = nullptr;
};
// Signatures for the calls this tool inserts; ids are allocated past the trace's own.
struct Sigs {
const char *createNames[2] = {"n", "buffers"};
const char *storageNames[4] = {"buffer", "size", "data", "flags"};
const char *subDataNames[4] = {"buffer", "offset", "size", "data"};
const char *bindRangeNames[5] = {"target", "index", "buffer", "offset", "size"};
const char *bindNames[2] = {"target", "buffer"};
trace::FunctionSig create{}, storage{}, subData{}, bindRange{}, bind{};
void Init(trace::Id firstId) {
create = {firstId + 0, "glCreateBuffers", 2, createNames};
storage = {firstId + 1, "glNamedBufferStorage", 4, storageNames};
subData = {firstId + 2, "glNamedBufferSubData", 4, subDataNames};
bindRange = {firstId + 3, "glBindBufferRange", 5, bindRangeNames};
bind = {firstId + 4, "glBindBuffer", 2, bindNames};
}
};
class Rewriter {
public:
uint64_t align = 1024;
std::set<unsigned> mapCalls;
int Run(const char *in, const char *out) {
Scan(in);
if (relocSrc_.empty()) {
std::fprintf(stderr, "nothing to realign at %llu bytes\n", (unsigned long long)align);
return 2;
}
sigs_.Init(maxSigId_ + 1);
stride_ = (maxRelocSize_ + align - 1) / align * align;
Pass(in, nullptr); // dry run: count the slots
slotCap_ = slotsUsed_;
Pass(in, out);
std::fprintf(stderr,
"realigned %llu binds of %zu source buffer(s) to %llu bytes: %llu uploads, relocation buffer %llu "
"bytes, %llu calls inserted\n",
(unsigned long long)relocBinds_, relocSrc_.size(), (unsigned long long)align,
(unsigned long long)slotsUsed_, (unsigned long long)(slotCap_ * stride_),
(unsigned long long)inserted_);
for (const auto &m : callMap_) {
std::printf("call %u -> %llu\n", m.first, (unsigned long long)m.second);
}
return 0;
}
private:
// Pass 0: which buffers need relocating, and the sizes involved.
void Scan(const char *in) {
trace::Parser p;
if (!p.open(in)) Fail(nullptr, std::string("cannot open ") + in);
trace::Call *call;
while ((call = p.parse_call())) {
maxSigId_ = std::max(maxSigId_, call->sig->id);
if (Is(call, "glBindBufferRange")) {
unsigned target = unsigned(call->arg(0).toSInt());
uint64_t offset = uint64_t(call->arg(3).toSInt());
if (IsRangeTarget(target) && offset % align != 0) {
relocSrc_.insert(unsigned(call->arg(2).toUInt()));
maxRelocSize_ = std::max(maxRelocSize_, uint64_t(call->arg(4).toSInt()));
}
} else if (Is(call, "glBindBuffersRange")) {
unsigned target = unsigned(call->arg(0).toSInt());
const trace::Array *offsets = call->arg(4).toArray();
if (IsRangeTarget(target) && offsets) {
for (const trace::Value *v : offsets->values) {
if (uint64_t(v->toSInt()) % align != 0) Fail(call, "misaligned glBindBuffersRange is not handled");
}
}
}
delete call;
}
}
void Pass(const char *in, const char *out) {
trace::Parser p;
if (!p.open(in)) Fail(nullptr, std::string("cannot open ") + in);
trace::Writer writer;
writer_ = nullptr;
if (out) {
if (!writer.open(out, p.getVersion(), p.getProperties())) Fail(nullptr, std::string("cannot create ") + out);
writer_ = &writer;
}
shadow_.clear();
maps_.clear();
generic_.clear();
relocs_.clear();
slotsUsed_ = 0;
relocBinds_ = 0;
inserted_ = 0;
created_ = false;
trace::Call *call;
while ((call = p.parse_call())) {
Process(call);
delete call;
}
if (writer_) writer.close();
writer_ = nullptr;
}
unsigned BufferArg(trace::Call *call, unsigned index) { return unsigned(call->arg(index).toUInt()); }
unsigned Generic(unsigned target) {
auto it = generic_.find(target);
return it == generic_.end() ? 0 : it->second;
}
std::vector<char> *Shadow(unsigned buffer) {
auto it = shadow_.find(buffer);
return it == shadow_.end() ? nullptr : &it->second;
}
void Specify(trace::Call *call, unsigned buffer, uint64_t size, trace::Value *data) {
if (!relocSrc_.count(buffer)) return;
std::vector<char> &s = shadow_[buffer];
s.assign(size, 0);
const trace::Blob *blob = data ? data->toBlob() : nullptr;
if (blob) std::memcpy(s.data(), blob->buf, std::min<uint64_t>(size, blob->size));
for (auto &r : relocs_) {
if (r.second.src == buffer) r.second.dirty = true;
}
(void)call;
}
void Write(trace::Call *call, unsigned buffer, uint64_t offset, const char *bytes, uint64_t size) {
std::vector<char> *s = Shadow(buffer);
if (!s) return;
if (offset + size > s->size()) Fail(call, "write past the end of a tracked buffer");
std::memcpy(s->data() + offset, bytes, size);
}
void Refuse(trace::Call *call, unsigned buffer) {
if (relocSrc_.count(buffer)) Fail(call, "writes a relocated source buffer in a way the trace does not carry the bytes of");
}
void Emit(trace::Call *call) {
if (!writer_) return;
if (mapCalls.count(call->no)) callMap_[call->no] = writtenCalls_;
writer_->writeCall(call);
++writtenCalls_;
}
void EmitNew(trace::Call *call) {
++inserted_;
if (writer_) {
writer_->writeCall(call);
++writtenCalls_;
}
delete call;
}
trace::Call *NewCall(const trace::FunctionSig *sig, unsigned thread) {
return new trace::Call(sig, trace::CallFlags(0), thread);
}
void EmitBind(unsigned thread, const trace::EnumSig *targetSig, unsigned target, unsigned buffer) {
trace::Call *c = NewCall(&sigs_.bind, thread);
c->args[0].value = targetSig ? static_cast<trace::Value *>(new trace::Enum(targetSig, target))
: static_cast<trace::Value *>(new trace::SInt(target));
c->args[1].value = new trace::UInt(buffer);
EmitNew(c);
}
void CreateRelocBuffer(unsigned thread) {
trace::Call *c = NewCall(&sigs_.create, thread);
c->args[0].value = new trace::SInt(1);
trace::Array *names = new trace::Array(1);
names->values[0] = new trace::UInt(kRelocBufferName);
c->args[1].value = names;
EmitNew(c);
c = NewCall(&sigs_.storage, thread);
c->args[0].value = new trace::UInt(kRelocBufferName);
c->args[1].value = new trace::SInt(int64_t(slotCap_ * stride_));
c->args[2].value = new trace::Null();
c->args[3].value = new trace::UInt(kDynamicStorageBit);
EmitNew(c);
created_ = true;
}
void Upload(trace::Call *before, unsigned target, unsigned index, Reloc &r) {
std::vector<char> *s = Shadow(r.src);
if (!s) Fail(before, "a relocated range reads a buffer whose storage the trace never specified");
if (r.offset + r.size > s->size()) Fail(before, "a relocated range runs past its buffer");
std::vector<char> bytes(s->begin() + r.offset, s->begin() + r.offset + r.size);
if (!r.dirty && bytes == r.last) return;
unsigned thread = before->thread_id;
if (writer_ && slotsUsed_ >= slotCap_) Fail(before, "relocation slots exceeded the dry run");
uint64_t slotOffset = slotsUsed_++ * stride_;
if (!created_) CreateRelocBuffer(thread);
trace::Call *c = NewCall(&sigs_.subData, thread);
c->args[0].value = new trace::UInt(kRelocBufferName);
c->args[1].value = new trace::SInt(int64_t(slotOffset));
c->args[2].value = new trace::SInt(int64_t(r.size));
trace::Blob *blob = new trace::Blob(r.size);
std::memcpy(blob->buf, bytes.data(), r.size);
c->args[3].value = blob;
EmitNew(c);
c = NewCall(&sigs_.bindRange, thread);
c->args[0].value = r.targetSig ? static_cast<trace::Value *>(new trace::Enum(r.targetSig, target))
: static_cast<trace::Value *>(new trace::SInt(target));
c->args[1].value = new trace::UInt(index);
c->args[2].value = new trace::UInt(kRelocBufferName);
c->args[3].value = new trace::SInt(int64_t(slotOffset));
c->args[4].value = new trace::SInt(int64_t(r.size));
EmitNew(c);
// glBindBufferRange also moved the generic binding; put back the app's.
EmitBind(thread, r.targetSig, target, Generic(target));
r.last = std::move(bytes);
r.dirty = false;
}
void Process(trace::Call *call) {
const char *n = call->name();
if (Is(call, "glBindBuffer")) {
generic_[unsigned(call->arg(0).toSInt())] = BufferArg(call, 1);
} else if (Is(call, "glBindBufferBase")) {
unsigned target = unsigned(call->arg(0).toSInt());
generic_[target] = BufferArg(call, 2);
relocs_.erase({target, unsigned(call->arg(1).toUInt())});
} else if (Is(call, "glBindBufferRange")) {
unsigned target = unsigned(call->arg(0).toSInt());
unsigned index = unsigned(call->arg(1).toUInt());
unsigned buffer = BufferArg(call, 2);
uint64_t offset = uint64_t(call->arg(3).toSInt());
generic_[target] = buffer;
if (IsRangeTarget(target) && offset % align != 0) {
Reloc r;
r.src = buffer;
r.offset = offset;
r.size = uint64_t(call->arg(4).toSInt());
trace::Value &t = call->arg(0);
trace::Enum *e = nullptr;
// Enum values print by name in dumps; keep the trace's own enum signature when it has one.
struct EnumProbe : trace::Visitor {
trace::Enum *found = nullptr;
void visit(trace::Enum *node) override { found = node; }
} probe;
t.visit(probe);
e = probe.found;
r.targetSig = e ? e->sig : nullptr;
relocs_[{target, index}] = std::move(r);
++relocBinds_;
if (mapCalls.count(call->no) && writer_) callMap_[call->no] = writtenCalls_;
// Only the generic binding survives at this point; the indexed one is bound before its first read.
EmitBind(call->thread_id, e ? e->sig : nullptr, target, buffer);
--inserted_; // a replacement, not an insertion
return;
}
relocs_.erase({target, index});
} else if (Is(call, "glBindBuffersBase") || Is(call, "glBindBuffersRange")) {
unsigned target = unsigned(call->arg(0).toSInt());
unsigned first = unsigned(call->arg(1).toUInt());
unsigned count = unsigned(call->arg(2).toSInt());
for (unsigned i = first; i < first + count; ++i) relocs_.erase({target, i});
} else if (Is(call, "glNamedBufferStorage") || Is(call, "glNamedBufferData")) {
Specify(call, BufferArg(call, 0), uint64_t(call->arg(1).toSInt()), &call->arg(2));
} else if (Is(call, "glBufferStorage") || Is(call, "glBufferData")) {
Specify(call, Generic(unsigned(call->arg(0).toSInt())), uint64_t(call->arg(1).toSInt()), &call->arg(2));
} else if (Is(call, "glNamedBufferSubData") || Is(call, "glBufferSubData")) {
unsigned buffer = Is(call, "glNamedBufferSubData") ? BufferArg(call, 0) : Generic(unsigned(call->arg(0).toSInt()));
if (relocSrc_.count(buffer)) {
const trace::Blob *blob = call->arg(3).toBlob();
if (!blob) Fail(call, "subdata without bytes");
Write(call, buffer, uint64_t(call->arg(1).toSInt()), blob->buf,
std::min<uint64_t>(uint64_t(call->arg(2).toSInt()), blob->size));
}
} else if (Is(call, "glCopyNamedBufferSubData")) {
Refuse(call, BufferArg(call, 1));
} else if (Is(call, "glCopyBufferSubData")) {
Refuse(call, Generic(unsigned(call->arg(1).toSInt())));
} else if (StartsWith(n, "glClearNamedBuffer")) {
Refuse(call, BufferArg(call, 0));
} else if (StartsWith(n, "glClearBuffer") && (StartsWith(n, "glClearBufferData") || StartsWith(n, "glClearBufferSubData"))) {
Refuse(call, Generic(unsigned(call->arg(0).toSInt())));
} else if (Is(call, "glMapNamedBufferRange") || Is(call, "glMapBufferRange")) {
unsigned buffer = Is(call, "glMapNamedBufferRange") ? BufferArg(call, 0) : Generic(unsigned(call->arg(0).toSInt()));
if (relocSrc_.count(buffer) && call->ret) {
maps_.push_back({buffer, uint64_t(call->arg(1).toSInt()), uint64_t(call->arg(2).toSInt()),
call->ret->toUIntPtr()});
}
} else if (Is(call, "glMapNamedBuffer") || Is(call, "glMapBuffer")) {
unsigned buffer = Is(call, "glMapNamedBuffer") ? BufferArg(call, 0) : Generic(unsigned(call->arg(0).toSInt()));
std::vector<char> *s = Shadow(buffer);
if (s && call->ret) maps_.push_back({buffer, 0, s->size(), call->ret->toUIntPtr()});
} else if (Is(call, "glUnmapNamedBuffer") || Is(call, "glUnmapBuffer")) {
unsigned buffer = Is(call, "glUnmapNamedBuffer") ? BufferArg(call, 0) : Generic(unsigned(call->arg(0).toSInt()));
maps_.erase(std::remove_if(maps_.begin(), maps_.end(), [&](const MapRegion &m) { return m.buffer == buffer; }),
maps_.end());
} else if (Is(call, "memcpy")) {
uint64_t dest = call->arg(0).toUIntPtr();
const trace::Blob *blob = call->arg(1).toBlob();
uint64_t size = call->arg(2).toUInt();
if (blob) {
size = std::min<uint64_t>(size, blob->size);
for (const MapRegion &m : maps_) {
uint64_t lo = std::max(dest, m.ptr);
uint64_t hi = std::min(dest + size, m.ptr + m.length);
if (lo >= hi) continue;
Write(call, m.buffer, m.offset + (lo - m.ptr), blob->buf + (lo - dest), hi - lo);
}
}
} else if (ReadsIndexedBuffers(call)) {
for (auto &r : relocs_) Upload(call, r.first.first, r.first.second, r.second);
}
Emit(call);
}
Sigs sigs_;
trace::Id maxSigId_ = 0;
std::set<unsigned> relocSrc_;
uint64_t maxRelocSize_ = 0;
uint64_t stride_ = 0;
uint64_t slotCap_ = 0;
uint64_t slotsUsed_ = 0;
uint64_t relocBinds_ = 0;
uint64_t inserted_ = 0;
uint64_t writtenCalls_ = 0;
bool created_ = false;
trace::Writer *writer_ = nullptr;
std::unordered_map<unsigned, std::vector<char>> shadow_;
std::vector<MapRegion> maps_;
std::unordered_map<unsigned, unsigned> generic_;
std::map<std::pair<unsigned, unsigned>, Reloc> relocs_;
std::map<unsigned, uint64_t> callMap_;
};
} // namespace
int main(int argc, char **argv) {
Rewriter rw;
std::vector<const char *> files;
for (int i = 1; i < argc; ++i) {
if (!std::strcmp(argv[i], "--align") && i + 1 < argc) {
rw.align = std::strtoull(argv[++i], nullptr, 0);
} else if (!std::strcmp(argv[i], "--map-call") && i + 1 < argc) {
rw.mapCalls.insert(unsigned(std::strtoul(argv[++i], nullptr, 0)));
} else {
files.push_back(argv[i]);
}
}
if (files.size() != 2 || rw.align == 0) {
std::fprintf(stderr, "usage: %s [--align N] [--map-call N]... in.trace out.trace\n", argv[0]);
return 1;
}
return rw.Run(files[0], files[1]);
}
+5 -4
View File
@@ -268,10 +268,11 @@
"target_call": 145353
},
{
"name": "minecraft-1.21.1-neoforge-create-indirect-in-world",
"trace_archive": "minecraft-1.21.1-neoforge-create-indirect-in-world.tgz",
"golden": "minecraft-1.21.1-neoforge-create-indirect-in-world.0000504631.png",
"target_call": 504631,
"name": "minecraft-1.21.1-neoforge-create-indirect-in-world-align1024",
"derived_from": "minecraft-1.21.1-neoforge-create-indirect-in-world (the original desktop capture, retired): NOT the same trace - its 16-byte-aligned uniform/storage buffer range binds were relocated to 1024-aligned slots by tools/trace_replay/fixture_tools/realign_buffer_ranges.cpp --align 1024, which inserts calls and renumbers them (original target_call 504631)",
"trace_archive": "minecraft-1.21.1-neoforge-create-indirect-in-world-align1024.tgz",
"golden": "minecraft-1.21.1-neoforge-create-indirect-in-world-align1024.0000508443.png",
"target_call": 508443,
"timeout_seconds": 1800,
"coherent_as_flush": true
},
+2
View File
@@ -40,6 +40,8 @@ KNOWN_CASE_KEYS = frozenset({
"split",
"avoid_angle_llvmpipe_explicit_lod_bias",
"backend_overrides",
# Documentation only - which trace a derived fixture was made from, and how. Nothing reads it.
"derived_from",
})
# The only fields a per-backend block may restate. Deliberately three: they are the three the