Repository navigation
fix(agc): accept unaligned shader headers in ABI resolution - #4809
Conversation
Gran Turismo 7 (PPSA01317) passes shader headers at 4-byte aligned addresses to sceAgcUnknownCreateInterpolantMapping. RegisterShader already reads them through a copy (boykopovar#902); ResolveShaderAbi, ResolveGraphicsStagesAbi, ResolveGraphicsAbi and RegisteredHeader still required 8-byte alignment and threw "null or misaligned address". Read the fixed fields through GuestShaderFields at those sites.
|
I had prepared the same fix on my own branch (not pushed), so I won't open a duplicate. While testing it I found two things that might be worth adding here:
ShaderRegister GuestShaderRegister(const ShaderRegister* registers, std::size_t index) {
ShaderRegister reg;
std::memcpy(®, static_cast<const void*>(registers + index), sizeof(reg));
return reg;
}
// tests/Submit.cpp, testShaderHeaderAlignment, after the registration loop
for (const std::size_t offset : {4, 1}) AgcDriverResolveShaderAbi_nid_postfix(at(offset, shader), {}, {});
// tests/execution/PreparedShaders.cpp, SharedCodeHeaders, after resolving `copy`
alignas(8) std::array<std::byte, sizeof(Shader) + 4> unaligned{};
for (const std::size_t offset : {4, 1}) {
std::memcpy(unaligned.data() + offset, ©, sizeof(copy));
AgcDriverResolveShaderAbi_nid_postfix(reinterpret_cast<const Shader*>(unaligned.data() + offset), {}, primitive);
}On AI-assisted (Claude Code). |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
|
A run on GPU hardware, since the description and the comment above used lavapipe. Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU. The head 1988607 merged into
Written with AI assistance. |
What
Carries the shader-header alignment fix from the second patch attached to #4782. ABI resolution and registered-header lookup now copy the fixed
Shaderfields into an aligned local object before reading them. This lets those paths handle guest headers whose addresses are not naturally aligned, while preserving the existing guest-memory range check.Extends
PreparedShaderswith a header address four bytes off its natural alignment and exercises ABI resolution through it. The unrelated exports/library patch from #4782 is not included.#4043 and #2589 also touch
ShaderRegistry.cppand/orPreparedShaders.cpp, but address relocated snapshots and background ABI compilation. This change has no dependency on either PR; the file overlap is disclosed for rebasing coordination.Tested
BUILD_TESTING=ON: builtagc_driver_prepared_shaders_tests, including the changedShaderRegistry.cppandPreparedShaders.cpp.mesa-vulkan-drivers22.3.6):agc_driver_prepared_shaderspassed (1/1).python3 tools/check_conventions.py --base upstream/mainandgit diff --check upstream/main...HEAD: passed.Checklist
main; no open PR implements the same alignment behaviorNotImplemented_nid_no_patch); no new silent stubs.mdfiles or images added to the repository